@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.cjs
CHANGED
|
@@ -60,7 +60,8 @@ __export(index_exports, {
|
|
|
60
60
|
ActaAccount: () => ActaAccount,
|
|
61
61
|
ActaBatch: () => ActaBatch,
|
|
62
62
|
ActaBilling: () => ActaBilling,
|
|
63
|
-
|
|
63
|
+
ActaFlexBatch: () => ActaFlexBatch,
|
|
64
|
+
ActaFlexDeposit: () => ActaFlexDeposit,
|
|
64
65
|
ConnectorType: () => ConnectorType,
|
|
65
66
|
HttpMethod: () => HttpMethod,
|
|
66
67
|
PolicyFlags: () => PolicyFlags,
|
|
@@ -362,7 +363,7 @@ var bscUSDT = token({
|
|
|
362
363
|
symbol: "USDT",
|
|
363
364
|
logoURI: "https://api.acta.link/deposit/v1/logos/usdt.png" /* USDT */
|
|
364
365
|
});
|
|
365
|
-
var bscTokens = [bscUSDT];
|
|
366
|
+
var bscTokens = [bscUSDT, bscUSDC];
|
|
366
367
|
var ethereumETH = nativeETH(import_chains3.mainnet.id);
|
|
367
368
|
var ethereumWETH = token({
|
|
368
369
|
chainId: import_chains3.mainnet.id,
|
|
@@ -669,7 +670,7 @@ function getTokenByChainIdAndAddress(chainId, address) {
|
|
|
669
670
|
return token2;
|
|
670
671
|
}
|
|
671
672
|
|
|
672
|
-
// src/
|
|
673
|
+
// src/flexdeposit.ts
|
|
673
674
|
var import_viem5 = require("viem");
|
|
674
675
|
|
|
675
676
|
// src/account.ts
|
|
@@ -849,6 +850,48 @@ var ActaAccount = class {
|
|
|
849
850
|
};
|
|
850
851
|
});
|
|
851
852
|
}
|
|
853
|
+
createAccountHelperBatch() {
|
|
854
|
+
return __async(this, null, function* () {
|
|
855
|
+
const account = yield this.createAccount();
|
|
856
|
+
const entryPoint = (0, import_constants.getEntryPoint)("0.7");
|
|
857
|
+
const paymasterClient = (0, import_account_abstraction.createPaymasterClient)({
|
|
858
|
+
transport: (0, import_viem3.http)(`https://api.acta.link/paymaster/v1/rpc`)
|
|
859
|
+
});
|
|
860
|
+
const pimlicoClient = (0, import_pimlico.createPimlicoClient)({
|
|
861
|
+
chain: getChainById(this.chainId),
|
|
862
|
+
transport: (0, import_viem3.http)(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
863
|
+
entryPoint
|
|
864
|
+
});
|
|
865
|
+
const accountClient = (0, import_permissionless.createSmartAccountClient)({
|
|
866
|
+
account,
|
|
867
|
+
chain: getChainById(this.chainId),
|
|
868
|
+
paymaster: paymasterClient,
|
|
869
|
+
bundlerTransport: (0, import_viem3.http)(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
870
|
+
userOperation: {
|
|
871
|
+
estimateFeesPerGas: () => __async(this, null, function* () {
|
|
872
|
+
return (yield pimlicoClient.getUserOperationGasPrice()).fast;
|
|
873
|
+
})
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
const kernelAccountClient = (0, import_sdk.createKernelAccountClient)({
|
|
877
|
+
account,
|
|
878
|
+
chain: getChainById(this.chainId),
|
|
879
|
+
paymaster: paymasterClient,
|
|
880
|
+
bundlerTransport: (0, import_viem3.http)(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
881
|
+
userOperation: {
|
|
882
|
+
estimateFeesPerGas: () => __async(this, null, function* () {
|
|
883
|
+
return (yield pimlicoClient.getUserOperationGasPrice()).fast;
|
|
884
|
+
})
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
return {
|
|
888
|
+
paymasterClient,
|
|
889
|
+
pimlicoClient,
|
|
890
|
+
accountClient,
|
|
891
|
+
kernelAccountClient
|
|
892
|
+
};
|
|
893
|
+
});
|
|
894
|
+
}
|
|
852
895
|
estimateSinglePaymentGas(parameters) {
|
|
853
896
|
return __async(this, null, function* () {
|
|
854
897
|
const {
|
|
@@ -941,7 +984,7 @@ var ActaAccount = class {
|
|
|
941
984
|
throw new Error("Receivers not found for batch payment");
|
|
942
985
|
}
|
|
943
986
|
const account = yield this.createAccount();
|
|
944
|
-
const { accountClient, pimlicoClient } = yield this.
|
|
987
|
+
const { accountClient, pimlicoClient } = yield this.createAccountHelperBatch();
|
|
945
988
|
const fromAddress = signerAddress;
|
|
946
989
|
const smartAccountAddress = account.address;
|
|
947
990
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
@@ -972,18 +1015,42 @@ var ActaAccount = class {
|
|
|
972
1015
|
}
|
|
973
1016
|
]
|
|
974
1017
|
});
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
|
|
1018
|
+
const data = {
|
|
1019
|
+
jsonrpc: "2.0",
|
|
1020
|
+
id: 1,
|
|
1021
|
+
method: "pm_getTokenQuotes",
|
|
1022
|
+
params: [
|
|
1023
|
+
{
|
|
1024
|
+
tokens: [token2.address]
|
|
1025
|
+
},
|
|
1026
|
+
import_account_abstraction.entryPoint07Address,
|
|
1027
|
+
(0, import_viem3.toHex)(chainId)
|
|
1028
|
+
]
|
|
1029
|
+
};
|
|
1030
|
+
const res = yield fetch("https://api.acta.link/paymaster/v1/rpc", {
|
|
1031
|
+
method: "POST",
|
|
1032
|
+
headers: {
|
|
1033
|
+
"Content-Type": "application/json"
|
|
1034
|
+
},
|
|
1035
|
+
body: JSON.stringify(data)
|
|
1036
|
+
}).then((response) => {
|
|
1037
|
+
if (!response.ok) {
|
|
1038
|
+
throw new Error("HTTP error " + response.status);
|
|
1039
|
+
}
|
|
1040
|
+
return response.json();
|
|
978
1041
|
});
|
|
979
1042
|
const userOperationMaxCost = (0, import_permissionless.getRequiredPrefund)({
|
|
980
1043
|
userOperation,
|
|
981
1044
|
entryPointVersion: "0.7"
|
|
982
1045
|
});
|
|
983
|
-
const
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1046
|
+
const quotes = res.result;
|
|
1047
|
+
if (!quotes.paymaster) {
|
|
1048
|
+
throw new Error("Error fetching quotes");
|
|
1049
|
+
}
|
|
1050
|
+
const postOpGas = (0, import_viem3.hexToBigInt)(quotes.postOpGas);
|
|
1051
|
+
const exchangeRate = (0, import_viem3.hexToBigInt)(quotes.exchangeRate);
|
|
1052
|
+
const exchangeRateNativeToUsd = (0, import_viem3.hexToBigInt)(quotes.exchangeRateNativeToUsd);
|
|
1053
|
+
const paymaster = quotes.paymaster;
|
|
987
1054
|
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
988
1055
|
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
989
1056
|
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
@@ -1139,7 +1206,7 @@ var ActaAccount = class {
|
|
|
1139
1206
|
feebps
|
|
1140
1207
|
});
|
|
1141
1208
|
const account = yield this.createAccount();
|
|
1142
|
-
const { accountClient } = yield this.
|
|
1209
|
+
const { accountClient } = yield this.createAccountHelperBatch();
|
|
1143
1210
|
const fromAddress = signerAddress;
|
|
1144
1211
|
const smartAccountAddress = account.address;
|
|
1145
1212
|
const amountToTransfer = feeInclusive ? totalAmount : feeExclusiveAmountInToken;
|
|
@@ -1239,7 +1306,7 @@ var ActaAccount = class {
|
|
|
1239
1306
|
signer: this.signer
|
|
1240
1307
|
}
|
|
1241
1308
|
);
|
|
1242
|
-
const sessionKeyAddress = "
|
|
1309
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1243
1310
|
const emptyAccount = (0, import_sdk.addressToEmptyAccount)(sessionKeyAddress);
|
|
1244
1311
|
const emptySessionKeySigner = yield (0, import_signers.toECDSASigner)({ signer: emptyAccount });
|
|
1245
1312
|
const {
|
|
@@ -1367,7 +1434,7 @@ var ActaAccount = class {
|
|
|
1367
1434
|
signer: this.signer
|
|
1368
1435
|
}
|
|
1369
1436
|
);
|
|
1370
|
-
const sessionKeyAddress = "
|
|
1437
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1371
1438
|
const emptyAccount = (0, import_sdk.addressToEmptyAccount)(sessionKeyAddress);
|
|
1372
1439
|
const emptySessionKeySigner = yield (0, import_signers.toECDSASigner)({ signer: emptyAccount });
|
|
1373
1440
|
const {
|
|
@@ -1473,7 +1540,7 @@ var ActaAccount = class {
|
|
|
1473
1540
|
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1474
1541
|
const account = yield this.createAccount();
|
|
1475
1542
|
const { kernelAccountClient, accountClient } = yield this.createAccountHelpers();
|
|
1476
|
-
const sessionKeyAddress = "
|
|
1543
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1477
1544
|
const emptyAccount = (0, import_sdk.addressToEmptyAccount)(sessionKeyAddress);
|
|
1478
1545
|
const emptySessionKeySigner = yield (0, import_signers.toECDSASigner)({ signer: emptyAccount });
|
|
1479
1546
|
const callPolicy = (0, import_policies.toCallPolicy)({
|
|
@@ -1779,11 +1846,11 @@ function fetchBatchInstructionDetails(url, APIKey) {
|
|
|
1779
1846
|
});
|
|
1780
1847
|
}
|
|
1781
1848
|
|
|
1782
|
-
// src/
|
|
1783
|
-
var transactionServiceUrl = "https://api.acta.link/
|
|
1784
|
-
var depositServiceUrl = "https://api.acta.link/
|
|
1785
|
-
var transactionServiceTestUrl = "https://api.acta.link/
|
|
1786
|
-
var depositServiceTestUrl = "https://api.acta.link/
|
|
1849
|
+
// src/flexdeposit.ts
|
|
1850
|
+
var transactionServiceUrl = "https://flex-api.acta.link/flex/deposit/transaction/v1/";
|
|
1851
|
+
var depositServiceUrl = "https://flex-api.acta.link/flex/deposit/v1/";
|
|
1852
|
+
var transactionServiceTestUrl = "https://flex-api.acta.link/flex/deposit/transaction/test/v1/";
|
|
1853
|
+
var depositServiceTestUrl = "https://flex-api.acta.link/flex/deposit/test/v1/";
|
|
1787
1854
|
var returnEnvUrl = (chainId) => {
|
|
1788
1855
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
1789
1856
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
@@ -1802,7 +1869,7 @@ var returnEnvUrl = (chainId) => {
|
|
|
1802
1869
|
};
|
|
1803
1870
|
}
|
|
1804
1871
|
};
|
|
1805
|
-
var
|
|
1872
|
+
var ActaFlexDeposit = class {
|
|
1806
1873
|
constructor(parameters) {
|
|
1807
1874
|
this.feeInclusive = false;
|
|
1808
1875
|
this.count = 0;
|
|
@@ -2151,11 +2218,471 @@ var ActaDeposit = class {
|
|
|
2151
2218
|
}
|
|
2152
2219
|
};
|
|
2153
2220
|
|
|
2154
|
-
// src/
|
|
2221
|
+
// src/flexbatch.ts
|
|
2155
2222
|
var import_viem6 = require("viem");
|
|
2156
|
-
var
|
|
2157
|
-
var
|
|
2223
|
+
var batchServiceUrl = "https://flex-api.acta.link/flex/batch/api/v1/";
|
|
2224
|
+
var batchServiceTestUrl = "https://flex-api.acta.link/flex/batch/test/api/v1/";
|
|
2158
2225
|
var returnEnvUrl2 = (chainId) => {
|
|
2226
|
+
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2227
|
+
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
2228
|
+
if (!mainnetChain && !testnetChain) {
|
|
2229
|
+
throw new Error(`Chain ${chainId} not supported.`);
|
|
2230
|
+
}
|
|
2231
|
+
if (mainnetChain) {
|
|
2232
|
+
return {
|
|
2233
|
+
envBatchServiceUrl: batchServiceUrl
|
|
2234
|
+
};
|
|
2235
|
+
} else {
|
|
2236
|
+
return {
|
|
2237
|
+
envBatchServiceUrl: batchServiceTestUrl
|
|
2238
|
+
};
|
|
2239
|
+
}
|
|
2240
|
+
};
|
|
2241
|
+
var ActaFlexBatch = class {
|
|
2242
|
+
constructor(parameters) {
|
|
2243
|
+
var _a;
|
|
2244
|
+
this.APIkey = (_a = parameters.APIKey) != null ? _a : void 0;
|
|
2245
|
+
}
|
|
2246
|
+
createSession(params) {
|
|
2247
|
+
return __async(this, null, function* () {
|
|
2248
|
+
try {
|
|
2249
|
+
const { instructionId, name, signerAddress, token: token2, chainId } = params;
|
|
2250
|
+
if (!this.APIkey) {
|
|
2251
|
+
throw new Error("No API key provided.");
|
|
2252
|
+
}
|
|
2253
|
+
if (!signerAddress || signerAddress === import_viem6.zeroAddress) {
|
|
2254
|
+
throw new Error("Signer address is required.");
|
|
2255
|
+
}
|
|
2256
|
+
if (!name || name === "") {
|
|
2257
|
+
throw new Error("Name of Batch payment is required");
|
|
2258
|
+
}
|
|
2259
|
+
if (!token2) {
|
|
2260
|
+
throw new Error("Token symbol is required");
|
|
2261
|
+
}
|
|
2262
|
+
if (!instructionId || instructionId === "") {
|
|
2263
|
+
throw new Error("Instruction id is required");
|
|
2264
|
+
}
|
|
2265
|
+
const { envBatchServiceUrl } = returnEnvUrl2(chainId);
|
|
2266
|
+
const session = yield createBatchSessionAPICall(
|
|
2267
|
+
`${envBatchServiceUrl}create/session`,
|
|
2268
|
+
this.APIkey,
|
|
2269
|
+
{
|
|
2270
|
+
name,
|
|
2271
|
+
chainId,
|
|
2272
|
+
instructionId,
|
|
2273
|
+
signerAddress,
|
|
2274
|
+
token: token2
|
|
2275
|
+
}
|
|
2276
|
+
);
|
|
2277
|
+
console.log(session);
|
|
2278
|
+
const sessionId = session.id;
|
|
2279
|
+
return sessionId;
|
|
2280
|
+
} catch (error) {
|
|
2281
|
+
if (error instanceof Error) {
|
|
2282
|
+
throw new Error(error.message);
|
|
2283
|
+
}
|
|
2284
|
+
throw new Error("Failed to create session.");
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
estimateSinglePaymentGas(parameters) {
|
|
2289
|
+
return __async(this, null, function* () {
|
|
2290
|
+
try {
|
|
2291
|
+
const {
|
|
2292
|
+
chainId,
|
|
2293
|
+
feeInclusive,
|
|
2294
|
+
signerAddress,
|
|
2295
|
+
token: token2,
|
|
2296
|
+
walletClient,
|
|
2297
|
+
instructionId
|
|
2298
|
+
} = parameters;
|
|
2299
|
+
if (!this.APIkey) {
|
|
2300
|
+
throw new Error("No API key provided.");
|
|
2301
|
+
}
|
|
2302
|
+
let isFeeInclusive = false;
|
|
2303
|
+
if (feeInclusive) {
|
|
2304
|
+
isFeeInclusive = true;
|
|
2305
|
+
}
|
|
2306
|
+
const { envBatchServiceUrl } = returnEnvUrl2(chainId);
|
|
2307
|
+
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2308
|
+
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2309
|
+
this.APIkey
|
|
2310
|
+
);
|
|
2311
|
+
if (instuctionData.receivers.length === 0 || instuctionData.receivers.length === void 0) {
|
|
2312
|
+
throw new Error("Instruction not found");
|
|
2313
|
+
}
|
|
2314
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, token2);
|
|
2315
|
+
if (!tokenData) {
|
|
2316
|
+
throw new Error("Token not supported");
|
|
2317
|
+
}
|
|
2318
|
+
const totalAmount = instuctionData.totalAmount;
|
|
2319
|
+
const totalAmountParsed = BigInt(
|
|
2320
|
+
(0, import_viem6.parseUnits)(totalAmount, tokenData.decimals)
|
|
2321
|
+
);
|
|
2322
|
+
const receivers = instuctionData.receivers.map(
|
|
2323
|
+
(i) => {
|
|
2324
|
+
const receiver = (0, import_viem6.getAddress)(i.address);
|
|
2325
|
+
const tokenAmount = BigInt((0, import_viem6.parseUnits)(i.amount, tokenData.decimals));
|
|
2326
|
+
return {
|
|
2327
|
+
address: receiver,
|
|
2328
|
+
amount: tokenAmount
|
|
2329
|
+
};
|
|
2330
|
+
}
|
|
2331
|
+
);
|
|
2332
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2333
|
+
const account = new ActaAccount(
|
|
2334
|
+
chainId,
|
|
2335
|
+
viemClient.publicClient(),
|
|
2336
|
+
walletClient
|
|
2337
|
+
);
|
|
2338
|
+
const {
|
|
2339
|
+
estimatedGasCostInToken,
|
|
2340
|
+
ActalinkFeesInToken,
|
|
2341
|
+
feeInclusiveAmountInToken,
|
|
2342
|
+
feeExclusiveAmountInToken,
|
|
2343
|
+
estimatedTotalFeesInToken,
|
|
2344
|
+
paymaster,
|
|
2345
|
+
userOperation
|
|
2346
|
+
} = yield account.estimateSingleBatchPaymentGas({
|
|
2347
|
+
chainId,
|
|
2348
|
+
feeInclusive: isFeeInclusive,
|
|
2349
|
+
signerAddress,
|
|
2350
|
+
token: token2,
|
|
2351
|
+
walletClient,
|
|
2352
|
+
receivers,
|
|
2353
|
+
totalAmount: totalAmountParsed,
|
|
2354
|
+
feebps: 20
|
|
2355
|
+
});
|
|
2356
|
+
return {
|
|
2357
|
+
estimatedGasCostInToken,
|
|
2358
|
+
ActalinkFeesInToken,
|
|
2359
|
+
feeInclusiveAmountInToken,
|
|
2360
|
+
feeExclusiveAmountInToken,
|
|
2361
|
+
estimatedTotalFeesInToken,
|
|
2362
|
+
paymaster,
|
|
2363
|
+
userOperation
|
|
2364
|
+
};
|
|
2365
|
+
} catch (error) {
|
|
2366
|
+
if (error instanceof Error) {
|
|
2367
|
+
throw new Error(error.message);
|
|
2368
|
+
}
|
|
2369
|
+
throw new Error("Failed to estimate single payment gas.");
|
|
2370
|
+
}
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
createSingleBatchPayment(params, serviceParams) {
|
|
2374
|
+
return __async(this, null, function* () {
|
|
2375
|
+
try {
|
|
2376
|
+
const {
|
|
2377
|
+
chainId,
|
|
2378
|
+
feeInclusive,
|
|
2379
|
+
signerAddress,
|
|
2380
|
+
token: tokenSymbol,
|
|
2381
|
+
walletClient,
|
|
2382
|
+
allowMaxTokenApproval,
|
|
2383
|
+
instructionId
|
|
2384
|
+
} = params;
|
|
2385
|
+
if (!this.APIkey) {
|
|
2386
|
+
throw new Error("No API key provided.");
|
|
2387
|
+
}
|
|
2388
|
+
let isFeeInclusive = false;
|
|
2389
|
+
if (feeInclusive) {
|
|
2390
|
+
isFeeInclusive = true;
|
|
2391
|
+
}
|
|
2392
|
+
const { envBatchServiceUrl } = returnEnvUrl2(chainId);
|
|
2393
|
+
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2394
|
+
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2395
|
+
this.APIkey
|
|
2396
|
+
);
|
|
2397
|
+
if (instuctionData.receivers.length === 0 || instuctionData.receivers.length === void 0) {
|
|
2398
|
+
throw new Error("Instruction not found");
|
|
2399
|
+
}
|
|
2400
|
+
console.log(instuctionData);
|
|
2401
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2402
|
+
if (!tokenData) {
|
|
2403
|
+
throw new Error("Token not supported");
|
|
2404
|
+
}
|
|
2405
|
+
const totalAmount = instuctionData.totalAmount;
|
|
2406
|
+
const totalAmountParsed = BigInt(
|
|
2407
|
+
(0, import_viem6.parseUnits)(totalAmount, tokenData.decimals)
|
|
2408
|
+
);
|
|
2409
|
+
const receivers = instuctionData.receivers.map(
|
|
2410
|
+
(i) => {
|
|
2411
|
+
const receiver = (0, import_viem6.getAddress)(i.address);
|
|
2412
|
+
const tokenAmount = BigInt((0, import_viem6.parseUnits)(i.amount, tokenData.decimals));
|
|
2413
|
+
return {
|
|
2414
|
+
address: receiver,
|
|
2415
|
+
amount: tokenAmount
|
|
2416
|
+
};
|
|
2417
|
+
}
|
|
2418
|
+
);
|
|
2419
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2420
|
+
const account = new ActaAccount(
|
|
2421
|
+
chainId,
|
|
2422
|
+
viemClient.publicClient(),
|
|
2423
|
+
walletClient
|
|
2424
|
+
);
|
|
2425
|
+
console.log("signing");
|
|
2426
|
+
const rpcParameters = yield account.signSingleBatchOperation({
|
|
2427
|
+
signerAddress,
|
|
2428
|
+
chainId,
|
|
2429
|
+
token: tokenSymbol,
|
|
2430
|
+
feeInclusive: isFeeInclusive,
|
|
2431
|
+
receivers,
|
|
2432
|
+
totalAmount: totalAmountParsed,
|
|
2433
|
+
walletClient,
|
|
2434
|
+
allowMaxTokenApproval,
|
|
2435
|
+
feebps: 20
|
|
2436
|
+
});
|
|
2437
|
+
const txn = yield executeSingleBatchPaymentAPICall(
|
|
2438
|
+
`${envBatchServiceUrl}execute/single/batch`,
|
|
2439
|
+
this.APIkey,
|
|
2440
|
+
rpcParameters,
|
|
2441
|
+
{
|
|
2442
|
+
senderAddress: signerAddress,
|
|
2443
|
+
chainId,
|
|
2444
|
+
tokenAddress: tokenData.address,
|
|
2445
|
+
amount: (0, import_viem6.toHex)(totalAmountParsed),
|
|
2446
|
+
feeInclusive: isFeeInclusive,
|
|
2447
|
+
serviceType: "batch"
|
|
2448
|
+
},
|
|
2449
|
+
serviceParams
|
|
2450
|
+
);
|
|
2451
|
+
return txn;
|
|
2452
|
+
} catch (error) {
|
|
2453
|
+
if (error instanceof Error) {
|
|
2454
|
+
throw new Error(error.message);
|
|
2455
|
+
}
|
|
2456
|
+
throw new Error("Failed to create payment.");
|
|
2457
|
+
}
|
|
2458
|
+
});
|
|
2459
|
+
}
|
|
2460
|
+
createScheduleBatchPayment(params, serviceParams) {
|
|
2461
|
+
return __async(this, null, function* () {
|
|
2462
|
+
try {
|
|
2463
|
+
const {
|
|
2464
|
+
chainId,
|
|
2465
|
+
feeInclusive,
|
|
2466
|
+
signerAddress,
|
|
2467
|
+
token: tokenSymbol,
|
|
2468
|
+
walletClient,
|
|
2469
|
+
allowMaxTokenApproval,
|
|
2470
|
+
instructionId,
|
|
2471
|
+
executionTime
|
|
2472
|
+
} = params;
|
|
2473
|
+
if (!this.APIkey) {
|
|
2474
|
+
throw new Error("No API key provided.");
|
|
2475
|
+
}
|
|
2476
|
+
let isFeeInclusive = false;
|
|
2477
|
+
if (feeInclusive) {
|
|
2478
|
+
isFeeInclusive = true;
|
|
2479
|
+
}
|
|
2480
|
+
const { envBatchServiceUrl } = returnEnvUrl2(chainId);
|
|
2481
|
+
if (executionTime <= Date.now() + 1e3 * 60 * 2) {
|
|
2482
|
+
throw new Error(
|
|
2483
|
+
"Execution time must be more than 5 mins from current time."
|
|
2484
|
+
);
|
|
2485
|
+
}
|
|
2486
|
+
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2487
|
+
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2488
|
+
this.APIkey
|
|
2489
|
+
);
|
|
2490
|
+
if (instuctionData.receivers.length === 0 || instuctionData.receivers.length === void 0) {
|
|
2491
|
+
throw new Error("Instruction not found");
|
|
2492
|
+
}
|
|
2493
|
+
console.log(instuctionData);
|
|
2494
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2495
|
+
if (!tokenData) {
|
|
2496
|
+
throw new Error("Token not supported");
|
|
2497
|
+
}
|
|
2498
|
+
const totalAmount = instuctionData.totalAmount;
|
|
2499
|
+
const totalAmountParsed = BigInt(
|
|
2500
|
+
(0, import_viem6.parseUnits)(totalAmount, tokenData.decimals)
|
|
2501
|
+
);
|
|
2502
|
+
const receivers = instuctionData.receivers.map(
|
|
2503
|
+
(i) => {
|
|
2504
|
+
const receiver = (0, import_viem6.getAddress)(i.address);
|
|
2505
|
+
const tokenAmount = BigInt((0, import_viem6.parseUnits)(i.amount, tokenData.decimals));
|
|
2506
|
+
return {
|
|
2507
|
+
address: receiver,
|
|
2508
|
+
amount: tokenAmount
|
|
2509
|
+
};
|
|
2510
|
+
}
|
|
2511
|
+
);
|
|
2512
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2513
|
+
const account = new ActaAccount(
|
|
2514
|
+
chainId,
|
|
2515
|
+
viemClient.publicClient(),
|
|
2516
|
+
walletClient
|
|
2517
|
+
);
|
|
2518
|
+
console.log("signing");
|
|
2519
|
+
const { amountExclusive, approval } = yield account.signRecurringOrScheduleBatchPayments({
|
|
2520
|
+
signerAddress,
|
|
2521
|
+
chainId,
|
|
2522
|
+
token: tokenSymbol,
|
|
2523
|
+
feeInclusive: isFeeInclusive,
|
|
2524
|
+
receivers,
|
|
2525
|
+
totalAmount: totalAmountParsed,
|
|
2526
|
+
walletClient,
|
|
2527
|
+
allowMaxTokenApproval,
|
|
2528
|
+
count: 1,
|
|
2529
|
+
feebps: 20
|
|
2530
|
+
});
|
|
2531
|
+
const txn = yield executeScheduleBatchPaymentAPICall(
|
|
2532
|
+
`${envBatchServiceUrl}execute/schedule/batch`,
|
|
2533
|
+
this.APIkey,
|
|
2534
|
+
{
|
|
2535
|
+
senderAddress: signerAddress,
|
|
2536
|
+
chainId,
|
|
2537
|
+
tokenAddress: tokenData.address,
|
|
2538
|
+
amount: (0, import_viem6.toHex)(totalAmountParsed),
|
|
2539
|
+
feeInclusive: isFeeInclusive,
|
|
2540
|
+
serviceType: "batch",
|
|
2541
|
+
amountExclusive: (0, import_viem6.toHex)(amountExclusive),
|
|
2542
|
+
approval,
|
|
2543
|
+
executionAt: executionTime
|
|
2544
|
+
},
|
|
2545
|
+
{
|
|
2546
|
+
sessionId: serviceParams.sessionId
|
|
2547
|
+
}
|
|
2548
|
+
);
|
|
2549
|
+
console.log(txn);
|
|
2550
|
+
return txn.transaction.id;
|
|
2551
|
+
} catch (error) {
|
|
2552
|
+
console.log(error);
|
|
2553
|
+
if (error instanceof Error) {
|
|
2554
|
+
throw new Error(error.message);
|
|
2555
|
+
}
|
|
2556
|
+
throw new Error("Failed to create payment.");
|
|
2557
|
+
}
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
createSingleBatchPaymentWithoutKey(params, serviceParams) {
|
|
2561
|
+
return __async(this, null, function* () {
|
|
2562
|
+
try {
|
|
2563
|
+
const {
|
|
2564
|
+
chainId,
|
|
2565
|
+
feeInclusive,
|
|
2566
|
+
signerAddress,
|
|
2567
|
+
token: tokenSymbol,
|
|
2568
|
+
walletClient,
|
|
2569
|
+
allowMaxTokenApproval,
|
|
2570
|
+
receivers,
|
|
2571
|
+
totalAmount
|
|
2572
|
+
} = params;
|
|
2573
|
+
let isFeeInclusive = false;
|
|
2574
|
+
if (feeInclusive) {
|
|
2575
|
+
isFeeInclusive = true;
|
|
2576
|
+
}
|
|
2577
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2578
|
+
if (!tokenData) {
|
|
2579
|
+
throw new Error("Token not supported");
|
|
2580
|
+
}
|
|
2581
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2582
|
+
const account = new ActaAccount(
|
|
2583
|
+
chainId,
|
|
2584
|
+
viemClient.publicClient(),
|
|
2585
|
+
walletClient
|
|
2586
|
+
);
|
|
2587
|
+
console.log("signing");
|
|
2588
|
+
const rpcParameters = yield account.signSingleBatchOperation({
|
|
2589
|
+
signerAddress,
|
|
2590
|
+
chainId,
|
|
2591
|
+
token: tokenSymbol,
|
|
2592
|
+
feeInclusive: isFeeInclusive,
|
|
2593
|
+
receivers,
|
|
2594
|
+
totalAmount,
|
|
2595
|
+
walletClient,
|
|
2596
|
+
allowMaxTokenApproval,
|
|
2597
|
+
feebps: 20
|
|
2598
|
+
});
|
|
2599
|
+
return {
|
|
2600
|
+
senderAddress: signerAddress,
|
|
2601
|
+
chainId,
|
|
2602
|
+
tokenAddress: tokenData.address,
|
|
2603
|
+
amount: (0, import_viem6.toHex)(totalAmount),
|
|
2604
|
+
feeInclusive: isFeeInclusive,
|
|
2605
|
+
serviceType: "batch",
|
|
2606
|
+
sessionId: serviceParams.sessionId,
|
|
2607
|
+
rpcParameters
|
|
2608
|
+
};
|
|
2609
|
+
} catch (error) {
|
|
2610
|
+
if (error instanceof Error) {
|
|
2611
|
+
throw new Error(error.message);
|
|
2612
|
+
}
|
|
2613
|
+
throw new Error("Failed to create payment.");
|
|
2614
|
+
}
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
createScheduleBatchPaymentWithoutKey(params, serviceParams) {
|
|
2618
|
+
return __async(this, null, function* () {
|
|
2619
|
+
try {
|
|
2620
|
+
const {
|
|
2621
|
+
chainId,
|
|
2622
|
+
feeInclusive,
|
|
2623
|
+
signerAddress,
|
|
2624
|
+
token: tokenSymbol,
|
|
2625
|
+
walletClient,
|
|
2626
|
+
allowMaxTokenApproval,
|
|
2627
|
+
executionTime,
|
|
2628
|
+
receivers,
|
|
2629
|
+
totalAmount
|
|
2630
|
+
} = params;
|
|
2631
|
+
let isFeeInclusive = false;
|
|
2632
|
+
if (feeInclusive) {
|
|
2633
|
+
isFeeInclusive = true;
|
|
2634
|
+
}
|
|
2635
|
+
const tokenData = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2636
|
+
if (!tokenData) {
|
|
2637
|
+
throw new Error("Token not supported");
|
|
2638
|
+
}
|
|
2639
|
+
const viemClient = new ViemClient(chainId, walletClient);
|
|
2640
|
+
const account = new ActaAccount(
|
|
2641
|
+
chainId,
|
|
2642
|
+
viemClient.publicClient(),
|
|
2643
|
+
walletClient
|
|
2644
|
+
);
|
|
2645
|
+
console.log("signing");
|
|
2646
|
+
const { amountExclusive, approval } = yield account.signRecurringOrScheduleBatchPayments({
|
|
2647
|
+
signerAddress,
|
|
2648
|
+
chainId,
|
|
2649
|
+
token: tokenSymbol,
|
|
2650
|
+
feeInclusive: isFeeInclusive,
|
|
2651
|
+
receivers,
|
|
2652
|
+
totalAmount,
|
|
2653
|
+
walletClient,
|
|
2654
|
+
allowMaxTokenApproval,
|
|
2655
|
+
count: 1,
|
|
2656
|
+
feebps: 20
|
|
2657
|
+
});
|
|
2658
|
+
return {
|
|
2659
|
+
senderAddress: signerAddress,
|
|
2660
|
+
chainId,
|
|
2661
|
+
tokenAddress: tokenData.address,
|
|
2662
|
+
amount: (0, import_viem6.toHex)(totalAmount),
|
|
2663
|
+
feeInclusive: isFeeInclusive,
|
|
2664
|
+
serviceType: "batch",
|
|
2665
|
+
amountExclusive: (0, import_viem6.toHex)(amountExclusive),
|
|
2666
|
+
approval,
|
|
2667
|
+
executionAt: executionTime,
|
|
2668
|
+
sessionId: serviceParams.sessionId
|
|
2669
|
+
};
|
|
2670
|
+
} catch (error) {
|
|
2671
|
+
console.log(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
|
+
};
|
|
2680
|
+
|
|
2681
|
+
// src/billing.ts
|
|
2682
|
+
var import_viem7 = require("viem");
|
|
2683
|
+
var billingServiceUrl = "https://api.acta.link/pay/api/v1/";
|
|
2684
|
+
var billingServiceTestUrl = "https://api.acta.link/pay/test/api/v1/";
|
|
2685
|
+
var returnEnvUrl3 = (chainId) => {
|
|
2159
2686
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2160
2687
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
2161
2688
|
if (!mainnetChain && !testnetChain) {
|
|
@@ -2257,7 +2784,7 @@ var ActaBilling = class {
|
|
|
2257
2784
|
if (!token2) {
|
|
2258
2785
|
throw new Error("Token not supported.");
|
|
2259
2786
|
}
|
|
2260
|
-
const { envBillingServiceUrl } =
|
|
2787
|
+
const { envBillingServiceUrl } = returnEnvUrl3(chainId);
|
|
2261
2788
|
const rpcParameters = yield this.account.signSinglePaymentOperation({
|
|
2262
2789
|
signerAddress,
|
|
2263
2790
|
chainId,
|
|
@@ -2276,7 +2803,7 @@ var ActaBilling = class {
|
|
|
2276
2803
|
receiverAddress: receiver,
|
|
2277
2804
|
chainId,
|
|
2278
2805
|
tokenAddress: token2.address,
|
|
2279
|
-
amount: (0,
|
|
2806
|
+
amount: (0, import_viem7.toHex)(amount),
|
|
2280
2807
|
feeInclusive,
|
|
2281
2808
|
serviceType
|
|
2282
2809
|
},
|
|
@@ -2320,7 +2847,7 @@ var ActaBilling = class {
|
|
|
2320
2847
|
if (!chainId || !count || !intervalUnit || !startDate || !endDate) {
|
|
2321
2848
|
throw new Error("Invalid parameters.");
|
|
2322
2849
|
}
|
|
2323
|
-
const { envBillingServiceUrl } =
|
|
2850
|
+
const { envBillingServiceUrl } = returnEnvUrl3(chainId);
|
|
2324
2851
|
const { approval, amountExclusive } = yield this.account.signRecurringPayments({
|
|
2325
2852
|
signerAddress,
|
|
2326
2853
|
chainId,
|
|
@@ -2393,10 +2920,10 @@ var ActaBilling = class {
|
|
|
2393
2920
|
};
|
|
2394
2921
|
|
|
2395
2922
|
// src/batch.ts
|
|
2396
|
-
var
|
|
2397
|
-
var
|
|
2398
|
-
var
|
|
2399
|
-
var
|
|
2923
|
+
var import_viem8 = require("viem");
|
|
2924
|
+
var batchServiceUrl2 = "https://api.acta.link/bexo/api/v1/";
|
|
2925
|
+
var batchServiceTestUrl2 = "https://api.acta.link/bexo/test/api/v1/";
|
|
2926
|
+
var returnEnvUrl4 = (chainId) => {
|
|
2400
2927
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2401
2928
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
2402
2929
|
if (!mainnetChain && !testnetChain) {
|
|
@@ -2404,11 +2931,11 @@ var returnEnvUrl3 = (chainId) => {
|
|
|
2404
2931
|
}
|
|
2405
2932
|
if (mainnetChain) {
|
|
2406
2933
|
return {
|
|
2407
|
-
envBatchServiceUrl:
|
|
2934
|
+
envBatchServiceUrl: batchServiceUrl2
|
|
2408
2935
|
};
|
|
2409
2936
|
} else {
|
|
2410
2937
|
return {
|
|
2411
|
-
envBatchServiceUrl:
|
|
2938
|
+
envBatchServiceUrl: batchServiceTestUrl2
|
|
2412
2939
|
};
|
|
2413
2940
|
}
|
|
2414
2941
|
};
|
|
@@ -2424,7 +2951,7 @@ var ActaBatch = class {
|
|
|
2424
2951
|
if (!this.APIkey) {
|
|
2425
2952
|
throw new Error("No API key provided.");
|
|
2426
2953
|
}
|
|
2427
|
-
if (!signerAddress || signerAddress ===
|
|
2954
|
+
if (!signerAddress || signerAddress === import_viem8.zeroAddress) {
|
|
2428
2955
|
throw new Error("Signer address is required.");
|
|
2429
2956
|
}
|
|
2430
2957
|
if (!name || name === "") {
|
|
@@ -2436,7 +2963,7 @@ var ActaBatch = class {
|
|
|
2436
2963
|
if (!instructionId || instructionId === "") {
|
|
2437
2964
|
throw new Error("Instruction id is required");
|
|
2438
2965
|
}
|
|
2439
|
-
const { envBatchServiceUrl } =
|
|
2966
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2440
2967
|
const session = yield createBatchSessionAPICall(
|
|
2441
2968
|
`${envBatchServiceUrl}create/session`,
|
|
2442
2969
|
this.APIkey,
|
|
@@ -2477,7 +3004,7 @@ var ActaBatch = class {
|
|
|
2477
3004
|
if (feeInclusive) {
|
|
2478
3005
|
isFeeInclusive = true;
|
|
2479
3006
|
}
|
|
2480
|
-
const { envBatchServiceUrl } =
|
|
3007
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2481
3008
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2482
3009
|
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2483
3010
|
this.APIkey
|
|
@@ -2491,12 +3018,12 @@ var ActaBatch = class {
|
|
|
2491
3018
|
}
|
|
2492
3019
|
const totalAmount = instuctionData.totalAmount;
|
|
2493
3020
|
const totalAmountParsed = BigInt(
|
|
2494
|
-
(0,
|
|
3021
|
+
(0, import_viem8.parseUnits)(totalAmount, tokenData.decimals)
|
|
2495
3022
|
);
|
|
2496
3023
|
const receivers = instuctionData.receivers.map(
|
|
2497
3024
|
(i) => {
|
|
2498
|
-
const receiver = (0,
|
|
2499
|
-
const tokenAmount = BigInt((0,
|
|
3025
|
+
const receiver = (0, import_viem8.getAddress)(i.address);
|
|
3026
|
+
const tokenAmount = BigInt((0, import_viem8.parseUnits)(i.amount, tokenData.decimals));
|
|
2500
3027
|
return {
|
|
2501
3028
|
address: receiver,
|
|
2502
3029
|
amount: tokenAmount
|
|
@@ -2563,7 +3090,7 @@ var ActaBatch = class {
|
|
|
2563
3090
|
if (feeInclusive) {
|
|
2564
3091
|
isFeeInclusive = true;
|
|
2565
3092
|
}
|
|
2566
|
-
const { envBatchServiceUrl } =
|
|
3093
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2567
3094
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2568
3095
|
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2569
3096
|
this.APIkey
|
|
@@ -2578,12 +3105,12 @@ var ActaBatch = class {
|
|
|
2578
3105
|
}
|
|
2579
3106
|
const totalAmount = instuctionData.totalAmount;
|
|
2580
3107
|
const totalAmountParsed = BigInt(
|
|
2581
|
-
(0,
|
|
3108
|
+
(0, import_viem8.parseUnits)(totalAmount, tokenData.decimals)
|
|
2582
3109
|
);
|
|
2583
3110
|
const receivers = instuctionData.receivers.map(
|
|
2584
3111
|
(i) => {
|
|
2585
|
-
const receiver = (0,
|
|
2586
|
-
const tokenAmount = BigInt((0,
|
|
3112
|
+
const receiver = (0, import_viem8.getAddress)(i.address);
|
|
3113
|
+
const tokenAmount = BigInt((0, import_viem8.parseUnits)(i.amount, tokenData.decimals));
|
|
2587
3114
|
return {
|
|
2588
3115
|
address: receiver,
|
|
2589
3116
|
amount: tokenAmount
|
|
@@ -2616,7 +3143,7 @@ var ActaBatch = class {
|
|
|
2616
3143
|
senderAddress: signerAddress,
|
|
2617
3144
|
chainId,
|
|
2618
3145
|
tokenAddress: tokenData.address,
|
|
2619
|
-
amount: (0,
|
|
3146
|
+
amount: (0, import_viem8.toHex)(totalAmountParsed),
|
|
2620
3147
|
feeInclusive: isFeeInclusive,
|
|
2621
3148
|
serviceType: "batch"
|
|
2622
3149
|
},
|
|
@@ -2651,7 +3178,7 @@ var ActaBatch = class {
|
|
|
2651
3178
|
if (feeInclusive) {
|
|
2652
3179
|
isFeeInclusive = true;
|
|
2653
3180
|
}
|
|
2654
|
-
const { envBatchServiceUrl } =
|
|
3181
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2655
3182
|
if (executionTime <= Date.now() + 1e3 * 60 * 2) {
|
|
2656
3183
|
throw new Error(
|
|
2657
3184
|
"Execution time must be more than 5 mins from current time."
|
|
@@ -2671,12 +3198,12 @@ var ActaBatch = class {
|
|
|
2671
3198
|
}
|
|
2672
3199
|
const totalAmount = instuctionData.totalAmount;
|
|
2673
3200
|
const totalAmountParsed = BigInt(
|
|
2674
|
-
(0,
|
|
3201
|
+
(0, import_viem8.parseUnits)(totalAmount, tokenData.decimals)
|
|
2675
3202
|
);
|
|
2676
3203
|
const receivers = instuctionData.receivers.map(
|
|
2677
3204
|
(i) => {
|
|
2678
|
-
const receiver = (0,
|
|
2679
|
-
const tokenAmount = BigInt((0,
|
|
3205
|
+
const receiver = (0, import_viem8.getAddress)(i.address);
|
|
3206
|
+
const tokenAmount = BigInt((0, import_viem8.parseUnits)(i.amount, tokenData.decimals));
|
|
2680
3207
|
return {
|
|
2681
3208
|
address: receiver,
|
|
2682
3209
|
amount: tokenAmount
|
|
@@ -2709,10 +3236,10 @@ var ActaBatch = class {
|
|
|
2709
3236
|
senderAddress: signerAddress,
|
|
2710
3237
|
chainId,
|
|
2711
3238
|
tokenAddress: tokenData.address,
|
|
2712
|
-
amount: (0,
|
|
3239
|
+
amount: (0, import_viem8.toHex)(totalAmountParsed),
|
|
2713
3240
|
feeInclusive: isFeeInclusive,
|
|
2714
3241
|
serviceType: "batch",
|
|
2715
|
-
amountExclusive: (0,
|
|
3242
|
+
amountExclusive: (0, import_viem8.toHex)(amountExclusive),
|
|
2716
3243
|
approval,
|
|
2717
3244
|
executionAt: executionTime
|
|
2718
3245
|
},
|
|
@@ -2774,7 +3301,7 @@ var ActaBatch = class {
|
|
|
2774
3301
|
senderAddress: signerAddress,
|
|
2775
3302
|
chainId,
|
|
2776
3303
|
tokenAddress: tokenData.address,
|
|
2777
|
-
amount: (0,
|
|
3304
|
+
amount: (0, import_viem8.toHex)(totalAmount),
|
|
2778
3305
|
feeInclusive: isFeeInclusive,
|
|
2779
3306
|
serviceType: "batch",
|
|
2780
3307
|
sessionId: serviceParams.sessionId,
|
|
@@ -2833,10 +3360,10 @@ var ActaBatch = class {
|
|
|
2833
3360
|
senderAddress: signerAddress,
|
|
2834
3361
|
chainId,
|
|
2835
3362
|
tokenAddress: tokenData.address,
|
|
2836
|
-
amount: (0,
|
|
3363
|
+
amount: (0, import_viem8.toHex)(totalAmount),
|
|
2837
3364
|
feeInclusive: isFeeInclusive,
|
|
2838
3365
|
serviceType: "batch",
|
|
2839
|
-
amountExclusive: (0,
|
|
3366
|
+
amountExclusive: (0, import_viem8.toHex)(amountExclusive),
|
|
2840
3367
|
approval,
|
|
2841
3368
|
executionAt: executionTime,
|
|
2842
3369
|
sessionId: serviceParams.sessionId
|
|
@@ -2855,7 +3382,7 @@ var ActaBatch = class {
|
|
|
2855
3382
|
// src/utils.ts
|
|
2856
3383
|
var import_sdk2 = require("@zerodev/sdk");
|
|
2857
3384
|
var import_accounts = require("@zerodev/sdk/accounts");
|
|
2858
|
-
var
|
|
3385
|
+
var import_viem9 = require("viem");
|
|
2859
3386
|
var import_accounts2 = require("viem/accounts");
|
|
2860
3387
|
var import_actions = require("viem/actions");
|
|
2861
3388
|
var import_utils2 = require("viem/utils");
|
|
@@ -2863,14 +3390,14 @@ var import_account_abstraction2 = require("viem/account-abstraction");
|
|
|
2863
3390
|
var import_policies2 = require("@zerodev/permissions/policies");
|
|
2864
3391
|
var import_semver = require("semver");
|
|
2865
3392
|
var ECDSA_SIGNER_CONTRACT = "0x6A6F069E2a08c2468e7724Ab3250CdBFBA14D4FF";
|
|
2866
|
-
var billingServiceUrl2 = "https://api.
|
|
3393
|
+
var billingServiceUrl2 = "https://api.acta.link/pay/v1/";
|
|
2867
3394
|
var depositServiceUrl2 = "https://api.acta.link/bexo/v1/";
|
|
2868
|
-
var transactionServiceUrl2 = "https://api.
|
|
2869
|
-
var billingServiceTestUrl2 = "https://api.
|
|
3395
|
+
var transactionServiceUrl2 = "https://api.acta.link/transaction/v1/";
|
|
3396
|
+
var billingServiceTestUrl2 = "https://api.acta.link/pay/test/v1/";
|
|
2870
3397
|
var toSignerId = (signer) => {
|
|
2871
|
-
return (0,
|
|
3398
|
+
return (0, import_viem9.encodeAbiParameters)(
|
|
2872
3399
|
[{ name: "signerData", type: "bytes" }],
|
|
2873
|
-
[(0,
|
|
3400
|
+
[(0, import_viem9.concat)([signer.signerContractAddress, signer.getSignerData()])]
|
|
2874
3401
|
);
|
|
2875
3402
|
};
|
|
2876
3403
|
function toECDSASigner2(_0) {
|
|
@@ -2907,11 +3434,11 @@ function toECDSASigner2(_0) {
|
|
|
2907
3434
|
});
|
|
2908
3435
|
}
|
|
2909
3436
|
var toPolicyId = (policies) => {
|
|
2910
|
-
return (0,
|
|
3437
|
+
return (0, import_viem9.encodeAbiParameters)(
|
|
2911
3438
|
[{ name: "policiesData", type: "bytes[]" }],
|
|
2912
3439
|
[
|
|
2913
3440
|
policies.map(
|
|
2914
|
-
(policy) => (0,
|
|
3441
|
+
(policy) => (0, import_viem9.concat)([policy.getPolicyInfoInBytes(), policy.getPolicyData()])
|
|
2915
3442
|
)
|
|
2916
3443
|
]
|
|
2917
3444
|
);
|
|
@@ -2929,38 +3456,38 @@ function toPermissionValidator2(_0, _1) {
|
|
|
2929
3456
|
throw new Error("Only EntryPoint 0.7 is supported");
|
|
2930
3457
|
}
|
|
2931
3458
|
const getEnableData = (_kernelAccountAddress) => __async(null, null, function* () {
|
|
2932
|
-
const enableData = (0,
|
|
3459
|
+
const enableData = (0, import_viem9.encodeAbiParameters)(
|
|
2933
3460
|
[{ name: "policyAndSignerData", type: "bytes[]" }],
|
|
2934
3461
|
[
|
|
2935
3462
|
[
|
|
2936
3463
|
...policies.map(
|
|
2937
|
-
(policy) => (0,
|
|
3464
|
+
(policy) => (0, import_viem9.concat)([policy.getPolicyInfoInBytes(), policy.getPolicyData()])
|
|
2938
3465
|
),
|
|
2939
|
-
(0,
|
|
3466
|
+
(0, import_viem9.concat)([flag, signer.signerContractAddress, signer.getSignerData()])
|
|
2940
3467
|
]
|
|
2941
3468
|
]
|
|
2942
3469
|
);
|
|
2943
3470
|
return enableData;
|
|
2944
3471
|
});
|
|
2945
3472
|
const getPermissionId = () => {
|
|
2946
|
-
const pIdData = (0,
|
|
3473
|
+
const pIdData = (0, import_viem9.encodeAbiParameters)(
|
|
2947
3474
|
[{ name: "policyAndSignerData", type: "bytes[]" }],
|
|
2948
3475
|
[[toPolicyId(policies), flag, toSignerId(signer)]]
|
|
2949
3476
|
);
|
|
2950
|
-
return (0,
|
|
3477
|
+
return (0, import_viem9.slice)((0, import_viem9.keccak256)(pIdData), 0, 4);
|
|
2951
3478
|
};
|
|
2952
3479
|
return __spreadProps(__spreadValues({}, signer.account), {
|
|
2953
3480
|
supportedKernelVersions: ">=0.3.0",
|
|
2954
3481
|
validatorType: "PERMISSION",
|
|
2955
|
-
address:
|
|
3482
|
+
address: import_viem9.zeroAddress,
|
|
2956
3483
|
source: "PermissionValidator",
|
|
2957
3484
|
getEnableData,
|
|
2958
3485
|
getIdentifier: getPermissionId,
|
|
2959
3486
|
signMessage: (_02) => __async(null, [_02], function* ({ message }) {
|
|
2960
|
-
return (0,
|
|
3487
|
+
return (0, import_viem9.concat)(["0xff", yield signer.account.signMessage({ message })]);
|
|
2961
3488
|
}),
|
|
2962
3489
|
signTypedData: (typedData) => __async(null, null, function* () {
|
|
2963
|
-
return (0,
|
|
3490
|
+
return (0, import_viem9.concat)(["0xff", yield signer.account.signTypedData(typedData)]);
|
|
2964
3491
|
}),
|
|
2965
3492
|
signUserOperation: (userOperation) => __async(null, null, function* () {
|
|
2966
3493
|
const userOpHash = (0, import_account_abstraction2.getUserOperationHash)({
|
|
@@ -2974,7 +3501,7 @@ function toPermissionValidator2(_0, _1) {
|
|
|
2974
3501
|
const signature = yield signer.account.signMessage({
|
|
2975
3502
|
message: { raw: userOpHash }
|
|
2976
3503
|
});
|
|
2977
|
-
return (0,
|
|
3504
|
+
return (0, import_viem9.concat)(["0xff", signature]);
|
|
2978
3505
|
}),
|
|
2979
3506
|
getNonceKey(_accountAddress, customNonceKey) {
|
|
2980
3507
|
return __async(this, null, function* () {
|
|
@@ -2986,7 +3513,7 @@ function toPermissionValidator2(_0, _1) {
|
|
|
2986
3513
|
},
|
|
2987
3514
|
getStubSignature(_userOperation) {
|
|
2988
3515
|
return __async(this, null, function* () {
|
|
2989
|
-
return (0,
|
|
3516
|
+
return (0, import_viem9.concat)(["0xff", signer.getDummySignature()]);
|
|
2990
3517
|
});
|
|
2991
3518
|
},
|
|
2992
3519
|
getPluginSerializationParams: () => {
|
|
@@ -3123,12 +3650,12 @@ var decodeParamsFromInitCode = (initCode, kernelVersion) => {
|
|
|
3123
3650
|
};
|
|
3124
3651
|
}
|
|
3125
3652
|
try {
|
|
3126
|
-
deployWithFactoryFunctionData = (0,
|
|
3653
|
+
deployWithFactoryFunctionData = (0, import_viem9.decodeFunctionData)({
|
|
3127
3654
|
abi: import_sdk2.KernelFactoryStakerAbi,
|
|
3128
3655
|
data: initCode
|
|
3129
3656
|
});
|
|
3130
3657
|
} catch (error) {
|
|
3131
|
-
deployWithFactoryFunctionData = (0,
|
|
3658
|
+
deployWithFactoryFunctionData = (0, import_viem9.decodeFunctionData)({
|
|
3132
3659
|
abi: import_sdk2.KernelV3FactoryAbi,
|
|
3133
3660
|
data: initCode
|
|
3134
3661
|
});
|
|
@@ -3139,12 +3666,12 @@ var decodeParamsFromInitCode = (initCode, kernelVersion) => {
|
|
|
3139
3666
|
index = BigInt(deployWithFactoryFunctionData.args[2]);
|
|
3140
3667
|
let initializeFunctionData;
|
|
3141
3668
|
if (kernelVersion === "0.3.0") {
|
|
3142
|
-
initializeFunctionData = (0,
|
|
3669
|
+
initializeFunctionData = (0, import_viem9.decodeFunctionData)({
|
|
3143
3670
|
abi: import_sdk2.KernelV3AccountAbi,
|
|
3144
3671
|
data: deployWithFactoryFunctionData.args[1]
|
|
3145
3672
|
});
|
|
3146
3673
|
} else {
|
|
3147
|
-
initializeFunctionData = (0,
|
|
3674
|
+
initializeFunctionData = (0, import_viem9.decodeFunctionData)({
|
|
3148
3675
|
abi: import_sdk2.KernelV3_1AccountAbi,
|
|
3149
3676
|
data: deployWithFactoryFunctionData.args[1]
|
|
3150
3677
|
});
|
|
@@ -3162,12 +3689,12 @@ var decodeParamsFromInitCode = (initCode, kernelVersion) => {
|
|
|
3162
3689
|
index = BigInt(deployWithFactoryFunctionData.args[1]);
|
|
3163
3690
|
let initializeFunctionData;
|
|
3164
3691
|
if (kernelVersion === "0.3.0") {
|
|
3165
|
-
initializeFunctionData = (0,
|
|
3692
|
+
initializeFunctionData = (0, import_viem9.decodeFunctionData)({
|
|
3166
3693
|
abi: import_sdk2.KernelV3AccountAbi,
|
|
3167
3694
|
data: deployWithFactoryFunctionData.args[0]
|
|
3168
3695
|
});
|
|
3169
3696
|
} else {
|
|
3170
|
-
initializeFunctionData = (0,
|
|
3697
|
+
initializeFunctionData = (0, import_viem9.decodeFunctionData)({
|
|
3171
3698
|
abi: import_sdk2.KernelV3_1AccountAbi,
|
|
3172
3699
|
data: deployWithFactoryFunctionData.args[0]
|
|
3173
3700
|
});
|
|
@@ -3270,12 +3797,12 @@ var cancelRecurringTransaction = (_0) => __async(null, [_0], function* ({
|
|
|
3270
3797
|
);
|
|
3271
3798
|
console.log(`sender: ${response.senderAddress}`);
|
|
3272
3799
|
console.log(`receiver: ${response.receiverAddress}`);
|
|
3273
|
-
console.log(`amountEx: ${(0,
|
|
3800
|
+
console.log(`amountEx: ${(0, import_viem9.hexToBigInt)(response.amountExclusive)}`);
|
|
3274
3801
|
console.log(`token: ${response.tokenAddress}`);
|
|
3275
3802
|
const rpcParameters = yield account.signRecurringTransactionCancellation({
|
|
3276
3803
|
signerAddress: response.senderAddress,
|
|
3277
3804
|
receiverAddress: response.receiverAddress,
|
|
3278
|
-
amountExclusive: (0,
|
|
3805
|
+
amountExclusive: (0, import_viem9.hexToBigInt)(response.amountExclusive),
|
|
3279
3806
|
token: response.tokenAddress
|
|
3280
3807
|
});
|
|
3281
3808
|
console.log(rpcParameters);
|
|
@@ -3299,7 +3826,8 @@ var cancelRecurringTransaction = (_0) => __async(null, [_0], function* ({
|
|
|
3299
3826
|
ActaAccount,
|
|
3300
3827
|
ActaBatch,
|
|
3301
3828
|
ActaBilling,
|
|
3302
|
-
|
|
3829
|
+
ActaFlexBatch,
|
|
3830
|
+
ActaFlexDeposit,
|
|
3303
3831
|
ConnectorType,
|
|
3304
3832
|
HttpMethod,
|
|
3305
3833
|
PolicyFlags,
|