@actalink/commonlib 0.0.13 → 0.0.15
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 +401 -73
- package/dist/index.d.cts +1162 -3
- package/dist/index.d.ts +1162 -3
- package/dist/index.js +342 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47,10 +47,14 @@ import {
|
|
|
47
47
|
mainnet as mainnet2,
|
|
48
48
|
linea,
|
|
49
49
|
optimism as optimism2,
|
|
50
|
-
polygon as polygon2
|
|
50
|
+
polygon as polygon2,
|
|
51
|
+
sepolia as sepolia2,
|
|
52
|
+
polygonAmoy as polygonAmoy2,
|
|
53
|
+
baseSepolia as baseSepolia2
|
|
51
54
|
} from "viem/chains";
|
|
52
55
|
|
|
53
56
|
// src/chains.ts
|
|
57
|
+
import { baseSepolia, polygonAmoy, sepolia } from "viem/chains";
|
|
54
58
|
import { arbitrum, base, bsc, optimism, polygon, mainnet } from "viem/chains";
|
|
55
59
|
var supportedChains = [
|
|
56
60
|
arbitrum,
|
|
@@ -58,8 +62,13 @@ var supportedChains = [
|
|
|
58
62
|
bsc,
|
|
59
63
|
mainnet,
|
|
60
64
|
optimism,
|
|
61
|
-
polygon
|
|
65
|
+
polygon,
|
|
66
|
+
baseSepolia,
|
|
67
|
+
sepolia,
|
|
68
|
+
polygonAmoy
|
|
62
69
|
];
|
|
70
|
+
var mainnetChains = [arbitrum, base, bsc, mainnet, optimism, polygon];
|
|
71
|
+
var testnetChains = [sepolia, baseSepolia, polygonAmoy];
|
|
63
72
|
function getChainById(chainId) {
|
|
64
73
|
const chain = supportedChains.find((c) => c.id === chainId);
|
|
65
74
|
if (!chain) throw new Error(`Chain ${chainId} not supported.`);
|
|
@@ -79,6 +88,12 @@ function getChainExplorerByChainId(chainId) {
|
|
|
79
88
|
return "https://optimistic.etherscan.io";
|
|
80
89
|
case polygon.id:
|
|
81
90
|
return "https://polygonscan.com";
|
|
91
|
+
case baseSepolia.id:
|
|
92
|
+
return "https://sepolia.basescan.org";
|
|
93
|
+
case sepolia.id:
|
|
94
|
+
return "https://sepolia.etherscan.io";
|
|
95
|
+
case polygonAmoy.id:
|
|
96
|
+
return "https://amoy.polygonscan.com";
|
|
82
97
|
default:
|
|
83
98
|
return void 0;
|
|
84
99
|
}
|
|
@@ -421,6 +436,36 @@ var polygonUSDCe = token({
|
|
|
421
436
|
logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
|
|
422
437
|
});
|
|
423
438
|
var polygonTokens = [polygonUSDC, polygonUSDT];
|
|
439
|
+
var polygonAmoyUSDC = token({
|
|
440
|
+
chainId: polygonAmoy2.id,
|
|
441
|
+
address: getAddress("0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582"),
|
|
442
|
+
decimals: 6,
|
|
443
|
+
fiatISO: "USDC",
|
|
444
|
+
name: "USDC",
|
|
445
|
+
symbol: "USDC",
|
|
446
|
+
logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
|
|
447
|
+
});
|
|
448
|
+
var polygonAmoyTokens = [polygonAmoyUSDC];
|
|
449
|
+
var baseSepoliaUSDC = token({
|
|
450
|
+
chainId: baseSepolia2.id,
|
|
451
|
+
address: getAddress("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
|
|
452
|
+
decimals: 6,
|
|
453
|
+
fiatISO: "USDC",
|
|
454
|
+
name: "USDC",
|
|
455
|
+
symbol: "USDC",
|
|
456
|
+
logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
|
|
457
|
+
});
|
|
458
|
+
var baseSepoliaTokens = [baseSepoliaUSDC];
|
|
459
|
+
var sepoliaUSDC = token({
|
|
460
|
+
chainId: sepolia2.id,
|
|
461
|
+
address: getAddress("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
|
|
462
|
+
decimals: 6,
|
|
463
|
+
fiatISO: "USDC",
|
|
464
|
+
name: "USDC",
|
|
465
|
+
symbol: "USDC",
|
|
466
|
+
logoURI: "https://api.acta.link/deposit/v1/logos/usdc.png" /* USDC */
|
|
467
|
+
});
|
|
468
|
+
var sepoliaTokens = [sepoliaUSDC];
|
|
424
469
|
var supportedTokensByChain = /* @__PURE__ */ new Map([
|
|
425
470
|
[arbitrum2.id, arbitrumTokens],
|
|
426
471
|
//done
|
|
@@ -432,8 +477,11 @@ var supportedTokensByChain = /* @__PURE__ */ new Map([
|
|
|
432
477
|
//done
|
|
433
478
|
[optimism2.id, optimismTokens],
|
|
434
479
|
//done
|
|
435
|
-
[polygon2.id, polygonTokens]
|
|
480
|
+
[polygon2.id, polygonTokens],
|
|
436
481
|
//done
|
|
482
|
+
[sepolia2.id, sepoliaTokens],
|
|
483
|
+
[polygonAmoy2.id, polygonAmoyTokens],
|
|
484
|
+
[baseSepolia2.id, baseSepoliaTokens]
|
|
437
485
|
]);
|
|
438
486
|
function nativeETH(chainId) {
|
|
439
487
|
return nativeToken({
|
|
@@ -565,6 +613,12 @@ function getRpcByChainId(chainId) {
|
|
|
565
613
|
return "https://arbitrum-mainnet.g.alchemy.com/v2/2uxlNSyeU1IcP7HMKteJM21td0IAHroW";
|
|
566
614
|
case 59144:
|
|
567
615
|
return "https://linea-mainnet.g.alchemy.com/v2/2uxlNSyeU1IcP7HMKteJM21td0IAHroW";
|
|
616
|
+
case 80002:
|
|
617
|
+
return `https://polygon-amoy.g.alchemy.com/v2/2uxlNSyeU1IcP7HMKteJM21td0IAHroW`;
|
|
618
|
+
case 84532:
|
|
619
|
+
return `https://base-sepolia.g.alchemy.com/v2/2uxlNSyeU1IcP7HMKteJM21td0IAHroW`;
|
|
620
|
+
case 11155111:
|
|
621
|
+
return `https://eth-sepolia.g.alchemy.com/v2/2uxlNSyeU1IcP7HMKteJM21td0IAHroW`;
|
|
568
622
|
default:
|
|
569
623
|
return void 0;
|
|
570
624
|
}
|
|
@@ -585,6 +639,12 @@ function getPimlicoRpcByChainId(chainId) {
|
|
|
585
639
|
return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
|
|
586
640
|
case 59144:
|
|
587
641
|
return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
|
|
642
|
+
case 80002:
|
|
643
|
+
return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
|
|
644
|
+
case 84532:
|
|
645
|
+
return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
|
|
646
|
+
case 11155111:
|
|
647
|
+
return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=pim_Jjg9Mp3i5LPCvgSyqXKK5T`;
|
|
588
648
|
default:
|
|
589
649
|
return void 0;
|
|
590
650
|
}
|
|
@@ -652,7 +712,7 @@ var ViemClient = class {
|
|
|
652
712
|
});
|
|
653
713
|
const receipt = yield this.publicClient().waitForTransactionReceipt({
|
|
654
714
|
hash: txn,
|
|
655
|
-
confirmations: token2.chainId === 1 ? 1 : 5
|
|
715
|
+
confirmations: token2.chainId === 1 || 11155111 ? 1 : 5
|
|
656
716
|
});
|
|
657
717
|
return amount;
|
|
658
718
|
}
|
|
@@ -775,7 +835,7 @@ var ActaAccount = class {
|
|
|
775
835
|
functionName: "transferFrom",
|
|
776
836
|
args: [
|
|
777
837
|
fromAddress,
|
|
778
|
-
"
|
|
838
|
+
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
779
839
|
BigInt(0)
|
|
780
840
|
]
|
|
781
841
|
},
|
|
@@ -858,7 +918,7 @@ var ActaAccount = class {
|
|
|
858
918
|
functionName: "transferFrom",
|
|
859
919
|
args: [
|
|
860
920
|
fromAddress,
|
|
861
|
-
"
|
|
921
|
+
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
862
922
|
BigInt(0)
|
|
863
923
|
]
|
|
864
924
|
}
|
|
@@ -945,7 +1005,7 @@ var ActaAccount = class {
|
|
|
945
1005
|
functionName: "transferFrom",
|
|
946
1006
|
args: [
|
|
947
1007
|
fromAddress,
|
|
948
|
-
"
|
|
1008
|
+
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
949
1009
|
estimatedGasCostInToken
|
|
950
1010
|
]
|
|
951
1011
|
},
|
|
@@ -1000,7 +1060,6 @@ var ActaAccount = class {
|
|
|
1000
1060
|
}
|
|
1001
1061
|
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1002
1062
|
console.log("validating gas");
|
|
1003
|
-
console.log(receivers);
|
|
1004
1063
|
const {
|
|
1005
1064
|
estimatedGasCostInToken,
|
|
1006
1065
|
ActalinkFeesInToken,
|
|
@@ -1047,7 +1106,7 @@ var ActaAccount = class {
|
|
|
1047
1106
|
functionName: "transferFrom",
|
|
1048
1107
|
args: [
|
|
1049
1108
|
fromAddress,
|
|
1050
|
-
"
|
|
1109
|
+
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
1051
1110
|
estimatedGasCostInToken
|
|
1052
1111
|
]
|
|
1053
1112
|
}
|
|
@@ -1161,7 +1220,7 @@ var ActaAccount = class {
|
|
|
1161
1220
|
{
|
|
1162
1221
|
condition: ParamCondition.ONE_OF,
|
|
1163
1222
|
value: [
|
|
1164
|
-
"
|
|
1223
|
+
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
1165
1224
|
getAddress2(receiver)
|
|
1166
1225
|
]
|
|
1167
1226
|
},
|
|
@@ -1199,6 +1258,133 @@ var ActaAccount = class {
|
|
|
1199
1258
|
return { approval, amountExclusive };
|
|
1200
1259
|
});
|
|
1201
1260
|
}
|
|
1261
|
+
signRecurringOrScheduleBatchPayments(paymentParams) {
|
|
1262
|
+
return __async(this, null, function* () {
|
|
1263
|
+
if (!this.signer) {
|
|
1264
|
+
throw new Error("Signer is required for self custody payments.");
|
|
1265
|
+
}
|
|
1266
|
+
const {
|
|
1267
|
+
signerAddress,
|
|
1268
|
+
chainId,
|
|
1269
|
+
token: tokenSymbol,
|
|
1270
|
+
feeInclusive,
|
|
1271
|
+
count,
|
|
1272
|
+
allowMaxTokenApproval,
|
|
1273
|
+
receivers,
|
|
1274
|
+
totalAmount,
|
|
1275
|
+
walletClient
|
|
1276
|
+
} = paymentParams;
|
|
1277
|
+
if (signerAddress === void 0) {
|
|
1278
|
+
throw new Error("signer address is not provided.");
|
|
1279
|
+
}
|
|
1280
|
+
if (totalAmount <= BigInt(0)) {
|
|
1281
|
+
throw new Error("Amount must be greater than 0.");
|
|
1282
|
+
}
|
|
1283
|
+
if (receivers.length === 0) {
|
|
1284
|
+
throw new Error("Receivers not found for batch payment");
|
|
1285
|
+
}
|
|
1286
|
+
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1287
|
+
if (!token2) {
|
|
1288
|
+
throw new Error("Token not found.");
|
|
1289
|
+
}
|
|
1290
|
+
const kernelVersion = KERNEL_V3_1;
|
|
1291
|
+
const entryPoint = getEntryPoint("0.7");
|
|
1292
|
+
const paymentCount = count != null ? count : 24;
|
|
1293
|
+
const account = yield this.createAccount();
|
|
1294
|
+
const smartAccountAddress = account.address;
|
|
1295
|
+
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1296
|
+
const { paymasterClient, pimlicoClient } = yield this.createAccountHelpers();
|
|
1297
|
+
const ecdsaValidator = yield signerToEcdsaValidator(
|
|
1298
|
+
viemClient.publicClient(),
|
|
1299
|
+
{
|
|
1300
|
+
entryPoint,
|
|
1301
|
+
kernelVersion,
|
|
1302
|
+
signer: this.signer
|
|
1303
|
+
}
|
|
1304
|
+
);
|
|
1305
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1306
|
+
const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
|
|
1307
|
+
const emptySessionKeySigner = yield toECDSASigner({ signer: emptyAccount });
|
|
1308
|
+
const {
|
|
1309
|
+
estimatedGasCostInToken,
|
|
1310
|
+
ActalinkFeesInToken,
|
|
1311
|
+
feeInclusiveAmountInToken,
|
|
1312
|
+
feeExclusiveAmountInToken,
|
|
1313
|
+
estimatedTotalFeesInToken,
|
|
1314
|
+
paymaster
|
|
1315
|
+
} = yield this.estimateSingleBatchPaymentGas({
|
|
1316
|
+
signerAddress,
|
|
1317
|
+
chainId,
|
|
1318
|
+
token: tokenSymbol,
|
|
1319
|
+
receivers,
|
|
1320
|
+
feeInclusive,
|
|
1321
|
+
totalAmount,
|
|
1322
|
+
walletClient
|
|
1323
|
+
});
|
|
1324
|
+
const amountToTransfer = feeInclusive ? totalAmount : feeExclusiveAmountInToken;
|
|
1325
|
+
const receiverAmount = feeInclusive ? feeInclusiveAmountInToken : totalAmount;
|
|
1326
|
+
yield viemClient.checkAndApproveToken(
|
|
1327
|
+
token2,
|
|
1328
|
+
smartAccountAddress,
|
|
1329
|
+
amountToTransfer * BigInt(paymentCount) + estimatedGasCostInToken * BigInt(2) * BigInt(paymentCount),
|
|
1330
|
+
allowMaxTokenApproval != null ? allowMaxTokenApproval : false
|
|
1331
|
+
);
|
|
1332
|
+
const amountExclusive = amountToTransfer + amountToTransfer / BigInt(2);
|
|
1333
|
+
const receiversAddress = receivers.map((r) => getAddress2(r.address));
|
|
1334
|
+
const callPolicy = toCallPolicy({
|
|
1335
|
+
policyVersion: CallPolicyVersion.V0_0_4,
|
|
1336
|
+
permissions: [
|
|
1337
|
+
{
|
|
1338
|
+
target: token2.address,
|
|
1339
|
+
valueLimit: BigInt(0),
|
|
1340
|
+
abi: parseAbi2(["function transferFrom(address,address,uint)"]),
|
|
1341
|
+
functionName: "transferFrom",
|
|
1342
|
+
args: [
|
|
1343
|
+
{
|
|
1344
|
+
condition: ParamCondition.EQUAL,
|
|
1345
|
+
value: getAddress2(signerAddress)
|
|
1346
|
+
},
|
|
1347
|
+
{
|
|
1348
|
+
condition: ParamCondition.ONE_OF,
|
|
1349
|
+
value: [
|
|
1350
|
+
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
1351
|
+
...receiversAddress
|
|
1352
|
+
]
|
|
1353
|
+
},
|
|
1354
|
+
{
|
|
1355
|
+
condition: ParamCondition.LESS_THAN_OR_EQUAL,
|
|
1356
|
+
value: amountExclusive
|
|
1357
|
+
}
|
|
1358
|
+
]
|
|
1359
|
+
}
|
|
1360
|
+
]
|
|
1361
|
+
});
|
|
1362
|
+
const permissionPlugin = yield toPermissionValidator(
|
|
1363
|
+
viemClient.publicClient(),
|
|
1364
|
+
{
|
|
1365
|
+
entryPoint,
|
|
1366
|
+
kernelVersion,
|
|
1367
|
+
signer: emptySessionKeySigner,
|
|
1368
|
+
policies: [callPolicy]
|
|
1369
|
+
}
|
|
1370
|
+
);
|
|
1371
|
+
const serializedSessionKeyAccount = yield createKernelAccount(
|
|
1372
|
+
viemClient.publicClient(),
|
|
1373
|
+
{
|
|
1374
|
+
entryPoint,
|
|
1375
|
+
kernelVersion,
|
|
1376
|
+
plugins: {
|
|
1377
|
+
sudo: ecdsaValidator,
|
|
1378
|
+
regular: permissionPlugin
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
);
|
|
1382
|
+
const approval = yield serializePermissionAccount(
|
|
1383
|
+
serializedSessionKeyAccount
|
|
1384
|
+
);
|
|
1385
|
+
return { approval, amountExclusive };
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1202
1388
|
signRecurringTransactionCancellation(paymentCancellationParams) {
|
|
1203
1389
|
return __async(this, null, function* () {
|
|
1204
1390
|
var _a;
|
|
@@ -1240,7 +1426,7 @@ var ActaAccount = class {
|
|
|
1240
1426
|
{
|
|
1241
1427
|
condition: ParamCondition.ONE_OF,
|
|
1242
1428
|
value: [
|
|
1243
|
-
"
|
|
1429
|
+
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
1244
1430
|
getAddress2(receiverAddress)
|
|
1245
1431
|
]
|
|
1246
1432
|
},
|
|
@@ -1446,6 +1632,23 @@ function executeSingleBatchPaymentAPICall(url, APIKey, userOperation, paymentPar
|
|
|
1446
1632
|
return response.data;
|
|
1447
1633
|
});
|
|
1448
1634
|
}
|
|
1635
|
+
function executeScheduleBatchPaymentAPICall(url, APIKey, paymentParams, serviceParams) {
|
|
1636
|
+
return __async(this, null, function* () {
|
|
1637
|
+
const params = {
|
|
1638
|
+
paymentParams,
|
|
1639
|
+
serviceParams
|
|
1640
|
+
};
|
|
1641
|
+
const response = yield sendRequest({
|
|
1642
|
+
url,
|
|
1643
|
+
method: "post" /* Post */,
|
|
1644
|
+
body: params,
|
|
1645
|
+
headers: {
|
|
1646
|
+
"x-api-key": APIKey
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
return response.data;
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1449
1652
|
function fetchRecurringTransactionWithId(url) {
|
|
1450
1653
|
return __async(this, null, function* () {
|
|
1451
1654
|
const response = yield sendRequest({ url, method: "get" /* Get */ });
|
|
@@ -2063,7 +2266,28 @@ import {
|
|
|
2063
2266
|
toHex as toHex4,
|
|
2064
2267
|
zeroAddress as zeroAddress5
|
|
2065
2268
|
} from "viem";
|
|
2269
|
+
var transactionServiceUrl3 = "https://api.acta.link/transaction/v1/";
|
|
2066
2270
|
var batchServiceUrl = "https://api.acta.link/batch/api/v1/";
|
|
2271
|
+
var transactionServiceTestUrl = "https://api.acta.link/transaction/test/v1/";
|
|
2272
|
+
var batchServiceTestUrl = "https://api.acta.link/batch/test/api/v1/";
|
|
2273
|
+
var returnEnvUrl = (chainId) => {
|
|
2274
|
+
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2275
|
+
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
2276
|
+
if (!mainnetChain && !testnetChain) {
|
|
2277
|
+
throw new Error(`Chain ${chainId} not supported.`);
|
|
2278
|
+
}
|
|
2279
|
+
if (mainnetChain) {
|
|
2280
|
+
return {
|
|
2281
|
+
envTransactionServiceUrl: transactionServiceUrl3,
|
|
2282
|
+
envBatchServiceUrl: batchServiceUrl
|
|
2283
|
+
};
|
|
2284
|
+
} else {
|
|
2285
|
+
return {
|
|
2286
|
+
envTransactionServiceUrl: transactionServiceTestUrl,
|
|
2287
|
+
envBatchServiceUrl: batchServiceTestUrl
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2290
|
+
};
|
|
2067
2291
|
var ActaBatch = class {
|
|
2068
2292
|
constructor(parameters) {
|
|
2069
2293
|
this.APIkey = parameters.APIKey;
|
|
@@ -2084,8 +2308,9 @@ var ActaBatch = class {
|
|
|
2084
2308
|
if (!instructionId || instructionId === "") {
|
|
2085
2309
|
throw new Error("Instruction id is required");
|
|
2086
2310
|
}
|
|
2311
|
+
const { envBatchServiceUrl } = returnEnvUrl(chainId);
|
|
2087
2312
|
const session = yield createBatchSessionAPICall(
|
|
2088
|
-
`${
|
|
2313
|
+
`${envBatchServiceUrl}create/session`,
|
|
2089
2314
|
this.APIkey,
|
|
2090
2315
|
{
|
|
2091
2316
|
name,
|
|
@@ -2117,8 +2342,9 @@ var ActaBatch = class {
|
|
|
2117
2342
|
walletClient,
|
|
2118
2343
|
instructionId
|
|
2119
2344
|
} = parameters;
|
|
2345
|
+
const { envBatchServiceUrl } = returnEnvUrl(chainId);
|
|
2120
2346
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2121
|
-
`${
|
|
2347
|
+
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2122
2348
|
this.APIkey
|
|
2123
2349
|
);
|
|
2124
2350
|
if (instuctionData.receivers.length === 0 || instuctionData.receivers.length === void 0) {
|
|
@@ -2194,8 +2420,9 @@ var ActaBatch = class {
|
|
|
2194
2420
|
allowMaxTokenApproval,
|
|
2195
2421
|
instructionId
|
|
2196
2422
|
} = params;
|
|
2423
|
+
const { envBatchServiceUrl } = returnEnvUrl(chainId);
|
|
2197
2424
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2198
|
-
`${
|
|
2425
|
+
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2199
2426
|
this.APIkey
|
|
2200
2427
|
);
|
|
2201
2428
|
if (instuctionData.receivers.length === 0 || instuctionData.receivers.length === void 0) {
|
|
@@ -2238,7 +2465,7 @@ var ActaBatch = class {
|
|
|
2238
2465
|
allowMaxTokenApproval
|
|
2239
2466
|
});
|
|
2240
2467
|
const txn = yield executeSingleBatchPaymentAPICall(
|
|
2241
|
-
`${
|
|
2468
|
+
`${envBatchServiceUrl}execute/single/batch`,
|
|
2242
2469
|
this.APIkey,
|
|
2243
2470
|
rpcParameters,
|
|
2244
2471
|
{
|
|
@@ -2261,6 +2488,98 @@ var ActaBatch = class {
|
|
|
2261
2488
|
}
|
|
2262
2489
|
});
|
|
2263
2490
|
}
|
|
2491
|
+
createScheduleBatchPayment(params, serviceParams) {
|
|
2492
|
+
return __async(this, null, function* () {
|
|
2493
|
+
try {
|
|
2494
|
+
const {
|
|
2495
|
+
chainId,
|
|
2496
|
+
feeInclusive,
|
|
2497
|
+
signerAddress,
|
|
2498
|
+
token: tokenSymbol,
|
|
2499
|
+
walletClient,
|
|
2500
|
+
allowMaxTokenApproval,
|
|
2501
|
+
instructionId,
|
|
2502
|
+
executionTime
|
|
2503
|
+
} = params;
|
|
2504
|
+
const { envBatchServiceUrl } = returnEnvUrl(chainId);
|
|
2505
|
+
if (executionTime <= Date.now() + 1e3 * 60 * 2) {
|
|
2506
|
+
throw new Error(
|
|
2507
|
+
"Execution time must be more than 5 mins from current time."
|
|
2508
|
+
);
|
|
2509
|
+
}
|
|
2510
|
+
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2511
|
+
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2512
|
+
this.APIkey
|
|
2513
|
+
);
|
|
2514
|
+
if (instuctionData.receivers.length === 0 || instuctionData.receivers.length === void 0) {
|
|
2515
|
+
throw new Error("Instruction not found");
|
|
2516
|
+
}
|
|
2517
|
+
console.log(instuctionData);
|
|
2518
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2519
|
+
if (!tokenData) {
|
|
2520
|
+
throw new Error("Token not supported");
|
|
2521
|
+
}
|
|
2522
|
+
const totalAmount = instuctionData.totalAmount;
|
|
2523
|
+
const totalAmountParsed = BigInt(
|
|
2524
|
+
parseUnits(totalAmount, tokenData.decimals)
|
|
2525
|
+
);
|
|
2526
|
+
const receivers = instuctionData.receivers.map(
|
|
2527
|
+
(i) => {
|
|
2528
|
+
const receiver = getAddress3(i.address);
|
|
2529
|
+
const tokenAmount = BigInt(parseUnits(i.amount, tokenData.decimals));
|
|
2530
|
+
return {
|
|
2531
|
+
address: receiver,
|
|
2532
|
+
amount: tokenAmount
|
|
2533
|
+
};
|
|
2534
|
+
}
|
|
2535
|
+
);
|
|
2536
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2537
|
+
const account = new ActaAccount(
|
|
2538
|
+
chainId,
|
|
2539
|
+
viemClient.publicClient(),
|
|
2540
|
+
walletClient
|
|
2541
|
+
);
|
|
2542
|
+
console.log("signing");
|
|
2543
|
+
const { amountExclusive, approval } = yield account.signRecurringOrScheduleBatchPayments({
|
|
2544
|
+
signerAddress,
|
|
2545
|
+
chainId,
|
|
2546
|
+
token: tokenSymbol,
|
|
2547
|
+
feeInclusive,
|
|
2548
|
+
receivers,
|
|
2549
|
+
totalAmount: totalAmountParsed,
|
|
2550
|
+
walletClient,
|
|
2551
|
+
allowMaxTokenApproval,
|
|
2552
|
+
count: 1
|
|
2553
|
+
});
|
|
2554
|
+
const txn = yield executeScheduleBatchPaymentAPICall(
|
|
2555
|
+
`${envBatchServiceUrl}execute/schedule/batch`,
|
|
2556
|
+
this.APIkey,
|
|
2557
|
+
{
|
|
2558
|
+
senderAddress: signerAddress,
|
|
2559
|
+
chainId,
|
|
2560
|
+
tokenAddress: tokenData.address,
|
|
2561
|
+
amount: toHex4(totalAmountParsed),
|
|
2562
|
+
feeInclusive,
|
|
2563
|
+
serviceType: "batch",
|
|
2564
|
+
amountExclusive: toHex4(amountExclusive),
|
|
2565
|
+
approval,
|
|
2566
|
+
executionAt: executionTime
|
|
2567
|
+
},
|
|
2568
|
+
{
|
|
2569
|
+
sessionId: serviceParams.sessionId
|
|
2570
|
+
}
|
|
2571
|
+
);
|
|
2572
|
+
console.log(txn);
|
|
2573
|
+
return txn.transaction.id;
|
|
2574
|
+
} catch (error) {
|
|
2575
|
+
console.log(error);
|
|
2576
|
+
if (error instanceof Error) {
|
|
2577
|
+
throw new Error(error.message);
|
|
2578
|
+
}
|
|
2579
|
+
throw new Error("Failed to create payment.");
|
|
2580
|
+
}
|
|
2581
|
+
});
|
|
2582
|
+
}
|
|
2264
2583
|
};
|
|
2265
2584
|
|
|
2266
2585
|
// src/utils.ts
|
|
@@ -2307,7 +2626,7 @@ import { coerce, gt } from "semver";
|
|
|
2307
2626
|
var ECDSA_SIGNER_CONTRACT = "0x6A6F069E2a08c2468e7724Ab3250CdBFBA14D4FF";
|
|
2308
2627
|
var billingServiceUrl = "https://api.acta.link/billing/v1/";
|
|
2309
2628
|
var depositServiceUrl2 = "https://api.acta.link/deposit/v1/";
|
|
2310
|
-
var
|
|
2629
|
+
var transactionServiceUrl4 = "https://api.acta.link/transaction/v1/";
|
|
2311
2630
|
var toSignerId = (signer) => {
|
|
2312
2631
|
return encodeAbiParameters(
|
|
2313
2632
|
[{ name: "signerData", type: "bytes" }],
|
|
@@ -2706,7 +3025,7 @@ var cancelRecurringTransaction = (_0) => __async(null, [_0], function* ({
|
|
|
2706
3025
|
});
|
|
2707
3026
|
console.log(rpcParameters);
|
|
2708
3027
|
const txn = yield cancelRecurringPaymentAPICall(
|
|
2709
|
-
`${
|
|
3028
|
+
`${transactionServiceUrl4}execute/cancel`,
|
|
2710
3029
|
rpcParameters,
|
|
2711
3030
|
{
|
|
2712
3031
|
chainId,
|
|
@@ -2740,6 +3059,7 @@ export {
|
|
|
2740
3059
|
baseDAI,
|
|
2741
3060
|
baseETH,
|
|
2742
3061
|
baseEURC,
|
|
3062
|
+
baseSepoliaUSDC,
|
|
2743
3063
|
baseUSDC,
|
|
2744
3064
|
baseUSDT,
|
|
2745
3065
|
baseUSDbC,
|
|
@@ -2765,6 +3085,7 @@ export {
|
|
|
2765
3085
|
ethereumUSDC,
|
|
2766
3086
|
ethereumUSDT,
|
|
2767
3087
|
ethereumWETH,
|
|
3088
|
+
executeScheduleBatchPaymentAPICall,
|
|
2768
3089
|
executeSingleBatchPaymentAPICall,
|
|
2769
3090
|
executeSinglePaymentAPICall,
|
|
2770
3091
|
fetchBatchInstructionDetails,
|
|
@@ -2784,12 +3105,14 @@ export {
|
|
|
2784
3105
|
lineaETH,
|
|
2785
3106
|
lineaUSDC,
|
|
2786
3107
|
lineaWETH,
|
|
3108
|
+
mainnetChains,
|
|
2787
3109
|
optimismDAI,
|
|
2788
3110
|
optimismETH,
|
|
2789
3111
|
optimismUSDC,
|
|
2790
3112
|
optimismUSDCe,
|
|
2791
3113
|
optimismUSDT,
|
|
2792
3114
|
optimismWETH,
|
|
3115
|
+
polygonAmoyUSDC,
|
|
2793
3116
|
polygonDAI,
|
|
2794
3117
|
polygonPOL,
|
|
2795
3118
|
polygonUSDC,
|
|
@@ -2799,9 +3122,11 @@ export {
|
|
|
2799
3122
|
polygonWPOL,
|
|
2800
3123
|
scheduleRecurringPaymentsAPICall,
|
|
2801
3124
|
sendRequest,
|
|
3125
|
+
sepoliaUSDC,
|
|
2802
3126
|
serializePermissionAccountParams,
|
|
2803
3127
|
supportedChains,
|
|
2804
3128
|
supportedTokensByChain,
|
|
3129
|
+
testnetChains,
|
|
2805
3130
|
toECDSASigner2 as toECDSASigner,
|
|
2806
3131
|
toPermissionValidator2 as toPermissionValidator,
|
|
2807
3132
|
toPolicyId,
|