From 64cf55d64ee164775e06cc8bb6090227a8b629ea Mon Sep 17 00:00:00 2001 From: Corey-Code <37006206+Corey-Code@users.noreply.github.com> Date: Thu, 22 Oct 2026 14:26:25 -0400 Subject: [PATCH] Simulate BeeZee fees on the chain REST instead of the dead proxy. --- src/lib/cosmos/fees.ts | 12 +++++++----- tests/lib/cosmos/fees.test.ts | 13 +++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 tests/lib/cosmos/fees.test.ts diff --git a/src/lib/cosmos/fees.ts b/src/lib/cosmos/fees.ts index f983e8e..044e583 100644 --- a/src/lib/cosmos/fees.ts +++ b/src/lib/cosmos/fees.ts @@ -42,8 +42,6 @@ export interface SimulateResult { gasWanted: number; } -const BZE_SIMULATE_PROXY_URL = 'https://api.vidulum.app/bze/cosmos/tx/v1beta1/simulate'; - // Cache for params let tradebinParamsCache: TradebinParams | null = null; let tradebinParamsCacheTime = 0; @@ -148,6 +146,12 @@ export function parseFeeString(feeStr: string): { amount: string; denom: string return { amount: '0', denom: 'ubze' }; } +/** Chain REST simulate path. BeeZee answers this directly; do not proxy it. */ +export function cosmosSimulateUrl(restEndpoint: string): string { + const base = restEndpoint.replace(/\/$/, ''); + return `${base}/cosmos/tx/v1beta1/simulate`; +} + /** * Simulate a transaction to get accurate gas estimate */ @@ -166,9 +170,7 @@ export async function simulateTransaction( const txBytes = TxRaw.encode(txRaw).finish(); - const simulateUrl = restEndpoint.includes('rest.getbze.com') - ? BZE_SIMULATE_PROXY_URL - : `${restEndpoint}/cosmos/tx/v1beta1/simulate`; + const simulateUrl = cosmosSimulateUrl(restEndpoint); const response = await fetch(simulateUrl, { method: 'POST', diff --git a/tests/lib/cosmos/fees.test.ts b/tests/lib/cosmos/fees.test.ts new file mode 100644 index 0000000..83159b2 --- /dev/null +++ b/tests/lib/cosmos/fees.test.ts @@ -0,0 +1,13 @@ +import { cosmosSimulateUrl } from '@/lib/cosmos/fees'; + +describe('cosmosSimulateUrl', () => { + it('asks BeeZee REST directly', () => { + expect(cosmosSimulateUrl('https://rest.getbze.com')).toBe( + 'https://rest.getbze.com/cosmos/tx/v1beta1/simulate' + ); + expect(cosmosSimulateUrl('https://rest.getbze.com/')).toBe( + 'https://rest.getbze.com/cosmos/tx/v1beta1/simulate' + ); + expect(cosmosSimulateUrl('https://rest.getbze.com')).not.toContain('api.vidulum.app'); + }); +});