@rash2x/bridge-widget 0.8.9 → 0.8.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/evaa-bridge.cjs +1 -1
- package/dist/evaa-bridge.mjs +1 -1
- package/dist/{index-Bl4_W_Mc.js → index-BNr-8fA_.js} +2 -2
- package/dist/{index-Bl4_W_Mc.js.map → index-BNr-8fA_.js.map} +1 -1
- package/dist/{index-BLnE8fLp.cjs → index-CdXk0Wlz.cjs} +105 -49
- package/dist/index-CdXk0Wlz.cjs.map +1 -0
- package/dist/{index--9cCU23B.cjs → index-Cm-9-5dT.cjs} +2 -2
- package/dist/{index--9cCU23B.cjs.map → index-Cm-9-5dT.cjs.map} +1 -1
- package/dist/{index-IZ7t2PGj.js → index-DnqFAL14.js} +105 -49
- package/dist/index-DnqFAL14.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-BLnE8fLp.cjs.map +0 -1
- package/dist/index-IZ7t2PGj.js.map +0 -1
|
@@ -3256,6 +3256,11 @@ function isEvmBalanceDebugEnabled() {
|
|
|
3256
3256
|
const flag = window.localStorage.getItem("evaa.debugBalances");
|
|
3257
3257
|
return flag === "1" || flag === "true";
|
|
3258
3258
|
}
|
|
3259
|
+
function isRpcTransportError(error) {
|
|
3260
|
+
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
3261
|
+
const normalized = message.toLowerCase();
|
|
3262
|
+
return normalized.includes("err_name_not_resolved") || normalized.includes("dns") || normalized.includes("failed to fetch") || normalized.includes("fetch failed") || normalized.includes("networkerror") || normalized.includes("timeout");
|
|
3263
|
+
}
|
|
3259
3264
|
async function getEvmBalances(publicClient, address, tokens) {
|
|
3260
3265
|
const balances = {};
|
|
3261
3266
|
const debugRows = [];
|
|
@@ -3273,7 +3278,7 @@ async function getEvmBalances(publicClient, address, tokens) {
|
|
|
3273
3278
|
const chainNative = publicClient.chain?.nativeCurrency;
|
|
3274
3279
|
const nativeSymbol = chainNative?.symbol ?? "ETH";
|
|
3275
3280
|
const nativeDecimals = chainNative?.decimals ?? 18;
|
|
3276
|
-
const maxAttempts =
|
|
3281
|
+
const maxAttempts = 1;
|
|
3277
3282
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
3278
3283
|
try {
|
|
3279
3284
|
const nativeBalance = await publicClient.getBalance({
|
|
@@ -3425,6 +3430,12 @@ async function getEvmBalances(publicClient, address, tokens) {
|
|
|
3425
3430
|
"Multicall failed, falling back to individual calls:",
|
|
3426
3431
|
error
|
|
3427
3432
|
);
|
|
3433
|
+
if (isRpcTransportError(error)) {
|
|
3434
|
+
console.warn(
|
|
3435
|
+
"Skipping per-token fallback because RPC transport is unavailable"
|
|
3436
|
+
);
|
|
3437
|
+
return balances;
|
|
3438
|
+
}
|
|
3428
3439
|
for (const token of erc20Tokens) {
|
|
3429
3440
|
try {
|
|
3430
3441
|
const tokenBalance = await publicClient.readContract({
|
|
@@ -3657,6 +3668,7 @@ function useBalances(chainKey, address) {
|
|
|
3657
3668
|
enabled: !!address && !!chainKey && !!assetMatrix && tokensOnChain.length > 0 && isAddressValidForChain(chainKey, address),
|
|
3658
3669
|
staleTime: 6e4,
|
|
3659
3670
|
gcTime: 5 * 6e4,
|
|
3671
|
+
retry: false,
|
|
3660
3672
|
refetchOnWindowFocus: false,
|
|
3661
3673
|
refetchInterval: 6e4,
|
|
3662
3674
|
refetchIntervalInBackground: false
|
|
@@ -5979,6 +5991,39 @@ class EvmChainStrategy {
|
|
|
5979
5991
|
...rpcError
|
|
5980
5992
|
});
|
|
5981
5993
|
}
|
|
5994
|
+
isNonceResubmissionError(error) {
|
|
5995
|
+
const rpcError = this.getRpcErrorDetails(error);
|
|
5996
|
+
const combined = [rpcError.message, rpcError.shortMessage, rpcError.details].filter(Boolean).join(" ").toLowerCase();
|
|
5997
|
+
return combined.includes("nonce too low") || combined.includes("replacement transaction underpriced");
|
|
5998
|
+
}
|
|
5999
|
+
async sendTransactionWithNonceRetry(walletClient, params) {
|
|
6000
|
+
try {
|
|
6001
|
+
return await walletClient.sendTransaction(params);
|
|
6002
|
+
} catch (error) {
|
|
6003
|
+
if (!this.isNonceResubmissionError(error)) {
|
|
6004
|
+
throw error;
|
|
6005
|
+
}
|
|
6006
|
+
this.logRpcWarning(
|
|
6007
|
+
"Retrying transaction after nonce-related error",
|
|
6008
|
+
error
|
|
6009
|
+
);
|
|
6010
|
+
return await walletClient.sendTransaction(params);
|
|
6011
|
+
}
|
|
6012
|
+
}
|
|
6013
|
+
async writeContractWithNonceRetry(walletClient, params) {
|
|
6014
|
+
try {
|
|
6015
|
+
return await walletClient.writeContract(params);
|
|
6016
|
+
} catch (error) {
|
|
6017
|
+
if (!this.isNonceResubmissionError(error)) {
|
|
6018
|
+
throw error;
|
|
6019
|
+
}
|
|
6020
|
+
this.logRpcWarning(
|
|
6021
|
+
"Retrying contract write after nonce-related error",
|
|
6022
|
+
error
|
|
6023
|
+
);
|
|
6024
|
+
return await walletClient.writeContract(params);
|
|
6025
|
+
}
|
|
6026
|
+
}
|
|
5982
6027
|
async getBalances(address, tokens) {
|
|
5983
6028
|
const chainKey = tokens[0]?.chainKey;
|
|
5984
6029
|
const client = this.resolvePublicClientForChain(chainKey);
|
|
@@ -6043,12 +6088,16 @@ class EvmChainStrategy {
|
|
|
6043
6088
|
if (!tx?.to) continue;
|
|
6044
6089
|
const client = this.resolvePublicClientForChain(step.chainKey);
|
|
6045
6090
|
if (!client) {
|
|
6046
|
-
this.logRpcWarning(
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6091
|
+
this.logRpcWarning(
|
|
6092
|
+
"Skipped network fee estimation: no public client",
|
|
6093
|
+
"no-client",
|
|
6094
|
+
{
|
|
6095
|
+
chainKey: step.chainKey,
|
|
6096
|
+
stepType: step.type,
|
|
6097
|
+
stepIndex: i3 + 1,
|
|
6098
|
+
totalSteps: txSteps.length
|
|
6099
|
+
}
|
|
6100
|
+
);
|
|
6052
6101
|
continue;
|
|
6053
6102
|
}
|
|
6054
6103
|
try {
|
|
@@ -6076,12 +6125,16 @@ class EvmChainStrategy {
|
|
|
6076
6125
|
try {
|
|
6077
6126
|
feePerGas = await client.getGasPrice();
|
|
6078
6127
|
} catch (gasPriceError) {
|
|
6079
|
-
this.logRpcWarning(
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6128
|
+
this.logRpcWarning(
|
|
6129
|
+
"Failed to get gas price for network fee estimation",
|
|
6130
|
+
gasPriceError,
|
|
6131
|
+
{
|
|
6132
|
+
chainKey: step.chainKey,
|
|
6133
|
+
stepType: step.type,
|
|
6134
|
+
stepIndex: i3 + 1,
|
|
6135
|
+
totalSteps: txSteps.length
|
|
6136
|
+
}
|
|
6137
|
+
);
|
|
6085
6138
|
}
|
|
6086
6139
|
}
|
|
6087
6140
|
if (gas && feePerGas) {
|
|
@@ -6160,7 +6213,9 @@ class EvmChainStrategy {
|
|
|
6160
6213
|
const requiredChainId = this.config.chainKeyToId[firstChainKey.toLowerCase()];
|
|
6161
6214
|
const currentChainId = this.walletClient.chain?.id;
|
|
6162
6215
|
if (requiredChainId && currentChainId !== requiredChainId) {
|
|
6163
|
-
console.log(
|
|
6216
|
+
console.log(
|
|
6217
|
+
`Switching from chain ${currentChainId} to ${requiredChainId}`
|
|
6218
|
+
);
|
|
6164
6219
|
await this.switchToChain(requiredChainId);
|
|
6165
6220
|
} else {
|
|
6166
6221
|
console.log(`Already on correct chain ${currentChainId}`);
|
|
@@ -6189,6 +6244,16 @@ class EvmChainStrategy {
|
|
|
6189
6244
|
bridgeTxHash = hash;
|
|
6190
6245
|
}
|
|
6191
6246
|
lastTxHash = hash;
|
|
6247
|
+
if (step.type === "approve") {
|
|
6248
|
+
const receiptClient = this.resolvePublicClientForChain(step.chainKey);
|
|
6249
|
+
if (!receiptClient) {
|
|
6250
|
+
throw new WalletNotConnectedError("evm");
|
|
6251
|
+
}
|
|
6252
|
+
await receiptClient.waitForTransactionReceipt({
|
|
6253
|
+
hash,
|
|
6254
|
+
confirmations: 1
|
|
6255
|
+
});
|
|
6256
|
+
}
|
|
6192
6257
|
onStepComplete?.(hash, step.type, i3, totalSteps);
|
|
6193
6258
|
}
|
|
6194
6259
|
const hashForTracking = bridgeTxHash ?? lastTxHash;
|
|
@@ -6206,15 +6271,6 @@ class EvmChainStrategy {
|
|
|
6206
6271
|
throw toChainStrategyError(error, "evm", "transaction");
|
|
6207
6272
|
}
|
|
6208
6273
|
}
|
|
6209
|
-
async getNextNonce() {
|
|
6210
|
-
if (!this.publicClient || !this.config.evmAddress) {
|
|
6211
|
-
throw new WalletNotConnectedError("evm");
|
|
6212
|
-
}
|
|
6213
|
-
return await this.publicClient.getTransactionCount({
|
|
6214
|
-
address: this.config.evmAddress,
|
|
6215
|
-
blockTag: "pending"
|
|
6216
|
-
});
|
|
6217
|
-
}
|
|
6218
6274
|
async executeTransaction(step) {
|
|
6219
6275
|
const walletClient = this.walletClient;
|
|
6220
6276
|
if (!walletClient) {
|
|
@@ -6227,14 +6283,12 @@ class EvmChainStrategy {
|
|
|
6227
6283
|
);
|
|
6228
6284
|
}
|
|
6229
6285
|
const tx = step.transaction;
|
|
6230
|
-
const
|
|
6231
|
-
const hash = await walletClient.sendTransaction({
|
|
6286
|
+
const hash = await this.sendTransactionWithNonceRetry(walletClient, {
|
|
6232
6287
|
to: tx.to,
|
|
6233
6288
|
data: tx.data,
|
|
6234
6289
|
account: tx.from || this.config.evmAddress,
|
|
6235
6290
|
value: tx.value ? BigInt(tx.value) : void 0,
|
|
6236
|
-
chain: walletClient.chain
|
|
6237
|
-
nonce
|
|
6291
|
+
chain: walletClient.chain
|
|
6238
6292
|
});
|
|
6239
6293
|
return hash;
|
|
6240
6294
|
}
|
|
@@ -6276,16 +6330,17 @@ class EvmChainStrategy {
|
|
|
6276
6330
|
});
|
|
6277
6331
|
if (currentAllowance > 0n) {
|
|
6278
6332
|
try {
|
|
6279
|
-
const
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6333
|
+
const resetHash = await this.writeContractWithNonceRetry(
|
|
6334
|
+
walletClient,
|
|
6335
|
+
{
|
|
6336
|
+
address: tokenAddress,
|
|
6337
|
+
abi: ERC20_ABI,
|
|
6338
|
+
functionName: "approve",
|
|
6339
|
+
args: [spenderAddress, 0n],
|
|
6340
|
+
account: this.config.evmAddress,
|
|
6341
|
+
chain: walletClient.chain
|
|
6342
|
+
}
|
|
6343
|
+
);
|
|
6289
6344
|
await publicClient.waitForTransactionReceipt({
|
|
6290
6345
|
hash: resetHash
|
|
6291
6346
|
});
|
|
@@ -6301,16 +6356,17 @@ class EvmChainStrategy {
|
|
|
6301
6356
|
console.log("USDT allowance is 0, no reset needed");
|
|
6302
6357
|
}
|
|
6303
6358
|
try {
|
|
6304
|
-
const
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6359
|
+
const approveHash = await this.writeContractWithNonceRetry(
|
|
6360
|
+
walletClient,
|
|
6361
|
+
{
|
|
6362
|
+
address: tokenAddress,
|
|
6363
|
+
abi: ERC20_ABI,
|
|
6364
|
+
functionName: "approve",
|
|
6365
|
+
args: [spenderAddress, amount],
|
|
6366
|
+
account: this.config.evmAddress,
|
|
6367
|
+
chain: walletClient.chain
|
|
6368
|
+
}
|
|
6369
|
+
);
|
|
6314
6370
|
return approveHash;
|
|
6315
6371
|
} catch (approveError) {
|
|
6316
6372
|
throw new TransactionFailedError(
|
|
@@ -26765,7 +26821,7 @@ class WalletConnectModal {
|
|
|
26765
26821
|
}
|
|
26766
26822
|
async initUi() {
|
|
26767
26823
|
if (typeof window !== "undefined") {
|
|
26768
|
-
await Promise.resolve().then(() => require("./index
|
|
26824
|
+
await Promise.resolve().then(() => require("./index-Cm-9-5dT.cjs"));
|
|
26769
26825
|
const modal = document.createElement("wcm-modal");
|
|
26770
26826
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
26771
26827
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -27687,4 +27743,4 @@ exports.useSettingsStore = useSettingsStore;
|
|
|
27687
27743
|
exports.useSwapModel = useSwapModel;
|
|
27688
27744
|
exports.useTokensStore = useTokensStore;
|
|
27689
27745
|
exports.useTransactionStore = useTransactionStore;
|
|
27690
|
-
//# sourceMappingURL=index-
|
|
27746
|
+
//# sourceMappingURL=index-CdXk0Wlz.cjs.map
|