@actalink/commonlib 0.0.42 → 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 +75 -13
- package/dist/index.d.cts +1806 -4998
- package/dist/index.d.ts +1806 -4998
- package/dist/index.js +84 -22
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -565,7 +565,7 @@ function getTokenByChainIdAndAddress(chainId, address) {
|
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
// src/flexdeposit.ts
|
|
568
|
-
import { toHex as toHex3, zeroAddress as
|
|
568
|
+
import { toHex as toHex3, zeroAddress as zeroAddress2 } from "viem";
|
|
569
569
|
|
|
570
570
|
// src/account.ts
|
|
571
571
|
import {
|
|
@@ -596,6 +596,7 @@ import {
|
|
|
596
596
|
VALIDATOR_TYPE
|
|
597
597
|
} from "@zerodev/sdk/constants";
|
|
598
598
|
import { signerToEcdsaValidator } from "@zerodev/ecdsa-validator";
|
|
599
|
+
import { signerToSmartAccountValidator } from "@zerodev/smart-account-validator";
|
|
599
600
|
import { createSmartAccountClient, getRequiredPrefund } from "permissionless";
|
|
600
601
|
import { createPimlicoClient } from "permissionless/clients/pimlico";
|
|
601
602
|
|
|
@@ -718,8 +719,9 @@ var ActaAccount = class {
|
|
|
718
719
|
this.signer = signer;
|
|
719
720
|
this.publicClient = publicClient;
|
|
720
721
|
}
|
|
721
|
-
|
|
722
|
+
createAccountFromEOA() {
|
|
722
723
|
return __async(this, null, function* () {
|
|
724
|
+
console.log("EOA connected");
|
|
723
725
|
const kernelVersion = KERNEL_V3_1;
|
|
724
726
|
const entryPoint = getEntryPoint("0.7");
|
|
725
727
|
const ecdsaValidator = yield signerToEcdsaValidator(this.publicClient, {
|
|
@@ -737,12 +739,51 @@ var ActaAccount = class {
|
|
|
737
739
|
return account;
|
|
738
740
|
});
|
|
739
741
|
}
|
|
742
|
+
createAccountFromSmartWallet() {
|
|
743
|
+
return __async(this, null, function* () {
|
|
744
|
+
console.log("Smart account Connected");
|
|
745
|
+
const kernelVersion = KERNEL_V3_1;
|
|
746
|
+
const entryPoint = getEntryPoint("0.7");
|
|
747
|
+
const validator = yield signerToSmartAccountValidator(this.publicClient, {
|
|
748
|
+
entryPoint: getEntryPoint("0.7"),
|
|
749
|
+
kernelVersion,
|
|
750
|
+
signer: this.signer,
|
|
751
|
+
smartAccountType: "SAFE"
|
|
752
|
+
});
|
|
753
|
+
const account = yield createKernelAccount(this.publicClient, {
|
|
754
|
+
plugins: {
|
|
755
|
+
sudo: validator
|
|
756
|
+
},
|
|
757
|
+
entryPoint,
|
|
758
|
+
kernelVersion
|
|
759
|
+
});
|
|
760
|
+
return account;
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
createAccount() {
|
|
764
|
+
return __async(this, null, function* () {
|
|
765
|
+
const signerAccount = this.signer.account;
|
|
766
|
+
if (!signerAccount) {
|
|
767
|
+
throw new Error("Signer account not provided");
|
|
768
|
+
}
|
|
769
|
+
const code = yield this.publicClient.getCode({
|
|
770
|
+
address: signerAccount.address
|
|
771
|
+
});
|
|
772
|
+
let account;
|
|
773
|
+
if (code && code.length > 0) {
|
|
774
|
+
account = yield this.createAccountFromSmartWallet();
|
|
775
|
+
} else {
|
|
776
|
+
account = yield this.createAccountFromEOA();
|
|
777
|
+
}
|
|
778
|
+
return account;
|
|
779
|
+
});
|
|
780
|
+
}
|
|
740
781
|
createAccountHelpers() {
|
|
741
782
|
return __async(this, null, function* () {
|
|
742
783
|
const account = yield this.createAccount();
|
|
743
784
|
const entryPoint = getEntryPoint("0.7");
|
|
744
785
|
const paymasterClient = createPaymasterClient({
|
|
745
|
-
transport: http2(
|
|
786
|
+
transport: http2(`https://api.acta.link/paymaster/v1/rpc`)
|
|
746
787
|
});
|
|
747
788
|
const pimlicoClient = createPimlicoClient({
|
|
748
789
|
chain: getChainById(this.chainId),
|
|
@@ -837,10 +878,8 @@ var ActaAccount = class {
|
|
|
837
878
|
if (receiver === signerAddress) {
|
|
838
879
|
throw new Error("Receiver cannot be the same as the signer.");
|
|
839
880
|
}
|
|
840
|
-
const account = yield this.createAccount();
|
|
841
881
|
const { accountClient, pimlicoClient } = yield this.createAccountHelpers();
|
|
842
882
|
const fromAddress = signerAddress;
|
|
843
|
-
const smartAccountAddress = account.address;
|
|
844
883
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
845
884
|
if (!token2) {
|
|
846
885
|
throw new Error("Token not found.");
|
|
@@ -865,17 +904,42 @@ var ActaAccount = class {
|
|
|
865
904
|
}
|
|
866
905
|
]
|
|
867
906
|
});
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
|
|
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();
|
|
871
930
|
});
|
|
872
931
|
const userOperationMaxCost = getRequiredPrefund({
|
|
873
932
|
userOperation,
|
|
874
933
|
entryPointVersion: "0.7"
|
|
875
934
|
});
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
|
|
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;
|
|
879
943
|
const maxCostInWei = userOperationMaxCost + postOpGas * userOperation.maxFeePerGas;
|
|
880
944
|
const costInToken = maxCostInWei * exchangeRate / BigInt(1e18);
|
|
881
945
|
const costInUsd = maxCostInWei * exchangeRateNativeToUsd / BigInt(1e18);
|
|
@@ -889,7 +953,7 @@ var ActaAccount = class {
|
|
|
889
953
|
estimatedTotalFeesInToken,
|
|
890
954
|
feeInclusiveAmountInToken,
|
|
891
955
|
feeExclusiveAmountInToken,
|
|
892
|
-
paymaster
|
|
956
|
+
paymaster,
|
|
893
957
|
userOperation
|
|
894
958
|
};
|
|
895
959
|
});
|
|
@@ -912,10 +976,8 @@ var ActaAccount = class {
|
|
|
912
976
|
if (receivers.length === 0) {
|
|
913
977
|
throw new Error("Receivers not found for batch payment");
|
|
914
978
|
}
|
|
915
|
-
const account = yield this.createAccount();
|
|
916
979
|
const { accountClient, pimlicoClient } = yield this.createAccountHelperBatch();
|
|
917
980
|
const fromAddress = signerAddress;
|
|
918
|
-
const smartAccountAddress = account.address;
|
|
919
981
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
920
982
|
if (!token2) {
|
|
921
983
|
throw new Error("Token not found.");
|
|
@@ -1836,13 +1898,13 @@ var ActaFlexDeposit = class {
|
|
|
1836
1898
|
createSession(serviceSessionparams) {
|
|
1837
1899
|
return __async(this, null, function* () {
|
|
1838
1900
|
try {
|
|
1839
|
-
if (!this.signerAddress || this.signerAddress ===
|
|
1901
|
+
if (!this.signerAddress || this.signerAddress === zeroAddress2) {
|
|
1840
1902
|
throw new Error("Signer address is required.");
|
|
1841
1903
|
}
|
|
1842
1904
|
if (this.paymentType !== "single" && this.paymentType !== "choose" && this.paymentType !== "recurring") {
|
|
1843
1905
|
throw new Error("Invalid payment type.");
|
|
1844
1906
|
}
|
|
1845
|
-
if (!this.receiver || this.receiver ===
|
|
1907
|
+
if (!this.receiver || this.receiver === zeroAddress2) {
|
|
1846
1908
|
throw new Error("Receiver is required.");
|
|
1847
1909
|
}
|
|
1848
1910
|
if (this.paymentType === "recurring" && (this.count === void 0 || this.count === 0)) {
|
|
@@ -2152,7 +2214,7 @@ import {
|
|
|
2152
2214
|
getAddress as getAddress3,
|
|
2153
2215
|
parseUnits,
|
|
2154
2216
|
toHex as toHex4,
|
|
2155
|
-
zeroAddress as
|
|
2217
|
+
zeroAddress as zeroAddress3
|
|
2156
2218
|
} from "viem";
|
|
2157
2219
|
var batchServiceUrl = "https://flex-api.acta.link/flex/batch/api/v1/";
|
|
2158
2220
|
var batchServiceTestUrl = "https://flex-api.acta.link/flex/batch/test/api/v1/";
|
|
@@ -2184,7 +2246,7 @@ var ActaFlexBatch = class {
|
|
|
2184
2246
|
if (!this.APIkey) {
|
|
2185
2247
|
throw new Error("No API key provided.");
|
|
2186
2248
|
}
|
|
2187
|
-
if (!signerAddress || signerAddress ===
|
|
2249
|
+
if (!signerAddress || signerAddress === zeroAddress3) {
|
|
2188
2250
|
throw new Error("Signer address is required.");
|
|
2189
2251
|
}
|
|
2190
2252
|
if (!name || name === "") {
|
|
@@ -2858,7 +2920,7 @@ import {
|
|
|
2858
2920
|
getAddress as getAddress4,
|
|
2859
2921
|
parseUnits as parseUnits2,
|
|
2860
2922
|
toHex as toHex6,
|
|
2861
|
-
zeroAddress as
|
|
2923
|
+
zeroAddress as zeroAddress4
|
|
2862
2924
|
} from "viem";
|
|
2863
2925
|
var batchServiceUrl2 = "https://api.acta.link/bexo/api/v1/";
|
|
2864
2926
|
var batchServiceTestUrl2 = "https://api.acta.link/bexo/test/api/v1/";
|
|
@@ -2890,7 +2952,7 @@ var ActaBatch = class {
|
|
|
2890
2952
|
if (!this.APIkey) {
|
|
2891
2953
|
throw new Error("No API key provided.");
|
|
2892
2954
|
}
|
|
2893
|
-
if (!signerAddress || signerAddress ===
|
|
2955
|
+
if (!signerAddress || signerAddress === zeroAddress4) {
|
|
2894
2956
|
throw new Error("Signer address is required.");
|
|
2895
2957
|
}
|
|
2896
2958
|
if (!name || name === "") {
|
|
@@ -3337,7 +3399,7 @@ import {
|
|
|
3337
3399
|
encodeAbiParameters,
|
|
3338
3400
|
keccak256,
|
|
3339
3401
|
slice,
|
|
3340
|
-
zeroAddress as
|
|
3402
|
+
zeroAddress as zeroAddress5,
|
|
3341
3403
|
decodeFunctionData,
|
|
3342
3404
|
hexToBigInt as hexToBigInt2
|
|
3343
3405
|
} from "viem";
|
|
@@ -3449,7 +3511,7 @@ function toPermissionValidator2(_0, _1) {
|
|
|
3449
3511
|
return __spreadProps(__spreadValues({}, signer.account), {
|
|
3450
3512
|
supportedKernelVersions: ">=0.3.0",
|
|
3451
3513
|
validatorType: "PERMISSION",
|
|
3452
|
-
address:
|
|
3514
|
+
address: zeroAddress5,
|
|
3453
3515
|
source: "PermissionValidator",
|
|
3454
3516
|
getEnableData,
|
|
3455
3517
|
getIdentifier: getPermissionId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actalink/commonlib",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"author": "Actalink",
|
|
5
5
|
"license": "MIT license",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,12 +33,13 @@
|
|
|
33
33
|
"@zerodev/ecdsa-validator": "^5.4.8",
|
|
34
34
|
"@zerodev/permissions": "5.5.12",
|
|
35
35
|
"@zerodev/sdk": "5.4.41",
|
|
36
|
+
"@zerodev/smart-account-validator": "^5.4.1",
|
|
36
37
|
"@zerodev/webauthn-key": "^5.4.4",
|
|
37
38
|
"permissionless": "^0.2.47",
|
|
38
39
|
"semver": "^7.7.2",
|
|
39
40
|
"ts-node": "^10.9.2",
|
|
40
41
|
"typescript": "^5.8.3",
|
|
41
|
-
"viem": "2.
|
|
42
|
+
"viem": "2.43.2"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/semver": "^7.7.0",
|