@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.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 zeroAddress3 } from "viem";
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
- createAccount() {
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,6 +739,45 @@ 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();
@@ -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.");
@@ -912,10 +951,8 @@ var ActaAccount = class {
912
951
  if (receivers.length === 0) {
913
952
  throw new Error("Receivers not found for batch payment");
914
953
  }
915
- const account = yield this.createAccount();
916
954
  const { accountClient, pimlicoClient } = yield this.createAccountHelperBatch();
917
955
  const fromAddress = signerAddress;
918
- const smartAccountAddress = account.address;
919
956
  const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
920
957
  if (!token2) {
921
958
  throw new Error("Token not found.");
@@ -1808,7 +1845,7 @@ var ActaFlexDeposit = class {
1808
1845
  this.serviceSessionParams = void 0;
1809
1846
  this.depositSessionId = "";
1810
1847
  this.status = "not_started";
1811
- this.serviceType = "bexo";
1848
+ this.serviceType = "deposit";
1812
1849
  this.allowMaxTokenApproval = false;
1813
1850
  var _a, _b, _c;
1814
1851
  this.connectorType = parameters.connectorType;
@@ -1836,13 +1873,13 @@ var ActaFlexDeposit = class {
1836
1873
  createSession(serviceSessionparams) {
1837
1874
  return __async(this, null, function* () {
1838
1875
  try {
1839
- if (!this.signerAddress || this.signerAddress === zeroAddress3) {
1876
+ if (!this.signerAddress || this.signerAddress === zeroAddress2) {
1840
1877
  throw new Error("Signer address is required.");
1841
1878
  }
1842
1879
  if (this.paymentType !== "single" && this.paymentType !== "choose" && this.paymentType !== "recurring") {
1843
1880
  throw new Error("Invalid payment type.");
1844
1881
  }
1845
- if (!this.receiver || this.receiver === zeroAddress3) {
1882
+ if (!this.receiver || this.receiver === zeroAddress2) {
1846
1883
  throw new Error("Receiver is required.");
1847
1884
  }
1848
1885
  if (this.paymentType === "recurring" && (this.count === void 0 || this.count === 0)) {
@@ -1933,7 +1970,7 @@ var ActaFlexDeposit = class {
1933
1970
  return __async(this, null, function* () {
1934
1971
  try {
1935
1972
  if (this.paymentType === "single") {
1936
- const paymentParams = this.serviceType === "bexo" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
1973
+ const paymentParams = this.serviceType === "deposit" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
1937
1974
  depositSessionId: this.depositSessionId
1938
1975
  }) : servicePaymentParams;
1939
1976
  const id = yield this.createSinglePayment(paymentParams);
@@ -1942,7 +1979,7 @@ var ActaFlexDeposit = class {
1942
1979
  if (this.paymentType === "choose") {
1943
1980
  }
1944
1981
  if (this.paymentType === "recurring") {
1945
- const paymentParams = this.serviceType === "bexo" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
1982
+ const paymentParams = this.serviceType === "deposit" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
1946
1983
  depositSessionId: this.depositSessionId
1947
1984
  }) : servicePaymentParams;
1948
1985
  const id = yield this.createRecurringPayments(paymentParams);
@@ -2152,7 +2189,7 @@ import {
2152
2189
  getAddress as getAddress3,
2153
2190
  parseUnits,
2154
2191
  toHex as toHex4,
2155
- zeroAddress as zeroAddress4
2192
+ zeroAddress as zeroAddress3
2156
2193
  } from "viem";
2157
2194
  var batchServiceUrl = "https://flex-api.acta.link/flex/batch/api/v1/";
2158
2195
  var batchServiceTestUrl = "https://flex-api.acta.link/flex/batch/test/api/v1/";
@@ -2184,7 +2221,7 @@ var ActaFlexBatch = class {
2184
2221
  if (!this.APIkey) {
2185
2222
  throw new Error("No API key provided.");
2186
2223
  }
2187
- if (!signerAddress || signerAddress === zeroAddress4) {
2224
+ if (!signerAddress || signerAddress === zeroAddress3) {
2188
2225
  throw new Error("Signer address is required.");
2189
2226
  }
2190
2227
  if (!name || name === "") {
@@ -2858,7 +2895,7 @@ import {
2858
2895
  getAddress as getAddress4,
2859
2896
  parseUnits as parseUnits2,
2860
2897
  toHex as toHex6,
2861
- zeroAddress as zeroAddress5
2898
+ zeroAddress as zeroAddress4
2862
2899
  } from "viem";
2863
2900
  var batchServiceUrl2 = "https://api.acta.link/bexo/api/v1/";
2864
2901
  var batchServiceTestUrl2 = "https://api.acta.link/bexo/test/api/v1/";
@@ -2890,7 +2927,7 @@ var ActaBatch = class {
2890
2927
  if (!this.APIkey) {
2891
2928
  throw new Error("No API key provided.");
2892
2929
  }
2893
- if (!signerAddress || signerAddress === zeroAddress5) {
2930
+ if (!signerAddress || signerAddress === zeroAddress4) {
2894
2931
  throw new Error("Signer address is required.");
2895
2932
  }
2896
2933
  if (!name || name === "") {
@@ -3337,7 +3374,7 @@ import {
3337
3374
  encodeAbiParameters,
3338
3375
  keccak256,
3339
3376
  slice,
3340
- zeroAddress as zeroAddress6,
3377
+ zeroAddress as zeroAddress5,
3341
3378
  decodeFunctionData,
3342
3379
  hexToBigInt as hexToBigInt2
3343
3380
  } from "viem";
@@ -3449,7 +3486,7 @@ function toPermissionValidator2(_0, _1) {
3449
3486
  return __spreadProps(__spreadValues({}, signer.account), {
3450
3487
  supportedKernelVersions: ">=0.3.0",
3451
3488
  validatorType: "PERMISSION",
3452
- address: zeroAddress6,
3489
+ address: zeroAddress5,
3453
3490
  source: "PermissionValidator",
3454
3491
  getEnableData,
3455
3492
  getIdentifier: getPermissionId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actalink/commonlib",
3
- "version": "0.0.41",
3
+ "version": "0.1.0-dev",
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.30.0"
42
+ "viem": "2.43.2"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@types/semver": "^7.7.0",