kokio-sdk 0.1.2 → 0.1.4

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.
Files changed (78) hide show
  1. package/{src/abis/BeaconProxy.json → dist/esm/abis/BeaconProxy.js} +3 -2
  2. package/dist/esm/abis/DeviceWallet.js +913 -0
  3. package/{src/abis/DeviceWalletFactory.json → dist/esm/abis/DeviceWalletFactory.js} +3 -2
  4. package/{src/abis/ESIMWallet.json → dist/esm/abis/ESIMWallet.js} +3 -2
  5. package/{src/abis/ESIMWalletFactory.json → dist/esm/abis/ESIMWalletFactory.js} +3 -2
  6. package/{src/abis/LazyWalletRegistry.json → dist/esm/abis/LazyWalletRegistry.js} +3 -2
  7. package/{src/abis/P256Verifier.json → dist/esm/abis/P256Verifier.js} +3 -2
  8. package/{src/abis/Registry.json → dist/esm/abis/Registry.js} +3 -2
  9. package/{src/abis/RegistryHelper.json → dist/esm/abis/RegistryHelper.js} +3 -2
  10. package/dist/esm/abis/index.js +10 -0
  11. package/dist/esm/config.js +52 -0
  12. package/dist/esm/interface/P256VerifierClass.js +10 -0
  13. package/dist/esm/interface/constantsClass.js +38 -0
  14. package/{src/interface/deviceWalletClass.ts → dist/esm/interface/deviceWalletClass.js} +12 -36
  15. package/dist/esm/interface/deviceWalletFactoryClass.js +18 -0
  16. package/dist/esm/interface/eSIMWalletClass.js +33 -0
  17. package/dist/esm/interface/eSIMWalletFactoryClass.js +21 -0
  18. package/dist/esm/interface/lazyWalletRegistryClass.js +19 -0
  19. package/{src/interface/smartAccountClass.ts → dist/esm/interface/smartAccountClass.js} +3 -11
  20. package/dist/esm/interface/utilsClass.js +13 -0
  21. package/{src/logic/P256Verifier.ts → dist/esm/logic/P256Verifier.js} +6 -17
  22. package/dist/esm/logic/account-kit/createSmartAccount.js +298 -0
  23. package/{src/logic/constants.ts → dist/esm/logic/constants.js} +42 -103
  24. package/{src/logic/deviceWallet.ts → dist/esm/logic/deviceWallet.js} +46 -74
  25. package/{src/logic/deviceWalletFactory.ts → dist/esm/logic/deviceWalletFactory.js} +22 -43
  26. package/{src/logic/eSIMWallet.ts → dist/esm/logic/eSIMWallet.js} +41 -59
  27. package/{src/logic/eSIMWalletFactory.ts → dist/esm/logic/eSIMWalletFactory.js} +28 -41
  28. package/{src/logic/lazyWalletRegistry.ts → dist/esm/logic/lazyWalletRegistry.js} +29 -60
  29. package/dist/esm/logic/utils.js +100 -0
  30. package/dist/esm/types-export.js +1 -0
  31. package/dist/esm/types.js +1 -0
  32. package/dist/types/abis/BeaconProxy.d.ts +3 -0
  33. package/dist/types/abis/DeviceWallet.d.ts +3 -0
  34. package/dist/types/abis/DeviceWalletFactory.d.ts +3 -0
  35. package/dist/types/abis/ESIMWallet.d.ts +3 -0
  36. package/dist/types/abis/ESIMWalletFactory.d.ts +3 -0
  37. package/dist/types/abis/LazyWalletRegistry.d.ts +3 -0
  38. package/dist/types/abis/P256Verifier.d.ts +3 -0
  39. package/dist/types/abis/Registry.d.ts +3 -0
  40. package/dist/types/abis/RegistryHelper.d.ts +3 -0
  41. package/dist/types/abis/index.d.ts +10 -0
  42. package/dist/types/config.d.ts +37 -0
  43. package/dist/types/interface/P256VerifierClass.d.ts +7 -0
  44. package/dist/types/interface/constantsClass.d.ts +27 -0
  45. package/dist/types/interface/deviceWalletClass.d.ts +2577 -0
  46. package/dist/types/interface/deviceWalletFactoryClass.d.ts +2570 -0
  47. package/dist/types/interface/eSIMWalletClass.d.ts +16 -0
  48. package/dist/types/interface/eSIMWalletFactoryClass.d.ts +2571 -0
  49. package/dist/types/interface/lazyWalletRegistryClass.d.ts +11 -0
  50. package/dist/types/interface/smartAccountClass.d.ts +2574 -0
  51. package/dist/types/interface/utilsClass.d.ts +2567 -0
  52. package/dist/types/logic/P256Verifier.d.ts +3 -0
  53. package/dist/types/logic/account-kit/createSmartAccount.d.ts +6 -0
  54. package/dist/types/logic/constants.d.ts +32 -0
  55. package/dist/types/logic/deviceWallet.d.ts +12 -0
  56. package/dist/types/logic/deviceWalletFactory.d.ts +5 -0
  57. package/dist/types/logic/eSIMWallet.d.ts +11 -0
  58. package/dist/types/logic/eSIMWalletFactory.d.ts +6 -0
  59. package/dist/types/logic/lazyWalletRegistry.d.ts +7 -0
  60. package/dist/types/logic/utils.d.ts +18 -0
  61. package/dist/types/types-export.d.ts +1 -0
  62. package/{src/types.ts → dist/types/types.d.ts} +19 -21
  63. package/package.json +24 -14
  64. package/.github/workflows/npm_publish.yaml +0 -45
  65. package/src/abis/DeviceWallet.json +0 -912
  66. package/src/abis/index.ts +0 -21
  67. package/src/config.ts +0 -58
  68. package/src/interface/P256VerifierClass.ts +0 -19
  69. package/src/interface/constantsClass.ts +0 -36
  70. package/src/interface/deviceWalletFactoryClass.ts +0 -35
  71. package/src/interface/eSIMWalletClass.ts +0 -55
  72. package/src/interface/eSIMWalletFactoryClass.ts +0 -36
  73. package/src/interface/lazyWalletRegistryClass.ts +0 -34
  74. package/src/interface/utilsClass.ts +0 -21
  75. package/src/logic/account-kit/createSmartAccount.ts +0 -401
  76. package/src/logic/utils.ts +0 -123
  77. package/src/types-export.ts +0 -7
  78. package/tsconfig.json +0 -114
@@ -1,4 +1,4 @@
1
- [
1
+ const DeviceWalletFactory = [
2
2
  {
3
3
  "inputs": [
4
4
  {
@@ -820,4 +820,5 @@
820
820
  "stateMutability": "view",
821
821
  "type": "function"
822
822
  }
823
- ]
823
+ ];
824
+ export default DeviceWalletFactory;
@@ -1,4 +1,4 @@
1
- [
1
+ const ESIMWallet = [
2
2
  {
3
3
  "inputs": [],
4
4
  "stateMutability": "nonpayable",
@@ -483,4 +483,5 @@
483
483
  "stateMutability": "payable",
484
484
  "type": "receive"
485
485
  }
486
- ]
486
+ ];
487
+ export default ESIMWallet;
@@ -1,4 +1,4 @@
1
- [
1
+ const ESIMWalletFactory = [
2
2
  {
3
3
  "inputs": [
4
4
  {
@@ -459,4 +459,5 @@
459
459
  "stateMutability": "payable",
460
460
  "type": "function"
461
461
  }
462
- ]
462
+ ];
463
+ export default ESIMWalletFactory;
@@ -1,4 +1,4 @@
1
- [
1
+ const LazyWalletRegistry = [
2
2
  {
3
3
  "inputs": [
4
4
  {
@@ -726,4 +726,5 @@
726
726
  "stateMutability": "payable",
727
727
  "type": "function"
728
728
  }
729
- ]
729
+ ];
730
+ export default LazyWalletRegistry;
@@ -1,4 +1,4 @@
1
- [
1
+ const P256Verifier = [
2
2
  {
3
3
  "inputs": [
4
4
  {
@@ -70,4 +70,5 @@
70
70
  "stateMutability": "view",
71
71
  "type": "function"
72
72
  }
73
- ]
73
+ ];
74
+ export default P256Verifier;
@@ -1,4 +1,4 @@
1
- [
1
+ const Registry = [
2
2
  {
3
3
  "inputs": [
4
4
  {
@@ -803,4 +803,5 @@
803
803
  "stateMutability": "view",
804
804
  "type": "function"
805
805
  }
806
- ]
806
+ ];
807
+ export default Registry;
@@ -1,4 +1,4 @@
1
- [
1
+ const RegistryHelper = [
2
2
  {
3
3
  "type": "function",
4
4
  "name": "deployLazyWallet",
@@ -379,4 +379,5 @@
379
379
  "name": "OnlyLazyWalletRegistry",
380
380
  "inputs": []
381
381
  }
382
- ]
382
+ ];
383
+ export default RegistryHelper;
@@ -0,0 +1,10 @@
1
+ import DeviceWallet from './DeviceWallet.js';
2
+ import DeviceWalletFactory from './DeviceWalletFactory.js';
3
+ import ESIMWallet from './ESIMWallet.js';
4
+ import ESIMWalletFactory from './ESIMWalletFactory.js';
5
+ import LazyWalletRegistry from './LazyWalletRegistry.js';
6
+ import P256Verifier from './P256Verifier.js';
7
+ import Registry from './Registry.js';
8
+ import RegistryHelper from './RegistryHelper.js';
9
+ import BeaconProxy from './BeaconProxy.js';
10
+ export { DeviceWallet, DeviceWalletFactory, ESIMWallet, ESIMWalletFactory, LazyWalletRegistry, P256Verifier, Registry, RegistryHelper, BeaconProxy };
@@ -0,0 +1,52 @@
1
+ import { ConstantsSubPackage } from "./interface/constantsClass.js";
2
+ import { SmartAccountSubPackage } from "./interface/smartAccountClass.js";
3
+ import { DeviceWalletFactorySubPackage } from "./interface/deviceWalletFactoryClass.js";
4
+ import { P256VerifierSubPackage } from "./interface/P256VerifierClass.js";
5
+ import { LazyWalletRegistrySubPackage } from "./interface/lazyWalletRegistryClass.js";
6
+ import { DeviceWalletSubPackage } from "./interface/deviceWalletClass.js";
7
+ import { ESIMWalletSubPackage } from "./interface/eSIMWalletClass.js";
8
+ import { ESIMWalletFactorySubPackage } from "./interface/eSIMWalletFactoryClass.js";
9
+ export class Kokio {
10
+ viemWalletClient;
11
+ credentialId;
12
+ rpId;
13
+ organizationId;
14
+ pimlicoAPIKey;
15
+ gasPolicyId;
16
+ _constants;
17
+ smartAccount;
18
+ deviceWalletFactory;
19
+ eSIMWalletFactory;
20
+ lazyWalletRegistry;
21
+ deviceWallet;
22
+ eSIMWallet;
23
+ P256Verifier;
24
+ constructor(viemWalletClient, credentialId, rpId, organizationId, pimlicoAPIKey, gasPolicyId, smartAccountClient, deviceWalletAddress, eSIMWalletAddress) {
25
+ this.viemWalletClient = viemWalletClient;
26
+ this.credentialId = credentialId;
27
+ this.rpId = rpId;
28
+ this.organizationId = organizationId;
29
+ this.pimlicoAPIKey = pimlicoAPIKey;
30
+ this.gasPolicyId = gasPolicyId;
31
+ this._constants = new ConstantsSubPackage(this.viemWalletClient, this.pimlicoAPIKey);
32
+ this.smartAccount = new SmartAccountSubPackage(this.viemWalletClient, this.credentialId, this.rpId, this.organizationId, this.pimlicoAPIKey, this.gasPolicyId);
33
+ this.deviceWalletFactory = smartAccountClient ? new DeviceWalletFactorySubPackage(viemWalletClient, smartAccountClient) : undefined;
34
+ this.eSIMWalletFactory = smartAccountClient ? new ESIMWalletFactorySubPackage(viemWalletClient, smartAccountClient) : undefined;
35
+ this.lazyWalletRegistry = smartAccountClient ? new LazyWalletRegistrySubPackage(smartAccountClient) : undefined;
36
+ this.P256Verifier = smartAccountClient ? new P256VerifierSubPackage(smartAccountClient) : undefined;
37
+ this.deviceWallet = deviceWalletAddress && smartAccountClient ? new DeviceWalletSubPackage(viemWalletClient, smartAccountClient, deviceWalletAddress) : undefined;
38
+ this.eSIMWallet = eSIMWalletAddress && smartAccountClient ? new ESIMWalletSubPackage(smartAccountClient, eSIMWalletAddress) : undefined;
39
+ }
40
+ /**
41
+ * Chain-specific constants (factory addresses, chain, RPC URLs, custom errors)
42
+ * for the wallet client's connected chain. Resolution is asynchronous because
43
+ * the chain id is read from the client, so this getter returns a promise:
44
+ *
45
+ * const { factoryAddresses } = await kokio.constants;
46
+ *
47
+ * The underlying value is memoized, so repeated awaits do not re-fetch.
48
+ */
49
+ get constants() {
50
+ return this._constants.load();
51
+ }
52
+ }
@@ -0,0 +1,10 @@
1
+ import { _verifySignature } from "../logic/P256Verifier.js";
2
+ export class P256VerifierSubPackage {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ verifySignature(message, requireMessageVerification, webAuthnSignature, x, y) {
8
+ return _verifySignature(this.client, message, requireMessageVerification, webAuthnSignature, x, y);
9
+ }
10
+ }
@@ -0,0 +1,38 @@
1
+ import { _extractChainID, _getChainSpecificConstants } from "../logic/constants.js";
2
+ /**
3
+ * Resolves chain-specific constants for the wallet client's connected chain.
4
+ *
5
+ * The chain id can only be read asynchronously from the client, so resolution
6
+ * is deferred to `load()` (memoized after the first call). Access the resolved
7
+ * values via `await kokio.constants` on the top-level SDK instance.
8
+ */
9
+ export class ConstantsSubPackage {
10
+ client;
11
+ pimlicoAPIKey;
12
+ cache;
13
+ constructor(client, pimlicoAPIKey) {
14
+ this.client = client;
15
+ this.pimlicoAPIKey = pimlicoAPIKey;
16
+ }
17
+ /**
18
+ * Resolves and caches the chain-specific constants. Subsequent calls
19
+ * return the same promise, so the chain id is only fetched once.
20
+ */
21
+ load() {
22
+ if (!this.cache) {
23
+ this.cache = (async () => {
24
+ const chainID = await _extractChainID(this.client);
25
+ const rpcURL = this.client.transport.url;
26
+ const values = _getChainSpecificConstants(chainID, rpcURL, this.pimlicoAPIKey);
27
+ return {
28
+ factoryAddresses: values.factoryAddresses,
29
+ chain: values.chain,
30
+ rpcURL: values.rpcURL,
31
+ pimlicoRpcURL: values.pimlicoRpcURL,
32
+ customErrors: values.customErrors,
33
+ };
34
+ })();
35
+ }
36
+ return this.cache;
37
+ }
38
+ }
@@ -1,62 +1,38 @@
1
- import { Address, WalletClient } from "viem";
2
- import {
3
- _addESIMWallet,
4
- _deployESIMWallet,
5
- _getOwner,
6
- _getVaultAddress,
7
- _payETHForDataBundles,
8
- _pullETH,
9
- _removeESIMWallet,
10
- _setESIMUniqueIdentifierForAnESIMWallet,
11
- _toggleAccessToETH
12
- } from "../logic/deviceWallet.js"
13
- import { SmartAccountClient } from "@aa-sdk/core";
14
-
1
+ import { _addESIMWallet, _deployESIMWallet, _getOwner, _getVaultAddress, _payETHForDataBundles, _pullETH, _removeESIMWallet, _setESIMUniqueIdentifierForAnESIMWallet, _toggleAccessToETH } from "../logic/deviceWallet.js";
15
2
  export class DeviceWalletSubPackage {
16
-
17
3
  smartAccountClient;
18
4
  walletClient;
19
5
  address;
20
-
21
- constructor(walletClient: WalletClient, smartAccountClient: SmartAccountClient, address: Address) {
6
+ constructor(walletClient, smartAccountClient, address) {
22
7
  this.smartAccountClient = smartAccountClient;
23
8
  this.walletClient = walletClient;
24
9
  this.address = address;
25
10
  }
26
-
27
- addESIMWallet (eSIMWalletAddress: Address, hasAccessToETH: boolean) {
11
+ addESIMWallet(eSIMWalletAddress, hasAccessToETH) {
28
12
  return _addESIMWallet(this.smartAccountClient, this.address, eSIMWalletAddress, hasAccessToETH);
29
13
  }
30
-
31
- deployESIMWallet (hasAccessToETH: boolean, salt: bigint) {
14
+ deployESIMWallet(hasAccessToETH, salt) {
32
15
  return _deployESIMWallet(this.smartAccountClient, this.address, hasAccessToETH, salt);
33
16
  }
34
-
35
- getVaultAddress () {
17
+ getVaultAddress() {
36
18
  return _getVaultAddress(this.smartAccountClient, this.address);
37
19
  }
38
-
39
- payETHForDataBundles (amount: bigint) {
20
+ payETHForDataBundles(amount) {
40
21
  return _payETHForDataBundles(this.smartAccountClient, this.address, amount);
41
22
  }
42
-
43
- pullETH (amount: bigint) {
23
+ pullETH(amount) {
44
24
  return _pullETH(this.smartAccountClient, this.address, amount);
45
25
  }
46
-
47
- removeESIMWallet (eSIMWalletAddress: Address, hasAccessToETH: boolean) {
26
+ removeESIMWallet(eSIMWalletAddress, hasAccessToETH) {
48
27
  return _removeESIMWallet(this.smartAccountClient, this.address, eSIMWalletAddress, hasAccessToETH);
49
28
  }
50
-
51
- setESIMUniqueIdentifierForAnESIMWallet (eSIMWalletAddress: Address, eSIMUniqueIdentifier: string) {
29
+ setESIMUniqueIdentifierForAnESIMWallet(eSIMWalletAddress, eSIMUniqueIdentifier) {
52
30
  return _setESIMUniqueIdentifierForAnESIMWallet(this.smartAccountClient, this.address, eSIMWalletAddress, eSIMUniqueIdentifier);
53
31
  }
54
-
55
- toggleAccessToETH (eSIMWalletAddress: Address, hasAccessToETH: boolean) {
32
+ toggleAccessToETH(eSIMWalletAddress, hasAccessToETH) {
56
33
  return _toggleAccessToETH(this.smartAccountClient, this.address, eSIMWalletAddress, hasAccessToETH);
57
34
  }
58
-
59
- getOwner () {
60
- return _getOwner (this.walletClient, this.address);
35
+ getOwner() {
36
+ return _getOwner(this.walletClient, this.address);
61
37
  }
62
38
  }
@@ -0,0 +1,18 @@
1
+ import { _createAccountWithEOA, _getAddress, _getCurrentDeviceWalletImplementation } from "../logic/deviceWalletFactory.js";
2
+ export class DeviceWalletFactorySubPackage {
3
+ smartAccountClient;
4
+ walletClient;
5
+ constructor(walletClient, smartAccountClient) {
6
+ this.smartAccountClient = smartAccountClient;
7
+ this.walletClient = walletClient;
8
+ }
9
+ createAccountWithEOA(deviceUniqueIdentifier, deviceWalletOwnerKey, salt, depositAmount) {
10
+ return _createAccountWithEOA(this.walletClient, deviceUniqueIdentifier, deviceWalletOwnerKey, salt, depositAmount);
11
+ }
12
+ getAddress(deviceUniqueIdentifier, deviceWalletOwnerKey, salt) {
13
+ return _getAddress(this.smartAccountClient, deviceUniqueIdentifier, deviceWalletOwnerKey, salt);
14
+ }
15
+ getCurrentDeviceWalletImplementation() {
16
+ return _getCurrentDeviceWalletImplementation(this.smartAccountClient);
17
+ }
18
+ }
@@ -0,0 +1,33 @@
1
+ import { _acceptOwnershipTransfer, _buyDataBundle, _owner, _populateHistory, _requestTransferOwnership, _sendETHToDeviceWallet, _setESIMUniqueIdentifier, _transferOwnership } from "../logic/eSIMWallet.js";
2
+ export class ESIMWalletSubPackage {
3
+ client;
4
+ address;
5
+ constructor(client, address) {
6
+ this.client = client;
7
+ this.address = address;
8
+ }
9
+ acceptOwnershipTransfer() {
10
+ return _acceptOwnershipTransfer(this.client, this.address);
11
+ }
12
+ buyDataBundle(dataBundleDetails) {
13
+ return _buyDataBundle(this.client, this.address, dataBundleDetails);
14
+ }
15
+ owner() {
16
+ return _owner(this.client, this.address);
17
+ }
18
+ populateHistory(dataBundleDetails) {
19
+ return _populateHistory(this.client, this.address, dataBundleDetails);
20
+ }
21
+ requestTransferOwnership(newOwner) {
22
+ return _requestTransferOwnership(this.client, this.address, newOwner);
23
+ }
24
+ sendETHToDeviceWallet(amount) {
25
+ return _sendETHToDeviceWallet(this.client, this.address, amount);
26
+ }
27
+ _setESIMUniqueIdentifier(eSIMUniqueIdentifier) {
28
+ return _setESIMUniqueIdentifier(this.client, this.address, eSIMUniqueIdentifier);
29
+ }
30
+ _transferOwnership(amount) {
31
+ return _transferOwnership(this.client, this.address, amount);
32
+ }
33
+ }
@@ -0,0 +1,21 @@
1
+ import { _addRegistryAddress, _deployESIMWalletWithEOA, _deployESIMWalletWithUserOp, _getCurrentESIMWalletImplementation } from "../logic/eSIMWalletFactory.js";
2
+ export class ESIMWalletFactorySubPackage {
3
+ smartAccountClient;
4
+ walletClient;
5
+ constructor(walletClient, smartAccountClient) {
6
+ this.smartAccountClient = smartAccountClient;
7
+ this.walletClient = walletClient;
8
+ }
9
+ deployESIMWalletWithEOA(deviceWalletAddress, salt) {
10
+ return _deployESIMWalletWithEOA(this.walletClient, deviceWalletAddress, salt);
11
+ }
12
+ deployESIMWalletWithUserOp(deviceWalletAddress, salt) {
13
+ return _deployESIMWalletWithUserOp(this.smartAccountClient, deviceWalletAddress, salt);
14
+ }
15
+ addRegistryAddress(registryContractAddress) {
16
+ return _addRegistryAddress(this.smartAccountClient, registryContractAddress);
17
+ }
18
+ _getCurrentESIMWalletImplementation() {
19
+ return _getCurrentESIMWalletImplementation(this.smartAccountClient);
20
+ }
21
+ }
@@ -0,0 +1,19 @@
1
+ import { _batchPopulateHistory, _deployLazyWalletAndSetESIMIdentifier, _isLazyWalletDeployed, _switchESIMIdentifierToNewDeviceIdentifier } from "../logic/lazyWalletRegistry.js";
2
+ export class LazyWalletRegistrySubPackage {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ _batchPopulateHistory(deviceUniqueIdentifiers, eSIMUniqueIdentifiers, dataBundleDetails) {
8
+ return _batchPopulateHistory(this.client, deviceUniqueIdentifiers, eSIMUniqueIdentifiers, dataBundleDetails);
9
+ }
10
+ _deployLazyWalletAndSetESIMIdentifier(deviceOwnerPublicKey, deviceUniqueIdentifier, salt, depositAmount) {
11
+ return _deployLazyWalletAndSetESIMIdentifier(this.client, deviceOwnerPublicKey, deviceUniqueIdentifier, salt, depositAmount);
12
+ }
13
+ _isLazyWalletDeployed(deviceUniqueIdentifier) {
14
+ return _isLazyWalletDeployed(this.client, deviceUniqueIdentifier);
15
+ }
16
+ _switchESIMIdentifierToNewDeviceIdentifier(eSIMIdentifier, oldDeviceIdentifier, newDeviceIdentifier) {
17
+ return _switchESIMIdentifierToNewDeviceIdentifier(this.client, eSIMIdentifier, oldDeviceIdentifier, newDeviceIdentifier);
18
+ }
19
+ }
@@ -1,18 +1,12 @@
1
- import { Address, WalletClient } from "viem";
2
1
  import { _getSmartWallet, _getSmartWalletClient } from "../logic/account-kit/createSmartAccount.js";
3
- import { P256Key, SignedRequest } from "../types";
4
- import { SmartAccountClient, SmartContractAccount } from "@aa-sdk/core";
5
-
6
2
  export class SmartAccountSubPackage {
7
-
8
3
  client;
9
4
  credentialId;
10
5
  rpId;
11
6
  organizationId;
12
7
  pimlicoAPIKey;
13
8
  gasPolicyId;
14
-
15
- constructor(client: WalletClient, credentialId: string, rpId: string, organiationId: string, pimlicoAPIKey: string, gasPolicyId: string) {
9
+ constructor(client, credentialId, rpId, organiationId, pimlicoAPIKey, gasPolicyId) {
16
10
  this.client = client;
17
11
  this.credentialId = credentialId;
18
12
  this.rpId = rpId;
@@ -20,12 +14,10 @@ export class SmartAccountSubPackage {
20
14
  this.pimlicoAPIKey = pimlicoAPIKey;
21
15
  this.gasPolicyId = gasPolicyId;
22
16
  }
23
-
24
- getSmartWallet (deviceUniqueIdentifier: string, deviceWalletOwnerKey: P256Key, salt: bigint) {
17
+ getSmartWallet(deviceUniqueIdentifier, deviceWalletOwnerKey, salt) {
25
18
  return _getSmartWallet(this.client, this.credentialId, this.rpId, this.organizationId, deviceUniqueIdentifier, deviceWalletOwnerKey, salt);
26
19
  }
27
-
28
- getSmartWalletClient (account: SmartContractAccount) {
20
+ getSmartWalletClient(account) {
29
21
  return _getSmartWalletClient(this.client, this.pimlicoAPIKey, this.gasPolicyId, account);
30
22
  }
31
23
  }
@@ -0,0 +1,13 @@
1
+ import { _add0x, _remove0x } from "../logic/utils.js";
2
+ export class UtilsSubPackage {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ add0x(data) {
8
+ _add0x(data);
9
+ }
10
+ remove0x(data) {
11
+ _remove0x(data);
12
+ }
13
+ }
@@ -1,27 +1,16 @@
1
- import { encodeFunctionData, WalletClient } from "viem";
2
- import { WebAuthnSignature } from "../types.js";
3
- import { SmartAccountClient } from "@aa-sdk/core";
1
+ import { encodeFunctionData } from "viem";
4
2
  import { _getChainSpecificConstants, customErrors } from "./constants.js";
5
3
  import { P256Verifier } from "../abis/index.js";
6
-
7
- export const _verifySignature = async (
8
- client: SmartAccountClient,
9
- message: string,
10
- requireMessageVerification: boolean,
11
- webAuthnSignature: WebAuthnSignature,
12
- x: bigint,
13
- y: bigint
14
- ) => {
15
-
4
+ export const _verifySignature = async (client, message, requireMessageVerification, webAuthnSignature, x, y) => {
16
5
  const chainID = await client.getChainId();
17
6
  const rpcURL = client.transport.url;
18
7
  const values = _getChainSpecificConstants(chainID, rpcURL);
19
- if(!client.account) throw new Error(customErrors.MISSING_SMART_WALLET)
20
-
8
+ if (!client.account)
9
+ throw new Error(customErrors.MISSING_SMART_WALLET);
21
10
  // UserOp
22
11
  return client.sendUserOperation({
23
12
  account: client.account,
24
- uo:{
13
+ uo: {
25
14
  target: values.factoryAddresses.P256VERIFIER,
26
15
  data: encodeFunctionData({
27
16
  abi: P256Verifier,
@@ -30,4 +19,4 @@ export const _verifySignature = async (
30
19
  })
31
20
  }
32
21
  });
33
- }
22
+ };