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