@actalink/commonlib 0.0.15 → 0.0.17
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 +221 -63
- package/dist/index.d.cts +50 -3
- package/dist/index.d.ts +50 -3
- package/dist/index.js +222 -64
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -879,7 +879,8 @@ var ActaAccount = class {
|
|
|
879
879
|
chainId,
|
|
880
880
|
token: tokenSymbol,
|
|
881
881
|
amount,
|
|
882
|
-
receiver
|
|
882
|
+
receiver,
|
|
883
|
+
feebps
|
|
883
884
|
} = parameters;
|
|
884
885
|
if (amount <= BigInt(0)) {
|
|
885
886
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -895,11 +896,6 @@ var ActaAccount = class {
|
|
|
895
896
|
if (!token2) {
|
|
896
897
|
throw new Error("Token not found.");
|
|
897
898
|
}
|
|
898
|
-
const quotes = yield pimlicoClient.getTokenQuotes({
|
|
899
|
-
tokens: [token2.address],
|
|
900
|
-
chain: getChainById(chainId)
|
|
901
|
-
});
|
|
902
|
-
const { postOpGas, exchangeRate, paymaster } = quotes[0];
|
|
903
899
|
const userOperation = yield accountClient.prepareUserOperation({
|
|
904
900
|
calls: [
|
|
905
901
|
{
|
|
@@ -920,22 +916,31 @@ var ActaAccount = class {
|
|
|
920
916
|
}
|
|
921
917
|
]
|
|
922
918
|
});
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
);
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
|
|
919
|
+
const quotes = yield pimlicoClient.getTokenQuotes({
|
|
920
|
+
tokens: [token2.address],
|
|
921
|
+
chain: getChainById(chainId)
|
|
922
|
+
});
|
|
923
|
+
const userOperationMaxCost = (0, import_permissionless.getRequiredPrefund)({
|
|
924
|
+
userOperation,
|
|
925
|
+
entryPointVersion: "0.7"
|
|
926
|
+
});
|
|
927
|
+
const postOpGas = quotes[0].postOpGas;
|
|
928
|
+
const exchangeRate = quotes[0].exchangeRate;
|
|
929
|
+
const exchangeRateNativeToUsd = quotes[0].exchangeRateNativeToUsd;
|
|
930
|
+
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
931
|
+
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
932
|
+
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
933
|
+
const ActalinkFeesInToken = amount * BigInt(feebps) / BigInt(1e4);
|
|
934
|
+
const estimatedTotalFeesInToken = costInToken + ActalinkFeesInToken;
|
|
930
935
|
const feeInclusiveAmountInToken = amount - estimatedTotalFeesInToken;
|
|
931
936
|
const feeExclusiveAmountInToken = amount + estimatedTotalFeesInToken;
|
|
932
937
|
return {
|
|
933
|
-
estimatedGasCostInToken,
|
|
938
|
+
estimatedGasCostInToken: costInToken,
|
|
934
939
|
ActalinkFeesInToken,
|
|
935
940
|
estimatedTotalFeesInToken,
|
|
936
941
|
feeInclusiveAmountInToken,
|
|
937
942
|
feeExclusiveAmountInToken,
|
|
938
|
-
paymaster,
|
|
943
|
+
paymaster: quotes[0].paymaster,
|
|
939
944
|
userOperation
|
|
940
945
|
};
|
|
941
946
|
});
|
|
@@ -949,7 +954,8 @@ var ActaAccount = class {
|
|
|
949
954
|
receivers,
|
|
950
955
|
feeInclusive,
|
|
951
956
|
walletClient,
|
|
952
|
-
totalAmount
|
|
957
|
+
totalAmount,
|
|
958
|
+
feebps
|
|
953
959
|
} = parameters;
|
|
954
960
|
if (totalAmount <= BigInt(0)) {
|
|
955
961
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -965,14 +971,6 @@ var ActaAccount = class {
|
|
|
965
971
|
if (!token2) {
|
|
966
972
|
throw new Error("Token not found.");
|
|
967
973
|
}
|
|
968
|
-
console.log(`fromAddress: ${fromAddress}`);
|
|
969
|
-
const quotes = yield pimlicoClient.getTokenQuotes({
|
|
970
|
-
tokens: [token2.address],
|
|
971
|
-
chain: getChainById(chainId)
|
|
972
|
-
});
|
|
973
|
-
const { postOpGas, exchangeRate, paymaster } = quotes[0];
|
|
974
|
-
console.log("preparing");
|
|
975
|
-
console.log(token2.address);
|
|
976
974
|
const receiversData = receivers.map((r) => {
|
|
977
975
|
return {
|
|
978
976
|
to: (0, import_viem3.getAddress)(token2.address),
|
|
@@ -997,17 +995,27 @@ var ActaAccount = class {
|
|
|
997
995
|
}
|
|
998
996
|
]
|
|
999
997
|
});
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
);
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1006
|
-
|
|
998
|
+
const quotes = yield pimlicoClient.getTokenQuotes({
|
|
999
|
+
tokens: [token2.address],
|
|
1000
|
+
chain: getChainById(chainId)
|
|
1001
|
+
});
|
|
1002
|
+
const userOperationMaxCost = (0, import_permissionless.getRequiredPrefund)({
|
|
1003
|
+
userOperation,
|
|
1004
|
+
entryPointVersion: "0.7"
|
|
1005
|
+
});
|
|
1006
|
+
const postOpGas = quotes[0].postOpGas;
|
|
1007
|
+
const exchangeRate = quotes[0].exchangeRate;
|
|
1008
|
+
const exchangeRateNativeToUsd = quotes[0].exchangeRateNativeToUsd;
|
|
1009
|
+
const paymaster = quotes[0].paymaster;
|
|
1010
|
+
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
1011
|
+
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
1012
|
+
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
1013
|
+
const ActalinkFeesInToken = totalAmount * BigInt(feebps) / BigInt(1e4);
|
|
1014
|
+
const estimatedTotalFeesInToken = costInToken + ActalinkFeesInToken;
|
|
1007
1015
|
const feeInclusiveAmountInToken = totalAmount - estimatedTotalFeesInToken;
|
|
1008
1016
|
const feeExclusiveAmountInToken = totalAmount + estimatedTotalFeesInToken;
|
|
1009
1017
|
return {
|
|
1010
|
-
estimatedGasCostInToken,
|
|
1018
|
+
estimatedGasCostInToken: costInToken,
|
|
1011
1019
|
ActalinkFeesInToken,
|
|
1012
1020
|
estimatedTotalFeesInToken,
|
|
1013
1021
|
feeInclusiveAmountInToken,
|
|
@@ -1030,7 +1038,8 @@ var ActaAccount = class {
|
|
|
1030
1038
|
amount,
|
|
1031
1039
|
receiver,
|
|
1032
1040
|
feeInclusive,
|
|
1033
|
-
allowMaxTokenApproval
|
|
1041
|
+
allowMaxTokenApproval,
|
|
1042
|
+
feebps
|
|
1034
1043
|
} = singlePaymentParams;
|
|
1035
1044
|
if (amount <= BigInt(0)) {
|
|
1036
1045
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -1056,7 +1065,8 @@ var ActaAccount = class {
|
|
|
1056
1065
|
token: tokenSymbol,
|
|
1057
1066
|
amount,
|
|
1058
1067
|
receiver,
|
|
1059
|
-
feeInclusive
|
|
1068
|
+
feeInclusive,
|
|
1069
|
+
feebps
|
|
1060
1070
|
});
|
|
1061
1071
|
const account = yield this.createAccount();
|
|
1062
1072
|
const { accountClient } = yield this.createAccountHelpers();
|
|
@@ -1079,7 +1089,7 @@ var ActaAccount = class {
|
|
|
1079
1089
|
args: [
|
|
1080
1090
|
fromAddress,
|
|
1081
1091
|
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
1082
|
-
|
|
1092
|
+
estimatedTotalFeesInToken
|
|
1083
1093
|
]
|
|
1084
1094
|
},
|
|
1085
1095
|
{
|
|
@@ -1119,7 +1129,8 @@ var ActaAccount = class {
|
|
|
1119
1129
|
feeInclusive,
|
|
1120
1130
|
allowMaxTokenApproval,
|
|
1121
1131
|
totalAmount,
|
|
1122
|
-
walletClient
|
|
1132
|
+
walletClient,
|
|
1133
|
+
feebps
|
|
1123
1134
|
} = singlePaymentParams;
|
|
1124
1135
|
if (totalAmount <= BigInt(0)) {
|
|
1125
1136
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -1147,7 +1158,8 @@ var ActaAccount = class {
|
|
|
1147
1158
|
receivers,
|
|
1148
1159
|
feeInclusive,
|
|
1149
1160
|
totalAmount,
|
|
1150
|
-
walletClient
|
|
1161
|
+
walletClient,
|
|
1162
|
+
feebps
|
|
1151
1163
|
});
|
|
1152
1164
|
const account = yield this.createAccount();
|
|
1153
1165
|
const { accountClient } = yield this.createAccountHelpers();
|
|
@@ -1180,7 +1192,7 @@ var ActaAccount = class {
|
|
|
1180
1192
|
args: [
|
|
1181
1193
|
fromAddress,
|
|
1182
1194
|
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
1183
|
-
|
|
1195
|
+
estimatedTotalFeesInToken
|
|
1184
1196
|
]
|
|
1185
1197
|
}
|
|
1186
1198
|
]
|
|
@@ -1216,7 +1228,8 @@ var ActaAccount = class {
|
|
|
1216
1228
|
intervalUnit,
|
|
1217
1229
|
startDate,
|
|
1218
1230
|
endDate,
|
|
1219
|
-
allowMaxTokenApproval
|
|
1231
|
+
allowMaxTokenApproval,
|
|
1232
|
+
feebps
|
|
1220
1233
|
} = recurringPaymentParams;
|
|
1221
1234
|
if (amount <= BigInt(0)) {
|
|
1222
1235
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -1266,7 +1279,8 @@ var ActaAccount = class {
|
|
|
1266
1279
|
token: tokenSymbol,
|
|
1267
1280
|
amount,
|
|
1268
1281
|
receiver,
|
|
1269
|
-
feeInclusive
|
|
1282
|
+
feeInclusive,
|
|
1283
|
+
feebps
|
|
1270
1284
|
});
|
|
1271
1285
|
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
1272
1286
|
const receiverAmount = feeInclusive ? feeInclusiveAmountInToken : amount;
|
|
@@ -1345,7 +1359,8 @@ var ActaAccount = class {
|
|
|
1345
1359
|
allowMaxTokenApproval,
|
|
1346
1360
|
receivers,
|
|
1347
1361
|
totalAmount,
|
|
1348
|
-
walletClient
|
|
1362
|
+
walletClient,
|
|
1363
|
+
feebps
|
|
1349
1364
|
} = paymentParams;
|
|
1350
1365
|
if (signerAddress === void 0) {
|
|
1351
1366
|
throw new Error("signer address is not provided.");
|
|
@@ -1392,7 +1407,8 @@ var ActaAccount = class {
|
|
|
1392
1407
|
receivers,
|
|
1393
1408
|
feeInclusive,
|
|
1394
1409
|
totalAmount,
|
|
1395
|
-
walletClient
|
|
1410
|
+
walletClient,
|
|
1411
|
+
feebps
|
|
1396
1412
|
});
|
|
1397
1413
|
const amountToTransfer = feeInclusive ? totalAmount : feeExclusiveAmountInToken;
|
|
1398
1414
|
const receiverAmount = feeInclusive ? feeInclusiveAmountInToken : totalAmount;
|
|
@@ -1774,6 +1790,7 @@ var transactionServiceUrl = "https://api.acta.link/transaction/v1/";
|
|
|
1774
1790
|
var depositServiceUrl = "https://api.acta.link/deposit/v1/";
|
|
1775
1791
|
var ActaDeposit = class {
|
|
1776
1792
|
constructor(parameters) {
|
|
1793
|
+
this.feeInclusive = false;
|
|
1777
1794
|
this.count = 0;
|
|
1778
1795
|
this.intervalUnit = void 0;
|
|
1779
1796
|
this.startDate = void 0;
|
|
@@ -1783,7 +1800,7 @@ var ActaDeposit = class {
|
|
|
1783
1800
|
this.status = "not_started";
|
|
1784
1801
|
this.serviceType = "deposit";
|
|
1785
1802
|
this.allowMaxTokenApproval = false;
|
|
1786
|
-
var _a, _b;
|
|
1803
|
+
var _a, _b, _c;
|
|
1787
1804
|
this.connectorType = parameters.connectorType;
|
|
1788
1805
|
this.walletClient = parameters.walletClient;
|
|
1789
1806
|
this.signerAddress = parameters.signerAddress;
|
|
@@ -1791,14 +1808,14 @@ var ActaDeposit = class {
|
|
|
1791
1808
|
this.token = parameters.token;
|
|
1792
1809
|
this.amount = parameters.amount;
|
|
1793
1810
|
this.receiver = parameters.receiver;
|
|
1794
|
-
this.feeInclusive = parameters.feeInclusive;
|
|
1811
|
+
this.feeInclusive = (_a = parameters.feeInclusive) != null ? _a : false;
|
|
1795
1812
|
this.paymentType = parameters.paymentType;
|
|
1796
1813
|
this.count = parameters.count;
|
|
1797
1814
|
this.intervalUnit = parameters.intervalUnit;
|
|
1798
1815
|
this.startDate = parameters.startDate;
|
|
1799
1816
|
this.endDate = parameters.endDate;
|
|
1800
|
-
this.depositSessionId = (
|
|
1801
|
-
this.allowMaxTokenApproval = (
|
|
1817
|
+
this.depositSessionId = (_b = parameters.depositSessionId) != null ? _b : "";
|
|
1818
|
+
this.allowMaxTokenApproval = (_c = parameters.allowMaxTokenApproval) != null ? _c : false;
|
|
1802
1819
|
this.viemClient = new ViemClient(this.chainId, this.walletClient);
|
|
1803
1820
|
this.account = new ActaAccount(
|
|
1804
1821
|
this.chainId,
|
|
@@ -1963,7 +1980,8 @@ var ActaDeposit = class {
|
|
|
1963
1980
|
amount,
|
|
1964
1981
|
receiver,
|
|
1965
1982
|
feeInclusive,
|
|
1966
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval
|
|
1983
|
+
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
1984
|
+
feebps: 10
|
|
1967
1985
|
});
|
|
1968
1986
|
const txn = yield executeSinglePaymentAPICall(
|
|
1969
1987
|
`${transactionServiceUrl}execute/single`,
|
|
@@ -2056,7 +2074,8 @@ var ActaDeposit = class {
|
|
|
2056
2074
|
startDate,
|
|
2057
2075
|
endDate,
|
|
2058
2076
|
receiver,
|
|
2059
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval
|
|
2077
|
+
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2078
|
+
feebps: 20
|
|
2060
2079
|
});
|
|
2061
2080
|
const txn = yield scheduleRecurringPaymentsAPICall(
|
|
2062
2081
|
`${transactionServiceUrl}schedule/recurring`,
|
|
@@ -2099,7 +2118,8 @@ var ActaDeposit = class {
|
|
|
2099
2118
|
feeInclusive,
|
|
2100
2119
|
receiver,
|
|
2101
2120
|
signerAddress,
|
|
2102
|
-
token: tokenSymbol
|
|
2121
|
+
token: tokenSymbol,
|
|
2122
|
+
feebps: 10
|
|
2103
2123
|
});
|
|
2104
2124
|
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
2105
2125
|
let paymentAmount = (amountToTransfer + estimatedGasCostInToken * BigInt(2)) * BigInt(count != null ? count : 1);
|
|
@@ -2119,6 +2139,7 @@ var import_viem6 = require("viem");
|
|
|
2119
2139
|
var transactionServiceUrl2 = "https://api.acta.link/transaction/v1/";
|
|
2120
2140
|
var ActaBilling = class {
|
|
2121
2141
|
constructor(parameters) {
|
|
2142
|
+
this.feeInclusive = true;
|
|
2122
2143
|
this.count = 0;
|
|
2123
2144
|
this.intervalUnit = void 0;
|
|
2124
2145
|
this.startDate = void 0;
|
|
@@ -2127,7 +2148,7 @@ var ActaBilling = class {
|
|
|
2127
2148
|
this.status = "not_started";
|
|
2128
2149
|
this.serviceType = "deposit";
|
|
2129
2150
|
this.allowMaxTokenApproval = false;
|
|
2130
|
-
var _a;
|
|
2151
|
+
var _a, _b;
|
|
2131
2152
|
this.connectorType = parameters.connectorType;
|
|
2132
2153
|
this.walletClient = parameters.walletClient;
|
|
2133
2154
|
this.signerAddress = parameters.signerAddress;
|
|
@@ -2135,13 +2156,13 @@ var ActaBilling = class {
|
|
|
2135
2156
|
this.token = parameters.token;
|
|
2136
2157
|
this.amount = parameters.amount;
|
|
2137
2158
|
this.receiver = parameters.receiver;
|
|
2138
|
-
this.feeInclusive = parameters.feeInclusive;
|
|
2159
|
+
this.feeInclusive = (_a = parameters.feeInclusive) != null ? _a : true;
|
|
2139
2160
|
this.paymentType = parameters.paymentType;
|
|
2140
2161
|
this.count = parameters.count;
|
|
2141
2162
|
this.intervalUnit = parameters.intervalUnit;
|
|
2142
2163
|
this.startDate = parameters.startDate;
|
|
2143
2164
|
this.endDate = parameters.endDate;
|
|
2144
|
-
this.allowMaxTokenApproval = (
|
|
2165
|
+
this.allowMaxTokenApproval = (_b = parameters.allowMaxTokenApproval) != null ? _b : false;
|
|
2145
2166
|
this.serviceType = parameters.serviceType;
|
|
2146
2167
|
this.viemClient = new ViemClient(this.chainId, this.walletClient);
|
|
2147
2168
|
this.account = new ActaAccount(
|
|
@@ -2209,7 +2230,8 @@ var ActaBilling = class {
|
|
|
2209
2230
|
amount,
|
|
2210
2231
|
receiver,
|
|
2211
2232
|
feeInclusive,
|
|
2212
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval
|
|
2233
|
+
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2234
|
+
feebps: 20
|
|
2213
2235
|
});
|
|
2214
2236
|
const txn = yield executeSinglePaymentAPICall(
|
|
2215
2237
|
`${transactionServiceUrl2}execute/single`,
|
|
@@ -2274,7 +2296,8 @@ var ActaBilling = class {
|
|
|
2274
2296
|
startDate,
|
|
2275
2297
|
endDate,
|
|
2276
2298
|
receiver,
|
|
2277
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval
|
|
2299
|
+
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2300
|
+
feebps: 20
|
|
2278
2301
|
});
|
|
2279
2302
|
const txn = yield scheduleRecurringPaymentsAPICall(
|
|
2280
2303
|
`${transactionServiceUrl2}schedule/recurring`,
|
|
@@ -2317,7 +2340,8 @@ var ActaBilling = class {
|
|
|
2317
2340
|
feeInclusive,
|
|
2318
2341
|
receiver,
|
|
2319
2342
|
signerAddress,
|
|
2320
|
-
token: tokenSymbol
|
|
2343
|
+
token: tokenSymbol,
|
|
2344
|
+
feebps: 20
|
|
2321
2345
|
});
|
|
2322
2346
|
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
2323
2347
|
let paymentAmount = (amountToTransfer + estimatedGasCostInToken * BigInt(2)) * BigInt(count != null ? count : 1);
|
|
@@ -2410,6 +2434,10 @@ var ActaBatch = class {
|
|
|
2410
2434
|
walletClient,
|
|
2411
2435
|
instructionId
|
|
2412
2436
|
} = parameters;
|
|
2437
|
+
let isFeeInclusive = false;
|
|
2438
|
+
if (feeInclusive) {
|
|
2439
|
+
isFeeInclusive = true;
|
|
2440
|
+
}
|
|
2413
2441
|
const { envBatchServiceUrl } = returnEnvUrl(chainId);
|
|
2414
2442
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2415
2443
|
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
@@ -2452,12 +2480,13 @@ var ActaBatch = class {
|
|
|
2452
2480
|
userOperation
|
|
2453
2481
|
} = yield account.estimateSingleBatchPaymentGas({
|
|
2454
2482
|
chainId,
|
|
2455
|
-
feeInclusive,
|
|
2483
|
+
feeInclusive: isFeeInclusive,
|
|
2456
2484
|
signerAddress,
|
|
2457
2485
|
token: token2,
|
|
2458
2486
|
walletClient,
|
|
2459
2487
|
receivers,
|
|
2460
|
-
totalAmount: totalAmountParsed
|
|
2488
|
+
totalAmount: totalAmountParsed,
|
|
2489
|
+
feebps: 20
|
|
2461
2490
|
});
|
|
2462
2491
|
return {
|
|
2463
2492
|
estimatedGasCostInToken,
|
|
@@ -2488,6 +2517,10 @@ var ActaBatch = class {
|
|
|
2488
2517
|
allowMaxTokenApproval,
|
|
2489
2518
|
instructionId
|
|
2490
2519
|
} = params;
|
|
2520
|
+
let isFeeInclusive = false;
|
|
2521
|
+
if (feeInclusive) {
|
|
2522
|
+
isFeeInclusive = true;
|
|
2523
|
+
}
|
|
2491
2524
|
const { envBatchServiceUrl } = returnEnvUrl(chainId);
|
|
2492
2525
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2493
2526
|
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
@@ -2526,11 +2559,12 @@ var ActaBatch = class {
|
|
|
2526
2559
|
signerAddress,
|
|
2527
2560
|
chainId,
|
|
2528
2561
|
token: tokenSymbol,
|
|
2529
|
-
feeInclusive,
|
|
2562
|
+
feeInclusive: isFeeInclusive,
|
|
2530
2563
|
receivers,
|
|
2531
2564
|
totalAmount: totalAmountParsed,
|
|
2532
2565
|
walletClient,
|
|
2533
|
-
allowMaxTokenApproval
|
|
2566
|
+
allowMaxTokenApproval,
|
|
2567
|
+
feebps: 20
|
|
2534
2568
|
});
|
|
2535
2569
|
const txn = yield executeSingleBatchPaymentAPICall(
|
|
2536
2570
|
`${envBatchServiceUrl}execute/single/batch`,
|
|
@@ -2541,7 +2575,7 @@ var ActaBatch = class {
|
|
|
2541
2575
|
chainId,
|
|
2542
2576
|
tokenAddress: tokenData.address,
|
|
2543
2577
|
amount: (0, import_viem7.toHex)(totalAmountParsed),
|
|
2544
|
-
feeInclusive,
|
|
2578
|
+
feeInclusive: isFeeInclusive,
|
|
2545
2579
|
serviceType: "batch"
|
|
2546
2580
|
},
|
|
2547
2581
|
serviceParams
|
|
@@ -2569,6 +2603,10 @@ var ActaBatch = class {
|
|
|
2569
2603
|
instructionId,
|
|
2570
2604
|
executionTime
|
|
2571
2605
|
} = params;
|
|
2606
|
+
let isFeeInclusive = false;
|
|
2607
|
+
if (feeInclusive) {
|
|
2608
|
+
isFeeInclusive = true;
|
|
2609
|
+
}
|
|
2572
2610
|
const { envBatchServiceUrl } = returnEnvUrl(chainId);
|
|
2573
2611
|
if (executionTime <= Date.now() + 1e3 * 60 * 2) {
|
|
2574
2612
|
throw new Error(
|
|
@@ -2612,12 +2650,13 @@ var ActaBatch = class {
|
|
|
2612
2650
|
signerAddress,
|
|
2613
2651
|
chainId,
|
|
2614
2652
|
token: tokenSymbol,
|
|
2615
|
-
feeInclusive,
|
|
2653
|
+
feeInclusive: isFeeInclusive,
|
|
2616
2654
|
receivers,
|
|
2617
2655
|
totalAmount: totalAmountParsed,
|
|
2618
2656
|
walletClient,
|
|
2619
2657
|
allowMaxTokenApproval,
|
|
2620
|
-
count: 1
|
|
2658
|
+
count: 1,
|
|
2659
|
+
feebps: 20
|
|
2621
2660
|
});
|
|
2622
2661
|
const txn = yield executeScheduleBatchPaymentAPICall(
|
|
2623
2662
|
`${envBatchServiceUrl}execute/schedule/batch`,
|
|
@@ -2627,7 +2666,7 @@ var ActaBatch = class {
|
|
|
2627
2666
|
chainId,
|
|
2628
2667
|
tokenAddress: tokenData.address,
|
|
2629
2668
|
amount: (0, import_viem7.toHex)(totalAmountParsed),
|
|
2630
|
-
feeInclusive,
|
|
2669
|
+
feeInclusive: isFeeInclusive,
|
|
2631
2670
|
serviceType: "batch",
|
|
2632
2671
|
amountExclusive: (0, import_viem7.toHex)(amountExclusive),
|
|
2633
2672
|
approval,
|
|
@@ -2648,6 +2687,125 @@ var ActaBatch = class {
|
|
|
2648
2687
|
}
|
|
2649
2688
|
});
|
|
2650
2689
|
}
|
|
2690
|
+
createSingleBatchPaymentWithoutKey(params, serviceParams) {
|
|
2691
|
+
return __async(this, null, function* () {
|
|
2692
|
+
try {
|
|
2693
|
+
const {
|
|
2694
|
+
chainId,
|
|
2695
|
+
feeInclusive,
|
|
2696
|
+
signerAddress,
|
|
2697
|
+
token: tokenSymbol,
|
|
2698
|
+
walletClient,
|
|
2699
|
+
allowMaxTokenApproval,
|
|
2700
|
+
receivers,
|
|
2701
|
+
totalAmount
|
|
2702
|
+
} = params;
|
|
2703
|
+
let isFeeInclusive = false;
|
|
2704
|
+
if (feeInclusive) {
|
|
2705
|
+
isFeeInclusive = true;
|
|
2706
|
+
}
|
|
2707
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2708
|
+
if (!tokenData) {
|
|
2709
|
+
throw new Error("Token not supported");
|
|
2710
|
+
}
|
|
2711
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2712
|
+
const account = new ActaAccount(
|
|
2713
|
+
chainId,
|
|
2714
|
+
viemClient.publicClient(),
|
|
2715
|
+
walletClient
|
|
2716
|
+
);
|
|
2717
|
+
console.log("signing");
|
|
2718
|
+
const rpcParameters = yield account.signSingleBatchOperation({
|
|
2719
|
+
signerAddress,
|
|
2720
|
+
chainId,
|
|
2721
|
+
token: tokenSymbol,
|
|
2722
|
+
feeInclusive: isFeeInclusive,
|
|
2723
|
+
receivers,
|
|
2724
|
+
totalAmount,
|
|
2725
|
+
walletClient,
|
|
2726
|
+
allowMaxTokenApproval,
|
|
2727
|
+
feebps: 20
|
|
2728
|
+
});
|
|
2729
|
+
return {
|
|
2730
|
+
senderAddress: signerAddress,
|
|
2731
|
+
chainId,
|
|
2732
|
+
tokenAddress: tokenData.address,
|
|
2733
|
+
amount: (0, import_viem7.toHex)(totalAmount),
|
|
2734
|
+
feeInclusive: isFeeInclusive,
|
|
2735
|
+
serviceType: "batch",
|
|
2736
|
+
sessionId: serviceParams.sessionId,
|
|
2737
|
+
rpcParameters
|
|
2738
|
+
};
|
|
2739
|
+
} catch (error) {
|
|
2740
|
+
if (error instanceof Error) {
|
|
2741
|
+
throw new Error(error.message);
|
|
2742
|
+
}
|
|
2743
|
+
throw new Error("Failed to create payment.");
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
createScheduleBatchPaymentWithoutKey(params, serviceParams) {
|
|
2748
|
+
return __async(this, null, function* () {
|
|
2749
|
+
try {
|
|
2750
|
+
const {
|
|
2751
|
+
chainId,
|
|
2752
|
+
feeInclusive,
|
|
2753
|
+
signerAddress,
|
|
2754
|
+
token: tokenSymbol,
|
|
2755
|
+
walletClient,
|
|
2756
|
+
allowMaxTokenApproval,
|
|
2757
|
+
executionTime,
|
|
2758
|
+
receivers,
|
|
2759
|
+
totalAmount
|
|
2760
|
+
} = params;
|
|
2761
|
+
let isFeeInclusive = false;
|
|
2762
|
+
if (feeInclusive) {
|
|
2763
|
+
isFeeInclusive = true;
|
|
2764
|
+
}
|
|
2765
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2766
|
+
if (!tokenData) {
|
|
2767
|
+
throw new Error("Token not supported");
|
|
2768
|
+
}
|
|
2769
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2770
|
+
const account = new ActaAccount(
|
|
2771
|
+
chainId,
|
|
2772
|
+
viemClient.publicClient(),
|
|
2773
|
+
walletClient
|
|
2774
|
+
);
|
|
2775
|
+
console.log("signing");
|
|
2776
|
+
const { amountExclusive, approval } = yield account.signRecurringOrScheduleBatchPayments({
|
|
2777
|
+
signerAddress,
|
|
2778
|
+
chainId,
|
|
2779
|
+
token: tokenSymbol,
|
|
2780
|
+
feeInclusive: isFeeInclusive,
|
|
2781
|
+
receivers,
|
|
2782
|
+
totalAmount,
|
|
2783
|
+
walletClient,
|
|
2784
|
+
allowMaxTokenApproval,
|
|
2785
|
+
count: 1,
|
|
2786
|
+
feebps: 20
|
|
2787
|
+
});
|
|
2788
|
+
return {
|
|
2789
|
+
senderAddress: signerAddress,
|
|
2790
|
+
chainId,
|
|
2791
|
+
tokenAddress: tokenData.address,
|
|
2792
|
+
amount: (0, import_viem7.toHex)(totalAmount),
|
|
2793
|
+
feeInclusive: isFeeInclusive,
|
|
2794
|
+
serviceType: "batch",
|
|
2795
|
+
amountExclusive: (0, import_viem7.toHex)(amountExclusive),
|
|
2796
|
+
approval,
|
|
2797
|
+
executionAt: executionTime,
|
|
2798
|
+
sessionId: serviceParams.sessionId
|
|
2799
|
+
};
|
|
2800
|
+
} catch (error) {
|
|
2801
|
+
console.log(error);
|
|
2802
|
+
if (error instanceof Error) {
|
|
2803
|
+
throw new Error(error.message);
|
|
2804
|
+
}
|
|
2805
|
+
throw new Error("Failed to create payment.");
|
|
2806
|
+
}
|
|
2807
|
+
});
|
|
2808
|
+
}
|
|
2651
2809
|
};
|
|
2652
2810
|
|
|
2653
2811
|
// src/utils.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -52,7 +52,7 @@ interface AbstractPaymentParams {
|
|
|
52
52
|
token: "USDC" | "USDT" | "DAI" | "ETH" | "WETH" | "BNB" | "WBNB" | "USDCe" | "USDbC" | "EURC" | "POL" | "WPOL";
|
|
53
53
|
amount: bigint;
|
|
54
54
|
receiver: Address;
|
|
55
|
-
feeInclusive
|
|
55
|
+
feeInclusive?: boolean;
|
|
56
56
|
paymentType: "single" | "recurring" | "choose";
|
|
57
57
|
count?: number;
|
|
58
58
|
intervalUnit?: "5mins" | "day" | "week" | "month" | "year";
|
|
@@ -69,7 +69,9 @@ interface BillingClassParams extends AbstractPaymentParams {
|
|
|
69
69
|
interface BatchClassParams {
|
|
70
70
|
APIKey: string;
|
|
71
71
|
}
|
|
72
|
-
type EstimateSinglePaymentGasParameters = Omit<AbstractPaymentParams, "connectorType" | "signer" | "walletClient" | "serviceType" | "paymentType" | "count" | "intervalUnit" | "startDate" | "endDate" | "serviceUrl" | "serviceParams" | "serviceSessionParams"
|
|
72
|
+
type EstimateSinglePaymentGasParameters = Omit<AbstractPaymentParams, "connectorType" | "signer" | "walletClient" | "serviceType" | "paymentType" | "count" | "intervalUnit" | "startDate" | "endDate" | "serviceUrl" | "serviceParams" | "serviceSessionParams"> & {
|
|
73
|
+
feebps: 20 | 10 | 15;
|
|
74
|
+
};
|
|
73
75
|
type EstimateSingleBatchPaymentGasParameters = Omit<AbstractPaymentParams, "connectorType" | "signer" | "serviceType" | "paymentType" | "count" | "intervalUnit" | "startDate" | "endDate" | "serviceUrl" | "serviceParams" | "serviceSessionParams" | "receiver" | "amount" | "token"> & {
|
|
74
76
|
receivers: {
|
|
75
77
|
address: Address;
|
|
@@ -77,6 +79,7 @@ type EstimateSingleBatchPaymentGasParameters = Omit<AbstractPaymentParams, "conn
|
|
|
77
79
|
}[];
|
|
78
80
|
token: "USDC" | "USDT";
|
|
79
81
|
totalAmount: bigint;
|
|
82
|
+
feebps: 20 | 10 | 15;
|
|
80
83
|
};
|
|
81
84
|
type CalculateSingleBatchPaymentGasParameters = Omit<AbstractPaymentParams, "connectorType" | "signer" | "serviceType" | "paymentType" | "count" | "intervalUnit" | "startDate" | "endDate" | "serviceUrl" | "serviceParams" | "serviceSessionParams" | "receiver" | "amount" | "receivers" | "token"> & {
|
|
82
85
|
token: "USDC" | "USDT";
|
|
@@ -142,6 +145,7 @@ type PermissionAccountParams = {
|
|
|
142
145
|
};
|
|
143
146
|
type SinglePaymentParamsType = Omit<AbstractPaymentParams, "connectorType" | "signer" | "walletClient" | "serviceType" | "serviceUrl" | "serviceSessionParams" | "count" | "intervalUnit" | "startDate" | "endDate" | "paymentType"> & {
|
|
144
147
|
allowMaxTokenApproval?: boolean;
|
|
148
|
+
feebps: 20 | 10 | 15;
|
|
145
149
|
};
|
|
146
150
|
type SingleBatchPaymentParamsType = Omit<AbstractPaymentParams, "connectorType" | "signer" | "serviceType" | "serviceUrl" | "serviceSessionParams" | "count" | "intervalUnit" | "startDate" | "endDate" | "paymentType" | "receiver" | "amount" | "token"> & {
|
|
147
151
|
allowMaxTokenApproval?: boolean;
|
|
@@ -151,21 +155,38 @@ type SingleBatchPaymentParamsType = Omit<AbstractPaymentParams, "connectorType"
|
|
|
151
155
|
}[];
|
|
152
156
|
token: "USDC" | "USDT";
|
|
153
157
|
totalAmount: bigint;
|
|
158
|
+
feebps: 20 | 10 | 15;
|
|
154
159
|
};
|
|
155
160
|
type ScheduleOrRecurringBatchPaymentParamsType = SingleBatchPaymentParamsType & {
|
|
156
161
|
count: number;
|
|
162
|
+
feebps: 20 | 10 | 15;
|
|
157
163
|
};
|
|
158
164
|
type SingleBatchPaymentClassParamsType = Omit<AbstractPaymentParams, "connectorType" | "signer" | "serviceType" | "serviceUrl" | "serviceSessionParams" | "count" | "intervalUnit" | "startDate" | "endDate" | "paymentType" | "receiver" | "amount" | "token"> & {
|
|
159
165
|
allowMaxTokenApproval?: boolean;
|
|
160
166
|
token: "USDC" | "USDT";
|
|
161
167
|
instructionId: string;
|
|
162
168
|
};
|
|
169
|
+
type SingleBatchPaymentWithoutKeyClassParamsType = Omit<SingleBatchPaymentClassParamsType, "instructionId"> & {
|
|
170
|
+
receivers: {
|
|
171
|
+
address: Address;
|
|
172
|
+
amount: bigint;
|
|
173
|
+
}[];
|
|
174
|
+
totalAmount: bigint;
|
|
175
|
+
};
|
|
163
176
|
type ScheduleBatchPaymentClassParamsType = SingleBatchPaymentClassParamsType & {
|
|
164
177
|
executionTime: number;
|
|
165
178
|
};
|
|
179
|
+
type ScheduleBatchPaymentWithoutKeyClassParamsType = Omit<ScheduleBatchPaymentClassParamsType, "instructionId"> & {
|
|
180
|
+
receivers: {
|
|
181
|
+
address: Address;
|
|
182
|
+
amount: bigint;
|
|
183
|
+
}[];
|
|
184
|
+
totalAmount: bigint;
|
|
185
|
+
};
|
|
166
186
|
type RecurringPaymentParamsType = Omit<AbstractPaymentParams, "connectorType" | "signer" | "walletClient" | "serviceType" | "paymentType" | "serviceUrl" | "serviceSessionParams"> & {
|
|
167
187
|
endDate?: number;
|
|
168
188
|
allowMaxTokenApproval?: boolean;
|
|
189
|
+
feebps: 20 | 10 | 15;
|
|
169
190
|
};
|
|
170
191
|
|
|
171
192
|
declare const arbitrumETH: Token;
|
|
@@ -1512,6 +1533,32 @@ declare class ActaBatch {
|
|
|
1512
1533
|
createScheduleBatchPayment(params: ScheduleBatchPaymentClassParamsType, serviceParams: {
|
|
1513
1534
|
sessionId: string;
|
|
1514
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
|
+
}>;
|
|
1515
1562
|
}
|
|
1516
1563
|
|
|
1517
1564
|
declare class ActaAccount {
|
|
@@ -12015,4 +12062,4 @@ declare function createBatchSessionAPICall(url: string, APIKey: string, params:
|
|
|
12015
12062
|
}): Promise<any>;
|
|
12016
12063
|
declare function fetchBatchInstructionDetails(url: string, APIKey: string): Promise<any>;
|
|
12017
12064
|
|
|
12018
|
-
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 };
|