@actalink/commonlib 0.0.39-dev → 0.0.39
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 +106 -25
- package/dist/index.d.cts +3440 -1
- package/dist/index.d.ts +3440 -1
- package/dist/index.js +128 -44
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -849,6 +849,48 @@ var ActaAccount = class {
|
|
|
849
849
|
};
|
|
850
850
|
});
|
|
851
851
|
}
|
|
852
|
+
createAccountHelperBatch() {
|
|
853
|
+
return __async(this, null, function* () {
|
|
854
|
+
const account = yield this.createAccount();
|
|
855
|
+
const entryPoint = (0, import_constants.getEntryPoint)("0.7");
|
|
856
|
+
const paymasterClient = (0, import_account_abstraction.createPaymasterClient)({
|
|
857
|
+
transport: (0, import_viem3.http)(`https://api.acta.link/paymaster/v1/rpc`)
|
|
858
|
+
});
|
|
859
|
+
const pimlicoClient = (0, import_pimlico.createPimlicoClient)({
|
|
860
|
+
chain: getChainById(this.chainId),
|
|
861
|
+
transport: (0, import_viem3.http)(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
862
|
+
entryPoint
|
|
863
|
+
});
|
|
864
|
+
const accountClient = (0, import_permissionless.createSmartAccountClient)({
|
|
865
|
+
account,
|
|
866
|
+
chain: getChainById(this.chainId),
|
|
867
|
+
paymaster: paymasterClient,
|
|
868
|
+
bundlerTransport: (0, import_viem3.http)(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
869
|
+
userOperation: {
|
|
870
|
+
estimateFeesPerGas: () => __async(this, null, function* () {
|
|
871
|
+
return (yield pimlicoClient.getUserOperationGasPrice()).fast;
|
|
872
|
+
})
|
|
873
|
+
}
|
|
874
|
+
});
|
|
875
|
+
const kernelAccountClient = (0, import_sdk.createKernelAccountClient)({
|
|
876
|
+
account,
|
|
877
|
+
chain: getChainById(this.chainId),
|
|
878
|
+
paymaster: paymasterClient,
|
|
879
|
+
bundlerTransport: (0, import_viem3.http)(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
880
|
+
userOperation: {
|
|
881
|
+
estimateFeesPerGas: () => __async(this, null, function* () {
|
|
882
|
+
return (yield pimlicoClient.getUserOperationGasPrice()).fast;
|
|
883
|
+
})
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
return {
|
|
887
|
+
paymasterClient,
|
|
888
|
+
pimlicoClient,
|
|
889
|
+
accountClient,
|
|
890
|
+
kernelAccountClient
|
|
891
|
+
};
|
|
892
|
+
});
|
|
893
|
+
}
|
|
852
894
|
estimateSinglePaymentGas(parameters) {
|
|
853
895
|
return __async(this, null, function* () {
|
|
854
896
|
const {
|
|
@@ -941,7 +983,7 @@ var ActaAccount = class {
|
|
|
941
983
|
throw new Error("Receivers not found for batch payment");
|
|
942
984
|
}
|
|
943
985
|
const account = yield this.createAccount();
|
|
944
|
-
const { accountClient, pimlicoClient } = yield this.
|
|
986
|
+
const { accountClient, pimlicoClient } = yield this.createAccountHelperBatch();
|
|
945
987
|
const fromAddress = signerAddress;
|
|
946
988
|
const smartAccountAddress = account.address;
|
|
947
989
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
@@ -972,18 +1014,42 @@ var ActaAccount = class {
|
|
|
972
1014
|
}
|
|
973
1015
|
]
|
|
974
1016
|
});
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
|
|
1017
|
+
const data = {
|
|
1018
|
+
jsonrpc: "2.0",
|
|
1019
|
+
id: 1,
|
|
1020
|
+
method: "pm_getTokenQuotes",
|
|
1021
|
+
params: [
|
|
1022
|
+
{
|
|
1023
|
+
tokens: [token2.address]
|
|
1024
|
+
},
|
|
1025
|
+
import_account_abstraction.entryPoint07Address,
|
|
1026
|
+
(0, import_viem3.toHex)(chainId)
|
|
1027
|
+
]
|
|
1028
|
+
};
|
|
1029
|
+
const res = yield fetch("https://api.acta.link/paymaster/v1/rpc", {
|
|
1030
|
+
method: "POST",
|
|
1031
|
+
headers: {
|
|
1032
|
+
"Content-Type": "application/json"
|
|
1033
|
+
},
|
|
1034
|
+
body: JSON.stringify(data)
|
|
1035
|
+
}).then((response) => {
|
|
1036
|
+
if (!response.ok) {
|
|
1037
|
+
throw new Error("HTTP error " + response.status);
|
|
1038
|
+
}
|
|
1039
|
+
return response.json();
|
|
978
1040
|
});
|
|
979
1041
|
const userOperationMaxCost = (0, import_permissionless.getRequiredPrefund)({
|
|
980
1042
|
userOperation,
|
|
981
1043
|
entryPointVersion: "0.7"
|
|
982
1044
|
});
|
|
983
|
-
const
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1045
|
+
const quotes = res.result;
|
|
1046
|
+
if (!quotes.paymaster) {
|
|
1047
|
+
throw new Error("Error fetching quotes");
|
|
1048
|
+
}
|
|
1049
|
+
const postOpGas = (0, import_viem3.hexToBigInt)(quotes.postOpGas);
|
|
1050
|
+
const exchangeRate = (0, import_viem3.hexToBigInt)(quotes.exchangeRate);
|
|
1051
|
+
const exchangeRateNativeToUsd = (0, import_viem3.hexToBigInt)(quotes.exchangeRateNativeToUsd);
|
|
1052
|
+
const paymaster = quotes.paymaster;
|
|
987
1053
|
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
988
1054
|
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
989
1055
|
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
@@ -1139,7 +1205,7 @@ var ActaAccount = class {
|
|
|
1139
1205
|
feebps
|
|
1140
1206
|
});
|
|
1141
1207
|
const account = yield this.createAccount();
|
|
1142
|
-
const { accountClient } = yield this.
|
|
1208
|
+
const { accountClient } = yield this.createAccountHelperBatch();
|
|
1143
1209
|
const fromAddress = signerAddress;
|
|
1144
1210
|
const smartAccountAddress = account.address;
|
|
1145
1211
|
const amountToTransfer = feeInclusive ? totalAmount : feeExclusiveAmountInToken;
|
|
@@ -1239,7 +1305,7 @@ var ActaAccount = class {
|
|
|
1239
1305
|
signer: this.signer
|
|
1240
1306
|
}
|
|
1241
1307
|
);
|
|
1242
|
-
const sessionKeyAddress = "
|
|
1308
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1243
1309
|
const emptyAccount = (0, import_sdk.addressToEmptyAccount)(sessionKeyAddress);
|
|
1244
1310
|
const emptySessionKeySigner = yield (0, import_signers.toECDSASigner)({ signer: emptyAccount });
|
|
1245
1311
|
const {
|
|
@@ -1367,7 +1433,7 @@ var ActaAccount = class {
|
|
|
1367
1433
|
signer: this.signer
|
|
1368
1434
|
}
|
|
1369
1435
|
);
|
|
1370
|
-
const sessionKeyAddress = "
|
|
1436
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1371
1437
|
const emptyAccount = (0, import_sdk.addressToEmptyAccount)(sessionKeyAddress);
|
|
1372
1438
|
const emptySessionKeySigner = yield (0, import_signers.toECDSASigner)({ signer: emptyAccount });
|
|
1373
1439
|
const {
|
|
@@ -1473,7 +1539,7 @@ var ActaAccount = class {
|
|
|
1473
1539
|
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1474
1540
|
const account = yield this.createAccount();
|
|
1475
1541
|
const { kernelAccountClient, accountClient } = yield this.createAccountHelpers();
|
|
1476
|
-
const sessionKeyAddress = "
|
|
1542
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1477
1543
|
const emptyAccount = (0, import_sdk.addressToEmptyAccount)(sessionKeyAddress);
|
|
1478
1544
|
const emptySessionKeySigner = yield (0, import_signers.toECDSASigner)({ signer: emptyAccount });
|
|
1479
1545
|
const callPolicy = (0, import_policies.toCallPolicy)({
|
|
@@ -2153,8 +2219,8 @@ var ActaDeposit = class {
|
|
|
2153
2219
|
|
|
2154
2220
|
// src/billing.ts
|
|
2155
2221
|
var import_viem6 = require("viem");
|
|
2156
|
-
var billingServiceUrl = "https://api.
|
|
2157
|
-
var billingServiceTestUrl = "https://api.
|
|
2222
|
+
var billingServiceUrl = "https://api.acta.link/pay/api/v1/";
|
|
2223
|
+
var billingServiceTestUrl = "https://api.acta.link/pay/test/api/v1/";
|
|
2158
2224
|
var returnEnvUrl2 = (chainId) => {
|
|
2159
2225
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2160
2226
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
@@ -2394,8 +2460,8 @@ var ActaBilling = class {
|
|
|
2394
2460
|
|
|
2395
2461
|
// src/batch.ts
|
|
2396
2462
|
var import_viem7 = require("viem");
|
|
2397
|
-
var batchServiceUrl = "https://api.
|
|
2398
|
-
var batchServiceTestUrl = "https://api.
|
|
2463
|
+
var batchServiceUrl = "https://api.acta.link/bexo/api/v1/";
|
|
2464
|
+
var batchServiceTestUrl = "https://api.acta.link/bexo/test/api/v1/";
|
|
2399
2465
|
var returnEnvUrl3 = (chainId) => {
|
|
2400
2466
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2401
2467
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
@@ -2863,10 +2929,10 @@ var import_account_abstraction2 = require("viem/account-abstraction");
|
|
|
2863
2929
|
var import_policies2 = require("@zerodev/permissions/policies");
|
|
2864
2930
|
var import_semver = require("semver");
|
|
2865
2931
|
var ECDSA_SIGNER_CONTRACT = "0x6A6F069E2a08c2468e7724Ab3250CdBFBA14D4FF";
|
|
2866
|
-
var billingServiceUrl2 = "https://api.
|
|
2932
|
+
var billingServiceUrl2 = "https://api.acta.link/pay/v1/";
|
|
2867
2933
|
var depositServiceUrl2 = "https://api.acta.link/bexo/v1/";
|
|
2868
|
-
var transactionServiceUrl2 = "https://api.
|
|
2869
|
-
var billingServiceTestUrl2 = "https://api.
|
|
2934
|
+
var transactionServiceUrl2 = "https://api.acta.link/transaction/v1/";
|
|
2935
|
+
var billingServiceTestUrl2 = "https://api.acta.link/pay/test/v1/";
|
|
2870
2936
|
var toSignerId = (signer) => {
|
|
2871
2937
|
return (0, import_viem8.encodeAbiParameters)(
|
|
2872
2938
|
[{ name: "signerData", type: "bytes" }],
|
|
@@ -3186,21 +3252,36 @@ var decodeParamsFromInitCode = (initCode, kernelVersion) => {
|
|
|
3186
3252
|
throw new Error("Invalid initCode");
|
|
3187
3253
|
return { index, validatorInitData, useMetaFactory };
|
|
3188
3254
|
};
|
|
3189
|
-
var getPeriodInterval = (periodUnit) => {
|
|
3255
|
+
var getPeriodInterval = (periodUnit, currentDate = /* @__PURE__ */ new Date(), count = 1) => {
|
|
3256
|
+
const nextDate = new Date(currentDate);
|
|
3257
|
+
const c = count;
|
|
3190
3258
|
switch (periodUnit) {
|
|
3191
3259
|
case "5mins":
|
|
3192
|
-
|
|
3260
|
+
nextDate.setMinutes(nextDate.getMinutes() + 5 * c);
|
|
3261
|
+
break;
|
|
3193
3262
|
case "day":
|
|
3194
|
-
|
|
3263
|
+
nextDate.setDate(nextDate.getDate() + 1 * c);
|
|
3264
|
+
break;
|
|
3195
3265
|
case "week":
|
|
3196
|
-
|
|
3266
|
+
nextDate.setDate(nextDate.getDate() + 7 * c);
|
|
3267
|
+
break;
|
|
3197
3268
|
case "month":
|
|
3198
|
-
|
|
3269
|
+
nextDate.setMonth(nextDate.getMonth() + 1 * c);
|
|
3270
|
+
break;
|
|
3271
|
+
case "quarter":
|
|
3272
|
+
nextDate.setMonth(nextDate.getMonth() + 3 * c);
|
|
3273
|
+
break;
|
|
3274
|
+
case "halfyear":
|
|
3275
|
+
nextDate.setMonth(nextDate.getMonth() + 6 * c);
|
|
3276
|
+
break;
|
|
3199
3277
|
case "year":
|
|
3200
|
-
|
|
3278
|
+
nextDate.setFullYear(nextDate.getFullYear() + 1 * c);
|
|
3279
|
+
break;
|
|
3201
3280
|
default:
|
|
3202
3281
|
throw new Error("Invalid period unit");
|
|
3203
3282
|
}
|
|
3283
|
+
const milliSeconds = nextDate.getTime();
|
|
3284
|
+
return { milliSeconds, nextDate };
|
|
3204
3285
|
};
|
|
3205
3286
|
var createBillingCheckoutSession = (serviceSessionparams) => __async(null, null, function* () {
|
|
3206
3287
|
var _a, _b, _c, _d;
|