diff --git a/changelogs/3.0.26.txt b/changelogs/3.0.26.txt new file mode 100644 index 0000000..619f4cd --- /dev/null +++ b/changelogs/3.0.26.txt @@ -0,0 +1 @@ +Bug fixes and performance improvements diff --git a/package-lock.json b/package-lock.json index 9967d49..5e909d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mytonwallet", - "version": "3.0.25", + "version": "3.0.26", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mytonwallet", - "version": "3.0.25", + "version": "3.0.26", "license": "GPL-3.0-or-later", "dependencies": { "@awesome-cordova-plugins/core": "6.8.0", diff --git a/package.json b/package.json index d9759ad..6f15656 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mytonwallet", - "version": "3.0.25", + "version": "3.0.26", "description": "The most feature-rich web wallet and browser extension for TON – with support of multi-accounts, tokens (jettons), NFT, TON DNS, TON Sites, TON Proxy, and TON Magic.", "main": "index.js", "scripts": { diff --git a/public/version.txt b/public/version.txt index de2e889..2551016 100644 --- a/public/version.txt +++ b/public/version.txt @@ -1 +1 @@ -3.0.25 +3.0.26 diff --git a/src/api/chains/ton/tokens.ts b/src/api/chains/ton/tokens.ts index 17798c4..d9e8b37 100644 --- a/src/api/chains/ton/tokens.ts +++ b/src/api/chains/ton/tokens.ts @@ -8,7 +8,7 @@ import type { import { TINY_TOKENS } from '../../../config'; import { parseAccountId } from '../../../util/account'; -import { fetchJson } from '../../../util/fetch'; +import { fetchJsonWithProxy } from '../../../util/fetch'; import { logDebugError } from '../../../util/logs'; import { fixIpfsUrl } from '../../../util/metadata'; import { @@ -293,7 +293,7 @@ export async function checkMintlessTokenWalletIsClaimed(network: ApiNetwork, tok async function fetchMintlessTokenWalletData(customPayloadApiUrl: string, address: string) { const rawAddress = toRawAddress(address); - return (await fetchJson(`${customPayloadApiUrl}/wallet/${rawAddress}`).catch(() => undefined)) as { + return (await fetchJsonWithProxy(`${customPayloadApiUrl}/wallet/${rawAddress}`).catch(() => undefined)) as { custom_payload: string; state_init: string; compressed_info: { diff --git a/src/util/fetch.ts b/src/util/fetch.ts index c3467c8..bc1914d 100644 --- a/src/util/fetch.ts +++ b/src/util/fetch.ts @@ -1,4 +1,6 @@ -import { DEFAULT_ERROR_PAUSE, DEFAULT_RETRIES, DEFAULT_TIMEOUT } from '../config'; +import { + BRILLIANT_API_BASE_URL, DEFAULT_ERROR_PAUSE, DEFAULT_RETRIES, DEFAULT_TIMEOUT, +} from '../config'; import { ApiServerError } from '../api/errors'; import { logDebug } from './logs'; import { pause } from './schedulers'; @@ -7,6 +9,17 @@ type QueryParams = Record; const MAX_TIMEOUT = 30000; // 30 sec +export async function fetchJsonWithProxy(url: string | URL, data?: QueryParams, init?: RequestInit) { + try { + return await fetchJson(url, data, init); + } catch (err) { + if (err instanceof ApiServerError && (!err.statusCode || err.statusCode === 403)) { + return fetchJson(`${BRILLIANT_API_BASE_URL}/proxy/?url=${url.toString()}`, data, init); + } + throw err; + } +} + export async function fetchJson(url: string | URL, data?: QueryParams, init?: RequestInit) { const urlObject = new URL(url); if (data) {