@rash2x/bridge-widget 0.6.92 → 0.6.93
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-p9NMtKHb.cjs → index-BC-9ZbF7.cjs} +115 -10
- package/dist/{index-p9NMtKHb.cjs.map → index-BC-9ZbF7.cjs.map} +1 -1
- package/dist/{index-j6yDeMSt.js → index-BDIi-D7p.js} +115 -10
- package/dist/{index-j6yDeMSt.js.map → index-BDIi-D7p.js.map} +1 -1
- package/dist/{index--FWEmzfG.js → index-Ba3TMYQR.js} +2 -2
- package/dist/{index--FWEmzfG.js.map → index-Ba3TMYQR.js.map} +1 -1
- package/dist/{index-B8oK1IHg.cjs → index-DgvHCFl2.cjs} +2 -2
- package/dist/{index-B8oK1IHg.cjs.map → index-DgvHCFl2.cjs.map} +1 -1
- package/package.json +1 -1
package/dist/evaa-bridge.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-BC-9ZbF7.cjs");
|
|
4
4
|
exports.DEFAULT_SLIPPAGE_BPS = index.DEFAULT_SLIPPAGE_BPS;
|
|
5
5
|
exports.EvaaBridge = index.EvaaBridge;
|
|
6
6
|
exports.RoutePriority = index.RoutePriority;
|
package/dist/evaa-bridge.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L, d, f, e, D, Q, H, z, W, U, w, s, v, r, p, q, G, Z, a5, $, a2, x, A, y, a0, B, _, a3, a4, S, a1, P, I, V, Y, a6, a7, J, K, X, F, N, t, o, i, u, l, m, j, n, h, k } from "./index-
|
|
1
|
+
import { L, d, f, e, D, Q, H, z, W, U, w, s, v, r, p, q, G, Z, a5, $, a2, x, A, y, a0, B, _, a3, a4, S, a1, P, I, V, Y, a6, a7, J, K, X, F, N, t, o, i, u, l, m, j, n, h, k } from "./index-BDIi-D7p.js";
|
|
2
2
|
export {
|
|
3
3
|
L as DEFAULT_SLIPPAGE_BPS,
|
|
4
4
|
d as EvaaBridge,
|
|
@@ -5306,6 +5306,15 @@ class EvmChainStrategy {
|
|
|
5306
5306
|
throw toChainStrategyError(error, "evm", "transaction");
|
|
5307
5307
|
}
|
|
5308
5308
|
}
|
|
5309
|
+
async getNextNonce() {
|
|
5310
|
+
if (!this.publicClient || !this.config.evmAddress) {
|
|
5311
|
+
throw new WalletNotConnectedError("evm");
|
|
5312
|
+
}
|
|
5313
|
+
return await this.publicClient.getTransactionCount({
|
|
5314
|
+
address: this.config.evmAddress,
|
|
5315
|
+
blockTag: "pending"
|
|
5316
|
+
});
|
|
5317
|
+
}
|
|
5309
5318
|
async executeTransaction(step) {
|
|
5310
5319
|
const walletClient = this.walletClient;
|
|
5311
5320
|
if (!walletClient) {
|
|
@@ -5318,12 +5327,14 @@ class EvmChainStrategy {
|
|
|
5318
5327
|
);
|
|
5319
5328
|
}
|
|
5320
5329
|
const tx = step.transaction;
|
|
5330
|
+
const nonce = await this.getNextNonce();
|
|
5321
5331
|
const hash = await walletClient.sendTransaction({
|
|
5322
5332
|
to: tx.to,
|
|
5323
5333
|
data: tx.data,
|
|
5324
5334
|
account: tx.from || this.config.evmAddress,
|
|
5325
5335
|
value: tx.value ? BigInt(tx.value) : void 0,
|
|
5326
|
-
chain: walletClient.chain
|
|
5336
|
+
chain: walletClient.chain,
|
|
5337
|
+
nonce
|
|
5327
5338
|
});
|
|
5328
5339
|
return hash;
|
|
5329
5340
|
}
|
|
@@ -5365,13 +5376,15 @@ class EvmChainStrategy {
|
|
|
5365
5376
|
});
|
|
5366
5377
|
if (currentAllowance > 0n) {
|
|
5367
5378
|
try {
|
|
5379
|
+
const resetNonce = await this.getNextNonce();
|
|
5368
5380
|
const resetHash = await walletClient.writeContract({
|
|
5369
5381
|
address: tokenAddress,
|
|
5370
5382
|
abi: ERC20_ABI,
|
|
5371
5383
|
functionName: "approve",
|
|
5372
5384
|
args: [spenderAddress, 0n],
|
|
5373
5385
|
account: this.config.evmAddress,
|
|
5374
|
-
chain: walletClient.chain
|
|
5386
|
+
chain: walletClient.chain,
|
|
5387
|
+
nonce: resetNonce
|
|
5375
5388
|
});
|
|
5376
5389
|
await publicClient.waitForTransactionReceipt({
|
|
5377
5390
|
hash: resetHash
|
|
@@ -5388,13 +5401,15 @@ class EvmChainStrategy {
|
|
|
5388
5401
|
console.log("USDT allowance is 0, no reset needed");
|
|
5389
5402
|
}
|
|
5390
5403
|
try {
|
|
5404
|
+
const approveNonce = await this.getNextNonce();
|
|
5391
5405
|
const approveHash = await walletClient.writeContract({
|
|
5392
5406
|
address: tokenAddress,
|
|
5393
5407
|
abi: ERC20_ABI,
|
|
5394
5408
|
functionName: "approve",
|
|
5395
5409
|
args: [spenderAddress, amount],
|
|
5396
5410
|
account: this.config.evmAddress,
|
|
5397
|
-
chain: walletClient.chain
|
|
5411
|
+
chain: walletClient.chain,
|
|
5412
|
+
nonce: approveNonce
|
|
5398
5413
|
});
|
|
5399
5414
|
return approveHash;
|
|
5400
5415
|
} catch (approveError) {
|
|
@@ -6259,6 +6274,13 @@ class TronChainStrategy {
|
|
|
6259
6274
|
} else {
|
|
6260
6275
|
signedTx = await tronWeb.trx.sign(unsignedTx);
|
|
6261
6276
|
}
|
|
6277
|
+
const signatures = signedTx.signature;
|
|
6278
|
+
if (!Array.isArray(signatures) || signatures.length === 0) {
|
|
6279
|
+
throw new TransactionFailedError(
|
|
6280
|
+
"tron",
|
|
6281
|
+
"Wallet returned unsigned transaction"
|
|
6282
|
+
);
|
|
6283
|
+
}
|
|
6262
6284
|
const sent = await tronWeb.trx.sendRawTransaction(signedTx);
|
|
6263
6285
|
if (!sent?.result || !sent?.txid) {
|
|
6264
6286
|
throw new TransactionFailedError(
|
|
@@ -25761,7 +25783,7 @@ class WalletConnectModal {
|
|
|
25761
25783
|
}
|
|
25762
25784
|
async initUi() {
|
|
25763
25785
|
if (typeof window !== "undefined") {
|
|
25764
|
-
await Promise.resolve().then(() => require("./index-
|
|
25786
|
+
await Promise.resolve().then(() => require("./index-DgvHCFl2.cjs"));
|
|
25765
25787
|
const modal = document.createElement("wcm-modal");
|
|
25766
25788
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25767
25789
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -25807,6 +25829,59 @@ const useThemeStore = zustand.create((set2) => ({
|
|
|
25807
25829
|
}));
|
|
25808
25830
|
const TRON_MAINNET_CHAIN_ID = "tron:0x2b6653dc";
|
|
25809
25831
|
const CONNECTION_TIMEOUT = 6e4;
|
|
25832
|
+
function isRecord(value) {
|
|
25833
|
+
return typeof value === "object" && value !== null;
|
|
25834
|
+
}
|
|
25835
|
+
function hasValidSignature(transaction2) {
|
|
25836
|
+
if (!isRecord(transaction2)) return false;
|
|
25837
|
+
const signature = transaction2.signature;
|
|
25838
|
+
return Array.isArray(signature) && signature.length > 0 && signature.every((item) => typeof item === "string" && item.length > 0);
|
|
25839
|
+
}
|
|
25840
|
+
function normalizeSignature(signature) {
|
|
25841
|
+
return signature.replace(/^0x/i, "");
|
|
25842
|
+
}
|
|
25843
|
+
function toSignedTransaction(result, unsignedTx) {
|
|
25844
|
+
if (hasValidSignature(result)) {
|
|
25845
|
+
return result;
|
|
25846
|
+
}
|
|
25847
|
+
if (isRecord(result)) {
|
|
25848
|
+
const nestedTx = result.transaction;
|
|
25849
|
+
if (hasValidSignature(nestedTx)) {
|
|
25850
|
+
return nestedTx;
|
|
25851
|
+
}
|
|
25852
|
+
const nestedSignedTx = result.signedTransaction;
|
|
25853
|
+
if (hasValidSignature(nestedSignedTx)) {
|
|
25854
|
+
return nestedSignedTx;
|
|
25855
|
+
}
|
|
25856
|
+
const signature = result.signature;
|
|
25857
|
+
if (typeof signature === "string" && signature.length > 0) {
|
|
25858
|
+
return {
|
|
25859
|
+
...unsignedTx,
|
|
25860
|
+
signature: [normalizeSignature(signature)]
|
|
25861
|
+
};
|
|
25862
|
+
}
|
|
25863
|
+
if (Array.isArray(signature) && signature.length > 0 && signature.every((item) => typeof item === "string" && item.length > 0)) {
|
|
25864
|
+
return {
|
|
25865
|
+
...unsignedTx,
|
|
25866
|
+
signature: signature.map((item) => normalizeSignature(item))
|
|
25867
|
+
};
|
|
25868
|
+
}
|
|
25869
|
+
}
|
|
25870
|
+
if (typeof result === "string" && result.length > 0) {
|
|
25871
|
+
return {
|
|
25872
|
+
...unsignedTx,
|
|
25873
|
+
signature: [normalizeSignature(result)]
|
|
25874
|
+
};
|
|
25875
|
+
}
|
|
25876
|
+
return null;
|
|
25877
|
+
}
|
|
25878
|
+
function isUserRejectedError(error) {
|
|
25879
|
+
if (isRecord(error) && typeof error.code === "number" && error.code === 4001) {
|
|
25880
|
+
return true;
|
|
25881
|
+
}
|
|
25882
|
+
const msg = error instanceof Error ? error.message.toLowerCase() : "";
|
|
25883
|
+
return msg.includes("user rejected") || msg.includes("rejected by user");
|
|
25884
|
+
}
|
|
25810
25885
|
function useTronWalletConnect(projectId) {
|
|
25811
25886
|
const { address, isConnected, isConnecting } = useTronWalletConnectStore();
|
|
25812
25887
|
const { setAddress, setActions, reset } = useTronWalletConnectStore();
|
|
@@ -25987,11 +26062,41 @@ function useTronWalletConnect(projectId) {
|
|
|
25987
26062
|
throw new Error("WalletConnect not connected");
|
|
25988
26063
|
}
|
|
25989
26064
|
try {
|
|
25990
|
-
const
|
|
25991
|
-
|
|
25992
|
-
|
|
25993
|
-
|
|
25994
|
-
|
|
26065
|
+
const requestVariants = [
|
|
26066
|
+
[transaction2],
|
|
26067
|
+
[transaction2, address],
|
|
26068
|
+
[{ transaction: transaction2, address }],
|
|
26069
|
+
{ transaction: transaction2, address }
|
|
26070
|
+
];
|
|
26071
|
+
let lastResponse;
|
|
26072
|
+
let lastError;
|
|
26073
|
+
for (const params of requestVariants) {
|
|
26074
|
+
try {
|
|
26075
|
+
const result = await providerRef.current.request(
|
|
26076
|
+
{
|
|
26077
|
+
method: "tron_signTransaction",
|
|
26078
|
+
params
|
|
26079
|
+
},
|
|
26080
|
+
TRON_MAINNET_CHAIN_ID
|
|
26081
|
+
);
|
|
26082
|
+
lastResponse = result;
|
|
26083
|
+
const signedTx = toSignedTransaction(result, transaction2);
|
|
26084
|
+
if (signedTx) {
|
|
26085
|
+
return signedTx;
|
|
26086
|
+
}
|
|
26087
|
+
} catch (error) {
|
|
26088
|
+
if (isUserRejectedError(error)) {
|
|
26089
|
+
throw error;
|
|
26090
|
+
}
|
|
26091
|
+
lastError = error;
|
|
26092
|
+
}
|
|
26093
|
+
}
|
|
26094
|
+
if (lastError) {
|
|
26095
|
+
throw lastError;
|
|
26096
|
+
}
|
|
26097
|
+
throw new Error(
|
|
26098
|
+
`WalletConnect returned unsigned transaction: ${JSON.stringify(lastResponse)}`
|
|
26099
|
+
);
|
|
25995
26100
|
} catch (error) {
|
|
25996
26101
|
console.error("TRON WalletConnect transaction signing failed:", error);
|
|
25997
26102
|
throw error;
|
|
@@ -26515,4 +26620,4 @@ exports.useSettingsStore = useSettingsStore;
|
|
|
26515
26620
|
exports.useSwapModel = useSwapModel;
|
|
26516
26621
|
exports.useTokensStore = useTokensStore;
|
|
26517
26622
|
exports.useTransactionStore = useTransactionStore;
|
|
26518
|
-
//# sourceMappingURL=index-
|
|
26623
|
+
//# sourceMappingURL=index-BC-9ZbF7.cjs.map
|