@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.js
CHANGED
|
@@ -565,7 +565,7 @@ function getTokenByChainIdAndAddress(chainId, address) {
|
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
// src/deposit.ts
|
|
568
|
-
import { toHex as
|
|
568
|
+
import { toHex as toHex3, zeroAddress as zeroAddress3 } from "viem";
|
|
569
569
|
|
|
570
570
|
// src/account.ts
|
|
571
571
|
import {
|
|
@@ -573,13 +573,16 @@ import {
|
|
|
573
573
|
getAddress as getAddress2,
|
|
574
574
|
parseAbi as parseAbi2,
|
|
575
575
|
encodeFunctionData as encodeFunctionData2,
|
|
576
|
+
hexToBigInt,
|
|
576
577
|
concatHex,
|
|
577
|
-
pad
|
|
578
|
+
pad,
|
|
579
|
+
toHex
|
|
578
580
|
} from "viem";
|
|
579
581
|
import { parseAccount } from "viem/utils";
|
|
580
582
|
import {
|
|
581
583
|
createPaymasterClient,
|
|
582
|
-
formatUserOperationRequest
|
|
584
|
+
formatUserOperationRequest,
|
|
585
|
+
entryPoint07Address
|
|
583
586
|
} from "viem/account-abstraction";
|
|
584
587
|
import {
|
|
585
588
|
addressToEmptyAccount,
|
|
@@ -776,6 +779,48 @@ var ActaAccount = class {
|
|
|
776
779
|
};
|
|
777
780
|
});
|
|
778
781
|
}
|
|
782
|
+
createAccountHelperBatch() {
|
|
783
|
+
return __async(this, null, function* () {
|
|
784
|
+
const account = yield this.createAccount();
|
|
785
|
+
const entryPoint = getEntryPoint("0.7");
|
|
786
|
+
const paymasterClient = createPaymasterClient({
|
|
787
|
+
transport: http2(`https://api.acta.link/paymaster/v1/rpc`)
|
|
788
|
+
});
|
|
789
|
+
const pimlicoClient = createPimlicoClient({
|
|
790
|
+
chain: getChainById(this.chainId),
|
|
791
|
+
transport: http2(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
792
|
+
entryPoint
|
|
793
|
+
});
|
|
794
|
+
const accountClient = createSmartAccountClient({
|
|
795
|
+
account,
|
|
796
|
+
chain: getChainById(this.chainId),
|
|
797
|
+
paymaster: paymasterClient,
|
|
798
|
+
bundlerTransport: http2(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
799
|
+
userOperation: {
|
|
800
|
+
estimateFeesPerGas: () => __async(this, null, function* () {
|
|
801
|
+
return (yield pimlicoClient.getUserOperationGasPrice()).fast;
|
|
802
|
+
})
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
const kernelAccountClient = createKernelAccountClient({
|
|
806
|
+
account,
|
|
807
|
+
chain: getChainById(this.chainId),
|
|
808
|
+
paymaster: paymasterClient,
|
|
809
|
+
bundlerTransport: http2(`${proxyUrl}/rpc?chainId=${this.chainId}`),
|
|
810
|
+
userOperation: {
|
|
811
|
+
estimateFeesPerGas: () => __async(this, null, function* () {
|
|
812
|
+
return (yield pimlicoClient.getUserOperationGasPrice()).fast;
|
|
813
|
+
})
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
return {
|
|
817
|
+
paymasterClient,
|
|
818
|
+
pimlicoClient,
|
|
819
|
+
accountClient,
|
|
820
|
+
kernelAccountClient
|
|
821
|
+
};
|
|
822
|
+
});
|
|
823
|
+
}
|
|
779
824
|
estimateSinglePaymentGas(parameters) {
|
|
780
825
|
return __async(this, null, function* () {
|
|
781
826
|
const {
|
|
@@ -868,7 +913,7 @@ var ActaAccount = class {
|
|
|
868
913
|
throw new Error("Receivers not found for batch payment");
|
|
869
914
|
}
|
|
870
915
|
const account = yield this.createAccount();
|
|
871
|
-
const { accountClient, pimlicoClient } = yield this.
|
|
916
|
+
const { accountClient, pimlicoClient } = yield this.createAccountHelperBatch();
|
|
872
917
|
const fromAddress = signerAddress;
|
|
873
918
|
const smartAccountAddress = account.address;
|
|
874
919
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
@@ -899,18 +944,42 @@ var ActaAccount = class {
|
|
|
899
944
|
}
|
|
900
945
|
]
|
|
901
946
|
});
|
|
902
|
-
const
|
|
903
|
-
|
|
904
|
-
|
|
947
|
+
const data = {
|
|
948
|
+
jsonrpc: "2.0",
|
|
949
|
+
id: 1,
|
|
950
|
+
method: "pm_getTokenQuotes",
|
|
951
|
+
params: [
|
|
952
|
+
{
|
|
953
|
+
tokens: [token2.address]
|
|
954
|
+
},
|
|
955
|
+
entryPoint07Address,
|
|
956
|
+
toHex(chainId)
|
|
957
|
+
]
|
|
958
|
+
};
|
|
959
|
+
const res = yield fetch("https://api.acta.link/paymaster/v1/rpc", {
|
|
960
|
+
method: "POST",
|
|
961
|
+
headers: {
|
|
962
|
+
"Content-Type": "application/json"
|
|
963
|
+
},
|
|
964
|
+
body: JSON.stringify(data)
|
|
965
|
+
}).then((response) => {
|
|
966
|
+
if (!response.ok) {
|
|
967
|
+
throw new Error("HTTP error " + response.status);
|
|
968
|
+
}
|
|
969
|
+
return response.json();
|
|
905
970
|
});
|
|
906
971
|
const userOperationMaxCost = getRequiredPrefund({
|
|
907
972
|
userOperation,
|
|
908
973
|
entryPointVersion: "0.7"
|
|
909
974
|
});
|
|
910
|
-
const
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
975
|
+
const quotes = res.result;
|
|
976
|
+
if (!quotes.paymaster) {
|
|
977
|
+
throw new Error("Error fetching quotes");
|
|
978
|
+
}
|
|
979
|
+
const postOpGas = hexToBigInt(quotes.postOpGas);
|
|
980
|
+
const exchangeRate = hexToBigInt(quotes.exchangeRate);
|
|
981
|
+
const exchangeRateNativeToUsd = hexToBigInt(quotes.exchangeRateNativeToUsd);
|
|
982
|
+
const paymaster = quotes.paymaster;
|
|
914
983
|
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
915
984
|
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
916
985
|
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
@@ -1066,7 +1135,7 @@ var ActaAccount = class {
|
|
|
1066
1135
|
feebps
|
|
1067
1136
|
});
|
|
1068
1137
|
const account = yield this.createAccount();
|
|
1069
|
-
const { accountClient } = yield this.
|
|
1138
|
+
const { accountClient } = yield this.createAccountHelperBatch();
|
|
1070
1139
|
const fromAddress = signerAddress;
|
|
1071
1140
|
const smartAccountAddress = account.address;
|
|
1072
1141
|
const amountToTransfer = feeInclusive ? totalAmount : feeExclusiveAmountInToken;
|
|
@@ -1166,7 +1235,7 @@ var ActaAccount = class {
|
|
|
1166
1235
|
signer: this.signer
|
|
1167
1236
|
}
|
|
1168
1237
|
);
|
|
1169
|
-
const sessionKeyAddress = "
|
|
1238
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1170
1239
|
const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
|
|
1171
1240
|
const emptySessionKeySigner = yield toECDSASigner({ signer: emptyAccount });
|
|
1172
1241
|
const {
|
|
@@ -1294,7 +1363,7 @@ var ActaAccount = class {
|
|
|
1294
1363
|
signer: this.signer
|
|
1295
1364
|
}
|
|
1296
1365
|
);
|
|
1297
|
-
const sessionKeyAddress = "
|
|
1366
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1298
1367
|
const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
|
|
1299
1368
|
const emptySessionKeySigner = yield toECDSASigner({ signer: emptyAccount });
|
|
1300
1369
|
const {
|
|
@@ -1400,7 +1469,7 @@ var ActaAccount = class {
|
|
|
1400
1469
|
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1401
1470
|
const account = yield this.createAccount();
|
|
1402
1471
|
const { kernelAccountClient, accountClient } = yield this.createAccountHelpers();
|
|
1403
|
-
const sessionKeyAddress = "
|
|
1472
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1404
1473
|
const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
|
|
1405
1474
|
const emptySessionKeySigner = yield toECDSASigner({ signer: emptyAccount });
|
|
1406
1475
|
const callPolicy = toCallPolicy({
|
|
@@ -1476,7 +1545,7 @@ var ActaAccount = class {
|
|
|
1476
1545
|
};
|
|
1477
1546
|
|
|
1478
1547
|
// src/api.ts
|
|
1479
|
-
import { toHex } from "viem";
|
|
1548
|
+
import { toHex as toHex2 } from "viem";
|
|
1480
1549
|
var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
|
|
1481
1550
|
HttpMethod2["Get"] = "get";
|
|
1482
1551
|
HttpMethod2["Post"] = "post";
|
|
@@ -1562,8 +1631,8 @@ function verifySessionAPICall(url, sessionId) {
|
|
|
1562
1631
|
function scheduleRecurringPaymentsAPICall(url, params) {
|
|
1563
1632
|
return __async(this, null, function* () {
|
|
1564
1633
|
const parsedParams = __spreadProps(__spreadValues({}, params), {
|
|
1565
|
-
amount:
|
|
1566
|
-
amountExclusive:
|
|
1634
|
+
amount: toHex2(params.amount),
|
|
1635
|
+
amountExclusive: toHex2(params.amountExclusive)
|
|
1567
1636
|
});
|
|
1568
1637
|
const response = yield sendRequest({
|
|
1569
1638
|
url,
|
|
@@ -1577,8 +1646,8 @@ function scheduleSubscriptionPaymentsAPICall(url, paymentParams, serviceParams)
|
|
|
1577
1646
|
return __async(this, null, function* () {
|
|
1578
1647
|
const parsedParams = {
|
|
1579
1648
|
paymentParams: __spreadProps(__spreadValues({}, paymentParams), {
|
|
1580
|
-
amount:
|
|
1581
|
-
amountExclusive:
|
|
1649
|
+
amount: toHex2(paymentParams.amount),
|
|
1650
|
+
amountExclusive: toHex2(paymentParams.amountExclusive)
|
|
1582
1651
|
}),
|
|
1583
1652
|
serviceParams
|
|
1584
1653
|
};
|
|
@@ -1802,7 +1871,7 @@ var ActaDeposit = class {
|
|
|
1802
1871
|
signerAddress: this.signerAddress,
|
|
1803
1872
|
chainId: this.chainId,
|
|
1804
1873
|
token: token2.address,
|
|
1805
|
-
amount:
|
|
1874
|
+
amount: toHex3(this.amount),
|
|
1806
1875
|
receiver: this.receiver,
|
|
1807
1876
|
feeInclusive: this.feeInclusive,
|
|
1808
1877
|
serviceType: "deposit",
|
|
@@ -1934,7 +2003,7 @@ var ActaDeposit = class {
|
|
|
1934
2003
|
receiverAddress: receiver,
|
|
1935
2004
|
chainId,
|
|
1936
2005
|
tokenAddress: token2.address,
|
|
1937
|
-
amount:
|
|
2006
|
+
amount: toHex3(amount),
|
|
1938
2007
|
feeInclusive,
|
|
1939
2008
|
serviceType
|
|
1940
2009
|
},
|
|
@@ -2079,9 +2148,9 @@ var ActaDeposit = class {
|
|
|
2079
2148
|
};
|
|
2080
2149
|
|
|
2081
2150
|
// src/billing.ts
|
|
2082
|
-
import { toHex as
|
|
2083
|
-
var billingServiceUrl = "https://api.
|
|
2084
|
-
var billingServiceTestUrl = "https://api.
|
|
2151
|
+
import { toHex as toHex4 } from "viem";
|
|
2152
|
+
var billingServiceUrl = "https://api.acta.link/pay/api/v1/";
|
|
2153
|
+
var billingServiceTestUrl = "https://api.acta.link/pay/test/api/v1/";
|
|
2085
2154
|
var returnEnvUrl2 = (chainId) => {
|
|
2086
2155
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2087
2156
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
@@ -2203,7 +2272,7 @@ var ActaBilling = class {
|
|
|
2203
2272
|
receiverAddress: receiver,
|
|
2204
2273
|
chainId,
|
|
2205
2274
|
tokenAddress: token2.address,
|
|
2206
|
-
amount:
|
|
2275
|
+
amount: toHex4(amount),
|
|
2207
2276
|
feeInclusive,
|
|
2208
2277
|
serviceType
|
|
2209
2278
|
},
|
|
@@ -2323,11 +2392,11 @@ var ActaBilling = class {
|
|
|
2323
2392
|
import {
|
|
2324
2393
|
getAddress as getAddress3,
|
|
2325
2394
|
parseUnits,
|
|
2326
|
-
toHex as
|
|
2395
|
+
toHex as toHex5,
|
|
2327
2396
|
zeroAddress as zeroAddress4
|
|
2328
2397
|
} from "viem";
|
|
2329
|
-
var batchServiceUrl = "https://api.
|
|
2330
|
-
var batchServiceTestUrl = "https://api.
|
|
2398
|
+
var batchServiceUrl = "https://api.acta.link/bexo/api/v1/";
|
|
2399
|
+
var batchServiceTestUrl = "https://api.acta.link/bexo/test/api/v1/";
|
|
2331
2400
|
var returnEnvUrl3 = (chainId) => {
|
|
2332
2401
|
const mainnetChain = mainnetChains.find((c) => c.id === chainId);
|
|
2333
2402
|
const testnetChain = testnetChains.find((c) => c.id === chainId);
|
|
@@ -2548,7 +2617,7 @@ var ActaBatch = class {
|
|
|
2548
2617
|
senderAddress: signerAddress,
|
|
2549
2618
|
chainId,
|
|
2550
2619
|
tokenAddress: tokenData.address,
|
|
2551
|
-
amount:
|
|
2620
|
+
amount: toHex5(totalAmountParsed),
|
|
2552
2621
|
feeInclusive: isFeeInclusive,
|
|
2553
2622
|
serviceType: "batch"
|
|
2554
2623
|
},
|
|
@@ -2641,10 +2710,10 @@ var ActaBatch = class {
|
|
|
2641
2710
|
senderAddress: signerAddress,
|
|
2642
2711
|
chainId,
|
|
2643
2712
|
tokenAddress: tokenData.address,
|
|
2644
|
-
amount:
|
|
2713
|
+
amount: toHex5(totalAmountParsed),
|
|
2645
2714
|
feeInclusive: isFeeInclusive,
|
|
2646
2715
|
serviceType: "batch",
|
|
2647
|
-
amountExclusive:
|
|
2716
|
+
amountExclusive: toHex5(amountExclusive),
|
|
2648
2717
|
approval,
|
|
2649
2718
|
executionAt: executionTime
|
|
2650
2719
|
},
|
|
@@ -2706,7 +2775,7 @@ var ActaBatch = class {
|
|
|
2706
2775
|
senderAddress: signerAddress,
|
|
2707
2776
|
chainId,
|
|
2708
2777
|
tokenAddress: tokenData.address,
|
|
2709
|
-
amount:
|
|
2778
|
+
amount: toHex5(totalAmount),
|
|
2710
2779
|
feeInclusive: isFeeInclusive,
|
|
2711
2780
|
serviceType: "batch",
|
|
2712
2781
|
sessionId: serviceParams.sessionId,
|
|
@@ -2765,10 +2834,10 @@ var ActaBatch = class {
|
|
|
2765
2834
|
senderAddress: signerAddress,
|
|
2766
2835
|
chainId,
|
|
2767
2836
|
tokenAddress: tokenData.address,
|
|
2768
|
-
amount:
|
|
2837
|
+
amount: toHex5(totalAmount),
|
|
2769
2838
|
feeInclusive: isFeeInclusive,
|
|
2770
2839
|
serviceType: "batch",
|
|
2771
|
-
amountExclusive:
|
|
2840
|
+
amountExclusive: toHex5(amountExclusive),
|
|
2772
2841
|
approval,
|
|
2773
2842
|
executionAt: executionTime,
|
|
2774
2843
|
sessionId: serviceParams.sessionId
|
|
@@ -2826,10 +2895,10 @@ import {
|
|
|
2826
2895
|
} from "@zerodev/permissions/policies";
|
|
2827
2896
|
import { coerce, gt } from "semver";
|
|
2828
2897
|
var ECDSA_SIGNER_CONTRACT = "0x6A6F069E2a08c2468e7724Ab3250CdBFBA14D4FF";
|
|
2829
|
-
var billingServiceUrl2 = "https://api.
|
|
2898
|
+
var billingServiceUrl2 = "https://api.acta.link/pay/v1/";
|
|
2830
2899
|
var depositServiceUrl2 = "https://api.acta.link/bexo/v1/";
|
|
2831
|
-
var transactionServiceUrl2 = "https://api.
|
|
2832
|
-
var billingServiceTestUrl2 = "https://api.
|
|
2900
|
+
var transactionServiceUrl2 = "https://api.acta.link/transaction/v1/";
|
|
2901
|
+
var billingServiceTestUrl2 = "https://api.acta.link/pay/test/v1/";
|
|
2833
2902
|
var toSignerId = (signer) => {
|
|
2834
2903
|
return encodeAbiParameters(
|
|
2835
2904
|
[{ name: "signerData", type: "bytes" }],
|
|
@@ -3149,21 +3218,36 @@ var decodeParamsFromInitCode = (initCode, kernelVersion) => {
|
|
|
3149
3218
|
throw new Error("Invalid initCode");
|
|
3150
3219
|
return { index, validatorInitData, useMetaFactory };
|
|
3151
3220
|
};
|
|
3152
|
-
var getPeriodInterval = (periodUnit) => {
|
|
3221
|
+
var getPeriodInterval = (periodUnit, currentDate = /* @__PURE__ */ new Date(), count = 1) => {
|
|
3222
|
+
const nextDate = new Date(currentDate);
|
|
3223
|
+
const c = count;
|
|
3153
3224
|
switch (periodUnit) {
|
|
3154
3225
|
case "5mins":
|
|
3155
|
-
|
|
3226
|
+
nextDate.setMinutes(nextDate.getMinutes() + 5 * c);
|
|
3227
|
+
break;
|
|
3156
3228
|
case "day":
|
|
3157
|
-
|
|
3229
|
+
nextDate.setDate(nextDate.getDate() + 1 * c);
|
|
3230
|
+
break;
|
|
3158
3231
|
case "week":
|
|
3159
|
-
|
|
3232
|
+
nextDate.setDate(nextDate.getDate() + 7 * c);
|
|
3233
|
+
break;
|
|
3160
3234
|
case "month":
|
|
3161
|
-
|
|
3235
|
+
nextDate.setMonth(nextDate.getMonth() + 1 * c);
|
|
3236
|
+
break;
|
|
3237
|
+
case "quarter":
|
|
3238
|
+
nextDate.setMonth(nextDate.getMonth() + 3 * c);
|
|
3239
|
+
break;
|
|
3240
|
+
case "halfyear":
|
|
3241
|
+
nextDate.setMonth(nextDate.getMonth() + 6 * c);
|
|
3242
|
+
break;
|
|
3162
3243
|
case "year":
|
|
3163
|
-
|
|
3244
|
+
nextDate.setFullYear(nextDate.getFullYear() + 1 * c);
|
|
3245
|
+
break;
|
|
3164
3246
|
default:
|
|
3165
3247
|
throw new Error("Invalid period unit");
|
|
3166
3248
|
}
|
|
3249
|
+
const milliSeconds = nextDate.getTime();
|
|
3250
|
+
return { milliSeconds, nextDate };
|
|
3167
3251
|
};
|
|
3168
3252
|
var createBillingCheckoutSession = (serviceSessionparams) => __async(null, null, function* () {
|
|
3169
3253
|
var _a, _b, _c, _d;
|