@1llet.xyz/erc4337-gasless-sdk 0.4.71 → 0.4.73
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/index.d.mts +156 -82
- package/dist/index.d.ts +156 -82
- package/dist/index.js +700 -170
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +684 -162
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { monad, unichain, arbitrum, polygon, bsc, avalanche, optimism, gnosis, baseSepolia, base, optimismSepolia, worldchain } from 'viem/chains';
|
|
1
|
+
import { monad, unichain, arbitrum, polygon, bsc, avalanche, optimism, gnosis, baseSepolia, base, optimismSepolia, mainnet, worldchain } from 'viem/chains';
|
|
2
2
|
import * as StellarSdk from 'stellar-sdk';
|
|
3
3
|
import { Networks } from 'stellar-sdk';
|
|
4
4
|
import axios from 'axios';
|
|
5
|
-
import { parseAbi, createPublicClient, http, encodeFunctionData, createWalletClient, decodeErrorResult, encodeAbiParameters, keccak256, maxUint256, padHex } from 'viem';
|
|
5
|
+
import { parseAbi, createPublicClient, http, encodeFunctionData, parseUnits, formatUnits, createWalletClient, decodeErrorResult, encodeAbiParameters, keccak256, maxUint256, padHex, getAddress, erc20Abi as erc20Abi$1 } from 'viem';
|
|
6
6
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
7
|
-
import { OpenAPI,
|
|
7
|
+
import { OpenAPI, QuoteRequest, OneClickService } from '@defuse-protocol/one-click-sdk-typescript';
|
|
8
|
+
import { c32addressDecode } from 'c32check';
|
|
8
9
|
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
10
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -48,7 +49,7 @@ var init_Base = __esm({
|
|
|
48
49
|
chain: base,
|
|
49
50
|
rpcUrl: "https://base-mainnet.g.alchemy.com/v2/49fUGmuW05ynCui0VEvDN",
|
|
50
51
|
supports7702: true,
|
|
51
|
-
erc4337:
|
|
52
|
+
erc4337: true,
|
|
52
53
|
bundlerUrl: `${BUNDLER_URL}/rpc?chain=base`,
|
|
53
54
|
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
54
55
|
factoryAddress: "0xe2584152891E4769025807DEa0cD611F135aDC68",
|
|
@@ -86,103 +87,74 @@ var init_Base = __esm({
|
|
|
86
87
|
};
|
|
87
88
|
}
|
|
88
89
|
});
|
|
89
|
-
var
|
|
90
|
-
var
|
|
91
|
-
"src/chains/Evm/
|
|
90
|
+
var AVALANCHE;
|
|
91
|
+
var init_Avalanche = __esm({
|
|
92
|
+
"src/chains/Evm/Avalanche.ts"() {
|
|
92
93
|
init_bundler();
|
|
93
|
-
|
|
94
|
+
AVALANCHE = {
|
|
94
95
|
assets: [
|
|
95
96
|
{
|
|
96
97
|
name: "USDC",
|
|
97
98
|
decimals: 6,
|
|
98
|
-
address: "
|
|
99
|
-
coingeckoId: "usd-coin"
|
|
100
|
-
|
|
101
|
-
{
|
|
102
|
-
name: "USDT",
|
|
103
|
-
decimals: 6,
|
|
104
|
-
address: "0x4ECaBa5870353805a9F068101A40E0f32ed605C6",
|
|
105
|
-
coingeckoId: "tether"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: "EURe",
|
|
109
|
-
decimals: 18,
|
|
110
|
-
address: "0x420CA0f9B9b604cE0fd9C18EF134C705e5Fa3430",
|
|
111
|
-
coingeckoId: "monerium-eur-money"
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: "GNO",
|
|
115
|
-
decimals: 18,
|
|
116
|
-
address: "0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb",
|
|
117
|
-
coingeckoId: "gnosis"
|
|
99
|
+
address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
100
|
+
coingeckoId: "usd-coin",
|
|
101
|
+
supportsStargate: true
|
|
118
102
|
},
|
|
119
103
|
{
|
|
120
|
-
name: "
|
|
104
|
+
name: "AVAX",
|
|
121
105
|
decimals: 18,
|
|
122
|
-
address: "
|
|
123
|
-
coingeckoId: "
|
|
106
|
+
address: "0x0000000000000000000000000000000000000000",
|
|
107
|
+
coingeckoId: "avalanche-2"
|
|
124
108
|
},
|
|
125
109
|
{
|
|
126
|
-
name: "
|
|
127
|
-
decimals:
|
|
128
|
-
address: "
|
|
129
|
-
coingeckoId: "
|
|
110
|
+
name: "USDT",
|
|
111
|
+
decimals: 6,
|
|
112
|
+
address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
|
|
113
|
+
coingeckoId: "tether"
|
|
130
114
|
}
|
|
131
115
|
],
|
|
132
116
|
evm: {
|
|
133
|
-
chain:
|
|
134
|
-
rpcUrl:
|
|
135
|
-
supports7702:
|
|
136
|
-
|
|
137
|
-
|
|
117
|
+
chain: avalanche,
|
|
118
|
+
rpcUrl: avalanche.rpcUrls.default.http[0],
|
|
119
|
+
supports7702: false,
|
|
120
|
+
bundlerUrl: `${BUNDLER_URL}/rpc?chain=avalanche`,
|
|
121
|
+
erc4337: false,
|
|
138
122
|
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
139
|
-
factoryAddress: "
|
|
140
|
-
paymasterAddress: "
|
|
123
|
+
factoryAddress: "0x5D1D71FE2De5D1C52c7c11311332eC7f0CBf88aF",
|
|
124
|
+
paymasterAddress: "0x6c0de464F2203FE089FF719Acf425dFfE6ac1EE5"
|
|
141
125
|
},
|
|
142
126
|
crossChainInformation: {
|
|
143
127
|
circleInformation: {
|
|
144
|
-
supportCirclePaymaster:
|
|
145
|
-
aproxFromFee: 0,
|
|
128
|
+
supportCirclePaymaster: true,
|
|
146
129
|
cCTPInformation: {
|
|
147
|
-
supportCCTP:
|
|
148
|
-
domain:
|
|
149
|
-
}
|
|
130
|
+
supportCCTP: true,
|
|
131
|
+
domain: 1
|
|
132
|
+
},
|
|
133
|
+
aproxFromFee: 0
|
|
150
134
|
},
|
|
151
135
|
nearIntentInformation: {
|
|
152
136
|
support: true,
|
|
153
137
|
assetsId: [
|
|
154
138
|
{
|
|
155
|
-
assetId: "
|
|
139
|
+
assetId: "nep245:v2_1.omni.hot.tg:43114_3atVJH3r5c4GqiSYmg9fECvjc47o",
|
|
156
140
|
name: "USDC",
|
|
157
141
|
decimals: 6
|
|
158
142
|
},
|
|
159
143
|
{
|
|
160
|
-
assetId: "
|
|
161
|
-
name: "
|
|
162
|
-
decimals: 6
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
assetId: "nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near",
|
|
166
|
-
name: "EURe",
|
|
167
|
-
decimals: 18
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
assetId: "nep141:gnosis-0x9c58bacc331c9aa871afd802db6379a98e80cedb.omft.near",
|
|
171
|
-
name: "GNO",
|
|
172
|
-
decimals: 18
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
assetId: "nep141:gnosis-0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1.omft.near",
|
|
176
|
-
name: "WETH",
|
|
144
|
+
assetId: "nep245:v2_1.omni.hot.tg:43114_11111111111111111111",
|
|
145
|
+
name: "AVAX",
|
|
177
146
|
decimals: 18
|
|
178
147
|
},
|
|
179
148
|
{
|
|
180
|
-
assetId: "
|
|
181
|
-
name: "
|
|
182
|
-
decimals:
|
|
149
|
+
assetId: "nep245:v2_1.omni.hot.tg:43114_372BeH7ENZieCaabwkbWkBiTTgXp",
|
|
150
|
+
name: "USDT",
|
|
151
|
+
decimals: 6
|
|
183
152
|
}
|
|
184
153
|
],
|
|
185
154
|
needMemo: false
|
|
155
|
+
},
|
|
156
|
+
stargateInformation: {
|
|
157
|
+
support: true
|
|
186
158
|
}
|
|
187
159
|
}
|
|
188
160
|
};
|
|
@@ -221,7 +193,7 @@ var init_Optimism = __esm({
|
|
|
221
193
|
],
|
|
222
194
|
evm: {
|
|
223
195
|
chain: optimism,
|
|
224
|
-
rpcUrl: "https://
|
|
196
|
+
rpcUrl: "https://mainnet.optimism.io",
|
|
225
197
|
supports7702: false,
|
|
226
198
|
erc4337: false,
|
|
227
199
|
bundlerUrl: `${BUNDLER_URL}/rpc?chain=optimism`,
|
|
@@ -268,74 +240,140 @@ var init_Optimism = __esm({
|
|
|
268
240
|
};
|
|
269
241
|
}
|
|
270
242
|
});
|
|
271
|
-
var
|
|
272
|
-
var
|
|
273
|
-
"src/chains/Evm/
|
|
243
|
+
var UNICHAIN;
|
|
244
|
+
var init_Unichain = __esm({
|
|
245
|
+
"src/chains/Evm/Unichain.ts"() {
|
|
274
246
|
init_bundler();
|
|
275
|
-
|
|
247
|
+
UNICHAIN = {
|
|
276
248
|
assets: [
|
|
277
249
|
{
|
|
278
250
|
name: "USDC",
|
|
279
251
|
decimals: 6,
|
|
280
|
-
address: "
|
|
281
|
-
coingeckoId: "usd-coin"
|
|
282
|
-
|
|
252
|
+
address: "0x078D782b760474a361dDA0AF3839290b0EF57AD6",
|
|
253
|
+
coingeckoId: "usd-coin"
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
evm: {
|
|
257
|
+
chain: unichain,
|
|
258
|
+
rpcUrl: "https://unichain-mainnet.g.alchemy.com/v2/49fUGmuW05ynCui0VEvDN",
|
|
259
|
+
bundlerUrl: `${BUNDLER_URL}/rpc?chain=unichain`,
|
|
260
|
+
supports7702: true,
|
|
261
|
+
erc4337: false,
|
|
262
|
+
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
263
|
+
factoryAddress: "0xB2E45aCbB68f3e98C87B6df16625f22e11728556",
|
|
264
|
+
paymasterAddress: "0x7A92b3Fee017E3E181a51D9045AACE30eC2B387D"
|
|
265
|
+
},
|
|
266
|
+
crossChainInformation: {
|
|
267
|
+
circleInformation: {
|
|
268
|
+
supportCirclePaymaster: true,
|
|
269
|
+
cCTPInformation: {
|
|
270
|
+
supportCCTP: true,
|
|
271
|
+
domain: 10
|
|
272
|
+
},
|
|
273
|
+
aproxFromFee: 0
|
|
283
274
|
},
|
|
275
|
+
nearIntentInformation: null
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
var GNOSIS;
|
|
281
|
+
var init_Gnosis = __esm({
|
|
282
|
+
"src/chains/Evm/Gnosis.ts"() {
|
|
283
|
+
init_bundler();
|
|
284
|
+
GNOSIS = {
|
|
285
|
+
assets: [
|
|
284
286
|
{
|
|
285
|
-
name: "
|
|
286
|
-
decimals:
|
|
287
|
-
address: "
|
|
288
|
-
coingeckoId: "
|
|
287
|
+
name: "USDC",
|
|
288
|
+
decimals: 6,
|
|
289
|
+
address: "0x2a22f9c3b484c3629090FeED35F17Ff8F88f76F0",
|
|
290
|
+
coingeckoId: "usd-coin"
|
|
289
291
|
},
|
|
290
292
|
{
|
|
291
293
|
name: "USDT",
|
|
292
294
|
decimals: 6,
|
|
293
|
-
address: "
|
|
295
|
+
address: "0x4ECaBa5870353805a9F068101A40E0f32ed605C6",
|
|
294
296
|
coingeckoId: "tether"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: "EURe",
|
|
300
|
+
decimals: 18,
|
|
301
|
+
address: "0x420CA0f9B9b604cE0fd9C18EF134C705e5Fa3430",
|
|
302
|
+
coingeckoId: "monerium-eur-money"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: "GNO",
|
|
306
|
+
decimals: 18,
|
|
307
|
+
address: "0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb",
|
|
308
|
+
coingeckoId: "gnosis"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: "WETH",
|
|
312
|
+
decimals: 18,
|
|
313
|
+
address: "0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1",
|
|
314
|
+
coingeckoId: "ethereum"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
name: "XDAI",
|
|
318
|
+
decimals: 18,
|
|
319
|
+
address: "0x0000000000000000000000000000000000000000",
|
|
320
|
+
coingeckoId: "xdai"
|
|
295
321
|
}
|
|
296
322
|
],
|
|
297
323
|
evm: {
|
|
298
|
-
chain:
|
|
299
|
-
rpcUrl:
|
|
300
|
-
supports7702:
|
|
301
|
-
|
|
302
|
-
|
|
324
|
+
chain: gnosis,
|
|
325
|
+
rpcUrl: gnosis.rpcUrls.default.http[0],
|
|
326
|
+
supports7702: true,
|
|
327
|
+
erc4337: true,
|
|
328
|
+
bundlerUrl: `${BUNDLER_URL}/rpc?chain=gnosis`,
|
|
303
329
|
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
304
|
-
factoryAddress: "
|
|
305
|
-
paymasterAddress: "
|
|
330
|
+
factoryAddress: "0xC8a2Fb1f2E686417A131E09be3320cb5431CcD90",
|
|
331
|
+
paymasterAddress: "0x4C36C70d68a7c26326711e8268bb163E3784fA96"
|
|
306
332
|
},
|
|
307
333
|
crossChainInformation: {
|
|
308
334
|
circleInformation: {
|
|
309
|
-
supportCirclePaymaster:
|
|
335
|
+
supportCirclePaymaster: false,
|
|
336
|
+
aproxFromFee: 0,
|
|
310
337
|
cCTPInformation: {
|
|
311
|
-
supportCCTP:
|
|
312
|
-
domain:
|
|
313
|
-
}
|
|
314
|
-
aproxFromFee: 0
|
|
338
|
+
supportCCTP: false,
|
|
339
|
+
domain: 0
|
|
340
|
+
}
|
|
315
341
|
},
|
|
316
342
|
nearIntentInformation: {
|
|
317
343
|
support: true,
|
|
318
344
|
assetsId: [
|
|
319
345
|
{
|
|
320
|
-
assetId: "
|
|
346
|
+
assetId: "nep141:gnosis-0x2a22f9c3b484c3629090feed35f17ff8f88f76f0.omft.near",
|
|
321
347
|
name: "USDC",
|
|
322
348
|
decimals: 6
|
|
323
349
|
},
|
|
324
350
|
{
|
|
325
|
-
assetId: "
|
|
326
|
-
name: "
|
|
351
|
+
assetId: "nep141:gnosis-0x4ecaba5870353805a9f068101a40e0f32ed605c6.omft.near",
|
|
352
|
+
name: "USDT",
|
|
353
|
+
decimals: 6
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
assetId: "nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near",
|
|
357
|
+
name: "EURe",
|
|
327
358
|
decimals: 18
|
|
328
359
|
},
|
|
329
360
|
{
|
|
330
|
-
assetId: "
|
|
331
|
-
name: "
|
|
332
|
-
decimals:
|
|
361
|
+
assetId: "nep141:gnosis-0x9c58bacc331c9aa871afd802db6379a98e80cedb.omft.near",
|
|
362
|
+
name: "GNO",
|
|
363
|
+
decimals: 18
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
assetId: "nep141:gnosis-0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1.omft.near",
|
|
367
|
+
name: "WETH",
|
|
368
|
+
decimals: 18
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
assetId: "nep141:gnosis.omft.near",
|
|
372
|
+
name: "XDAI",
|
|
373
|
+
decimals: 18
|
|
333
374
|
}
|
|
334
375
|
],
|
|
335
376
|
needMemo: false
|
|
336
|
-
},
|
|
337
|
-
stargateInformation: {
|
|
338
|
-
support: true
|
|
339
377
|
}
|
|
340
378
|
}
|
|
341
379
|
};
|
|
@@ -562,43 +600,6 @@ var init_Arbitrum = __esm({
|
|
|
562
600
|
};
|
|
563
601
|
}
|
|
564
602
|
});
|
|
565
|
-
var UNICHAIN;
|
|
566
|
-
var init_Unichain = __esm({
|
|
567
|
-
"src/chains/Evm/Unichain.ts"() {
|
|
568
|
-
init_bundler();
|
|
569
|
-
UNICHAIN = {
|
|
570
|
-
assets: [
|
|
571
|
-
{
|
|
572
|
-
name: "USDC",
|
|
573
|
-
decimals: 6,
|
|
574
|
-
address: "0x078D782b760474a361dDA0AF3839290b0EF57AD6",
|
|
575
|
-
coingeckoId: "usd-coin"
|
|
576
|
-
}
|
|
577
|
-
],
|
|
578
|
-
evm: {
|
|
579
|
-
chain: unichain,
|
|
580
|
-
rpcUrl: "https://unichain-mainnet.g.alchemy.com/v2/49fUGmuW05ynCui0VEvDN",
|
|
581
|
-
bundlerUrl: `${BUNDLER_URL}/rpc?chain=unichain`,
|
|
582
|
-
supports7702: true,
|
|
583
|
-
erc4337: false,
|
|
584
|
-
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
585
|
-
factoryAddress: "0xB2E45aCbB68f3e98C87B6df16625f22e11728556",
|
|
586
|
-
paymasterAddress: "0x7A92b3Fee017E3E181a51D9045AACE30eC2B387D"
|
|
587
|
-
},
|
|
588
|
-
crossChainInformation: {
|
|
589
|
-
circleInformation: {
|
|
590
|
-
supportCirclePaymaster: true,
|
|
591
|
-
cCTPInformation: {
|
|
592
|
-
supportCCTP: true,
|
|
593
|
-
domain: 10
|
|
594
|
-
},
|
|
595
|
-
aproxFromFee: 0
|
|
596
|
-
},
|
|
597
|
-
nearIntentInformation: null
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
});
|
|
602
603
|
var Monad;
|
|
603
604
|
var init_Monad = __esm({
|
|
604
605
|
"src/chains/Evm/Monad.ts"() {
|
|
@@ -716,6 +717,34 @@ var init_Stellar = __esm({
|
|
|
716
717
|
}
|
|
717
718
|
});
|
|
718
719
|
|
|
720
|
+
// src/chains/NoEvm/Stacks.ts
|
|
721
|
+
var STACKS;
|
|
722
|
+
var init_Stacks = __esm({
|
|
723
|
+
"src/chains/NoEvm/Stacks.ts"() {
|
|
724
|
+
STACKS = {
|
|
725
|
+
assets: [
|
|
726
|
+
{
|
|
727
|
+
name: "USDC",
|
|
728
|
+
decimals: 6,
|
|
729
|
+
address: "SP2ZNGJ15SD91GWW54B2Q1V31749666c2Q01",
|
|
730
|
+
// Placeholder or real Stacks token ID
|
|
731
|
+
coingeckoId: "usd-coin"
|
|
732
|
+
}
|
|
733
|
+
],
|
|
734
|
+
nonEvm: {
|
|
735
|
+
serverURL: "https://api.mainnet.hiro.so"
|
|
736
|
+
},
|
|
737
|
+
crossChainInformation: {
|
|
738
|
+
circleInformation: {
|
|
739
|
+
supportCirclePaymaster: false,
|
|
740
|
+
aproxFromFee: 0
|
|
741
|
+
},
|
|
742
|
+
nearIntentInformation: null
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
|
|
719
748
|
// src/services/StellarService.ts
|
|
720
749
|
var StellarService_exports = {};
|
|
721
750
|
__export(StellarService_exports, {
|
|
@@ -835,6 +864,17 @@ var init_facilitator = __esm({
|
|
|
835
864
|
return isDev ? PlatformFees.DEV : PlatformFees.DEFAULT;
|
|
836
865
|
};
|
|
837
866
|
FACILITATOR_NETWORKS = {
|
|
867
|
+
Ethereum: {
|
|
868
|
+
chainId: mainnet.id,
|
|
869
|
+
chain: mainnet,
|
|
870
|
+
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
871
|
+
usdcName: "USD Coin",
|
|
872
|
+
usdcVersion: "2",
|
|
873
|
+
domain: 0,
|
|
874
|
+
tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
|
|
875
|
+
messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
|
|
876
|
+
rpcUrl: mainnet.rpcUrls.default.http[0]
|
|
877
|
+
},
|
|
838
878
|
Base: {
|
|
839
879
|
chainId: 8453,
|
|
840
880
|
chain: base,
|
|
@@ -1103,6 +1143,68 @@ var init_WorldChain = __esm({
|
|
|
1103
1143
|
};
|
|
1104
1144
|
}
|
|
1105
1145
|
});
|
|
1146
|
+
var ETHEREUM;
|
|
1147
|
+
var init_Ethereum = __esm({
|
|
1148
|
+
"src/chains/Evm/Ethereum.ts"() {
|
|
1149
|
+
init_bundler();
|
|
1150
|
+
ETHEREUM = {
|
|
1151
|
+
assets: [
|
|
1152
|
+
{
|
|
1153
|
+
name: "USDC",
|
|
1154
|
+
decimals: 6,
|
|
1155
|
+
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
1156
|
+
coingeckoId: "usd-coin",
|
|
1157
|
+
supportsStargate: true
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
name: "ETH",
|
|
1161
|
+
decimals: 18,
|
|
1162
|
+
address: "0x0000000000000000000000000000000000000000",
|
|
1163
|
+
coingeckoId: "ethereum"
|
|
1164
|
+
}
|
|
1165
|
+
],
|
|
1166
|
+
evm: {
|
|
1167
|
+
chain: mainnet,
|
|
1168
|
+
rpcUrl: mainnet.rpcUrls.default.http[0],
|
|
1169
|
+
supports7702: true,
|
|
1170
|
+
erc4337: true,
|
|
1171
|
+
bundlerUrl: `${BUNDLER_URL}/rpc?chain=ethereum`,
|
|
1172
|
+
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
1173
|
+
factoryAddress: "0xe2584152891E4769025807DEa0cD611F135aDC68",
|
|
1174
|
+
paymasterAddress: "0x1e13Eb16C565E3f3FDe49A011755e50410bb1F95"
|
|
1175
|
+
},
|
|
1176
|
+
crossChainInformation: {
|
|
1177
|
+
circleInformation: {
|
|
1178
|
+
supportCirclePaymaster: true,
|
|
1179
|
+
cCTPInformation: {
|
|
1180
|
+
supportCCTP: true,
|
|
1181
|
+
domain: 0
|
|
1182
|
+
},
|
|
1183
|
+
aproxFromFee: 0
|
|
1184
|
+
},
|
|
1185
|
+
nearIntentInformation: {
|
|
1186
|
+
support: true,
|
|
1187
|
+
assetsId: [
|
|
1188
|
+
{
|
|
1189
|
+
assetId: "nep141:eth-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.omft.near",
|
|
1190
|
+
name: "USDC",
|
|
1191
|
+
decimals: 6
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
assetId: "nep141:eth.omft.near",
|
|
1195
|
+
name: "ETH",
|
|
1196
|
+
decimals: 18
|
|
1197
|
+
}
|
|
1198
|
+
],
|
|
1199
|
+
needMemo: false
|
|
1200
|
+
},
|
|
1201
|
+
stargateInformation: {
|
|
1202
|
+
support: false
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1106
1208
|
|
|
1107
1209
|
// src/chains/index.ts
|
|
1108
1210
|
var init_chains = __esm({
|
|
@@ -1118,6 +1220,8 @@ var init_chains = __esm({
|
|
|
1118
1220
|
init_Monad();
|
|
1119
1221
|
init_Binance();
|
|
1120
1222
|
init_Gnosis();
|
|
1223
|
+
init_Ethereum();
|
|
1224
|
+
init_Stacks();
|
|
1121
1225
|
}
|
|
1122
1226
|
});
|
|
1123
1227
|
|
|
@@ -1137,7 +1241,8 @@ var init_chainsInformation = __esm({
|
|
|
1137
1241
|
Stellar: STELLAR,
|
|
1138
1242
|
Monad,
|
|
1139
1243
|
BNB,
|
|
1140
|
-
Gnosis: GNOSIS
|
|
1244
|
+
Gnosis: GNOSIS,
|
|
1245
|
+
Ethereum: ETHEREUM
|
|
1141
1246
|
};
|
|
1142
1247
|
}
|
|
1143
1248
|
});
|
|
@@ -1384,7 +1489,7 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
|
|
|
1384
1489
|
mintTransactionHash: mintHash,
|
|
1385
1490
|
payer: payerAddress,
|
|
1386
1491
|
fee: fee.toString(),
|
|
1387
|
-
netAmount: amountBigInt.toString(),
|
|
1492
|
+
netAmount: (amountBigInt - fee).toString(),
|
|
1388
1493
|
attestation: {
|
|
1389
1494
|
message: attestationResponse.message,
|
|
1390
1495
|
attestation: attestationResponse.attestation
|
|
@@ -1650,15 +1755,15 @@ var init_near = __esm({
|
|
|
1650
1755
|
return { success: false, errorReason: `Stellar Verification Failed: ${e.message}` };
|
|
1651
1756
|
}
|
|
1652
1757
|
}
|
|
1653
|
-
const { createPublicClient:
|
|
1758
|
+
const { createPublicClient: createPublicClient5, http: http5 } = await import('viem');
|
|
1654
1759
|
const { FACILITATOR_NETWORKS: FACILITATOR_NETWORKS2 } = await Promise.resolve().then(() => (init_facilitator(), facilitator_exports));
|
|
1655
1760
|
const networkConfig = FACILITATOR_NETWORKS2[sourceChain];
|
|
1656
1761
|
if (!networkConfig) {
|
|
1657
1762
|
return { success: false, errorReason: `Unsupported source chain for verification: ${sourceChain}` };
|
|
1658
1763
|
}
|
|
1659
|
-
const publicClient =
|
|
1764
|
+
const publicClient = createPublicClient5({
|
|
1660
1765
|
chain: networkConfig.chain,
|
|
1661
|
-
transport:
|
|
1766
|
+
transport: http5(networkConfig.rpcUrl)
|
|
1662
1767
|
});
|
|
1663
1768
|
try {
|
|
1664
1769
|
console.log(`[NearStrategy] Waiting for receipt...`);
|
|
@@ -1859,6 +1964,7 @@ var init_stargate = __esm({
|
|
|
1859
1964
|
success: true,
|
|
1860
1965
|
transactionHash: "PENDING_USER_SIGNATURE",
|
|
1861
1966
|
netAmount: amount,
|
|
1967
|
+
estimatedReceived: selectedQuote.dstAmount,
|
|
1862
1968
|
data: {
|
|
1863
1969
|
strategy: "Stargate",
|
|
1864
1970
|
quote: selectedQuote,
|
|
@@ -1882,6 +1988,221 @@ var init_stargate = __esm({
|
|
|
1882
1988
|
};
|
|
1883
1989
|
}
|
|
1884
1990
|
});
|
|
1991
|
+
var STACKS_BRIDGE_ADDRESS_ETH, stacksBridgeAbi, StacksStrategy;
|
|
1992
|
+
var init_stacks = __esm({
|
|
1993
|
+
"src/services/stacks.ts"() {
|
|
1994
|
+
init_chainsInformation();
|
|
1995
|
+
STACKS_BRIDGE_ADDRESS_ETH = "0x8888888199b2Df864bf678259607d6D5EBb4e3Ce";
|
|
1996
|
+
stacksBridgeAbi = [
|
|
1997
|
+
{
|
|
1998
|
+
"inputs": [
|
|
1999
|
+
{ "internalType": "uint256", "name": "value", "type": "uint256" },
|
|
2000
|
+
{ "internalType": "uint32", "name": "remoteDomain", "type": "uint32" },
|
|
2001
|
+
{ "internalType": "bytes32", "name": "remoteRecipient", "type": "bytes32" },
|
|
2002
|
+
{ "internalType": "address", "name": "localToken", "type": "address" },
|
|
2003
|
+
{ "internalType": "uint256", "name": "maxFee", "type": "uint256" },
|
|
2004
|
+
{ "internalType": "bytes", "name": "hookData", "type": "bytes" }
|
|
2005
|
+
],
|
|
2006
|
+
"name": "depositToRemote",
|
|
2007
|
+
"outputs": [],
|
|
2008
|
+
"stateMutability": "nonpayable",
|
|
2009
|
+
"type": "function"
|
|
2010
|
+
}
|
|
2011
|
+
];
|
|
2012
|
+
StacksStrategy = class {
|
|
2013
|
+
constructor() {
|
|
2014
|
+
this.name = "Stacks";
|
|
2015
|
+
}
|
|
2016
|
+
canHandle(context) {
|
|
2017
|
+
return context.sourceChain === "Ethereum" && context.destChain === "Stacks";
|
|
2018
|
+
}
|
|
2019
|
+
async execute(context) {
|
|
2020
|
+
const { amount, recipient, facilitatorPrivateKey, sourceChain } = context;
|
|
2021
|
+
if (sourceChain !== "Ethereum") {
|
|
2022
|
+
return { success: false, errorReason: "Stacks Strategy only supports financing from Ethereum" };
|
|
2023
|
+
}
|
|
2024
|
+
if (!facilitatorPrivateKey) {
|
|
2025
|
+
return { success: false, errorReason: "Private Key required for Stacks Bridge execution" };
|
|
2026
|
+
}
|
|
2027
|
+
const networkConfig = NETWORKS[sourceChain];
|
|
2028
|
+
if (!networkConfig || !networkConfig.evm) {
|
|
2029
|
+
return { success: false, errorReason: `Unsupported chain or missing EVM config: ${sourceChain}` };
|
|
2030
|
+
}
|
|
2031
|
+
try {
|
|
2032
|
+
const account = privateKeyToAccount(facilitatorPrivateKey);
|
|
2033
|
+
const client = createWalletClient({
|
|
2034
|
+
account,
|
|
2035
|
+
chain: networkConfig.evm.chain,
|
|
2036
|
+
transport: http(networkConfig.evm.rpcUrl)
|
|
2037
|
+
});
|
|
2038
|
+
const publicClient = createPublicClient({
|
|
2039
|
+
chain: networkConfig.evm.chain,
|
|
2040
|
+
transport: http(networkConfig.evm.rpcUrl)
|
|
2041
|
+
});
|
|
2042
|
+
const ethAssets = NETWORKS["Ethereum"].assets;
|
|
2043
|
+
const usdcToken = ethAssets.find((a) => a.name === "USDC");
|
|
2044
|
+
if (!usdcToken || !usdcToken.address) throw new Error("USDC config/address not found for Ethereum");
|
|
2045
|
+
const usdcAddress = getAddress(usdcToken.address);
|
|
2046
|
+
const amountBigInt = parseUnits(amount, 6);
|
|
2047
|
+
const balance = await publicClient.readContract({
|
|
2048
|
+
address: usdcAddress,
|
|
2049
|
+
abi: erc20Abi$1,
|
|
2050
|
+
functionName: "balanceOf",
|
|
2051
|
+
args: [account.address]
|
|
2052
|
+
});
|
|
2053
|
+
if (balance < amountBigInt) {
|
|
2054
|
+
throw new Error(`Insufficient USDC balance on Ethereum (Facilitator). Has: ${balance}, Needed: ${amountBigInt}`);
|
|
2055
|
+
}
|
|
2056
|
+
const allowance = await publicClient.readContract({
|
|
2057
|
+
address: usdcAddress,
|
|
2058
|
+
abi: erc20Abi$1,
|
|
2059
|
+
functionName: "allowance",
|
|
2060
|
+
args: [account.address, STACKS_BRIDGE_ADDRESS_ETH]
|
|
2061
|
+
});
|
|
2062
|
+
if (allowance < amountBigInt) {
|
|
2063
|
+
console.log("[Stacks] Approving bridge...");
|
|
2064
|
+
const approveHash = await client.writeContract({
|
|
2065
|
+
address: usdcAddress,
|
|
2066
|
+
abi: erc20Abi$1,
|
|
2067
|
+
functionName: "approve",
|
|
2068
|
+
args: [STACKS_BRIDGE_ADDRESS_ETH, amountBigInt],
|
|
2069
|
+
chain: networkConfig.evm.chain
|
|
2070
|
+
});
|
|
2071
|
+
await publicClient.waitForTransactionReceipt({ hash: approveHash });
|
|
2072
|
+
console.log("[Stacks] Approved.");
|
|
2073
|
+
}
|
|
2074
|
+
const REMOTE_DOMAIN_STACKS = 10003;
|
|
2075
|
+
let recipientBytes32;
|
|
2076
|
+
if (recipient.startsWith("0x")) {
|
|
2077
|
+
recipientBytes32 = padHex(recipient, { size: 32 });
|
|
2078
|
+
} else {
|
|
2079
|
+
try {
|
|
2080
|
+
const [version, hash2] = c32addressDecode(recipient);
|
|
2081
|
+
recipientBytes32 = padHex(`0x${hash2}`, { size: 32 });
|
|
2082
|
+
} catch (e) {
|
|
2083
|
+
throw new Error(`Invalid Stacks Recipient: ${e.message}`);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
console.log(`[Stacks] Depositing ${amount} USDC to ${recipient} (Domain ${REMOTE_DOMAIN_STACKS})...`);
|
|
2087
|
+
const hash = await client.writeContract({
|
|
2088
|
+
address: STACKS_BRIDGE_ADDRESS_ETH,
|
|
2089
|
+
abi: stacksBridgeAbi,
|
|
2090
|
+
functionName: "depositToRemote",
|
|
2091
|
+
args: [
|
|
2092
|
+
amountBigInt,
|
|
2093
|
+
REMOTE_DOMAIN_STACKS,
|
|
2094
|
+
recipientBytes32,
|
|
2095
|
+
usdcAddress,
|
|
2096
|
+
0n,
|
|
2097
|
+
// maxFee
|
|
2098
|
+
"0x"
|
|
2099
|
+
// hookData
|
|
2100
|
+
],
|
|
2101
|
+
chain: networkConfig.evm.chain
|
|
2102
|
+
});
|
|
2103
|
+
console.log(`[Stacks] Deposit Tx: ${hash}`);
|
|
2104
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
2105
|
+
if (receipt.status === "success") {
|
|
2106
|
+
return {
|
|
2107
|
+
success: true,
|
|
2108
|
+
transactionHash: hash,
|
|
2109
|
+
netAmount: amountBigInt.toString()
|
|
2110
|
+
};
|
|
2111
|
+
} else {
|
|
2112
|
+
return {
|
|
2113
|
+
success: false,
|
|
2114
|
+
transactionHash: hash,
|
|
2115
|
+
errorReason: "Stacks Deposit Transaction Reverted"
|
|
2116
|
+
};
|
|
2117
|
+
}
|
|
2118
|
+
} catch (error) {
|
|
2119
|
+
return {
|
|
2120
|
+
success: false,
|
|
2121
|
+
errorReason: error instanceof Error ? error.message : "Using Stacks Bridge failed"
|
|
2122
|
+
};
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
}
|
|
2127
|
+
});
|
|
2128
|
+
|
|
2129
|
+
// src/services/Router.ts
|
|
2130
|
+
var RouterService;
|
|
2131
|
+
var init_Router = __esm({
|
|
2132
|
+
"src/services/Router.ts"() {
|
|
2133
|
+
RouterService = class {
|
|
2134
|
+
/**
|
|
2135
|
+
* Orchestrates a Multi-Hop transfer by signing ALL UserOps upfront (Reverse Order),
|
|
2136
|
+
* and then executing them sequentially (Forward Order) with polling support.
|
|
2137
|
+
*
|
|
2138
|
+
* @param steps Array of MultiHopStep ordered by execution (Source -> Intermediate -> Dest)
|
|
2139
|
+
* @param onLog Optional callback for logging progress
|
|
2140
|
+
*/
|
|
2141
|
+
async executeMultiHop(steps, onLog = console.log) {
|
|
2142
|
+
onLog("[Router] Orchestrating Multi-Hop Sequence...");
|
|
2143
|
+
const signedOps = [];
|
|
2144
|
+
onLog("[Router] Phase 1: Preparation & Upfront Signing (Reverse Order)...");
|
|
2145
|
+
for (let i = steps.length - 1; i >= 0; i--) {
|
|
2146
|
+
const step = steps[i];
|
|
2147
|
+
onLog(`[Router] Preparing Step ${i + 1}: ${step.description}...`);
|
|
2148
|
+
try {
|
|
2149
|
+
const userOp = await step.buildUserOp();
|
|
2150
|
+
onLog(`[Router] Please sign Step ${i + 1} (${step.description})...`);
|
|
2151
|
+
const signedOp = await step.aa.signUserOperation(userOp);
|
|
2152
|
+
signedOps.unshift({ stepIndex: i, signedOp });
|
|
2153
|
+
onLog(`[Router] Step ${i + 1} Signed Successfully.`);
|
|
2154
|
+
} catch (err) {
|
|
2155
|
+
onLog(`[Router] Error preparing Step ${i + 1}: ${err.message}`);
|
|
2156
|
+
throw err;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
onLog("[Router] Phase 2: Sequential Execution (Forward Order)...");
|
|
2160
|
+
for (let i = 0; i < steps.length; i++) {
|
|
2161
|
+
const step = steps[i];
|
|
2162
|
+
const signedOp = signedOps[i].signedOp;
|
|
2163
|
+
if (step.waitCondition) {
|
|
2164
|
+
onLog(`[Router] Step ${i + 1} requires waiting (e.g. for funds)...`);
|
|
2165
|
+
const success = await this.pollCondition(step.waitCondition, onLog);
|
|
2166
|
+
if (!success) throw new Error(`Timeout waiting for condition at Step ${i + 1}`);
|
|
2167
|
+
}
|
|
2168
|
+
onLog(`[Router] Executing Step ${i + 1}...`);
|
|
2169
|
+
try {
|
|
2170
|
+
const hash = await step.aa.sendUserOperation(signedOp);
|
|
2171
|
+
onLog(`[Router] Step ${i + 1} Sent! Hash: ${hash}`);
|
|
2172
|
+
onLog(`[Router] Waiting for Step ${i + 1} confirmation...`);
|
|
2173
|
+
const receipt = await step.aa.waitForUserOperation(hash);
|
|
2174
|
+
if (!receipt.success) {
|
|
2175
|
+
throw new Error(`Step ${i + 1} Failed on-chain!`);
|
|
2176
|
+
}
|
|
2177
|
+
onLog(`[Router] Step ${i + 1} Confirmed.`);
|
|
2178
|
+
} catch (err) {
|
|
2179
|
+
onLog(`[Router] Execution Failed at Step ${i + 1}: ${err.message}`);
|
|
2180
|
+
throw err;
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
onLog("[Router] Multi-Hop Sequence Completed Successfully! \u{1F680}");
|
|
2184
|
+
return true;
|
|
2185
|
+
}
|
|
2186
|
+
async pollCondition(condition, onLog) {
|
|
2187
|
+
const timeout = 6e4 * 10;
|
|
2188
|
+
const interval = 5e3;
|
|
2189
|
+
let elapsed = 0;
|
|
2190
|
+
while (elapsed < timeout) {
|
|
2191
|
+
try {
|
|
2192
|
+
const passed = await condition();
|
|
2193
|
+
if (passed) return true;
|
|
2194
|
+
} catch (e) {
|
|
2195
|
+
onLog(`[Router] Polling check failed (retrying): ${e.message}`);
|
|
2196
|
+
}
|
|
2197
|
+
await new Promise((r) => setTimeout(r, interval));
|
|
2198
|
+
elapsed += interval;
|
|
2199
|
+
if (elapsed % 2e4 === 0) onLog(`[Router] Still waiting... (${Math.floor(elapsed / 1e3)}s)`);
|
|
2200
|
+
}
|
|
2201
|
+
return false;
|
|
2202
|
+
}
|
|
2203
|
+
};
|
|
2204
|
+
}
|
|
2205
|
+
});
|
|
1885
2206
|
|
|
1886
2207
|
// src/services/TransferManager.ts
|
|
1887
2208
|
var TransferManager_exports = {};
|
|
@@ -1894,17 +2215,24 @@ var init_TransferManager = __esm({
|
|
|
1894
2215
|
init_cctp2();
|
|
1895
2216
|
init_near();
|
|
1896
2217
|
init_stargate();
|
|
2218
|
+
init_stacks();
|
|
2219
|
+
init_Router();
|
|
2220
|
+
init_chainsInformation();
|
|
1897
2221
|
TransferManager = class {
|
|
1898
2222
|
constructor() {
|
|
1899
2223
|
this.strategies = [
|
|
1900
2224
|
new CCTPStrategy(),
|
|
1901
2225
|
new StargateStrategy(),
|
|
1902
|
-
new
|
|
2226
|
+
new StargateStrategy(),
|
|
2227
|
+
new NearStrategy(),
|
|
2228
|
+
new StacksStrategy()
|
|
1903
2229
|
];
|
|
2230
|
+
this.router = new RouterService();
|
|
1904
2231
|
}
|
|
1905
|
-
async execute(context) {
|
|
2232
|
+
async execute(context, logCallback) {
|
|
2233
|
+
const log = logCallback || console.log;
|
|
1906
2234
|
if (context.sourceChain === context.destChain && context.sourceToken === context.destToken) {
|
|
1907
|
-
|
|
2235
|
+
log(`[TransferManager] Same Chain detected. Signal Direct Transfer.`);
|
|
1908
2236
|
return {
|
|
1909
2237
|
success: true,
|
|
1910
2238
|
transactionHash: "DIRECT_TRANSFER_REQUIRED",
|
|
@@ -1916,20 +2244,38 @@ var init_TransferManager = __esm({
|
|
|
1916
2244
|
}
|
|
1917
2245
|
};
|
|
1918
2246
|
}
|
|
2247
|
+
if (context.destChain === "Stacks" && context.sourceChain !== "Ethereum") {
|
|
2248
|
+
const networkConfig = NETWORKS[context.sourceChain];
|
|
2249
|
+
if (networkConfig?.crossChainInformation?.circleInformation?.cCTPInformation?.supportCCTP) {
|
|
2250
|
+
log(`[TransferManager] Auto-Routing to Stacks via CCTP (${context.sourceChain} -> Ethereum -> Stacks)`);
|
|
2251
|
+
if (!context.sourceAA || !context.facilitatorPrivateKey) {
|
|
2252
|
+
return {
|
|
2253
|
+
success: false,
|
|
2254
|
+
errorReason: "Source AA and Facilitator Private Key required for Stacks Multi-Hop"
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
return this.executeEVMToStacks(
|
|
2258
|
+
context,
|
|
2259
|
+
context.sourceAA,
|
|
2260
|
+
context.facilitatorPrivateKey,
|
|
2261
|
+
logCallback
|
|
2262
|
+
);
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
1919
2265
|
const strategies = this.strategies;
|
|
1920
2266
|
const stargateStrategy = strategies.find((s) => s instanceof StargateStrategy);
|
|
1921
2267
|
if (stargateStrategy && stargateStrategy.canHandle(context)) {
|
|
1922
|
-
|
|
2268
|
+
log(`[TransferManager] Routing to: ${stargateStrategy.name} (Stargate)`);
|
|
1923
2269
|
return stargateStrategy.execute(context);
|
|
1924
2270
|
}
|
|
1925
2271
|
const cctpStrategy = strategies.find((s) => s instanceof CCTPStrategy);
|
|
1926
2272
|
if (cctpStrategy && cctpStrategy.canHandle(context)) {
|
|
1927
|
-
|
|
2273
|
+
log(`[TransferManager] Routing to: ${cctpStrategy.name} (CCTP)`);
|
|
1928
2274
|
return cctpStrategy.execute(context);
|
|
1929
2275
|
}
|
|
1930
2276
|
const nearStrategy = strategies.find((s) => s instanceof NearStrategy);
|
|
1931
2277
|
if (nearStrategy && nearStrategy.canHandle(context)) {
|
|
1932
|
-
|
|
2278
|
+
log(`[TransferManager] Routing to: ${nearStrategy.name} (Near)`);
|
|
1933
2279
|
return nearStrategy.execute(context);
|
|
1934
2280
|
}
|
|
1935
2281
|
return {
|
|
@@ -1937,6 +2283,115 @@ var init_TransferManager = __esm({
|
|
|
1937
2283
|
errorReason: `No suitable transfer strategy found for ${context.sourceChain} -> ${context.destChain}`
|
|
1938
2284
|
};
|
|
1939
2285
|
}
|
|
2286
|
+
/**
|
|
2287
|
+
* Specialized method for Base/Unichain -> Stacks flow.
|
|
2288
|
+
* 1. EVM (Base/Unichain) -> Ethereum (CCTP)
|
|
2289
|
+
* 2. Ethereum -> Stacks (Stacks Bridge)
|
|
2290
|
+
*/
|
|
2291
|
+
async executeEVMToStacks(context, sourceAA, ethPrivateKey, logCallback) {
|
|
2292
|
+
const log = logCallback || console.log;
|
|
2293
|
+
log(`[TransferManager] Starting ${context.sourceChain} -> Stacks Flow...`);
|
|
2294
|
+
const cctpStrategy = this.strategies.find((s) => s instanceof CCTPStrategy);
|
|
2295
|
+
const stacksStrategy = this.strategies.find((s) => s instanceof StacksStrategy);
|
|
2296
|
+
if (context.sourceChain === "Ethereum") {
|
|
2297
|
+
log("[TransferManager] Source is Ethereum. Executing Stacks Bridge Step...");
|
|
2298
|
+
return stacksStrategy.execute({
|
|
2299
|
+
...context,
|
|
2300
|
+
facilitatorPrivateKey: ethPrivateKey
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
const sourceConfig = NETWORKS[context.sourceChain];
|
|
2304
|
+
const supportsCCTP = sourceConfig?.crossChainInformation?.circleInformation?.cCTPInformation?.supportCCTP;
|
|
2305
|
+
if (supportsCCTP) {
|
|
2306
|
+
log(`[TransferManager] Step 1: ${context.sourceChain} -> Ethereum (via CCTP)`);
|
|
2307
|
+
const ethAccount = privateKeyToAccount(ethPrivateKey);
|
|
2308
|
+
const ethAddress = ethAccount.address;
|
|
2309
|
+
log(`[TransferManager] Funding Facilitator (${ethAddress})...`);
|
|
2310
|
+
try {
|
|
2311
|
+
const amountBigInt = parseUnits(context.amount, 6);
|
|
2312
|
+
const executeFunding = async () => {
|
|
2313
|
+
try {
|
|
2314
|
+
return await sourceAA.smartTransfer(
|
|
2315
|
+
"USDC",
|
|
2316
|
+
ethAddress,
|
|
2317
|
+
amountBigInt
|
|
2318
|
+
);
|
|
2319
|
+
} catch (e) {
|
|
2320
|
+
const msg = e.message || String(e);
|
|
2321
|
+
if (msg.includes("Approval required")) {
|
|
2322
|
+
log("[TransferManager] Approval Required. Approving USDC...");
|
|
2323
|
+
const saAddress = await sourceAA.getSmartAccount();
|
|
2324
|
+
if (!saAddress) throw new Error("SA Address missing for approval");
|
|
2325
|
+
await sourceAA.approveToken(sourceAA.getTokenAddress("USDC"), saAddress, amountBigInt);
|
|
2326
|
+
log("[TransferManager] Approved. Retrying Transfer...");
|
|
2327
|
+
return await sourceAA.smartTransfer(
|
|
2328
|
+
"USDC",
|
|
2329
|
+
ethAddress,
|
|
2330
|
+
amountBigInt
|
|
2331
|
+
);
|
|
2332
|
+
}
|
|
2333
|
+
throw e;
|
|
2334
|
+
}
|
|
2335
|
+
};
|
|
2336
|
+
const transferResult = await executeFunding();
|
|
2337
|
+
if ("success" in transferResult && !transferResult.success) {
|
|
2338
|
+
throw new Error("Funding Transfer Failed");
|
|
2339
|
+
}
|
|
2340
|
+
const fundingHash = transferResult.receipt.transactionHash;
|
|
2341
|
+
log(`[TransferManager] Funds Sent. Hash: ${fundingHash}`);
|
|
2342
|
+
const cctpResult = await cctpStrategy.execute({
|
|
2343
|
+
...context,
|
|
2344
|
+
destChain: "Ethereum",
|
|
2345
|
+
destToken: "USDC",
|
|
2346
|
+
recipient: ethAddress,
|
|
2347
|
+
facilitatorPrivateKey: ethPrivateKey,
|
|
2348
|
+
depositTxHash: fundingHash
|
|
2349
|
+
});
|
|
2350
|
+
if (!cctpResult.success) {
|
|
2351
|
+
return cctpResult;
|
|
2352
|
+
}
|
|
2353
|
+
log("[TransferManager] CCTP Step Initiated.");
|
|
2354
|
+
if (cctpResult.mintTransactionHash) {
|
|
2355
|
+
log("[TransferManager] CCTP Complete (Funds on Ethereum). Proceeding to Stacks Step...");
|
|
2356
|
+
const stacksResult = await stacksStrategy.execute({
|
|
2357
|
+
...context,
|
|
2358
|
+
sourceChain: "Ethereum",
|
|
2359
|
+
amount: cctpResult.netAmount ? formatUnits(BigInt(cctpResult.netAmount), 6) : context.amount,
|
|
2360
|
+
facilitatorPrivateKey: ethPrivateKey
|
|
2361
|
+
});
|
|
2362
|
+
return {
|
|
2363
|
+
success: stacksResult.success,
|
|
2364
|
+
transactionHash: stacksResult.transactionHash,
|
|
2365
|
+
data: {
|
|
2366
|
+
fundingStep: { transactionHash: fundingHash },
|
|
2367
|
+
cctpStep: cctpResult,
|
|
2368
|
+
stacksStep: stacksResult
|
|
2369
|
+
},
|
|
2370
|
+
netAmount: stacksResult.netAmount,
|
|
2371
|
+
errorReason: stacksResult.errorReason
|
|
2372
|
+
};
|
|
2373
|
+
} else {
|
|
2374
|
+
log("[TransferManager] CCTP Pending. Please resume later.");
|
|
2375
|
+
return {
|
|
2376
|
+
...cctpResult,
|
|
2377
|
+
attestation: {
|
|
2378
|
+
message: "CCTP Initiated but not finalized.",
|
|
2379
|
+
attestation: cctpResult.attestation?.attestation || ""
|
|
2380
|
+
}
|
|
2381
|
+
};
|
|
2382
|
+
}
|
|
2383
|
+
} catch (err) {
|
|
2384
|
+
return {
|
|
2385
|
+
success: false,
|
|
2386
|
+
errorReason: `Funding/CCTP Failed: ${err instanceof Error ? err.message : String(err)}`
|
|
2387
|
+
};
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
return {
|
|
2391
|
+
success: false,
|
|
2392
|
+
errorReason: `Unsupported Route for ${context.sourceChain}->Stacks Helper`
|
|
2393
|
+
};
|
|
2394
|
+
}
|
|
1940
2395
|
};
|
|
1941
2396
|
}
|
|
1942
2397
|
});
|
|
@@ -2150,6 +2605,24 @@ var BundlerClient = class {
|
|
|
2150
2605
|
amount.toString()
|
|
2151
2606
|
]);
|
|
2152
2607
|
}
|
|
2608
|
+
async scheduleUserOp(userOp, condition) {
|
|
2609
|
+
return await this.call("bundler_scheduleUserOp", [
|
|
2610
|
+
{
|
|
2611
|
+
sender: userOp.sender,
|
|
2612
|
+
nonce: "0x" + userOp.nonce.toString(16),
|
|
2613
|
+
initCode: userOp.initCode,
|
|
2614
|
+
callData: userOp.callData,
|
|
2615
|
+
callGasLimit: "0x" + userOp.callGasLimit.toString(16),
|
|
2616
|
+
verificationGasLimit: "0x" + userOp.verificationGasLimit.toString(16),
|
|
2617
|
+
preVerificationGas: "0x" + userOp.preVerificationGas.toString(16),
|
|
2618
|
+
maxFeePerGas: "0x" + userOp.maxFeePerGas.toString(16),
|
|
2619
|
+
maxPriorityFeePerGas: "0x" + userOp.maxPriorityFeePerGas.toString(16),
|
|
2620
|
+
paymasterAndData: userOp.paymasterAndData,
|
|
2621
|
+
signature: userOp.signature
|
|
2622
|
+
},
|
|
2623
|
+
condition
|
|
2624
|
+
]);
|
|
2625
|
+
}
|
|
2153
2626
|
};
|
|
2154
2627
|
var TokenService = class {
|
|
2155
2628
|
constructor(chainConfig, publicClient) {
|
|
@@ -2372,6 +2845,23 @@ var AccountAbstraction = class {
|
|
|
2372
2845
|
this.tokenService = new TokenService(chainConfig, this.publicClient);
|
|
2373
2846
|
this.userOpBuilder = new UserOpBuilder(chainConfig, this.bundlerClient, this.publicClient);
|
|
2374
2847
|
}
|
|
2848
|
+
getBundlerClient() {
|
|
2849
|
+
return this.bundlerClient;
|
|
2850
|
+
}
|
|
2851
|
+
getChainId() {
|
|
2852
|
+
return this.chainConfig.chain.id;
|
|
2853
|
+
}
|
|
2854
|
+
getPublicClient() {
|
|
2855
|
+
return this.publicClient;
|
|
2856
|
+
}
|
|
2857
|
+
async buildUserOperation(transaction) {
|
|
2858
|
+
if (!this.owner || !this.smartAccountAddress) throw new Error("Not connected");
|
|
2859
|
+
return this.userOpBuilder.buildUserOperationBatch(this.owner, this.smartAccountAddress, [transaction]);
|
|
2860
|
+
}
|
|
2861
|
+
async buildBatchUserOperation(transactions) {
|
|
2862
|
+
if (!this.owner || !this.smartAccountAddress) throw new Error("Not connected");
|
|
2863
|
+
return this.userOpBuilder.buildUserOperationBatch(this.owner, this.smartAccountAddress, transactions);
|
|
2864
|
+
}
|
|
2375
2865
|
async connect(signer) {
|
|
2376
2866
|
if (typeof signer === "string") {
|
|
2377
2867
|
const account = privateKeyToAccount(signer);
|
|
@@ -2450,13 +2940,29 @@ var AccountAbstraction = class {
|
|
|
2450
2940
|
* Get the Smart Account address for an owner
|
|
2451
2941
|
*/
|
|
2452
2942
|
async getSmartAccountAddress(owner) {
|
|
2453
|
-
|
|
2454
|
-
address
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2943
|
+
try {
|
|
2944
|
+
const address = await this.publicClient.readContract({
|
|
2945
|
+
address: this.factoryAddress,
|
|
2946
|
+
abi: factoryAbi,
|
|
2947
|
+
functionName: "getAccountAddress",
|
|
2948
|
+
args: [owner, 0n]
|
|
2949
|
+
});
|
|
2950
|
+
return address;
|
|
2951
|
+
} catch (e) {
|
|
2952
|
+
try {
|
|
2953
|
+
const { result } = await this.publicClient.simulateContract({
|
|
2954
|
+
address: this.factoryAddress,
|
|
2955
|
+
abi: factoryAbi,
|
|
2956
|
+
functionName: "createAccount",
|
|
2957
|
+
args: [owner, 0n],
|
|
2958
|
+
account: "0x0000000000000000000000000000000000000000"
|
|
2959
|
+
// Zero address or random for simulation
|
|
2960
|
+
});
|
|
2961
|
+
return result;
|
|
2962
|
+
} catch (inner) {
|
|
2963
|
+
throw e;
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2460
2966
|
}
|
|
2461
2967
|
// --- Token Methods (Delegated) ---
|
|
2462
2968
|
getTokenAddress(token) {
|
|
@@ -2713,6 +3219,12 @@ var AccountAbstraction = class {
|
|
|
2713
3219
|
}
|
|
2714
3220
|
};
|
|
2715
3221
|
|
|
3222
|
+
// src/index.ts
|
|
3223
|
+
init_Base();
|
|
3224
|
+
init_Avalanche();
|
|
3225
|
+
init_Optimism();
|
|
3226
|
+
init_Unichain();
|
|
3227
|
+
|
|
2716
3228
|
// src/chains.ts
|
|
2717
3229
|
init_Base();
|
|
2718
3230
|
init_Gnosis();
|
|
@@ -2754,11 +3266,14 @@ init_Arbitrum();
|
|
|
2754
3266
|
init_Unichain();
|
|
2755
3267
|
init_Monad();
|
|
2756
3268
|
init_Stellar();
|
|
3269
|
+
init_Stacks();
|
|
2757
3270
|
function mapToSDKConfig(data) {
|
|
2758
3271
|
if (data.nonEvm) {
|
|
3272
|
+
const isStacks = data.assets[0].address?.toString().startsWith("SP") || data.nonEvm.serverURL?.includes("hiro");
|
|
3273
|
+
const chainId = isStacks ? 5e3 : 9e3;
|
|
3274
|
+
const chainName = isStacks ? "Stacks" : "Stellar";
|
|
2759
3275
|
return {
|
|
2760
|
-
chain: { id:
|
|
2761
|
-
// Custom ID for Stellar
|
|
3276
|
+
chain: { id: chainId, name: chainName },
|
|
2762
3277
|
tokens: data.assets.map((a) => ({
|
|
2763
3278
|
symbol: a.name,
|
|
2764
3279
|
decimals: a.decimals,
|
|
@@ -2792,6 +3307,7 @@ var ARBITRUM_MAINNET = mapToSDKConfig(ARBITRUM);
|
|
|
2792
3307
|
var UNICHAIN_MAINNET = mapToSDKConfig(UNICHAIN);
|
|
2793
3308
|
var MONAD_MAINNET = mapToSDKConfig(Monad);
|
|
2794
3309
|
var STELLAR_MAINNET = mapToSDKConfig(STELLAR);
|
|
3310
|
+
var STACKS_MAINNET = mapToSDKConfig(STACKS);
|
|
2795
3311
|
var CHAIN_CONFIGS = {
|
|
2796
3312
|
[base.id]: BASE_MAINNET,
|
|
2797
3313
|
[baseSepolia.id]: BASE_SEPOLIA2,
|
|
@@ -2803,9 +3319,11 @@ var CHAIN_CONFIGS = {
|
|
|
2803
3319
|
[arbitrum.id]: ARBITRUM_MAINNET,
|
|
2804
3320
|
[unichain.id]: UNICHAIN_MAINNET,
|
|
2805
3321
|
[monad.id]: MONAD_MAINNET,
|
|
2806
|
-
9e3: STELLAR_MAINNET
|
|
3322
|
+
9e3: STELLAR_MAINNET,
|
|
3323
|
+
5e3: STACKS_MAINNET
|
|
2807
3324
|
};
|
|
2808
3325
|
var CHAIN_ID_TO_KEY = {
|
|
3326
|
+
[mainnet.id]: "Ethereum",
|
|
2809
3327
|
[base.id]: "Base",
|
|
2810
3328
|
[baseSepolia.id]: "Base",
|
|
2811
3329
|
[gnosis.id]: "Gnosis",
|
|
@@ -2817,7 +3335,8 @@ var CHAIN_ID_TO_KEY = {
|
|
|
2817
3335
|
[avalanche.id]: "Avalanche",
|
|
2818
3336
|
[unichain.id]: "Unichain",
|
|
2819
3337
|
[monad.id]: "Monad",
|
|
2820
|
-
"9000": "Stellar"
|
|
3338
|
+
"9000": "Stellar",
|
|
3339
|
+
"5000": "Stacks"
|
|
2821
3340
|
};
|
|
2822
3341
|
|
|
2823
3342
|
// src/index.ts
|
|
@@ -2912,6 +3431,9 @@ var UniswapService = class {
|
|
|
2912
3431
|
};
|
|
2913
3432
|
var uniswapService = new UniswapService();
|
|
2914
3433
|
|
|
2915
|
-
|
|
3434
|
+
// src/index.ts
|
|
3435
|
+
init_Router();
|
|
3436
|
+
|
|
3437
|
+
export { ARBITRUM_MAINNET, AVALANCHE, AVALANCHE_MAINNET, AccountAbstraction, BASE, BASE_MAINNET, BASE_SEPOLIA2 as BASE_SEPOLIA, BSC_MAINNET, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, GNOSIS_MAINNET, MONAD_MAINNET, NearStrategy, OPTIMISM, OPTIMISM_MAINNET, POLYGON_MAINNET, RouterService, STACKS_MAINNET, STELLAR, STELLAR_MAINNET, StargateStrategy, StellarService, TransferManager, UNICHAIN, UNICHAIN_MAINNET, UniswapService, entryPointAbi, erc20Abi, getNearQuote, getNearSimulation, getStargateSimulation, smartAccountAbi, uniswapService };
|
|
2916
3438
|
//# sourceMappingURL=index.mjs.map
|
|
2917
3439
|
//# sourceMappingURL=index.mjs.map
|