@actalink/commonlib 0.0.40 → 0.0.42
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 +528 -66
- package/dist/index.d.cts +72 -2
- package/dist/index.d.ts +72 -2
- package/dist/index.js +513 -47
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -564,7 +564,7 @@ function getTokenByChainIdAndAddress(chainId, address) {
|
|
|
564
564
|
return token2;
|
|
565
565
|
}
|
|
566
566
|
|
|
567
|
-
// src/
|
|
567
|
+
// src/flexdeposit.ts
|
|
568
568
|
import { toHex as toHex3, zeroAddress as zeroAddress3 } from "viem";
|
|
569
569
|
|
|
570
570
|
// src/account.ts
|
|
@@ -1775,11 +1775,11 @@ function fetchBatchInstructionDetails(url, APIKey) {
|
|
|
1775
1775
|
});
|
|
1776
1776
|
}
|
|
1777
1777
|
|
|
1778
|
-
// src/
|
|
1779
|
-
var transactionServiceUrl = "https://api.acta.link/
|
|
1780
|
-
var depositServiceUrl = "https://api.acta.link/
|
|
1781
|
-
var transactionServiceTestUrl = "https://api.acta.link/
|
|
1782
|
-
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/";
|
|
1783
1783
|
var returnEnvUrl = (chainId) => {
|
|
1784
1784
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
1785
1785
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
@@ -1798,7 +1798,7 @@ var returnEnvUrl = (chainId) => {
|
|
|
1798
1798
|
};
|
|
1799
1799
|
}
|
|
1800
1800
|
};
|
|
1801
|
-
var
|
|
1801
|
+
var ActaFlexDeposit = class {
|
|
1802
1802
|
constructor(parameters) {
|
|
1803
1803
|
this.feeInclusive = false;
|
|
1804
1804
|
this.count = 0;
|
|
@@ -1808,7 +1808,7 @@ var ActaDeposit = class {
|
|
|
1808
1808
|
this.serviceSessionParams = void 0;
|
|
1809
1809
|
this.depositSessionId = "";
|
|
1810
1810
|
this.status = "not_started";
|
|
1811
|
-
this.serviceType = "
|
|
1811
|
+
this.serviceType = "deposit";
|
|
1812
1812
|
this.allowMaxTokenApproval = false;
|
|
1813
1813
|
var _a, _b, _c;
|
|
1814
1814
|
this.connectorType = parameters.connectorType;
|
|
@@ -1933,7 +1933,7 @@ var ActaDeposit = class {
|
|
|
1933
1933
|
return __async(this, null, function* () {
|
|
1934
1934
|
try {
|
|
1935
1935
|
if (this.paymentType === "single") {
|
|
1936
|
-
const paymentParams = this.serviceType === "
|
|
1936
|
+
const paymentParams = this.serviceType === "deposit" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
|
|
1937
1937
|
depositSessionId: this.depositSessionId
|
|
1938
1938
|
}) : servicePaymentParams;
|
|
1939
1939
|
const id = yield this.createSinglePayment(paymentParams);
|
|
@@ -1942,7 +1942,7 @@ var ActaDeposit = class {
|
|
|
1942
1942
|
if (this.paymentType === "choose") {
|
|
1943
1943
|
}
|
|
1944
1944
|
if (this.paymentType === "recurring") {
|
|
1945
|
-
const paymentParams = this.serviceType === "
|
|
1945
|
+
const paymentParams = this.serviceType === "deposit" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
|
|
1946
1946
|
depositSessionId: this.depositSessionId
|
|
1947
1947
|
}) : servicePaymentParams;
|
|
1948
1948
|
const id = yield this.createRecurringPayments(paymentParams);
|
|
@@ -2147,11 +2147,476 @@ var ActaDeposit = class {
|
|
|
2147
2147
|
}
|
|
2148
2148
|
};
|
|
2149
2149
|
|
|
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/";
|
|
2159
|
+
var returnEnvUrl2 = (chainId) => {
|
|
2160
|
+
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2161
|
+
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
2162
|
+
if (!mainnetChain && !testnetChain) {
|
|
2163
|
+
throw new Error(`Chain ${chainId} not supported.`);
|
|
2164
|
+
}
|
|
2165
|
+
if (mainnetChain) {
|
|
2166
|
+
return {
|
|
2167
|
+
envBatchServiceUrl: batchServiceUrl
|
|
2168
|
+
};
|
|
2169
|
+
} else {
|
|
2170
|
+
return {
|
|
2171
|
+
envBatchServiceUrl: batchServiceTestUrl
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
var ActaFlexBatch = class {
|
|
2176
|
+
constructor(parameters) {
|
|
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
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
estimateSinglePaymentGas(parameters) {
|
|
2223
|
+
return __async(this, null, function* () {
|
|
2224
|
+
try {
|
|
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");
|
|
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
|
+
);
|
|
2272
|
+
const {
|
|
2273
|
+
estimatedGasCostInToken,
|
|
2274
|
+
ActalinkFeesInToken,
|
|
2275
|
+
feeInclusiveAmountInToken,
|
|
2276
|
+
feeExclusiveAmountInToken,
|
|
2277
|
+
estimatedTotalFeesInToken,
|
|
2278
|
+
paymaster,
|
|
2279
|
+
userOperation
|
|
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
|
+
});
|
|
2290
|
+
return {
|
|
2291
|
+
estimatedGasCostInToken,
|
|
2292
|
+
ActalinkFeesInToken,
|
|
2293
|
+
feeInclusiveAmountInToken,
|
|
2294
|
+
feeExclusiveAmountInToken,
|
|
2295
|
+
estimatedTotalFeesInToken,
|
|
2296
|
+
paymaster,
|
|
2297
|
+
userOperation
|
|
2298
|
+
};
|
|
2299
|
+
} catch (error) {
|
|
2300
|
+
if (error instanceof Error) {
|
|
2301
|
+
throw new Error(error.message);
|
|
2302
|
+
}
|
|
2303
|
+
throw new Error("Failed to estimate single payment gas.");
|
|
2304
|
+
}
|
|
2305
|
+
});
|
|
2306
|
+
}
|
|
2307
|
+
createSingleBatchPayment(params, serviceParams) {
|
|
2308
|
+
return __async(this, null, function* () {
|
|
2309
|
+
try {
|
|
2310
|
+
const {
|
|
2311
|
+
chainId,
|
|
2312
|
+
feeInclusive,
|
|
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.");
|
|
2321
|
+
}
|
|
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
|
+
|
|
2150
2615
|
// src/billing.ts
|
|
2151
|
-
import { toHex as
|
|
2616
|
+
import { toHex as toHex5 } from "viem";
|
|
2152
2617
|
var billingServiceUrl = "https://api.acta.link/pay/api/v1/";
|
|
2153
2618
|
var billingServiceTestUrl = "https://api.acta.link/pay/test/api/v1/";
|
|
2154
|
-
var
|
|
2619
|
+
var returnEnvUrl3 = (chainId) => {
|
|
2155
2620
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2156
2621
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
2157
2622
|
if (!mainnetChain && !testnetChain) {
|
|
@@ -2253,7 +2718,7 @@ var ActaBilling = class {
|
|
|
2253
2718
|
if (!token2) {
|
|
2254
2719
|
throw new Error("Token not supported.");
|
|
2255
2720
|
}
|
|
2256
|
-
const { envBillingServiceUrl } =
|
|
2721
|
+
const { envBillingServiceUrl } = returnEnvUrl3(chainId);
|
|
2257
2722
|
const rpcParameters = yield this.account.signSinglePaymentOperation({
|
|
2258
2723
|
signerAddress,
|
|
2259
2724
|
chainId,
|
|
@@ -2272,7 +2737,7 @@ var ActaBilling = class {
|
|
|
2272
2737
|
receiverAddress: receiver,
|
|
2273
2738
|
chainId,
|
|
2274
2739
|
tokenAddress: token2.address,
|
|
2275
|
-
amount:
|
|
2740
|
+
amount: toHex5(amount),
|
|
2276
2741
|
feeInclusive,
|
|
2277
2742
|
serviceType
|
|
2278
2743
|
},
|
|
@@ -2316,7 +2781,7 @@ var ActaBilling = class {
|
|
|
2316
2781
|
if (!chainId || !count || !intervalUnit || !startDate || !endDate) {
|
|
2317
2782
|
throw new Error("Invalid parameters.");
|
|
2318
2783
|
}
|
|
2319
|
-
const { envBillingServiceUrl } =
|
|
2784
|
+
const { envBillingServiceUrl } = returnEnvUrl3(chainId);
|
|
2320
2785
|
const { approval, amountExclusive } = yield this.account.signRecurringPayments({
|
|
2321
2786
|
signerAddress,
|
|
2322
2787
|
chainId,
|
|
@@ -2390,14 +2855,14 @@ var ActaBilling = class {
|
|
|
2390
2855
|
|
|
2391
2856
|
// src/batch.ts
|
|
2392
2857
|
import {
|
|
2393
|
-
getAddress as
|
|
2394
|
-
parseUnits,
|
|
2395
|
-
toHex as
|
|
2396
|
-
zeroAddress as
|
|
2858
|
+
getAddress as getAddress4,
|
|
2859
|
+
parseUnits as parseUnits2,
|
|
2860
|
+
toHex as toHex6,
|
|
2861
|
+
zeroAddress as zeroAddress5
|
|
2397
2862
|
} from "viem";
|
|
2398
|
-
var
|
|
2399
|
-
var
|
|
2400
|
-
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) => {
|
|
2401
2866
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2402
2867
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
2403
2868
|
if (!mainnetChain && !testnetChain) {
|
|
@@ -2405,11 +2870,11 @@ var returnEnvUrl3 = (chainId) => {
|
|
|
2405
2870
|
}
|
|
2406
2871
|
if (mainnetChain) {
|
|
2407
2872
|
return {
|
|
2408
|
-
envBatchServiceUrl:
|
|
2873
|
+
envBatchServiceUrl: batchServiceUrl2
|
|
2409
2874
|
};
|
|
2410
2875
|
} else {
|
|
2411
2876
|
return {
|
|
2412
|
-
envBatchServiceUrl:
|
|
2877
|
+
envBatchServiceUrl: batchServiceTestUrl2
|
|
2413
2878
|
};
|
|
2414
2879
|
}
|
|
2415
2880
|
};
|
|
@@ -2425,7 +2890,7 @@ var ActaBatch = class {
|
|
|
2425
2890
|
if (!this.APIkey) {
|
|
2426
2891
|
throw new Error("No API key provided.");
|
|
2427
2892
|
}
|
|
2428
|
-
if (!signerAddress || signerAddress ===
|
|
2893
|
+
if (!signerAddress || signerAddress === zeroAddress5) {
|
|
2429
2894
|
throw new Error("Signer address is required.");
|
|
2430
2895
|
}
|
|
2431
2896
|
if (!name || name === "") {
|
|
@@ -2437,7 +2902,7 @@ var ActaBatch = class {
|
|
|
2437
2902
|
if (!instructionId || instructionId === "") {
|
|
2438
2903
|
throw new Error("Instruction id is required");
|
|
2439
2904
|
}
|
|
2440
|
-
const { envBatchServiceUrl } =
|
|
2905
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2441
2906
|
const session = yield createBatchSessionAPICall(
|
|
2442
2907
|
`${envBatchServiceUrl}create/session`,
|
|
2443
2908
|
this.APIkey,
|
|
@@ -2478,7 +2943,7 @@ var ActaBatch = class {
|
|
|
2478
2943
|
if (feeInclusive) {
|
|
2479
2944
|
isFeeInclusive = true;
|
|
2480
2945
|
}
|
|
2481
|
-
const { envBatchServiceUrl } =
|
|
2946
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2482
2947
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2483
2948
|
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2484
2949
|
this.APIkey
|
|
@@ -2492,12 +2957,12 @@ var ActaBatch = class {
|
|
|
2492
2957
|
}
|
|
2493
2958
|
const totalAmount = instuctionData.totalAmount;
|
|
2494
2959
|
const totalAmountParsed = BigInt(
|
|
2495
|
-
|
|
2960
|
+
parseUnits2(totalAmount, tokenData.decimals)
|
|
2496
2961
|
);
|
|
2497
2962
|
const receivers = instuctionData.receivers.map(
|
|
2498
2963
|
(i) => {
|
|
2499
|
-
const receiver =
|
|
2500
|
-
const tokenAmount = BigInt(
|
|
2964
|
+
const receiver = getAddress4(i.address);
|
|
2965
|
+
const tokenAmount = BigInt(parseUnits2(i.amount, tokenData.decimals));
|
|
2501
2966
|
return {
|
|
2502
2967
|
address: receiver,
|
|
2503
2968
|
amount: tokenAmount
|
|
@@ -2564,7 +3029,7 @@ var ActaBatch = class {
|
|
|
2564
3029
|
if (feeInclusive) {
|
|
2565
3030
|
isFeeInclusive = true;
|
|
2566
3031
|
}
|
|
2567
|
-
const { envBatchServiceUrl } =
|
|
3032
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2568
3033
|
const instuctionData = yield fetchBatchInstructionDetails(
|
|
2569
3034
|
`${envBatchServiceUrl}instruction/${instructionId}`,
|
|
2570
3035
|
this.APIkey
|
|
@@ -2579,12 +3044,12 @@ var ActaBatch = class {
|
|
|
2579
3044
|
}
|
|
2580
3045
|
const totalAmount = instuctionData.totalAmount;
|
|
2581
3046
|
const totalAmountParsed = BigInt(
|
|
2582
|
-
|
|
3047
|
+
parseUnits2(totalAmount, tokenData.decimals)
|
|
2583
3048
|
);
|
|
2584
3049
|
const receivers = instuctionData.receivers.map(
|
|
2585
3050
|
(i) => {
|
|
2586
|
-
const receiver =
|
|
2587
|
-
const tokenAmount = BigInt(
|
|
3051
|
+
const receiver = getAddress4(i.address);
|
|
3052
|
+
const tokenAmount = BigInt(parseUnits2(i.amount, tokenData.decimals));
|
|
2588
3053
|
return {
|
|
2589
3054
|
address: receiver,
|
|
2590
3055
|
amount: tokenAmount
|
|
@@ -2617,7 +3082,7 @@ var ActaBatch = class {
|
|
|
2617
3082
|
senderAddress: signerAddress,
|
|
2618
3083
|
chainId,
|
|
2619
3084
|
tokenAddress: tokenData.address,
|
|
2620
|
-
amount:
|
|
3085
|
+
amount: toHex6(totalAmountParsed),
|
|
2621
3086
|
feeInclusive: isFeeInclusive,
|
|
2622
3087
|
serviceType: "batch"
|
|
2623
3088
|
},
|
|
@@ -2652,7 +3117,7 @@ var ActaBatch = class {
|
|
|
2652
3117
|
if (feeInclusive) {
|
|
2653
3118
|
isFeeInclusive = true;
|
|
2654
3119
|
}
|
|
2655
|
-
const { envBatchServiceUrl } =
|
|
3120
|
+
const { envBatchServiceUrl } = returnEnvUrl4(chainId);
|
|
2656
3121
|
if (executionTime <= Date.now() + 1e3 * 60 * 2) {
|
|
2657
3122
|
throw new Error(
|
|
2658
3123
|
"Execution time must be more than 5 mins from current time."
|
|
@@ -2672,12 +3137,12 @@ var ActaBatch = class {
|
|
|
2672
3137
|
}
|
|
2673
3138
|
const totalAmount = instuctionData.totalAmount;
|
|
2674
3139
|
const totalAmountParsed = BigInt(
|
|
2675
|
-
|
|
3140
|
+
parseUnits2(totalAmount, tokenData.decimals)
|
|
2676
3141
|
);
|
|
2677
3142
|
const receivers = instuctionData.receivers.map(
|
|
2678
3143
|
(i) => {
|
|
2679
|
-
const receiver =
|
|
2680
|
-
const tokenAmount = BigInt(
|
|
3144
|
+
const receiver = getAddress4(i.address);
|
|
3145
|
+
const tokenAmount = BigInt(parseUnits2(i.amount, tokenData.decimals));
|
|
2681
3146
|
return {
|
|
2682
3147
|
address: receiver,
|
|
2683
3148
|
amount: tokenAmount
|
|
@@ -2710,10 +3175,10 @@ var ActaBatch = class {
|
|
|
2710
3175
|
senderAddress: signerAddress,
|
|
2711
3176
|
chainId,
|
|
2712
3177
|
tokenAddress: tokenData.address,
|
|
2713
|
-
amount:
|
|
3178
|
+
amount: toHex6(totalAmountParsed),
|
|
2714
3179
|
feeInclusive: isFeeInclusive,
|
|
2715
3180
|
serviceType: "batch",
|
|
2716
|
-
amountExclusive:
|
|
3181
|
+
amountExclusive: toHex6(amountExclusive),
|
|
2717
3182
|
approval,
|
|
2718
3183
|
executionAt: executionTime
|
|
2719
3184
|
},
|
|
@@ -2775,7 +3240,7 @@ var ActaBatch = class {
|
|
|
2775
3240
|
senderAddress: signerAddress,
|
|
2776
3241
|
chainId,
|
|
2777
3242
|
tokenAddress: tokenData.address,
|
|
2778
|
-
amount:
|
|
3243
|
+
amount: toHex6(totalAmount),
|
|
2779
3244
|
feeInclusive: isFeeInclusive,
|
|
2780
3245
|
serviceType: "batch",
|
|
2781
3246
|
sessionId: serviceParams.sessionId,
|
|
@@ -2834,10 +3299,10 @@ var ActaBatch = class {
|
|
|
2834
3299
|
senderAddress: signerAddress,
|
|
2835
3300
|
chainId,
|
|
2836
3301
|
tokenAddress: tokenData.address,
|
|
2837
|
-
amount:
|
|
3302
|
+
amount: toHex6(totalAmount),
|
|
2838
3303
|
feeInclusive: isFeeInclusive,
|
|
2839
3304
|
serviceType: "batch",
|
|
2840
|
-
amountExclusive:
|
|
3305
|
+
amountExclusive: toHex6(amountExclusive),
|
|
2841
3306
|
approval,
|
|
2842
3307
|
executionAt: executionTime,
|
|
2843
3308
|
sessionId: serviceParams.sessionId
|
|
@@ -2872,7 +3337,7 @@ import {
|
|
|
2872
3337
|
encodeAbiParameters,
|
|
2873
3338
|
keccak256,
|
|
2874
3339
|
slice,
|
|
2875
|
-
zeroAddress as
|
|
3340
|
+
zeroAddress as zeroAddress6,
|
|
2876
3341
|
decodeFunctionData,
|
|
2877
3342
|
hexToBigInt as hexToBigInt2
|
|
2878
3343
|
} from "viem";
|
|
@@ -2984,7 +3449,7 @@ function toPermissionValidator2(_0, _1) {
|
|
|
2984
3449
|
return __spreadProps(__spreadValues({}, signer.account), {
|
|
2985
3450
|
supportedKernelVersions: ">=0.3.0",
|
|
2986
3451
|
validatorType: "PERMISSION",
|
|
2987
|
-
address:
|
|
3452
|
+
address: zeroAddress6,
|
|
2988
3453
|
source: "PermissionValidator",
|
|
2989
3454
|
getEnableData,
|
|
2990
3455
|
getIdentifier: getPermissionId,
|
|
@@ -3330,7 +3795,8 @@ export {
|
|
|
3330
3795
|
ActaAccount,
|
|
3331
3796
|
ActaBatch,
|
|
3332
3797
|
ActaBilling,
|
|
3333
|
-
|
|
3798
|
+
ActaFlexBatch,
|
|
3799
|
+
ActaFlexDeposit,
|
|
3334
3800
|
ConnectorType,
|
|
3335
3801
|
HttpMethod,
|
|
3336
3802
|
PolicyFlags,
|