@actalink/sdkv2 0.1.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/index.js ADDED
@@ -0,0 +1,1528 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+
41
+ // src/tokens.ts
42
+ import { getAddress, zeroAddress } from "viem";
43
+ import {
44
+ arbitrum as arbitrum2,
45
+ base as base2,
46
+ bsc as bsc2,
47
+ mainnet as mainnet2,
48
+ linea,
49
+ optimism as optimism2,
50
+ polygon as polygon2,
51
+ sepolia as sepolia2,
52
+ polygonAmoy as polygonAmoy2,
53
+ baseSepolia as baseSepolia2
54
+ } from "viem/chains";
55
+
56
+ // src/chains.ts
57
+ import { baseSepolia, polygonAmoy, sepolia } from "viem/chains";
58
+ import { arbitrum, base, bsc, optimism, polygon, mainnet } from "viem/chains";
59
+ var supportedChains = [
60
+ arbitrum,
61
+ base,
62
+ bsc,
63
+ mainnet,
64
+ optimism,
65
+ polygon
66
+ ];
67
+ var mainnetChains = [arbitrum, base, bsc, mainnet, optimism, polygon];
68
+ var testnetChains = [sepolia, baseSepolia, polygonAmoy];
69
+ function getChainById(chainId) {
70
+ const chain = supportedChains.find((c) => c.id === chainId);
71
+ if (!chain) throw new Error(`Chain ${chainId} not supported.`);
72
+ return chain;
73
+ }
74
+ function getChainExplorerByChainId(chainId) {
75
+ switch (chainId) {
76
+ case arbitrum.id:
77
+ return "https://arbiscan.io";
78
+ case base.id:
79
+ return "https://basescan.org";
80
+ case bsc.id:
81
+ return "https://bscscan.com";
82
+ case mainnet.id:
83
+ return "https://etherscan.io";
84
+ case optimism.id:
85
+ return "https://optimistic.etherscan.io";
86
+ case polygon.id:
87
+ return "https://polygonscan.com";
88
+ default:
89
+ return void 0;
90
+ }
91
+ }
92
+
93
+ // src/types/schema.ts
94
+ import { z } from "zod";
95
+ import { isAddress } from "viem";
96
+ var ProviderConfigSchema = z.object({
97
+ type: z.enum(["alchemy", "infura", "quicknode", "other"]),
98
+ apiKey: z.string().min(1, "API key is required"),
99
+ url: z.string().url().optional()
100
+ });
101
+ var ActaAccessConfigSchema = z.object({
102
+ projectId: z.string().min(1, "projectId is required")
103
+ });
104
+ var CreateSinglePaymentSchema = z.object({
105
+ signerAddress: z.string().refine((val) => isAddress(val), {
106
+ message: "Invalid Ethereum address"
107
+ }).transform((val) => val),
108
+ chainId: z.union([
109
+ z.literal(1),
110
+ z.literal(42161),
111
+ z.literal(8453),
112
+ z.literal(59144),
113
+ z.literal(56),
114
+ z.literal(10),
115
+ z.literal(137)
116
+ ]),
117
+ publicClient: z.custom(
118
+ (val) => val !== void 0,
119
+ "Invalid PublicClient Instance"
120
+ ),
121
+ walletClient: z.custom(
122
+ (val) => val !== void 0,
123
+ "Invalid WalletClient Instance"
124
+ ),
125
+ token: z.enum(["USDC", "USDT"]),
126
+ amount: z.bigint().refine((v) => v > BigInt(0), "Amount must be positive"),
127
+ receiver: z.string().refine((val) => isAddress(val), {
128
+ message: "Invalid Ethereum address"
129
+ }).transform((val) => val),
130
+ allowMaxTokenApproval: z.boolean()
131
+ });
132
+ var CreateRecurringPaymentSchema = z.object({
133
+ signerAddress: z.string().refine((val) => isAddress(val), {
134
+ message: "Invalid Ethereum address"
135
+ }).transform((val) => val),
136
+ chainId: z.union([
137
+ z.literal(1),
138
+ z.literal(42161),
139
+ z.literal(8453),
140
+ z.literal(59144),
141
+ z.literal(56),
142
+ z.literal(10),
143
+ z.literal(137)
144
+ ]),
145
+ publicClient: z.custom(
146
+ (val) => val !== void 0,
147
+ "Invalid PublicClient Instance"
148
+ ),
149
+ walletClient: z.custom(
150
+ (val) => val !== void 0,
151
+ "Invalid WalletClient Instance"
152
+ ),
153
+ token: z.enum(["USDC", "USDT"]),
154
+ amount: z.bigint().refine((v) => v > BigInt(0), "Amount must be positive"),
155
+ receiver: z.string().refine((val) => isAddress(val), {
156
+ message: "Invalid Ethereum address"
157
+ }).transform((val) => val),
158
+ allowMaxTokenApproval: z.boolean(),
159
+ count: z.number().int().positive(),
160
+ intervalUnit: z.enum(["day", "week", "month", "year"])
161
+ });
162
+ var EstimateSinglePaymentGasSchema = z.object({
163
+ signerAddress: z.string().refine((val) => isAddress(val), {
164
+ message: "Invalid Ethereum address"
165
+ }).transform((val) => val),
166
+ chainId: z.union([
167
+ z.literal(1),
168
+ z.literal(42161),
169
+ z.literal(8453),
170
+ z.literal(59144),
171
+ z.literal(56),
172
+ z.literal(10),
173
+ z.literal(137)
174
+ ]),
175
+ publicClient: z.custom(
176
+ (val) => val !== void 0,
177
+ "Invalid PublicClient Instance"
178
+ ),
179
+ walletClient: z.custom(
180
+ (val) => val !== void 0,
181
+ "Invalid WalletClient Instance"
182
+ ),
183
+ token: z.enum(["USDC", "USDT"]),
184
+ amount: z.bigint().refine((v) => v > BigInt(0), "Amount must be positive"),
185
+ receiver: z.string().refine((val) => isAddress(val), {
186
+ message: "Invalid Ethereum address"
187
+ }).transform((val) => val)
188
+ });
189
+ var PaymentStatusSchema = z.object({
190
+ id: z.string(),
191
+ status: z.enum(["pending", "success", "failed", "cancelled"]),
192
+ transactionHash: z.string().optional(),
193
+ error: z.string().optional(),
194
+ createdAt: z.string(),
195
+ updatedAt: z.string()
196
+ });
197
+ var PollPaymentStatusSchema = z.object({
198
+ id: z.string().min(1, "Payment ID is required")
199
+ });
200
+
201
+ // src/tokens.ts
202
+ var arbitrumETH = nativeETH(arbitrum2.id);
203
+ var arbitrumWETH = token({
204
+ chainId: arbitrum2.id,
205
+ address: getAddress("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),
206
+ decimals: 18,
207
+ name: "Wrapped Ether",
208
+ symbol: "WETH",
209
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
210
+ });
211
+ var arbitrumUSDC = token({
212
+ chainId: arbitrum2.id,
213
+ address: getAddress("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
214
+ name: "USD Coin",
215
+ symbol: "USDC",
216
+ fiatISO: "USD",
217
+ decimals: 6,
218
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
219
+ });
220
+ var arbitrumDAI = token({
221
+ chainId: arbitrum2.id,
222
+ address: getAddress("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
223
+ decimals: 18,
224
+ fiatISO: "USD",
225
+ name: "Dai Stablecoin",
226
+ symbol: "DAI",
227
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
228
+ });
229
+ var arbitrumUSDT = token({
230
+ chainId: arbitrum2.id,
231
+ address: getAddress("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),
232
+ decimals: 6,
233
+ fiatISO: "USD",
234
+ name: "Tether USD",
235
+ symbol: "USDT",
236
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
237
+ });
238
+ var arbitrumUSDCe = token({
239
+ chainId: arbitrum2.id,
240
+ address: getAddress("0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"),
241
+ decimals: 6,
242
+ fiatISO: "USD",
243
+ name: "Bridged USD Coin",
244
+ symbol: "USDCe",
245
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
246
+ });
247
+ var arbitrumTokens = [arbitrumUSDC, arbitrumUSDT];
248
+ var baseETH = nativeETH(base2.id);
249
+ var baseWETH = token({
250
+ chainId: base2.id,
251
+ address: getAddress("0x4200000000000000000000000000000000000006"),
252
+ decimals: 18,
253
+ name: "Wrapped Ether",
254
+ symbol: "WETH",
255
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
256
+ });
257
+ var baseUSDC = token({
258
+ chainId: base2.id,
259
+ address: getAddress("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
260
+ name: "USD Coin",
261
+ symbol: "USDC",
262
+ fiatISO: "USD",
263
+ decimals: 6,
264
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
265
+ });
266
+ var baseEURC = token({
267
+ chainId: base2.id,
268
+ address: getAddress("0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42"),
269
+ decimals: 6,
270
+ fiatISO: "EUR",
271
+ name: "EURC",
272
+ symbol: "EURC",
273
+ logoURI: "https://api.acta.link/deposit/v1/logos/eurc.png" /* EURC */
274
+ });
275
+ var baseUSDbC = token({
276
+ chainId: base2.id,
277
+ address: getAddress("0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA"),
278
+ name: "Bridged USD Coin",
279
+ symbol: "USDbC",
280
+ fiatISO: "USD",
281
+ decimals: 6,
282
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdbc.png"
283
+ });
284
+ var baseDAI = token({
285
+ chainId: base2.id,
286
+ address: getAddress("0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"),
287
+ name: "Dai Stablecoin",
288
+ symbol: "DAI",
289
+ fiatISO: "USD",
290
+ decimals: 18,
291
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
292
+ });
293
+ var baseUSDT = token({
294
+ chainId: base2.id,
295
+ address: getAddress("0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2"),
296
+ name: "Tether USD",
297
+ symbol: "USDT",
298
+ fiatISO: "USD",
299
+ decimals: 6,
300
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
301
+ });
302
+ var baseTokens = [baseUSDC, baseUSDT];
303
+ var bscBNB = nativeToken({
304
+ chainId: bsc2.id,
305
+ name: "BNB",
306
+ symbol: "BNB",
307
+ logoURI: "https://api.acta.link/deposit/v1/logos/bnb.png" /* BNB */
308
+ });
309
+ var bscWBNB = token({
310
+ chainId: bsc2.id,
311
+ address: getAddress("0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"),
312
+ decimals: 18,
313
+ name: "Wrapped BNB",
314
+ symbol: "WBNB",
315
+ logoURI: "https://api.acta.link/deposit/v1/logos/bnb.png" /* BNB */
316
+ });
317
+ var bscUSDC = token({
318
+ chainId: bsc2.id,
319
+ address: getAddress("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
320
+ decimals: 18,
321
+ fiatISO: "USD",
322
+ name: "USD Coin",
323
+ symbol: "USDC",
324
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
325
+ });
326
+ var bscUSDT = token({
327
+ chainId: bsc2.id,
328
+ address: getAddress("0x55d398326f99059fF775485246999027B3197955"),
329
+ decimals: 18,
330
+ fiatISO: "USD",
331
+ name: "Tether USD",
332
+ symbol: "USDT",
333
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
334
+ });
335
+ var bscTokens = [bscUSDT];
336
+ var ethereumETH = nativeETH(mainnet2.id);
337
+ var ethereumWETH = token({
338
+ chainId: mainnet2.id,
339
+ address: getAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
340
+ decimals: 18,
341
+ name: "Wrapped Ether",
342
+ symbol: "WETH",
343
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
344
+ });
345
+ var ethereumUSDC = token({
346
+ chainId: mainnet2.id,
347
+ address: getAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
348
+ decimals: 6,
349
+ fiatISO: "USD",
350
+ name: "USD Coin",
351
+ symbol: "USDC",
352
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
353
+ });
354
+ var ethereumDAI = token({
355
+ chainId: mainnet2.id,
356
+ address: getAddress("0x6B175474E89094C44Da98b954EedeAC495271d0F"),
357
+ decimals: 18,
358
+ fiatISO: "USD",
359
+ name: "Dai Stablecoin",
360
+ symbol: "DAI",
361
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
362
+ });
363
+ var ethereumUSDT = token({
364
+ chainId: mainnet2.id,
365
+ address: getAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7"),
366
+ decimals: 6,
367
+ fiatISO: "USD",
368
+ name: "Tether USD",
369
+ symbol: "USDT",
370
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
371
+ });
372
+ var ethereumEURC = token({
373
+ chainId: mainnet2.id,
374
+ address: getAddress("0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c"),
375
+ decimals: 6,
376
+ fiatISO: "EUR",
377
+ name: "EURC",
378
+ symbol: "EURC",
379
+ logoURI: "https://api.acta.link/deposit/v1/logos/eurc.png" /* EURC */
380
+ });
381
+ var ethereumTokens = [ethereumUSDC, ethereumUSDT];
382
+ var lineaETH = nativeETH(linea.id);
383
+ var lineaWETH = token({
384
+ chainId: linea.id,
385
+ address: getAddress("0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f"),
386
+ decimals: 18,
387
+ name: "Wrapped Ether",
388
+ symbol: "WETH",
389
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
390
+ });
391
+ var lineaUSDC = token({
392
+ chainId: linea.id,
393
+ address: getAddress("0x176211869cA2b568f2A7D4EE941E073a821EE1ff"),
394
+ decimals: 6,
395
+ fiatISO: "USD",
396
+ name: "USD Coin",
397
+ symbol: "USDC",
398
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
399
+ });
400
+ var lineaDAI = token({
401
+ chainId: linea.id,
402
+ address: getAddress("0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5"),
403
+ decimals: 18,
404
+ fiatISO: "USD",
405
+ name: "Dai Stablecoin",
406
+ symbol: "DAI",
407
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
408
+ });
409
+ var optimismETH = nativeETH(optimism2.id);
410
+ var optimismWETH = token({
411
+ chainId: optimism2.id,
412
+ address: getAddress("0x4200000000000000000000000000000000000006"),
413
+ decimals: 18,
414
+ name: "Wrapped Ether",
415
+ symbol: "WETH",
416
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
417
+ });
418
+ var optimismUSDC = token({
419
+ chainId: optimism2.id,
420
+ address: getAddress("0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85"),
421
+ decimals: 6,
422
+ fiatISO: "USD",
423
+ name: "USD Coin",
424
+ symbol: "USDC",
425
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
426
+ });
427
+ var optimismDAI = token({
428
+ chainId: optimism2.id,
429
+ address: getAddress("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
430
+ decimals: 18,
431
+ fiatISO: "USD",
432
+ name: "Dai Stablecoin",
433
+ symbol: "DAI",
434
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
435
+ });
436
+ var optimismUSDT = token({
437
+ chainId: optimism2.id,
438
+ address: getAddress("0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"),
439
+ decimals: 6,
440
+ fiatISO: "USD",
441
+ name: "Tether USD",
442
+ symbol: "USDT",
443
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
444
+ });
445
+ var optimismUSDCe = token({
446
+ chainId: optimism2.id,
447
+ address: getAddress("0x7F5c764cBc14f9669B88837ca1490cCa17c31607"),
448
+ decimals: 6,
449
+ fiatISO: "USD",
450
+ name: "Bridged USD Coin",
451
+ symbol: "USDCe",
452
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
453
+ });
454
+ var optimismTokens = [optimismUSDC, optimismUSDT];
455
+ var polygonPOL = nativeToken({
456
+ chainId: polygon2.id,
457
+ name: "Polygon",
458
+ symbol: "POL",
459
+ logoURI: "https://api.acta.link/deposit/v1/logos/pol.png" /* POL */
460
+ });
461
+ var polygonWPOL = token({
462
+ chainId: polygon2.id,
463
+ address: getAddress("0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"),
464
+ decimals: 18,
465
+ name: "Wrapped Polygon",
466
+ symbol: "WPOL",
467
+ logoURI: "https://api.acta.link/deposit/v1/logos/pol.png" /* POL */
468
+ });
469
+ var polygonWETH = token({
470
+ chainId: polygon2.id,
471
+ address: getAddress("0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619"),
472
+ decimals: 18,
473
+ name: "Wrapped Ether",
474
+ symbol: "WETH",
475
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
476
+ });
477
+ var polygonUSDC = token({
478
+ chainId: polygon2.id,
479
+ address: getAddress("0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"),
480
+ decimals: 6,
481
+ fiatISO: "USD",
482
+ name: "USD Coin",
483
+ symbol: "USDC",
484
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
485
+ });
486
+ var polygonDAI = token({
487
+ chainId: polygon2.id,
488
+ address: getAddress("0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063"),
489
+ decimals: 18,
490
+ fiatISO: "USD",
491
+ name: "Dai Stablecoin",
492
+ symbol: "DAI",
493
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
494
+ });
495
+ var polygonUSDT = token({
496
+ chainId: polygon2.id,
497
+ address: getAddress("0xc2132D05D31c914a87C6611C10748AEb04B58e8F"),
498
+ decimals: 6,
499
+ fiatISO: "USD",
500
+ name: "Tether USD",
501
+ symbol: "USDT",
502
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
503
+ });
504
+ var polygonUSDCe = token({
505
+ chainId: polygon2.id,
506
+ address: getAddress("0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"),
507
+ decimals: 6,
508
+ fiatISO: "USD",
509
+ name: "USD Coin (PoS)",
510
+ symbol: "USDCe",
511
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
512
+ });
513
+ var polygonTokens = [polygonUSDC, polygonUSDT];
514
+ var polygonAmoyUSDC = token({
515
+ chainId: polygonAmoy2.id,
516
+ address: getAddress("0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582"),
517
+ decimals: 6,
518
+ fiatISO: "USDC",
519
+ name: "USDC",
520
+ symbol: "USDC",
521
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
522
+ });
523
+ var baseSepoliaUSDC = token({
524
+ chainId: baseSepolia2.id,
525
+ address: getAddress("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
526
+ decimals: 6,
527
+ fiatISO: "USDC",
528
+ name: "USDC",
529
+ symbol: "USDC",
530
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
531
+ });
532
+ var sepoliaUSDC = token({
533
+ chainId: sepolia2.id,
534
+ address: getAddress("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
535
+ decimals: 6,
536
+ fiatISO: "USDC",
537
+ name: "USDC",
538
+ symbol: "USDC",
539
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
540
+ });
541
+ var supportedTokensByChain = /* @__PURE__ */ new Map([
542
+ [arbitrum2.id, arbitrumTokens],
543
+ //done
544
+ [base2.id, baseTokens],
545
+ //done
546
+ [bsc2.id, bscTokens],
547
+ //done
548
+ [mainnet2.id, ethereumTokens],
549
+ //done
550
+ [optimism2.id, optimismTokens],
551
+ //done
552
+ [polygon2.id, polygonTokens]
553
+ ]);
554
+ function nativeETH(chainId) {
555
+ return nativeToken({
556
+ chainId,
557
+ name: "Ether",
558
+ symbol: "ETH",
559
+ logoURI: "https://api.acta.link/deposit/v1/logos/ethereum.png" /* ETH */
560
+ });
561
+ }
562
+ function nativeToken({
563
+ chainId,
564
+ name,
565
+ symbol,
566
+ logoURI,
567
+ address = zeroAddress,
568
+ decimals = 18
569
+ }) {
570
+ return {
571
+ chainId,
572
+ address,
573
+ name,
574
+ decimals,
575
+ symbol,
576
+ logoURI,
577
+ logoSourceURI: logoURI
578
+ };
579
+ }
580
+ function token({
581
+ chainId,
582
+ address,
583
+ name,
584
+ symbol,
585
+ decimals,
586
+ fiatISO,
587
+ logoURI
588
+ }) {
589
+ return {
590
+ chainId,
591
+ address,
592
+ name,
593
+ symbol,
594
+ decimals,
595
+ fiatISO,
596
+ logoURI,
597
+ logoSourceURI: logoURI
598
+ };
599
+ }
600
+ function getTokenByChainIdAndSymbol(chainId, symbol) {
601
+ const chain = getChainById(chainId);
602
+ if (!chain) throw new Error(`Chain ${chainId} not supported.`);
603
+ const tokens = supportedTokensByChain.get(chain.id);
604
+ if (!tokens) throw new Error(`Tokens not found for chain ${chainId}.`);
605
+ const token2 = tokens.find((t) => t.symbol === symbol);
606
+ if (!token2)
607
+ throw new Error(`Token ${symbol} not found for chain ${chainId}.`);
608
+ return token2;
609
+ }
610
+ var tokensCommonSymbols = [
611
+ "USDC",
612
+ "USDT",
613
+ "DAI",
614
+ "ETH",
615
+ "WETH",
616
+ "BNB",
617
+ "WBNB",
618
+ "USDCe",
619
+ "USDbC",
620
+ "EURC",
621
+ "POL",
622
+ "WPOL"
623
+ ];
624
+ function getTokenByChainIdAndAddress(chainId, address) {
625
+ const chain = getChainById(chainId);
626
+ if (!chain) throw new Error(`Chain ${chainId} not supported.`);
627
+ const tokens = supportedTokensByChain.get(chain.id);
628
+ if (!tokens) throw new Error(`Tokens not found for chain ${chainId}.`);
629
+ const token2 = tokens.find((t) => t.address === address);
630
+ if (!token2)
631
+ throw new Error(`Token ${address} not found for chain ${chainId}.`);
632
+ return token2;
633
+ }
634
+
635
+ // src/account.ts
636
+ import {
637
+ http,
638
+ getAddress as getAddress2,
639
+ parseAbi as parseAbi2
640
+ } from "viem";
641
+ import {
642
+ createPaymasterClient,
643
+ formatUserOperationRequest
644
+ } from "viem/account-abstraction";
645
+ import {
646
+ addressToEmptyAccount,
647
+ createKernelAccount,
648
+ createKernelAccountClient
649
+ } from "@zerodev/sdk";
650
+ import { getEntryPoint, KERNEL_V3_1 } from "@zerodev/sdk/constants";
651
+ import { signerToEcdsaValidator } from "@zerodev/ecdsa-validator";
652
+ import { createSmartAccountClient, getRequiredPrefund } from "permissionless";
653
+ import { createPimlicoClient } from "permissionless/clients/pimlico";
654
+
655
+ // src/rpc.ts
656
+ function getPimlicoRpcByChainId(chainId) {
657
+ switch (chainId) {
658
+ case 1:
659
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
660
+ case 10:
661
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
662
+ case 56:
663
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
664
+ case 137:
665
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
666
+ case 8453:
667
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
668
+ case 42161:
669
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
670
+ case 59144:
671
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
672
+ case 80002:
673
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
674
+ case 84532:
675
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
676
+ case 11155111:
677
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
678
+ default:
679
+ return void 0;
680
+ }
681
+ }
682
+
683
+ // src/viemClient.ts
684
+ import {
685
+ parseAbi,
686
+ encodeFunctionData,
687
+ maxUint256
688
+ } from "viem";
689
+ var ViemClient = class {
690
+ constructor(walletClient, publicClient) {
691
+ this.walletClient = walletClient;
692
+ this.publicClient = publicClient;
693
+ }
694
+ checkTokenAllowance(token2, owner, spender) {
695
+ return __async(this, null, function* () {
696
+ const allowance = yield this.publicClient.readContract({
697
+ address: token2.address,
698
+ abi: parseAbi([
699
+ "function allowance(address,address) view returns (uint256)"
700
+ ]),
701
+ functionName: "allowance",
702
+ args: [owner, spender]
703
+ });
704
+ return allowance;
705
+ });
706
+ }
707
+ checkAndApproveToken(token2, spender, amount, allowMaxTokenApproval) {
708
+ return __async(this, null, function* () {
709
+ var _a;
710
+ if (this.walletClient === void 0) {
711
+ throw new Error("Wallet client is required");
712
+ }
713
+ const signerAddress = (_a = this.walletClient.account) == null ? void 0 : _a.address;
714
+ if (signerAddress === void 0) {
715
+ throw new Error("Signer address is required");
716
+ }
717
+ const allowance = yield this.checkTokenAllowance(
718
+ token2,
719
+ signerAddress,
720
+ spender
721
+ );
722
+ if (allowance < amount) {
723
+ const txn = yield this.walletClient.sendTransaction({
724
+ to: token2.address,
725
+ account: signerAddress,
726
+ chain: getChainById(token2.chainId),
727
+ value: BigInt(0),
728
+ data: encodeFunctionData({
729
+ abi: parseAbi(["function approve(address,uint)"]),
730
+ functionName: "approve",
731
+ args: [spender, allowMaxTokenApproval ? maxUint256 : amount]
732
+ })
733
+ });
734
+ const receipt = yield this.publicClient.waitForTransactionReceipt({
735
+ hash: txn,
736
+ confirmations: token2.chainId === 1 || 11155111 ? 1 : 5
737
+ });
738
+ return amount;
739
+ }
740
+ return allowance;
741
+ });
742
+ }
743
+ };
744
+
745
+ // src/account.ts
746
+ import { toECDSASigner } from "@zerodev/permissions/signers";
747
+ import {
748
+ serializePermissionAccount,
749
+ toPermissionValidator
750
+ } from "@zerodev/permissions";
751
+ import {
752
+ toCallPolicy,
753
+ CallPolicyVersion,
754
+ ParamCondition
755
+ } from "@zerodev/permissions/policies";
756
+ var ActaAccount = class {
757
+ constructor(publicClient, signer) {
758
+ this.signer = signer;
759
+ this.publicClient = publicClient;
760
+ }
761
+ createAccount() {
762
+ return __async(this, null, function* () {
763
+ const kernelVersion = KERNEL_V3_1;
764
+ const entryPoint = getEntryPoint("0.7");
765
+ const ecdsaValidator = yield signerToEcdsaValidator(this.publicClient, {
766
+ signer: this.signer,
767
+ entryPoint,
768
+ kernelVersion
769
+ });
770
+ const account = yield createKernelAccount(this.publicClient, {
771
+ plugins: {
772
+ sudo: ecdsaValidator
773
+ },
774
+ entryPoint,
775
+ kernelVersion
776
+ });
777
+ return account;
778
+ });
779
+ }
780
+ createAccountHelpers() {
781
+ return __async(this, null, function* () {
782
+ var _a;
783
+ const chainId = (_a = this.publicClient.chain) == null ? void 0 : _a.id;
784
+ if (!chainId) {
785
+ throw new Error("Invalid PublicClient Instance.");
786
+ }
787
+ const account = yield this.createAccount();
788
+ const entryPoint = getEntryPoint("0.7");
789
+ const paymasterClient = createPaymasterClient({
790
+ transport: http(getPimlicoRpcByChainId(chainId))
791
+ });
792
+ const pimlicoClient = createPimlicoClient({
793
+ chain: getChainById(chainId),
794
+ transport: http(getPimlicoRpcByChainId(chainId)),
795
+ entryPoint
796
+ });
797
+ const accountClient = createSmartAccountClient({
798
+ account,
799
+ chain: getChainById(chainId),
800
+ paymaster: paymasterClient,
801
+ bundlerTransport: http(getPimlicoRpcByChainId(chainId)),
802
+ userOperation: {
803
+ estimateFeesPerGas: () => __async(this, null, function* () {
804
+ return (yield pimlicoClient.getUserOperationGasPrice()).fast;
805
+ })
806
+ }
807
+ });
808
+ const kernelAccountClient = createKernelAccountClient({
809
+ account,
810
+ chain: getChainById(chainId),
811
+ paymaster: paymasterClient,
812
+ bundlerTransport: http(getPimlicoRpcByChainId(chainId)),
813
+ userOperation: {
814
+ estimateFeesPerGas: () => __async(this, null, function* () {
815
+ return (yield pimlicoClient.getUserOperationGasPrice()).fast;
816
+ })
817
+ }
818
+ });
819
+ return {
820
+ paymasterClient,
821
+ pimlicoClient,
822
+ accountClient,
823
+ kernelAccountClient
824
+ };
825
+ });
826
+ }
827
+ estimateSinglePaymentGas(parameters) {
828
+ return __async(this, null, function* () {
829
+ const {
830
+ signerAddress,
831
+ chainId,
832
+ token: tokenSymbol,
833
+ amount,
834
+ receiver,
835
+ feebps
836
+ } = parameters;
837
+ if (amount <= BigInt(0)) {
838
+ throw new Error("Amount must be greater than 0.");
839
+ }
840
+ if (receiver === signerAddress) {
841
+ throw new Error("Receiver cannot be the same as the signer.");
842
+ }
843
+ const account = yield this.createAccount();
844
+ const { accountClient, pimlicoClient } = yield this.createAccountHelpers();
845
+ const fromAddress = signerAddress;
846
+ const smartAccountAddress = account.address;
847
+ const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
848
+ if (!token2) {
849
+ throw new Error("Token not found.");
850
+ }
851
+ const userOperation = yield accountClient.prepareUserOperation({
852
+ calls: [
853
+ {
854
+ to: getAddress2(token2.address),
855
+ abi: parseAbi2(["function transferFrom(address,address,uint)"]),
856
+ functionName: "transferFrom",
857
+ args: [
858
+ fromAddress,
859
+ "0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
860
+ BigInt(0)
861
+ ]
862
+ },
863
+ {
864
+ to: getAddress2(token2.address),
865
+ abi: parseAbi2(["function transferFrom(address,address,uint)"]),
866
+ functionName: "transferFrom",
867
+ args: [fromAddress, receiver, BigInt(0)]
868
+ }
869
+ ]
870
+ });
871
+ const quotes = yield pimlicoClient.getTokenQuotes({
872
+ tokens: [token2.address],
873
+ chain: getChainById(chainId)
874
+ });
875
+ const userOperationMaxCost = getRequiredPrefund({
876
+ userOperation,
877
+ entryPointVersion: "0.7"
878
+ });
879
+ const postOpGas = quotes[0].postOpGas;
880
+ const exchangeRate = quotes[0].exchangeRate;
881
+ const exchangeRateNativeToUsd = quotes[0].exchangeRateNativeToUsd;
882
+ const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
883
+ const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
884
+ const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
885
+ const ActalinkFeesInToken = amount * BigInt(feebps) / BigInt(1e4);
886
+ const estimatedTotalFeesInToken = costInToken + ActalinkFeesInToken;
887
+ const feeInclusiveAmountInToken = amount - estimatedTotalFeesInToken;
888
+ const feeExclusiveAmountInToken = amount + estimatedTotalFeesInToken;
889
+ return {
890
+ estimatedGasCostInToken: costInToken,
891
+ ActalinkFeesInToken,
892
+ estimatedTotalFeesInToken,
893
+ feeInclusiveAmountInToken,
894
+ feeExclusiveAmountInToken,
895
+ paymaster: quotes[0].paymaster,
896
+ userOperation
897
+ };
898
+ });
899
+ }
900
+ signSinglePaymentOperation(singlePaymentParams) {
901
+ return __async(this, null, function* () {
902
+ try {
903
+ if (!this.signer) {
904
+ throw new Error("Signer is required for self custody payments.");
905
+ }
906
+ const {
907
+ chainId,
908
+ token: tokenSymbol,
909
+ amount,
910
+ receiver,
911
+ feeInclusive,
912
+ allowMaxTokenApproval,
913
+ feebps,
914
+ signerAddress,
915
+ publicClient,
916
+ walletClient
917
+ } = singlePaymentParams;
918
+ if (amount <= BigInt(0)) {
919
+ throw new Error("Amount must be greater than 0.");
920
+ }
921
+ if (receiver === signerAddress) {
922
+ throw new Error("Receiver cannot be the same as the signer.");
923
+ }
924
+ const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
925
+ if (!token2) {
926
+ throw new Error("Token not found.");
927
+ }
928
+ const viemClient = new ViemClient(walletClient, publicClient);
929
+ const {
930
+ feeInclusiveAmountInToken,
931
+ feeExclusiveAmountInToken,
932
+ estimatedTotalFeesInToken
933
+ } = yield this.estimateSinglePaymentGas({
934
+ signerAddress,
935
+ chainId,
936
+ token: tokenSymbol,
937
+ amount,
938
+ receiver,
939
+ feebps,
940
+ publicClient,
941
+ walletClient
942
+ });
943
+ const account = yield this.createAccount();
944
+ const { accountClient } = yield this.createAccountHelpers();
945
+ const fromAddress = signerAddress;
946
+ const smartAccountAddress = account.address;
947
+ const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
948
+ const receiverAmount = feeInclusive ? feeInclusiveAmountInToken : amount;
949
+ yield viemClient.checkAndApproveToken(
950
+ token2,
951
+ smartAccountAddress,
952
+ amountToTransfer,
953
+ allowMaxTokenApproval != null ? allowMaxTokenApproval : false
954
+ );
955
+ const userOperation = yield accountClient.prepareUserOperation({
956
+ calls: [
957
+ {
958
+ to: getAddress2(token2.address),
959
+ abi: parseAbi2(["function transferFrom(address,address,uint)"]),
960
+ functionName: "transferFrom",
961
+ args: [
962
+ fromAddress,
963
+ "0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
964
+ estimatedTotalFeesInToken
965
+ ]
966
+ },
967
+ {
968
+ to: getAddress2(token2.address),
969
+ abi: parseAbi2(["function transferFrom(address,address,uint)"]),
970
+ functionName: "transferFrom",
971
+ args: [fromAddress, receiver, receiverAmount]
972
+ }
973
+ ]
974
+ });
975
+ const signature = yield account.signUserOperation(__spreadProps(__spreadValues({}, userOperation), {
976
+ chainId
977
+ }));
978
+ const rpcParameters = formatUserOperationRequest(__spreadProps(__spreadValues({}, userOperation), {
979
+ signature
980
+ }));
981
+ return rpcParameters;
982
+ } catch (error) {
983
+ if (error instanceof Error) {
984
+ throw new Error(error.message);
985
+ }
986
+ throw new Error("Failed to sign single payment operation.");
987
+ }
988
+ });
989
+ }
990
+ signRecurringPayments(recurringPaymentParams) {
991
+ return __async(this, null, function* () {
992
+ if (!this.signer) {
993
+ throw new Error("Signer is required for self custody payments.");
994
+ }
995
+ const {
996
+ signerAddress,
997
+ chainId,
998
+ token: tokenSymbol,
999
+ amount,
1000
+ receiver,
1001
+ count,
1002
+ intervalUnit,
1003
+ allowMaxTokenApproval,
1004
+ feebps,
1005
+ feeInclusive,
1006
+ publicClient,
1007
+ walletClient
1008
+ } = recurringPaymentParams;
1009
+ if (amount <= BigInt(0)) {
1010
+ throw new Error("Amount must be greater than 0.");
1011
+ }
1012
+ if (!signerAddress) {
1013
+ throw new Error("Signer Connot be empty");
1014
+ }
1015
+ if (receiver === signerAddress) {
1016
+ throw new Error("Receiver cannot be the same as the signer.");
1017
+ }
1018
+ if (!intervalUnit) {
1019
+ throw new Error("Interval unit is required.");
1020
+ }
1021
+ const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
1022
+ if (!token2) {
1023
+ throw new Error("Token not found.");
1024
+ }
1025
+ const kernelVersion = KERNEL_V3_1;
1026
+ const entryPoint = getEntryPoint("0.7");
1027
+ const paymentCount = count != null ? count : 24;
1028
+ const account = yield this.createAccount();
1029
+ const smartAccountAddress = account.address;
1030
+ const viemClient = new ViemClient(walletClient, publicClient);
1031
+ const ecdsaValidator = yield signerToEcdsaValidator(this.publicClient, {
1032
+ entryPoint,
1033
+ kernelVersion,
1034
+ signer: this.signer
1035
+ });
1036
+ const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
1037
+ const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
1038
+ const emptySessionKeySigner = yield toECDSASigner({ signer: emptyAccount });
1039
+ const { feeExclusiveAmountInToken, estimatedGasCostInToken } = yield this.estimateSinglePaymentGas({
1040
+ signerAddress,
1041
+ chainId,
1042
+ token: tokenSymbol,
1043
+ amount,
1044
+ receiver,
1045
+ feebps,
1046
+ publicClient,
1047
+ walletClient
1048
+ });
1049
+ const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
1050
+ yield viemClient.checkAndApproveToken(
1051
+ token2,
1052
+ smartAccountAddress,
1053
+ amountToTransfer * BigInt(paymentCount) + estimatedGasCostInToken * BigInt(2) * BigInt(paymentCount),
1054
+ allowMaxTokenApproval != null ? allowMaxTokenApproval : false
1055
+ );
1056
+ const amountExclusive = amountToTransfer + amountToTransfer / BigInt(2);
1057
+ const callPolicy = toCallPolicy({
1058
+ policyVersion: CallPolicyVersion.V0_0_4,
1059
+ permissions: [
1060
+ {
1061
+ target: token2.address,
1062
+ valueLimit: BigInt(0),
1063
+ abi: parseAbi2(["function transferFrom(address,address,uint)"]),
1064
+ functionName: "transferFrom",
1065
+ args: [
1066
+ {
1067
+ condition: ParamCondition.EQUAL,
1068
+ value: getAddress2(signerAddress)
1069
+ },
1070
+ {
1071
+ condition: ParamCondition.ONE_OF,
1072
+ value: [
1073
+ "0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
1074
+ getAddress2(receiver)
1075
+ ]
1076
+ },
1077
+ {
1078
+ condition: ParamCondition.LESS_THAN_OR_EQUAL,
1079
+ value: amountExclusive
1080
+ }
1081
+ ]
1082
+ }
1083
+ ]
1084
+ });
1085
+ const permissionPlugin = yield toPermissionValidator(this.publicClient, {
1086
+ entryPoint,
1087
+ kernelVersion,
1088
+ signer: emptySessionKeySigner,
1089
+ policies: [callPolicy]
1090
+ });
1091
+ const serializedSessionKeyAccount = yield createKernelAccount(
1092
+ this.publicClient,
1093
+ {
1094
+ entryPoint,
1095
+ kernelVersion,
1096
+ plugins: {
1097
+ sudo: ecdsaValidator,
1098
+ regular: permissionPlugin
1099
+ }
1100
+ }
1101
+ );
1102
+ const approval = yield serializePermissionAccount(
1103
+ serializedSessionKeyAccount
1104
+ );
1105
+ return { approval, amountExclusive };
1106
+ });
1107
+ }
1108
+ };
1109
+
1110
+ // src/api.ts
1111
+ var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
1112
+ HttpMethod2["GET"] = "GET";
1113
+ HttpMethod2["POST"] = "POST";
1114
+ HttpMethod2["DELETE"] = "DELETE";
1115
+ HttpMethod2["PUT"] = "PUT";
1116
+ HttpMethod2["PATCH"] = "PATCH";
1117
+ return HttpMethod2;
1118
+ })(HttpMethod || {});
1119
+ function sendRequest(_0) {
1120
+ return __async(this, arguments, function* ({
1121
+ url,
1122
+ method,
1123
+ body,
1124
+ headers = {}
1125
+ }) {
1126
+ var _a, _b, _c, _d;
1127
+ try {
1128
+ const isGet = method === "GET" /* GET */;
1129
+ const response = yield fetch(url, {
1130
+ method,
1131
+ headers: __spreadValues({
1132
+ Accept: "application/json",
1133
+ "Content-Type": "application/json"
1134
+ }, headers),
1135
+ body: isGet ? void 0 : JSON.stringify(body)
1136
+ });
1137
+ const contentType = (_a = response.headers.get("content-type")) != null ? _a : "";
1138
+ let result = null;
1139
+ if (contentType.includes("application/json")) {
1140
+ result = yield response.json().catch(() => null);
1141
+ }
1142
+ if (!response.ok) {
1143
+ return {
1144
+ error: {
1145
+ code: response.status,
1146
+ message: (_b = result == null ? void 0 : result.error) != null ? _b : response.statusText
1147
+ },
1148
+ status: response.status
1149
+ };
1150
+ }
1151
+ return {
1152
+ data: (_c = result == null ? void 0 : result.data) != null ? _c : result,
1153
+ message: (_d = result == null ? void 0 : result.message) != null ? _d : "Success",
1154
+ status: response.status
1155
+ };
1156
+ } catch (err) {
1157
+ return {
1158
+ error: {
1159
+ code: 0,
1160
+ message: err instanceof Error ? err.message : "Network error or unexpected failure"
1161
+ },
1162
+ status: 0
1163
+ };
1164
+ }
1165
+ });
1166
+ }
1167
+ function scheduleRecurringPaymentsAPICall(url, params) {
1168
+ return __async(this, null, function* () {
1169
+ const parsedParams = __spreadProps(__spreadValues({}, params), {
1170
+ amount: params.amount,
1171
+ amountExclusive: params.amountExclusive
1172
+ });
1173
+ const response = yield sendRequest({
1174
+ url,
1175
+ method: "POST" /* POST */,
1176
+ body: { paymentParams: parsedParams }
1177
+ });
1178
+ return response.data;
1179
+ });
1180
+ }
1181
+ function executeSinglePaymentAPICall(url, userOperation, paymentParams) {
1182
+ return __async(this, null, function* () {
1183
+ const params = {
1184
+ userOperation,
1185
+ paymentParams
1186
+ };
1187
+ const response = yield sendRequest({
1188
+ url,
1189
+ method: "POST" /* POST */,
1190
+ body: params
1191
+ });
1192
+ return response.data;
1193
+ });
1194
+ }
1195
+ function fetchRecurringTransactionWithId(url) {
1196
+ return __async(this, null, function* () {
1197
+ const response = yield sendRequest({ url, method: "GET" /* GET */ });
1198
+ return response.data;
1199
+ });
1200
+ }
1201
+ function fetchPaymentStatus(url, id) {
1202
+ return __async(this, null, function* () {
1203
+ const response = yield sendRequest({
1204
+ url: `${url}?id=${encodeURIComponent(id)}`,
1205
+ method: "GET" /* GET */
1206
+ });
1207
+ return response.data;
1208
+ });
1209
+ }
1210
+ function waitForPaymentStatus(url, id, intervalMs = 2e3) {
1211
+ return __async(this, null, function* () {
1212
+ return new Promise((resolve, reject) => __async(null, null, function* () {
1213
+ const poll = () => __async(null, null, function* () {
1214
+ try {
1215
+ const status = yield fetchPaymentStatus(url, id);
1216
+ if (status == null ? void 0 : status.error) {
1217
+ reject(new Error(status.error));
1218
+ return;
1219
+ }
1220
+ if ((status == null ? void 0 : status.status) === "success" || (status == null ? void 0 : status.status) === "failed" || (status == null ? void 0 : status.status) === "cancelled") {
1221
+ resolve(status);
1222
+ return;
1223
+ }
1224
+ if ((status == null ? void 0 : status.status) === "pending") {
1225
+ setTimeout(poll, intervalMs);
1226
+ } else {
1227
+ reject(new Error(`Unknown payment status: ${status == null ? void 0 : status.status}`));
1228
+ }
1229
+ } catch (error) {
1230
+ reject(
1231
+ error instanceof Error ? error : new Error("Unknown error occurred")
1232
+ );
1233
+ }
1234
+ });
1235
+ poll();
1236
+ }));
1237
+ });
1238
+ }
1239
+
1240
+ // src/execution/access.ts
1241
+ import { toHex } from "viem";
1242
+
1243
+ // src/constants.ts
1244
+ var ACCESS_URL = "https://api.acta.link/deposit";
1245
+
1246
+ // src/execution/access.ts
1247
+ var getPeriodInterval = (periodUnit) => {
1248
+ switch (periodUnit) {
1249
+ case "5mins":
1250
+ return 5 * 60;
1251
+ case "day":
1252
+ return 24 * 60 * 60;
1253
+ case "week":
1254
+ return 7 * 24 * 60 * 60;
1255
+ case "month":
1256
+ return 28 * 24 * 60 * 60;
1257
+ case "year":
1258
+ return 365 * 24 * 60 * 60;
1259
+ default:
1260
+ throw new Error("Invalid period unit");
1261
+ }
1262
+ };
1263
+ function estimateSinglePaymentGasInternal(parameters) {
1264
+ return __async(this, null, function* () {
1265
+ const { publicClient, walletClient } = parameters;
1266
+ const accountInstance = new ActaAccount(publicClient, walletClient);
1267
+ const {
1268
+ estimatedGasCostInToken,
1269
+ ActalinkFeesInToken,
1270
+ feeInclusiveAmountInToken,
1271
+ feeExclusiveAmountInToken,
1272
+ estimatedTotalFeesInToken,
1273
+ paymaster,
1274
+ userOperation
1275
+ } = yield accountInstance.estimateSinglePaymentGas(parameters);
1276
+ return {
1277
+ estimatedGasCostInToken,
1278
+ ActalinkFeesInToken,
1279
+ feeInclusiveAmountInToken,
1280
+ feeExclusiveAmountInToken,
1281
+ estimatedTotalFeesInToken,
1282
+ paymaster,
1283
+ userOperation
1284
+ };
1285
+ });
1286
+ }
1287
+ function createOnetimePaymentInternal(parameters) {
1288
+ return __async(this, null, function* () {
1289
+ const {
1290
+ signerAddress,
1291
+ receiver,
1292
+ amount,
1293
+ token: tokenSymbol,
1294
+ chainId,
1295
+ feebps,
1296
+ publicClient,
1297
+ walletClient,
1298
+ allowMaxTokenApproval,
1299
+ projectId
1300
+ } = parameters;
1301
+ const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
1302
+ if (!token2) {
1303
+ throw new Error("Token not supported.");
1304
+ }
1305
+ const accountInstance = new ActaAccount(publicClient, walletClient);
1306
+ const rpcParameters = yield accountInstance.signSinglePaymentOperation({
1307
+ signerAddress,
1308
+ chainId,
1309
+ token: tokenSymbol,
1310
+ amount,
1311
+ receiver,
1312
+ feeInclusive: false,
1313
+ allowMaxTokenApproval,
1314
+ feebps,
1315
+ publicClient,
1316
+ walletClient
1317
+ });
1318
+ const data = yield executeSinglePaymentAPICall(
1319
+ `${ACCESS_URL}/api/v1/execute/single`,
1320
+ rpcParameters,
1321
+ {
1322
+ amount: toHex(amount),
1323
+ chainId,
1324
+ feeInclusive: false,
1325
+ projectId,
1326
+ receiver,
1327
+ signerAddress,
1328
+ token: token2.address
1329
+ }
1330
+ );
1331
+ return data.id;
1332
+ });
1333
+ }
1334
+ function createRecurringePaymentInternal(parameters) {
1335
+ return __async(this, null, function* () {
1336
+ const {
1337
+ signerAddress,
1338
+ receiver,
1339
+ amount,
1340
+ token: tokenSymbol,
1341
+ chainId,
1342
+ feebps,
1343
+ publicClient,
1344
+ walletClient,
1345
+ allowMaxTokenApproval,
1346
+ count,
1347
+ intervalUnit,
1348
+ projectId
1349
+ } = parameters;
1350
+ const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
1351
+ if (!token2) {
1352
+ throw new Error("Token not supported.");
1353
+ }
1354
+ const accountInstance = new ActaAccount(publicClient, walletClient);
1355
+ const { approval, amountExclusive } = yield accountInstance.signRecurringPayments({
1356
+ signerAddress,
1357
+ chainId,
1358
+ token: tokenSymbol,
1359
+ amount,
1360
+ receiver,
1361
+ feeInclusive: false,
1362
+ allowMaxTokenApproval,
1363
+ feebps,
1364
+ publicClient,
1365
+ walletClient,
1366
+ count,
1367
+ intervalUnit
1368
+ });
1369
+ const startAt = Math.floor(Date.now() / 1e3) + 2 * 60;
1370
+ const data = yield scheduleRecurringPaymentsAPICall(
1371
+ `${ACCESS_URL}/api/v1/schedule/recurring`,
1372
+ {
1373
+ senderAddress: signerAddress,
1374
+ receiverAddress: receiver,
1375
+ chainId,
1376
+ amount: toHex(amount),
1377
+ amountExclusive: toHex(amountExclusive),
1378
+ approval,
1379
+ feeInclusive: false,
1380
+ tokenAddress: token2.address,
1381
+ intervalUnit,
1382
+ intervalCount: count,
1383
+ startAt,
1384
+ endAt: startAt + getPeriodInterval(intervalUnit) * count,
1385
+ projectId
1386
+ }
1387
+ );
1388
+ return data.id;
1389
+ });
1390
+ }
1391
+
1392
+ // src/access.ts
1393
+ var ActaAccessSDK = class {
1394
+ constructor(parameters) {
1395
+ this.projectId = parameters.projectId;
1396
+ }
1397
+ estimateSinglePaymentGasInToken(parameters) {
1398
+ return __async(this, null, function* () {
1399
+ try {
1400
+ const result = EstimateSinglePaymentGasSchema.parse(parameters);
1401
+ const { estimatedTotalFeesInToken } = yield estimateSinglePaymentGasInternal(__spreadProps(__spreadValues({}, result), { feebps: 10 }));
1402
+ return estimatedTotalFeesInToken;
1403
+ } catch (error) {
1404
+ if (error instanceof Error) {
1405
+ throw new Error(error.message);
1406
+ }
1407
+ throw new Error("Failed to estimate single payment gas.");
1408
+ }
1409
+ });
1410
+ }
1411
+ createOnetimePayment(parameters) {
1412
+ return __async(this, null, function* () {
1413
+ try {
1414
+ const result = CreateSinglePaymentSchema.parse(parameters);
1415
+ const id = yield createOnetimePaymentInternal(__spreadProps(__spreadValues({}, result), {
1416
+ feebps: 10,
1417
+ projectId: this.projectId
1418
+ }));
1419
+ return id;
1420
+ } catch (error) {
1421
+ if (error instanceof Error) {
1422
+ throw new Error(error.message);
1423
+ }
1424
+ throw new Error("Failed to create onetime payment");
1425
+ }
1426
+ });
1427
+ }
1428
+ createRecurringPayment(parameters) {
1429
+ return __async(this, null, function* () {
1430
+ try {
1431
+ const result = CreateRecurringPaymentSchema.parse(parameters);
1432
+ const id = yield createRecurringePaymentInternal(__spreadProps(__spreadValues({}, result), {
1433
+ feebps: 10,
1434
+ projectId: this.projectId
1435
+ }));
1436
+ return id;
1437
+ } catch (error) {
1438
+ if (error instanceof Error) {
1439
+ throw new Error(error.message);
1440
+ }
1441
+ throw new Error("Failed to create onetime payment");
1442
+ }
1443
+ });
1444
+ }
1445
+ waitForPaymentStatus(id, intervalMs = 2e3) {
1446
+ return __async(this, null, function* () {
1447
+ try {
1448
+ const result = PollPaymentStatusSchema.parse({ id });
1449
+ return yield waitForPaymentStatus(
1450
+ `${ACCESS_URL}/api/v1/payment/status`,
1451
+ result.id,
1452
+ intervalMs
1453
+ );
1454
+ } catch (error) {
1455
+ if (error instanceof Error) {
1456
+ throw new Error(error.message);
1457
+ }
1458
+ throw new Error("Failed to wait for payment status");
1459
+ }
1460
+ });
1461
+ }
1462
+ };
1463
+ export {
1464
+ ActaAccessSDK,
1465
+ ActaAccount,
1466
+ HttpMethod,
1467
+ ViemClient,
1468
+ arbitrumDAI,
1469
+ arbitrumETH,
1470
+ arbitrumUSDC,
1471
+ arbitrumUSDCe,
1472
+ arbitrumUSDT,
1473
+ arbitrumWETH,
1474
+ baseDAI,
1475
+ baseETH,
1476
+ baseEURC,
1477
+ baseSepoliaUSDC,
1478
+ baseUSDC,
1479
+ baseUSDT,
1480
+ baseUSDbC,
1481
+ baseWETH,
1482
+ bscBNB,
1483
+ bscUSDC,
1484
+ bscUSDT,
1485
+ bscWBNB,
1486
+ ethereumDAI,
1487
+ ethereumETH,
1488
+ ethereumEURC,
1489
+ ethereumUSDC,
1490
+ ethereumUSDT,
1491
+ ethereumWETH,
1492
+ executeSinglePaymentAPICall,
1493
+ fetchPaymentStatus,
1494
+ fetchRecurringTransactionWithId,
1495
+ getChainById,
1496
+ getChainExplorerByChainId,
1497
+ getPimlicoRpcByChainId,
1498
+ getTokenByChainIdAndAddress,
1499
+ getTokenByChainIdAndSymbol,
1500
+ lineaDAI,
1501
+ lineaETH,
1502
+ lineaUSDC,
1503
+ lineaWETH,
1504
+ mainnetChains,
1505
+ optimismDAI,
1506
+ optimismETH,
1507
+ optimismUSDC,
1508
+ optimismUSDCe,
1509
+ optimismUSDT,
1510
+ optimismWETH,
1511
+ polygonAmoyUSDC,
1512
+ polygonDAI,
1513
+ polygonPOL,
1514
+ polygonUSDC,
1515
+ polygonUSDCe,
1516
+ polygonUSDT,
1517
+ polygonWETH,
1518
+ polygonWPOL,
1519
+ scheduleRecurringPaymentsAPICall,
1520
+ sendRequest,
1521
+ sepoliaUSDC,
1522
+ supportedChains,
1523
+ supportedTokensByChain,
1524
+ testnetChains,
1525
+ token,
1526
+ tokensCommonSymbols,
1527
+ waitForPaymentStatus
1528
+ };