@trustware/sdk-staging 1.1.9-staging.6 → 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/LICENSE +5 -4
- package/README.md +32 -1
- package/THIRD_PARTY_NOTICES.md +118 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-BTPkApRH.d.cts → core-B7Ez-5-r.d.cts} +3 -2
- package/dist/{core-2oZuxC1J.d.ts → core-BPLiD1UG.d.ts} +3 -2
- package/dist/core.cjs +246 -48
- 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 +247 -48
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +300 -76
- 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 +325 -103
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-BMO1O-cW.d.ts → manager-B6NNV-E_.d.ts} +129 -18
- package/dist/{manager-BZwbtOyf.d.cts → manager-BwjyFjjz.d.cts} +129 -18
- package/dist/{detect-B8xXLwHK.d.ts → metadata-BiTMMvlY.d.ts} +5 -2
- package/dist/{detect-C8xpZRrL.d.cts → metadata-HCflXcsF.d.cts} +5 -2
- package/dist/smart-account.cjs +117 -39
- 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 +117 -39
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +113 -36
- 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 +113 -36
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +239 -54
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +267 -81
- package/dist/widget.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -49,6 +49,31 @@ var init_config = __esm({
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
// src/errors/TrustwareError.ts
|
|
53
|
+
var TrustwareError;
|
|
54
|
+
var init_TrustwareError = __esm({
|
|
55
|
+
"src/errors/TrustwareError.ts"() {
|
|
56
|
+
"use strict";
|
|
57
|
+
TrustwareError = class extends Error {
|
|
58
|
+
constructor(params) {
|
|
59
|
+
super(params.message);
|
|
60
|
+
this.name = "TrustwareError";
|
|
61
|
+
this.code = params.code;
|
|
62
|
+
this.userMessage = params.userMessage;
|
|
63
|
+
this.cause = params.cause;
|
|
64
|
+
}
|
|
65
|
+
toJSON() {
|
|
66
|
+
return {
|
|
67
|
+
name: this.name,
|
|
68
|
+
code: this.code,
|
|
69
|
+
message: this.message,
|
|
70
|
+
userMessage: this.userMessage
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
52
77
|
// src/config/merge.ts
|
|
53
78
|
function deepMerge(base2, patch) {
|
|
54
79
|
if (!patch) return { ...base2 };
|
|
@@ -69,46 +94,80 @@ function normalizeSlippage(v) {
|
|
|
69
94
|
if (n > 5) return 5;
|
|
70
95
|
return n;
|
|
71
96
|
}
|
|
97
|
+
function warnDeprecatedSwapModeFlag() {
|
|
98
|
+
if (hasWarnedDeprecatedSwapModeFlag) return;
|
|
99
|
+
hasWarnedDeprecatedSwapModeFlag = true;
|
|
100
|
+
console.warn(
|
|
101
|
+
'[Trustware SDK] `features.swapMode` is deprecated \u2014 use `mode: "swap"` on the top-level config instead.'
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function resolveMode(input) {
|
|
105
|
+
if (input.mode === "swap") return "swap";
|
|
106
|
+
if (input.mode === "deposit") return "deposit";
|
|
107
|
+
if (input.features?.swapMode) {
|
|
108
|
+
warnDeprecatedSwapModeFlag();
|
|
109
|
+
return "swap";
|
|
110
|
+
}
|
|
111
|
+
return "deposit";
|
|
112
|
+
}
|
|
72
113
|
function resolveConfig(input) {
|
|
73
114
|
if (!input?.apiKey) {
|
|
74
|
-
throw new
|
|
115
|
+
throw new TrustwareError({
|
|
116
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
117
|
+
message: "TrustwareConfig: 'apiKey' is required.",
|
|
118
|
+
userMessage: "Missing required API key configuration."
|
|
119
|
+
});
|
|
75
120
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
121
|
+
const mode = resolveMode(input);
|
|
122
|
+
if (mode === "deposit" && (!input.routes?.toChain || !input.routes?.toToken)) {
|
|
123
|
+
throw new TrustwareError({
|
|
124
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
125
|
+
message: "TrustwareConfig: 'routes.toChain' and 'routes.toToken' are required in deposit mode.",
|
|
126
|
+
userMessage: "Missing required destination chain/token configuration."
|
|
127
|
+
});
|
|
80
128
|
}
|
|
81
|
-
const toChain = input.routes
|
|
82
|
-
if (input.routes
|
|
129
|
+
const toChain = input.routes?.toChain;
|
|
130
|
+
if (input.routes?.toAddress && toChain) {
|
|
83
131
|
const result = validateAddressForChain(input.routes.toAddress, toChain);
|
|
84
132
|
if (!result.isValid) {
|
|
85
133
|
console.error(`[Trustware SDK] Invalid toAddress: ${result.error}`);
|
|
86
|
-
throw new
|
|
134
|
+
throw new TrustwareError({
|
|
135
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
136
|
+
message: `Invalid toAddress: ${result.error}`,
|
|
137
|
+
userMessage: "The configured destination address is invalid."
|
|
138
|
+
});
|
|
87
139
|
}
|
|
88
140
|
}
|
|
89
|
-
if (input.routes
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
141
|
+
if (input.routes?.fromAddress) {
|
|
142
|
+
const fromChain = input.routes.fromChain ?? toChain;
|
|
143
|
+
if (fromChain) {
|
|
144
|
+
const result = validateAddressForChain(
|
|
145
|
+
input.routes.fromAddress,
|
|
146
|
+
fromChain
|
|
147
|
+
);
|
|
148
|
+
if (!result.isValid) {
|
|
149
|
+
console.error(`[Trustware SDK] Invalid fromAddress: ${result.error}`);
|
|
150
|
+
throw new TrustwareError({
|
|
151
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
152
|
+
message: `Invalid fromAddress: ${result.error}`,
|
|
153
|
+
userMessage: "The configured source address is invalid."
|
|
154
|
+
});
|
|
155
|
+
}
|
|
97
156
|
}
|
|
98
157
|
}
|
|
99
158
|
const autoDetectProvider = typeof input.autoDetectProvider === "boolean" ? input.autoDetectProvider : DEFAULT_AUTO_DETECT_PROVIDER;
|
|
100
159
|
const routes = {
|
|
101
|
-
toChain: input.routes
|
|
102
|
-
toToken: input.routes
|
|
103
|
-
fromToken: input.routes
|
|
104
|
-
fromAddress: input.routes
|
|
105
|
-
fromChain: input.routes
|
|
106
|
-
toAddress: input.routes
|
|
160
|
+
toChain: input.routes?.toChain ?? "",
|
|
161
|
+
toToken: input.routes?.toToken ?? "",
|
|
162
|
+
fromToken: input.routes?.fromToken,
|
|
163
|
+
fromAddress: input.routes?.fromAddress,
|
|
164
|
+
fromChain: input.routes?.fromChain,
|
|
165
|
+
toAddress: input.routes?.toAddress,
|
|
107
166
|
defaultSlippage: normalizeSlippage(
|
|
108
|
-
input.routes
|
|
167
|
+
input.routes?.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
109
168
|
),
|
|
110
169
|
options: {
|
|
111
|
-
...input.routes
|
|
170
|
+
...input.routes?.options
|
|
112
171
|
}
|
|
113
172
|
};
|
|
114
173
|
const theme = input.theme ?? "system";
|
|
@@ -127,13 +186,16 @@ function resolveConfig(input) {
|
|
|
127
186
|
tokensPagination: input.features?.tokensPagination ?? DEFAULT_FEATURE_FLAGS.tokensPagination,
|
|
128
187
|
balanceStreaming: input.features?.balanceStreaming ?? DEFAULT_FEATURE_FLAGS.balanceStreaming,
|
|
129
188
|
shouldAllowGA4: input.features?.shouldAllowGA4 ?? DEFAULT_FEATURE_FLAGS.shouldAllowGA4,
|
|
130
|
-
|
|
189
|
+
// Always mirrors the canonical `mode`, however the caller set it (new `mode` field
|
|
190
|
+
// or the deprecated `features.swapMode` flag).
|
|
191
|
+
swapMode: mode === "swap",
|
|
131
192
|
swapDefaultDestToken: input.features?.swapDefaultDestToken ?? DEFAULT_FEATURE_FLAGS.swapDefaultDestToken,
|
|
132
193
|
swapLockDestToken: input.features?.swapLockDestToken ?? DEFAULT_FEATURE_FLAGS.swapLockDestToken,
|
|
133
194
|
swapAllowedDestTokens: input.features?.swapAllowedDestTokens ?? DEFAULT_FEATURE_FLAGS.swapAllowedDestTokens
|
|
134
195
|
};
|
|
135
196
|
return {
|
|
136
197
|
apiKey: input.apiKey,
|
|
198
|
+
mode,
|
|
137
199
|
routes,
|
|
138
200
|
autoDetectProvider,
|
|
139
201
|
theme,
|
|
@@ -146,12 +208,15 @@ function resolveConfig(input) {
|
|
|
146
208
|
onEvent: input.onEvent
|
|
147
209
|
};
|
|
148
210
|
}
|
|
211
|
+
var hasWarnedDeprecatedSwapModeFlag;
|
|
149
212
|
var init_merge = __esm({
|
|
150
213
|
"src/config/merge.ts"() {
|
|
151
214
|
"use strict";
|
|
152
215
|
init_defaults();
|
|
153
216
|
init_config();
|
|
154
217
|
init_index();
|
|
218
|
+
init_TrustwareError();
|
|
219
|
+
hasWarnedDeprecatedSwapModeFlag = false;
|
|
155
220
|
}
|
|
156
221
|
});
|
|
157
222
|
|
|
@@ -408,7 +473,7 @@ var init_constants = __esm({
|
|
|
408
473
|
"src/constants.ts"() {
|
|
409
474
|
"use strict";
|
|
410
475
|
SDK_NAME = "@trustware/sdk";
|
|
411
|
-
SDK_VERSION = "1.1.
|
|
476
|
+
SDK_VERSION = "1.1.10-staging.0";
|
|
412
477
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
413
478
|
GTM_ID = "GTM-TZDGNCXB";
|
|
414
479
|
API_PREFIX = "/api";
|
|
@@ -1049,12 +1114,33 @@ var init_deepLink = __esm({
|
|
|
1049
1114
|
});
|
|
1050
1115
|
|
|
1051
1116
|
// src/wallets/metadata.ts
|
|
1052
|
-
var WALLETS;
|
|
1117
|
+
var POPULAR_ORDER, WALLETS;
|
|
1053
1118
|
var init_metadata = __esm({
|
|
1054
1119
|
"src/wallets/metadata.ts"() {
|
|
1055
1120
|
"use strict";
|
|
1056
1121
|
init_deepLink();
|
|
1057
1122
|
init_constants();
|
|
1123
|
+
POPULAR_ORDER = [
|
|
1124
|
+
"rabby",
|
|
1125
|
+
"metamask",
|
|
1126
|
+
"walletconnect",
|
|
1127
|
+
"rainbow",
|
|
1128
|
+
"phantom-evm",
|
|
1129
|
+
"phantom-solana",
|
|
1130
|
+
"metamask-solana",
|
|
1131
|
+
"solflare",
|
|
1132
|
+
"okx",
|
|
1133
|
+
"brave",
|
|
1134
|
+
"coinbase",
|
|
1135
|
+
"zerion",
|
|
1136
|
+
"taho",
|
|
1137
|
+
"trust",
|
|
1138
|
+
"bitget",
|
|
1139
|
+
"backpack",
|
|
1140
|
+
"imtoken",
|
|
1141
|
+
"safe",
|
|
1142
|
+
"kucoin"
|
|
1143
|
+
];
|
|
1058
1144
|
WALLETS = [
|
|
1059
1145
|
{
|
|
1060
1146
|
id: "metamask",
|
|
@@ -2392,7 +2478,9 @@ var init_chains = __esm({
|
|
|
2392
2478
|
btc: "bitcoin",
|
|
2393
2479
|
bitcoin: "bitcoin",
|
|
2394
2480
|
sei: "cosmos",
|
|
2395
|
-
"pacific-1": "cosmos"
|
|
2481
|
+
"pacific-1": "cosmos",
|
|
2482
|
+
nibiru: "cosmos",
|
|
2483
|
+
"cataclysm-1": "cosmos"
|
|
2396
2484
|
};
|
|
2397
2485
|
}
|
|
2398
2486
|
});
|
|
@@ -2448,6 +2536,25 @@ function validateSeiAddress(address) {
|
|
|
2448
2536
|
error: "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings."
|
|
2449
2537
|
};
|
|
2450
2538
|
}
|
|
2539
|
+
function resolveCosmosBech32Prefix(chain) {
|
|
2540
|
+
const chainDef = typeof chain === "object" && chain ? chain : void 0;
|
|
2541
|
+
const identifier = chainDef?.networkIdentifier ?? chainDef?.chainId ?? chainDef?.id ?? (typeof chain === "string" ? chain : void 0);
|
|
2542
|
+
const normalized = String(identifier ?? "").trim().toLowerCase();
|
|
2543
|
+
return COSMOS_BECH32_PREFIX_BY_CHAIN_ID[normalized] ?? "sei";
|
|
2544
|
+
}
|
|
2545
|
+
function validateCosmosAddress(address, chain) {
|
|
2546
|
+
const trimmed = address.trim();
|
|
2547
|
+
const prefix = resolveCosmosBech32Prefix(chain);
|
|
2548
|
+
if (prefix === "sei" && isEvmAddress(trimmed)) {
|
|
2549
|
+
return { isValid: true };
|
|
2550
|
+
}
|
|
2551
|
+
const result = validateBech32LikeAddress(trimmed, prefix);
|
|
2552
|
+
if (result.isValid) return result;
|
|
2553
|
+
return {
|
|
2554
|
+
isValid: false,
|
|
2555
|
+
error: prefix === "sei" ? "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings." : `Address must be a valid ${prefix}1 bech32 string.`
|
|
2556
|
+
};
|
|
2557
|
+
}
|
|
2451
2558
|
function validateSolanaAddress(address) {
|
|
2452
2559
|
const trimmed = address.trim();
|
|
2453
2560
|
if (trimmed.startsWith("0x") || isEvmAddress(trimmed)) {
|
|
@@ -2495,15 +2602,12 @@ function validateAddressForChain(address, chain) {
|
|
|
2495
2602
|
case "bitcoin":
|
|
2496
2603
|
return validateBtcAddress(trimmed);
|
|
2497
2604
|
case "cosmos":
|
|
2498
|
-
|
|
2499
|
-
return validateSeiAddress(trimmed);
|
|
2500
|
-
}
|
|
2501
|
-
return validateBech32LikeAddress(trimmed, "sei");
|
|
2605
|
+
return validateCosmosAddress(trimmed, chainDef ?? chain);
|
|
2502
2606
|
default:
|
|
2503
2607
|
return { isValid: false, error: "Unsupported or unknown chain type." };
|
|
2504
2608
|
}
|
|
2505
2609
|
}
|
|
2506
|
-
function validateAddressForRouteChain(address, chainType) {
|
|
2610
|
+
function validateAddressForRouteChain(address, chainType, chainRef) {
|
|
2507
2611
|
switch (normalizeChainType(chainType)) {
|
|
2508
2612
|
case "evm":
|
|
2509
2613
|
return validateEvmAddress(address);
|
|
@@ -2512,7 +2616,7 @@ function validateAddressForRouteChain(address, chainType) {
|
|
|
2512
2616
|
case "bitcoin":
|
|
2513
2617
|
return validateBtcAddress(address);
|
|
2514
2618
|
case "cosmos":
|
|
2515
|
-
return
|
|
2619
|
+
return validateCosmosAddress(address, chainRef ?? chainType);
|
|
2516
2620
|
default:
|
|
2517
2621
|
return { isValid: false, error: "Unsupported chain type." };
|
|
2518
2622
|
}
|
|
@@ -2534,14 +2638,18 @@ function validateRouteAddresses(params) {
|
|
|
2534
2638
|
const normalizedDirection = params.direction?.trim().toLowerCase();
|
|
2535
2639
|
const isDepositFlow = normalizedDirection === "deposit" || (toType === "evm" || toType === "cosmos") && (fromType === "bitcoin" || fromType === "solana");
|
|
2536
2640
|
if (isDepositFlow) {
|
|
2537
|
-
const fromResult2 = validateAddressForRouteChain(
|
|
2641
|
+
const fromResult2 = validateAddressForRouteChain(
|
|
2642
|
+
fromAddress,
|
|
2643
|
+
fromType,
|
|
2644
|
+
params.fromChain
|
|
2645
|
+
);
|
|
2538
2646
|
if (!fromResult2.isValid) {
|
|
2539
2647
|
return {
|
|
2540
2648
|
isValid: false,
|
|
2541
2649
|
error: `From address: ${fromResult2.error ?? "Invalid address."}`
|
|
2542
2650
|
};
|
|
2543
2651
|
}
|
|
2544
|
-
const toResult2 = toType === "cosmos" ?
|
|
2652
|
+
const toResult2 = toType === "cosmos" ? validateCosmosAddress(toAddress, params.toChain) : validateEvmAddress(toAddress);
|
|
2545
2653
|
if (!toResult2.isValid) {
|
|
2546
2654
|
return {
|
|
2547
2655
|
isValid: false,
|
|
@@ -2566,14 +2674,22 @@ function validateRouteAddresses(params) {
|
|
|
2566
2674
|
}
|
|
2567
2675
|
return { isValid: true };
|
|
2568
2676
|
}
|
|
2569
|
-
const fromResult = validateAddressForRouteChain(
|
|
2677
|
+
const fromResult = validateAddressForRouteChain(
|
|
2678
|
+
fromAddress,
|
|
2679
|
+
fromType,
|
|
2680
|
+
params.fromChain
|
|
2681
|
+
);
|
|
2570
2682
|
if (!fromResult.isValid) {
|
|
2571
2683
|
return {
|
|
2572
2684
|
isValid: false,
|
|
2573
2685
|
error: `From address: ${fromResult.error ?? "Invalid address."}`
|
|
2574
2686
|
};
|
|
2575
2687
|
}
|
|
2576
|
-
const toResult = validateAddressForRouteChain(
|
|
2688
|
+
const toResult = validateAddressForRouteChain(
|
|
2689
|
+
toAddress,
|
|
2690
|
+
toType,
|
|
2691
|
+
params.toChain
|
|
2692
|
+
);
|
|
2577
2693
|
if (!toResult.isValid) {
|
|
2578
2694
|
return {
|
|
2579
2695
|
isValid: false,
|
|
@@ -2582,13 +2698,19 @@ function validateRouteAddresses(params) {
|
|
|
2582
2698
|
}
|
|
2583
2699
|
return { isValid: true };
|
|
2584
2700
|
}
|
|
2585
|
-
var BECH32_CHARSET;
|
|
2701
|
+
var BECH32_CHARSET, COSMOS_BECH32_PREFIX_BY_CHAIN_ID;
|
|
2586
2702
|
var init_address = __esm({
|
|
2587
2703
|
"src/validation/address.ts"() {
|
|
2588
2704
|
"use strict";
|
|
2589
2705
|
init_index_node4();
|
|
2590
2706
|
init_chains();
|
|
2591
2707
|
BECH32_CHARSET = /^[023456789acdefghjklmnpqrstuvwxyz]+$/i;
|
|
2708
|
+
COSMOS_BECH32_PREFIX_BY_CHAIN_ID = {
|
|
2709
|
+
"pacific-1": "sei",
|
|
2710
|
+
sei: "sei",
|
|
2711
|
+
"cataclysm-1": "nibi",
|
|
2712
|
+
nibiru: "nibi"
|
|
2713
|
+
};
|
|
2592
2714
|
}
|
|
2593
2715
|
});
|
|
2594
2716
|
|
|
@@ -4255,6 +4377,27 @@ var init_wallets = __esm({
|
|
|
4255
4377
|
});
|
|
4256
4378
|
|
|
4257
4379
|
// src/core/routes.ts
|
|
4380
|
+
function assertValidPostHook(hooks) {
|
|
4381
|
+
const postHook = hooks?.postHook;
|
|
4382
|
+
if (!postHook) return;
|
|
4383
|
+
if (!postHook.target?.trim()) {
|
|
4384
|
+
throw new Error("hooks.postHook.target is required.");
|
|
4385
|
+
}
|
|
4386
|
+
if (!postHook.callData?.trim()) {
|
|
4387
|
+
throw new Error("hooks.postHook.callData is required.");
|
|
4388
|
+
}
|
|
4389
|
+
if (postHook.fullAmount) {
|
|
4390
|
+
if (postHook.amountInputPos === void 0) {
|
|
4391
|
+
throw new Error(
|
|
4392
|
+
"hooks.postHook.amountInputPos is required when fullAmount is true."
|
|
4393
|
+
);
|
|
4394
|
+
}
|
|
4395
|
+
} else if (!postHook.fundAmount?.trim()) {
|
|
4396
|
+
throw new Error(
|
|
4397
|
+
"hooks.postHook.fundAmount is required unless fullAmount is set."
|
|
4398
|
+
);
|
|
4399
|
+
}
|
|
4400
|
+
}
|
|
4258
4401
|
function isEvmTxRequest(txReq) {
|
|
4259
4402
|
return Boolean(txReq?.data && (txReq.to || txReq.target));
|
|
4260
4403
|
}
|
|
@@ -4273,6 +4416,7 @@ async function buildRoute(body, signal) {
|
|
|
4273
4416
|
if (!addressValidation.isValid) {
|
|
4274
4417
|
throw new Error(addressValidation.error || "Invalid route addresses.");
|
|
4275
4418
|
}
|
|
4419
|
+
assertValidPostHook(body.hooks);
|
|
4276
4420
|
const cfg = TrustwareConfigStore.get();
|
|
4277
4421
|
const url = `${apiBase()}/v1/routes/route`;
|
|
4278
4422
|
const payload = {
|
|
@@ -4311,6 +4455,7 @@ async function buildRoute(body, signal) {
|
|
|
4311
4455
|
return { intentId, txReq, actions, finalExchangeRate, route, sponsorship };
|
|
4312
4456
|
}
|
|
4313
4457
|
async function buildDepositAddress(body, signal) {
|
|
4458
|
+
assertValidPostHook(body.hooks);
|
|
4314
4459
|
const cfg = TrustwareConfigStore.get();
|
|
4315
4460
|
const url = `${apiBase()}/v1/routes/deposit-address`;
|
|
4316
4461
|
const payload = {
|
|
@@ -4352,7 +4497,7 @@ async function buildDepositAddress(body, signal) {
|
|
|
4352
4497
|
route
|
|
4353
4498
|
};
|
|
4354
4499
|
}
|
|
4355
|
-
async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
4500
|
+
async function submitReceipt(intentId, txHash, sponsorshipRequestId, eoaAddress) {
|
|
4356
4501
|
const r = await rateLimitedFetch(
|
|
4357
4502
|
`${apiBase()}/v1/route-intent/${intentId}/receipt`,
|
|
4358
4503
|
{
|
|
@@ -4360,7 +4505,8 @@ async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
|
4360
4505
|
headers: jsonHeaders({ "Idempotency-Key": txHash }),
|
|
4361
4506
|
body: JSON.stringify({
|
|
4362
4507
|
txHash,
|
|
4363
|
-
...sponsorshipRequestId ? { sponsorshipRequestId } : {}
|
|
4508
|
+
...sponsorshipRequestId ? { sponsorshipRequestId } : {},
|
|
4509
|
+
...eoaAddress ? { eoaAddress } : {}
|
|
4364
4510
|
})
|
|
4365
4511
|
}
|
|
4366
4512
|
);
|
|
@@ -5058,11 +5204,92 @@ var init_registryClient = __esm({
|
|
|
5058
5204
|
});
|
|
5059
5205
|
|
|
5060
5206
|
// src/core/tx.ts
|
|
5061
|
-
import { keccak256 } from "viem";
|
|
5207
|
+
import { keccak256, encodeFunctionData, parseAbi } from "viem";
|
|
5062
5208
|
function backendChainId(chain, fallback) {
|
|
5063
5209
|
const preferred = chain?.networkIdentifier ?? chain?.chainId ?? chain?.id;
|
|
5064
5210
|
return String(preferred ?? fallback ?? "");
|
|
5065
5211
|
}
|
|
5212
|
+
function sleep2(ms) {
|
|
5213
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5214
|
+
}
|
|
5215
|
+
async function sendEvmTx(w, tx) {
|
|
5216
|
+
if (w.type === "eip1193") {
|
|
5217
|
+
const from = await w.getAddress();
|
|
5218
|
+
const params = {
|
|
5219
|
+
from,
|
|
5220
|
+
to: tx.to,
|
|
5221
|
+
data: tx.data,
|
|
5222
|
+
value: tx.value ? `0x${tx.value.toString(16)}` : "0x0"
|
|
5223
|
+
};
|
|
5224
|
+
if (tx.chainId !== void 0) {
|
|
5225
|
+
params.chainId = `0x${tx.chainId.toString(16)}`;
|
|
5226
|
+
}
|
|
5227
|
+
const hash = await w.request({
|
|
5228
|
+
method: "eth_sendTransaction",
|
|
5229
|
+
params: [params]
|
|
5230
|
+
});
|
|
5231
|
+
return hash;
|
|
5232
|
+
}
|
|
5233
|
+
const response = await w.sendTransaction({
|
|
5234
|
+
to: tx.to,
|
|
5235
|
+
data: tx.data,
|
|
5236
|
+
value: tx.value,
|
|
5237
|
+
chainId: tx.chainId
|
|
5238
|
+
});
|
|
5239
|
+
return response.hash;
|
|
5240
|
+
}
|
|
5241
|
+
async function waitForTxConfirmation(chainId, txHash) {
|
|
5242
|
+
const timeoutMs = 12e4;
|
|
5243
|
+
const intervalMs = 2e3;
|
|
5244
|
+
const started = Date.now();
|
|
5245
|
+
while (Date.now() - started < timeoutMs) {
|
|
5246
|
+
const status = await getEVMTxStatus({ chainId, txHash });
|
|
5247
|
+
if (status.status === "success") return;
|
|
5248
|
+
if (status.status === "reverted") {
|
|
5249
|
+
throw new Error("Approval transaction reverted");
|
|
5250
|
+
}
|
|
5251
|
+
await sleep2(intervalMs);
|
|
5252
|
+
}
|
|
5253
|
+
throw new Error("Timed out waiting for approval confirmation");
|
|
5254
|
+
}
|
|
5255
|
+
async function ensureApprovals(w, approvals, fallbackChainId) {
|
|
5256
|
+
if (!approvals || approvals.length === 0) return;
|
|
5257
|
+
const owner = await w.getAddress();
|
|
5258
|
+
for (const approval of approvals) {
|
|
5259
|
+
const spender = approval.spender;
|
|
5260
|
+
const tokenAddress = approval.tokenAddress;
|
|
5261
|
+
const amount = approval.amount;
|
|
5262
|
+
if (!spender || !tokenAddress || !amount) continue;
|
|
5263
|
+
const chainId = approval.chainId || String(fallbackChainId ?? "");
|
|
5264
|
+
if (!chainId) continue;
|
|
5265
|
+
const amountWei = BigInt(amount);
|
|
5266
|
+
if (amountWei === 0n) continue;
|
|
5267
|
+
let currentAllowance = 0n;
|
|
5268
|
+
try {
|
|
5269
|
+
const { allowance } = await getEVMAllowance({
|
|
5270
|
+
chainId,
|
|
5271
|
+
tokenAddress,
|
|
5272
|
+
ownerAddress: owner,
|
|
5273
|
+
spenderAddress: spender
|
|
5274
|
+
});
|
|
5275
|
+
currentAllowance = BigInt(allowance || "0");
|
|
5276
|
+
} catch {
|
|
5277
|
+
}
|
|
5278
|
+
if (currentAllowance >= amountWei) continue;
|
|
5279
|
+
const data = encodeFunctionData({
|
|
5280
|
+
abi: erc20ApproveAbi,
|
|
5281
|
+
functionName: "approve",
|
|
5282
|
+
args: [spender, amountWei]
|
|
5283
|
+
});
|
|
5284
|
+
const hash = await sendEvmTx(w, {
|
|
5285
|
+
to: tokenAddress,
|
|
5286
|
+
data,
|
|
5287
|
+
value: 0n,
|
|
5288
|
+
chainId: Number.isFinite(Number(chainId)) ? Number(chainId) : void 0
|
|
5289
|
+
});
|
|
5290
|
+
await waitForTxConfirmation(chainId, hash);
|
|
5291
|
+
}
|
|
5292
|
+
}
|
|
5066
5293
|
function isUserRejected(e2) {
|
|
5067
5294
|
const code = e2?.code ?? e2?.data?.code;
|
|
5068
5295
|
if (code === 4001) return true;
|
|
@@ -5096,6 +5323,13 @@ async function sendRouteTransaction(b, fallbackChainId) {
|
|
|
5096
5323
|
}
|
|
5097
5324
|
}
|
|
5098
5325
|
}
|
|
5326
|
+
if (!validatedSponsorship) {
|
|
5327
|
+
await ensureApprovals(
|
|
5328
|
+
w,
|
|
5329
|
+
b.route?.execution?.approvals,
|
|
5330
|
+
Number.isFinite(target) ? target : void 0
|
|
5331
|
+
);
|
|
5332
|
+
}
|
|
5099
5333
|
if (w.type === "eip1193") {
|
|
5100
5334
|
const from = await w.getAddress();
|
|
5101
5335
|
const hexValue = value ? `0x${value.toString(16)}` : "0x0";
|
|
@@ -5192,11 +5426,16 @@ async function runTopUp(params) {
|
|
|
5192
5426
|
}
|
|
5193
5427
|
}
|
|
5194
5428
|
}
|
|
5429
|
+
var erc20ApproveAbi;
|
|
5195
5430
|
var init_tx = __esm({
|
|
5196
5431
|
"src/core/tx.ts"() {
|
|
5197
5432
|
"use strict";
|
|
5198
5433
|
init_wallets();
|
|
5199
5434
|
init_routes();
|
|
5435
|
+
init_sdkRpc();
|
|
5436
|
+
erc20ApproveAbi = parseAbi([
|
|
5437
|
+
"function approve(address spender, uint256 amount) returns (bool)"
|
|
5438
|
+
]);
|
|
5200
5439
|
}
|
|
5201
5440
|
});
|
|
5202
5441
|
|
|
@@ -5318,7 +5557,9 @@ var init_chainHelpers = __esm({
|
|
|
5318
5557
|
btc: "bitcoin",
|
|
5319
5558
|
bitcoin: "bitcoin",
|
|
5320
5559
|
sei: "cosmos",
|
|
5321
|
-
"pacific-1": "cosmos"
|
|
5560
|
+
"pacific-1": "cosmos",
|
|
5561
|
+
nibiru: "cosmos",
|
|
5562
|
+
"cataclysm-1": "cosmos"
|
|
5322
5563
|
};
|
|
5323
5564
|
SEI_EVM_CHAIN_ID = "1329";
|
|
5324
5565
|
SEI_COSMOS_CHAIN_ID = "pacific-1";
|
|
@@ -5534,7 +5775,8 @@ function filterSupportedChains(chains) {
|
|
|
5534
5775
|
}
|
|
5535
5776
|
if (chainType === "cosmos") {
|
|
5536
5777
|
const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
|
|
5537
|
-
|
|
5778
|
+
const isNibiru = normalizeChainKey2(chain.chainId ?? chain.id) === NIBIRU_COSMOS_CHAIN_ID;
|
|
5779
|
+
if (seiKey !== "sei" && !isNibiru) {
|
|
5538
5780
|
return false;
|
|
5539
5781
|
}
|
|
5540
5782
|
}
|
|
@@ -5634,7 +5876,7 @@ function useChains() {
|
|
|
5634
5876
|
error
|
|
5635
5877
|
};
|
|
5636
5878
|
}
|
|
5637
|
-
var POPULAR_CHAINS_BY_TVL, POPULAR_LIMIT;
|
|
5879
|
+
var POPULAR_CHAINS_BY_TVL, POPULAR_LIMIT, NIBIRU_COSMOS_CHAIN_ID;
|
|
5638
5880
|
var init_useChains = __esm({
|
|
5639
5881
|
"src/core/useChains.ts"() {
|
|
5640
5882
|
"use strict";
|
|
@@ -5644,6 +5886,7 @@ var init_useChains = __esm({
|
|
|
5644
5886
|
init_popularChains();
|
|
5645
5887
|
POPULAR_CHAINS_BY_TVL = popularChains_default.byTvl;
|
|
5646
5888
|
POPULAR_LIMIT = popularChains_default.popularLimit;
|
|
5889
|
+
NIBIRU_COSMOS_CHAIN_ID = "cataclysm-1";
|
|
5647
5890
|
}
|
|
5648
5891
|
});
|
|
5649
5892
|
|
|
@@ -7324,31 +7567,6 @@ var init_useTokens = __esm({
|
|
|
7324
7567
|
}
|
|
7325
7568
|
});
|
|
7326
7569
|
|
|
7327
|
-
// src/errors/TrustwareError.ts
|
|
7328
|
-
var TrustwareError;
|
|
7329
|
-
var init_TrustwareError = __esm({
|
|
7330
|
-
"src/errors/TrustwareError.ts"() {
|
|
7331
|
-
"use strict";
|
|
7332
|
-
TrustwareError = class extends Error {
|
|
7333
|
-
constructor(params) {
|
|
7334
|
-
super(params.message);
|
|
7335
|
-
this.name = "TrustwareError";
|
|
7336
|
-
this.code = params.code;
|
|
7337
|
-
this.userMessage = params.userMessage;
|
|
7338
|
-
this.cause = params.cause;
|
|
7339
|
-
}
|
|
7340
|
-
toJSON() {
|
|
7341
|
-
return {
|
|
7342
|
-
name: this.name,
|
|
7343
|
-
code: this.code,
|
|
7344
|
-
message: this.message,
|
|
7345
|
-
userMessage: this.userMessage
|
|
7346
|
-
};
|
|
7347
|
-
}
|
|
7348
|
-
};
|
|
7349
|
-
}
|
|
7350
|
-
});
|
|
7351
|
-
|
|
7352
7570
|
// src/core/index.ts
|
|
7353
7571
|
var _lastValidatedKey, Trustware;
|
|
7354
7572
|
var init_core = __esm({
|
|
@@ -7950,6 +8168,7 @@ function useTrustwareConfig() {
|
|
|
7950
8168
|
} catch {
|
|
7951
8169
|
return {
|
|
7952
8170
|
apiKey: "",
|
|
8171
|
+
mode: "deposit",
|
|
7953
8172
|
routes: {
|
|
7954
8173
|
toChain: "",
|
|
7955
8174
|
toToken: "",
|
|
@@ -28303,7 +28522,7 @@ var init_utils5 = __esm({
|
|
|
28303
28522
|
});
|
|
28304
28523
|
|
|
28305
28524
|
// node_modules/@account-kit/smart-contracts/dist/esm/src/light-account/accounts/base.js
|
|
28306
|
-
import { concat as concat5, encodeFunctionData, fromHex as fromHex4, hashMessage, hashTypedData, trim } from "viem";
|
|
28525
|
+
import { concat as concat5, encodeFunctionData as encodeFunctionData2, fromHex as fromHex4, hashMessage, hashTypedData, trim } from "viem";
|
|
28307
28526
|
async function createLightAccountBase({ transport, chain, signer, abi, version, type, entryPoint, accountAddress, getAccountInitCode }) {
|
|
28308
28527
|
const client = createBundlerClient({
|
|
28309
28528
|
transport,
|
|
@@ -28322,7 +28541,7 @@ async function createLightAccountBase({ transport, chain, signer, abi, version,
|
|
|
28322
28541
|
if (fromHex4(storage, "number") !== 0 && !implementationAddresses.some((x) => x === trim(storage))) {
|
|
28323
28542
|
throw new Error(`could not determine if smart account implementation is ${type} ${String(version)}`);
|
|
28324
28543
|
}
|
|
28325
|
-
return
|
|
28544
|
+
return encodeFunctionData2({
|
|
28326
28545
|
abi,
|
|
28327
28546
|
functionName: "upgradeToAndCall",
|
|
28328
28547
|
args: [upgradeToAddress, upgradeToInitData]
|
|
@@ -28381,7 +28600,7 @@ async function createLightAccountBase({ transport, chain, signer, abi, version,
|
|
|
28381
28600
|
prepareSign,
|
|
28382
28601
|
formatSign,
|
|
28383
28602
|
encodeExecute: async ({ target, data, value }) => {
|
|
28384
|
-
return
|
|
28603
|
+
return encodeFunctionData2({
|
|
28385
28604
|
abi,
|
|
28386
28605
|
functionName: "execute",
|
|
28387
28606
|
args: [target, value ?? 0n, data]
|
|
@@ -28394,7 +28613,7 @@ async function createLightAccountBase({ transport, chain, signer, abi, version,
|
|
|
28394
28613
|
accum[2].push(curr.data);
|
|
28395
28614
|
return accum;
|
|
28396
28615
|
}, [[], [], []]);
|
|
28397
|
-
return
|
|
28616
|
+
return encodeFunctionData2({
|
|
28398
28617
|
abi,
|
|
28399
28618
|
functionName: "executeBatch",
|
|
28400
28619
|
args: [targets, values, datas]
|
|
@@ -28488,7 +28707,7 @@ var init_OZ_ERC1967Proxy = __esm({
|
|
|
28488
28707
|
});
|
|
28489
28708
|
|
|
28490
28709
|
// node_modules/@account-kit/smart-contracts/dist/esm/src/light-account/accounts/predictAddress.js
|
|
28491
|
-
import { encodeAbiParameters as encodeAbiParameters4, encodeDeployData, keccak256 as keccak2565, getContractAddress, toHex as toHex6, encodeFunctionData as
|
|
28710
|
+
import { encodeAbiParameters as encodeAbiParameters4, encodeDeployData, keccak256 as keccak2565, getContractAddress, toHex as toHex6, encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
28492
28711
|
function predictLightAccountAddress({ factoryAddress, salt, ownerAddress, version }) {
|
|
28493
28712
|
const implementationAddress = (
|
|
28494
28713
|
// If we aren't using the default factory address, we compute the implementation address from the factory's `create` deployment.
|
|
@@ -28512,7 +28731,7 @@ function predictLightAccountAddress({ factoryAddress, salt, ownerAddress, versio
|
|
|
28512
28731
|
abi: OZ_ERC1967Proxy_ConstructorAbi,
|
|
28513
28732
|
args: [
|
|
28514
28733
|
implementationAddress,
|
|
28515
|
-
|
|
28734
|
+
encodeFunctionData3({
|
|
28516
28735
|
abi: LightAccountAbi_v1,
|
|
28517
28736
|
functionName: "initialize",
|
|
28518
28737
|
args: [ownerAddress]
|
|
@@ -28549,7 +28768,7 @@ var init_predictAddress = __esm({
|
|
|
28549
28768
|
});
|
|
28550
28769
|
|
|
28551
28770
|
// node_modules/@account-kit/smart-contracts/dist/esm/src/light-account/accounts/account.js
|
|
28552
|
-
import { concatHex as concatHex2, encodeFunctionData as
|
|
28771
|
+
import { concatHex as concatHex2, encodeFunctionData as encodeFunctionData4 } from "viem";
|
|
28553
28772
|
async function createLightAccount({ transport, chain, signer, initCode, version = defaultLightAccountVersion(), entryPoint = getEntryPoint(chain, {
|
|
28554
28773
|
version: AccountVersionRegistry["LightAccount"][version].entryPointVersion
|
|
28555
28774
|
}), accountAddress, factoryAddress = getDefaultLightAccountFactoryAddress(chain, version), salt: salt_ = 0n }) {
|
|
@@ -28566,7 +28785,7 @@ async function createLightAccount({ transport, chain, signer, initCode, version
|
|
|
28566
28785
|
return initCode;
|
|
28567
28786
|
return concatHex2([
|
|
28568
28787
|
factoryAddress,
|
|
28569
|
-
|
|
28788
|
+
encodeFunctionData4({
|
|
28570
28789
|
abi: factoryAbi,
|
|
28571
28790
|
functionName: "createAccount",
|
|
28572
28791
|
args: [signerAddress, salt]
|
|
@@ -28593,7 +28812,7 @@ async function createLightAccount({ transport, chain, signer, initCode, version
|
|
|
28593
28812
|
return {
|
|
28594
28813
|
...account,
|
|
28595
28814
|
encodeTransferOwnership: (newOwner) => {
|
|
28596
|
-
return
|
|
28815
|
+
return encodeFunctionData4({
|
|
28597
28816
|
abi: accountAbi,
|
|
28598
28817
|
functionName: "transferOwnership",
|
|
28599
28818
|
args: [newOwner]
|
|
@@ -29901,7 +30120,7 @@ var init_feeEstimator2 = __esm({
|
|
|
29901
30120
|
});
|
|
29902
30121
|
|
|
29903
30122
|
// node_modules/@account-kit/infra/dist/esm/gas-manager.js
|
|
29904
|
-
import { encodeFunctionData as
|
|
30123
|
+
import { encodeFunctionData as encodeFunctionData5 } from "viem";
|
|
29905
30124
|
var AlchemyPaymasterAddressV06Unify, AlchemyPaymasterAddressV07Unify, AlchemyPaymasterAddressV4, AlchemyPaymasterAddressV3, AlchemyPaymasterAddressV2, ArbSepoliaPaymasterAddress, AlchemyPaymasterAddressV1, AlchemyPaymasterAddressV07V2, AlchemyPaymasterAddressV07V1, getAlchemyPaymasterAddress, PermitTypes, ERC20Abis, EIP7597Abis;
|
|
29906
30125
|
var init_gas_manager = __esm({
|
|
29907
30126
|
"node_modules/@account-kit/infra/dist/esm/gas-manager.js"() {
|
|
@@ -30090,7 +30309,7 @@ var init_invalidSignedPermit = __esm({
|
|
|
30090
30309
|
});
|
|
30091
30310
|
|
|
30092
30311
|
// node_modules/@account-kit/infra/dist/esm/middleware/gasManager.js
|
|
30093
|
-
import { fromHex as fromHex5, isHex as isHex2, encodeAbiParameters as encodeAbiParameters5, encodeFunctionData as
|
|
30312
|
+
import { fromHex as fromHex5, isHex as isHex2, encodeAbiParameters as encodeAbiParameters5, encodeFunctionData as encodeFunctionData6, parseAbi as parseAbi2 } from "viem";
|
|
30094
30313
|
function alchemyGasManagerMiddleware(policyId, policyToken, webhookData) {
|
|
30095
30314
|
const buildContext = async (args) => {
|
|
30096
30315
|
const context = { policyId };
|
|
@@ -30272,16 +30491,16 @@ var init_gasManager = __esm({
|
|
|
30272
30491
|
}
|
|
30273
30492
|
let allowanceFuture = client.call({
|
|
30274
30493
|
to: policyToken.address,
|
|
30275
|
-
data:
|
|
30276
|
-
abi:
|
|
30494
|
+
data: encodeFunctionData6({
|
|
30495
|
+
abi: parseAbi2(ERC20Abis),
|
|
30277
30496
|
functionName: "allowance",
|
|
30278
30497
|
args: [account.address, paymasterAddress]
|
|
30279
30498
|
})
|
|
30280
30499
|
});
|
|
30281
30500
|
let nonceFuture = client.call({
|
|
30282
30501
|
to: policyToken.address,
|
|
30283
|
-
data:
|
|
30284
|
-
abi:
|
|
30502
|
+
data: encodeFunctionData6({
|
|
30503
|
+
abi: parseAbi2(EIP7597Abis),
|
|
30285
30504
|
functionName: "nonces",
|
|
30286
30505
|
args: [account.address]
|
|
30287
30506
|
})
|
|
@@ -30734,7 +30953,7 @@ var init_fee_utils = __esm({
|
|
|
30734
30953
|
|
|
30735
30954
|
// src/smart-account/permit2.ts
|
|
30736
30955
|
import {
|
|
30737
|
-
encodeFunctionData as
|
|
30956
|
+
encodeFunctionData as encodeFunctionData7,
|
|
30738
30957
|
keccak256 as keccak2567,
|
|
30739
30958
|
encodeAbiParameters as encodeAbiParameters6,
|
|
30740
30959
|
concat as concat6,
|
|
@@ -30858,7 +31077,7 @@ async function signPermit2(eip1193Request, params) {
|
|
|
30858
31077
|
return sig;
|
|
30859
31078
|
}
|
|
30860
31079
|
function encodePermitTransferFrom(token, amount, nonce, deadline, saAddress, eoaAddress, sig) {
|
|
30861
|
-
return
|
|
31080
|
+
return encodeFunctionData7({
|
|
30862
31081
|
abi: PERMIT2_ABI,
|
|
30863
31082
|
functionName: "permitTransferFrom",
|
|
30864
31083
|
args: [
|
|
@@ -30870,28 +31089,28 @@ function encodePermitTransferFrom(token, amount, nonce, deadline, saAddress, eoa
|
|
|
30870
31089
|
});
|
|
30871
31090
|
}
|
|
30872
31091
|
function encodeErc20Approve(spender, amount) {
|
|
30873
|
-
return
|
|
31092
|
+
return encodeFunctionData7({
|
|
30874
31093
|
abi: ERC20_APPROVE_ABI,
|
|
30875
31094
|
functionName: "approve",
|
|
30876
31095
|
args: [spender, amount]
|
|
30877
31096
|
});
|
|
30878
31097
|
}
|
|
30879
31098
|
function encodeErc20Allowance(owner, spender) {
|
|
30880
|
-
return
|
|
31099
|
+
return encodeFunctionData7({
|
|
30881
31100
|
abi: ERC20_ALLOWANCE_ABI,
|
|
30882
31101
|
functionName: "allowance",
|
|
30883
31102
|
args: [owner, spender]
|
|
30884
31103
|
});
|
|
30885
31104
|
}
|
|
30886
31105
|
function encodeErc20BalanceOf(owner) {
|
|
30887
|
-
return
|
|
31106
|
+
return encodeFunctionData7({
|
|
30888
31107
|
abi: ERC20_BALANCE_OF_ABI,
|
|
30889
31108
|
functionName: "balanceOf",
|
|
30890
31109
|
args: [owner]
|
|
30891
31110
|
});
|
|
30892
31111
|
}
|
|
30893
31112
|
function encodeWethWithdraw(amount) {
|
|
30894
|
-
return
|
|
31113
|
+
return encodeFunctionData7({
|
|
30895
31114
|
abi: WETH_ABI,
|
|
30896
31115
|
functionName: "withdraw",
|
|
30897
31116
|
args: [amount]
|
|
@@ -30984,9 +31203,9 @@ var init_permit2 = __esm({
|
|
|
30984
31203
|
});
|
|
30985
31204
|
|
|
30986
31205
|
// src/smart-account/uniswap.ts
|
|
30987
|
-
import { encodeFunctionData as
|
|
31206
|
+
import { encodeFunctionData as encodeFunctionData8 } from "viem";
|
|
30988
31207
|
function encodeUniswapExactOutputSingle(tokenIn, tokenOut, fee, recipient, amountOut, amountInMaximum) {
|
|
30989
|
-
return
|
|
31208
|
+
return encodeFunctionData8({
|
|
30990
31209
|
abi: SWAP_ROUTER_ABI,
|
|
30991
31210
|
functionName: "exactOutputSingle",
|
|
30992
31211
|
args: [
|
|
@@ -31468,7 +31687,7 @@ async function sendRouteAsUserOperation(params) {
|
|
|
31468
31687
|
);
|
|
31469
31688
|
}
|
|
31470
31689
|
console.debug("[send] UserOp included", { userOpHash, txHash });
|
|
31471
|
-
await submitReceipt(intentId, txHash, getSponsorshipRequestId());
|
|
31690
|
+
await submitReceipt(intentId, txHash, getSponsorshipRequestId(), eoaAddress);
|
|
31472
31691
|
return { userOpHash, txHash, intentId };
|
|
31473
31692
|
}
|
|
31474
31693
|
var NATIVE_ADDRS;
|
|
@@ -31514,14 +31733,14 @@ var init_smart_account2 = __esm({
|
|
|
31514
31733
|
|
|
31515
31734
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
31516
31735
|
import { useCallback as useCallback19, useEffect as useEffect26, useMemo as useMemo20, useRef as useRef13, useState as useState26 } from "react";
|
|
31517
|
-
import { encodeFunctionData as
|
|
31736
|
+
import { encodeFunctionData as encodeFunctionData9, erc20Abi } from "viem";
|
|
31518
31737
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
31519
31738
|
const chainType = (chain.type ?? chain.chainType ?? "").toLowerCase();
|
|
31520
31739
|
const value = (addr ?? "").trim();
|
|
31521
31740
|
if (chainType === "solana") return value;
|
|
31522
31741
|
return value.toLowerCase();
|
|
31523
31742
|
}
|
|
31524
|
-
function
|
|
31743
|
+
function sleep3(ms) {
|
|
31525
31744
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
31526
31745
|
}
|
|
31527
31746
|
function useTransactionActionModel({
|
|
@@ -31639,7 +31858,7 @@ function useTransactionActionModel({
|
|
|
31639
31858
|
if (status.status === "reverted") {
|
|
31640
31859
|
throw new Error("Approval transaction reverted");
|
|
31641
31860
|
}
|
|
31642
|
-
await
|
|
31861
|
+
await sleep3(intervalMs);
|
|
31643
31862
|
}
|
|
31644
31863
|
throw new Error("Timed out waiting for approval confirmation");
|
|
31645
31864
|
},
|
|
@@ -31679,7 +31898,7 @@ function useTransactionActionModel({
|
|
|
31679
31898
|
}
|
|
31680
31899
|
}
|
|
31681
31900
|
}
|
|
31682
|
-
const data =
|
|
31901
|
+
const data = encodeFunctionData9({
|
|
31683
31902
|
abi: erc20Abi,
|
|
31684
31903
|
functionName: "approve",
|
|
31685
31904
|
args: [spender, amountWei]
|
|
@@ -33289,7 +33508,7 @@ var init_useSwapRoute = __esm({
|
|
|
33289
33508
|
|
|
33290
33509
|
// src/modes/swap/hooks/useSwapExecution.ts
|
|
33291
33510
|
import { useCallback as useCallback21, useRef as useRef16, useState as useState29 } from "react";
|
|
33292
|
-
import { encodeFunctionData as
|
|
33511
|
+
import { encodeFunctionData as encodeFunctionData10, erc20Abi as erc20Abi2 } from "viem";
|
|
33293
33512
|
function normalizeTx(raw) {
|
|
33294
33513
|
const r = raw;
|
|
33295
33514
|
return {
|
|
@@ -33300,7 +33519,7 @@ function normalizeTx(raw) {
|
|
|
33300
33519
|
toChainTxUrl: r.toChainTxUrl || r.to_chain_tx_url || void 0
|
|
33301
33520
|
};
|
|
33302
33521
|
}
|
|
33303
|
-
function
|
|
33522
|
+
function sleep4(ms) {
|
|
33304
33523
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
33305
33524
|
}
|
|
33306
33525
|
function isUserRejection(err) {
|
|
@@ -33318,7 +33537,7 @@ async function waitForApprovalConfirmation(chainId, txHash) {
|
|
|
33318
33537
|
if (status.status === "success") return;
|
|
33319
33538
|
if (status.status === "reverted")
|
|
33320
33539
|
throw new Error("Approval transaction reverted");
|
|
33321
|
-
await
|
|
33540
|
+
await sleep4(2e3);
|
|
33322
33541
|
}
|
|
33323
33542
|
throw new Error("Timed out waiting for approval confirmation");
|
|
33324
33543
|
}
|
|
@@ -33558,7 +33777,7 @@ function useSwapExecution(fromChain) {
|
|
|
33558
33777
|
const approveAmount = maxApproval ? BigInt(
|
|
33559
33778
|
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
|
33560
33779
|
) : fromAmountWei;
|
|
33561
|
-
const data =
|
|
33780
|
+
const data = encodeFunctionData10({
|
|
33562
33781
|
abi: erc20Abi2,
|
|
33563
33782
|
functionName: "approve",
|
|
33564
33783
|
args: [spender, approveAmount]
|
|
@@ -39757,7 +39976,7 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
39757
39976
|
if (!isOpen) {
|
|
39758
39977
|
return null;
|
|
39759
39978
|
}
|
|
39760
|
-
if (config.
|
|
39979
|
+
if (config.mode === "swap") {
|
|
39761
39980
|
return /* @__PURE__ */ jsx60(SwapMode, { theme, style });
|
|
39762
39981
|
}
|
|
39763
39982
|
return /* @__PURE__ */ jsx60(DepositProvider, { initialStep: effectiveInitialStep, children: /* @__PURE__ */ jsx60(
|
|
@@ -39863,6 +40082,7 @@ export {
|
|
|
39863
40082
|
DEFAULT_SLIPPAGE2 as DEFAULT_SLIPPAGE,
|
|
39864
40083
|
GTM_ID,
|
|
39865
40084
|
IdentityStore,
|
|
40085
|
+
POPULAR_ORDER,
|
|
39866
40086
|
RateLimitError,
|
|
39867
40087
|
SDK_NAME,
|
|
39868
40088
|
SDK_VERSION,
|
|
@@ -39871,6 +40091,7 @@ export {
|
|
|
39871
40091
|
TrustwareProvider,
|
|
39872
40092
|
TrustwareWidgetV2 as TrustwareWidget,
|
|
39873
40093
|
WALLETCONNECT_PROJECT_ID,
|
|
40094
|
+
WALLETS,
|
|
39874
40095
|
buildWalletIdentityAddress,
|
|
39875
40096
|
connectDetectedWallet,
|
|
39876
40097
|
createWalletIdentity,
|
|
@@ -39887,6 +40108,7 @@ export {
|
|
|
39887
40108
|
useWireDetectionIntoManager,
|
|
39888
40109
|
validateAddressForChain,
|
|
39889
40110
|
validateBtcAddress,
|
|
40111
|
+
validateCosmosAddress,
|
|
39890
40112
|
validateEvmAddress,
|
|
39891
40113
|
validateRouteAddresses,
|
|
39892
40114
|
validateSeiAddress,
|