@actalink/commonlib 0.0.2 → 0.0.4

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 CHANGED
@@ -86,14 +86,14 @@ function getChainExplorerByChainId(chainId) {
86
86
 
87
87
  // src/types.ts
88
88
  var TokenLogo = /* @__PURE__ */ ((TokenLogo2) => {
89
- TokenLogo2["ETH"] = "https://pay.daimo.com/chain-logos/ethereum.png";
90
- TokenLogo2["WETH"] = "https://pay.daimo.com/coin-logos/weth.png";
91
- TokenLogo2["USDC"] = "https://pay.daimo.com/coin-logos/usdc.png";
92
- TokenLogo2["EURC"] = "https://pay.daimo.com/coin-logos/eurc.png";
93
- TokenLogo2["USDT"] = "https://pay.daimo.com/coin-logos/usdt.png";
94
- TokenLogo2["DAI"] = "https://pay.daimo.com/coin-logos/dai.png";
95
- TokenLogo2["POL"] = "https://pay.daimo.com/coin-logos/pol.png";
96
- TokenLogo2["BNB"] = "https://pay.daimo.com/coin-logos/bnb.png";
89
+ TokenLogo2["ETH"] = "https://api.acta.link/deposit/v1/logos/ethereum.png";
90
+ TokenLogo2["WETH"] = "https://api.acta.link/deposit/v1/logos/weth.png";
91
+ TokenLogo2["USDC"] = "https://api.acta.link/deposit/v1/logos/usdc.png";
92
+ TokenLogo2["EURC"] = "https://api.acta.link/deposit/v1/logos/eurc.png";
93
+ TokenLogo2["USDT"] = "https://api.acta.link/deposit/v1/logos/usdt.png";
94
+ TokenLogo2["DAI"] = "https://api.acta.link/deposit/v1/logos/dai.png";
95
+ TokenLogo2["POL"] = "https://api.acta.link/deposit/v1/logos/pol.png";
96
+ TokenLogo2["BNB"] = "https://api.acta.link/deposit/v1/logos/bnb.png";
97
97
  return TokenLogo2;
98
98
  })(TokenLogo || {});
99
99
  var ConnectorType = /* @__PURE__ */ ((ConnectorType2) => {
@@ -116,7 +116,7 @@ var arbitrumWETH = token({
116
116
  decimals: 18,
117
117
  name: "Wrapped Ether",
118
118
  symbol: "WETH",
119
- logoURI: "https://pay.daimo.com/coin-logos/weth.png" /* WETH */
119
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
120
120
  });
121
121
  var arbitrumUSDC = token({
122
122
  chainId: arbitrum2.id,
@@ -125,7 +125,7 @@ var arbitrumUSDC = token({
125
125
  symbol: "USDC",
126
126
  fiatISO: "USD",
127
127
  decimals: 6,
128
- logoURI: "https://pay.daimo.com/coin-logos/usdc.png" /* USDC */
128
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
129
129
  });
130
130
  var arbitrumDAI = token({
131
131
  chainId: arbitrum2.id,
@@ -134,7 +134,7 @@ var arbitrumDAI = token({
134
134
  fiatISO: "USD",
135
135
  name: "Dai Stablecoin",
136
136
  symbol: "DAI",
137
- logoURI: "https://pay.daimo.com/coin-logos/dai.png" /* DAI */
137
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
138
138
  });
139
139
  var arbitrumUSDT = token({
140
140
  chainId: arbitrum2.id,
@@ -143,7 +143,7 @@ var arbitrumUSDT = token({
143
143
  fiatISO: "USD",
144
144
  name: "Tether USD",
145
145
  symbol: "USDT",
146
- logoURI: "https://pay.daimo.com/coin-logos/usdt.png" /* USDT */
146
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
147
147
  });
148
148
  var arbitrumUSDCe = token({
149
149
  chainId: arbitrum2.id,
@@ -152,7 +152,7 @@ var arbitrumUSDCe = token({
152
152
  fiatISO: "USD",
153
153
  name: "Bridged USD Coin",
154
154
  symbol: "USDCe",
155
- logoURI: "https://pay.daimo.com/coin-logos/usdc.png" /* USDC */
155
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
156
156
  });
157
157
  var arbitrumTokens = [arbitrumUSDC, arbitrumUSDT];
158
158
  var baseETH = nativeETH(base2.id);
@@ -162,7 +162,7 @@ var baseWETH = token({
162
162
  decimals: 18,
163
163
  name: "Wrapped Ether",
164
164
  symbol: "WETH",
165
- logoURI: "https://pay.daimo.com/coin-logos/weth.png" /* WETH */
165
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
166
166
  });
167
167
  var baseUSDC = token({
168
168
  chainId: base2.id,
@@ -171,7 +171,7 @@ var baseUSDC = token({
171
171
  symbol: "USDC",
172
172
  fiatISO: "USD",
173
173
  decimals: 6,
174
- logoURI: "https://pay.daimo.com/coin-logos/usdc.png" /* USDC */
174
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
175
175
  });
176
176
  var baseEURC = token({
177
177
  chainId: base2.id,
@@ -180,7 +180,7 @@ var baseEURC = token({
180
180
  fiatISO: "EUR",
181
181
  name: "EURC",
182
182
  symbol: "EURC",
183
- logoURI: "https://pay.daimo.com/coin-logos/eurc.png" /* EURC */
183
+ logoURI: "https://api.acta.link/deposit/v1/logos/eurc.png" /* EURC */
184
184
  });
185
185
  var baseUSDbC = token({
186
186
  chainId: base2.id,
@@ -189,7 +189,7 @@ var baseUSDbC = token({
189
189
  symbol: "USDbC",
190
190
  fiatISO: "USD",
191
191
  decimals: 6,
192
- logoURI: "https://pay.daimo.com/coin-logos/usdbc.png"
192
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdbc.png"
193
193
  });
194
194
  var baseDAI = token({
195
195
  chainId: base2.id,
@@ -198,7 +198,7 @@ var baseDAI = token({
198
198
  symbol: "DAI",
199
199
  fiatISO: "USD",
200
200
  decimals: 18,
201
- logoURI: "https://pay.daimo.com/coin-logos/dai.png" /* DAI */
201
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
202
202
  });
203
203
  var baseUSDT = token({
204
204
  chainId: base2.id,
@@ -207,14 +207,14 @@ var baseUSDT = token({
207
207
  symbol: "USDT",
208
208
  fiatISO: "USD",
209
209
  decimals: 6,
210
- logoURI: "https://pay.daimo.com/coin-logos/usdt.png" /* USDT */
210
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
211
211
  });
212
212
  var baseTokens = [baseUSDC, baseUSDT];
213
213
  var bscBNB = nativeToken({
214
214
  chainId: bsc2.id,
215
215
  name: "BNB",
216
216
  symbol: "BNB",
217
- logoURI: "https://pay.daimo.com/coin-logos/bnb.png" /* BNB */
217
+ logoURI: "https://api.acta.link/deposit/v1/logos/bnb.png" /* BNB */
218
218
  });
219
219
  var bscWBNB = token({
220
220
  chainId: bsc2.id,
@@ -222,7 +222,7 @@ var bscWBNB = token({
222
222
  decimals: 18,
223
223
  name: "Wrapped BNB",
224
224
  symbol: "WBNB",
225
- logoURI: "https://pay.daimo.com/coin-logos/bnb.png" /* BNB */
225
+ logoURI: "https://api.acta.link/deposit/v1/logos/bnb.png" /* BNB */
226
226
  });
227
227
  var bscUSDC = token({
228
228
  chainId: bsc2.id,
@@ -231,7 +231,7 @@ var bscUSDC = token({
231
231
  fiatISO: "USD",
232
232
  name: "USD Coin",
233
233
  symbol: "USDC",
234
- logoURI: "https://pay.daimo.com/coin-logos/usdc.png" /* USDC */
234
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
235
235
  });
236
236
  var bscUSDT = token({
237
237
  chainId: bsc2.id,
@@ -240,7 +240,7 @@ var bscUSDT = token({
240
240
  fiatISO: "USD",
241
241
  name: "Tether USD",
242
242
  symbol: "USDT",
243
- logoURI: "https://pay.daimo.com/coin-logos/usdt.png" /* USDT */
243
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
244
244
  });
245
245
  var bscTokens = [bscUSDT];
246
246
  var ethereumETH = nativeETH(mainnet2.id);
@@ -250,7 +250,7 @@ var ethereumWETH = token({
250
250
  decimals: 18,
251
251
  name: "Wrapped Ether",
252
252
  symbol: "WETH",
253
- logoURI: "https://pay.daimo.com/coin-logos/weth.png" /* WETH */
253
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
254
254
  });
255
255
  var ethereumUSDC = token({
256
256
  chainId: mainnet2.id,
@@ -259,7 +259,7 @@ var ethereumUSDC = token({
259
259
  fiatISO: "USD",
260
260
  name: "USD Coin",
261
261
  symbol: "USDC",
262
- logoURI: "https://pay.daimo.com/coin-logos/usdc.png" /* USDC */
262
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
263
263
  });
264
264
  var ethereumDAI = token({
265
265
  chainId: mainnet2.id,
@@ -268,7 +268,7 @@ var ethereumDAI = token({
268
268
  fiatISO: "USD",
269
269
  name: "Dai Stablecoin",
270
270
  symbol: "DAI",
271
- logoURI: "https://pay.daimo.com/coin-logos/dai.png" /* DAI */
271
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
272
272
  });
273
273
  var ethereumUSDT = token({
274
274
  chainId: mainnet2.id,
@@ -277,7 +277,7 @@ var ethereumUSDT = token({
277
277
  fiatISO: "USD",
278
278
  name: "Tether USD",
279
279
  symbol: "USDT",
280
- logoURI: "https://pay.daimo.com/coin-logos/usdt.png" /* USDT */
280
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
281
281
  });
282
282
  var ethereumEURC = token({
283
283
  chainId: mainnet2.id,
@@ -286,7 +286,7 @@ var ethereumEURC = token({
286
286
  fiatISO: "EUR",
287
287
  name: "EURC",
288
288
  symbol: "EURC",
289
- logoURI: "https://pay.daimo.com/coin-logos/eurc.png" /* EURC */
289
+ logoURI: "https://api.acta.link/deposit/v1/logos/eurc.png" /* EURC */
290
290
  });
291
291
  var ethereumTokens = [ethereumUSDC, ethereumUSDT];
292
292
  var lineaETH = nativeETH(linea.id);
@@ -296,7 +296,7 @@ var lineaWETH = token({
296
296
  decimals: 18,
297
297
  name: "Wrapped Ether",
298
298
  symbol: "WETH",
299
- logoURI: "https://pay.daimo.com/coin-logos/weth.png" /* WETH */
299
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
300
300
  });
301
301
  var lineaUSDC = token({
302
302
  chainId: linea.id,
@@ -305,7 +305,7 @@ var lineaUSDC = token({
305
305
  fiatISO: "USD",
306
306
  name: "USD Coin",
307
307
  symbol: "USDC",
308
- logoURI: "https://pay.daimo.com/coin-logos/usdc.png" /* USDC */
308
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
309
309
  });
310
310
  var lineaDAI = token({
311
311
  chainId: linea.id,
@@ -314,7 +314,7 @@ var lineaDAI = token({
314
314
  fiatISO: "USD",
315
315
  name: "Dai Stablecoin",
316
316
  symbol: "DAI",
317
- logoURI: "https://pay.daimo.com/coin-logos/dai.png" /* DAI */
317
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
318
318
  });
319
319
  var optimismETH = nativeETH(optimism2.id);
320
320
  var optimismWETH = token({
@@ -323,7 +323,7 @@ var optimismWETH = token({
323
323
  decimals: 18,
324
324
  name: "Wrapped Ether",
325
325
  symbol: "WETH",
326
- logoURI: "https://pay.daimo.com/coin-logos/weth.png" /* WETH */
326
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
327
327
  });
328
328
  var optimismUSDC = token({
329
329
  chainId: optimism2.id,
@@ -332,7 +332,7 @@ var optimismUSDC = token({
332
332
  fiatISO: "USD",
333
333
  name: "USD Coin",
334
334
  symbol: "USDC",
335
- logoURI: "https://pay.daimo.com/coin-logos/usdc.png" /* USDC */
335
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
336
336
  });
337
337
  var optimismDAI = token({
338
338
  chainId: optimism2.id,
@@ -341,7 +341,7 @@ var optimismDAI = token({
341
341
  fiatISO: "USD",
342
342
  name: "Dai Stablecoin",
343
343
  symbol: "DAI",
344
- logoURI: "https://pay.daimo.com/coin-logos/dai.png" /* DAI */
344
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
345
345
  });
346
346
  var optimismUSDT = token({
347
347
  chainId: optimism2.id,
@@ -350,7 +350,7 @@ var optimismUSDT = token({
350
350
  fiatISO: "USD",
351
351
  name: "Tether USD",
352
352
  symbol: "USDT",
353
- logoURI: "https://pay.daimo.com/coin-logos/usdt.png" /* USDT */
353
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
354
354
  });
355
355
  var optimismUSDCe = token({
356
356
  chainId: optimism2.id,
@@ -359,14 +359,14 @@ var optimismUSDCe = token({
359
359
  fiatISO: "USD",
360
360
  name: "Bridged USD Coin",
361
361
  symbol: "USDCe",
362
- logoURI: "https://pay.daimo.com/coin-logos/usdc.png" /* USDC */
362
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
363
363
  });
364
364
  var optimismTokens = [optimismUSDC, optimismUSDT];
365
365
  var polygonPOL = nativeToken({
366
366
  chainId: polygon2.id,
367
367
  name: "Polygon",
368
368
  symbol: "POL",
369
- logoURI: "https://pay.daimo.com/coin-logos/pol.png" /* POL */
369
+ logoURI: "https://api.acta.link/deposit/v1/logos/pol.png" /* POL */
370
370
  });
371
371
  var polygonWPOL = token({
372
372
  chainId: polygon2.id,
@@ -374,7 +374,7 @@ var polygonWPOL = token({
374
374
  decimals: 18,
375
375
  name: "Wrapped Polygon",
376
376
  symbol: "WPOL",
377
- logoURI: "https://pay.daimo.com/coin-logos/pol.png" /* POL */
377
+ logoURI: "https://api.acta.link/deposit/v1/logos/pol.png" /* POL */
378
378
  });
379
379
  var polygonWETH = token({
380
380
  chainId: polygon2.id,
@@ -382,7 +382,7 @@ var polygonWETH = token({
382
382
  decimals: 18,
383
383
  name: "Wrapped Ether",
384
384
  symbol: "WETH",
385
- logoURI: "https://pay.daimo.com/coin-logos/weth.png" /* WETH */
385
+ logoURI: "https://api.acta.link/deposit/v1/logos/weth.png" /* WETH */
386
386
  });
387
387
  var polygonUSDC = token({
388
388
  chainId: polygon2.id,
@@ -391,7 +391,7 @@ var polygonUSDC = token({
391
391
  fiatISO: "USD",
392
392
  name: "USD Coin",
393
393
  symbol: "USDC",
394
- logoURI: "https://pay.daimo.com/coin-logos/usdc.png" /* USDC */
394
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
395
395
  });
396
396
  var polygonDAI = token({
397
397
  chainId: polygon2.id,
@@ -400,7 +400,7 @@ var polygonDAI = token({
400
400
  fiatISO: "USD",
401
401
  name: "Dai Stablecoin",
402
402
  symbol: "DAI",
403
- logoURI: "https://pay.daimo.com/coin-logos/dai.png" /* DAI */
403
+ logoURI: "https://api.acta.link/deposit/v1/logos/dai.png" /* DAI */
404
404
  });
405
405
  var polygonUSDT = token({
406
406
  chainId: polygon2.id,
@@ -409,7 +409,7 @@ var polygonUSDT = token({
409
409
  fiatISO: "USD",
410
410
  name: "Tether USD",
411
411
  symbol: "USDT",
412
- logoURI: "https://pay.daimo.com/coin-logos/usdt.png" /* USDT */
412
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
413
413
  });
414
414
  var polygonUSDCe = token({
415
415
  chainId: polygon2.id,
@@ -418,7 +418,7 @@ var polygonUSDCe = token({
418
418
  fiatISO: "USD",
419
419
  name: "USD Coin (PoS)",
420
420
  symbol: "USDCe",
421
- logoURI: "https://pay.daimo.com/coin-logos/usdc.png" /* USDC */
421
+ logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
422
422
  });
423
423
  var polygonTokens = [polygonUSDC, polygonUSDT];
424
424
  var supportedTokensByChain = /* @__PURE__ */ new Map([
@@ -440,7 +440,7 @@ function nativeETH(chainId) {
440
440
  chainId,
441
441
  name: "Ether",
442
442
  symbol: "ETH",
443
- logoURI: "https://pay.daimo.com/chain-logos/ethereum.png" /* ETH */
443
+ logoURI: "https://api.acta.link/deposit/v1/logos/ethereum.png" /* ETH */
444
444
  });
445
445
  }
446
446
  function nativeToken({
@@ -511,7 +511,8 @@ function getTokenByChainIdAndAddress(chainId, address) {
511
511
  const tokens = supportedTokensByChain.get(chain.id);
512
512
  if (!tokens) throw new Error(`Tokens not found for chain ${chainId}.`);
513
513
  const token2 = tokens.find((t) => t.address === address);
514
- if (!token2) throw new Error(`Token ${address} not found for chain ${chainId}.`);
514
+ if (!token2)
515
+ throw new Error(`Token ${address} not found for chain ${chainId}.`);
515
516
  return token2;
516
517
  }
517
518
 
@@ -524,7 +525,6 @@ import {
524
525
  getAddress as getAddress2,
525
526
  parseAbi as parseAbi2
526
527
  } from "viem";
527
- import { privateKeyToAccount as privateKeyToAccount2 } from "viem/accounts";
528
528
  import {
529
529
  createPaymasterClient,
530
530
  formatUserOperationRequest
@@ -583,7 +583,8 @@ import {
583
583
  http,
584
584
  createPublicClient,
585
585
  parseAbi,
586
- encodeFunctionData
586
+ encodeFunctionData,
587
+ maxUint256
587
588
  } from "viem";
588
589
  var ViemClient = class {
589
590
  constructor(chainId, walletClient) {
@@ -609,7 +610,7 @@ var ViemClient = class {
609
610
  return allowance;
610
611
  });
611
612
  }
612
- checkAndApproveToken(token2, spender, amount) {
613
+ checkAndApproveToken(token2, spender, amount, allowMaxTokenApproval) {
613
614
  return __async(this, null, function* () {
614
615
  var _a;
615
616
  if (this.walletClient === void 0) {
@@ -634,7 +635,7 @@ var ViemClient = class {
634
635
  data: encodeFunctionData({
635
636
  abi: parseAbi(["function approve(address,uint)"]),
636
637
  functionName: "approve",
637
- args: [spender, amount]
638
+ args: [spender, allowMaxTokenApproval ? maxUint256 : amount]
638
639
  })
639
640
  });
640
641
  const receipt = yield this.publicClient().waitForTransactionReceipt({
@@ -1142,28 +1143,17 @@ var ActaAccount = class {
1142
1143
  to: getAddress2(token2.address),
1143
1144
  abi: parseAbi2(["function transferFrom(address,address,uint)"]),
1144
1145
  functionName: "transferFrom",
1145
- args: [fromAddress, smartAccountAddress, BigInt(0)]
1146
- },
1147
- {
1148
- to: getAddress2(token2.address),
1149
- abi: parseAbi2(["function approve(address,uint)"]),
1150
- functionName: "approve",
1151
- args: [paymaster, BigInt(0)]
1152
- },
1153
- {
1154
- to: getAddress2(token2.address),
1155
- abi: parseAbi2(["function transfer(address,uint)"]),
1156
- functionName: "transfer",
1157
1146
  args: [
1147
+ fromAddress,
1158
1148
  "0x061BA68bc8208F4AddBeE86F74F17D77129cCF70",
1159
1149
  BigInt(0)
1160
1150
  ]
1161
1151
  },
1162
1152
  {
1163
1153
  to: getAddress2(token2.address),
1164
- abi: parseAbi2(["function transfer(address,uint)"]),
1165
- functionName: "transfer",
1166
- args: [receiver, BigInt(0)]
1154
+ abi: parseAbi2(["function transferFrom(address,address,uint)"]),
1155
+ functionName: "transferFrom",
1156
+ args: [fromAddress, receiver, BigInt(0)]
1167
1157
  }
1168
1158
  ]
1169
1159
  });
@@ -1199,7 +1189,8 @@ var ActaAccount = class {
1199
1189
  token: tokenSymbol,
1200
1190
  amount,
1201
1191
  receiver,
1202
- feeInclusive
1192
+ feeInclusive,
1193
+ allowMaxTokenApproval
1203
1194
  } = singlePaymentParams;
1204
1195
  if (amount <= BigInt(0)) {
1205
1196
  throw new Error("Amount must be greater than 0.");
@@ -1236,7 +1227,8 @@ var ActaAccount = class {
1236
1227
  yield viemClient.checkAndApproveToken(
1237
1228
  token2,
1238
1229
  smartAccountAddress,
1239
- amountToTransfer
1230
+ amountToTransfer,
1231
+ allowMaxTokenApproval != null ? allowMaxTokenApproval : false
1240
1232
  );
1241
1233
  const userOperation = yield accountClient.prepareUserOperation({
1242
1234
  calls: [
@@ -1244,33 +1236,19 @@ var ActaAccount = class {
1244
1236
  to: getAddress2(token2.address),
1245
1237
  abi: parseAbi2(["function transferFrom(address,address,uint)"]),
1246
1238
  functionName: "transferFrom",
1247
- args: [fromAddress, smartAccountAddress, amountToTransfer]
1248
- },
1249
- {
1250
- to: getAddress2(token2.address),
1251
- abi: parseAbi2(["function approve(address,uint)"]),
1252
- functionName: "approve",
1253
- args: [paymaster, estimatedGasCostInToken]
1254
- },
1255
- {
1256
- to: getAddress2(token2.address),
1257
- abi: parseAbi2(["function transfer(address,uint)"]),
1258
- functionName: "transfer",
1259
1239
  args: [
1240
+ fromAddress,
1260
1241
  "0x061BA68bc8208F4AddBeE86F74F17D77129cCF70",
1261
- ActalinkFeesInToken
1242
+ receiverAmount
1262
1243
  ]
1263
1244
  },
1264
1245
  {
1265
1246
  to: getAddress2(token2.address),
1266
- abi: parseAbi2(["function transfer(address,uint)"]),
1267
- functionName: "transfer",
1268
- args: [receiver, receiverAmount]
1247
+ abi: parseAbi2(["function transferFrom(address,address,uint)"]),
1248
+ functionName: "transferFrom",
1249
+ args: [fromAddress, receiver, estimatedTotalFeesInToken]
1269
1250
  }
1270
- ],
1271
- paymasterContext: {
1272
- token: token2.address
1273
- }
1251
+ ]
1274
1252
  });
1275
1253
  const signature = yield account.signUserOperation(__spreadProps(__spreadValues({}, userOperation), {
1276
1254
  chainId: this.chainId
@@ -1302,7 +1280,8 @@ var ActaAccount = class {
1302
1280
  count,
1303
1281
  intervalUnit,
1304
1282
  startDate,
1305
- endDate
1283
+ endDate,
1284
+ allowMaxTokenApproval
1306
1285
  } = recurringPaymentParams;
1307
1286
  if (amount <= BigInt(0)) {
1308
1287
  throw new Error("Amount must be greater than 0.");
@@ -1324,11 +1303,6 @@ var ActaAccount = class {
1324
1303
  const smartAccountAddress = account.address;
1325
1304
  const viemClient = new ViemClient(this.chainId, this.signer);
1326
1305
  const { paymasterClient, pimlicoClient } = yield this.createAccountHelpers();
1327
- const sessionKeySigner = yield toECDSASigner(
1328
- privateKeyToAccount2(
1329
- "0x8519baaeb81ebbcf3597d93c2f9790d1eda37097121e844e1b88c1ab77b67ae2"
1330
- )
1331
- );
1332
1306
  const ecdsaValidator = yield signerToEcdsaValidator(
1333
1307
  viemClient.publicClient(),
1334
1308
  {
@@ -1337,7 +1311,7 @@ var ActaAccount = class {
1337
1311
  signer: this.signer
1338
1312
  }
1339
1313
  );
1340
- const sessionKeyAddress = "0x0744F720fe178AC21F25a30263B6269a1C0bB106";
1314
+ const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
1341
1315
  const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
1342
1316
  const emptySessionKeySigner = yield toECDSASigner(emptyAccount);
1343
1317
  const {
@@ -1361,7 +1335,8 @@ var ActaAccount = class {
1361
1335
  yield viemClient.checkAndApproveToken(
1362
1336
  token2,
1363
1337
  smartAccountAddress,
1364
- amountToTransfer * BigInt(paymentCount) + estimatedGasCostInToken * BigInt(2) * BigInt(paymentCount)
1338
+ amountToTransfer * BigInt(paymentCount) + estimatedGasCostInToken * BigInt(2) * BigInt(paymentCount),
1339
+ allowMaxTokenApproval != null ? allowMaxTokenApproval : false
1365
1340
  );
1366
1341
  const callPolicy = toCallPolicy2({
1367
1342
  policyVersion: CallPolicyVersion.V0_0_4,
@@ -1376,45 +1351,13 @@ var ActaAccount = class {
1376
1351
  condition: ParamCondition.EQUAL,
1377
1352
  value: signerAddress
1378
1353
  },
1379
- {
1380
- condition: ParamCondition.EQUAL,
1381
- value: smartAccountAddress
1382
- },
1383
- {
1384
- condition: ParamCondition.GREATER_THAN_OR_EQUAL,
1385
- value: 0
1386
- }
1387
- ]
1388
- },
1389
- {
1390
- target: token2.address,
1391
- valueLimit: BigInt(0),
1392
- abi: parseAbi2(["function approve(address,uint)"]),
1393
- functionName: "approve",
1394
- args: [
1395
- {
1396
- condition: ParamCondition.EQUAL,
1397
- value: paymaster
1398
- },
1399
- {
1400
- condition: ParamCondition.GREATER_THAN_OR_EQUAL,
1401
- value: 0
1402
- }
1403
- ]
1404
- },
1405
- {
1406
- target: token2.address,
1407
- valueLimit: BigInt(0),
1408
- abi: parseAbi2(["function transfer(address,uint)"]),
1409
- functionName: "transfer",
1410
- args: [
1411
1354
  {
1412
1355
  condition: ParamCondition.ONE_OF,
1413
- value: ["0xbDCBee616C26D5282227a672C3d0B87EA477A3fe", receiver]
1356
+ value: ["0x061BA68bc8208F4AddBeE86F74F17D77129cCF70", receiver]
1414
1357
  },
1415
1358
  {
1416
- condition: ParamCondition.GREATER_THAN_OR_EQUAL,
1417
- value: 0
1359
+ condition: ParamCondition.LESS_THAN_OR_EQUAL,
1360
+ value: amountToTransfer + amountToTransfer / BigInt(2)
1418
1361
  }
1419
1362
  ]
1420
1363
  }
@@ -1574,7 +1517,8 @@ var ActaDeposit = class {
1574
1517
  this.depositSessionId = "";
1575
1518
  this.status = "not_started";
1576
1519
  this.serviceType = "deposit";
1577
- var _a;
1520
+ this.allowMaxTokenApproval = false;
1521
+ var _a, _b;
1578
1522
  this.connectorType = parameters.connectorType;
1579
1523
  this.walletClient = parameters.walletClient;
1580
1524
  this.signerAddress = parameters.signerAddress;
@@ -1589,6 +1533,7 @@ var ActaDeposit = class {
1589
1533
  this.startDate = parameters.startDate;
1590
1534
  this.endDate = parameters.endDate;
1591
1535
  this.depositSessionId = (_a = parameters.depositSessionId) != null ? _a : "";
1536
+ this.allowMaxTokenApproval = (_b = parameters.allowMaxTokenApproval) != null ? _b : false;
1592
1537
  this.viemClient = new ViemClient(this.chainId, this.walletClient);
1593
1538
  this.account = new ActaAccount(
1594
1539
  this.chainId,
@@ -1752,7 +1697,8 @@ var ActaDeposit = class {
1752
1697
  token: tokenSymbol,
1753
1698
  amount,
1754
1699
  receiver,
1755
- feeInclusive
1700
+ feeInclusive,
1701
+ allowMaxTokenApproval: this.allowMaxTokenApproval
1756
1702
  });
1757
1703
  const txn = yield executeSinglePaymentAPICall(
1758
1704
  `${transactionServiceUrl}execute/single`,
@@ -1844,7 +1790,8 @@ var ActaDeposit = class {
1844
1790
  intervalUnit,
1845
1791
  startDate,
1846
1792
  endDate,
1847
- receiver
1793
+ receiver,
1794
+ allowMaxTokenApproval: this.allowMaxTokenApproval
1848
1795
  });
1849
1796
  const txn = yield scheduleRecurringPaymentsAPICall(
1850
1797
  `${transactionServiceUrl}schedule/recurring`,
@@ -1867,6 +1814,38 @@ var ActaDeposit = class {
1867
1814
  return txn.recurringTransaction.id;
1868
1815
  });
1869
1816
  }
1817
+ getPaymentSteps() {
1818
+ return __async(this, null, function* () {
1819
+ const signerAddress = this.signerAddress;
1820
+ const chainId = this.chainId;
1821
+ const tokenSymbol = this.token;
1822
+ const amount = this.amount;
1823
+ const receiver = this.receiver;
1824
+ const feeInclusive = this.feeInclusive;
1825
+ const count = this.count;
1826
+ if (!signerAddress) return ["allowance", "confirm"];
1827
+ const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
1828
+ if (!token2) return ["allowance", "confirm"];
1829
+ const smartAccount = yield this.account.createAccount();
1830
+ const { estimatedGasCostInToken, feeExclusiveAmountInToken } = yield this.account.estimateSinglePaymentGas({
1831
+ chainId,
1832
+ amount,
1833
+ feeInclusive,
1834
+ receiver,
1835
+ signerAddress,
1836
+ token: tokenSymbol
1837
+ });
1838
+ const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
1839
+ let paymentAmount = (amountToTransfer + estimatedGasCostInToken * BigInt(2)) * BigInt(count != null ? count : 1);
1840
+ const allowance = yield this.viemClient.checkTokenAllowance(
1841
+ token2,
1842
+ signerAddress,
1843
+ smartAccount.address
1844
+ );
1845
+ if (paymentAmount <= allowance) return ["confirm"];
1846
+ return ["allowance", "confirm"];
1847
+ });
1848
+ }
1870
1849
  };
1871
1850
  export {
1872
1851
  ActaAccount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actalink/commonlib",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "author": "Actalink",
5
5
  "license": "MIT license",
6
6
  "publishConfig": {