@actalink/commonlib 0.0.16 → 0.0.18

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 CHANGED
@@ -1192,7 +1192,7 @@ var ActaAccount = class {
1192
1192
  args: [
1193
1193
  fromAddress,
1194
1194
  "0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
1195
- estimatedGasCostInToken
1195
+ estimatedTotalFeesInToken
1196
1196
  ]
1197
1197
  }
1198
1198
  ]
@@ -2382,12 +2382,16 @@ var returnEnvUrl = (chainId) => {
2382
2382
  };
2383
2383
  var ActaBatch = class {
2384
2384
  constructor(parameters) {
2385
- this.APIkey = parameters.APIKey;
2385
+ var _a;
2386
+ this.APIkey = (_a = parameters.APIKey) != null ? _a : void 0;
2386
2387
  }
2387
2388
  createSession(params) {
2388
2389
  return __async(this, null, function* () {
2389
2390
  try {
2390
2391
  const { instructionId, name, signerAddress, token: token2, chainId } = params;
2392
+ if (!this.APIkey) {
2393
+ throw new Error("No API key provided.");
2394
+ }
2391
2395
  if (!signerAddress || signerAddress === import_viem7.zeroAddress) {
2392
2396
  throw new Error("Signer address is required.");
2393
2397
  }
@@ -2434,6 +2438,9 @@ var ActaBatch = class {
2434
2438
  walletClient,
2435
2439
  instructionId
2436
2440
  } = parameters;
2441
+ if (!this.APIkey) {
2442
+ throw new Error("No API key provided.");
2443
+ }
2437
2444
  let isFeeInclusive = false;
2438
2445
  if (feeInclusive) {
2439
2446
  isFeeInclusive = true;
@@ -2517,6 +2524,9 @@ var ActaBatch = class {
2517
2524
  allowMaxTokenApproval,
2518
2525
  instructionId
2519
2526
  } = params;
2527
+ if (!this.APIkey) {
2528
+ throw new Error("No API key provided.");
2529
+ }
2520
2530
  let isFeeInclusive = false;
2521
2531
  if (feeInclusive) {
2522
2532
  isFeeInclusive = true;
@@ -2603,6 +2613,9 @@ var ActaBatch = class {
2603
2613
  instructionId,
2604
2614
  executionTime
2605
2615
  } = params;
2616
+ if (!this.APIkey) {
2617
+ throw new Error("No API key provided.");
2618
+ }
2606
2619
  let isFeeInclusive = false;
2607
2620
  if (feeInclusive) {
2608
2621
  isFeeInclusive = true;
@@ -2687,6 +2700,125 @@ var ActaBatch = class {
2687
2700
  }
2688
2701
  });
2689
2702
  }
2703
+ createSingleBatchPaymentWithoutKey(params, serviceParams) {
2704
+ return __async(this, null, function* () {
2705
+ try {
2706
+ const {
2707
+ chainId,
2708
+ feeInclusive,
2709
+ signerAddress,
2710
+ token: tokenSymbol,
2711
+ walletClient,
2712
+ allowMaxTokenApproval,
2713
+ receivers,
2714
+ totalAmount
2715
+ } = params;
2716
+ let isFeeInclusive = false;
2717
+ if (feeInclusive) {
2718
+ isFeeInclusive = true;
2719
+ }
2720
+ const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
2721
+ if (!tokenData) {
2722
+ throw new Error("Token not supported");
2723
+ }
2724
+ const viemClient = new ViemClient(chainId, walletClient);
2725
+ const account = new ActaAccount(
2726
+ chainId,
2727
+ viemClient.publicClient(),
2728
+ walletClient
2729
+ );
2730
+ console.log("signing");
2731
+ const rpcParameters = yield account.signSingleBatchOperation({
2732
+ signerAddress,
2733
+ chainId,
2734
+ token: tokenSymbol,
2735
+ feeInclusive: isFeeInclusive,
2736
+ receivers,
2737
+ totalAmount,
2738
+ walletClient,
2739
+ allowMaxTokenApproval,
2740
+ feebps: 20
2741
+ });
2742
+ return {
2743
+ senderAddress: signerAddress,
2744
+ chainId,
2745
+ tokenAddress: tokenData.address,
2746
+ amount: (0, import_viem7.toHex)(totalAmount),
2747
+ feeInclusive: isFeeInclusive,
2748
+ serviceType: "batch",
2749
+ sessionId: serviceParams.sessionId,
2750
+ rpcParameters
2751
+ };
2752
+ } catch (error) {
2753
+ if (error instanceof Error) {
2754
+ throw new Error(error.message);
2755
+ }
2756
+ throw new Error("Failed to create payment.");
2757
+ }
2758
+ });
2759
+ }
2760
+ createScheduleBatchPaymentWithoutKey(params, serviceParams) {
2761
+ return __async(this, null, function* () {
2762
+ try {
2763
+ const {
2764
+ chainId,
2765
+ feeInclusive,
2766
+ signerAddress,
2767
+ token: tokenSymbol,
2768
+ walletClient,
2769
+ allowMaxTokenApproval,
2770
+ executionTime,
2771
+ receivers,
2772
+ totalAmount
2773
+ } = params;
2774
+ let isFeeInclusive = false;
2775
+ if (feeInclusive) {
2776
+ isFeeInclusive = true;
2777
+ }
2778
+ const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
2779
+ if (!tokenData) {
2780
+ throw new Error("Token not supported");
2781
+ }
2782
+ const viemClient = new ViemClient(chainId, walletClient);
2783
+ const account = new ActaAccount(
2784
+ chainId,
2785
+ viemClient.publicClient(),
2786
+ walletClient
2787
+ );
2788
+ console.log("signing");
2789
+ const { amountExclusive, approval } = yield account.signRecurringOrScheduleBatchPayments({
2790
+ signerAddress,
2791
+ chainId,
2792
+ token: tokenSymbol,
2793
+ feeInclusive: isFeeInclusive,
2794
+ receivers,
2795
+ totalAmount,
2796
+ walletClient,
2797
+ allowMaxTokenApproval,
2798
+ count: 1,
2799
+ feebps: 20
2800
+ });
2801
+ return {
2802
+ senderAddress: signerAddress,
2803
+ chainId,
2804
+ tokenAddress: tokenData.address,
2805
+ amount: (0, import_viem7.toHex)(totalAmount),
2806
+ feeInclusive: isFeeInclusive,
2807
+ serviceType: "batch",
2808
+ amountExclusive: (0, import_viem7.toHex)(amountExclusive),
2809
+ approval,
2810
+ executionAt: executionTime,
2811
+ sessionId: serviceParams.sessionId
2812
+ };
2813
+ } catch (error) {
2814
+ console.log(error);
2815
+ if (error instanceof Error) {
2816
+ throw new Error(error.message);
2817
+ }
2818
+ throw new Error("Failed to create payment.");
2819
+ }
2820
+ });
2821
+ }
2690
2822
  };
2691
2823
 
2692
2824
  // src/utils.ts
package/dist/index.d.cts CHANGED
@@ -67,7 +67,7 @@ interface BillingClassParams extends AbstractPaymentParams {
67
67
  allowMaxTokenApproval?: boolean;
68
68
  }
69
69
  interface BatchClassParams {
70
- APIKey: string;
70
+ APIKey?: string;
71
71
  }
72
72
  type EstimateSinglePaymentGasParameters = Omit<AbstractPaymentParams, "connectorType" | "signer" | "walletClient" | "serviceType" | "paymentType" | "count" | "intervalUnit" | "startDate" | "endDate" | "serviceUrl" | "serviceParams" | "serviceSessionParams"> & {
73
73
  feebps: 20 | 10 | 15;
@@ -166,9 +166,23 @@ type SingleBatchPaymentClassParamsType = Omit<AbstractPaymentParams, "connectorT
166
166
  token: "USDC" | "USDT";
167
167
  instructionId: string;
168
168
  };
169
+ type SingleBatchPaymentWithoutKeyClassParamsType = Omit<SingleBatchPaymentClassParamsType, "instructionId"> & {
170
+ receivers: {
171
+ address: Address;
172
+ amount: bigint;
173
+ }[];
174
+ totalAmount: bigint;
175
+ };
169
176
  type ScheduleBatchPaymentClassParamsType = SingleBatchPaymentClassParamsType & {
170
177
  executionTime: number;
171
178
  };
179
+ type ScheduleBatchPaymentWithoutKeyClassParamsType = Omit<ScheduleBatchPaymentClassParamsType, "instructionId"> & {
180
+ receivers: {
181
+ address: Address;
182
+ amount: bigint;
183
+ }[];
184
+ totalAmount: bigint;
185
+ };
172
186
  type RecurringPaymentParamsType = Omit<AbstractPaymentParams, "connectorType" | "signer" | "walletClient" | "serviceType" | "paymentType" | "serviceUrl" | "serviceSessionParams"> & {
173
187
  endDate?: number;
174
188
  allowMaxTokenApproval?: boolean;
@@ -1519,6 +1533,32 @@ declare class ActaBatch {
1519
1533
  createScheduleBatchPayment(params: ScheduleBatchPaymentClassParamsType, serviceParams: {
1520
1534
  sessionId: string;
1521
1535
  }): Promise<any>;
1536
+ createSingleBatchPaymentWithoutKey(params: SingleBatchPaymentWithoutKeyClassParamsType, serviceParams: {
1537
+ sessionId: string;
1538
+ }): Promise<{
1539
+ senderAddress: `0x${string}` | undefined;
1540
+ chainId: 80002 | 42161 | 8453 | 56 | 1 | 10 | 137 | 84532 | 11155111 | 59144;
1541
+ tokenAddress: `0x${string}`;
1542
+ amount: `0x${string}`;
1543
+ feeInclusive: boolean;
1544
+ serviceType: string;
1545
+ sessionId: string;
1546
+ rpcParameters: viem.RpcUserOperation;
1547
+ }>;
1548
+ createScheduleBatchPaymentWithoutKey(params: ScheduleBatchPaymentWithoutKeyClassParamsType, serviceParams: {
1549
+ sessionId: string;
1550
+ }): Promise<{
1551
+ senderAddress: `0x${string}` | undefined;
1552
+ chainId: 80002 | 42161 | 8453 | 56 | 1 | 10 | 137 | 84532 | 11155111 | 59144;
1553
+ tokenAddress: `0x${string}`;
1554
+ amount: `0x${string}`;
1555
+ feeInclusive: boolean;
1556
+ serviceType: string;
1557
+ amountExclusive: `0x${string}`;
1558
+ approval: string;
1559
+ executionAt: number;
1560
+ sessionId: string;
1561
+ }>;
1522
1562
  }
1523
1563
 
1524
1564
  declare class ActaAccount {
@@ -12022,4 +12062,4 @@ declare function createBatchSessionAPICall(url: string, APIKey: string, params:
12022
12062
  }): Promise<any>;
12023
12063
  declare function fetchBatchInstructionDetails(url: string, APIKey: string): Promise<any>;
12024
12064
 
12025
- export { type AbstractPaymentParams, ActaAccount, ActaBatch, ActaBilling, ActaDeposit, type BatchClassParams, type BillingClassParams, type CalculateSingleBatchPaymentGasParameters, ConnectorType, type DepositClassParams, type EstimateSingleBatchPaymentGasParameters, type EstimateSinglePaymentGasParameters, type ExportPermissionAccountParams, HttpMethod, type ModularSigner, type PermissionAccountParams, type PermissionData, type PermissionPlugin, type PermissionPluginParams, type Policy, PolicyFlags, type PolicyParams, type RecurringPaymentParamsType, type ScheduleBatchPaymentClassParamsType, type ScheduleOrRecurringBatchPaymentParamsType, type SingleBatchPaymentClassParamsType, type SingleBatchPaymentParamsType, type SinglePaymentParamsType, type Token, TokenLogo, ViemClient, arbitrumDAI, arbitrumETH, arbitrumUSDC, arbitrumUSDCe, arbitrumUSDT, arbitrumWETH, base64ToBytes, baseDAI, baseETH, baseEURC, baseSepoliaUSDC, baseUSDC, baseUSDT, baseUSDbC, baseWETH, bscBNB, bscUSDC, bscUSDT, bscWBNB, bytesToBase64, cancelRecurringPaymentAPICall, cancelRecurringTransaction, createBatchSessionAPICall, createBillingCheckoutSession, createBillingSessionAPICall, createPolicyFromParams, createSessionAPICall, decodeParamsFromInitCode, deserializePermissionAccount, deserializePermissionAccountParams, ethereumDAI, ethereumETH, ethereumEURC, ethereumUSDC, ethereumUSDT, ethereumWETH, executeScheduleBatchPaymentAPICall, executeSingleBatchPaymentAPICall, executeSinglePaymentAPICall, fetchBatchInstructionDetails, fetchBillingSessionDetails, fetchRecurringTransactionWithId, getBillingPaymentSessionDetails, getChainById, getChainExplorerByChainId, getPeriodInterval, getPimlicoRpcByChainId, getRpcByChainId, getTokenByChainIdAndAddress, getTokenByChainIdAndSymbol, isKernelVersionAfter, isPermissionValidatorPlugin, lineaDAI, lineaETH, lineaUSDC, lineaWETH, mainnetChains, optimismDAI, optimismETH, optimismUSDC, optimismUSDCe, optimismUSDT, optimismWETH, polygonAmoyUSDC, polygonDAI, polygonPOL, polygonUSDC, polygonUSDCe, polygonUSDT, polygonWETH, polygonWPOL, scheduleRecurringPaymentsAPICall, sendRequest, sepoliaUSDC, serializePermissionAccountParams, supportedChains, supportedTokensByChain, testnetChains, toECDSASigner, toPermissionValidator, toPolicyId, toSignerId, token, tokensCommonSymbols, verifySessionAPICall };
12065
+ export { type AbstractPaymentParams, ActaAccount, ActaBatch, ActaBilling, ActaDeposit, type BatchClassParams, type BillingClassParams, type CalculateSingleBatchPaymentGasParameters, ConnectorType, type DepositClassParams, type EstimateSingleBatchPaymentGasParameters, type EstimateSinglePaymentGasParameters, type ExportPermissionAccountParams, HttpMethod, type ModularSigner, type PermissionAccountParams, type PermissionData, type PermissionPlugin, type PermissionPluginParams, type Policy, PolicyFlags, type PolicyParams, type RecurringPaymentParamsType, type ScheduleBatchPaymentClassParamsType, type ScheduleBatchPaymentWithoutKeyClassParamsType, type ScheduleOrRecurringBatchPaymentParamsType, type SingleBatchPaymentClassParamsType, type SingleBatchPaymentParamsType, type SingleBatchPaymentWithoutKeyClassParamsType, type SinglePaymentParamsType, type Token, TokenLogo, ViemClient, arbitrumDAI, arbitrumETH, arbitrumUSDC, arbitrumUSDCe, arbitrumUSDT, arbitrumWETH, base64ToBytes, baseDAI, baseETH, baseEURC, baseSepoliaUSDC, baseUSDC, baseUSDT, baseUSDbC, baseWETH, bscBNB, bscUSDC, bscUSDT, bscWBNB, bytesToBase64, cancelRecurringPaymentAPICall, cancelRecurringTransaction, createBatchSessionAPICall, createBillingCheckoutSession, createBillingSessionAPICall, createPolicyFromParams, createSessionAPICall, decodeParamsFromInitCode, deserializePermissionAccount, deserializePermissionAccountParams, ethereumDAI, ethereumETH, ethereumEURC, ethereumUSDC, ethereumUSDT, ethereumWETH, executeScheduleBatchPaymentAPICall, executeSingleBatchPaymentAPICall, executeSinglePaymentAPICall, fetchBatchInstructionDetails, fetchBillingSessionDetails, fetchRecurringTransactionWithId, getBillingPaymentSessionDetails, getChainById, getChainExplorerByChainId, getPeriodInterval, getPimlicoRpcByChainId, getRpcByChainId, getTokenByChainIdAndAddress, getTokenByChainIdAndSymbol, isKernelVersionAfter, isPermissionValidatorPlugin, lineaDAI, lineaETH, lineaUSDC, lineaWETH, mainnetChains, optimismDAI, optimismETH, optimismUSDC, optimismUSDCe, optimismUSDT, optimismWETH, polygonAmoyUSDC, polygonDAI, polygonPOL, polygonUSDC, polygonUSDCe, polygonUSDT, polygonWETH, polygonWPOL, scheduleRecurringPaymentsAPICall, sendRequest, sepoliaUSDC, serializePermissionAccountParams, supportedChains, supportedTokensByChain, testnetChains, toECDSASigner, toPermissionValidator, toPolicyId, toSignerId, token, tokensCommonSymbols, verifySessionAPICall };
package/dist/index.d.ts CHANGED
@@ -67,7 +67,7 @@ interface BillingClassParams extends AbstractPaymentParams {
67
67
  allowMaxTokenApproval?: boolean;
68
68
  }
69
69
  interface BatchClassParams {
70
- APIKey: string;
70
+ APIKey?: string;
71
71
  }
72
72
  type EstimateSinglePaymentGasParameters = Omit<AbstractPaymentParams, "connectorType" | "signer" | "walletClient" | "serviceType" | "paymentType" | "count" | "intervalUnit" | "startDate" | "endDate" | "serviceUrl" | "serviceParams" | "serviceSessionParams"> & {
73
73
  feebps: 20 | 10 | 15;
@@ -166,9 +166,23 @@ type SingleBatchPaymentClassParamsType = Omit<AbstractPaymentParams, "connectorT
166
166
  token: "USDC" | "USDT";
167
167
  instructionId: string;
168
168
  };
169
+ type SingleBatchPaymentWithoutKeyClassParamsType = Omit<SingleBatchPaymentClassParamsType, "instructionId"> & {
170
+ receivers: {
171
+ address: Address;
172
+ amount: bigint;
173
+ }[];
174
+ totalAmount: bigint;
175
+ };
169
176
  type ScheduleBatchPaymentClassParamsType = SingleBatchPaymentClassParamsType & {
170
177
  executionTime: number;
171
178
  };
179
+ type ScheduleBatchPaymentWithoutKeyClassParamsType = Omit<ScheduleBatchPaymentClassParamsType, "instructionId"> & {
180
+ receivers: {
181
+ address: Address;
182
+ amount: bigint;
183
+ }[];
184
+ totalAmount: bigint;
185
+ };
172
186
  type RecurringPaymentParamsType = Omit<AbstractPaymentParams, "connectorType" | "signer" | "walletClient" | "serviceType" | "paymentType" | "serviceUrl" | "serviceSessionParams"> & {
173
187
  endDate?: number;
174
188
  allowMaxTokenApproval?: boolean;
@@ -1519,6 +1533,32 @@ declare class ActaBatch {
1519
1533
  createScheduleBatchPayment(params: ScheduleBatchPaymentClassParamsType, serviceParams: {
1520
1534
  sessionId: string;
1521
1535
  }): Promise<any>;
1536
+ createSingleBatchPaymentWithoutKey(params: SingleBatchPaymentWithoutKeyClassParamsType, serviceParams: {
1537
+ sessionId: string;
1538
+ }): Promise<{
1539
+ senderAddress: `0x${string}` | undefined;
1540
+ chainId: 80002 | 42161 | 8453 | 56 | 1 | 10 | 137 | 84532 | 11155111 | 59144;
1541
+ tokenAddress: `0x${string}`;
1542
+ amount: `0x${string}`;
1543
+ feeInclusive: boolean;
1544
+ serviceType: string;
1545
+ sessionId: string;
1546
+ rpcParameters: viem.RpcUserOperation;
1547
+ }>;
1548
+ createScheduleBatchPaymentWithoutKey(params: ScheduleBatchPaymentWithoutKeyClassParamsType, serviceParams: {
1549
+ sessionId: string;
1550
+ }): Promise<{
1551
+ senderAddress: `0x${string}` | undefined;
1552
+ chainId: 80002 | 42161 | 8453 | 56 | 1 | 10 | 137 | 84532 | 11155111 | 59144;
1553
+ tokenAddress: `0x${string}`;
1554
+ amount: `0x${string}`;
1555
+ feeInclusive: boolean;
1556
+ serviceType: string;
1557
+ amountExclusive: `0x${string}`;
1558
+ approval: string;
1559
+ executionAt: number;
1560
+ sessionId: string;
1561
+ }>;
1522
1562
  }
1523
1563
 
1524
1564
  declare class ActaAccount {
@@ -12022,4 +12062,4 @@ declare function createBatchSessionAPICall(url: string, APIKey: string, params:
12022
12062
  }): Promise<any>;
12023
12063
  declare function fetchBatchInstructionDetails(url: string, APIKey: string): Promise<any>;
12024
12064
 
12025
- export { type AbstractPaymentParams, ActaAccount, ActaBatch, ActaBilling, ActaDeposit, type BatchClassParams, type BillingClassParams, type CalculateSingleBatchPaymentGasParameters, ConnectorType, type DepositClassParams, type EstimateSingleBatchPaymentGasParameters, type EstimateSinglePaymentGasParameters, type ExportPermissionAccountParams, HttpMethod, type ModularSigner, type PermissionAccountParams, type PermissionData, type PermissionPlugin, type PermissionPluginParams, type Policy, PolicyFlags, type PolicyParams, type RecurringPaymentParamsType, type ScheduleBatchPaymentClassParamsType, type ScheduleOrRecurringBatchPaymentParamsType, type SingleBatchPaymentClassParamsType, type SingleBatchPaymentParamsType, type SinglePaymentParamsType, type Token, TokenLogo, ViemClient, arbitrumDAI, arbitrumETH, arbitrumUSDC, arbitrumUSDCe, arbitrumUSDT, arbitrumWETH, base64ToBytes, baseDAI, baseETH, baseEURC, baseSepoliaUSDC, baseUSDC, baseUSDT, baseUSDbC, baseWETH, bscBNB, bscUSDC, bscUSDT, bscWBNB, bytesToBase64, cancelRecurringPaymentAPICall, cancelRecurringTransaction, createBatchSessionAPICall, createBillingCheckoutSession, createBillingSessionAPICall, createPolicyFromParams, createSessionAPICall, decodeParamsFromInitCode, deserializePermissionAccount, deserializePermissionAccountParams, ethereumDAI, ethereumETH, ethereumEURC, ethereumUSDC, ethereumUSDT, ethereumWETH, executeScheduleBatchPaymentAPICall, executeSingleBatchPaymentAPICall, executeSinglePaymentAPICall, fetchBatchInstructionDetails, fetchBillingSessionDetails, fetchRecurringTransactionWithId, getBillingPaymentSessionDetails, getChainById, getChainExplorerByChainId, getPeriodInterval, getPimlicoRpcByChainId, getRpcByChainId, getTokenByChainIdAndAddress, getTokenByChainIdAndSymbol, isKernelVersionAfter, isPermissionValidatorPlugin, lineaDAI, lineaETH, lineaUSDC, lineaWETH, mainnetChains, optimismDAI, optimismETH, optimismUSDC, optimismUSDCe, optimismUSDT, optimismWETH, polygonAmoyUSDC, polygonDAI, polygonPOL, polygonUSDC, polygonUSDCe, polygonUSDT, polygonWETH, polygonWPOL, scheduleRecurringPaymentsAPICall, sendRequest, sepoliaUSDC, serializePermissionAccountParams, supportedChains, supportedTokensByChain, testnetChains, toECDSASigner, toPermissionValidator, toPolicyId, toSignerId, token, tokensCommonSymbols, verifySessionAPICall };
12065
+ export { type AbstractPaymentParams, ActaAccount, ActaBatch, ActaBilling, ActaDeposit, type BatchClassParams, type BillingClassParams, type CalculateSingleBatchPaymentGasParameters, ConnectorType, type DepositClassParams, type EstimateSingleBatchPaymentGasParameters, type EstimateSinglePaymentGasParameters, type ExportPermissionAccountParams, HttpMethod, type ModularSigner, type PermissionAccountParams, type PermissionData, type PermissionPlugin, type PermissionPluginParams, type Policy, PolicyFlags, type PolicyParams, type RecurringPaymentParamsType, type ScheduleBatchPaymentClassParamsType, type ScheduleBatchPaymentWithoutKeyClassParamsType, type ScheduleOrRecurringBatchPaymentParamsType, type SingleBatchPaymentClassParamsType, type SingleBatchPaymentParamsType, type SingleBatchPaymentWithoutKeyClassParamsType, type SinglePaymentParamsType, type Token, TokenLogo, ViemClient, arbitrumDAI, arbitrumETH, arbitrumUSDC, arbitrumUSDCe, arbitrumUSDT, arbitrumWETH, base64ToBytes, baseDAI, baseETH, baseEURC, baseSepoliaUSDC, baseUSDC, baseUSDT, baseUSDbC, baseWETH, bscBNB, bscUSDC, bscUSDT, bscWBNB, bytesToBase64, cancelRecurringPaymentAPICall, cancelRecurringTransaction, createBatchSessionAPICall, createBillingCheckoutSession, createBillingSessionAPICall, createPolicyFromParams, createSessionAPICall, decodeParamsFromInitCode, deserializePermissionAccount, deserializePermissionAccountParams, ethereumDAI, ethereumETH, ethereumEURC, ethereumUSDC, ethereumUSDT, ethereumWETH, executeScheduleBatchPaymentAPICall, executeSingleBatchPaymentAPICall, executeSinglePaymentAPICall, fetchBatchInstructionDetails, fetchBillingSessionDetails, fetchRecurringTransactionWithId, getBillingPaymentSessionDetails, getChainById, getChainExplorerByChainId, getPeriodInterval, getPimlicoRpcByChainId, getRpcByChainId, getTokenByChainIdAndAddress, getTokenByChainIdAndSymbol, isKernelVersionAfter, isPermissionValidatorPlugin, lineaDAI, lineaETH, lineaUSDC, lineaWETH, mainnetChains, optimismDAI, optimismETH, optimismUSDC, optimismUSDCe, optimismUSDT, optimismWETH, polygonAmoyUSDC, polygonDAI, polygonPOL, polygonUSDC, polygonUSDCe, polygonUSDT, polygonWETH, polygonWPOL, scheduleRecurringPaymentsAPICall, sendRequest, sepoliaUSDC, serializePermissionAccountParams, supportedChains, supportedTokensByChain, testnetChains, toECDSASigner, toPermissionValidator, toPolicyId, toSignerId, token, tokensCommonSymbols, verifySessionAPICall };
package/dist/index.js CHANGED
@@ -1119,7 +1119,7 @@ var ActaAccount = class {
1119
1119
  args: [
1120
1120
  fromAddress,
1121
1121
  "0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
1122
- estimatedGasCostInToken
1122
+ estimatedTotalFeesInToken
1123
1123
  ]
1124
1124
  }
1125
1125
  ]
@@ -2314,12 +2314,16 @@ var returnEnvUrl = (chainId) => {
2314
2314
  };
2315
2315
  var ActaBatch = class {
2316
2316
  constructor(parameters) {
2317
- this.APIkey = parameters.APIKey;
2317
+ var _a;
2318
+ this.APIkey = (_a = parameters.APIKey) != null ? _a : void 0;
2318
2319
  }
2319
2320
  createSession(params) {
2320
2321
  return __async(this, null, function* () {
2321
2322
  try {
2322
2323
  const { instructionId, name, signerAddress, token: token2, chainId } = params;
2324
+ if (!this.APIkey) {
2325
+ throw new Error("No API key provided.");
2326
+ }
2323
2327
  if (!signerAddress || signerAddress === zeroAddress5) {
2324
2328
  throw new Error("Signer address is required.");
2325
2329
  }
@@ -2366,6 +2370,9 @@ var ActaBatch = class {
2366
2370
  walletClient,
2367
2371
  instructionId
2368
2372
  } = parameters;
2373
+ if (!this.APIkey) {
2374
+ throw new Error("No API key provided.");
2375
+ }
2369
2376
  let isFeeInclusive = false;
2370
2377
  if (feeInclusive) {
2371
2378
  isFeeInclusive = true;
@@ -2449,6 +2456,9 @@ var ActaBatch = class {
2449
2456
  allowMaxTokenApproval,
2450
2457
  instructionId
2451
2458
  } = params;
2459
+ if (!this.APIkey) {
2460
+ throw new Error("No API key provided.");
2461
+ }
2452
2462
  let isFeeInclusive = false;
2453
2463
  if (feeInclusive) {
2454
2464
  isFeeInclusive = true;
@@ -2535,6 +2545,9 @@ var ActaBatch = class {
2535
2545
  instructionId,
2536
2546
  executionTime
2537
2547
  } = params;
2548
+ if (!this.APIkey) {
2549
+ throw new Error("No API key provided.");
2550
+ }
2538
2551
  let isFeeInclusive = false;
2539
2552
  if (feeInclusive) {
2540
2553
  isFeeInclusive = true;
@@ -2619,6 +2632,125 @@ var ActaBatch = class {
2619
2632
  }
2620
2633
  });
2621
2634
  }
2635
+ createSingleBatchPaymentWithoutKey(params, serviceParams) {
2636
+ return __async(this, null, function* () {
2637
+ try {
2638
+ const {
2639
+ chainId,
2640
+ feeInclusive,
2641
+ signerAddress,
2642
+ token: tokenSymbol,
2643
+ walletClient,
2644
+ allowMaxTokenApproval,
2645
+ receivers,
2646
+ totalAmount
2647
+ } = params;
2648
+ let isFeeInclusive = false;
2649
+ if (feeInclusive) {
2650
+ isFeeInclusive = true;
2651
+ }
2652
+ const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
2653
+ if (!tokenData) {
2654
+ throw new Error("Token not supported");
2655
+ }
2656
+ const viemClient = new ViemClient(chainId, walletClient);
2657
+ const account = new ActaAccount(
2658
+ chainId,
2659
+ viemClient.publicClient(),
2660
+ walletClient
2661
+ );
2662
+ console.log("signing");
2663
+ const rpcParameters = yield account.signSingleBatchOperation({
2664
+ signerAddress,
2665
+ chainId,
2666
+ token: tokenSymbol,
2667
+ feeInclusive: isFeeInclusive,
2668
+ receivers,
2669
+ totalAmount,
2670
+ walletClient,
2671
+ allowMaxTokenApproval,
2672
+ feebps: 20
2673
+ });
2674
+ return {
2675
+ senderAddress: signerAddress,
2676
+ chainId,
2677
+ tokenAddress: tokenData.address,
2678
+ amount: toHex4(totalAmount),
2679
+ feeInclusive: isFeeInclusive,
2680
+ serviceType: "batch",
2681
+ sessionId: serviceParams.sessionId,
2682
+ rpcParameters
2683
+ };
2684
+ } catch (error) {
2685
+ if (error instanceof Error) {
2686
+ throw new Error(error.message);
2687
+ }
2688
+ throw new Error("Failed to create payment.");
2689
+ }
2690
+ });
2691
+ }
2692
+ createScheduleBatchPaymentWithoutKey(params, serviceParams) {
2693
+ return __async(this, null, function* () {
2694
+ try {
2695
+ const {
2696
+ chainId,
2697
+ feeInclusive,
2698
+ signerAddress,
2699
+ token: tokenSymbol,
2700
+ walletClient,
2701
+ allowMaxTokenApproval,
2702
+ executionTime,
2703
+ receivers,
2704
+ totalAmount
2705
+ } = params;
2706
+ let isFeeInclusive = false;
2707
+ if (feeInclusive) {
2708
+ isFeeInclusive = true;
2709
+ }
2710
+ const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
2711
+ if (!tokenData) {
2712
+ throw new Error("Token not supported");
2713
+ }
2714
+ const viemClient = new ViemClient(chainId, walletClient);
2715
+ const account = new ActaAccount(
2716
+ chainId,
2717
+ viemClient.publicClient(),
2718
+ walletClient
2719
+ );
2720
+ console.log("signing");
2721
+ const { amountExclusive, approval } = yield account.signRecurringOrScheduleBatchPayments({
2722
+ signerAddress,
2723
+ chainId,
2724
+ token: tokenSymbol,
2725
+ feeInclusive: isFeeInclusive,
2726
+ receivers,
2727
+ totalAmount,
2728
+ walletClient,
2729
+ allowMaxTokenApproval,
2730
+ count: 1,
2731
+ feebps: 20
2732
+ });
2733
+ return {
2734
+ senderAddress: signerAddress,
2735
+ chainId,
2736
+ tokenAddress: tokenData.address,
2737
+ amount: toHex4(totalAmount),
2738
+ feeInclusive: isFeeInclusive,
2739
+ serviceType: "batch",
2740
+ amountExclusive: toHex4(amountExclusive),
2741
+ approval,
2742
+ executionAt: executionTime,
2743
+ sessionId: serviceParams.sessionId
2744
+ };
2745
+ } catch (error) {
2746
+ console.log(error);
2747
+ if (error instanceof Error) {
2748
+ throw new Error(error.message);
2749
+ }
2750
+ throw new Error("Failed to create payment.");
2751
+ }
2752
+ });
2753
+ }
2622
2754
  };
2623
2755
 
2624
2756
  // src/utils.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actalink/commonlib",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "author": "Actalink",
5
5
  "license": "MIT license",
6
6
  "publishConfig": {