@actalink/commonlib 0.0.41 → 0.1.0-dev
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 +45 -8
- package/dist/index.d.cts +1806 -4998
- package/dist/index.d.ts +1806 -4998
- package/dist/index.js +54 -17
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -680,6 +680,7 @@ var import_account_abstraction = require("viem/account-abstraction");
|
|
|
680
680
|
var import_sdk = require("@zerodev/sdk");
|
|
681
681
|
var import_constants = require("@zerodev/sdk/constants");
|
|
682
682
|
var import_ecdsa_validator = require("@zerodev/ecdsa-validator");
|
|
683
|
+
var import_smart_account_validator = require("@zerodev/smart-account-validator");
|
|
683
684
|
var import_permissionless = require("permissionless");
|
|
684
685
|
var import_pimlico = require("permissionless/clients/pimlico");
|
|
685
686
|
|
|
@@ -789,8 +790,9 @@ var ActaAccount = class {
|
|
|
789
790
|
this.signer = signer;
|
|
790
791
|
this.publicClient = publicClient;
|
|
791
792
|
}
|
|
792
|
-
|
|
793
|
+
createAccountFromEOA() {
|
|
793
794
|
return __async(this, null, function* () {
|
|
795
|
+
console.log("EOA connected");
|
|
794
796
|
const kernelVersion = import_constants.KERNEL_V3_1;
|
|
795
797
|
const entryPoint = (0, import_constants.getEntryPoint)("0.7");
|
|
796
798
|
const ecdsaValidator = yield (0, import_ecdsa_validator.signerToEcdsaValidator)(this.publicClient, {
|
|
@@ -808,6 +810,45 @@ var ActaAccount = class {
|
|
|
808
810
|
return account;
|
|
809
811
|
});
|
|
810
812
|
}
|
|
813
|
+
createAccountFromSmartWallet() {
|
|
814
|
+
return __async(this, null, function* () {
|
|
815
|
+
console.log("Smart account Connected");
|
|
816
|
+
const kernelVersion = import_constants.KERNEL_V3_1;
|
|
817
|
+
const entryPoint = (0, import_constants.getEntryPoint)("0.7");
|
|
818
|
+
const validator = yield (0, import_smart_account_validator.signerToSmartAccountValidator)(this.publicClient, {
|
|
819
|
+
entryPoint: (0, import_constants.getEntryPoint)("0.7"),
|
|
820
|
+
kernelVersion,
|
|
821
|
+
signer: this.signer,
|
|
822
|
+
smartAccountType: "SAFE"
|
|
823
|
+
});
|
|
824
|
+
const account = yield (0, import_sdk.createKernelAccount)(this.publicClient, {
|
|
825
|
+
plugins: {
|
|
826
|
+
sudo: validator
|
|
827
|
+
},
|
|
828
|
+
entryPoint,
|
|
829
|
+
kernelVersion
|
|
830
|
+
});
|
|
831
|
+
return account;
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
createAccount() {
|
|
835
|
+
return __async(this, null, function* () {
|
|
836
|
+
const signerAccount = this.signer.account;
|
|
837
|
+
if (!signerAccount) {
|
|
838
|
+
throw new Error("Signer account not provided");
|
|
839
|
+
}
|
|
840
|
+
const code = yield this.publicClient.getCode({
|
|
841
|
+
address: signerAccount.address
|
|
842
|
+
});
|
|
843
|
+
let account;
|
|
844
|
+
if (code && code.length > 0) {
|
|
845
|
+
account = yield this.createAccountFromSmartWallet();
|
|
846
|
+
} else {
|
|
847
|
+
account = yield this.createAccountFromEOA();
|
|
848
|
+
}
|
|
849
|
+
return account;
|
|
850
|
+
});
|
|
851
|
+
}
|
|
811
852
|
createAccountHelpers() {
|
|
812
853
|
return __async(this, null, function* () {
|
|
813
854
|
const account = yield this.createAccount();
|
|
@@ -908,10 +949,8 @@ var ActaAccount = class {
|
|
|
908
949
|
if (receiver === signerAddress) {
|
|
909
950
|
throw new Error("Receiver cannot be the same as the signer.");
|
|
910
951
|
}
|
|
911
|
-
const account = yield this.createAccount();
|
|
912
952
|
const { accountClient, pimlicoClient } = yield this.createAccountHelpers();
|
|
913
953
|
const fromAddress = signerAddress;
|
|
914
|
-
const smartAccountAddress = account.address;
|
|
915
954
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
916
955
|
if (!token2) {
|
|
917
956
|
throw new Error("Token not found.");
|
|
@@ -983,10 +1022,8 @@ var ActaAccount = class {
|
|
|
983
1022
|
if (receivers.length === 0) {
|
|
984
1023
|
throw new Error("Receivers not found for batch payment");
|
|
985
1024
|
}
|
|
986
|
-
const account = yield this.createAccount();
|
|
987
1025
|
const { accountClient, pimlicoClient } = yield this.createAccountHelperBatch();
|
|
988
1026
|
const fromAddress = signerAddress;
|
|
989
|
-
const smartAccountAddress = account.address;
|
|
990
1027
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
991
1028
|
if (!token2) {
|
|
992
1029
|
throw new Error("Token not found.");
|
|
@@ -1879,7 +1916,7 @@ var ActaFlexDeposit = class {
|
|
|
1879
1916
|
this.serviceSessionParams = void 0;
|
|
1880
1917
|
this.depositSessionId = "";
|
|
1881
1918
|
this.status = "not_started";
|
|
1882
|
-
this.serviceType = "
|
|
1919
|
+
this.serviceType = "deposit";
|
|
1883
1920
|
this.allowMaxTokenApproval = false;
|
|
1884
1921
|
var _a, _b, _c;
|
|
1885
1922
|
this.connectorType = parameters.connectorType;
|
|
@@ -2004,7 +2041,7 @@ var ActaFlexDeposit = class {
|
|
|
2004
2041
|
return __async(this, null, function* () {
|
|
2005
2042
|
try {
|
|
2006
2043
|
if (this.paymentType === "single") {
|
|
2007
|
-
const paymentParams = this.serviceType === "
|
|
2044
|
+
const paymentParams = this.serviceType === "deposit" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
|
|
2008
2045
|
depositSessionId: this.depositSessionId
|
|
2009
2046
|
}) : servicePaymentParams;
|
|
2010
2047
|
const id = yield this.createSinglePayment(paymentParams);
|
|
@@ -2013,7 +2050,7 @@ var ActaFlexDeposit = class {
|
|
|
2013
2050
|
if (this.paymentType === "choose") {
|
|
2014
2051
|
}
|
|
2015
2052
|
if (this.paymentType === "recurring") {
|
|
2016
|
-
const paymentParams = this.serviceType === "
|
|
2053
|
+
const paymentParams = this.serviceType === "deposit" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
|
|
2017
2054
|
depositSessionId: this.depositSessionId
|
|
2018
2055
|
}) : servicePaymentParams;
|
|
2019
2056
|
const id = yield this.createRecurringPayments(paymentParams);
|