@actalink/commonlib 0.0.38 → 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 +75 -9
- package/dist/index.d.cts +3435 -0
- package/dist/index.d.ts +3435 -0
- package/dist/index.js +97 -28
- 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;
|