kokio-sdk 0.1.4 → 1.0.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.
Files changed (84) hide show
  1. package/README.md +185 -1
  2. package/dist/esm/admin/config-admin.js +85 -0
  3. package/dist/esm/admin/interface/deviceWalletClass.js +34 -0
  4. package/dist/esm/admin/interface/deviceWalletFactoryClass.js +57 -0
  5. package/dist/esm/admin/interface/eSIMWalletClass.js +31 -0
  6. package/dist/esm/admin/interface/eSIMWalletFactoryClass.js +22 -0
  7. package/dist/esm/admin/interface/lazyWalletRegistryClass.js +33 -0
  8. package/dist/esm/admin/interface/registryClass.js +43 -0
  9. package/dist/esm/config.js +4 -0
  10. package/dist/esm/interface/deviceWalletClass.js +1 -13
  11. package/dist/esm/interface/eSIMWalletClass.js +2 -8
  12. package/dist/esm/interface/eSIMWalletFactoryClass.js +2 -8
  13. package/dist/esm/interface/lazyWalletRegistryClass.js +2 -11
  14. package/dist/esm/logic/P256Verifier.js +8 -15
  15. package/dist/esm/logic/account-kit/createSmartAccount.js +76 -24
  16. package/dist/esm/logic/admin/deviceWallet.eoa.js +42 -0
  17. package/dist/esm/logic/admin/deviceWalletFactory.eoa.js +133 -0
  18. package/dist/esm/logic/admin/eSIMWallet.eoa.js +30 -0
  19. package/dist/esm/logic/admin/eSIMWalletFactory.eoa.js +43 -0
  20. package/dist/esm/logic/admin/lazyWalletRegistry.eoa.js +62 -0
  21. package/dist/esm/logic/admin/reads/deviceWallet.reads.js +45 -0
  22. package/dist/esm/logic/admin/reads/deviceWalletFactory.reads.js +87 -0
  23. package/dist/esm/logic/admin/reads/eSIMWallet.reads.js +44 -0
  24. package/dist/esm/logic/admin/reads/eSIMWalletFactory.reads.js +32 -0
  25. package/dist/esm/logic/admin/reads/lazyWalletRegistry.reads.js +62 -0
  26. package/dist/esm/logic/admin/reads/registry.reads.js +136 -0
  27. package/dist/esm/logic/admin/registry.eoa.js +23 -0
  28. package/dist/esm/logic/constants.js +31 -71
  29. package/dist/esm/logic/deviceWallet.js +28 -91
  30. package/dist/esm/logic/deviceWalletFactory.js +21 -30
  31. package/dist/esm/logic/eSIMWallet.js +25 -57
  32. package/dist/esm/logic/eSIMWalletFactory.js +17 -50
  33. package/dist/esm/logic/errors.js +118 -0
  34. package/dist/esm/logic/lazyWalletRegistry.js +12 -72
  35. package/dist/esm/logic/utils.js +3 -3
  36. package/dist/types/abis/BeaconProxy.d.ts +58 -2
  37. package/dist/types/abis/DeviceWallet.d.ts +702 -2
  38. package/dist/types/abis/DeviceWalletFactory.d.ts +634 -2
  39. package/dist/types/abis/ESIMWallet.d.ts +375 -2
  40. package/dist/types/abis/ESIMWalletFactory.d.ts +355 -2
  41. package/dist/types/abis/LazyWalletRegistry.d.ts +565 -2
  42. package/dist/types/abis/P256Verifier.d.ts +56 -2
  43. package/dist/types/abis/Registry.d.ts +623 -2
  44. package/dist/types/abis/RegistryHelper.d.ts +295 -2
  45. package/dist/types/admin/config-admin.d.ts +55 -0
  46. package/dist/types/admin/interface/deviceWalletClass.d.ts +17 -0
  47. package/dist/types/admin/interface/deviceWalletFactoryClass.d.ts +25 -0
  48. package/dist/types/admin/interface/eSIMWalletClass.d.ts +17 -0
  49. package/dist/types/admin/interface/eSIMWalletFactoryClass.d.ts +10 -0
  50. package/dist/types/admin/interface/lazyWalletRegistryClass.d.ts +14 -0
  51. package/dist/types/admin/interface/registryClass.d.ts +17 -0
  52. package/dist/types/config.d.ts +2 -0
  53. package/dist/types/interface/P256VerifierClass.d.ts +2 -1
  54. package/dist/types/interface/deviceWalletClass.d.ts +24 -28
  55. package/dist/types/interface/deviceWalletFactoryClass.d.ts +27 -26
  56. package/dist/types/interface/eSIMWalletClass.d.ts +2 -4
  57. package/dist/types/interface/eSIMWalletFactoryClass.d.ts +24 -26
  58. package/dist/types/interface/lazyWalletRegistryClass.d.ts +1 -6
  59. package/dist/types/interface/smartAccountClass.d.ts +23 -23
  60. package/dist/types/logic/P256Verifier.d.ts +2 -1
  61. package/dist/types/logic/account-kit/createSmartAccount.d.ts +38 -1
  62. package/dist/types/logic/admin/deviceWallet.eoa.d.ts +12 -0
  63. package/dist/types/logic/admin/deviceWalletFactory.eoa.d.ts +33 -0
  64. package/dist/types/logic/admin/eSIMWallet.eoa.d.ts +14 -0
  65. package/dist/types/logic/admin/eSIMWalletFactory.eoa.d.ts +13 -0
  66. package/dist/types/logic/admin/lazyWalletRegistry.eoa.d.ts +18 -0
  67. package/dist/types/logic/admin/reads/deviceWallet.reads.d.ts +16 -0
  68. package/dist/types/logic/admin/reads/deviceWalletFactory.reads.d.ts +26 -0
  69. package/dist/types/logic/admin/reads/eSIMWallet.reads.d.ts +15 -0
  70. package/dist/types/logic/admin/reads/eSIMWalletFactory.reads.d.ts +10 -0
  71. package/dist/types/logic/admin/reads/lazyWalletRegistry.reads.d.ts +20 -0
  72. package/dist/types/logic/admin/reads/registry.reads.d.ts +34 -0
  73. package/dist/types/logic/admin/registry.eoa.d.ts +7 -0
  74. package/dist/types/logic/deviceWallet.d.ts +1 -5
  75. package/dist/types/logic/deviceWalletFactory.d.ts +5 -4
  76. package/dist/types/logic/eSIMWallet.d.ts +1 -3
  77. package/dist/types/logic/eSIMWalletFactory.d.ts +2 -4
  78. package/dist/types/logic/errors.d.ts +63 -0
  79. package/dist/types/logic/lazyWalletRegistry.d.ts +1 -6
  80. package/dist/types/logic/utils.d.ts +8 -1
  81. package/dist/types/types.d.ts +1 -1
  82. package/package.json +12 -3
  83. package/dist/esm/interface/utilsClass.js +0 -13
  84. package/dist/types/interface/utilsClass.d.ts +0 -2567
@@ -0,0 +1,13 @@
1
+ import { Address, WalletClient } from "viem";
2
+ /**
3
+ * Admin-EOA logic for `ESIMWalletFactory`. Both functions are owner-gated
4
+ * (`addRegistryAddress` requires `msg.sender == owner()`, `updateESIMWalletImplementation`
5
+ * is `onlyOwner`), so the `client` must carry the `upgradeManager` EOA.
6
+ *
7
+ * Note: `ESIMWalletFactory.deployESIMWallet` is intentionally NOT exposed - it is
8
+ * `onlyRegistryOrDeviceWalletFactoryOrDeviceWallet`, so a bare EOA always reverts.
9
+ */
10
+ /** One-time wiring of the registry into the eSIM factory. Owner only. */
11
+ export declare const _addRegistryAddress: (client: WalletClient, registryContractAddress: Address) => Promise<`0x${string}`>;
12
+ /** Point the eSIM-wallet beacon at a new implementation. `onlyOwner`. */
13
+ export declare const _updateESIMWalletImplementation: (client: WalletClient, eSIMWalletImpl: Address) => Promise<`0x${string}`>;
@@ -0,0 +1,18 @@
1
+ import { WalletClient } from "viem";
2
+ import { DataBundleDetails, P256Key } from "../../types.js";
3
+ /**
4
+ * Admin-EOA logic for `LazyWalletRegistry`. All three functions are
5
+ * `onlyESIMWalletAdmin` on chain, so they can only succeed from the admin EOA -
6
+ * a device-wallet userOp (whose sender is the smart account) always reverts.
7
+ * This is why they belong on the EOA surface rather than the mobile userOp one.
8
+ */
9
+ /** Record fiat/lazy purchase history for a batch of devices. `onlyESIMWalletAdmin`. */
10
+ export declare const _batchPopulateHistory: (client: WalletClient, deviceUniqueIdentifiers: Array<string>, eSIMUniqueIdentifiers: Array<Array<string>>, dataBundleDetails: Array<Array<DataBundleDetails>>) => Promise<`0x${string}`>;
11
+ /**
12
+ * Materialise a lazily-provisioned device wallet and its eSIMs on chain.
13
+ * `onlyESIMWalletAdmin`, `payable`: the contract requires `depositAmount == msg.value`,
14
+ * so `value` is set to `depositAmount` here.
15
+ */
16
+ export declare const _deployLazyWalletAndSetESIMIdentifier: (client: WalletClient, deviceOwnerPublicKey: P256Key, deviceUniqueIdentifier: string, salt: bigint, depositAmount: bigint) => Promise<`0x${string}`>;
17
+ /** Re-point an eSIM identifier from an old device to a new one. `onlyESIMWalletAdmin`. */
18
+ export declare const _switchESIMIdentifierToNewDeviceIdentifier: (client: WalletClient, eSIMIdentifier: string, oldDeviceIdentifier: string, newDeviceIdentifier: string) => Promise<`0x${string}`>;
@@ -0,0 +1,16 @@
1
+ import { Address, WalletClient } from "viem";
2
+ /**
3
+ * Read-only admin logic targeting a specific `DeviceWallet` instance (its address
4
+ * is passed in). Surfaces the instance's public storage getters + `getVaultAddress`
5
+ * view for the backend. Each read extends the `WalletClient` with `publicActions`;
6
+ * no EOA account is required, and the target is the instance address (not a
7
+ * factory address, so no chain-constants lookup is needed).
8
+ */
9
+ /** The device's unique identifier string. */
10
+ export declare const _deviceUniqueIdentifier: (client: WalletClient, deviceWalletAddress: Address) => Promise<string>;
11
+ /** Whether an eSIM wallet is a valid child of this device wallet. */
12
+ export declare const _isValidESIMWallet: (client: WalletClient, deviceWalletAddress: Address, eSIMWallet: Address) => Promise<boolean>;
13
+ /** Whether an eSIM wallet is allowed to pull ETH from this device wallet. */
14
+ export declare const _canPullETH: (client: WalletClient, deviceWalletAddress: Address, eSIMWallet: Address) => Promise<boolean>;
15
+ /** The vault address this device wallet pays eSIM purchases to. */
16
+ export declare const _getVaultAddress: (client: WalletClient, deviceWalletAddress: Address) => Promise<Address>;
@@ -0,0 +1,26 @@
1
+ import { Address, WalletClient } from "viem";
2
+ import { P256Key } from "../../../types.js";
3
+ /**
4
+ * Read-only admin logic for `DeviceWalletFactory` - the contract's public
5
+ * storage getters and `view` functions, surfaced for the backend.
6
+ *
7
+ * A viem `WalletClient` carries no public actions, so each read extends it with
8
+ * `publicActions` (reusing the same transport, so it also works under an anvil
9
+ * fork) before calling `readContract`. Reads need no EOA account, so there is no
10
+ * `MissingEOAWalletError` guard.
11
+ */
12
+ /** The admin EOA (`eSIMWalletAdmin`) currently set on the factory. */
13
+ export declare const _eSIMWalletAdmin: (client: WalletClient) => Promise<Address>;
14
+ /** The vault EOA that receives eSIM payments. */
15
+ export declare const _vault: (client: WalletClient) => Promise<Address>;
16
+ /** The pending admin proposed via `requestAdminUpdate` (zero address if none). */
17
+ export declare const _newRequestedAdmin: (client: WalletClient) => Promise<Address>;
18
+ /** Whether a device wallet has been registered with the factory. */
19
+ export declare const _deviceWalletInfoAdded: (client: WalletClient, deviceWallet: Address) => Promise<boolean>;
20
+ /** The current device-wallet beacon implementation. */
21
+ export declare const _getCurrentDeviceWalletImplementation: (client: WalletClient) => Promise<Address>;
22
+ /**
23
+ * The counterfactual (CREATE2) device-wallet address for an owner key. On-chain
24
+ * arg order is `(ownerKey, uid, salt)` - note this differs from `createAccount`.
25
+ */
26
+ export declare const _getCounterFactualAddress: (client: WalletClient, deviceWalletOwnerKey: P256Key, deviceUniqueIdentifier: string, salt: bigint) => Promise<Address>;
@@ -0,0 +1,15 @@
1
+ import { Address, WalletClient } from "viem";
2
+ /**
3
+ * Read-only admin logic targeting a specific `ESIMWallet` instance (its address
4
+ * is passed in). Surfaces the instance's public storage getters + `owner` view
5
+ * for the backend. Each read extends the `WalletClient` with `publicActions`; no
6
+ * EOA account is required.
7
+ */
8
+ /** The `ESIMWalletFactory` that deployed this eSIM wallet. */
9
+ export declare const _eSIMWalletFactory: (client: WalletClient, eSIMWalletAddress: Address) => Promise<Address>;
10
+ /** The eSIM's unique identifier string (empty until set by the admin). */
11
+ export declare const _eSIMUniqueIdentifier: (client: WalletClient, eSIMWalletAddress: Address) => Promise<string>;
12
+ /** The pending owner proposed via `requestTransferOwnership` (zero if none). */
13
+ export declare const _newRequestedOwner: (client: WalletClient, eSIMWalletAddress: Address) => Promise<Address>;
14
+ /** The current owner (device wallet) of this eSIM wallet. */
15
+ export declare const _owner: (client: WalletClient, eSIMWalletAddress: Address) => Promise<Address>;
@@ -0,0 +1,10 @@
1
+ import { Address, WalletClient } from "viem";
2
+ /**
3
+ * Read-only admin logic for `ESIMWalletFactory` - its public storage getter and
4
+ * `view` function, surfaced for the backend. Each read extends the `WalletClient`
5
+ * with `publicActions` (no EOA account required).
6
+ */
7
+ /** Whether an eSIM wallet was deployed by this factory. */
8
+ export declare const _isESIMWalletDeployed: (client: WalletClient, eSIMWallet: Address) => Promise<boolean>;
9
+ /** The current eSIM-wallet beacon implementation. */
10
+ export declare const _getCurrentESIMWalletImplementation: (client: WalletClient) => Promise<Address>;
@@ -0,0 +1,20 @@
1
+ import { WalletClient } from "viem";
2
+ import { DataBundleDetails } from "../../../types.js";
3
+ /**
4
+ * Read-only admin logic for `LazyWalletRegistry` - its public storage getters,
5
+ * surfaced for the backend's fiat/lazy provisioning flows. Each read extends the
6
+ * `WalletClient` with `publicActions`; no EOA account is required.
7
+ *
8
+ * Note: `deviceIdentifierToESIMDetails` and
9
+ * `eSIMIdentifiersAssociatedWithDeviceIdentifier` back dynamic arrays on chain,
10
+ * so their auto-generated getters take an element `index` and return one entry -
11
+ * callers iterate indices to read the whole list (there is no full-array getter).
12
+ */
13
+ /** The upgrade-manager (owner) EOA of the lazy registry. */
14
+ export declare const _upgradeManager: (client: WalletClient) => Promise<`0x${string}`>;
15
+ /** The device identifier an eSIM identifier is currently associated with. */
16
+ export declare const _eSIMIdentifierToDeviceIdentifier: (client: WalletClient, eSIMIdentifier: string) => Promise<string>;
17
+ /** One data-bundle history entry for a (device, eSIM) pair, by array index. */
18
+ export declare const _deviceIdentifierToESIMDetails: (client: WalletClient, deviceIdentifier: string, eSIMIdentifier: string, index: bigint) => Promise<DataBundleDetails>;
19
+ /** One eSIM identifier associated with a device identifier, by array index. */
20
+ export declare const _eSIMIdentifiersAssociatedWithDeviceIdentifier: (client: WalletClient, deviceIdentifier: string, index: bigint) => Promise<string>;
@@ -0,0 +1,34 @@
1
+ import { Address, Hex, WalletClient } from "viem";
2
+ /**
3
+ * Read-only admin logic for `Registry` (which inherits `RegistryHelper`, so its
4
+ * ABI carries the helper mappings too). Surfaces the public storage getters for
5
+ * the backend. Each read extends the `WalletClient` with `publicActions`; no EOA
6
+ * account is required.
7
+ */
8
+ /** The admin EOA (`eSIMWalletAdmin`) recorded in the registry. */
9
+ export declare const _eSIMWalletAdmin: (client: WalletClient) => Promise<Address>;
10
+ /** The vault EOA recorded in the registry. */
11
+ export declare const _vault: (client: WalletClient) => Promise<Address>;
12
+ /** The upgrade-manager (owner) EOA recorded in the registry. */
13
+ export declare const _upgradeManager: (client: WalletClient) => Promise<Address>;
14
+ /** The `LazyWalletRegistry` address wired into the registry. */
15
+ export declare const _lazyWalletRegistry: (client: WalletClient) => Promise<Address>;
16
+ /** The device wallet registered for a device unique identifier (zero if none). */
17
+ export declare const _uniqueIdentifierToDeviceWallet: (client: WalletClient, deviceIdentifier: string) => Promise<Address>;
18
+ /**
19
+ * One of a device wallet's two P-256 owner keys. The on-chain getter for the
20
+ * `bytes32[2]` array takes the element index (`0` or `1`) and returns one key.
21
+ */
22
+ export declare const _deviceWalletToOwner: (client: WalletClient, deviceWallet: Address, index: bigint) => Promise<Hex>;
23
+ /** The device wallet registered for a hash of owner P-256 keys (zero if none). */
24
+ export declare const _registeredP256Keys: (client: WalletClient, hashOfOwnerP256Keys: Hex) => Promise<Address>;
25
+ /** Whether a device wallet is registered/valid. */
26
+ export declare const _isDeviceWalletValid: (client: WalletClient, deviceWallet: Address) => Promise<boolean>;
27
+ /**
28
+ * The device wallet that owns an eSIM wallet (zero address if the eSIM is not
29
+ * valid). On-chain this getter is named `isESIMWalletValid` but returns the
30
+ * associated device-wallet address, not a boolean.
31
+ */
32
+ export declare const _isESIMWalletValid: (client: WalletClient, eSIMWallet: Address) => Promise<Address>;
33
+ /** Whether an eSIM wallet is currently on standby. */
34
+ export declare const _isESIMWalletOnStandby: (client: WalletClient, eSIMWallet: Address) => Promise<boolean>;
@@ -0,0 +1,7 @@
1
+ import { Address, WalletClient } from "viem";
2
+ /**
3
+ * Admin-EOA logic for `Registry`. `addOrUpdateLazyWalletRegistryAddress` is
4
+ * `onlyOwner`, so the `client` must carry the `upgradeManager` EOA.
5
+ */
6
+ /** Wire (or rewire) the LazyWalletRegistry into the Registry. `onlyOwner`. */
7
+ export declare const _addOrUpdateLazyWalletRegistryAddress: (client: WalletClient, lazyWalletRegistry: Address) => Promise<`0x${string}`>;
@@ -1,12 +1,8 @@
1
1
  import { Address, WalletClient } from "viem";
2
2
  import { SmartAccountClient } from "@aa-sdk/core";
3
3
  import { P256Key } from "../types.js";
4
- export declare const _deployESIMWallet: (client: SmartAccountClient, address: Address, hasAccessToETH: boolean, salt: bigint) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
5
- export declare const _setESIMUniqueIdentifierForAnESIMWallet: (client: SmartAccountClient, address: Address, eSIMWalletAddress: Address, eSIMUniqueIdentifier: string) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
6
- export declare const _payETHForDataBundles: (client: SmartAccountClient, address: Address, amount: bigint) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
7
- export declare const _pullETH: (client: SmartAccountClient, address: Address, amount: bigint) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
8
- export declare const _getVaultAddress: (client: SmartAccountClient, address: Address) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
9
4
  export declare const _toggleAccessToETH: (client: SmartAccountClient, address: Address, eSIMWalletAddress: Address, hasAccessToETH: boolean) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
10
5
  export declare const _addESIMWallet: (client: SmartAccountClient, address: Address, eSIMWalletAddress: Address, hasAccessToETH: boolean) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
11
6
  export declare const _removeESIMWallet: (client: SmartAccountClient, address: Address, eSIMWalletAddress: Address, hasAccessToETH: boolean) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
7
+ export declare const _getVaultAddress: (client: SmartAccountClient, address: Address) => Promise<Address>;
12
8
  export declare const _getOwner: (client: WalletClient, address: Address) => Promise<P256Key>;
@@ -1,5 +1,6 @@
1
- import { WalletClient } from "viem";
1
+ import { Address, WalletClient } from "viem";
2
2
  import { SmartAccountClient } from "@aa-sdk/core";
3
- export declare const _createAccountWithEOA: (client: WalletClient, deviceUniqueIdentifier: string, deviceWalletOwnerKey: string, salt: bigint, depositAmount: bigint) => Promise<`0x${string}`>;
4
- export declare const _getAddress: (client: SmartAccountClient, deviceUniqueIdentifier: string, deviceWalletOwnerKey: string, salt: bigint) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
5
- export declare const _getCurrentDeviceWalletImplementation: (client: SmartAccountClient) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
3
+ import { P256Key } from "../types.js";
4
+ export declare const _createAccountWithEOA: (client: WalletClient, deviceUniqueIdentifier: string, deviceWalletOwnerKey: P256Key, salt: bigint, depositAmount: bigint) => Promise<`0x${string}`>;
5
+ export declare const _getAddress: (client: SmartAccountClient, deviceUniqueIdentifier: string, deviceWalletOwnerKey: P256Key, salt: bigint) => Promise<Address>;
6
+ export declare const _getCurrentDeviceWalletImplementation: (client: SmartAccountClient) => Promise<Address>;
@@ -3,9 +3,7 @@ import { DataBundleDetails } from "../types.js";
3
3
  import { SmartAccountClient } from "@aa-sdk/core";
4
4
  export declare const _setESIMUniqueIdentifier: (client: SmartAccountClient, address: Address, eSIMUniqueIdentifier: string) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
5
5
  export declare const _buyDataBundle: (client: SmartAccountClient, address: Address, dataBundleDetails: DataBundleDetails) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
6
- export declare const _populateHistory: (client: SmartAccountClient, address: Address, dataBundleDetails: Array<DataBundleDetails>) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
7
- export declare const _owner: (client: SmartAccountClient, address: Address) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
6
+ export declare const _owner: (client: SmartAccountClient, address: Address) => Promise<Address>;
8
7
  export declare const _requestTransferOwnership: (client: SmartAccountClient, address: Address, newOwner: Address) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
9
8
  export declare const _acceptOwnershipTransfer: (client: SmartAccountClient, address: Address) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
10
9
  export declare const _sendETHToDeviceWallet: (client: SmartAccountClient, address: Address, amount: bigint) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
11
- export declare const _transferOwnership: (client: SmartAccountClient, address: Address, amount: bigint) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
@@ -1,6 +1,4 @@
1
- import { Address, WalletClient } from "viem";
1
+ import { Address } from "viem";
2
2
  import { SmartAccountClient } from "@aa-sdk/core";
3
- export declare const _addRegistryAddress: (client: SmartAccountClient, registryContractAddress: Address) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
4
- export declare const _deployESIMWalletWithEOA: (client: WalletClient, deviceWalletAddress: Address, salt: bigint) => Promise<`0x${string}`>;
5
3
  export declare const _deployESIMWalletWithUserOp: (client: SmartAccountClient, deviceWalletAddress: Address, salt: bigint) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
6
- export declare const _getCurrentESIMWalletImplementation: (client: SmartAccountClient) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
4
+ export declare const _getCurrentESIMWalletImplementation: (client: SmartAccountClient) => Promise<Address>;
@@ -0,0 +1,63 @@
1
+ import { Hex } from "viem";
2
+ /**
3
+ * Base class for every error the Kokio SDK throws deliberately. Consumers can
4
+ * `instanceof KokioError` to distinguish SDK-originated failures from viem /
5
+ * bundler / network errors, and switch on `code` for programmatic handling.
6
+ */
7
+ export declare class KokioError extends Error {
8
+ readonly code: string;
9
+ constructor(code: string, message: string);
10
+ }
11
+ /** A required value was null, undefined, or empty. */
12
+ export declare class NullOrUndefinedValueError extends KokioError {
13
+ constructor(message?: string);
14
+ }
15
+ /** The client has no smart-wallet (ERC-4337) account associated. */
16
+ export declare class MissingSmartWalletError extends KokioError {
17
+ constructor(message?: string);
18
+ }
19
+ /** The client has no EOA account associated. */
20
+ export declare class MissingEOAWalletError extends KokioError {
21
+ constructor(message?: string);
22
+ }
23
+ /** No client/signer instance was supplied where one was required. */
24
+ export declare class InvalidClientError extends KokioError {
25
+ constructor(message?: string);
26
+ }
27
+ /** The requested chain id is not known to the SDK at all. */
28
+ export declare class UnsupportedChainError extends KokioError {
29
+ constructor(chainID: number);
30
+ }
31
+ /** The chain is known but its factory address book is still '0x' placeholders. */
32
+ export declare class UnconfiguredChainError extends KokioError {
33
+ constructor(chainID: number);
34
+ }
35
+ /**
36
+ * The off-chain counterfactual address diverged from the factory's on-chain
37
+ * `getCounterFactualAddress` view - a signal that the pinned BeaconProxy
38
+ * bytecode or CREATE2 encoding has drifted from the deployed contracts.
39
+ */
40
+ export declare class CounterfactualMismatchError extends KokioError {
41
+ readonly offChain: Hex;
42
+ readonly onChain: Hex;
43
+ constructor(offChain: Hex, onChain: Hex);
44
+ }
45
+ export interface DecodedRevert {
46
+ errorName: string;
47
+ args: readonly unknown[];
48
+ }
49
+ /**
50
+ * Best-effort decode of raw revert data (the ABI-encoded `Error(string)`,
51
+ * `Panic(uint256)`, or a contract custom error) against the known Kokio ABIs.
52
+ * Returns `null` when the selector matches none of them.
53
+ */
54
+ export declare const decodeContractRevert: (data: Hex) => DecodedRevert | null;
55
+ /**
56
+ * A decoded on-chain revert. Carries the raw revert data plus, when the
57
+ * selector was recognised, the decoded custom-error name and args.
58
+ */
59
+ export declare class ContractRevertError extends KokioError {
60
+ readonly data: Hex;
61
+ readonly decoded: DecodedRevert | null;
62
+ constructor(data: Hex);
63
+ }
@@ -1,7 +1,2 @@
1
- import { Hex } from "viem";
2
- import { DataBundleDetails } from "../types.js";
3
1
  import { SmartAccountClient } from "@aa-sdk/core";
4
- export declare const _isLazyWalletDeployed: (client: SmartAccountClient, deviceUniqueIdentifier: string) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
5
- export declare const _batchPopulateHistory: (client: SmartAccountClient, deviceUniqueIdentifiers: Array<string>, eSIMUniqueIdentifiers: Array<Array<string>>, dataBundleDetails: Array<Array<DataBundleDetails>>) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
6
- export declare const _deployLazyWalletAndSetESIMIdentifier: (client: SmartAccountClient, deviceOwnerPublicKey: Hex[2], deviceUniqueIdentifier: string, salt: bigint, depositAmount: bigint) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
7
- export declare const _switchESIMIdentifierToNewDeviceIdentifier: (client: SmartAccountClient, eSIMIdentifier: string, oldDeviceIdentifier: string, newDeviceIdentifier: string) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
2
+ export declare const _isLazyWalletDeployed: (client: SmartAccountClient, deviceUniqueIdentifier: string) => Promise<boolean>;
@@ -4,7 +4,14 @@ export declare const _remove0x: (data: Hex | string) => string;
4
4
  export declare function _shouldRemoveLeadingZero(bytes: Uint8Array): boolean;
5
5
  export declare function _concatUint8Arrays(arrays: Uint8Array[]): Uint8Array;
6
6
  export declare function base64UrlToBuffer(base64url: string): Buffer;
7
- export declare function decodeClientDataJSON(base64url: string): any;
7
+ export interface ClientDataJSON {
8
+ type: string;
9
+ challenge: string;
10
+ origin: string;
11
+ crossOrigin?: boolean;
12
+ [key: string]: unknown;
13
+ }
14
+ export declare function decodeClientDataJSON(base64url: string): ClientDataJSON;
8
15
  export declare function hexToArrayBuffer(hexString: string): ArrayBuffer;
9
16
  export declare function parseDEREncodedSignature(signature: Uint8Array): {
10
17
  r: string;
@@ -23,7 +23,7 @@ export type P256Credential = {
23
23
  };
24
24
  };
25
25
  export type DataBundleDetails = {
26
- dataBundleId: string;
26
+ dataBundleID: string;
27
27
  dataBundlePrice: bigint;
28
28
  };
29
29
  export type SignedRequest = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kokio-sdk",
3
- "version": "0.1.4",
3
+ "version": "1.0.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/config.js",
@@ -13,6 +13,11 @@
13
13
  "import": "./dist/esm/config.js",
14
14
  "default": "./dist/esm/config.js"
15
15
  },
16
+ "./admin": {
17
+ "types": "./dist/types/admin/config-admin.d.ts",
18
+ "import": "./dist/esm/admin/config-admin.js",
19
+ "default": "./dist/esm/admin/config-admin.js"
20
+ },
16
21
  "./types": {
17
22
  "types": "./dist/types/types-export.d.ts",
18
23
  "import": "./dist/esm/types.js"
@@ -27,7 +32,10 @@
27
32
  "scripts": {
28
33
  "build": "tsc",
29
34
  "prepack": "npm run build",
30
- "test": "echo \"Error: no test specified\" && exit 1"
35
+ "test": "vitest run",
36
+ "test:watch": "vitest",
37
+ "test:integration": "INTEGRATION=1 vitest run",
38
+ "test:integration:fork": "INTEGRATION=1 vitest run tests/integration --no-file-parallelism"
31
39
  },
32
40
  "repository": {
33
41
  "type": "git",
@@ -41,7 +49,8 @@
41
49
  "homepage": "https://github.com/Blockchain-Powered-eSIM/kokio-sdk#readme",
42
50
  "devDependencies": {
43
51
  "dotenv": "^16.5.0",
44
- "typescript": "^5.7.3"
52
+ "typescript": "^5.7.3",
53
+ "vitest": "4.1.10"
45
54
  },
46
55
  "dependencies": {
47
56
  "@aa-sdk/core": "4.88.4",
@@ -1,13 +0,0 @@
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
- }