@actalink/sdkv2 0.1.5 → 0.1.6
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 +88 -69
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +87 -69
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -92,6 +92,7 @@ __export(index_exports, {
|
|
|
92
92
|
getChainExplorerByChainId: () => getChainExplorerByChainId,
|
|
93
93
|
getTokenByChainIdAndAddress: () => getTokenByChainIdAndAddress,
|
|
94
94
|
getTokenByChainIdAndSymbol: () => getTokenByChainIdAndSymbol,
|
|
95
|
+
isMainnet: () => isMainnet,
|
|
95
96
|
lineaDAI: () => lineaDAI,
|
|
96
97
|
lineaETH: () => lineaETH,
|
|
97
98
|
lineaUSDC: () => lineaUSDC,
|
|
@@ -143,6 +144,12 @@ var supportedChains = [
|
|
|
143
144
|
];
|
|
144
145
|
var mainnetChains = [import_chains2.arbitrum, import_chains2.base, import_chains2.bsc, import_chains2.mainnet, import_chains2.optimism, import_chains2.polygon];
|
|
145
146
|
var testnetChains = [import_chains.sepolia, import_chains.baseSepolia, import_chains.polygonAmoy];
|
|
147
|
+
function isMainnet(chainId) {
|
|
148
|
+
const mainnetIds = mainnetChains.map((c) => {
|
|
149
|
+
return c.id;
|
|
150
|
+
});
|
|
151
|
+
return mainnetIds.includes(chainId) ? true : false;
|
|
152
|
+
}
|
|
146
153
|
function getChainById(chainId) {
|
|
147
154
|
const chain = supportedChains.find((c) => c.id === chainId);
|
|
148
155
|
if (!chain) throw new Error(`Chain ${chainId} not supported.`);
|
|
@@ -809,6 +816,7 @@ var import_policies = require("@zerodev/permissions/policies");
|
|
|
809
816
|
// src/constants.ts
|
|
810
817
|
var ACCESS_URL = "https://flex-api.acta.link/flex/deposit";
|
|
811
818
|
var ACCESS_TESTNET_URL = "https://flex-api.acta.link/flex/deposit/test";
|
|
819
|
+
var PAYMASTER_URL = `https://api.acta.link/paymaster/flex/deposit`;
|
|
812
820
|
var PROXY_URL = `https://api.acta.link/proxy/v1`;
|
|
813
821
|
|
|
814
822
|
// src/account.ts
|
|
@@ -831,22 +839,24 @@ var ActaAccount = class {
|
|
|
831
839
|
sudo: ecdsaValidator
|
|
832
840
|
},
|
|
833
841
|
entryPoint,
|
|
834
|
-
kernelVersion
|
|
842
|
+
kernelVersion,
|
|
843
|
+
index: BigInt("flex-deposit".length)
|
|
835
844
|
});
|
|
836
845
|
return account;
|
|
837
846
|
});
|
|
838
847
|
}
|
|
839
|
-
createAccountHelpers() {
|
|
848
|
+
createAccountHelpers(projectId) {
|
|
840
849
|
return __async(this, null, function* () {
|
|
841
850
|
var _a;
|
|
842
851
|
const chainId = (_a = this.publicClient.chain) == null ? void 0 : _a.id;
|
|
843
852
|
if (!chainId) {
|
|
844
853
|
throw new Error("Invalid PublicClient Instance.");
|
|
845
854
|
}
|
|
855
|
+
const envPath = isMainnet(chainId) ? `v1/rpc` : `test/v1/rpc`;
|
|
846
856
|
const account = yield this.createAccount();
|
|
847
857
|
const entryPoint = (0, import_constants.getEntryPoint)("0.7");
|
|
848
858
|
const paymasterClient = (0, import_account_abstraction.createPaymasterClient)({
|
|
849
|
-
transport: (0, import_viem4.http)(`${
|
|
859
|
+
transport: (0, import_viem4.http)(`${PAYMASTER_URL}/${envPath}?projectId=${projectId}`)
|
|
850
860
|
});
|
|
851
861
|
const pimlicoClient = (0, import_pimlico.createPimlicoClient)({
|
|
852
862
|
chain: getChainById(chainId),
|
|
@@ -883,7 +893,7 @@ var ActaAccount = class {
|
|
|
883
893
|
};
|
|
884
894
|
});
|
|
885
895
|
}
|
|
886
|
-
estimateSinglePaymentGas(parameters) {
|
|
896
|
+
estimateSinglePaymentGas(parameters, projectId) {
|
|
887
897
|
return __async(this, null, function* () {
|
|
888
898
|
const {
|
|
889
899
|
signerAddress,
|
|
@@ -900,7 +910,7 @@ var ActaAccount = class {
|
|
|
900
910
|
throw new Error("Receiver cannot be the same as the signer.");
|
|
901
911
|
}
|
|
902
912
|
const account = yield this.createAccount();
|
|
903
|
-
const { accountClient, pimlicoClient } = yield this.createAccountHelpers();
|
|
913
|
+
const { accountClient, pimlicoClient } = yield this.createAccountHelpers(projectId);
|
|
904
914
|
const fromAddress = signerAddress;
|
|
905
915
|
const smartAccountAddress = account.address;
|
|
906
916
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
@@ -956,7 +966,7 @@ var ActaAccount = class {
|
|
|
956
966
|
};
|
|
957
967
|
});
|
|
958
968
|
}
|
|
959
|
-
signSinglePaymentOperation(singlePaymentParams) {
|
|
969
|
+
signSinglePaymentOperation(singlePaymentParams, projectId) {
|
|
960
970
|
return __async(this, null, function* () {
|
|
961
971
|
try {
|
|
962
972
|
if (!this.signer) {
|
|
@@ -989,18 +999,21 @@ var ActaAccount = class {
|
|
|
989
999
|
feeInclusiveAmountInToken,
|
|
990
1000
|
feeExclusiveAmountInToken,
|
|
991
1001
|
estimatedTotalFeesInToken
|
|
992
|
-
} = yield this.estimateSinglePaymentGas(
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
+
} = yield this.estimateSinglePaymentGas(
|
|
1003
|
+
{
|
|
1004
|
+
signerAddress,
|
|
1005
|
+
chainId,
|
|
1006
|
+
token: tokenSymbol,
|
|
1007
|
+
amount,
|
|
1008
|
+
receiver,
|
|
1009
|
+
feebps,
|
|
1010
|
+
publicClient,
|
|
1011
|
+
walletClient
|
|
1012
|
+
},
|
|
1013
|
+
projectId
|
|
1014
|
+
);
|
|
1002
1015
|
const account = yield this.createAccount();
|
|
1003
|
-
const { accountClient } = yield this.createAccountHelpers();
|
|
1016
|
+
const { accountClient } = yield this.createAccountHelpers(projectId);
|
|
1004
1017
|
const fromAddress = signerAddress;
|
|
1005
1018
|
const smartAccountAddress = account.address;
|
|
1006
1019
|
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
@@ -1046,7 +1059,7 @@ var ActaAccount = class {
|
|
|
1046
1059
|
}
|
|
1047
1060
|
});
|
|
1048
1061
|
}
|
|
1049
|
-
signRecurringPayments(recurringPaymentParams) {
|
|
1062
|
+
signRecurringPayments(recurringPaymentParams, projectId) {
|
|
1050
1063
|
return __async(this, null, function* () {
|
|
1051
1064
|
if (!this.signer) {
|
|
1052
1065
|
throw new Error("Signer is required for self custody payments.");
|
|
@@ -1095,16 +1108,19 @@ var ActaAccount = class {
|
|
|
1095
1108
|
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1096
1109
|
const emptyAccount = (0, import_sdk.addressToEmptyAccount)(sessionKeyAddress);
|
|
1097
1110
|
const emptySessionKeySigner = yield (0, import_signers.toECDSASigner)({ signer: emptyAccount });
|
|
1098
|
-
const { feeExclusiveAmountInToken, estimatedGasCostInToken } = yield this.estimateSinglePaymentGas(
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1111
|
+
const { feeExclusiveAmountInToken, estimatedGasCostInToken } = yield this.estimateSinglePaymentGas(
|
|
1112
|
+
{
|
|
1113
|
+
signerAddress,
|
|
1114
|
+
chainId,
|
|
1115
|
+
token: tokenSymbol,
|
|
1116
|
+
amount,
|
|
1117
|
+
receiver,
|
|
1118
|
+
feebps,
|
|
1119
|
+
publicClient,
|
|
1120
|
+
walletClient
|
|
1121
|
+
},
|
|
1122
|
+
projectId
|
|
1123
|
+
);
|
|
1108
1124
|
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
1109
1125
|
yield viemClient.checkAndApproveToken(
|
|
1110
1126
|
token2,
|
|
@@ -1330,7 +1346,7 @@ var getPeriodInterval = (periodUnit) => {
|
|
|
1330
1346
|
throw new Error("Invalid period unit");
|
|
1331
1347
|
}
|
|
1332
1348
|
};
|
|
1333
|
-
function estimateSinglePaymentGasInternal(parameters) {
|
|
1349
|
+
function estimateSinglePaymentGasInternal(parameters, projectId) {
|
|
1334
1350
|
return __async(this, null, function* () {
|
|
1335
1351
|
const { publicClient, walletClient } = parameters;
|
|
1336
1352
|
const accountInstance = new ActaAccount(publicClient, walletClient);
|
|
@@ -1342,7 +1358,7 @@ function estimateSinglePaymentGasInternal(parameters) {
|
|
|
1342
1358
|
estimatedTotalFeesInToken,
|
|
1343
1359
|
paymaster,
|
|
1344
1360
|
userOperation
|
|
1345
|
-
} = yield accountInstance.estimateSinglePaymentGas(parameters);
|
|
1361
|
+
} = yield accountInstance.estimateSinglePaymentGas(parameters, projectId);
|
|
1346
1362
|
return {
|
|
1347
1363
|
estimatedGasCostInToken,
|
|
1348
1364
|
ActalinkFeesInToken,
|
|
@@ -1354,7 +1370,7 @@ function estimateSinglePaymentGasInternal(parameters) {
|
|
|
1354
1370
|
};
|
|
1355
1371
|
});
|
|
1356
1372
|
}
|
|
1357
|
-
function createOnetimePaymentInternal(parameters) {
|
|
1373
|
+
function createOnetimePaymentInternal(parameters, projectId) {
|
|
1358
1374
|
return __async(this, null, function* () {
|
|
1359
1375
|
const {
|
|
1360
1376
|
signerAddress,
|
|
@@ -1365,8 +1381,7 @@ function createOnetimePaymentInternal(parameters) {
|
|
|
1365
1381
|
feebps,
|
|
1366
1382
|
publicClient,
|
|
1367
1383
|
walletClient,
|
|
1368
|
-
allowMaxTokenApproval
|
|
1369
|
-
projectId
|
|
1384
|
+
allowMaxTokenApproval
|
|
1370
1385
|
} = parameters;
|
|
1371
1386
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1372
1387
|
if (!token2) {
|
|
@@ -1374,18 +1389,21 @@ function createOnetimePaymentInternal(parameters) {
|
|
|
1374
1389
|
}
|
|
1375
1390
|
const { envAccessURL } = returnEnvUrl(chainId);
|
|
1376
1391
|
const accountInstance = new ActaAccount(publicClient, walletClient);
|
|
1377
|
-
const rpcParameters = yield accountInstance.signSinglePaymentOperation(
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1392
|
+
const rpcParameters = yield accountInstance.signSinglePaymentOperation(
|
|
1393
|
+
{
|
|
1394
|
+
signerAddress,
|
|
1395
|
+
chainId,
|
|
1396
|
+
token: tokenSymbol,
|
|
1397
|
+
amount,
|
|
1398
|
+
receiver,
|
|
1399
|
+
feeInclusive: false,
|
|
1400
|
+
allowMaxTokenApproval,
|
|
1401
|
+
feebps,
|
|
1402
|
+
publicClient,
|
|
1403
|
+
walletClient
|
|
1404
|
+
},
|
|
1405
|
+
projectId
|
|
1406
|
+
);
|
|
1389
1407
|
const data = yield executeSinglePaymentAPICall(
|
|
1390
1408
|
`${envAccessURL}/api/v1/execute/single`,
|
|
1391
1409
|
rpcParameters,
|
|
@@ -1402,7 +1420,7 @@ function createOnetimePaymentInternal(parameters) {
|
|
|
1402
1420
|
return data.id;
|
|
1403
1421
|
});
|
|
1404
1422
|
}
|
|
1405
|
-
function createRecurringePaymentInternal(parameters) {
|
|
1423
|
+
function createRecurringePaymentInternal(parameters, projectId) {
|
|
1406
1424
|
return __async(this, null, function* () {
|
|
1407
1425
|
const {
|
|
1408
1426
|
signerAddress,
|
|
@@ -1415,8 +1433,7 @@ function createRecurringePaymentInternal(parameters) {
|
|
|
1415
1433
|
walletClient,
|
|
1416
1434
|
allowMaxTokenApproval,
|
|
1417
1435
|
count,
|
|
1418
|
-
intervalUnit
|
|
1419
|
-
projectId
|
|
1436
|
+
intervalUnit
|
|
1420
1437
|
} = parameters;
|
|
1421
1438
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1422
1439
|
if (!token2) {
|
|
@@ -1424,20 +1441,23 @@ function createRecurringePaymentInternal(parameters) {
|
|
|
1424
1441
|
}
|
|
1425
1442
|
const { envAccessURL } = returnEnvUrl(chainId);
|
|
1426
1443
|
const accountInstance = new ActaAccount(publicClient, walletClient);
|
|
1427
|
-
const { approval, amountExclusive } = yield accountInstance.signRecurringPayments(
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1444
|
+
const { approval, amountExclusive } = yield accountInstance.signRecurringPayments(
|
|
1445
|
+
{
|
|
1446
|
+
signerAddress,
|
|
1447
|
+
chainId,
|
|
1448
|
+
token: tokenSymbol,
|
|
1449
|
+
amount,
|
|
1450
|
+
receiver,
|
|
1451
|
+
feeInclusive: false,
|
|
1452
|
+
allowMaxTokenApproval,
|
|
1453
|
+
feebps,
|
|
1454
|
+
publicClient,
|
|
1455
|
+
walletClient,
|
|
1456
|
+
count,
|
|
1457
|
+
intervalUnit
|
|
1458
|
+
},
|
|
1459
|
+
projectId
|
|
1460
|
+
);
|
|
1441
1461
|
const startAt = Math.floor(Date.now() / 1e3) + 2 * 60;
|
|
1442
1462
|
const data = yield scheduleRecurringPaymentsAPICall(
|
|
1443
1463
|
`${envAccessURL}/api/v1/schedule/recurring`,
|
|
@@ -1470,7 +1490,7 @@ var ActaFlexSDK = class {
|
|
|
1470
1490
|
return __async(this, null, function* () {
|
|
1471
1491
|
try {
|
|
1472
1492
|
const result = EstimateSinglePaymentGasSchema.parse(parameters);
|
|
1473
|
-
const { estimatedTotalFeesInToken } = yield estimateSinglePaymentGasInternal(__spreadProps(__spreadValues({}, result), { feebps: 10 }));
|
|
1493
|
+
const { estimatedTotalFeesInToken } = yield estimateSinglePaymentGasInternal(__spreadProps(__spreadValues({}, result), { feebps: 10 }), this.projectId);
|
|
1474
1494
|
return estimatedTotalFeesInToken;
|
|
1475
1495
|
} catch (error) {
|
|
1476
1496
|
if (error instanceof Error) {
|
|
@@ -1485,9 +1505,8 @@ var ActaFlexSDK = class {
|
|
|
1485
1505
|
try {
|
|
1486
1506
|
const result = CreateSinglePaymentSchema.parse(parameters);
|
|
1487
1507
|
const id = yield createOnetimePaymentInternal(__spreadProps(__spreadValues({}, result), {
|
|
1488
|
-
feebps: 10
|
|
1489
|
-
|
|
1490
|
-
}));
|
|
1508
|
+
feebps: 10
|
|
1509
|
+
}), this.projectId);
|
|
1491
1510
|
return id;
|
|
1492
1511
|
} catch (error) {
|
|
1493
1512
|
if (error instanceof Error) {
|
|
@@ -1502,9 +1521,8 @@ var ActaFlexSDK = class {
|
|
|
1502
1521
|
try {
|
|
1503
1522
|
const result = CreateRecurringPaymentSchema.parse(parameters);
|
|
1504
1523
|
const id = yield createRecurringePaymentInternal(__spreadProps(__spreadValues({}, result), {
|
|
1505
|
-
feebps: 10
|
|
1506
|
-
|
|
1507
|
-
}));
|
|
1524
|
+
feebps: 10
|
|
1525
|
+
}), this.projectId);
|
|
1508
1526
|
return id;
|
|
1509
1527
|
} catch (error) {
|
|
1510
1528
|
if (error instanceof Error) {
|
|
@@ -1570,6 +1588,7 @@ var ActaFlexSDK = class {
|
|
|
1570
1588
|
getChainExplorerByChainId,
|
|
1571
1589
|
getTokenByChainIdAndAddress,
|
|
1572
1590
|
getTokenByChainIdAndSymbol,
|
|
1591
|
+
isMainnet,
|
|
1573
1592
|
lineaDAI,
|
|
1574
1593
|
lineaETH,
|
|
1575
1594
|
lineaUSDC,
|
package/dist/index.d.cts
CHANGED
|
@@ -49485,6 +49485,7 @@ declare const testnetChains: ({
|
|
|
49485
49485
|
formatters?: undefined;
|
|
49486
49486
|
serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
|
|
49487
49487
|
})[];
|
|
49488
|
+
declare function isMainnet(chainId: number): boolean;
|
|
49488
49489
|
declare function getChainById(chainId: number): Chain | undefined;
|
|
49489
49490
|
declare function getChainExplorerByChainId(chainId: number): string | undefined;
|
|
49490
49491
|
|
|
@@ -49493,7 +49494,7 @@ declare class ActaAccount {
|
|
|
49493
49494
|
private readonly signer;
|
|
49494
49495
|
constructor(publicClient: PublicClient, signer: WalletClient);
|
|
49495
49496
|
createAccount(): Promise<_zerodev_sdk.CreateKernelAccountReturnType<"0.7">>;
|
|
49496
|
-
createAccountHelpers(): Promise<{
|
|
49497
|
+
createAccountHelpers(projectId: string): Promise<{
|
|
49497
49498
|
paymasterClient: {
|
|
49498
49499
|
account: undefined;
|
|
49499
49500
|
batch?: {
|
|
@@ -52889,7 +52890,7 @@ declare class ActaAccount {
|
|
|
52889
52890
|
}>;
|
|
52890
52891
|
estimateSinglePaymentGas(parameters: EstimateSinglePaymentGas & {
|
|
52891
52892
|
feebps: 10 | 15 | 20;
|
|
52892
|
-
}): Promise<{
|
|
52893
|
+
}, projectId: string): Promise<{
|
|
52893
52894
|
estimatedGasCostInToken: bigint;
|
|
52894
52895
|
ActalinkFeesInToken: bigint;
|
|
52895
52896
|
estimatedTotalFeesInToken: bigint;
|
|
@@ -52898,8 +52899,8 @@ declare class ActaAccount {
|
|
|
52898
52899
|
paymaster: `0x${string}`;
|
|
52899
52900
|
userOperation: UserOperation<"0.7">;
|
|
52900
52901
|
}>;
|
|
52901
|
-
signSinglePaymentOperation(singlePaymentParams: signSinglePaymentOperationParameters): Promise<RpcUserOperation>;
|
|
52902
|
-
signRecurringPayments(recurringPaymentParams: signRecurringPaymentOperationParameters): Promise<{
|
|
52902
|
+
signSinglePaymentOperation(singlePaymentParams: signSinglePaymentOperationParameters, projectId: string): Promise<RpcUserOperation>;
|
|
52903
|
+
signRecurringPayments(recurringPaymentParams: signRecurringPaymentOperationParameters, projectId: string): Promise<{
|
|
52903
52904
|
approval: string;
|
|
52904
52905
|
amountExclusive: bigint;
|
|
52905
52906
|
}>;
|
|
@@ -52976,4 +52977,4 @@ declare class ActaFlexSDK {
|
|
|
52976
52977
|
waitForPaymentStatus(id: string, intervalMs?: number): Promise<PaymentStatus>;
|
|
52977
52978
|
}
|
|
52978
52979
|
|
|
52979
|
-
export { ActaAccount, ActaFlexSDK, HttpMethod, type HttpRequest, type JsonResponse, ViemClient, arbitrumDAI, arbitrumETH, arbitrumUSDC, arbitrumUSDCe, arbitrumUSDT, arbitrumWETH, baseDAI, baseETH, baseEURC, baseSepoliaUSDC, baseUSDC, baseUSDT, baseUSDbC, baseWETH, bscBNB, bscUSDC, bscUSDT, bscWBNB, ethereumDAI, ethereumETH, ethereumEURC, ethereumUSDC, ethereumUSDT, ethereumWETH, executeSinglePaymentAPICall, fetchPaymentStatus, fetchRecurringTransactionWithId, getChainById, getChainExplorerByChainId, getTokenByChainIdAndAddress, getTokenByChainIdAndSymbol, lineaDAI, lineaETH, lineaUSDC, lineaWETH, mainnetChains, optimismDAI, optimismETH, optimismUSDC, optimismUSDCe, optimismUSDT, optimismWETH, polygonAmoyUSDC, polygonDAI, polygonPOL, polygonUSDC, polygonUSDCe, polygonUSDT, polygonWETH, polygonWPOL, scheduleRecurringPaymentsAPICall, sendRequest, sepoliaUSDC, supportedChains, supportedTokensByChain, testnetChains, token, tokensCommonSymbols, waitForPaymentStatus };
|
|
52980
|
+
export { ActaAccount, ActaFlexSDK, HttpMethod, type HttpRequest, type JsonResponse, ViemClient, arbitrumDAI, arbitrumETH, arbitrumUSDC, arbitrumUSDCe, arbitrumUSDT, arbitrumWETH, baseDAI, baseETH, baseEURC, baseSepoliaUSDC, baseUSDC, baseUSDT, baseUSDbC, baseWETH, bscBNB, bscUSDC, bscUSDT, bscWBNB, ethereumDAI, ethereumETH, ethereumEURC, ethereumUSDC, ethereumUSDT, ethereumWETH, executeSinglePaymentAPICall, fetchPaymentStatus, fetchRecurringTransactionWithId, getChainById, getChainExplorerByChainId, getTokenByChainIdAndAddress, getTokenByChainIdAndSymbol, isMainnet, lineaDAI, lineaETH, lineaUSDC, lineaWETH, mainnetChains, optimismDAI, optimismETH, optimismUSDC, optimismUSDCe, optimismUSDT, optimismWETH, polygonAmoyUSDC, polygonDAI, polygonPOL, polygonUSDC, polygonUSDCe, polygonUSDT, polygonWETH, polygonWPOL, scheduleRecurringPaymentsAPICall, sendRequest, sepoliaUSDC, supportedChains, supportedTokensByChain, testnetChains, token, tokensCommonSymbols, waitForPaymentStatus };
|
package/dist/index.d.ts
CHANGED
|
@@ -49485,6 +49485,7 @@ declare const testnetChains: ({
|
|
|
49485
49485
|
formatters?: undefined;
|
|
49486
49486
|
serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
|
|
49487
49487
|
})[];
|
|
49488
|
+
declare function isMainnet(chainId: number): boolean;
|
|
49488
49489
|
declare function getChainById(chainId: number): Chain | undefined;
|
|
49489
49490
|
declare function getChainExplorerByChainId(chainId: number): string | undefined;
|
|
49490
49491
|
|
|
@@ -49493,7 +49494,7 @@ declare class ActaAccount {
|
|
|
49493
49494
|
private readonly signer;
|
|
49494
49495
|
constructor(publicClient: PublicClient, signer: WalletClient);
|
|
49495
49496
|
createAccount(): Promise<_zerodev_sdk.CreateKernelAccountReturnType<"0.7">>;
|
|
49496
|
-
createAccountHelpers(): Promise<{
|
|
49497
|
+
createAccountHelpers(projectId: string): Promise<{
|
|
49497
49498
|
paymasterClient: {
|
|
49498
49499
|
account: undefined;
|
|
49499
49500
|
batch?: {
|
|
@@ -52889,7 +52890,7 @@ declare class ActaAccount {
|
|
|
52889
52890
|
}>;
|
|
52890
52891
|
estimateSinglePaymentGas(parameters: EstimateSinglePaymentGas & {
|
|
52891
52892
|
feebps: 10 | 15 | 20;
|
|
52892
|
-
}): Promise<{
|
|
52893
|
+
}, projectId: string): Promise<{
|
|
52893
52894
|
estimatedGasCostInToken: bigint;
|
|
52894
52895
|
ActalinkFeesInToken: bigint;
|
|
52895
52896
|
estimatedTotalFeesInToken: bigint;
|
|
@@ -52898,8 +52899,8 @@ declare class ActaAccount {
|
|
|
52898
52899
|
paymaster: `0x${string}`;
|
|
52899
52900
|
userOperation: UserOperation<"0.7">;
|
|
52900
52901
|
}>;
|
|
52901
|
-
signSinglePaymentOperation(singlePaymentParams: signSinglePaymentOperationParameters): Promise<RpcUserOperation>;
|
|
52902
|
-
signRecurringPayments(recurringPaymentParams: signRecurringPaymentOperationParameters): Promise<{
|
|
52902
|
+
signSinglePaymentOperation(singlePaymentParams: signSinglePaymentOperationParameters, projectId: string): Promise<RpcUserOperation>;
|
|
52903
|
+
signRecurringPayments(recurringPaymentParams: signRecurringPaymentOperationParameters, projectId: string): Promise<{
|
|
52903
52904
|
approval: string;
|
|
52904
52905
|
amountExclusive: bigint;
|
|
52905
52906
|
}>;
|
|
@@ -52976,4 +52977,4 @@ declare class ActaFlexSDK {
|
|
|
52976
52977
|
waitForPaymentStatus(id: string, intervalMs?: number): Promise<PaymentStatus>;
|
|
52977
52978
|
}
|
|
52978
52979
|
|
|
52979
|
-
export { ActaAccount, ActaFlexSDK, HttpMethod, type HttpRequest, type JsonResponse, ViemClient, arbitrumDAI, arbitrumETH, arbitrumUSDC, arbitrumUSDCe, arbitrumUSDT, arbitrumWETH, baseDAI, baseETH, baseEURC, baseSepoliaUSDC, baseUSDC, baseUSDT, baseUSDbC, baseWETH, bscBNB, bscUSDC, bscUSDT, bscWBNB, ethereumDAI, ethereumETH, ethereumEURC, ethereumUSDC, ethereumUSDT, ethereumWETH, executeSinglePaymentAPICall, fetchPaymentStatus, fetchRecurringTransactionWithId, getChainById, getChainExplorerByChainId, getTokenByChainIdAndAddress, getTokenByChainIdAndSymbol, lineaDAI, lineaETH, lineaUSDC, lineaWETH, mainnetChains, optimismDAI, optimismETH, optimismUSDC, optimismUSDCe, optimismUSDT, optimismWETH, polygonAmoyUSDC, polygonDAI, polygonPOL, polygonUSDC, polygonUSDCe, polygonUSDT, polygonWETH, polygonWPOL, scheduleRecurringPaymentsAPICall, sendRequest, sepoliaUSDC, supportedChains, supportedTokensByChain, testnetChains, token, tokensCommonSymbols, waitForPaymentStatus };
|
|
52980
|
+
export { ActaAccount, ActaFlexSDK, HttpMethod, type HttpRequest, type JsonResponse, ViemClient, arbitrumDAI, arbitrumETH, arbitrumUSDC, arbitrumUSDCe, arbitrumUSDT, arbitrumWETH, baseDAI, baseETH, baseEURC, baseSepoliaUSDC, baseUSDC, baseUSDT, baseUSDbC, baseWETH, bscBNB, bscUSDC, bscUSDT, bscWBNB, ethereumDAI, ethereumETH, ethereumEURC, ethereumUSDC, ethereumUSDT, ethereumWETH, executeSinglePaymentAPICall, fetchPaymentStatus, fetchRecurringTransactionWithId, getChainById, getChainExplorerByChainId, getTokenByChainIdAndAddress, getTokenByChainIdAndSymbol, isMainnet, lineaDAI, lineaETH, lineaUSDC, lineaWETH, mainnetChains, optimismDAI, optimismETH, optimismUSDC, optimismUSDCe, optimismUSDT, optimismWETH, polygonAmoyUSDC, polygonDAI, polygonPOL, polygonUSDC, polygonUSDCe, polygonUSDT, polygonWETH, polygonWPOL, scheduleRecurringPaymentsAPICall, sendRequest, sepoliaUSDC, supportedChains, supportedTokensByChain, testnetChains, token, tokensCommonSymbols, waitForPaymentStatus };
|
package/dist/index.js
CHANGED
|
@@ -69,6 +69,12 @@ var supportedChains = [
|
|
|
69
69
|
];
|
|
70
70
|
var mainnetChains = [arbitrum, base, bsc, mainnet, optimism, polygon];
|
|
71
71
|
var testnetChains = [sepolia, baseSepolia, polygonAmoy];
|
|
72
|
+
function isMainnet(chainId) {
|
|
73
|
+
const mainnetIds = mainnetChains.map((c) => {
|
|
74
|
+
return c.id;
|
|
75
|
+
});
|
|
76
|
+
return mainnetIds.includes(chainId) ? true : false;
|
|
77
|
+
}
|
|
72
78
|
function getChainById(chainId) {
|
|
73
79
|
const chain = supportedChains.find((c) => c.id === chainId);
|
|
74
80
|
if (!chain) throw new Error(`Chain ${chainId} not supported.`);
|
|
@@ -757,6 +763,7 @@ import {
|
|
|
757
763
|
// src/constants.ts
|
|
758
764
|
var ACCESS_URL = "https://flex-api.acta.link/flex/deposit";
|
|
759
765
|
var ACCESS_TESTNET_URL = "https://flex-api.acta.link/flex/deposit/test";
|
|
766
|
+
var PAYMASTER_URL = `https://api.acta.link/paymaster/flex/deposit`;
|
|
760
767
|
var PROXY_URL = `https://api.acta.link/proxy/v1`;
|
|
761
768
|
|
|
762
769
|
// src/account.ts
|
|
@@ -779,22 +786,24 @@ var ActaAccount = class {
|
|
|
779
786
|
sudo: ecdsaValidator
|
|
780
787
|
},
|
|
781
788
|
entryPoint,
|
|
782
|
-
kernelVersion
|
|
789
|
+
kernelVersion,
|
|
790
|
+
index: BigInt("flex-deposit".length)
|
|
783
791
|
});
|
|
784
792
|
return account;
|
|
785
793
|
});
|
|
786
794
|
}
|
|
787
|
-
createAccountHelpers() {
|
|
795
|
+
createAccountHelpers(projectId) {
|
|
788
796
|
return __async(this, null, function* () {
|
|
789
797
|
var _a;
|
|
790
798
|
const chainId = (_a = this.publicClient.chain) == null ? void 0 : _a.id;
|
|
791
799
|
if (!chainId) {
|
|
792
800
|
throw new Error("Invalid PublicClient Instance.");
|
|
793
801
|
}
|
|
802
|
+
const envPath = isMainnet(chainId) ? `v1/rpc` : `test/v1/rpc`;
|
|
794
803
|
const account = yield this.createAccount();
|
|
795
804
|
const entryPoint = getEntryPoint("0.7");
|
|
796
805
|
const paymasterClient = createPaymasterClient({
|
|
797
|
-
transport: http(`${
|
|
806
|
+
transport: http(`${PAYMASTER_URL}/${envPath}?projectId=${projectId}`)
|
|
798
807
|
});
|
|
799
808
|
const pimlicoClient = createPimlicoClient({
|
|
800
809
|
chain: getChainById(chainId),
|
|
@@ -831,7 +840,7 @@ var ActaAccount = class {
|
|
|
831
840
|
};
|
|
832
841
|
});
|
|
833
842
|
}
|
|
834
|
-
estimateSinglePaymentGas(parameters) {
|
|
843
|
+
estimateSinglePaymentGas(parameters, projectId) {
|
|
835
844
|
return __async(this, null, function* () {
|
|
836
845
|
const {
|
|
837
846
|
signerAddress,
|
|
@@ -848,7 +857,7 @@ var ActaAccount = class {
|
|
|
848
857
|
throw new Error("Receiver cannot be the same as the signer.");
|
|
849
858
|
}
|
|
850
859
|
const account = yield this.createAccount();
|
|
851
|
-
const { accountClient, pimlicoClient } = yield this.createAccountHelpers();
|
|
860
|
+
const { accountClient, pimlicoClient } = yield this.createAccountHelpers(projectId);
|
|
852
861
|
const fromAddress = signerAddress;
|
|
853
862
|
const smartAccountAddress = account.address;
|
|
854
863
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
@@ -904,7 +913,7 @@ var ActaAccount = class {
|
|
|
904
913
|
};
|
|
905
914
|
});
|
|
906
915
|
}
|
|
907
|
-
signSinglePaymentOperation(singlePaymentParams) {
|
|
916
|
+
signSinglePaymentOperation(singlePaymentParams, projectId) {
|
|
908
917
|
return __async(this, null, function* () {
|
|
909
918
|
try {
|
|
910
919
|
if (!this.signer) {
|
|
@@ -937,18 +946,21 @@ var ActaAccount = class {
|
|
|
937
946
|
feeInclusiveAmountInToken,
|
|
938
947
|
feeExclusiveAmountInToken,
|
|
939
948
|
estimatedTotalFeesInToken
|
|
940
|
-
} = yield this.estimateSinglePaymentGas(
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
949
|
+
} = yield this.estimateSinglePaymentGas(
|
|
950
|
+
{
|
|
951
|
+
signerAddress,
|
|
952
|
+
chainId,
|
|
953
|
+
token: tokenSymbol,
|
|
954
|
+
amount,
|
|
955
|
+
receiver,
|
|
956
|
+
feebps,
|
|
957
|
+
publicClient,
|
|
958
|
+
walletClient
|
|
959
|
+
},
|
|
960
|
+
projectId
|
|
961
|
+
);
|
|
950
962
|
const account = yield this.createAccount();
|
|
951
|
-
const { accountClient } = yield this.createAccountHelpers();
|
|
963
|
+
const { accountClient } = yield this.createAccountHelpers(projectId);
|
|
952
964
|
const fromAddress = signerAddress;
|
|
953
965
|
const smartAccountAddress = account.address;
|
|
954
966
|
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
@@ -994,7 +1006,7 @@ var ActaAccount = class {
|
|
|
994
1006
|
}
|
|
995
1007
|
});
|
|
996
1008
|
}
|
|
997
|
-
signRecurringPayments(recurringPaymentParams) {
|
|
1009
|
+
signRecurringPayments(recurringPaymentParams, projectId) {
|
|
998
1010
|
return __async(this, null, function* () {
|
|
999
1011
|
if (!this.signer) {
|
|
1000
1012
|
throw new Error("Signer is required for self custody payments.");
|
|
@@ -1043,16 +1055,19 @@ var ActaAccount = class {
|
|
|
1043
1055
|
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1044
1056
|
const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
|
|
1045
1057
|
const emptySessionKeySigner = yield toECDSASigner({ signer: emptyAccount });
|
|
1046
|
-
const { feeExclusiveAmountInToken, estimatedGasCostInToken } = yield this.estimateSinglePaymentGas(
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1058
|
+
const { feeExclusiveAmountInToken, estimatedGasCostInToken } = yield this.estimateSinglePaymentGas(
|
|
1059
|
+
{
|
|
1060
|
+
signerAddress,
|
|
1061
|
+
chainId,
|
|
1062
|
+
token: tokenSymbol,
|
|
1063
|
+
amount,
|
|
1064
|
+
receiver,
|
|
1065
|
+
feebps,
|
|
1066
|
+
publicClient,
|
|
1067
|
+
walletClient
|
|
1068
|
+
},
|
|
1069
|
+
projectId
|
|
1070
|
+
);
|
|
1056
1071
|
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
1057
1072
|
yield viemClient.checkAndApproveToken(
|
|
1058
1073
|
token2,
|
|
@@ -1278,7 +1293,7 @@ var getPeriodInterval = (periodUnit) => {
|
|
|
1278
1293
|
throw new Error("Invalid period unit");
|
|
1279
1294
|
}
|
|
1280
1295
|
};
|
|
1281
|
-
function estimateSinglePaymentGasInternal(parameters) {
|
|
1296
|
+
function estimateSinglePaymentGasInternal(parameters, projectId) {
|
|
1282
1297
|
return __async(this, null, function* () {
|
|
1283
1298
|
const { publicClient, walletClient } = parameters;
|
|
1284
1299
|
const accountInstance = new ActaAccount(publicClient, walletClient);
|
|
@@ -1290,7 +1305,7 @@ function estimateSinglePaymentGasInternal(parameters) {
|
|
|
1290
1305
|
estimatedTotalFeesInToken,
|
|
1291
1306
|
paymaster,
|
|
1292
1307
|
userOperation
|
|
1293
|
-
} = yield accountInstance.estimateSinglePaymentGas(parameters);
|
|
1308
|
+
} = yield accountInstance.estimateSinglePaymentGas(parameters, projectId);
|
|
1294
1309
|
return {
|
|
1295
1310
|
estimatedGasCostInToken,
|
|
1296
1311
|
ActalinkFeesInToken,
|
|
@@ -1302,7 +1317,7 @@ function estimateSinglePaymentGasInternal(parameters) {
|
|
|
1302
1317
|
};
|
|
1303
1318
|
});
|
|
1304
1319
|
}
|
|
1305
|
-
function createOnetimePaymentInternal(parameters) {
|
|
1320
|
+
function createOnetimePaymentInternal(parameters, projectId) {
|
|
1306
1321
|
return __async(this, null, function* () {
|
|
1307
1322
|
const {
|
|
1308
1323
|
signerAddress,
|
|
@@ -1313,8 +1328,7 @@ function createOnetimePaymentInternal(parameters) {
|
|
|
1313
1328
|
feebps,
|
|
1314
1329
|
publicClient,
|
|
1315
1330
|
walletClient,
|
|
1316
|
-
allowMaxTokenApproval
|
|
1317
|
-
projectId
|
|
1331
|
+
allowMaxTokenApproval
|
|
1318
1332
|
} = parameters;
|
|
1319
1333
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1320
1334
|
if (!token2) {
|
|
@@ -1322,18 +1336,21 @@ function createOnetimePaymentInternal(parameters) {
|
|
|
1322
1336
|
}
|
|
1323
1337
|
const { envAccessURL } = returnEnvUrl(chainId);
|
|
1324
1338
|
const accountInstance = new ActaAccount(publicClient, walletClient);
|
|
1325
|
-
const rpcParameters = yield accountInstance.signSinglePaymentOperation(
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1339
|
+
const rpcParameters = yield accountInstance.signSinglePaymentOperation(
|
|
1340
|
+
{
|
|
1341
|
+
signerAddress,
|
|
1342
|
+
chainId,
|
|
1343
|
+
token: tokenSymbol,
|
|
1344
|
+
amount,
|
|
1345
|
+
receiver,
|
|
1346
|
+
feeInclusive: false,
|
|
1347
|
+
allowMaxTokenApproval,
|
|
1348
|
+
feebps,
|
|
1349
|
+
publicClient,
|
|
1350
|
+
walletClient
|
|
1351
|
+
},
|
|
1352
|
+
projectId
|
|
1353
|
+
);
|
|
1337
1354
|
const data = yield executeSinglePaymentAPICall(
|
|
1338
1355
|
`${envAccessURL}/api/v1/execute/single`,
|
|
1339
1356
|
rpcParameters,
|
|
@@ -1350,7 +1367,7 @@ function createOnetimePaymentInternal(parameters) {
|
|
|
1350
1367
|
return data.id;
|
|
1351
1368
|
});
|
|
1352
1369
|
}
|
|
1353
|
-
function createRecurringePaymentInternal(parameters) {
|
|
1370
|
+
function createRecurringePaymentInternal(parameters, projectId) {
|
|
1354
1371
|
return __async(this, null, function* () {
|
|
1355
1372
|
const {
|
|
1356
1373
|
signerAddress,
|
|
@@ -1363,8 +1380,7 @@ function createRecurringePaymentInternal(parameters) {
|
|
|
1363
1380
|
walletClient,
|
|
1364
1381
|
allowMaxTokenApproval,
|
|
1365
1382
|
count,
|
|
1366
|
-
intervalUnit
|
|
1367
|
-
projectId
|
|
1383
|
+
intervalUnit
|
|
1368
1384
|
} = parameters;
|
|
1369
1385
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1370
1386
|
if (!token2) {
|
|
@@ -1372,20 +1388,23 @@ function createRecurringePaymentInternal(parameters) {
|
|
|
1372
1388
|
}
|
|
1373
1389
|
const { envAccessURL } = returnEnvUrl(chainId);
|
|
1374
1390
|
const accountInstance = new ActaAccount(publicClient, walletClient);
|
|
1375
|
-
const { approval, amountExclusive } = yield accountInstance.signRecurringPayments(
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1391
|
+
const { approval, amountExclusive } = yield accountInstance.signRecurringPayments(
|
|
1392
|
+
{
|
|
1393
|
+
signerAddress,
|
|
1394
|
+
chainId,
|
|
1395
|
+
token: tokenSymbol,
|
|
1396
|
+
amount,
|
|
1397
|
+
receiver,
|
|
1398
|
+
feeInclusive: false,
|
|
1399
|
+
allowMaxTokenApproval,
|
|
1400
|
+
feebps,
|
|
1401
|
+
publicClient,
|
|
1402
|
+
walletClient,
|
|
1403
|
+
count,
|
|
1404
|
+
intervalUnit
|
|
1405
|
+
},
|
|
1406
|
+
projectId
|
|
1407
|
+
);
|
|
1389
1408
|
const startAt = Math.floor(Date.now() / 1e3) + 2 * 60;
|
|
1390
1409
|
const data = yield scheduleRecurringPaymentsAPICall(
|
|
1391
1410
|
`${envAccessURL}/api/v1/schedule/recurring`,
|
|
@@ -1418,7 +1437,7 @@ var ActaFlexSDK = class {
|
|
|
1418
1437
|
return __async(this, null, function* () {
|
|
1419
1438
|
try {
|
|
1420
1439
|
const result = EstimateSinglePaymentGasSchema.parse(parameters);
|
|
1421
|
-
const { estimatedTotalFeesInToken } = yield estimateSinglePaymentGasInternal(__spreadProps(__spreadValues({}, result), { feebps: 10 }));
|
|
1440
|
+
const { estimatedTotalFeesInToken } = yield estimateSinglePaymentGasInternal(__spreadProps(__spreadValues({}, result), { feebps: 10 }), this.projectId);
|
|
1422
1441
|
return estimatedTotalFeesInToken;
|
|
1423
1442
|
} catch (error) {
|
|
1424
1443
|
if (error instanceof Error) {
|
|
@@ -1433,9 +1452,8 @@ var ActaFlexSDK = class {
|
|
|
1433
1452
|
try {
|
|
1434
1453
|
const result = CreateSinglePaymentSchema.parse(parameters);
|
|
1435
1454
|
const id = yield createOnetimePaymentInternal(__spreadProps(__spreadValues({}, result), {
|
|
1436
|
-
feebps: 10
|
|
1437
|
-
|
|
1438
|
-
}));
|
|
1455
|
+
feebps: 10
|
|
1456
|
+
}), this.projectId);
|
|
1439
1457
|
return id;
|
|
1440
1458
|
} catch (error) {
|
|
1441
1459
|
if (error instanceof Error) {
|
|
@@ -1450,9 +1468,8 @@ var ActaFlexSDK = class {
|
|
|
1450
1468
|
try {
|
|
1451
1469
|
const result = CreateRecurringPaymentSchema.parse(parameters);
|
|
1452
1470
|
const id = yield createRecurringePaymentInternal(__spreadProps(__spreadValues({}, result), {
|
|
1453
|
-
feebps: 10
|
|
1454
|
-
|
|
1455
|
-
}));
|
|
1471
|
+
feebps: 10
|
|
1472
|
+
}), this.projectId);
|
|
1456
1473
|
return id;
|
|
1457
1474
|
} catch (error) {
|
|
1458
1475
|
if (error instanceof Error) {
|
|
@@ -1517,6 +1534,7 @@ export {
|
|
|
1517
1534
|
getChainExplorerByChainId,
|
|
1518
1535
|
getTokenByChainIdAndAddress,
|
|
1519
1536
|
getTokenByChainIdAndSymbol,
|
|
1537
|
+
isMainnet,
|
|
1520
1538
|
lineaDAI,
|
|
1521
1539
|
lineaETH,
|
|
1522
1540
|
lineaUSDC,
|