Skip to content

Commit

Permalink
fix: regression in 'NoEstimateAvailable' check (#1785)
Browse files Browse the repository at this point in the history
* fix: regression in 'NoEstimateAvailable' check

* ci: bump nodejs version

* chore: lint fix
  • Loading branch information
zone117x authored Feb 3, 2025
1 parent 1d7d280 commit a079a74
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/transactions/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,16 @@ export async function fetchFeeEstimateTransaction({
const response = await client.fetch(url, options);

if (!response.ok) {
const body = await response.json().catch(() => ({}));

if (body?.reason === 'NoEstimateAvailable') {
throw new NoEstimateAvailableError(body?.reason_data?.message ?? '');
const body = await response.text().catch(() => '');

if (body.includes('NoEstimateAvailable')) {
let json: { reason_data?: { message?: string } } = {};
try {
json = JSON.parse(body);
} catch (err) {
// ignore
}
throw new NoEstimateAvailableError(json?.reason_data?.message ?? '');
}

throw new Error(
Expand Down

0 comments on commit a079a74

Please sign in to comment.