@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.js
CHANGED
|
@@ -593,7 +593,7 @@ import {
|
|
|
593
593
|
VALIDATOR_TYPE
|
|
594
594
|
} from "@zerodev/sdk/constants";
|
|
595
595
|
import { signerToEcdsaValidator } from "@zerodev/ecdsa-validator";
|
|
596
|
-
import { createSmartAccountClient } from "permissionless";
|
|
596
|
+
import { createSmartAccountClient, getRequiredPrefund } from "permissionless";
|
|
597
597
|
import { createPimlicoClient } from "permissionless/clients/pimlico";
|
|
598
598
|
|
|
599
599
|
// src/rpc.ts
|
|
@@ -806,7 +806,8 @@ var ActaAccount = class {
|
|
|
806
806
|
chainId,
|
|
807
807
|
token: tokenSymbol,
|
|
808
808
|
amount,
|
|
809
|
-
receiver
|
|
809
|
+
receiver,
|
|
810
|
+
feebps
|
|
810
811
|
} = parameters;
|
|
811
812
|
if (amount <= BigInt(0)) {
|
|
812
813
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -822,11 +823,6 @@ var ActaAccount = class {
|
|
|
822
823
|
if (!token2) {
|
|
823
824
|
throw new Error("Token not found.");
|
|
824
825
|
}
|
|
825
|
-
const quotes = yield pimlicoClient.getTokenQuotes({
|
|
826
|
-
tokens: [token2.address],
|
|
827
|
-
chain: getChainById(chainId)
|
|
828
|
-
});
|
|
829
|
-
const { postOpGas, exchangeRate, paymaster } = quotes[0];
|
|
830
826
|
const userOperation = yield accountClient.prepareUserOperation({
|
|
831
827
|
calls: [
|
|
832
828
|
{
|
|
@@ -847,22 +843,31 @@ var ActaAccount = class {
|
|
|
847
843
|
}
|
|
848
844
|
]
|
|
849
845
|
});
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
);
|
|
854
|
-
const
|
|
855
|
-
|
|
856
|
-
|
|
846
|
+
const quotes = yield pimlicoClient.getTokenQuotes({
|
|
847
|
+
tokens: [token2.address],
|
|
848
|
+
chain: getChainById(chainId)
|
|
849
|
+
});
|
|
850
|
+
const userOperationMaxCost = getRequiredPrefund({
|
|
851
|
+
userOperation,
|
|
852
|
+
entryPointVersion: "0.7"
|
|
853
|
+
});
|
|
854
|
+
const postOpGas = quotes[0].postOpGas;
|
|
855
|
+
const exchangeRate = quotes[0].exchangeRate;
|
|
856
|
+
const exchangeRateNativeToUsd = quotes[0].exchangeRateNativeToUsd;
|
|
857
|
+
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
858
|
+
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
859
|
+
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
860
|
+
const ActalinkFeesInToken = amount * BigInt(feebps) / BigInt(1e4);
|
|
861
|
+
const estimatedTotalFeesInToken = costInToken + ActalinkFeesInToken;
|
|
857
862
|
const feeInclusiveAmountInToken = amount - estimatedTotalFeesInToken;
|
|
858
863
|
const feeExclusiveAmountInToken = amount + estimatedTotalFeesInToken;
|
|
859
864
|
return {
|
|
860
|
-
estimatedGasCostInToken,
|
|
865
|
+
estimatedGasCostInToken: costInToken,
|
|
861
866
|
ActalinkFeesInToken,
|
|
862
867
|
estimatedTotalFeesInToken,
|
|
863
868
|
feeInclusiveAmountInToken,
|
|
864
869
|
feeExclusiveAmountInToken,
|
|
865
|
-
paymaster,
|
|
870
|
+
paymaster: quotes[0].paymaster,
|
|
866
871
|
userOperation
|
|
867
872
|
};
|
|
868
873
|
});
|
|
@@ -876,7 +881,8 @@ var ActaAccount = class {
|
|
|
876
881
|
receivers,
|
|
877
882
|
feeInclusive,
|
|
878
883
|
walletClient,
|
|
879
|
-
totalAmount
|
|
884
|
+
totalAmount,
|
|
885
|
+
feebps
|
|
880
886
|
} = parameters;
|
|
881
887
|
if (totalAmount <= BigInt(0)) {
|
|
882
888
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -892,14 +898,6 @@ var ActaAccount = class {
|
|
|
892
898
|
if (!token2) {
|
|
893
899
|
throw new Error("Token not found.");
|
|
894
900
|
}
|
|
895
|
-
console.log(`fromAddress: ${fromAddress}`);
|
|
896
|
-
const quotes = yield pimlicoClient.getTokenQuotes({
|
|
897
|
-
tokens: [token2.address],
|
|
898
|
-
chain: getChainById(chainId)
|
|
899
|
-
});
|
|
900
|
-
const { postOpGas, exchangeRate, paymaster } = quotes[0];
|
|
901
|
-
console.log("preparing");
|
|
902
|
-
console.log(token2.address);
|
|
903
901
|
const receiversData = receivers.map((r) => {
|
|
904
902
|
return {
|
|
905
903
|
to: getAddress2(token2.address),
|
|
@@ -924,17 +922,27 @@ var ActaAccount = class {
|
|
|
924
922
|
}
|
|
925
923
|
]
|
|
926
924
|
});
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
);
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
|
|
925
|
+
const quotes = yield pimlicoClient.getTokenQuotes({
|
|
926
|
+
tokens: [token2.address],
|
|
927
|
+
chain: getChainById(chainId)
|
|
928
|
+
});
|
|
929
|
+
const userOperationMaxCost = getRequiredPrefund({
|
|
930
|
+
userOperation,
|
|
931
|
+
entryPointVersion: "0.7"
|
|
932
|
+
});
|
|
933
|
+
const postOpGas = quotes[0].postOpGas;
|
|
934
|
+
const exchangeRate = quotes[0].exchangeRate;
|
|
935
|
+
const exchangeRateNativeToUsd = quotes[0].exchangeRateNativeToUsd;
|
|
936
|
+
const paymaster = quotes[0].paymaster;
|
|
937
|
+
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
938
|
+
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
939
|
+
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
940
|
+
const ActalinkFeesInToken = totalAmount * BigInt(feebps) / BigInt(1e4);
|
|
941
|
+
const estimatedTotalFeesInToken = costInToken + ActalinkFeesInToken;
|
|
934
942
|
const feeInclusiveAmountInToken = totalAmount - estimatedTotalFeesInToken;
|
|
935
943
|
const feeExclusiveAmountInToken = totalAmount + estimatedTotalFeesInToken;
|
|
936
944
|
return {
|
|
937
|
-
estimatedGasCostInToken,
|
|
945
|
+
estimatedGasCostInToken: costInToken,
|
|
938
946
|
ActalinkFeesInToken,
|
|
939
947
|
estimatedTotalFeesInToken,
|
|
940
948
|
feeInclusiveAmountInToken,
|
|
@@ -957,7 +965,8 @@ var ActaAccount = class {
|
|
|
957
965
|
amount,
|
|
958
966
|
receiver,
|
|
959
967
|
feeInclusive,
|
|
960
|
-
allowMaxTokenApproval
|
|
968
|
+
allowMaxTokenApproval,
|
|
969
|
+
feebps
|
|
961
970
|
} = singlePaymentParams;
|
|
962
971
|
if (amount <= BigInt(0)) {
|
|
963
972
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -983,7 +992,8 @@ var ActaAccount = class {
|
|
|
983
992
|
token: tokenSymbol,
|
|
984
993
|
amount,
|
|
985
994
|
receiver,
|
|
986
|
-
feeInclusive
|
|
995
|
+
feeInclusive,
|
|
996
|
+
feebps
|
|
987
997
|
});
|
|
988
998
|
const account = yield this.createAccount();
|
|
989
999
|
const { accountClient } = yield this.createAccountHelpers();
|
|
@@ -1006,7 +1016,7 @@ var ActaAccount = class {
|
|
|
1006
1016
|
args: [
|
|
1007
1017
|
fromAddress,
|
|
1008
1018
|
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
1009
|
-
|
|
1019
|
+
estimatedTotalFeesInToken
|
|
1010
1020
|
]
|
|
1011
1021
|
},
|
|
1012
1022
|
{
|
|
@@ -1046,7 +1056,8 @@ var ActaAccount = class {
|
|
|
1046
1056
|
feeInclusive,
|
|
1047
1057
|
allowMaxTokenApproval,
|
|
1048
1058
|
totalAmount,
|
|
1049
|
-
walletClient
|
|
1059
|
+
walletClient,
|
|
1060
|
+
feebps
|
|
1050
1061
|
} = singlePaymentParams;
|
|
1051
1062
|
if (totalAmount <= BigInt(0)) {
|
|
1052
1063
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -1074,7 +1085,8 @@ var ActaAccount = class {
|
|
|
1074
1085
|
receivers,
|
|
1075
1086
|
feeInclusive,
|
|
1076
1087
|
totalAmount,
|
|
1077
|
-
walletClient
|
|
1088
|
+
walletClient,
|
|
1089
|
+
feebps
|
|
1078
1090
|
});
|
|
1079
1091
|
const account = yield this.createAccount();
|
|
1080
1092
|
const { accountClient } = yield this.createAccountHelpers();
|
|
@@ -1107,7 +1119,7 @@ var ActaAccount = class {
|
|
|
1107
1119
|
args: [
|
|
1108
1120
|
fromAddress,
|
|
1109
1121
|
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
1110
|
-
|
|
1122
|
+
estimatedTotalFeesInToken
|
|
1111
1123
|
]
|
|
1112
1124
|
}
|
|
1113
1125
|
]
|
|
@@ -1143,7 +1155,8 @@ var ActaAccount = class {
|
|
|
1143
1155
|
intervalUnit,
|
|
1144
1156
|
startDate,
|
|
1145
1157
|
endDate,
|
|
1146
|
-
allowMaxTokenApproval
|
|
1158
|
+
allowMaxTokenApproval,
|
|
1159
|
+
feebps
|
|
1147
1160
|
} = recurringPaymentParams;
|
|
1148
1161
|
if (amount <= BigInt(0)) {
|
|
1149
1162
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -1193,7 +1206,8 @@ var ActaAccount = class {
|
|
|
1193
1206
|
token: tokenSymbol,
|
|
1194
1207
|
amount,
|
|
1195
1208
|
receiver,
|
|
1196
|
-
feeInclusive
|
|
1209
|
+
feeInclusive,
|
|
1210
|
+
feebps
|
|
1197
1211
|
});
|
|
1198
1212
|
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
1199
1213
|
const receiverAmount = feeInclusive ? feeInclusiveAmountInToken : amount;
|
|
@@ -1272,7 +1286,8 @@ var ActaAccount = class {
|
|
|
1272
1286
|
allowMaxTokenApproval,
|
|
1273
1287
|
receivers,
|
|
1274
1288
|
totalAmount,
|
|
1275
|
-
walletClient
|
|
1289
|
+
walletClient,
|
|
1290
|
+
feebps
|
|
1276
1291
|
} = paymentParams;
|
|
1277
1292
|
if (signerAddress === void 0) {
|
|
1278
1293
|
throw new Error("signer address is not provided.");
|
|
@@ -1319,7 +1334,8 @@ var ActaAccount = class {
|
|
|
1319
1334
|
receivers,
|
|
1320
1335
|
feeInclusive,
|
|
1321
1336
|
totalAmount,
|
|
1322
|
-
walletClient
|
|
1337
|
+
walletClient,
|
|
1338
|
+
feebps
|
|
1323
1339
|
});
|
|
1324
1340
|
const amountToTransfer = feeInclusive ? totalAmount : feeExclusiveAmountInToken;
|
|
1325
1341
|
const receiverAmount = feeInclusive ? feeInclusiveAmountInToken : totalAmount;
|
|
@@ -1701,6 +1717,7 @@ var transactionServiceUrl = "https://api.acta.link/transaction/v1/";
|
|
|
1701
1717
|
var depositServiceUrl = "https://api.acta.link/deposit/v1/";
|
|
1702
1718
|
var ActaDeposit = class {
|
|
1703
1719
|
constructor(parameters) {
|
|
1720
|
+
this.feeInclusive = false;
|
|
1704
1721
|
this.count = 0;
|
|
1705
1722
|
this.intervalUnit = void 0;
|
|
1706
1723
|
this.startDate = void 0;
|
|
@@ -1710,7 +1727,7 @@ var ActaDeposit = class {
|
|
|
1710
1727
|
this.status = "not_started";
|
|
1711
1728
|
this.serviceType = "deposit";
|
|
1712
1729
|
this.allowMaxTokenApproval = false;
|
|
1713
|
-
var _a, _b;
|
|
1730
|
+
var _a, _b, _c;
|
|
1714
1731
|
this.connectorType = parameters.connectorType;
|
|
1715
1732
|
this.walletClient = parameters.walletClient;
|
|
1716
1733
|
this.signerAddress = parameters.signerAddress;
|
|
@@ -1718,14 +1735,14 @@ var ActaDeposit = class {
|
|
|
1718
1735
|
this.token = parameters.token;
|
|
1719
1736
|
this.amount = parameters.amount;
|
|
1720
1737
|
this.receiver = parameters.receiver;
|
|
1721
|
-
this.feeInclusive = parameters.feeInclusive;
|
|
1738
|
+
this.feeInclusive = (_a = parameters.feeInclusive) != null ? _a : false;
|
|
1722
1739
|
this.paymentType = parameters.paymentType;
|
|
1723
1740
|
this.count = parameters.count;
|
|
1724
1741
|
this.intervalUnit = parameters.intervalUnit;
|
|
1725
1742
|
this.startDate = parameters.startDate;
|
|
1726
1743
|
this.endDate = parameters.endDate;
|
|
1727
|
-
this.depositSessionId = (
|
|
1728
|
-
this.allowMaxTokenApproval = (
|
|
1744
|
+
this.depositSessionId = (_b = parameters.depositSessionId) != null ? _b : "";
|
|
1745
|
+
this.allowMaxTokenApproval = (_c = parameters.allowMaxTokenApproval) != null ? _c : false;
|
|
1729
1746
|
this.viemClient = new ViemClient(this.chainId, this.walletClient);
|
|
1730
1747
|
this.account = new ActaAccount(
|
|
1731
1748
|
this.chainId,
|
|
@@ -1890,7 +1907,8 @@ var ActaDeposit = class {
|
|
|
1890
1907
|
amount,
|
|
1891
1908
|
receiver,
|
|
1892
1909
|
feeInclusive,
|
|
1893
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval
|
|
1910
|
+
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
1911
|
+
feebps: 10
|
|
1894
1912
|
});
|
|
1895
1913
|
const txn = yield executeSinglePaymentAPICall(
|
|
1896
1914
|
`${transactionServiceUrl}execute/single`,
|
|
@@ -1983,7 +2001,8 @@ var ActaDeposit = class {
|
|
|
1983
2001
|
startDate,
|
|
1984
2002
|
endDate,
|
|
1985
2003
|
receiver,
|
|
1986
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval
|
|
2004
|
+
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2005
|
+
feebps: 20
|
|
1987
2006
|
});
|
|
1988
2007
|
const txn = yield scheduleRecurringPaymentsAPICall(
|
|
1989
2008
|
`${transactionServiceUrl}schedule/recurring`,
|
|
@@ -2026,7 +2045,8 @@ var ActaDeposit = class {
|
|
|
2026
2045
|
feeInclusive,
|
|
2027
2046
|
receiver,
|
|
2028
2047
|
signerAddress,
|
|
2029
|
-
token: tokenSymbol
|
|
2048
|
+
token: tokenSymbol,
|
|
2049
|
+
feebps: 10
|
|
2030
2050
|
});
|
|
2031
2051
|
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
2032
2052
|
let paymentAmount = (amountToTransfer + estimatedGasCostInToken * BigInt(2)) * BigInt(count != null ? count : 1);
|
|
@@ -2046,6 +2066,7 @@ import { toHex as toHex3 } from "viem";
|
|
|
2046
2066
|
var transactionServiceUrl2 = "https://api.acta.link/transaction/v1/";
|
|
2047
2067
|
var ActaBilling = class {
|
|
2048
2068
|
constructor(parameters) {
|
|
2069
|
+
this.feeInclusive = true;
|
|
2049
2070
|
this.count = 0;
|
|
2050
2071
|
this.intervalUnit = void 0;
|
|
2051
2072
|
this.startDate = void 0;
|
|
@@ -2054,7 +2075,7 @@ var ActaBilling = class {
|
|
|
2054
2075
|
this.status = "not_started";
|
|
2055
2076
|
this.serviceType = "deposit";
|
|
2056
2077
|
this.allowMaxTokenApproval = false;
|
|
2057
|
-
var _a;
|
|
2078
|
+
var _a, _b;
|
|
2058
2079
|
this.connectorType = parameters.connectorType;
|
|
2059
2080
|
this.walletClient = parameters.walletClient;
|
|
2060
2081
|
this.signerAddress = parameters.signerAddress;
|
|
@@ -2062,13 +2083,13 @@ var ActaBilling = class {
|
|
|
2062
2083
|
this.token = parameters.token;
|
|
2063
2084
|
this.amount = parameters.amount;
|
|
2064
2085
|
this.receiver = parameters.receiver;
|
|
2065
|
-
this.feeInclusive = parameters.feeInclusive;
|
|
2086
|
+
this.feeInclusive = (_a = parameters.feeInclusive) != null ? _a : true;
|
|
2066
2087
|
this.paymentType = parameters.paymentType;
|
|
2067
2088
|
this.count = parameters.count;
|
|
2068
2089
|
this.intervalUnit = parameters.intervalUnit;
|
|
2069
2090
|
this.startDate = parameters.startDate;
|
|
2070
2091
|
this.endDate = parameters.endDate;
|
|
2071
|
-
this.allowMaxTokenApproval = (
|
|
2092
|
+
this.allowMaxTokenApproval = (_b = parameters.allowMaxTokenApproval) != null ? _b : false;
|
|
2072
2093
|
this.serviceType = parameters.serviceType;
|
|
2073
2094
|
this.viemClient = new ViemClient(this.chainId, this.walletClient);
|
|
2074
2095
|
this.account = new ActaAccount(
|
|
@@ -2136,7 +2157,8 @@ var ActaBilling = class {
|
|
|
2136
2157
|
amount,
|
|
2137
2158
|
receiver,
|
|
2138
2159
|
feeInclusive,
|
|
2139
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval
|
|
2160
|
+
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2161
|
+
feebps: 20
|
|
2140
2162
|
});
|
|
2141
2163
|
const txn = yield executeSinglePaymentAPICall(
|
|
2142
2164
|
`${transactionServiceUrl2}execute/single`,
|
|
@@ -2201,7 +2223,8 @@ var ActaBilling = class {
|
|
|
2201
2223
|
startDate,
|
|
2202
2224
|
endDate,
|
|
2203
2225
|
receiver,
|
|
2204
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval
|
|
2226
|
+
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2227
|
+
feebps: 20
|
|
2205
2228
|
});
|
|
2206
2229
|
const txn = yield scheduleRecurringPaymentsAPICall(
|
|
2207
2230
|
`${transactionServiceUrl2}schedule/recurring`,
|
|
@@ -2244,7 +2267,8 @@ var ActaBilling = class {
|
|
|
2244
2267
|
feeInclusive,
|
|
2245
2268
|
receiver,
|
|
2246
2269
|
signerAddress,
|
|
2247
|
-
token: tokenSymbol
|
|
2270
|
+
token: tokenSymbol,
|
|
2271
|
+
feebps: 20
|
|
2248
2272
|
});
|
|
2249
2273
|
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
2250
2274
|
let paymentAmount = (amountToTransfer + estimatedGasCostInToken * BigInt(2)) * BigInt(count != null ? count : 1);
|
|
@@ -2342,6 +2366,10 @@ var ActaBatch = class {
|
|
|
2342
2366
|
walletClient,
|
|
2343
2367
|
instructionId
|
|
2344
2368
|
} = parameters;
|
|
2369
|
+
let isFeeInclusive = false;
|
|
2370
|
+
if (feeInclusive) {
|
|
2371
|
+
isFeeInclusive = true;
|
|
2372
|
+
}
|
|
2345
2373
|
const { envBatchServiceUrl } = returnEnvUrl(chainId);
|
|
2346
2374
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2347
2375
|
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
@@ -2384,12 +2412,13 @@ var ActaBatch = class {
|
|
|
2384
2412
|
userOperation
|
|
2385
2413
|
} = yield account.estimateSingleBatchPaymentGas({
|
|
2386
2414
|
chainId,
|
|
2387
|
-
feeInclusive,
|
|
2415
|
+
feeInclusive: isFeeInclusive,
|
|
2388
2416
|
signerAddress,
|
|
2389
2417
|
token: token2,
|
|
2390
2418
|
walletClient,
|
|
2391
2419
|
receivers,
|
|
2392
|
-
totalAmount: totalAmountParsed
|
|
2420
|
+
totalAmount: totalAmountParsed,
|
|
2421
|
+
feebps: 20
|
|
2393
2422
|
});
|
|
2394
2423
|
return {
|
|
2395
2424
|
estimatedGasCostInToken,
|
|
@@ -2420,6 +2449,10 @@ var ActaBatch = class {
|
|
|
2420
2449
|
allowMaxTokenApproval,
|
|
2421
2450
|
instructionId
|
|
2422
2451
|
} = params;
|
|
2452
|
+
let isFeeInclusive = false;
|
|
2453
|
+
if (feeInclusive) {
|
|
2454
|
+
isFeeInclusive = true;
|
|
2455
|
+
}
|
|
2423
2456
|
const { envBatchServiceUrl } = returnEnvUrl(chainId);
|
|
2424
2457
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2425
2458
|
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
@@ -2458,11 +2491,12 @@ var ActaBatch = class {
|
|
|
2458
2491
|
signerAddress,
|
|
2459
2492
|
chainId,
|
|
2460
2493
|
token: tokenSymbol,
|
|
2461
|
-
feeInclusive,
|
|
2494
|
+
feeInclusive: isFeeInclusive,
|
|
2462
2495
|
receivers,
|
|
2463
2496
|
totalAmount: totalAmountParsed,
|
|
2464
2497
|
walletClient,
|
|
2465
|
-
allowMaxTokenApproval
|
|
2498
|
+
allowMaxTokenApproval,
|
|
2499
|
+
feebps: 20
|
|
2466
2500
|
});
|
|
2467
2501
|
const txn = yield executeSingleBatchPaymentAPICall(
|
|
2468
2502
|
`${envBatchServiceUrl}execute/single/batch`,
|
|
@@ -2473,7 +2507,7 @@ var ActaBatch = class {
|
|
|
2473
2507
|
chainId,
|
|
2474
2508
|
tokenAddress: tokenData.address,
|
|
2475
2509
|
amount: toHex4(totalAmountParsed),
|
|
2476
|
-
feeInclusive,
|
|
2510
|
+
feeInclusive: isFeeInclusive,
|
|
2477
2511
|
serviceType: "batch"
|
|
2478
2512
|
},
|
|
2479
2513
|
serviceParams
|
|
@@ -2501,6 +2535,10 @@ var ActaBatch = class {
|
|
|
2501
2535
|
instructionId,
|
|
2502
2536
|
executionTime
|
|
2503
2537
|
} = params;
|
|
2538
|
+
let isFeeInclusive = false;
|
|
2539
|
+
if (feeInclusive) {
|
|
2540
|
+
isFeeInclusive = true;
|
|
2541
|
+
}
|
|
2504
2542
|
const { envBatchServiceUrl } = returnEnvUrl(chainId);
|
|
2505
2543
|
if (executionTime <= Date.now() + 1e3 * 60 * 2) {
|
|
2506
2544
|
throw new Error(
|
|
@@ -2544,12 +2582,13 @@ var ActaBatch = class {
|
|
|
2544
2582
|
signerAddress,
|
|
2545
2583
|
chainId,
|
|
2546
2584
|
token: tokenSymbol,
|
|
2547
|
-
feeInclusive,
|
|
2585
|
+
feeInclusive: isFeeInclusive,
|
|
2548
2586
|
receivers,
|
|
2549
2587
|
totalAmount: totalAmountParsed,
|
|
2550
2588
|
walletClient,
|
|
2551
2589
|
allowMaxTokenApproval,
|
|
2552
|
-
count: 1
|
|
2590
|
+
count: 1,
|
|
2591
|
+
feebps: 20
|
|
2553
2592
|
});
|
|
2554
2593
|
const txn = yield executeScheduleBatchPaymentAPICall(
|
|
2555
2594
|
`${envBatchServiceUrl}execute/schedule/batch`,
|
|
@@ -2559,7 +2598,7 @@ var ActaBatch = class {
|
|
|
2559
2598
|
chainId,
|
|
2560
2599
|
tokenAddress: tokenData.address,
|
|
2561
2600
|
amount: toHex4(totalAmountParsed),
|
|
2562
|
-
feeInclusive,
|
|
2601
|
+
feeInclusive: isFeeInclusive,
|
|
2563
2602
|
serviceType: "batch",
|
|
2564
2603
|
amountExclusive: toHex4(amountExclusive),
|
|
2565
2604
|
approval,
|
|
@@ -2580,6 +2619,125 @@ var ActaBatch = class {
|
|
|
2580
2619
|
}
|
|
2581
2620
|
});
|
|
2582
2621
|
}
|
|
2622
|
+
createSingleBatchPaymentWithoutKey(params, serviceParams) {
|
|
2623
|
+
return __async(this, null, function* () {
|
|
2624
|
+
try {
|
|
2625
|
+
const {
|
|
2626
|
+
chainId,
|
|
2627
|
+
feeInclusive,
|
|
2628
|
+
signerAddress,
|
|
2629
|
+
token: tokenSymbol,
|
|
2630
|
+
walletClient,
|
|
2631
|
+
allowMaxTokenApproval,
|
|
2632
|
+
receivers,
|
|
2633
|
+
totalAmount
|
|
2634
|
+
} = params;
|
|
2635
|
+
let isFeeInclusive = false;
|
|
2636
|
+
if (feeInclusive) {
|
|
2637
|
+
isFeeInclusive = true;
|
|
2638
|
+
}
|
|
2639
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2640
|
+
if (!tokenData) {
|
|
2641
|
+
throw new Error("Token not supported");
|
|
2642
|
+
}
|
|
2643
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2644
|
+
const account = new ActaAccount(
|
|
2645
|
+
chainId,
|
|
2646
|
+
viemClient.publicClient(),
|
|
2647
|
+
walletClient
|
|
2648
|
+
);
|
|
2649
|
+
console.log("signing");
|
|
2650
|
+
const rpcParameters = yield account.signSingleBatchOperation({
|
|
2651
|
+
signerAddress,
|
|
2652
|
+
chainId,
|
|
2653
|
+
token: tokenSymbol,
|
|
2654
|
+
feeInclusive: isFeeInclusive,
|
|
2655
|
+
receivers,
|
|
2656
|
+
totalAmount,
|
|
2657
|
+
walletClient,
|
|
2658
|
+
allowMaxTokenApproval,
|
|
2659
|
+
feebps: 20
|
|
2660
|
+
});
|
|
2661
|
+
return {
|
|
2662
|
+
senderAddress: signerAddress,
|
|
2663
|
+
chainId,
|
|
2664
|
+
tokenAddress: tokenData.address,
|
|
2665
|
+
amount: toHex4(totalAmount),
|
|
2666
|
+
feeInclusive: isFeeInclusive,
|
|
2667
|
+
serviceType: "batch",
|
|
2668
|
+
sessionId: serviceParams.sessionId,
|
|
2669
|
+
rpcParameters
|
|
2670
|
+
};
|
|
2671
|
+
} catch (error) {
|
|
2672
|
+
if (error instanceof Error) {
|
|
2673
|
+
throw new Error(error.message);
|
|
2674
|
+
}
|
|
2675
|
+
throw new Error("Failed to create payment.");
|
|
2676
|
+
}
|
|
2677
|
+
});
|
|
2678
|
+
}
|
|
2679
|
+
createScheduleBatchPaymentWithoutKey(params, serviceParams) {
|
|
2680
|
+
return __async(this, null, function* () {
|
|
2681
|
+
try {
|
|
2682
|
+
const {
|
|
2683
|
+
chainId,
|
|
2684
|
+
feeInclusive,
|
|
2685
|
+
signerAddress,
|
|
2686
|
+
token: tokenSymbol,
|
|
2687
|
+
walletClient,
|
|
2688
|
+
allowMaxTokenApproval,
|
|
2689
|
+
executionTime,
|
|
2690
|
+
receivers,
|
|
2691
|
+
totalAmount
|
|
2692
|
+
} = params;
|
|
2693
|
+
let isFeeInclusive = false;
|
|
2694
|
+
if (feeInclusive) {
|
|
2695
|
+
isFeeInclusive = true;
|
|
2696
|
+
}
|
|
2697
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2698
|
+
if (!tokenData) {
|
|
2699
|
+
throw new Error("Token not supported");
|
|
2700
|
+
}
|
|
2701
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2702
|
+
const account = new ActaAccount(
|
|
2703
|
+
chainId,
|
|
2704
|
+
viemClient.publicClient(),
|
|
2705
|
+
walletClient
|
|
2706
|
+
);
|
|
2707
|
+
console.log("signing");
|
|
2708
|
+
const { amountExclusive, approval } = yield account.signRecurringOrScheduleBatchPayments({
|
|
2709
|
+
signerAddress,
|
|
2710
|
+
chainId,
|
|
2711
|
+
token: tokenSymbol,
|
|
2712
|
+
feeInclusive: isFeeInclusive,
|
|
2713
|
+
receivers,
|
|
2714
|
+
totalAmount,
|
|
2715
|
+
walletClient,
|
|
2716
|
+
allowMaxTokenApproval,
|
|
2717
|
+
count: 1,
|
|
2718
|
+
feebps: 20
|
|
2719
|
+
});
|
|
2720
|
+
return {
|
|
2721
|
+
senderAddress: signerAddress,
|
|
2722
|
+
chainId,
|
|
2723
|
+
tokenAddress: tokenData.address,
|
|
2724
|
+
amount: toHex4(totalAmount),
|
|
2725
|
+
feeInclusive: isFeeInclusive,
|
|
2726
|
+
serviceType: "batch",
|
|
2727
|
+
amountExclusive: toHex4(amountExclusive),
|
|
2728
|
+
approval,
|
|
2729
|
+
executionAt: executionTime,
|
|
2730
|
+
sessionId: serviceParams.sessionId
|
|
2731
|
+
};
|
|
2732
|
+
} catch (error) {
|
|
2733
|
+
console.log(error);
|
|
2734
|
+
if (error instanceof Error) {
|
|
2735
|
+
throw new Error(error.message);
|
|
2736
|
+
}
|
|
2737
|
+
throw new Error("Failed to create payment.");
|
|
2738
|
+
}
|
|
2739
|
+
});
|
|
2740
|
+
}
|
|
2583
2741
|
};
|
|
2584
2742
|
|
|
2585
2743
|
// src/utils.ts
|