@actalink/commonlib 0.1.0 → 0.1.1

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
@@ -85,7 +85,6 @@ __export(index_exports, {
85
85
  bscBNB: () => bscBNB,
86
86
  bscUSDC: () => bscUSDC,
87
87
  bscUSDT: () => bscUSDT,
88
- bscWBNB: () => bscWBNB,
89
88
  bytesToBase64: () => bytesToBase64,
90
89
  cancelRecurringPaymentAPICall: () => cancelRecurringPaymentAPICall,
91
90
  cancelRecurringTransaction: () => cancelRecurringTransaction,
@@ -337,14 +336,6 @@ var bscBNB = nativeToken({
337
336
  symbol: "BNB",
338
337
  logoURI: "https://api.acta.link/deposit/v1/logos/bnb.png" /* BNB */
339
338
  });
340
- var bscWBNB = token({
341
- chainId: import_chains3.bsc.id,
342
- address: (0, import_viem.getAddress)("0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"),
343
- decimals: 18,
344
- name: "Wrapped BNB",
345
- symbol: "WBNB",
346
- logoURI: "https://api.acta.link/deposit/v1/logos/bnb.png" /* BNB */
347
- });
348
339
  var bscUSDC = token({
349
340
  chainId: import_chains3.bsc.id,
350
341
  address: (0, import_viem.getAddress)("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
@@ -777,6 +768,43 @@ var ViemClient = class {
777
768
  return allowance;
778
769
  });
779
770
  }
771
+ approveToken(token2, spender, amount, allowMaxTokenApproval) {
772
+ return __async(this, null, function* () {
773
+ var _a;
774
+ if (this.walletClient === void 0) {
775
+ throw new Error("Wallet client is required");
776
+ }
777
+ const signerAddress = (_a = this.walletClient.account) == null ? void 0 : _a.address;
778
+ console.log("signerAddress", signerAddress);
779
+ if (signerAddress === void 0) {
780
+ throw new Error("Signer address is required");
781
+ }
782
+ const txn = yield this.walletClient.sendTransaction({
783
+ to: token2.address,
784
+ account: signerAddress,
785
+ chain: getChainById(token2.chainId),
786
+ value: BigInt(0),
787
+ data: (0, import_viem2.encodeFunctionData)({
788
+ abi: (0, import_viem2.parseAbi)(["function approve(address,uint)"]),
789
+ functionName: "approve",
790
+ args: [spender, allowMaxTokenApproval ? import_viem2.maxUint256 : amount]
791
+ })
792
+ });
793
+ return txn;
794
+ });
795
+ }
796
+ waitForTransactionReceipt(hash, blocks = 1) {
797
+ return __async(this, null, function* () {
798
+ if (this.walletClient === void 0) {
799
+ throw new Error("Wallet client is required");
800
+ }
801
+ const receipt = yield this.publicClient().waitForTransactionReceipt({
802
+ hash,
803
+ confirmations: blocks
804
+ });
805
+ return receipt;
806
+ });
807
+ }
780
808
  };
781
809
 
782
810
  // src/account.ts
@@ -1131,7 +1159,7 @@ var ActaAccount = class {
1131
1159
  };
1132
1160
  });
1133
1161
  }
1134
- signSinglePaymentOperation(singlePaymentParams) {
1162
+ estimatePaymentAmount(singlePaymentParams) {
1135
1163
  return __async(this, null, function* () {
1136
1164
  try {
1137
1165
  if (!this.signer) {
@@ -1144,7 +1172,6 @@ var ActaAccount = class {
1144
1172
  amount,
1145
1173
  receiver,
1146
1174
  feeInclusive,
1147
- allowMaxTokenApproval,
1148
1175
  feebps
1149
1176
  } = singlePaymentParams;
1150
1177
  if (amount <= BigInt(0)) {
@@ -1157,14 +1184,10 @@ var ActaAccount = class {
1157
1184
  if (!token2) {
1158
1185
  throw new Error("Token not found.");
1159
1186
  }
1160
- const viemClient = new ViemClient(this.chainId, this.signer);
1161
1187
  const {
1162
- estimatedGasCostInToken,
1163
- ActalinkFeesInToken,
1164
1188
  feeInclusiveAmountInToken,
1165
1189
  feeExclusiveAmountInToken,
1166
- estimatedTotalFeesInToken,
1167
- paymaster
1190
+ estimatedTotalFeesInToken
1168
1191
  } = yield this.estimateSinglePaymentGas({
1169
1192
  signerAddress,
1170
1193
  chainId,
@@ -1174,18 +1197,141 @@ var ActaAccount = class {
1174
1197
  feeInclusive,
1175
1198
  feebps
1176
1199
  });
1177
- const account = yield this.createAccount();
1178
- const { accountClient } = yield this.createAccountHelpers();
1179
- const fromAddress = signerAddress;
1180
- const smartAccountAddress = account.address;
1181
- const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
1200
+ const totalAmount = feeInclusive ? amount : feeExclusiveAmountInToken;
1201
+ const actalinkFees = estimatedTotalFeesInToken;
1182
1202
  const receiverAmount = feeInclusive ? feeInclusiveAmountInToken : amount;
1183
- yield viemClient.checkAndApproveToken(
1203
+ return {
1204
+ totalAmount,
1205
+ actalinkFees,
1206
+ receiverAmount
1207
+ };
1208
+ } catch (error) {
1209
+ if (error instanceof Error) {
1210
+ throw new Error(error.message);
1211
+ }
1212
+ throw new Error("Failed to estimate payment amount.");
1213
+ }
1214
+ });
1215
+ }
1216
+ checkAllowance(params) {
1217
+ return __async(this, null, function* () {
1218
+ var _a;
1219
+ try {
1220
+ if (!this.signer) {
1221
+ throw new Error("Signer is required for self custody payments.");
1222
+ }
1223
+ const { chainId, token: tokenSymbol } = params;
1224
+ const account = yield this.createAccount();
1225
+ const smartAccountAddress = yield account.getAddress();
1226
+ const owner = (_a = this.signer.account) == null ? void 0 : _a.address;
1227
+ console.log("signerAddress", owner);
1228
+ if (owner === void 0) {
1229
+ throw new Error("Signer address is required");
1230
+ }
1231
+ const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
1232
+ if (!token2) {
1233
+ throw new Error("Token not found.");
1234
+ }
1235
+ const viemClient = new ViemClient(this.chainId, this.signer);
1236
+ const allowance = yield viemClient.checkTokenAllowance(
1237
+ token2,
1238
+ owner,
1239
+ smartAccountAddress
1240
+ );
1241
+ return allowance;
1242
+ } catch (error) {
1243
+ if (error instanceof Error) {
1244
+ throw new Error(error.message);
1245
+ }
1246
+ throw new Error("Failed to check token allownace.");
1247
+ }
1248
+ });
1249
+ }
1250
+ approveToken(params) {
1251
+ return __async(this, null, function* () {
1252
+ try {
1253
+ if (!this.signer) {
1254
+ throw new Error("Signer is required for self custody payments.");
1255
+ }
1256
+ const {
1257
+ chainId,
1258
+ token: tokenSymbol,
1259
+ amount,
1260
+ allowMaxTokenApproval
1261
+ } = params;
1262
+ const account = yield this.createAccount();
1263
+ const smartAccountAddress = yield account.getAddress();
1264
+ const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
1265
+ if (!token2) {
1266
+ throw new Error("Token not found.");
1267
+ }
1268
+ const viemClient = new ViemClient(this.chainId, this.signer);
1269
+ const allowance = yield viemClient.approveToken(
1184
1270
  token2,
1185
1271
  smartAccountAddress,
1186
- amountToTransfer,
1187
- allowMaxTokenApproval != null ? allowMaxTokenApproval : false
1272
+ amount,
1273
+ allowMaxTokenApproval
1188
1274
  );
1275
+ return allowance;
1276
+ } catch (error) {
1277
+ if (error instanceof Error) {
1278
+ throw new Error(error.message);
1279
+ }
1280
+ throw new Error("Failed to approve token.");
1281
+ }
1282
+ });
1283
+ }
1284
+ waitForTransactionReceipt(params) {
1285
+ return __async(this, null, function* () {
1286
+ try {
1287
+ if (!this.signer) {
1288
+ throw new Error("Signer is required for self custody payments.");
1289
+ }
1290
+ const { chainId, hash } = params;
1291
+ if (!hash) {
1292
+ throw new Error("Hash is not provided.");
1293
+ }
1294
+ const viemClient = new ViemClient(this.chainId, this.signer);
1295
+ const receipt = yield viemClient.waitForTransactionReceipt(hash);
1296
+ return receipt;
1297
+ } catch (error) {
1298
+ if (error instanceof Error) {
1299
+ throw new Error(error.message);
1300
+ }
1301
+ throw new Error("Failed to check token allownace.");
1302
+ }
1303
+ });
1304
+ }
1305
+ signSinglePaymentOperation(singlePaymentParams) {
1306
+ return __async(this, null, function* () {
1307
+ try {
1308
+ if (!this.signer) {
1309
+ throw new Error("Signer is required for self custody payments.");
1310
+ }
1311
+ const {
1312
+ signerAddress,
1313
+ chainId,
1314
+ token: tokenSymbol,
1315
+ actalinkFees,
1316
+ receiverAmount,
1317
+ receiver
1318
+ } = singlePaymentParams;
1319
+ if (receiverAmount <= BigInt(0)) {
1320
+ throw new Error("Amount must be greater than 0.");
1321
+ }
1322
+ if (actalinkFees <= BigInt(0)) {
1323
+ throw new Error("Fees must be greater than 0.");
1324
+ }
1325
+ if (receiver === signerAddress) {
1326
+ throw new Error("Receiver cannot be the same as the signer.");
1327
+ }
1328
+ const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
1329
+ if (!token2) {
1330
+ throw new Error("Token not found.");
1331
+ }
1332
+ const account = yield this.createAccount();
1333
+ const { accountClient } = yield this.createAccountHelpers();
1334
+ const fromAddress = signerAddress;
1189
1335
  const userOperation = yield accountClient.prepareUserOperation({
1190
1336
  calls: [
1191
1337
  {
@@ -1195,7 +1341,7 @@ var ActaAccount = class {
1195
1341
  args: [
1196
1342
  fromAddress,
1197
1343
  "0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
1198
- estimatedTotalFeesInToken
1344
+ actalinkFees
1199
1345
  ]
1200
1346
  },
1201
1347
  {
@@ -1328,14 +1474,7 @@ var ActaAccount = class {
1328
1474
  chainId,
1329
1475
  token: tokenSymbol,
1330
1476
  amount,
1331
- receiver,
1332
- feeInclusive,
1333
- count,
1334
- intervalUnit,
1335
- startDate,
1336
- endDate,
1337
- allowMaxTokenApproval,
1338
- feebps
1477
+ receiver
1339
1478
  } = recurringPaymentParams;
1340
1479
  if (amount <= BigInt(0)) {
1341
1480
  throw new Error("Amount must be greater than 0.");
@@ -1346,20 +1485,14 @@ var ActaAccount = class {
1346
1485
  if (receiver === signerAddress) {
1347
1486
  throw new Error("Receiver cannot be the same as the signer.");
1348
1487
  }
1349
- if (!intervalUnit) {
1350
- throw new Error("Interval unit is required.");
1351
- }
1352
1488
  const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
1353
1489
  if (!token2) {
1354
1490
  throw new Error("Token not found.");
1355
1491
  }
1356
1492
  const kernelVersion = import_constants.KERNEL_V3_1;
1357
1493
  const entryPoint = (0, import_constants.getEntryPoint)("0.7");
1358
- const paymentCount = count != null ? count : 24;
1359
1494
  const account = yield this.createAccount();
1360
- const smartAccountAddress = account.address;
1361
1495
  const viemClient = new ViemClient(this.chainId, this.signer);
1362
- const { paymasterClient, pimlicoClient } = yield this.createAccountHelpers();
1363
1496
  const ecdsaValidator = yield (0, import_ecdsa_validator.signerToEcdsaValidator)(
1364
1497
  viemClient.publicClient(),
1365
1498
  {
@@ -1371,32 +1504,7 @@ var ActaAccount = class {
1371
1504
  const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
1372
1505
  const emptyAccount = (0, import_sdk.addressToEmptyAccount)(sessionKeyAddress);
1373
1506
  const emptySessionKeySigner = yield (0, import_signers.toECDSASigner)({ signer: emptyAccount });
1374
- const {
1375
- paymaster,
1376
- ActalinkFeesInToken,
1377
- feeInclusiveAmountInToken,
1378
- feeExclusiveAmountInToken,
1379
- estimatedTotalFeesInToken,
1380
- userOperation,
1381
- estimatedGasCostInToken
1382
- } = yield this.estimateSinglePaymentGas({
1383
- signerAddress,
1384
- chainId,
1385
- token: tokenSymbol,
1386
- amount,
1387
- receiver,
1388
- feeInclusive,
1389
- feebps
1390
- });
1391
- const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
1392
- const receiverAmount = feeInclusive ? feeInclusiveAmountInToken : amount;
1393
- yield viemClient.checkAndApproveToken(
1394
- token2,
1395
- smartAccountAddress,
1396
- amountToTransfer * BigInt(paymentCount) + estimatedGasCostInToken * BigInt(2) * BigInt(paymentCount),
1397
- allowMaxTokenApproval != null ? allowMaxTokenApproval : false
1398
- );
1399
- const amountExclusive = amountToTransfer + amountToTransfer / BigInt(2);
1507
+ const amountExclusive = amount + amount / BigInt(2);
1400
1508
  const callPolicy = (0, import_policies.toCallPolicy)({
1401
1509
  policyVersion: import_policies.CallPolicyVersion.V0_0_4,
1402
1510
  permissions: [
@@ -1943,6 +2051,7 @@ var ActaFlexDeposit = class {
1943
2051
  this.status = "not_started";
1944
2052
  this.serviceType = "deposit";
1945
2053
  this.allowMaxTokenApproval = false;
2054
+ this.feebps = 10;
1946
2055
  var _a, _b, _c;
1947
2056
  this.connectorType = parameters.connectorType;
1948
2057
  this.walletClient = parameters.walletClient;
@@ -2062,35 +2171,95 @@ var ActaFlexDeposit = class {
2062
2171
  }
2063
2172
  });
2064
2173
  }
2065
- createPayment(servicePaymentParams) {
2174
+ estimatePaymentAmount() {
2175
+ return __async(this, null, function* () {
2176
+ try {
2177
+ const signerAddress = this.signerAddress;
2178
+ const chainId = this.chainId;
2179
+ const tokenSymbol = this.token;
2180
+ const amount = this.amount;
2181
+ const receiver = this.receiver;
2182
+ const feeInclusive = this.feeInclusive;
2183
+ const feebps = this.feebps;
2184
+ const { totalAmount, actalinkFees, receiverAmount } = yield this.account.estimatePaymentAmount({
2185
+ signerAddress,
2186
+ chainId,
2187
+ token: tokenSymbol,
2188
+ amount,
2189
+ receiver,
2190
+ feeInclusive,
2191
+ feebps
2192
+ });
2193
+ return {
2194
+ totalAmount,
2195
+ actalinkFees,
2196
+ receiverAmount
2197
+ };
2198
+ } catch (error) {
2199
+ if (error instanceof Error) {
2200
+ throw new Error(error.message);
2201
+ }
2202
+ throw new Error("Failed to estimate payment amount.");
2203
+ }
2204
+ });
2205
+ }
2206
+ checkAllowance() {
2066
2207
  return __async(this, null, function* () {
2067
2208
  try {
2068
- if (this.paymentType === "single") {
2069
- const paymentParams = this.serviceType === "deposit" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
2070
- depositSessionId: this.depositSessionId
2071
- }) : servicePaymentParams;
2072
- const id = yield this.createSinglePayment(paymentParams);
2073
- return id;
2074
- }
2075
- if (this.paymentType === "choose") {
2076
- }
2077
- if (this.paymentType === "recurring") {
2078
- const paymentParams = this.serviceType === "deposit" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
2079
- depositSessionId: this.depositSessionId
2080
- }) : servicePaymentParams;
2081
- const id = yield this.createRecurringPayments(paymentParams);
2082
- return id;
2209
+ const chainId = this.chainId;
2210
+ const tokenSymbol = this.token;
2211
+ const allowance = yield this.account.checkAllowance({
2212
+ chainId,
2213
+ token: tokenSymbol
2214
+ });
2215
+ return allowance;
2216
+ } catch (error) {
2217
+ if (error instanceof Error) {
2218
+ throw new Error(error.message);
2083
2219
  }
2220
+ throw new Error("Failed to check token allowance.");
2221
+ }
2222
+ });
2223
+ }
2224
+ approveToken(parameters) {
2225
+ return __async(this, null, function* () {
2226
+ try {
2227
+ const chainId = this.chainId;
2228
+ const tokenSymbol = this.token;
2229
+ const { totalAmount, allowMaxTokenApproval } = parameters;
2230
+ const hash = yield this.account.approveToken({
2231
+ chainId,
2232
+ token: tokenSymbol,
2233
+ amount: totalAmount,
2234
+ allowMaxTokenApproval
2235
+ });
2236
+ return hash;
2084
2237
  } catch (error) {
2085
- this.status = "payment_failed";
2086
2238
  if (error instanceof Error) {
2087
2239
  throw new Error(error.message);
2088
2240
  }
2089
- throw new Error("Failed to create payment.");
2241
+ throw new Error("Failed to approve token.");
2242
+ }
2243
+ });
2244
+ }
2245
+ waitForTransactionReceipt(hash) {
2246
+ return __async(this, null, function* () {
2247
+ try {
2248
+ const chainId = this.chainId;
2249
+ const receipt = yield this.account.waitForTransactionReceipt({
2250
+ chainId,
2251
+ hash
2252
+ });
2253
+ return receipt;
2254
+ } catch (error) {
2255
+ if (error instanceof Error) {
2256
+ throw new Error(error.message);
2257
+ }
2258
+ throw new Error("Failed to fetch transaction receipt.");
2090
2259
  }
2091
2260
  });
2092
2261
  }
2093
- createSinglePayment(servicePaymentParams) {
2262
+ createSinglePayment(parameters, servicePaymentParams) {
2094
2263
  return __async(this, null, function* () {
2095
2264
  try {
2096
2265
  if (this.connectorType !== "Self-Custody" /* SELF_CUSTODY */) {
@@ -2102,18 +2271,12 @@ var ActaFlexDeposit = class {
2102
2271
  const signerAddress = this.signerAddress;
2103
2272
  const chainId = this.chainId;
2104
2273
  const tokenSymbol = this.token;
2105
- const amount = this.amount;
2106
2274
  const receiver = this.receiver;
2275
+ const amount = this.amount;
2107
2276
  const feeInclusive = this.feeInclusive;
2108
2277
  const serviceType = this.serviceType;
2278
+ const { actalinkFees, receiverAmount } = parameters;
2109
2279
  const { envTransactionServiceUrl, envDepositServiceUrl } = returnEnvUrl(chainId);
2110
- if (this.depositSessionId !== "") {
2111
- const session = yield verifySessionAPICall(
2112
- `${envDepositServiceUrl}verify-session?sessionId=${this.depositSessionId}`,
2113
- this.depositSessionId
2114
- );
2115
- this.depositSessionId = session.sessionId;
2116
- }
2117
2280
  const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
2118
2281
  if (!token2) {
2119
2282
  throw new Error("Token not supported.");
@@ -2122,11 +2285,9 @@ var ActaFlexDeposit = class {
2122
2285
  signerAddress,
2123
2286
  chainId,
2124
2287
  token: tokenSymbol,
2125
- amount,
2126
- receiver,
2127
- feeInclusive,
2128
- allowMaxTokenApproval: this.allowMaxTokenApproval,
2129
- feebps: 10
2288
+ actalinkFees,
2289
+ receiverAmount,
2290
+ receiver
2130
2291
  });
2131
2292
  const txn = yield executeSinglePaymentAPICall(
2132
2293
  `${envTransactionServiceUrl}execute/single`,
@@ -2214,14 +2375,7 @@ var ActaFlexDeposit = class {
2214
2375
  chainId,
2215
2376
  token: tokenSymbol,
2216
2377
  amount,
2217
- feeInclusive,
2218
- count,
2219
- intervalUnit,
2220
- startDate,
2221
- endDate,
2222
- receiver,
2223
- allowMaxTokenApproval: this.allowMaxTokenApproval,
2224
- feebps: 20
2378
+ receiver
2225
2379
  });
2226
2380
  const txn = yield scheduleRecurringPaymentsAPICall(
2227
2381
  `${envTransactionServiceUrl}schedule/recurring`,
@@ -2245,39 +2399,6 @@ var ActaFlexDeposit = class {
2245
2399
  return txn.recurringTransaction.id;
2246
2400
  });
2247
2401
  }
2248
- getPaymentSteps() {
2249
- return __async(this, null, function* () {
2250
- const signerAddress = this.signerAddress;
2251
- const chainId = this.chainId;
2252
- const tokenSymbol = this.token;
2253
- const amount = this.amount;
2254
- const receiver = this.receiver;
2255
- const feeInclusive = this.feeInclusive;
2256
- const count = this.count;
2257
- if (!signerAddress) return ["allowance", "confirm"];
2258
- const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
2259
- if (!token2) return ["allowance", "confirm"];
2260
- const smartAccount = yield this.account.createAccount();
2261
- const { estimatedGasCostInToken, feeExclusiveAmountInToken } = yield this.account.estimateSinglePaymentGas({
2262
- chainId,
2263
- amount,
2264
- feeInclusive,
2265
- receiver,
2266
- signerAddress,
2267
- token: tokenSymbol,
2268
- feebps: 10
2269
- });
2270
- const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
2271
- let paymentAmount = (amountToTransfer + estimatedGasCostInToken * BigInt(2)) * BigInt(count != null ? count : 1);
2272
- const allowance = yield this.viemClient.checkTokenAllowance(
2273
- token2,
2274
- signerAddress,
2275
- smartAccount.address
2276
- );
2277
- if (paymentAmount <= allowance) return ["confirm"];
2278
- return ["allowance", "confirm"];
2279
- });
2280
- }
2281
2402
  };
2282
2403
 
2283
2404
  // src/flexbatch.ts
@@ -2771,6 +2892,7 @@ var ActaBilling = class {
2771
2892
  this.status = "not_started";
2772
2893
  this.serviceType = "deposit";
2773
2894
  this.allowMaxTokenApproval = false;
2895
+ this.feebps = 20;
2774
2896
  var _a, _b;
2775
2897
  this.connectorType = parameters.connectorType;
2776
2898
  this.walletClient = parameters.walletClient;
@@ -2826,7 +2948,95 @@ var ActaBilling = class {
2826
2948
  }
2827
2949
  });
2828
2950
  }
2829
- createSinglePayment(servicePaymentParams) {
2951
+ estimatePaymentAmount() {
2952
+ return __async(this, null, function* () {
2953
+ try {
2954
+ const signerAddress = this.signerAddress;
2955
+ const chainId = this.chainId;
2956
+ const tokenSymbol = this.token;
2957
+ const amount = this.amount;
2958
+ const receiver = this.receiver;
2959
+ const feeInclusive = this.feeInclusive;
2960
+ const feebps = this.feebps;
2961
+ const { totalAmount, actalinkFees, receiverAmount } = yield this.account.estimatePaymentAmount({
2962
+ signerAddress,
2963
+ chainId,
2964
+ token: tokenSymbol,
2965
+ amount,
2966
+ receiver,
2967
+ feeInclusive,
2968
+ feebps
2969
+ });
2970
+ return {
2971
+ totalAmount,
2972
+ actalinkFees,
2973
+ receiverAmount
2974
+ };
2975
+ } catch (error) {
2976
+ if (error instanceof Error) {
2977
+ throw new Error(error.message);
2978
+ }
2979
+ throw new Error("Failed to estimate payment amount.");
2980
+ }
2981
+ });
2982
+ }
2983
+ checkAllowance() {
2984
+ return __async(this, null, function* () {
2985
+ try {
2986
+ const chainId = this.chainId;
2987
+ const tokenSymbol = this.token;
2988
+ const allowance = yield this.account.checkAllowance({
2989
+ chainId,
2990
+ token: tokenSymbol
2991
+ });
2992
+ return allowance;
2993
+ } catch (error) {
2994
+ if (error instanceof Error) {
2995
+ throw new Error(error.message);
2996
+ }
2997
+ throw new Error("Failed to check token allowance.");
2998
+ }
2999
+ });
3000
+ }
3001
+ approveToken(parameters) {
3002
+ return __async(this, null, function* () {
3003
+ try {
3004
+ const chainId = this.chainId;
3005
+ const tokenSymbol = this.token;
3006
+ const { totalAmount, allowMaxTokenApproval } = parameters;
3007
+ const hash = yield this.account.approveToken({
3008
+ chainId,
3009
+ token: tokenSymbol,
3010
+ amount: totalAmount,
3011
+ allowMaxTokenApproval
3012
+ });
3013
+ return hash;
3014
+ } catch (error) {
3015
+ if (error instanceof Error) {
3016
+ throw new Error(error.message);
3017
+ }
3018
+ throw new Error("Failed to approve token.");
3019
+ }
3020
+ });
3021
+ }
3022
+ waitForTransactionReceipt(hash) {
3023
+ return __async(this, null, function* () {
3024
+ try {
3025
+ const chainId = this.chainId;
3026
+ const receipt = yield this.account.waitForTransactionReceipt({
3027
+ chainId,
3028
+ hash
3029
+ });
3030
+ return receipt;
3031
+ } catch (error) {
3032
+ if (error instanceof Error) {
3033
+ throw new Error(error.message);
3034
+ }
3035
+ throw new Error("Failed to fetch transaction receipt.");
3036
+ }
3037
+ });
3038
+ }
3039
+ createSinglePayment(parameters, servicePaymentParams) {
2830
3040
  return __async(this, null, function* () {
2831
3041
  try {
2832
3042
  if (this.connectorType !== "Self-Custody" /* SELF_CUSTODY */) {
@@ -2835,6 +3045,7 @@ var ActaBilling = class {
2835
3045
  if (!servicePaymentParams.checkoutSessionId || servicePaymentParams.checkoutSessionId === "") {
2836
3046
  throw new Error("checkout session ID is required.");
2837
3047
  }
3048
+ const { actalinkFees, receiverAmount } = parameters;
2838
3049
  const signerAddress = this.signerAddress;
2839
3050
  const chainId = this.chainId;
2840
3051
  const tokenSymbol = this.token;
@@ -2851,11 +3062,9 @@ var ActaBilling = class {
2851
3062
  signerAddress,
2852
3063
  chainId,
2853
3064
  token: tokenSymbol,
2854
- amount,
2855
- receiver,
2856
- feeInclusive,
2857
- allowMaxTokenApproval: this.allowMaxTokenApproval,
2858
- feebps: 20
3065
+ actalinkFees,
3066
+ receiverAmount,
3067
+ receiver
2859
3068
  });
2860
3069
  const txn = yield executeSinglePaymentAPICall(
2861
3070
  `${envBillingServiceUrl}execute/single`,
@@ -2915,14 +3124,7 @@ var ActaBilling = class {
2915
3124
  chainId,
2916
3125
  token: tokenSymbol,
2917
3126
  amount,
2918
- feeInclusive,
2919
- count,
2920
- intervalUnit,
2921
- startDate,
2922
- endDate,
2923
- receiver,
2924
- allowMaxTokenApproval: this.allowMaxTokenApproval,
2925
- feebps: 20
3127
+ receiver
2926
3128
  });
2927
3129
  const txn = yield scheduleSubscriptionPaymentsAPICall(
2928
3130
  `${envBillingServiceUrl}schedule/subscription`,
@@ -3913,7 +4115,6 @@ var cancelRecurringTransaction = (_0) => __async(null, [_0], function* ({
3913
4115
  bscBNB,
3914
4116
  bscUSDC,
3915
4117
  bscUSDT,
3916
- bscWBNB,
3917
4118
  bytesToBase64,
3918
4119
  cancelRecurringPaymentAPICall,
3919
4120
  cancelRecurringTransaction,