@actalink/commonlib 0.0.40-dev → 0.0.41
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 +608 -80
- package/dist/index.d.cts +3507 -2
- package/dist/index.d.ts +3507 -2
- package/dist/index.js +689 -154
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -257,7 +257,7 @@ var bscUSDT = token({
|
|
|
257
257
|
symbol: "USDT",
|
|
258
258
|
logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
|
|
259
259
|
});
|
|
260
|
-
var bscTokens = [bscUSDT];
|
|
260
|
+
var bscTokens = [bscUSDT, bscUSDC];
|
|
261
261
|
var ethereumETH = nativeETH(mainnet2.id);
|
|
262
262
|
var ethereumWETH = token({
|
|
263
263
|
chainId: mainnet2.id,
|
|
@@ -564,8 +564,8 @@ function getTokenByChainIdAndAddress(chainId, address) {
|
|
|
564
564
|
return token2;
|
|
565
565
|
}
|
|
566
566
|
|
|
567
|
-
// src/
|
|
568
|
-
import { toHex as
|
|
567
|
+
// src/flexdeposit.ts
|
|
568
|
+
import { toHex as toHex3, zeroAddress as zeroAddress3 } from "viem";
|
|
569
569
|
|
|
570
570
|
// src/account.ts
|
|
571
571
|
import {
|
|
@@ -573,13 +573,16 @@ import {
|
|
|
573
573
|
getAddress as getAddress2,
|
|
574
574
|
parseAbi as parseAbi2,
|
|
575
575
|
encodeFunctionData as encodeFunctionData2,
|
|
576
|
+
hexToBigInt,
|
|
576
577
|
concatHex,
|
|
577
|
-
pad
|
|
578
|
+
pad,
|
|
579
|
+
toHex
|
|
578
580
|
} from "viem";
|
|
579
581
|
import { parseAccount } from "viem/utils";
|
|
580
582
|
import {
|
|
581
583
|
createPaymasterClient,
|
|
582
|
-
formatUserOperationRequest
|
|
584
|
+
formatUserOperationRequest,
|
|
585
|
+
entryPoint07Address
|
|
583
586
|
} from "viem/account-abstraction";
|
|
584
587
|
import {
|
|
585
588
|
addressToEmptyAccount,
|
|
@@ -776,6 +779,48 @@ var ActaAccount = class {
|
|
|
776
779
|
};
|
|
777
780
|
});
|
|
778
781
|
}
|
|
782
|
+
createAccountHelperBatch() {
|
|
783
|
+
return __async(this, null, function* () {
|
|
784
|
+
const account = yield this.createAccount();
|
|
785
|
+
const entryPoint = getEntryPoint("0.7");
|
|
786
|
+
const paymasterClient = createPaymasterClient({
|
|
787
|
+
transport: http2(`https://api.acta.link/paymaster/v1/rpc`)
|
|
788
|
+
});
|
|
789
|
+
const pimlicoClient = createPimlicoClient({
|
|
790
|
+
chain: getChainById(this.chainId),
|
|
791
|
+
transport: http2(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
792
|
+
entryPoint
|
|
793
|
+
});
|
|
794
|
+
const accountClient = createSmartAccountClient({
|
|
795
|
+
account,
|
|
796
|
+
chain: getChainById(this.chainId),
|
|
797
|
+
paymaster: paymasterClient,
|
|
798
|
+
bundlerTransport: http2(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
799
|
+
userOperation: {
|
|
800
|
+
estimateFeesPerGas: () => __async(this, null, function* () {
|
|
801
|
+
return (yield pimlicoClient.getUserOperationGasPrice()).fast;
|
|
802
|
+
})
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
const kernelAccountClient = createKernelAccountClient({
|
|
806
|
+
account,
|
|
807
|
+
chain: getChainById(this.chainId),
|
|
808
|
+
paymaster: paymasterClient,
|
|
809
|
+
bundlerTransport: http2(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
810
|
+
userOperation: {
|
|
811
|
+
estimateFeesPerGas: () => __async(this, null, function* () {
|
|
812
|
+
return (yield pimlicoClient.getUserOperationGasPrice()).fast;
|
|
813
|
+
})
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
return {
|
|
817
|
+
paymasterClient,
|
|
818
|
+
pimlicoClient,
|
|
819
|
+
accountClient,
|
|
820
|
+
kernelAccountClient
|
|
821
|
+
};
|
|
822
|
+
});
|
|
823
|
+
}
|
|
779
824
|
estimateSinglePaymentGas(parameters) {
|
|
780
825
|
return __async(this, null, function* () {
|
|
781
826
|
const {
|
|
@@ -868,7 +913,7 @@ var ActaAccount = class {
|
|
|
868
913
|
throw new Error("Receivers not found for batch payment");
|
|
869
914
|
}
|
|
870
915
|
const account = yield this.createAccount();
|
|
871
|
-
const { accountClient, pimlicoClient } = yield this.
|
|
916
|
+
const { accountClient, pimlicoClient } = yield this.createAccountHelperBatch();
|
|
872
917
|
const fromAddress = signerAddress;
|
|
873
918
|
const smartAccountAddress = account.address;
|
|
874
919
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
@@ -899,18 +944,42 @@ var ActaAccount = class {
|
|
|
899
944
|
}
|
|
900
945
|
]
|
|
901
946
|
});
|
|
902
|
-
const
|
|
903
|
-
|
|
904
|
-
|
|
947
|
+
const data = {
|
|
948
|
+
jsonrpc: "2.0",
|
|
949
|
+
id: 1,
|
|
950
|
+
method: "pm_getTokenQuotes",
|
|
951
|
+
params: [
|
|
952
|
+
{
|
|
953
|
+
tokens: [token2.address]
|
|
954
|
+
},
|
|
955
|
+
entryPoint07Address,
|
|
956
|
+
toHex(chainId)
|
|
957
|
+
]
|
|
958
|
+
};
|
|
959
|
+
const res = yield fetch("https://api.acta.link/paymaster/v1/rpc", {
|
|
960
|
+
method: "POST",
|
|
961
|
+
headers: {
|
|
962
|
+
"Content-Type": "application/json"
|
|
963
|
+
},
|
|
964
|
+
body: JSON.stringify(data)
|
|
965
|
+
}).then((response) => {
|
|
966
|
+
if (!response.ok) {
|
|
967
|
+
throw new Error("HTTP error " + response.status);
|
|
968
|
+
}
|
|
969
|
+
return response.json();
|
|
905
970
|
});
|
|
906
971
|
const userOperationMaxCost = getRequiredPrefund({
|
|
907
972
|
userOperation,
|
|
908
973
|
entryPointVersion: "0.7"
|
|
909
974
|
});
|
|
910
|
-
const
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
975
|
+
const quotes = res.result;
|
|
976
|
+
if (!quotes.paymaster) {
|
|
977
|
+
throw new Error("Error fetching quotes");
|
|
978
|
+
}
|
|
979
|
+
const postOpGas = hexToBigInt(quotes.postOpGas);
|
|
980
|
+
const exchangeRate = hexToBigInt(quotes.exchangeRate);
|
|
981
|
+
const exchangeRateNativeToUsd = hexToBigInt(quotes.exchangeRateNativeToUsd);
|
|
982
|
+
const paymaster = quotes.paymaster;
|
|
914
983
|
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
915
984
|
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
916
985
|
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
@@ -1066,7 +1135,7 @@ var ActaAccount = class {
|
|
|
1066
1135
|
feebps
|
|
1067
1136
|
});
|
|
1068
1137
|
const account = yield this.createAccount();
|
|
1069
|
-
const { accountClient } = yield this.
|
|
1138
|
+
const { accountClient } = yield this.createAccountHelperBatch();
|
|
1070
1139
|
const fromAddress = signerAddress;
|
|
1071
1140
|
const smartAccountAddress = account.address;
|
|
1072
1141
|
const amountToTransfer = feeInclusive ? totalAmount : feeExclusiveAmountInToken;
|
|
@@ -1166,7 +1235,7 @@ var ActaAccount = class {
|
|
|
1166
1235
|
signer: this.signer
|
|
1167
1236
|
}
|
|
1168
1237
|
);
|
|
1169
|
-
const sessionKeyAddress = "
|
|
1238
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1170
1239
|
const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
|
|
1171
1240
|
const emptySessionKeySigner = yield toECDSASigner({ signer: emptyAccount });
|
|
1172
1241
|
const {
|
|
@@ -1294,7 +1363,7 @@ var ActaAccount = class {
|
|
|
1294
1363
|
signer: this.signer
|
|
1295
1364
|
}
|
|
1296
1365
|
);
|
|
1297
|
-
const sessionKeyAddress = "
|
|
1366
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1298
1367
|
const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
|
|
1299
1368
|
const emptySessionKeySigner = yield toECDSASigner({ signer: emptyAccount });
|
|
1300
1369
|
const {
|
|
@@ -1400,7 +1469,7 @@ var ActaAccount = class {
|
|
|
1400
1469
|
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1401
1470
|
const account = yield this.createAccount();
|
|
1402
1471
|
const { kernelAccountClient, accountClient } = yield this.createAccountHelpers();
|
|
1403
|
-
const sessionKeyAddress = "
|
|
1472
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1404
1473
|
const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
|
|
1405
1474
|
const emptySessionKeySigner = yield toECDSASigner({ signer: emptyAccount });
|
|
1406
1475
|
const callPolicy = toCallPolicy({
|
|
@@ -1476,7 +1545,7 @@ var ActaAccount = class {
|
|
|
1476
1545
|
};
|
|
1477
1546
|
|
|
1478
1547
|
// src/api.ts
|
|
1479
|
-
import { toHex } from "viem";
|
|
1548
|
+
import { toHex as toHex2 } from "viem";
|
|
1480
1549
|
var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
|
|
1481
1550
|
HttpMethod2["Get"] = "get";
|
|
1482
1551
|
HttpMethod2["Post"] = "post";
|
|
@@ -1562,8 +1631,8 @@ function verifySessionAPICall(url, sessionId) {
|
|
|
1562
1631
|
function scheduleRecurringPaymentsAPICall(url, params) {
|
|
1563
1632
|
return __async(this, null, function* () {
|
|
1564
1633
|
const parsedParams = __spreadProps(__spreadValues({}, params), {
|
|
1565
|
-
amount:
|
|
1566
|
-
amountExclusive:
|
|
1634
|
+
amount: toHex2(params.amount),
|
|
1635
|
+
amountExclusive: toHex2(params.amountExclusive)
|
|
1567
1636
|
});
|
|
1568
1637
|
const response = yield sendRequest({
|
|
1569
1638
|
url,
|
|
@@ -1577,8 +1646,8 @@ function scheduleSubscriptionPaymentsAPICall(url, paymentParams, serviceParams)
|
|
|
1577
1646
|
return __async(this, null, function* () {
|
|
1578
1647
|
const parsedParams = {
|
|
1579
1648
|
paymentParams: __spreadProps(__spreadValues({}, paymentParams), {
|
|
1580
|
-
amount:
|
|
1581
|
-
amountExclusive:
|
|
1649
|
+
amount: toHex2(paymentParams.amount),
|
|
1650
|
+
amountExclusive: toHex2(paymentParams.amountExclusive)
|
|
1582
1651
|
}),
|
|
1583
1652
|
serviceParams
|
|
1584
1653
|
};
|
|
@@ -1706,11 +1775,11 @@ function fetchBatchInstructionDetails(url, APIKey) {
|
|
|
1706
1775
|
});
|
|
1707
1776
|
}
|
|
1708
1777
|
|
|
1709
|
-
// src/
|
|
1710
|
-
var transactionServiceUrl = "https://api.acta.link/
|
|
1711
|
-
var depositServiceUrl = "https://api.acta.link/
|
|
1712
|
-
var transactionServiceTestUrl = "https://api.acta.link/
|
|
1713
|
-
var depositServiceTestUrl = "https://api.acta.link/
|
|
1778
|
+
// src/flexdeposit.ts
|
|
1779
|
+
var transactionServiceUrl = "https://flex-api.acta.link/flex/deposit/transaction/v1/";
|
|
1780
|
+
var depositServiceUrl = "https://flex-api.acta.link/flex/deposit/v1/";
|
|
1781
|
+
var transactionServiceTestUrl = "https://flex-api.acta.link/flex/deposit/transaction/test/v1/";
|
|
1782
|
+
var depositServiceTestUrl = "https://flex-api.acta.link/flex/deposit/test/v1/";
|
|
1714
1783
|
var returnEnvUrl = (chainId) => {
|
|
1715
1784
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
1716
1785
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
@@ -1729,7 +1798,7 @@ var returnEnvUrl = (chainId) => {
|
|
|
1729
1798
|
};
|
|
1730
1799
|
}
|
|
1731
1800
|
};
|
|
1732
|
-
var
|
|
1801
|
+
var ActaFlexDeposit = class {
|
|
1733
1802
|
constructor(parameters) {
|
|
1734
1803
|
this.feeInclusive = false;
|
|
1735
1804
|
this.count = 0;
|
|
@@ -1802,7 +1871,7 @@ var ActaDeposit = class {
|
|
|
1802
1871
|
signerAddress: this.signerAddress,
|
|
1803
1872
|
chainId: this.chainId,
|
|
1804
1873
|
token: token2.address,
|
|
1805
|
-
amount:
|
|
1874
|
+
amount: toHex3(this.amount),
|
|
1806
1875
|
receiver: this.receiver,
|
|
1807
1876
|
feeInclusive: this.feeInclusive,
|
|
1808
1877
|
serviceType: "deposit",
|
|
@@ -1934,7 +2003,7 @@ var ActaDeposit = class {
|
|
|
1934
2003
|
receiverAddress: receiver,
|
|
1935
2004
|
chainId,
|
|
1936
2005
|
tokenAddress: token2.address,
|
|
1937
|
-
amount:
|
|
2006
|
+
amount: toHex3(amount),
|
|
1938
2007
|
feeInclusive,
|
|
1939
2008
|
serviceType
|
|
1940
2009
|
},
|
|
@@ -2078,10 +2147,15 @@ var ActaDeposit = class {
|
|
|
2078
2147
|
}
|
|
2079
2148
|
};
|
|
2080
2149
|
|
|
2081
|
-
// src/
|
|
2082
|
-
import {
|
|
2083
|
-
|
|
2084
|
-
|
|
2150
|
+
// src/flexbatch.ts
|
|
2151
|
+
import {
|
|
2152
|
+
getAddress as getAddress3,
|
|
2153
|
+
parseUnits,
|
|
2154
|
+
toHex as toHex4,
|
|
2155
|
+
zeroAddress as zeroAddress4
|
|
2156
|
+
} from "viem";
|
|
2157
|
+
var batchServiceUrl = "https://flex-api.acta.link/flex/batch/api/v1/";
|
|
2158
|
+
var batchServiceTestUrl = "https://flex-api.acta.link/flex/batch/test/api/v1/";
|
|
2085
2159
|
var returnEnvUrl2 = (chainId) => {
|
|
2086
2160
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2087
2161
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
@@ -2090,54 +2164,111 @@ var returnEnvUrl2 = (chainId) => {
|
|
|
2090
2164
|
}
|
|
2091
2165
|
if (mainnetChain) {
|
|
2092
2166
|
return {
|
|
2093
|
-
|
|
2167
|
+
envBatchServiceUrl: batchServiceUrl
|
|
2094
2168
|
};
|
|
2095
2169
|
} else {
|
|
2096
2170
|
return {
|
|
2097
|
-
|
|
2171
|
+
envBatchServiceUrl: batchServiceTestUrl
|
|
2098
2172
|
};
|
|
2099
2173
|
}
|
|
2100
2174
|
};
|
|
2101
|
-
var
|
|
2175
|
+
var ActaFlexBatch = class {
|
|
2102
2176
|
constructor(parameters) {
|
|
2103
|
-
|
|
2104
|
-
this.
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
this
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2177
|
+
var _a;
|
|
2178
|
+
this.APIkey = (_a = parameters.APIKey) != null ? _a : void 0;
|
|
2179
|
+
}
|
|
2180
|
+
createSession(params) {
|
|
2181
|
+
return __async(this, null, function* () {
|
|
2182
|
+
try {
|
|
2183
|
+
const { instructionId, name, signerAddress, token: token2, chainId } = params;
|
|
2184
|
+
if (!this.APIkey) {
|
|
2185
|
+
throw new Error("No API key provided.");
|
|
2186
|
+
}
|
|
2187
|
+
if (!signerAddress || signerAddress === zeroAddress4) {
|
|
2188
|
+
throw new Error("Signer address is required.");
|
|
2189
|
+
}
|
|
2190
|
+
if (!name || name === "") {
|
|
2191
|
+
throw new Error("Name of Batch payment is required");
|
|
2192
|
+
}
|
|
2193
|
+
if (!token2) {
|
|
2194
|
+
throw new Error("Token symbol is required");
|
|
2195
|
+
}
|
|
2196
|
+
if (!instructionId || instructionId === "") {
|
|
2197
|
+
throw new Error("Instruction id is required");
|
|
2198
|
+
}
|
|
2199
|
+
const { envBatchServiceUrl } = returnEnvUrl2(chainId);
|
|
2200
|
+
const session = yield createBatchSessionAPICall(
|
|
2201
|
+
`${envBatchServiceUrl}create/session`,
|
|
2202
|
+
this.APIkey,
|
|
2203
|
+
{
|
|
2204
|
+
name,
|
|
2205
|
+
chainId,
|
|
2206
|
+
instructionId,
|
|
2207
|
+
signerAddress,
|
|
2208
|
+
token: token2
|
|
2209
|
+
}
|
|
2210
|
+
);
|
|
2211
|
+
console.log(session);
|
|
2212
|
+
const sessionId = session.id;
|
|
2213
|
+
return sessionId;
|
|
2214
|
+
} catch (error) {
|
|
2215
|
+
if (error instanceof Error) {
|
|
2216
|
+
throw new Error(error.message);
|
|
2217
|
+
}
|
|
2218
|
+
throw new Error("Failed to create session.");
|
|
2219
|
+
}
|
|
2220
|
+
});
|
|
2134
2221
|
}
|
|
2135
2222
|
estimateSinglePaymentGas(parameters) {
|
|
2136
2223
|
return __async(this, null, function* () {
|
|
2137
2224
|
try {
|
|
2138
|
-
|
|
2139
|
-
|
|
2225
|
+
const {
|
|
2226
|
+
chainId,
|
|
2227
|
+
feeInclusive,
|
|
2228
|
+
signerAddress,
|
|
2229
|
+
token: token2,
|
|
2230
|
+
walletClient,
|
|
2231
|
+
instructionId
|
|
2232
|
+
} = parameters;
|
|
2233
|
+
if (!this.APIkey) {
|
|
2234
|
+
throw new Error("No API key provided.");
|
|
2235
|
+
}
|
|
2236
|
+
let isFeeInclusive = false;
|
|
2237
|
+
if (feeInclusive) {
|
|
2238
|
+
isFeeInclusive = true;
|
|
2239
|
+
}
|
|
2240
|
+
const { envBatchServiceUrl } = returnEnvUrl2(chainId);
|
|
2241
|
+
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2242
|
+
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2243
|
+
this.APIkey
|
|
2244
|
+
);
|
|
2245
|
+
if (instuctionData.receivers.length === 0 || instuctionData.receivers.length === void 0) {
|
|
2246
|
+
throw new Error("Instruction not found");
|
|
2247
|
+
}
|
|
2248
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, token2);
|
|
2249
|
+
if (!tokenData) {
|
|
2250
|
+
throw new Error("Token not supported");
|
|
2140
2251
|
}
|
|
2252
|
+
const totalAmount = instuctionData.totalAmount;
|
|
2253
|
+
const totalAmountParsed = BigInt(
|
|
2254
|
+
parseUnits(totalAmount, tokenData.decimals)
|
|
2255
|
+
);
|
|
2256
|
+
const receivers = instuctionData.receivers.map(
|
|
2257
|
+
(i) => {
|
|
2258
|
+
const receiver = getAddress3(i.address);
|
|
2259
|
+
const tokenAmount = BigInt(parseUnits(i.amount, tokenData.decimals));
|
|
2260
|
+
return {
|
|
2261
|
+
address: receiver,
|
|
2262
|
+
amount: tokenAmount
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
);
|
|
2266
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2267
|
+
const account = new ActaAccount(
|
|
2268
|
+
chainId,
|
|
2269
|
+
viemClient.publicClient(),
|
|
2270
|
+
walletClient
|
|
2271
|
+
);
|
|
2141
2272
|
const {
|
|
2142
2273
|
estimatedGasCostInToken,
|
|
2143
2274
|
ActalinkFeesInToken,
|
|
@@ -2146,7 +2277,16 @@ var ActaBilling = class {
|
|
|
2146
2277
|
estimatedTotalFeesInToken,
|
|
2147
2278
|
paymaster,
|
|
2148
2279
|
userOperation
|
|
2149
|
-
} = yield
|
|
2280
|
+
} = yield account.estimateSingleBatchPaymentGas({
|
|
2281
|
+
chainId,
|
|
2282
|
+
feeInclusive: isFeeInclusive,
|
|
2283
|
+
signerAddress,
|
|
2284
|
+
token: token2,
|
|
2285
|
+
walletClient,
|
|
2286
|
+
receivers,
|
|
2287
|
+
totalAmount: totalAmountParsed,
|
|
2288
|
+
feebps: 20
|
|
2289
|
+
});
|
|
2150
2290
|
return {
|
|
2151
2291
|
estimatedGasCostInToken,
|
|
2152
2292
|
ActalinkFeesInToken,
|
|
@@ -2164,58 +2304,452 @@ var ActaBilling = class {
|
|
|
2164
2304
|
}
|
|
2165
2305
|
});
|
|
2166
2306
|
}
|
|
2167
|
-
|
|
2307
|
+
createSingleBatchPayment(params, serviceParams) {
|
|
2168
2308
|
return __async(this, null, function* () {
|
|
2169
2309
|
try {
|
|
2170
|
-
|
|
2171
|
-
throw new Error("Only self custody payments are supported.");
|
|
2172
|
-
}
|
|
2173
|
-
if (!servicePaymentParams.checkoutSessionId || servicePaymentParams.checkoutSessionId === "") {
|
|
2174
|
-
throw new Error("checkout session ID is required.");
|
|
2175
|
-
}
|
|
2176
|
-
const signerAddress = this.signerAddress;
|
|
2177
|
-
const chainId = this.chainId;
|
|
2178
|
-
const tokenSymbol = this.token;
|
|
2179
|
-
const amount = this.amount;
|
|
2180
|
-
const receiver = this.receiver;
|
|
2181
|
-
const feeInclusive = this.feeInclusive;
|
|
2182
|
-
const serviceType = this.serviceType;
|
|
2183
|
-
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2184
|
-
if (!token2) {
|
|
2185
|
-
throw new Error("Token not supported.");
|
|
2186
|
-
}
|
|
2187
|
-
const { envBillingServiceUrl } = returnEnvUrl2(chainId);
|
|
2188
|
-
const rpcParameters = yield this.account.signSinglePaymentOperation({
|
|
2189
|
-
signerAddress,
|
|
2310
|
+
const {
|
|
2190
2311
|
chainId,
|
|
2191
|
-
token: tokenSymbol,
|
|
2192
|
-
amount,
|
|
2193
|
-
receiver,
|
|
2194
2312
|
feeInclusive,
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
receiverAddress: receiver,
|
|
2204
|
-
chainId,
|
|
2205
|
-
tokenAddress: token2.address,
|
|
2206
|
-
amount: toHex3(amount),
|
|
2207
|
-
feeInclusive,
|
|
2208
|
-
serviceType
|
|
2209
|
-
},
|
|
2210
|
-
servicePaymentParams
|
|
2211
|
-
);
|
|
2212
|
-
return txn;
|
|
2213
|
-
} catch (error) {
|
|
2214
|
-
if (error instanceof Error) {
|
|
2215
|
-
throw new Error(error.message);
|
|
2313
|
+
signerAddress,
|
|
2314
|
+
token: tokenSymbol,
|
|
2315
|
+
walletClient,
|
|
2316
|
+
allowMaxTokenApproval,
|
|
2317
|
+
instructionId
|
|
2318
|
+
} = params;
|
|
2319
|
+
if (!this.APIkey) {
|
|
2320
|
+
throw new Error("No API key provided.");
|
|
2216
2321
|
}
|
|
2217
|
-
|
|
2218
|
-
|
|
2322
|
+
let isFeeInclusive = false;
|
|
2323
|
+
if (feeInclusive) {
|
|
2324
|
+
isFeeInclusive = true;
|
|
2325
|
+
}
|
|
2326
|
+
const { envBatchServiceUrl } = returnEnvUrl2(chainId);
|
|
2327
|
+
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2328
|
+
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2329
|
+
this.APIkey
|
|
2330
|
+
);
|
|
2331
|
+
if (instuctionData.receivers.length === 0 || instuctionData.receivers.length === void 0) {
|
|
2332
|
+
throw new Error("Instruction not found");
|
|
2333
|
+
}
|
|
2334
|
+
console.log(instuctionData);
|
|
2335
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2336
|
+
if (!tokenData) {
|
|
2337
|
+
throw new Error("Token not supported");
|
|
2338
|
+
}
|
|
2339
|
+
const totalAmount = instuctionData.totalAmount;
|
|
2340
|
+
const totalAmountParsed = BigInt(
|
|
2341
|
+
parseUnits(totalAmount, tokenData.decimals)
|
|
2342
|
+
);
|
|
2343
|
+
const receivers = instuctionData.receivers.map(
|
|
2344
|
+
(i) => {
|
|
2345
|
+
const receiver = getAddress3(i.address);
|
|
2346
|
+
const tokenAmount = BigInt(parseUnits(i.amount, tokenData.decimals));
|
|
2347
|
+
return {
|
|
2348
|
+
address: receiver,
|
|
2349
|
+
amount: tokenAmount
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
);
|
|
2353
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2354
|
+
const account = new ActaAccount(
|
|
2355
|
+
chainId,
|
|
2356
|
+
viemClient.publicClient(),
|
|
2357
|
+
walletClient
|
|
2358
|
+
);
|
|
2359
|
+
console.log("signing");
|
|
2360
|
+
const rpcParameters = yield account.signSingleBatchOperation({
|
|
2361
|
+
signerAddress,
|
|
2362
|
+
chainId,
|
|
2363
|
+
token: tokenSymbol,
|
|
2364
|
+
feeInclusive: isFeeInclusive,
|
|
2365
|
+
receivers,
|
|
2366
|
+
totalAmount: totalAmountParsed,
|
|
2367
|
+
walletClient,
|
|
2368
|
+
allowMaxTokenApproval,
|
|
2369
|
+
feebps: 20
|
|
2370
|
+
});
|
|
2371
|
+
const txn = yield executeSingleBatchPaymentAPICall(
|
|
2372
|
+
`${envBatchServiceUrl}execute/single/batch`,
|
|
2373
|
+
this.APIkey,
|
|
2374
|
+
rpcParameters,
|
|
2375
|
+
{
|
|
2376
|
+
senderAddress: signerAddress,
|
|
2377
|
+
chainId,
|
|
2378
|
+
tokenAddress: tokenData.address,
|
|
2379
|
+
amount: toHex4(totalAmountParsed),
|
|
2380
|
+
feeInclusive: isFeeInclusive,
|
|
2381
|
+
serviceType: "batch"
|
|
2382
|
+
},
|
|
2383
|
+
serviceParams
|
|
2384
|
+
);
|
|
2385
|
+
return txn;
|
|
2386
|
+
} catch (error) {
|
|
2387
|
+
if (error instanceof Error) {
|
|
2388
|
+
throw new Error(error.message);
|
|
2389
|
+
}
|
|
2390
|
+
throw new Error("Failed to create payment.");
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
createScheduleBatchPayment(params, serviceParams) {
|
|
2395
|
+
return __async(this, null, function* () {
|
|
2396
|
+
try {
|
|
2397
|
+
const {
|
|
2398
|
+
chainId,
|
|
2399
|
+
feeInclusive,
|
|
2400
|
+
signerAddress,
|
|
2401
|
+
token: tokenSymbol,
|
|
2402
|
+
walletClient,
|
|
2403
|
+
allowMaxTokenApproval,
|
|
2404
|
+
instructionId,
|
|
2405
|
+
executionTime
|
|
2406
|
+
} = params;
|
|
2407
|
+
if (!this.APIkey) {
|
|
2408
|
+
throw new Error("No API key provided.");
|
|
2409
|
+
}
|
|
2410
|
+
let isFeeInclusive = false;
|
|
2411
|
+
if (feeInclusive) {
|
|
2412
|
+
isFeeInclusive = true;
|
|
2413
|
+
}
|
|
2414
|
+
const { envBatchServiceUrl } = returnEnvUrl2(chainId);
|
|
2415
|
+
if (executionTime <= Date.now() + 1e3 * 60 * 2) {
|
|
2416
|
+
throw new Error(
|
|
2417
|
+
"Execution time must be more than 5 mins from current time."
|
|
2418
|
+
);
|
|
2419
|
+
}
|
|
2420
|
+
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2421
|
+
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2422
|
+
this.APIkey
|
|
2423
|
+
);
|
|
2424
|
+
if (instuctionData.receivers.length === 0 || instuctionData.receivers.length === void 0) {
|
|
2425
|
+
throw new Error("Instruction not found");
|
|
2426
|
+
}
|
|
2427
|
+
console.log(instuctionData);
|
|
2428
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2429
|
+
if (!tokenData) {
|
|
2430
|
+
throw new Error("Token not supported");
|
|
2431
|
+
}
|
|
2432
|
+
const totalAmount = instuctionData.totalAmount;
|
|
2433
|
+
const totalAmountParsed = BigInt(
|
|
2434
|
+
parseUnits(totalAmount, tokenData.decimals)
|
|
2435
|
+
);
|
|
2436
|
+
const receivers = instuctionData.receivers.map(
|
|
2437
|
+
(i) => {
|
|
2438
|
+
const receiver = getAddress3(i.address);
|
|
2439
|
+
const tokenAmount = BigInt(parseUnits(i.amount, tokenData.decimals));
|
|
2440
|
+
return {
|
|
2441
|
+
address: receiver,
|
|
2442
|
+
amount: tokenAmount
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
);
|
|
2446
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2447
|
+
const account = new ActaAccount(
|
|
2448
|
+
chainId,
|
|
2449
|
+
viemClient.publicClient(),
|
|
2450
|
+
walletClient
|
|
2451
|
+
);
|
|
2452
|
+
console.log("signing");
|
|
2453
|
+
const { amountExclusive, approval } = yield account.signRecurringOrScheduleBatchPayments({
|
|
2454
|
+
signerAddress,
|
|
2455
|
+
chainId,
|
|
2456
|
+
token: tokenSymbol,
|
|
2457
|
+
feeInclusive: isFeeInclusive,
|
|
2458
|
+
receivers,
|
|
2459
|
+
totalAmount: totalAmountParsed,
|
|
2460
|
+
walletClient,
|
|
2461
|
+
allowMaxTokenApproval,
|
|
2462
|
+
count: 1,
|
|
2463
|
+
feebps: 20
|
|
2464
|
+
});
|
|
2465
|
+
const txn = yield executeScheduleBatchPaymentAPICall(
|
|
2466
|
+
`${envBatchServiceUrl}execute/schedule/batch`,
|
|
2467
|
+
this.APIkey,
|
|
2468
|
+
{
|
|
2469
|
+
senderAddress: signerAddress,
|
|
2470
|
+
chainId,
|
|
2471
|
+
tokenAddress: tokenData.address,
|
|
2472
|
+
amount: toHex4(totalAmountParsed),
|
|
2473
|
+
feeInclusive: isFeeInclusive,
|
|
2474
|
+
serviceType: "batch",
|
|
2475
|
+
amountExclusive: toHex4(amountExclusive),
|
|
2476
|
+
approval,
|
|
2477
|
+
executionAt: executionTime
|
|
2478
|
+
},
|
|
2479
|
+
{
|
|
2480
|
+
sessionId: serviceParams.sessionId
|
|
2481
|
+
}
|
|
2482
|
+
);
|
|
2483
|
+
console.log(txn);
|
|
2484
|
+
return txn.transaction.id;
|
|
2485
|
+
} catch (error) {
|
|
2486
|
+
console.log(error);
|
|
2487
|
+
if (error instanceof Error) {
|
|
2488
|
+
throw new Error(error.message);
|
|
2489
|
+
}
|
|
2490
|
+
throw new Error("Failed to create payment.");
|
|
2491
|
+
}
|
|
2492
|
+
});
|
|
2493
|
+
}
|
|
2494
|
+
createSingleBatchPaymentWithoutKey(params, serviceParams) {
|
|
2495
|
+
return __async(this, null, function* () {
|
|
2496
|
+
try {
|
|
2497
|
+
const {
|
|
2498
|
+
chainId,
|
|
2499
|
+
feeInclusive,
|
|
2500
|
+
signerAddress,
|
|
2501
|
+
token: tokenSymbol,
|
|
2502
|
+
walletClient,
|
|
2503
|
+
allowMaxTokenApproval,
|
|
2504
|
+
receivers,
|
|
2505
|
+
totalAmount
|
|
2506
|
+
} = params;
|
|
2507
|
+
let isFeeInclusive = false;
|
|
2508
|
+
if (feeInclusive) {
|
|
2509
|
+
isFeeInclusive = true;
|
|
2510
|
+
}
|
|
2511
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2512
|
+
if (!tokenData) {
|
|
2513
|
+
throw new Error("Token not supported");
|
|
2514
|
+
}
|
|
2515
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2516
|
+
const account = new ActaAccount(
|
|
2517
|
+
chainId,
|
|
2518
|
+
viemClient.publicClient(),
|
|
2519
|
+
walletClient
|
|
2520
|
+
);
|
|
2521
|
+
console.log("signing");
|
|
2522
|
+
const rpcParameters = yield account.signSingleBatchOperation({
|
|
2523
|
+
signerAddress,
|
|
2524
|
+
chainId,
|
|
2525
|
+
token: tokenSymbol,
|
|
2526
|
+
feeInclusive: isFeeInclusive,
|
|
2527
|
+
receivers,
|
|
2528
|
+
totalAmount,
|
|
2529
|
+
walletClient,
|
|
2530
|
+
allowMaxTokenApproval,
|
|
2531
|
+
feebps: 20
|
|
2532
|
+
});
|
|
2533
|
+
return {
|
|
2534
|
+
senderAddress: signerAddress,
|
|
2535
|
+
chainId,
|
|
2536
|
+
tokenAddress: tokenData.address,
|
|
2537
|
+
amount: toHex4(totalAmount),
|
|
2538
|
+
feeInclusive: isFeeInclusive,
|
|
2539
|
+
serviceType: "batch",
|
|
2540
|
+
sessionId: serviceParams.sessionId,
|
|
2541
|
+
rpcParameters
|
|
2542
|
+
};
|
|
2543
|
+
} catch (error) {
|
|
2544
|
+
if (error instanceof Error) {
|
|
2545
|
+
throw new Error(error.message);
|
|
2546
|
+
}
|
|
2547
|
+
throw new Error("Failed to create payment.");
|
|
2548
|
+
}
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
createScheduleBatchPaymentWithoutKey(params, serviceParams) {
|
|
2552
|
+
return __async(this, null, function* () {
|
|
2553
|
+
try {
|
|
2554
|
+
const {
|
|
2555
|
+
chainId,
|
|
2556
|
+
feeInclusive,
|
|
2557
|
+
signerAddress,
|
|
2558
|
+
token: tokenSymbol,
|
|
2559
|
+
walletClient,
|
|
2560
|
+
allowMaxTokenApproval,
|
|
2561
|
+
executionTime,
|
|
2562
|
+
receivers,
|
|
2563
|
+
totalAmount
|
|
2564
|
+
} = params;
|
|
2565
|
+
let isFeeInclusive = false;
|
|
2566
|
+
if (feeInclusive) {
|
|
2567
|
+
isFeeInclusive = true;
|
|
2568
|
+
}
|
|
2569
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2570
|
+
if (!tokenData) {
|
|
2571
|
+
throw new Error("Token not supported");
|
|
2572
|
+
}
|
|
2573
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2574
|
+
const account = new ActaAccount(
|
|
2575
|
+
chainId,
|
|
2576
|
+
viemClient.publicClient(),
|
|
2577
|
+
walletClient
|
|
2578
|
+
);
|
|
2579
|
+
console.log("signing");
|
|
2580
|
+
const { amountExclusive, approval } = yield account.signRecurringOrScheduleBatchPayments({
|
|
2581
|
+
signerAddress,
|
|
2582
|
+
chainId,
|
|
2583
|
+
token: tokenSymbol,
|
|
2584
|
+
feeInclusive: isFeeInclusive,
|
|
2585
|
+
receivers,
|
|
2586
|
+
totalAmount,
|
|
2587
|
+
walletClient,
|
|
2588
|
+
allowMaxTokenApproval,
|
|
2589
|
+
count: 1,
|
|
2590
|
+
feebps: 20
|
|
2591
|
+
});
|
|
2592
|
+
return {
|
|
2593
|
+
senderAddress: signerAddress,
|
|
2594
|
+
chainId,
|
|
2595
|
+
tokenAddress: tokenData.address,
|
|
2596
|
+
amount: toHex4(totalAmount),
|
|
2597
|
+
feeInclusive: isFeeInclusive,
|
|
2598
|
+
serviceType: "batch",
|
|
2599
|
+
amountExclusive: toHex4(amountExclusive),
|
|
2600
|
+
approval,
|
|
2601
|
+
executionAt: executionTime,
|
|
2602
|
+
sessionId: serviceParams.sessionId
|
|
2603
|
+
};
|
|
2604
|
+
} catch (error) {
|
|
2605
|
+
console.log(error);
|
|
2606
|
+
if (error instanceof Error) {
|
|
2607
|
+
throw new Error(error.message);
|
|
2608
|
+
}
|
|
2609
|
+
throw new Error("Failed to create payment.");
|
|
2610
|
+
}
|
|
2611
|
+
});
|
|
2612
|
+
}
|
|
2613
|
+
};
|
|
2614
|
+
|
|
2615
|
+
// src/billing.ts
|
|
2616
|
+
import { toHex as toHex5 } from "viem";
|
|
2617
|
+
var billingServiceUrl = "https://api.acta.link/pay/api/v1/";
|
|
2618
|
+
var billingServiceTestUrl = "https://api.acta.link/pay/test/api/v1/";
|
|
2619
|
+
var returnEnvUrl3 = (chainId) => {
|
|
2620
|
+
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2621
|
+
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
2622
|
+
if (!mainnetChain && !testnetChain) {
|
|
2623
|
+
throw new Error(`Chain ${chainId} not supported.`);
|
|
2624
|
+
}
|
|
2625
|
+
if (mainnetChain) {
|
|
2626
|
+
return {
|
|
2627
|
+
envBillingServiceUrl: billingServiceUrl
|
|
2628
|
+
};
|
|
2629
|
+
} else {
|
|
2630
|
+
return {
|
|
2631
|
+
envBillingServiceUrl: billingServiceTestUrl
|
|
2632
|
+
};
|
|
2633
|
+
}
|
|
2634
|
+
};
|
|
2635
|
+
var ActaBilling = class {
|
|
2636
|
+
constructor(parameters) {
|
|
2637
|
+
this.feeInclusive = true;
|
|
2638
|
+
this.count = 0;
|
|
2639
|
+
this.intervalUnit = void 0;
|
|
2640
|
+
this.startDate = void 0;
|
|
2641
|
+
this.endDate = void 0;
|
|
2642
|
+
this.serviceSessionParams = void 0;
|
|
2643
|
+
this.status = "not_started";
|
|
2644
|
+
this.serviceType = "deposit";
|
|
2645
|
+
this.allowMaxTokenApproval = false;
|
|
2646
|
+
var _a, _b;
|
|
2647
|
+
this.connectorType = parameters.connectorType;
|
|
2648
|
+
this.walletClient = parameters.walletClient;
|
|
2649
|
+
this.signerAddress = parameters.signerAddress;
|
|
2650
|
+
this.chainId = parameters.chainId;
|
|
2651
|
+
this.token = parameters.token;
|
|
2652
|
+
this.amount = parameters.amount;
|
|
2653
|
+
this.receiver = parameters.receiver;
|
|
2654
|
+
this.feeInclusive = (_a = parameters.feeInclusive) != null ? _a : true;
|
|
2655
|
+
this.paymentType = parameters.paymentType;
|
|
2656
|
+
this.count = parameters.count;
|
|
2657
|
+
this.intervalUnit = parameters.intervalUnit;
|
|
2658
|
+
this.startDate = parameters.startDate;
|
|
2659
|
+
this.endDate = parameters.endDate;
|
|
2660
|
+
this.allowMaxTokenApproval = (_b = parameters.allowMaxTokenApproval) != null ? _b : false;
|
|
2661
|
+
this.serviceType = parameters.serviceType;
|
|
2662
|
+
this.viemClient = new ViemClient(this.chainId, this.walletClient);
|
|
2663
|
+
this.account = new ActaAccount(
|
|
2664
|
+
this.chainId,
|
|
2665
|
+
this.viemClient.publicClient(),
|
|
2666
|
+
this.walletClient
|
|
2667
|
+
);
|
|
2668
|
+
}
|
|
2669
|
+
estimateSinglePaymentGas(parameters) {
|
|
2670
|
+
return __async(this, null, function* () {
|
|
2671
|
+
try {
|
|
2672
|
+
if (this.connectorType !== "Self-Custody" /* SELF_CUSTODY */) {
|
|
2673
|
+
throw new Error("Only self custody payments are supported.");
|
|
2674
|
+
}
|
|
2675
|
+
const {
|
|
2676
|
+
estimatedGasCostInToken,
|
|
2677
|
+
ActalinkFeesInToken,
|
|
2678
|
+
feeInclusiveAmountInToken,
|
|
2679
|
+
feeExclusiveAmountInToken,
|
|
2680
|
+
estimatedTotalFeesInToken,
|
|
2681
|
+
paymaster,
|
|
2682
|
+
userOperation
|
|
2683
|
+
} = yield this.account.estimateSinglePaymentGas(parameters);
|
|
2684
|
+
return {
|
|
2685
|
+
estimatedGasCostInToken,
|
|
2686
|
+
ActalinkFeesInToken,
|
|
2687
|
+
feeInclusiveAmountInToken,
|
|
2688
|
+
feeExclusiveAmountInToken,
|
|
2689
|
+
estimatedTotalFeesInToken,
|
|
2690
|
+
paymaster,
|
|
2691
|
+
userOperation
|
|
2692
|
+
};
|
|
2693
|
+
} catch (error) {
|
|
2694
|
+
if (error instanceof Error) {
|
|
2695
|
+
throw new Error(error.message);
|
|
2696
|
+
}
|
|
2697
|
+
throw new Error("Failed to estimate single payment gas.");
|
|
2698
|
+
}
|
|
2699
|
+
});
|
|
2700
|
+
}
|
|
2701
|
+
createSinglePayment(servicePaymentParams) {
|
|
2702
|
+
return __async(this, null, function* () {
|
|
2703
|
+
try {
|
|
2704
|
+
if (this.connectorType !== "Self-Custody" /* SELF_CUSTODY */) {
|
|
2705
|
+
throw new Error("Only self custody payments are supported.");
|
|
2706
|
+
}
|
|
2707
|
+
if (!servicePaymentParams.checkoutSessionId || servicePaymentParams.checkoutSessionId === "") {
|
|
2708
|
+
throw new Error("checkout session ID is required.");
|
|
2709
|
+
}
|
|
2710
|
+
const signerAddress = this.signerAddress;
|
|
2711
|
+
const chainId = this.chainId;
|
|
2712
|
+
const tokenSymbol = this.token;
|
|
2713
|
+
const amount = this.amount;
|
|
2714
|
+
const receiver = this.receiver;
|
|
2715
|
+
const feeInclusive = this.feeInclusive;
|
|
2716
|
+
const serviceType = this.serviceType;
|
|
2717
|
+
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2718
|
+
if (!token2) {
|
|
2719
|
+
throw new Error("Token not supported.");
|
|
2720
|
+
}
|
|
2721
|
+
const { envBillingServiceUrl } = returnEnvUrl3(chainId);
|
|
2722
|
+
const rpcParameters = yield this.account.signSinglePaymentOperation({
|
|
2723
|
+
signerAddress,
|
|
2724
|
+
chainId,
|
|
2725
|
+
token: tokenSymbol,
|
|
2726
|
+
amount,
|
|
2727
|
+
receiver,
|
|
2728
|
+
feeInclusive,
|
|
2729
|
+
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2730
|
+
feebps: 20
|
|
2731
|
+
});
|
|
2732
|
+
const txn = yield executeSinglePaymentAPICall(
|
|
2733
|
+
`${envBillingServiceUrl}execute/single`,
|
|
2734
|
+
rpcParameters,
|
|
2735
|
+
{
|
|
2736
|
+
senderAddress: signerAddress,
|
|
2737
|
+
receiverAddress: receiver,
|
|
2738
|
+
chainId,
|
|
2739
|
+
tokenAddress: token2.address,
|
|
2740
|
+
amount: toHex5(amount),
|
|
2741
|
+
feeInclusive,
|
|
2742
|
+
serviceType
|
|
2743
|
+
},
|
|
2744
|
+
servicePaymentParams
|
|
2745
|
+
);
|
|
2746
|
+
return txn;
|
|
2747
|
+
} catch (error) {
|
|
2748
|
+
if (error instanceof Error) {
|
|
2749
|
+
throw new Error(error.message);
|
|
2750
|
+
}
|
|
2751
|
+
throw new Error("Failed to create payment.");
|
|
2752
|
+
}
|
|
2219
2753
|
});
|
|
2220
2754
|
}
|
|
2221
2755
|
createRecurringPayments(servicePaymentParams) {
|
|
@@ -2247,7 +2781,7 @@ var ActaBilling = class {
|
|
|
2247
2781
|
if (!chainId || !count || !intervalUnit || !startDate || !endDate) {
|
|
2248
2782
|
throw new Error("Invalid parameters.");
|
|
2249
2783
|
}
|
|
2250
|
-
const { envBillingServiceUrl } =
|
|
2784
|
+
const { envBillingServiceUrl } = returnEnvUrl3(chainId);
|
|
2251
2785
|
const { approval, amountExclusive } = yield this.account.signRecurringPayments({
|
|
2252
2786
|
signerAddress,
|
|
2253
2787
|
chainId,
|
|
@@ -2321,14 +2855,14 @@ var ActaBilling = class {
|
|
|
2321
2855
|
|
|
2322
2856
|
// src/batch.ts
|
|
2323
2857
|
import {
|
|
2324
|
-
getAddress as
|
|
2325
|
-
parseUnits,
|
|
2326
|
-
toHex as
|
|
2327
|
-
zeroAddress as
|
|
2858
|
+
getAddress as getAddress4,
|
|
2859
|
+
parseUnits as parseUnits2,
|
|
2860
|
+
toHex as toHex6,
|
|
2861
|
+
zeroAddress as zeroAddress5
|
|
2328
2862
|
} from "viem";
|
|
2329
|
-
var
|
|
2330
|
-
var
|
|
2331
|
-
var
|
|
2863
|
+
var batchServiceUrl2 = "https://api.acta.link/bexo/api/v1/";
|
|
2864
|
+
var batchServiceTestUrl2 = "https://api.acta.link/bexo/test/api/v1/";
|
|
2865
|
+
var returnEnvUrl4 = (chainId) => {
|
|
2332
2866
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2333
2867
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
2334
2868
|
if (!mainnetChain && !testnetChain) {
|
|
@@ -2336,11 +2870,11 @@ var returnEnvUrl3 = (chainId) => {
|
|
|
2336
2870
|
}
|
|
2337
2871
|
if (mainnetChain) {
|
|
2338
2872
|
return {
|
|
2339
|
-
envBatchServiceUrl:
|
|
2873
|
+
envBatchServiceUrl: batchServiceUrl2
|
|
2340
2874
|
};
|
|
2341
2875
|
} else {
|
|
2342
2876
|
return {
|
|
2343
|
-
envBatchServiceUrl:
|
|
2877
|
+
envBatchServiceUrl: batchServiceTestUrl2
|
|
2344
2878
|
};
|
|
2345
2879
|
}
|
|
2346
2880
|
};
|
|
@@ -2356,7 +2890,7 @@ var ActaBatch = class {
|
|
|
2356
2890
|
if (!this.APIkey) {
|
|
2357
2891
|
throw new Error("No API key provided.");
|
|
2358
2892
|
}
|
|
2359
|
-
if (!signerAddress || signerAddress ===
|
|
2893
|
+
if (!signerAddress || signerAddress === zeroAddress5) {
|
|
2360
2894
|
throw new Error("Signer address is required.");
|
|
2361
2895
|
}
|
|
2362
2896
|
if (!name || name === "") {
|
|
@@ -2368,7 +2902,7 @@ var ActaBatch = class {
|
|
|
2368
2902
|
if (!instructionId || instructionId === "") {
|
|
2369
2903
|
throw new Error("Instruction id is required");
|
|
2370
2904
|
}
|
|
2371
|
-
const { envBatchServiceUrl } =
|
|
2905
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2372
2906
|
const session = yield createBatchSessionAPICall(
|
|
2373
2907
|
`${envBatchServiceUrl}create/session`,
|
|
2374
2908
|
this.APIkey,
|
|
@@ -2409,7 +2943,7 @@ var ActaBatch = class {
|
|
|
2409
2943
|
if (feeInclusive) {
|
|
2410
2944
|
isFeeInclusive = true;
|
|
2411
2945
|
}
|
|
2412
|
-
const { envBatchServiceUrl } =
|
|
2946
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2413
2947
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2414
2948
|
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2415
2949
|
this.APIkey
|
|
@@ -2423,12 +2957,12 @@ var ActaBatch = class {
|
|
|
2423
2957
|
}
|
|
2424
2958
|
const totalAmount = instuctionData.totalAmount;
|
|
2425
2959
|
const totalAmountParsed = BigInt(
|
|
2426
|
-
|
|
2960
|
+
parseUnits2(totalAmount, tokenData.decimals)
|
|
2427
2961
|
);
|
|
2428
2962
|
const receivers = instuctionData.receivers.map(
|
|
2429
2963
|
(i) => {
|
|
2430
|
-
const receiver =
|
|
2431
|
-
const tokenAmount = BigInt(
|
|
2964
|
+
const receiver = getAddress4(i.address);
|
|
2965
|
+
const tokenAmount = BigInt(parseUnits2(i.amount, tokenData.decimals));
|
|
2432
2966
|
return {
|
|
2433
2967
|
address: receiver,
|
|
2434
2968
|
amount: tokenAmount
|
|
@@ -2495,7 +3029,7 @@ var ActaBatch = class {
|
|
|
2495
3029
|
if (feeInclusive) {
|
|
2496
3030
|
isFeeInclusive = true;
|
|
2497
3031
|
}
|
|
2498
|
-
const { envBatchServiceUrl } =
|
|
3032
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2499
3033
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2500
3034
|
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2501
3035
|
this.APIkey
|
|
@@ -2510,12 +3044,12 @@ var ActaBatch = class {
|
|
|
2510
3044
|
}
|
|
2511
3045
|
const totalAmount = instuctionData.totalAmount;
|
|
2512
3046
|
const totalAmountParsed = BigInt(
|
|
2513
|
-
|
|
3047
|
+
parseUnits2(totalAmount, tokenData.decimals)
|
|
2514
3048
|
);
|
|
2515
3049
|
const receivers = instuctionData.receivers.map(
|
|
2516
3050
|
(i) => {
|
|
2517
|
-
const receiver =
|
|
2518
|
-
const tokenAmount = BigInt(
|
|
3051
|
+
const receiver = getAddress4(i.address);
|
|
3052
|
+
const tokenAmount = BigInt(parseUnits2(i.amount, tokenData.decimals));
|
|
2519
3053
|
return {
|
|
2520
3054
|
address: receiver,
|
|
2521
3055
|
amount: tokenAmount
|
|
@@ -2548,7 +3082,7 @@ var ActaBatch = class {
|
|
|
2548
3082
|
senderAddress: signerAddress,
|
|
2549
3083
|
chainId,
|
|
2550
3084
|
tokenAddress: tokenData.address,
|
|
2551
|
-
amount:
|
|
3085
|
+
amount: toHex6(totalAmountParsed),
|
|
2552
3086
|
feeInclusive: isFeeInclusive,
|
|
2553
3087
|
serviceType: "batch"
|
|
2554
3088
|
},
|
|
@@ -2583,7 +3117,7 @@ var ActaBatch = class {
|
|
|
2583
3117
|
if (feeInclusive) {
|
|
2584
3118
|
isFeeInclusive = true;
|
|
2585
3119
|
}
|
|
2586
|
-
const { envBatchServiceUrl } =
|
|
3120
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2587
3121
|
if (executionTime <= Date.now() + 1e3 * 60 * 2) {
|
|
2588
3122
|
throw new Error(
|
|
2589
3123
|
"Execution time must be more than 5 mins from current time."
|
|
@@ -2603,12 +3137,12 @@ var ActaBatch = class {
|
|
|
2603
3137
|
}
|
|
2604
3138
|
const totalAmount = instuctionData.totalAmount;
|
|
2605
3139
|
const totalAmountParsed = BigInt(
|
|
2606
|
-
|
|
3140
|
+
parseUnits2(totalAmount, tokenData.decimals)
|
|
2607
3141
|
);
|
|
2608
3142
|
const receivers = instuctionData.receivers.map(
|
|
2609
3143
|
(i) => {
|
|
2610
|
-
const receiver =
|
|
2611
|
-
const tokenAmount = BigInt(
|
|
3144
|
+
const receiver = getAddress4(i.address);
|
|
3145
|
+
const tokenAmount = BigInt(parseUnits2(i.amount, tokenData.decimals));
|
|
2612
3146
|
return {
|
|
2613
3147
|
address: receiver,
|
|
2614
3148
|
amount: tokenAmount
|
|
@@ -2641,10 +3175,10 @@ var ActaBatch = class {
|
|
|
2641
3175
|
senderAddress: signerAddress,
|
|
2642
3176
|
chainId,
|
|
2643
3177
|
tokenAddress: tokenData.address,
|
|
2644
|
-
amount:
|
|
3178
|
+
amount: toHex6(totalAmountParsed),
|
|
2645
3179
|
feeInclusive: isFeeInclusive,
|
|
2646
3180
|
serviceType: "batch",
|
|
2647
|
-
amountExclusive:
|
|
3181
|
+
amountExclusive: toHex6(amountExclusive),
|
|
2648
3182
|
approval,
|
|
2649
3183
|
executionAt: executionTime
|
|
2650
3184
|
},
|
|
@@ -2706,7 +3240,7 @@ var ActaBatch = class {
|
|
|
2706
3240
|
senderAddress: signerAddress,
|
|
2707
3241
|
chainId,
|
|
2708
3242
|
tokenAddress: tokenData.address,
|
|
2709
|
-
amount:
|
|
3243
|
+
amount: toHex6(totalAmount),
|
|
2710
3244
|
feeInclusive: isFeeInclusive,
|
|
2711
3245
|
serviceType: "batch",
|
|
2712
3246
|
sessionId: serviceParams.sessionId,
|
|
@@ -2765,10 +3299,10 @@ var ActaBatch = class {
|
|
|
2765
3299
|
senderAddress: signerAddress,
|
|
2766
3300
|
chainId,
|
|
2767
3301
|
tokenAddress: tokenData.address,
|
|
2768
|
-
amount:
|
|
3302
|
+
amount: toHex6(totalAmount),
|
|
2769
3303
|
feeInclusive: isFeeInclusive,
|
|
2770
3304
|
serviceType: "batch",
|
|
2771
|
-
amountExclusive:
|
|
3305
|
+
amountExclusive: toHex6(amountExclusive),
|
|
2772
3306
|
approval,
|
|
2773
3307
|
executionAt: executionTime,
|
|
2774
3308
|
sessionId: serviceParams.sessionId
|
|
@@ -2803,7 +3337,7 @@ import {
|
|
|
2803
3337
|
encodeAbiParameters,
|
|
2804
3338
|
keccak256,
|
|
2805
3339
|
slice,
|
|
2806
|
-
zeroAddress as
|
|
3340
|
+
zeroAddress as zeroAddress6,
|
|
2807
3341
|
decodeFunctionData,
|
|
2808
3342
|
hexToBigInt as hexToBigInt2
|
|
2809
3343
|
} from "viem";
|
|
@@ -2826,10 +3360,10 @@ import {
|
|
|
2826
3360
|
} from "@zerodev/permissions/policies";
|
|
2827
3361
|
import { coerce, gt } from "semver";
|
|
2828
3362
|
var ECDSA_SIGNER_CONTRACT = "0x6A6F069E2a08c2468e7724Ab3250CdBFBA14D4FF";
|
|
2829
|
-
var billingServiceUrl2 = "https://api.
|
|
3363
|
+
var billingServiceUrl2 = "https://api.acta.link/pay/v1/";
|
|
2830
3364
|
var depositServiceUrl2 = "https://api.acta.link/bexo/v1/";
|
|
2831
|
-
var transactionServiceUrl2 = "https://api.
|
|
2832
|
-
var billingServiceTestUrl2 = "https://api.
|
|
3365
|
+
var transactionServiceUrl2 = "https://api.acta.link/transaction/v1/";
|
|
3366
|
+
var billingServiceTestUrl2 = "https://api.acta.link/pay/test/v1/";
|
|
2833
3367
|
var toSignerId = (signer) => {
|
|
2834
3368
|
return encodeAbiParameters(
|
|
2835
3369
|
[{ name: "signerData", type: "bytes" }],
|
|
@@ -2915,7 +3449,7 @@ function toPermissionValidator2(_0, _1) {
|
|
|
2915
3449
|
return __spreadProps(__spreadValues({}, signer.account), {
|
|
2916
3450
|
supportedKernelVersions: ">=0.3.0",
|
|
2917
3451
|
validatorType: "PERMISSION",
|
|
2918
|
-
address:
|
|
3452
|
+
address: zeroAddress6,
|
|
2919
3453
|
source: "PermissionValidator",
|
|
2920
3454
|
getEnableData,
|
|
2921
3455
|
getIdentifier: getPermissionId,
|
|
@@ -3261,7 +3795,8 @@ export {
|
|
|
3261
3795
|
ActaAccount,
|
|
3262
3796
|
ActaBatch,
|
|
3263
3797
|
ActaBilling,
|
|
3264
|
-
|
|
3798
|
+
ActaFlexBatch,
|
|
3799
|
+
ActaFlexDeposit,
|
|
3265
3800
|
ConnectorType,
|
|
3266
3801
|
HttpMethod,
|
|
3267
3802
|
PolicyFlags,
|