@trustware/sdk-staging 1.1.9-staging.7 → 1.1.10-staging.0
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/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-gNyi5xsp.d.cts → core-B7Ez-5-r.d.cts} +1 -1
- package/dist/{core-DzqVEWwP.d.ts → core-BPLiD1UG.d.ts} +1 -1
- package/dist/core.cjs +131 -2
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +132 -2
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +147 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +173 -34
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-Dn4muk74.d.ts → manager-B6NNV-E_.d.ts} +89 -1
- package/dist/{manager-DWFNyouP.d.cts → manager-BwjyFjjz.d.cts} +89 -1
- package/dist/{detect-Cprq6X9o.d.ts → metadata-BiTMMvlY.d.ts} +5 -2
- package/dist/{detect-DWL4uExV.d.cts → metadata-HCflXcsF.d.cts} +5 -2
- package/dist/smart-account.cjs +1 -1
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.d.cts +235 -222
- package/dist/smart-account.d.ts +235 -222
- package/dist/smart-account.mjs +1 -1
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +1 -1
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +4 -7
- package/dist/wallet.d.ts +4 -7
- package/dist/wallet.mjs +1 -1
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +121 -6
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +149 -33
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/widget.mjs
CHANGED
|
@@ -563,7 +563,7 @@ var init_constants = __esm({
|
|
|
563
563
|
"src/constants.ts"() {
|
|
564
564
|
"use strict";
|
|
565
565
|
SDK_NAME = "@trustware/sdk";
|
|
566
|
-
SDK_VERSION = "1.1.
|
|
566
|
+
SDK_VERSION = "1.1.10-staging.0";
|
|
567
567
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
568
568
|
GTM_ID = "GTM-TZDGNCXB";
|
|
569
569
|
API_PREFIX = "/api";
|
|
@@ -2442,6 +2442,27 @@ var init_balances = __esm({
|
|
|
2442
2442
|
});
|
|
2443
2443
|
|
|
2444
2444
|
// src/core/routes.ts
|
|
2445
|
+
function assertValidPostHook(hooks) {
|
|
2446
|
+
const postHook = hooks?.postHook;
|
|
2447
|
+
if (!postHook) return;
|
|
2448
|
+
if (!postHook.target?.trim()) {
|
|
2449
|
+
throw new Error("hooks.postHook.target is required.");
|
|
2450
|
+
}
|
|
2451
|
+
if (!postHook.callData?.trim()) {
|
|
2452
|
+
throw new Error("hooks.postHook.callData is required.");
|
|
2453
|
+
}
|
|
2454
|
+
if (postHook.fullAmount) {
|
|
2455
|
+
if (postHook.amountInputPos === void 0) {
|
|
2456
|
+
throw new Error(
|
|
2457
|
+
"hooks.postHook.amountInputPos is required when fullAmount is true."
|
|
2458
|
+
);
|
|
2459
|
+
}
|
|
2460
|
+
} else if (!postHook.fundAmount?.trim()) {
|
|
2461
|
+
throw new Error(
|
|
2462
|
+
"hooks.postHook.fundAmount is required unless fullAmount is set."
|
|
2463
|
+
);
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2445
2466
|
function isEvmTxRequest(txReq) {
|
|
2446
2467
|
return Boolean(txReq?.data && (txReq.to || txReq.target));
|
|
2447
2468
|
}
|
|
@@ -2460,6 +2481,7 @@ async function buildRoute(body, signal) {
|
|
|
2460
2481
|
if (!addressValidation.isValid) {
|
|
2461
2482
|
throw new Error(addressValidation.error || "Invalid route addresses.");
|
|
2462
2483
|
}
|
|
2484
|
+
assertValidPostHook(body.hooks);
|
|
2463
2485
|
const cfg = TrustwareConfigStore.get();
|
|
2464
2486
|
const url = `${apiBase()}/v1/routes/route`;
|
|
2465
2487
|
const payload = {
|
|
@@ -2498,6 +2520,7 @@ async function buildRoute(body, signal) {
|
|
|
2498
2520
|
return { intentId, txReq, actions, finalExchangeRate, route, sponsorship };
|
|
2499
2521
|
}
|
|
2500
2522
|
async function buildDepositAddress(body, signal) {
|
|
2523
|
+
assertValidPostHook(body.hooks);
|
|
2501
2524
|
const cfg = TrustwareConfigStore.get();
|
|
2502
2525
|
const url = `${apiBase()}/v1/routes/deposit-address`;
|
|
2503
2526
|
const payload = {
|
|
@@ -8992,11 +9015,92 @@ var init_store = __esm({
|
|
|
8992
9015
|
});
|
|
8993
9016
|
|
|
8994
9017
|
// src/core/tx.ts
|
|
8995
|
-
import { keccak256 } from "viem";
|
|
9018
|
+
import { keccak256, encodeFunctionData, parseAbi } from "viem";
|
|
8996
9019
|
function backendChainId(chain, fallback) {
|
|
8997
9020
|
const preferred = chain?.networkIdentifier ?? chain?.chainId ?? chain?.id;
|
|
8998
9021
|
return String(preferred ?? fallback ?? "");
|
|
8999
9022
|
}
|
|
9023
|
+
function sleep2(ms) {
|
|
9024
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
9025
|
+
}
|
|
9026
|
+
async function sendEvmTx(w, tx) {
|
|
9027
|
+
if (w.type === "eip1193") {
|
|
9028
|
+
const from = await w.getAddress();
|
|
9029
|
+
const params = {
|
|
9030
|
+
from,
|
|
9031
|
+
to: tx.to,
|
|
9032
|
+
data: tx.data,
|
|
9033
|
+
value: tx.value ? `0x${tx.value.toString(16)}` : "0x0"
|
|
9034
|
+
};
|
|
9035
|
+
if (tx.chainId !== void 0) {
|
|
9036
|
+
params.chainId = `0x${tx.chainId.toString(16)}`;
|
|
9037
|
+
}
|
|
9038
|
+
const hash = await w.request({
|
|
9039
|
+
method: "eth_sendTransaction",
|
|
9040
|
+
params: [params]
|
|
9041
|
+
});
|
|
9042
|
+
return hash;
|
|
9043
|
+
}
|
|
9044
|
+
const response = await w.sendTransaction({
|
|
9045
|
+
to: tx.to,
|
|
9046
|
+
data: tx.data,
|
|
9047
|
+
value: tx.value,
|
|
9048
|
+
chainId: tx.chainId
|
|
9049
|
+
});
|
|
9050
|
+
return response.hash;
|
|
9051
|
+
}
|
|
9052
|
+
async function waitForTxConfirmation(chainId, txHash) {
|
|
9053
|
+
const timeoutMs = 12e4;
|
|
9054
|
+
const intervalMs = 2e3;
|
|
9055
|
+
const started = Date.now();
|
|
9056
|
+
while (Date.now() - started < timeoutMs) {
|
|
9057
|
+
const status = await getEVMTxStatus({ chainId, txHash });
|
|
9058
|
+
if (status.status === "success") return;
|
|
9059
|
+
if (status.status === "reverted") {
|
|
9060
|
+
throw new Error("Approval transaction reverted");
|
|
9061
|
+
}
|
|
9062
|
+
await sleep2(intervalMs);
|
|
9063
|
+
}
|
|
9064
|
+
throw new Error("Timed out waiting for approval confirmation");
|
|
9065
|
+
}
|
|
9066
|
+
async function ensureApprovals(w, approvals, fallbackChainId) {
|
|
9067
|
+
if (!approvals || approvals.length === 0) return;
|
|
9068
|
+
const owner = await w.getAddress();
|
|
9069
|
+
for (const approval of approvals) {
|
|
9070
|
+
const spender = approval.spender;
|
|
9071
|
+
const tokenAddress = approval.tokenAddress;
|
|
9072
|
+
const amount = approval.amount;
|
|
9073
|
+
if (!spender || !tokenAddress || !amount) continue;
|
|
9074
|
+
const chainId = approval.chainId || String(fallbackChainId ?? "");
|
|
9075
|
+
if (!chainId) continue;
|
|
9076
|
+
const amountWei = BigInt(amount);
|
|
9077
|
+
if (amountWei === 0n) continue;
|
|
9078
|
+
let currentAllowance = 0n;
|
|
9079
|
+
try {
|
|
9080
|
+
const { allowance } = await getEVMAllowance({
|
|
9081
|
+
chainId,
|
|
9082
|
+
tokenAddress,
|
|
9083
|
+
ownerAddress: owner,
|
|
9084
|
+
spenderAddress: spender
|
|
9085
|
+
});
|
|
9086
|
+
currentAllowance = BigInt(allowance || "0");
|
|
9087
|
+
} catch {
|
|
9088
|
+
}
|
|
9089
|
+
if (currentAllowance >= amountWei) continue;
|
|
9090
|
+
const data = encodeFunctionData({
|
|
9091
|
+
abi: erc20ApproveAbi,
|
|
9092
|
+
functionName: "approve",
|
|
9093
|
+
args: [spender, amountWei]
|
|
9094
|
+
});
|
|
9095
|
+
const hash = await sendEvmTx(w, {
|
|
9096
|
+
to: tokenAddress,
|
|
9097
|
+
data,
|
|
9098
|
+
value: 0n,
|
|
9099
|
+
chainId: Number.isFinite(Number(chainId)) ? Number(chainId) : void 0
|
|
9100
|
+
});
|
|
9101
|
+
await waitForTxConfirmation(chainId, hash);
|
|
9102
|
+
}
|
|
9103
|
+
}
|
|
9000
9104
|
function isUserRejected(e2) {
|
|
9001
9105
|
const code = e2?.code ?? e2?.data?.code;
|
|
9002
9106
|
if (code === 4001) return true;
|
|
@@ -9030,6 +9134,13 @@ async function sendRouteTransaction(b, fallbackChainId) {
|
|
|
9030
9134
|
}
|
|
9031
9135
|
}
|
|
9032
9136
|
}
|
|
9137
|
+
if (!validatedSponsorship) {
|
|
9138
|
+
await ensureApprovals(
|
|
9139
|
+
w,
|
|
9140
|
+
b.route?.execution?.approvals,
|
|
9141
|
+
Number.isFinite(target) ? target : void 0
|
|
9142
|
+
);
|
|
9143
|
+
}
|
|
9033
9144
|
if (w.type === "eip1193") {
|
|
9034
9145
|
const from = await w.getAddress();
|
|
9035
9146
|
const hexValue = value ? `0x${value.toString(16)}` : "0x0";
|
|
@@ -9126,11 +9237,16 @@ async function runTopUp(params) {
|
|
|
9126
9237
|
}
|
|
9127
9238
|
}
|
|
9128
9239
|
}
|
|
9240
|
+
var erc20ApproveAbi;
|
|
9129
9241
|
var init_tx = __esm({
|
|
9130
9242
|
"src/core/tx.ts"() {
|
|
9131
9243
|
"use strict";
|
|
9132
9244
|
init_wallets();
|
|
9133
9245
|
init_routes();
|
|
9246
|
+
init_sdkRpc();
|
|
9247
|
+
erc20ApproveAbi = parseAbi([
|
|
9248
|
+
"function approve(address spender, uint256 amount) returns (bool)"
|
|
9249
|
+
]);
|
|
9134
9250
|
}
|
|
9135
9251
|
});
|
|
9136
9252
|
|
|
@@ -28244,7 +28360,7 @@ var init_utils5 = __esm({
|
|
|
28244
28360
|
});
|
|
28245
28361
|
|
|
28246
28362
|
// node_modules/@account-kit/smart-contracts/dist/esm/src/light-account/accounts/base.js
|
|
28247
|
-
import { concat as concat5, encodeFunctionData, fromHex as fromHex4, hashMessage, hashTypedData, trim } from "viem";
|
|
28363
|
+
import { concat as concat5, encodeFunctionData as encodeFunctionData2, fromHex as fromHex4, hashMessage, hashTypedData, trim } from "viem";
|
|
28248
28364
|
async function createLightAccountBase({ transport, chain, signer, abi, version, type, entryPoint, accountAddress, getAccountInitCode }) {
|
|
28249
28365
|
const client = createBundlerClient({
|
|
28250
28366
|
transport,
|
|
@@ -28263,7 +28379,7 @@ async function createLightAccountBase({ transport, chain, signer, abi, version,
|
|
|
28263
28379
|
if (fromHex4(storage, "number") !== 0 && !implementationAddresses.some((x) => x === trim(storage))) {
|
|
28264
28380
|
throw new Error(`could not determine if smart account implementation is ${type} ${String(version)}`);
|
|
28265
28381
|
}
|
|
28266
|
-
return
|
|
28382
|
+
return encodeFunctionData2({
|
|
28267
28383
|
abi,
|
|
28268
28384
|
functionName: "upgradeToAndCall",
|
|
28269
28385
|
args: [upgradeToAddress, upgradeToInitData]
|
|
@@ -28322,7 +28438,7 @@ async function createLightAccountBase({ transport, chain, signer, abi, version,
|
|
|
28322
28438
|
prepareSign,
|
|
28323
28439
|
formatSign,
|
|
28324
28440
|
encodeExecute: async ({ target, data, value }) => {
|
|
28325
|
-
return
|
|
28441
|
+
return encodeFunctionData2({
|
|
28326
28442
|
abi,
|
|
28327
28443
|
functionName: "execute",
|
|
28328
28444
|
args: [target, value ?? 0n, data]
|
|
@@ -28335,7 +28451,7 @@ async function createLightAccountBase({ transport, chain, signer, abi, version,
|
|
|
28335
28451
|
accum[2].push(curr.data);
|
|
28336
28452
|
return accum;
|
|
28337
28453
|
}, [[], [], []]);
|
|
28338
|
-
return
|
|
28454
|
+
return encodeFunctionData2({
|
|
28339
28455
|
abi,
|
|
28340
28456
|
functionName: "executeBatch",
|
|
28341
28457
|
args: [targets, values, datas]
|
|
@@ -28429,7 +28545,7 @@ var init_OZ_ERC1967Proxy = __esm({
|
|
|
28429
28545
|
});
|
|
28430
28546
|
|
|
28431
28547
|
// node_modules/@account-kit/smart-contracts/dist/esm/src/light-account/accounts/predictAddress.js
|
|
28432
|
-
import { encodeAbiParameters as encodeAbiParameters4, encodeDeployData, keccak256 as keccak2565, getContractAddress, toHex as toHex6, encodeFunctionData as
|
|
28548
|
+
import { encodeAbiParameters as encodeAbiParameters4, encodeDeployData, keccak256 as keccak2565, getContractAddress, toHex as toHex6, encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
28433
28549
|
function predictLightAccountAddress({ factoryAddress, salt, ownerAddress, version }) {
|
|
28434
28550
|
const implementationAddress = (
|
|
28435
28551
|
// If we aren't using the default factory address, we compute the implementation address from the factory's `create` deployment.
|
|
@@ -28453,7 +28569,7 @@ function predictLightAccountAddress({ factoryAddress, salt, ownerAddress, versio
|
|
|
28453
28569
|
abi: OZ_ERC1967Proxy_ConstructorAbi,
|
|
28454
28570
|
args: [
|
|
28455
28571
|
implementationAddress,
|
|
28456
|
-
|
|
28572
|
+
encodeFunctionData3({
|
|
28457
28573
|
abi: LightAccountAbi_v1,
|
|
28458
28574
|
functionName: "initialize",
|
|
28459
28575
|
args: [ownerAddress]
|
|
@@ -28490,7 +28606,7 @@ var init_predictAddress = __esm({
|
|
|
28490
28606
|
});
|
|
28491
28607
|
|
|
28492
28608
|
// node_modules/@account-kit/smart-contracts/dist/esm/src/light-account/accounts/account.js
|
|
28493
|
-
import { concatHex as concatHex2, encodeFunctionData as
|
|
28609
|
+
import { concatHex as concatHex2, encodeFunctionData as encodeFunctionData4 } from "viem";
|
|
28494
28610
|
async function createLightAccount({ transport, chain, signer, initCode, version = defaultLightAccountVersion(), entryPoint = getEntryPoint(chain, {
|
|
28495
28611
|
version: AccountVersionRegistry["LightAccount"][version].entryPointVersion
|
|
28496
28612
|
}), accountAddress, factoryAddress = getDefaultLightAccountFactoryAddress(chain, version), salt: salt_ = 0n }) {
|
|
@@ -28507,7 +28623,7 @@ async function createLightAccount({ transport, chain, signer, initCode, version
|
|
|
28507
28623
|
return initCode;
|
|
28508
28624
|
return concatHex2([
|
|
28509
28625
|
factoryAddress,
|
|
28510
|
-
|
|
28626
|
+
encodeFunctionData4({
|
|
28511
28627
|
abi: factoryAbi,
|
|
28512
28628
|
functionName: "createAccount",
|
|
28513
28629
|
args: [signerAddress, salt]
|
|
@@ -28534,7 +28650,7 @@ async function createLightAccount({ transport, chain, signer, initCode, version
|
|
|
28534
28650
|
return {
|
|
28535
28651
|
...account,
|
|
28536
28652
|
encodeTransferOwnership: (newOwner) => {
|
|
28537
|
-
return
|
|
28653
|
+
return encodeFunctionData4({
|
|
28538
28654
|
abi: accountAbi,
|
|
28539
28655
|
functionName: "transferOwnership",
|
|
28540
28656
|
args: [newOwner]
|
|
@@ -29842,7 +29958,7 @@ var init_feeEstimator2 = __esm({
|
|
|
29842
29958
|
});
|
|
29843
29959
|
|
|
29844
29960
|
// node_modules/@account-kit/infra/dist/esm/gas-manager.js
|
|
29845
|
-
import { encodeFunctionData as
|
|
29961
|
+
import { encodeFunctionData as encodeFunctionData5 } from "viem";
|
|
29846
29962
|
var AlchemyPaymasterAddressV06Unify, AlchemyPaymasterAddressV07Unify, AlchemyPaymasterAddressV4, AlchemyPaymasterAddressV3, AlchemyPaymasterAddressV2, ArbSepoliaPaymasterAddress, AlchemyPaymasterAddressV1, AlchemyPaymasterAddressV07V2, AlchemyPaymasterAddressV07V1, getAlchemyPaymasterAddress, PermitTypes, ERC20Abis, EIP7597Abis;
|
|
29847
29963
|
var init_gas_manager = __esm({
|
|
29848
29964
|
"node_modules/@account-kit/infra/dist/esm/gas-manager.js"() {
|
|
@@ -30031,7 +30147,7 @@ var init_invalidSignedPermit = __esm({
|
|
|
30031
30147
|
});
|
|
30032
30148
|
|
|
30033
30149
|
// node_modules/@account-kit/infra/dist/esm/middleware/gasManager.js
|
|
30034
|
-
import { fromHex as fromHex5, isHex as isHex2, encodeAbiParameters as encodeAbiParameters5, encodeFunctionData as
|
|
30150
|
+
import { fromHex as fromHex5, isHex as isHex2, encodeAbiParameters as encodeAbiParameters5, encodeFunctionData as encodeFunctionData6, parseAbi as parseAbi2 } from "viem";
|
|
30035
30151
|
function alchemyGasManagerMiddleware(policyId, policyToken, webhookData) {
|
|
30036
30152
|
const buildContext = async (args) => {
|
|
30037
30153
|
const context = { policyId };
|
|
@@ -30213,16 +30329,16 @@ var init_gasManager = __esm({
|
|
|
30213
30329
|
}
|
|
30214
30330
|
let allowanceFuture = client.call({
|
|
30215
30331
|
to: policyToken.address,
|
|
30216
|
-
data:
|
|
30217
|
-
abi:
|
|
30332
|
+
data: encodeFunctionData6({
|
|
30333
|
+
abi: parseAbi2(ERC20Abis),
|
|
30218
30334
|
functionName: "allowance",
|
|
30219
30335
|
args: [account.address, paymasterAddress]
|
|
30220
30336
|
})
|
|
30221
30337
|
});
|
|
30222
30338
|
let nonceFuture = client.call({
|
|
30223
30339
|
to: policyToken.address,
|
|
30224
|
-
data:
|
|
30225
|
-
abi:
|
|
30340
|
+
data: encodeFunctionData6({
|
|
30341
|
+
abi: parseAbi2(EIP7597Abis),
|
|
30226
30342
|
functionName: "nonces",
|
|
30227
30343
|
args: [account.address]
|
|
30228
30344
|
})
|
|
@@ -30675,7 +30791,7 @@ var init_fee_utils = __esm({
|
|
|
30675
30791
|
|
|
30676
30792
|
// src/smart-account/permit2.ts
|
|
30677
30793
|
import {
|
|
30678
|
-
encodeFunctionData as
|
|
30794
|
+
encodeFunctionData as encodeFunctionData7,
|
|
30679
30795
|
keccak256 as keccak2567,
|
|
30680
30796
|
encodeAbiParameters as encodeAbiParameters6,
|
|
30681
30797
|
concat as concat6,
|
|
@@ -30799,7 +30915,7 @@ async function signPermit2(eip1193Request, params) {
|
|
|
30799
30915
|
return sig;
|
|
30800
30916
|
}
|
|
30801
30917
|
function encodePermitTransferFrom(token, amount, nonce, deadline, saAddress, eoaAddress, sig) {
|
|
30802
|
-
return
|
|
30918
|
+
return encodeFunctionData7({
|
|
30803
30919
|
abi: PERMIT2_ABI,
|
|
30804
30920
|
functionName: "permitTransferFrom",
|
|
30805
30921
|
args: [
|
|
@@ -30811,28 +30927,28 @@ function encodePermitTransferFrom(token, amount, nonce, deadline, saAddress, eoa
|
|
|
30811
30927
|
});
|
|
30812
30928
|
}
|
|
30813
30929
|
function encodeErc20Approve(spender, amount) {
|
|
30814
|
-
return
|
|
30930
|
+
return encodeFunctionData7({
|
|
30815
30931
|
abi: ERC20_APPROVE_ABI,
|
|
30816
30932
|
functionName: "approve",
|
|
30817
30933
|
args: [spender, amount]
|
|
30818
30934
|
});
|
|
30819
30935
|
}
|
|
30820
30936
|
function encodeErc20Allowance(owner, spender) {
|
|
30821
|
-
return
|
|
30937
|
+
return encodeFunctionData7({
|
|
30822
30938
|
abi: ERC20_ALLOWANCE_ABI,
|
|
30823
30939
|
functionName: "allowance",
|
|
30824
30940
|
args: [owner, spender]
|
|
30825
30941
|
});
|
|
30826
30942
|
}
|
|
30827
30943
|
function encodeErc20BalanceOf(owner) {
|
|
30828
|
-
return
|
|
30944
|
+
return encodeFunctionData7({
|
|
30829
30945
|
abi: ERC20_BALANCE_OF_ABI,
|
|
30830
30946
|
functionName: "balanceOf",
|
|
30831
30947
|
args: [owner]
|
|
30832
30948
|
});
|
|
30833
30949
|
}
|
|
30834
30950
|
function encodeWethWithdraw(amount) {
|
|
30835
|
-
return
|
|
30951
|
+
return encodeFunctionData7({
|
|
30836
30952
|
abi: WETH_ABI,
|
|
30837
30953
|
functionName: "withdraw",
|
|
30838
30954
|
args: [amount]
|
|
@@ -30925,9 +31041,9 @@ var init_permit2 = __esm({
|
|
|
30925
31041
|
});
|
|
30926
31042
|
|
|
30927
31043
|
// src/smart-account/uniswap.ts
|
|
30928
|
-
import { encodeFunctionData as
|
|
31044
|
+
import { encodeFunctionData as encodeFunctionData8 } from "viem";
|
|
30929
31045
|
function encodeUniswapExactOutputSingle(tokenIn, tokenOut, fee, recipient, amountOut, amountInMaximum) {
|
|
30930
|
-
return
|
|
31046
|
+
return encodeFunctionData8({
|
|
30931
31047
|
abi: SWAP_ROUTER_ABI,
|
|
30932
31048
|
functionName: "exactOutputSingle",
|
|
30933
31049
|
args: [
|
|
@@ -31455,14 +31571,14 @@ var init_smart_account2 = __esm({
|
|
|
31455
31571
|
|
|
31456
31572
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
31457
31573
|
import { useCallback as useCallback19, useEffect as useEffect26, useMemo as useMemo20, useRef as useRef13, useState as useState26 } from "react";
|
|
31458
|
-
import { encodeFunctionData as
|
|
31574
|
+
import { encodeFunctionData as encodeFunctionData9, erc20Abi } from "viem";
|
|
31459
31575
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
31460
31576
|
const chainType = (chain.type ?? chain.chainType ?? "").toLowerCase();
|
|
31461
31577
|
const value = (addr ?? "").trim();
|
|
31462
31578
|
if (chainType === "solana") return value;
|
|
31463
31579
|
return value.toLowerCase();
|
|
31464
31580
|
}
|
|
31465
|
-
function
|
|
31581
|
+
function sleep3(ms) {
|
|
31466
31582
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
31467
31583
|
}
|
|
31468
31584
|
function useTransactionActionModel({
|
|
@@ -31580,7 +31696,7 @@ function useTransactionActionModel({
|
|
|
31580
31696
|
if (status.status === "reverted") {
|
|
31581
31697
|
throw new Error("Approval transaction reverted");
|
|
31582
31698
|
}
|
|
31583
|
-
await
|
|
31699
|
+
await sleep3(intervalMs);
|
|
31584
31700
|
}
|
|
31585
31701
|
throw new Error("Timed out waiting for approval confirmation");
|
|
31586
31702
|
},
|
|
@@ -31620,7 +31736,7 @@ function useTransactionActionModel({
|
|
|
31620
31736
|
}
|
|
31621
31737
|
}
|
|
31622
31738
|
}
|
|
31623
|
-
const data =
|
|
31739
|
+
const data = encodeFunctionData9({
|
|
31624
31740
|
abi: erc20Abi,
|
|
31625
31741
|
functionName: "approve",
|
|
31626
31742
|
args: [spender, amountWei]
|
|
@@ -33230,7 +33346,7 @@ var init_useSwapRoute = __esm({
|
|
|
33230
33346
|
|
|
33231
33347
|
// src/modes/swap/hooks/useSwapExecution.ts
|
|
33232
33348
|
import { useCallback as useCallback21, useRef as useRef16, useState as useState29 } from "react";
|
|
33233
|
-
import { encodeFunctionData as
|
|
33349
|
+
import { encodeFunctionData as encodeFunctionData10, erc20Abi as erc20Abi2 } from "viem";
|
|
33234
33350
|
function normalizeTx(raw) {
|
|
33235
33351
|
const r = raw;
|
|
33236
33352
|
return {
|
|
@@ -33241,7 +33357,7 @@ function normalizeTx(raw) {
|
|
|
33241
33357
|
toChainTxUrl: r.toChainTxUrl || r.to_chain_tx_url || void 0
|
|
33242
33358
|
};
|
|
33243
33359
|
}
|
|
33244
|
-
function
|
|
33360
|
+
function sleep4(ms) {
|
|
33245
33361
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
33246
33362
|
}
|
|
33247
33363
|
function isUserRejection(err) {
|
|
@@ -33259,7 +33375,7 @@ async function waitForApprovalConfirmation(chainId, txHash) {
|
|
|
33259
33375
|
if (status.status === "success") return;
|
|
33260
33376
|
if (status.status === "reverted")
|
|
33261
33377
|
throw new Error("Approval transaction reverted");
|
|
33262
|
-
await
|
|
33378
|
+
await sleep4(2e3);
|
|
33263
33379
|
}
|
|
33264
33380
|
throw new Error("Timed out waiting for approval confirmation");
|
|
33265
33381
|
}
|
|
@@ -33499,7 +33615,7 @@ function useSwapExecution(fromChain) {
|
|
|
33499
33615
|
const approveAmount = maxApproval ? BigInt(
|
|
33500
33616
|
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
|
33501
33617
|
) : fromAmountWei;
|
|
33502
|
-
const data =
|
|
33618
|
+
const data = encodeFunctionData10({
|
|
33503
33619
|
abi: erc20Abi2,
|
|
33504
33620
|
functionName: "approve",
|
|
33505
33621
|
args: [spender, approveAmount]
|