@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
|
@@ -3239,6 +3239,11 @@ function isEvmBalanceDebugEnabled() {
|
|
|
3239
3239
|
const flag = window.localStorage.getItem("evaa.debugBalances");
|
|
3240
3240
|
return flag === "1" || flag === "true";
|
|
3241
3241
|
}
|
|
3242
|
+
function isRpcTransportError(error) {
|
|
3243
|
+
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
3244
|
+
const normalized = message.toLowerCase();
|
|
3245
|
+
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");
|
|
3246
|
+
}
|
|
3242
3247
|
async function getEvmBalances(publicClient, address, tokens) {
|
|
3243
3248
|
const balances = {};
|
|
3244
3249
|
const debugRows = [];
|
|
@@ -3256,7 +3261,7 @@ async function getEvmBalances(publicClient, address, tokens) {
|
|
|
3256
3261
|
const chainNative = publicClient.chain?.nativeCurrency;
|
|
3257
3262
|
const nativeSymbol = chainNative?.symbol ?? "ETH";
|
|
3258
3263
|
const nativeDecimals = chainNative?.decimals ?? 18;
|
|
3259
|
-
const maxAttempts =
|
|
3264
|
+
const maxAttempts = 1;
|
|
3260
3265
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
3261
3266
|
try {
|
|
3262
3267
|
const nativeBalance = await publicClient.getBalance({
|
|
@@ -3408,6 +3413,12 @@ async function getEvmBalances(publicClient, address, tokens) {
|
|
|
3408
3413
|
"Multicall failed, falling back to individual calls:",
|
|
3409
3414
|
error
|
|
3410
3415
|
);
|
|
3416
|
+
if (isRpcTransportError(error)) {
|
|
3417
|
+
console.warn(
|
|
3418
|
+
"Skipping per-token fallback because RPC transport is unavailable"
|
|
3419
|
+
);
|
|
3420
|
+
return balances;
|
|
3421
|
+
}
|
|
3411
3422
|
for (const token of erc20Tokens) {
|
|
3412
3423
|
try {
|
|
3413
3424
|
const tokenBalance = await publicClient.readContract({
|
|
@@ -3640,6 +3651,7 @@ function useBalances(chainKey, address) {
|
|
|
3640
3651
|
enabled: !!address && !!chainKey && !!assetMatrix && tokensOnChain.length > 0 && isAddressValidForChain(chainKey, address),
|
|
3641
3652
|
staleTime: 6e4,
|
|
3642
3653
|
gcTime: 5 * 6e4,
|
|
3654
|
+
retry: false,
|
|
3643
3655
|
refetchOnWindowFocus: false,
|
|
3644
3656
|
refetchInterval: 6e4,
|
|
3645
3657
|
refetchIntervalInBackground: false
|
|
@@ -5962,6 +5974,39 @@ class EvmChainStrategy {
|
|
|
5962
5974
|
...rpcError
|
|
5963
5975
|
});
|
|
5964
5976
|
}
|
|
5977
|
+
isNonceResubmissionError(error) {
|
|
5978
|
+
const rpcError = this.getRpcErrorDetails(error);
|
|
5979
|
+
const combined = [rpcError.message, rpcError.shortMessage, rpcError.details].filter(Boolean).join(" ").toLowerCase();
|
|
5980
|
+
return combined.includes("nonce too low") || combined.includes("replacement transaction underpriced");
|
|
5981
|
+
}
|
|
5982
|
+
async sendTransactionWithNonceRetry(walletClient, params) {
|
|
5983
|
+
try {
|
|
5984
|
+
return await walletClient.sendTransaction(params);
|
|
5985
|
+
} catch (error) {
|
|
5986
|
+
if (!this.isNonceResubmissionError(error)) {
|
|
5987
|
+
throw error;
|
|
5988
|
+
}
|
|
5989
|
+
this.logRpcWarning(
|
|
5990
|
+
"Retrying transaction after nonce-related error",
|
|
5991
|
+
error
|
|
5992
|
+
);
|
|
5993
|
+
return await walletClient.sendTransaction(params);
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
async writeContractWithNonceRetry(walletClient, params) {
|
|
5997
|
+
try {
|
|
5998
|
+
return await walletClient.writeContract(params);
|
|
5999
|
+
} catch (error) {
|
|
6000
|
+
if (!this.isNonceResubmissionError(error)) {
|
|
6001
|
+
throw error;
|
|
6002
|
+
}
|
|
6003
|
+
this.logRpcWarning(
|
|
6004
|
+
"Retrying contract write after nonce-related error",
|
|
6005
|
+
error
|
|
6006
|
+
);
|
|
6007
|
+
return await walletClient.writeContract(params);
|
|
6008
|
+
}
|
|
6009
|
+
}
|
|
5965
6010
|
async getBalances(address, tokens) {
|
|
5966
6011
|
const chainKey = tokens[0]?.chainKey;
|
|
5967
6012
|
const client = this.resolvePublicClientForChain(chainKey);
|
|
@@ -6026,12 +6071,16 @@ class EvmChainStrategy {
|
|
|
6026
6071
|
if (!tx?.to) continue;
|
|
6027
6072
|
const client = this.resolvePublicClientForChain(step.chainKey);
|
|
6028
6073
|
if (!client) {
|
|
6029
|
-
this.logRpcWarning(
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6074
|
+
this.logRpcWarning(
|
|
6075
|
+
"Skipped network fee estimation: no public client",
|
|
6076
|
+
"no-client",
|
|
6077
|
+
{
|
|
6078
|
+
chainKey: step.chainKey,
|
|
6079
|
+
stepType: step.type,
|
|
6080
|
+
stepIndex: i3 + 1,
|
|
6081
|
+
totalSteps: txSteps.length
|
|
6082
|
+
}
|
|
6083
|
+
);
|
|
6035
6084
|
continue;
|
|
6036
6085
|
}
|
|
6037
6086
|
try {
|
|
@@ -6059,12 +6108,16 @@ class EvmChainStrategy {
|
|
|
6059
6108
|
try {
|
|
6060
6109
|
feePerGas = await client.getGasPrice();
|
|
6061
6110
|
} catch (gasPriceError) {
|
|
6062
|
-
this.logRpcWarning(
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6111
|
+
this.logRpcWarning(
|
|
6112
|
+
"Failed to get gas price for network fee estimation",
|
|
6113
|
+
gasPriceError,
|
|
6114
|
+
{
|
|
6115
|
+
chainKey: step.chainKey,
|
|
6116
|
+
stepType: step.type,
|
|
6117
|
+
stepIndex: i3 + 1,
|
|
6118
|
+
totalSteps: txSteps.length
|
|
6119
|
+
}
|
|
6120
|
+
);
|
|
6068
6121
|
}
|
|
6069
6122
|
}
|
|
6070
6123
|
if (gas && feePerGas) {
|
|
@@ -6143,7 +6196,9 @@ class EvmChainStrategy {
|
|
|
6143
6196
|
const requiredChainId = this.config.chainKeyToId[firstChainKey.toLowerCase()];
|
|
6144
6197
|
const currentChainId = this.walletClient.chain?.id;
|
|
6145
6198
|
if (requiredChainId && currentChainId !== requiredChainId) {
|
|
6146
|
-
console.log(
|
|
6199
|
+
console.log(
|
|
6200
|
+
`Switching from chain ${currentChainId} to ${requiredChainId}`
|
|
6201
|
+
);
|
|
6147
6202
|
await this.switchToChain(requiredChainId);
|
|
6148
6203
|
} else {
|
|
6149
6204
|
console.log(`Already on correct chain ${currentChainId}`);
|
|
@@ -6172,6 +6227,16 @@ class EvmChainStrategy {
|
|
|
6172
6227
|
bridgeTxHash = hash;
|
|
6173
6228
|
}
|
|
6174
6229
|
lastTxHash = hash;
|
|
6230
|
+
if (step.type === "approve") {
|
|
6231
|
+
const receiptClient = this.resolvePublicClientForChain(step.chainKey);
|
|
6232
|
+
if (!receiptClient) {
|
|
6233
|
+
throw new WalletNotConnectedError("evm");
|
|
6234
|
+
}
|
|
6235
|
+
await receiptClient.waitForTransactionReceipt({
|
|
6236
|
+
hash,
|
|
6237
|
+
confirmations: 1
|
|
6238
|
+
});
|
|
6239
|
+
}
|
|
6175
6240
|
onStepComplete?.(hash, step.type, i3, totalSteps);
|
|
6176
6241
|
}
|
|
6177
6242
|
const hashForTracking = bridgeTxHash ?? lastTxHash;
|
|
@@ -6189,15 +6254,6 @@ class EvmChainStrategy {
|
|
|
6189
6254
|
throw toChainStrategyError(error, "evm", "transaction");
|
|
6190
6255
|
}
|
|
6191
6256
|
}
|
|
6192
|
-
async getNextNonce() {
|
|
6193
|
-
if (!this.publicClient || !this.config.evmAddress) {
|
|
6194
|
-
throw new WalletNotConnectedError("evm");
|
|
6195
|
-
}
|
|
6196
|
-
return await this.publicClient.getTransactionCount({
|
|
6197
|
-
address: this.config.evmAddress,
|
|
6198
|
-
blockTag: "pending"
|
|
6199
|
-
});
|
|
6200
|
-
}
|
|
6201
6257
|
async executeTransaction(step) {
|
|
6202
6258
|
const walletClient = this.walletClient;
|
|
6203
6259
|
if (!walletClient) {
|
|
@@ -6210,14 +6266,12 @@ class EvmChainStrategy {
|
|
|
6210
6266
|
);
|
|
6211
6267
|
}
|
|
6212
6268
|
const tx = step.transaction;
|
|
6213
|
-
const
|
|
6214
|
-
const hash = await walletClient.sendTransaction({
|
|
6269
|
+
const hash = await this.sendTransactionWithNonceRetry(walletClient, {
|
|
6215
6270
|
to: tx.to,
|
|
6216
6271
|
data: tx.data,
|
|
6217
6272
|
account: tx.from || this.config.evmAddress,
|
|
6218
6273
|
value: tx.value ? BigInt(tx.value) : void 0,
|
|
6219
|
-
chain: walletClient.chain
|
|
6220
|
-
nonce
|
|
6274
|
+
chain: walletClient.chain
|
|
6221
6275
|
});
|
|
6222
6276
|
return hash;
|
|
6223
6277
|
}
|
|
@@ -6259,16 +6313,17 @@ class EvmChainStrategy {
|
|
|
6259
6313
|
});
|
|
6260
6314
|
if (currentAllowance > 0n) {
|
|
6261
6315
|
try {
|
|
6262
|
-
const
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6316
|
+
const resetHash = await this.writeContractWithNonceRetry(
|
|
6317
|
+
walletClient,
|
|
6318
|
+
{
|
|
6319
|
+
address: tokenAddress,
|
|
6320
|
+
abi: ERC20_ABI,
|
|
6321
|
+
functionName: "approve",
|
|
6322
|
+
args: [spenderAddress, 0n],
|
|
6323
|
+
account: this.config.evmAddress,
|
|
6324
|
+
chain: walletClient.chain
|
|
6325
|
+
}
|
|
6326
|
+
);
|
|
6272
6327
|
await publicClient.waitForTransactionReceipt({
|
|
6273
6328
|
hash: resetHash
|
|
6274
6329
|
});
|
|
@@ -6284,16 +6339,17 @@ class EvmChainStrategy {
|
|
|
6284
6339
|
console.log("USDT allowance is 0, no reset needed");
|
|
6285
6340
|
}
|
|
6286
6341
|
try {
|
|
6287
|
-
const
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6342
|
+
const approveHash = await this.writeContractWithNonceRetry(
|
|
6343
|
+
walletClient,
|
|
6344
|
+
{
|
|
6345
|
+
address: tokenAddress,
|
|
6346
|
+
abi: ERC20_ABI,
|
|
6347
|
+
functionName: "approve",
|
|
6348
|
+
args: [spenderAddress, amount],
|
|
6349
|
+
account: this.config.evmAddress,
|
|
6350
|
+
chain: walletClient.chain
|
|
6351
|
+
}
|
|
6352
|
+
);
|
|
6297
6353
|
return approveHash;
|
|
6298
6354
|
} catch (approveError) {
|
|
6299
6355
|
throw new TransactionFailedError(
|
|
@@ -26748,7 +26804,7 @@ class WalletConnectModal {
|
|
|
26748
26804
|
}
|
|
26749
26805
|
async initUi() {
|
|
26750
26806
|
if (typeof window !== "undefined") {
|
|
26751
|
-
await import("./index-
|
|
26807
|
+
await import("./index-BNr-8fA_.js");
|
|
26752
26808
|
const modal = document.createElement("wcm-modal");
|
|
26753
26809
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
26754
26810
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -27672,4 +27728,4 @@ export {
|
|
|
27672
27728
|
calculateMinReceived as y,
|
|
27673
27729
|
getQuoteDetails as z
|
|
27674
27730
|
};
|
|
27675
|
-
//# sourceMappingURL=index-
|
|
27731
|
+
//# sourceMappingURL=index-DnqFAL14.js.map
|