@actalink/commonlib 0.1.0-dev → 0.1.0
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 +33 -8
- package/dist/index.js +33 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -854,7 +854,7 @@ var ActaAccount = class {
|
|
|
854
854
|
const account = yield this.createAccount();
|
|
855
855
|
const entryPoint = (0, import_constants.getEntryPoint)("0.7");
|
|
856
856
|
const paymasterClient = (0, import_account_abstraction.createPaymasterClient)({
|
|
857
|
-
transport: (0, import_viem3.http)(
|
|
857
|
+
transport: (0, import_viem3.http)(`https://api.acta.link/paymaster/v1/rpc`)
|
|
858
858
|
});
|
|
859
859
|
const pimlicoClient = (0, import_pimlico.createPimlicoClient)({
|
|
860
860
|
chain: getChainById(this.chainId),
|
|
@@ -975,17 +975,42 @@ var ActaAccount = class {
|
|
|
975
975
|
}
|
|
976
976
|
]
|
|
977
977
|
});
|
|
978
|
-
const
|
|
979
|
-
|
|
980
|
-
|
|
978
|
+
const data = {
|
|
979
|
+
jsonrpc: "2.0",
|
|
980
|
+
id: 1,
|
|
981
|
+
method: "pm_getTokenQuotes",
|
|
982
|
+
params: [
|
|
983
|
+
{
|
|
984
|
+
tokens: [token2.address]
|
|
985
|
+
},
|
|
986
|
+
import_account_abstraction.entryPoint07Address,
|
|
987
|
+
(0, import_viem3.toHex)(chainId)
|
|
988
|
+
]
|
|
989
|
+
};
|
|
990
|
+
const res = yield fetch("https://api.acta.link/paymaster/v1/rpc", {
|
|
991
|
+
method: "POST",
|
|
992
|
+
headers: {
|
|
993
|
+
"Content-Type": "application/json"
|
|
994
|
+
},
|
|
995
|
+
body: JSON.stringify(data)
|
|
996
|
+
}).then((response) => {
|
|
997
|
+
if (!response.ok) {
|
|
998
|
+
throw new Error("HTTP error " + response.status);
|
|
999
|
+
}
|
|
1000
|
+
return response.json();
|
|
981
1001
|
});
|
|
982
1002
|
const userOperationMaxCost = (0, import_permissionless.getRequiredPrefund)({
|
|
983
1003
|
userOperation,
|
|
984
1004
|
entryPointVersion: "0.7"
|
|
985
1005
|
});
|
|
986
|
-
const
|
|
987
|
-
|
|
988
|
-
|
|
1006
|
+
const quotes = res.result;
|
|
1007
|
+
if (!quotes.paymaster) {
|
|
1008
|
+
throw new Error("Error fetching quotes");
|
|
1009
|
+
}
|
|
1010
|
+
const postOpGas = (0, import_viem3.hexToBigInt)(quotes.postOpGas);
|
|
1011
|
+
const exchangeRate = (0, import_viem3.hexToBigInt)(quotes.exchangeRate);
|
|
1012
|
+
const exchangeRateNativeToUsd = (0, import_viem3.hexToBigInt)(quotes.exchangeRateNativeToUsd);
|
|
1013
|
+
const paymaster = quotes.paymaster;
|
|
989
1014
|
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
990
1015
|
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
991
1016
|
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
@@ -999,7 +1024,7 @@ var ActaAccount = class {
|
|
|
999
1024
|
estimatedTotalFeesInToken,
|
|
1000
1025
|
feeInclusiveAmountInToken,
|
|
1001
1026
|
feeExclusiveAmountInToken,
|
|
1002
|
-
paymaster
|
|
1027
|
+
paymaster,
|
|
1003
1028
|
userOperation
|
|
1004
1029
|
};
|
|
1005
1030
|
});
|
package/dist/index.js
CHANGED
|
@@ -783,7 +783,7 @@ var ActaAccount = class {
|
|
|
783
783
|
const account = yield this.createAccount();
|
|
784
784
|
const entryPoint = getEntryPoint("0.7");
|
|
785
785
|
const paymasterClient = createPaymasterClient({
|
|
786
|
-
transport: http2(
|
|
786
|
+
transport: http2(`https://api.acta.link/paymaster/v1/rpc`)
|
|
787
787
|
});
|
|
788
788
|
const pimlicoClient = createPimlicoClient({
|
|
789
789
|
chain: getChainById(this.chainId),
|
|
@@ -904,17 +904,42 @@ var ActaAccount = class {
|
|
|
904
904
|
}
|
|
905
905
|
]
|
|
906
906
|
});
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
|
|
907
|
+
const data = {
|
|
908
|
+
jsonrpc: "2.0",
|
|
909
|
+
id: 1,
|
|
910
|
+
method: "pm_getTokenQuotes",
|
|
911
|
+
params: [
|
|
912
|
+
{
|
|
913
|
+
tokens: [token2.address]
|
|
914
|
+
},
|
|
915
|
+
entryPoint07Address,
|
|
916
|
+
toHex(chainId)
|
|
917
|
+
]
|
|
918
|
+
};
|
|
919
|
+
const res = yield fetch("https://api.acta.link/paymaster/v1/rpc", {
|
|
920
|
+
method: "POST",
|
|
921
|
+
headers: {
|
|
922
|
+
"Content-Type": "application/json"
|
|
923
|
+
},
|
|
924
|
+
body: JSON.stringify(data)
|
|
925
|
+
}).then((response) => {
|
|
926
|
+
if (!response.ok) {
|
|
927
|
+
throw new Error("HTTP error " + response.status);
|
|
928
|
+
}
|
|
929
|
+
return response.json();
|
|
910
930
|
});
|
|
911
931
|
const userOperationMaxCost = getRequiredPrefund({
|
|
912
932
|
userOperation,
|
|
913
933
|
entryPointVersion: "0.7"
|
|
914
934
|
});
|
|
915
|
-
const
|
|
916
|
-
|
|
917
|
-
|
|
935
|
+
const quotes = res.result;
|
|
936
|
+
if (!quotes.paymaster) {
|
|
937
|
+
throw new Error("Error fetching quotes");
|
|
938
|
+
}
|
|
939
|
+
const postOpGas = hexToBigInt(quotes.postOpGas);
|
|
940
|
+
const exchangeRate = hexToBigInt(quotes.exchangeRate);
|
|
941
|
+
const exchangeRateNativeToUsd = hexToBigInt(quotes.exchangeRateNativeToUsd);
|
|
942
|
+
const paymaster = quotes.paymaster;
|
|
918
943
|
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
919
944
|
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
920
945
|
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
@@ -928,7 +953,7 @@ var ActaAccount = class {
|
|
|
928
953
|
estimatedTotalFeesInToken,
|
|
929
954
|
feeInclusiveAmountInToken,
|
|
930
955
|
feeExclusiveAmountInToken,
|
|
931
|
-
paymaster
|
|
956
|
+
paymaster,
|
|
932
957
|
userOperation
|
|
933
958
|
};
|
|
934
959
|
});
|