kokio-sdk 1.0.0 → 2.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 (107) hide show
  1. package/README.md +68 -19
  2. package/dist/esm/abis/BeaconProxy.js +30 -46
  3. package/dist/esm/abis/DeviceWallet.js +546 -535
  4. package/dist/esm/abis/DeviceWalletFactory.js +537 -544
  5. package/dist/esm/abis/ESIMWallet.js +440 -299
  6. package/dist/esm/abis/ESIMWalletFactory.js +372 -289
  7. package/dist/esm/abis/LazyWalletRegistry.js +941 -421
  8. package/dist/esm/abis/P256Verifier.js +29 -29
  9. package/dist/esm/abis/ProtocolAdmin.js +1228 -0
  10. package/dist/esm/abis/Registry.js +1207 -466
  11. package/dist/esm/abis/RegistryHelper.js +414 -20
  12. package/dist/esm/abis/index.js +2 -1
  13. package/dist/esm/admin/config-admin.js +24 -0
  14. package/dist/esm/admin/interface/deviceWalletClass.js +27 -6
  15. package/dist/esm/admin/interface/deviceWalletFactoryClass.js +41 -19
  16. package/dist/esm/admin/interface/eSIMWalletClass.js +10 -1
  17. package/dist/esm/admin/interface/eSIMWalletFactoryClass.js +24 -2
  18. package/dist/esm/admin/interface/lazyWalletRegistryClass.js +83 -4
  19. package/dist/esm/admin/interface/protocolAdminClass.js +195 -0
  20. package/dist/esm/admin/interface/registryClass.js +93 -2
  21. package/dist/esm/config.js +42 -7
  22. package/dist/esm/interface/deviceWalletClass.js +45 -5
  23. package/dist/esm/interface/deviceWalletFactoryClass.js +20 -1
  24. package/dist/esm/interface/eSIMWalletClass.js +12 -3
  25. package/dist/esm/interface/registryClass.js +47 -0
  26. package/dist/esm/interface/smartAccountClass.js +2 -4
  27. package/dist/esm/logic/account-kit/createSmartAccount.js +156 -102
  28. package/dist/esm/logic/admin/deviceWallet.eoa.js +23 -12
  29. package/dist/esm/logic/admin/deviceWalletFactory.eoa.js +63 -42
  30. package/dist/esm/logic/admin/eSIMWallet.eoa.js +3 -5
  31. package/dist/esm/logic/admin/eSIMWalletFactory.eoa.js +76 -8
  32. package/dist/esm/logic/admin/lazyWalletRegistry.eoa.js +330 -19
  33. package/dist/esm/logic/admin/protocolAdmin.eoa.js +524 -0
  34. package/dist/esm/logic/admin/reads/deviceWallet.reads.js +82 -7
  35. package/dist/esm/logic/admin/reads/deviceWalletFactory.reads.js +82 -23
  36. package/dist/esm/logic/admin/reads/eSIMWallet.reads.js +50 -6
  37. package/dist/esm/logic/admin/reads/eSIMWalletFactory.reads.js +63 -5
  38. package/dist/esm/logic/admin/reads/lazyWalletRegistry.reads.js +171 -10
  39. package/dist/esm/logic/admin/reads/protocolAdmin.reads.js +154 -0
  40. package/dist/esm/logic/admin/reads/registry.reads.js +289 -9
  41. package/dist/esm/logic/admin/registry.eoa.js +274 -4
  42. package/dist/esm/logic/constants.js +53 -26
  43. package/dist/esm/logic/deviceWallet.js +224 -31
  44. package/dist/esm/logic/deviceWalletFactory.js +89 -0
  45. package/dist/esm/logic/eSIMWallet.js +113 -43
  46. package/dist/esm/logic/eSIMWalletFactory.js +8 -8
  47. package/dist/esm/logic/errors.js +64 -0
  48. package/dist/esm/logic/registry.js +236 -0
  49. package/dist/esm/logic/utils.js +2 -1
  50. package/dist/types/abis/BeaconProxy.d.ts +21 -33
  51. package/dist/types/abis/DeviceWallet.d.ts +372 -365
  52. package/dist/types/abis/DeviceWalletFactory.d.ts +438 -448
  53. package/dist/types/abis/ESIMWallet.d.ts +352 -245
  54. package/dist/types/abis/ESIMWalletFactory.d.ts +278 -216
  55. package/dist/types/abis/LazyWalletRegistry.d.ts +710 -317
  56. package/dist/types/abis/P256Verifier.d.ts +16 -16
  57. package/dist/types/abis/ProtocolAdmin.d.ts +947 -0
  58. package/dist/types/abis/Registry.d.ts +960 -393
  59. package/dist/types/abis/RegistryHelper.d.ts +317 -16
  60. package/dist/types/abis/index.d.ts +2 -1
  61. package/dist/types/admin/config-admin.d.ts +16 -0
  62. package/dist/types/admin/interface/deviceWalletClass.d.ts +10 -3
  63. package/dist/types/admin/interface/deviceWalletFactoryClass.d.ts +14 -7
  64. package/dist/types/admin/interface/eSIMWalletClass.d.ts +3 -0
  65. package/dist/types/admin/interface/eSIMWalletFactoryClass.d.ts +8 -1
  66. package/dist/types/admin/interface/lazyWalletRegistryClass.d.ts +38 -2
  67. package/dist/types/admin/interface/protocolAdminClass.d.ts +95 -0
  68. package/dist/types/admin/interface/registryClass.d.ts +30 -0
  69. package/dist/types/config.d.ts +26 -5
  70. package/dist/types/interface/P256VerifierClass.d.ts +3 -4
  71. package/dist/types/interface/constantsClass.d.ts +2 -2
  72. package/dist/types/interface/deviceWalletClass.d.ts +22 -2569
  73. package/dist/types/interface/deviceWalletFactoryClass.d.ts +10 -2564
  74. package/dist/types/interface/eSIMWalletClass.d.ts +11 -8
  75. package/dist/types/interface/eSIMWalletFactoryClass.d.ts +5 -2565
  76. package/dist/types/interface/registryClass.d.ts +19 -0
  77. package/dist/types/interface/smartAccountClass.d.ts +6 -2568
  78. package/dist/types/logic/P256Verifier.d.ts +2 -2
  79. package/dist/types/logic/account-kit/createSmartAccount.d.ts +43 -19
  80. package/dist/types/logic/admin/deviceWallet.eoa.d.ts +15 -9
  81. package/dist/types/logic/admin/deviceWalletFactory.eoa.d.ts +34 -23
  82. package/dist/types/logic/admin/eSIMWallet.eoa.d.ts +0 -5
  83. package/dist/types/logic/admin/eSIMWalletFactory.eoa.d.ts +27 -9
  84. package/dist/types/logic/admin/lazyWalletRegistry.eoa.d.ts +102 -10
  85. package/dist/types/logic/admin/protocolAdmin.eoa.d.ts +163 -0
  86. package/dist/types/logic/admin/reads/deviceWallet.reads.d.ts +28 -8
  87. package/dist/types/logic/admin/reads/deviceWalletFactory.reads.d.ts +45 -14
  88. package/dist/types/logic/admin/reads/eSIMWallet.reads.d.ts +25 -6
  89. package/dist/types/logic/admin/reads/eSIMWalletFactory.reads.d.ts +21 -6
  90. package/dist/types/logic/admin/reads/lazyWalletRegistry.reads.d.ts +44 -11
  91. package/dist/types/logic/admin/reads/protocolAdmin.reads.d.ts +53 -0
  92. package/dist/types/logic/admin/reads/registry.reads.d.ts +105 -9
  93. package/dist/types/logic/admin/registry.eoa.d.ts +102 -5
  94. package/dist/types/logic/constants.d.ts +2 -0
  95. package/dist/types/logic/deviceWallet.d.ts +78 -6
  96. package/dist/types/logic/deviceWalletFactory.d.ts +32 -3
  97. package/dist/types/logic/eSIMWallet.d.ts +48 -7
  98. package/dist/types/logic/eSIMWalletFactory.d.ts +3 -3
  99. package/dist/types/logic/errors.d.ts +45 -0
  100. package/dist/types/logic/registry.d.ts +78 -0
  101. package/dist/types/types-export.d.ts +1 -1
  102. package/dist/types/types.d.ts +111 -1
  103. package/package.json +11 -13
  104. package/dist/esm/interface/lazyWalletRegistryClass.js +0 -10
  105. package/dist/esm/logic/lazyWalletRegistry.js +0 -19
  106. package/dist/types/interface/lazyWalletRegistryClass.d.ts +0 -6
  107. package/dist/types/logic/lazyWalletRegistry.d.ts +0 -2
@@ -1,6 +1,35 @@
1
1
  import { Address, WalletClient } from "viem";
2
- import { SmartAccountClient } from "@aa-sdk/core";
2
+ import { KokioSmartAccountClient } from "../types.js";
3
3
  import { P256Key } from "../types.js";
4
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>;
5
+ export declare const _getAddress: (client: KokioSmartAccountClient, deviceUniqueIdentifier: string, deviceWalletOwnerKey: P256Key, salt: bigint) => Promise<Address>;
6
+ export declare const _getCurrentDeviceWalletImplementation: (client: KokioSmartAccountClient) => Promise<Address>;
7
+ /**
8
+ * Check an identifier and owner key before deploying. Answers the zero address
9
+ * when both are free, or the wallet already holding one of them.
10
+ *
11
+ * Call this first. `createAccount` runs inside EntryPoint validation, where the
12
+ * 4337 rules bar it from reading the registry, so it cannot see that an
13
+ * identifier or a key is taken: it deploys a second wallet at a fresh address
14
+ * and the `postCreateAccount` that would register it fails afterwards.
15
+ *
16
+ * Reverts on an empty identifier or a key that is not a point on the P256 curve.
17
+ */
18
+ export declare const _preCreateAccountValidation: (client: KokioSmartAccountClient, deviceUniqueIdentifier: string, deviceWalletOwnerKey: P256Key) => Promise<Address>;
19
+ /**
20
+ * Whether the factory has recorded this wallet. Set by `postCreateAccount`, not
21
+ * by the deploy, so a wallet the app just created reads false until the backend
22
+ * registers it.
23
+ */
24
+ export declare const _deviceWalletInfoAdded: (client: KokioSmartAccountClient, deviceWallet: Address) => Promise<boolean>;
25
+ /**
26
+ * The beacon every device wallet reads its implementation from. One update moves
27
+ * all of them and no wallet can decline it.
28
+ */
29
+ export declare const _beacon: (client: KokioSmartAccountClient) => Promise<Address>;
30
+ /** The registry the factory writes new wallets into. */
31
+ export declare const _registry: (client: KokioSmartAccountClient) => Promise<Address>;
32
+ /** The EntryPoint baked into every device wallet this factory deploys. */
33
+ export declare const _entryPoint: (client: KokioSmartAccountClient) => Promise<Address>;
34
+ /** The contract new device wallets verify WebAuthn assertions through. */
35
+ export declare const _verifier: (client: KokioSmartAccountClient) => Promise<Address>;
@@ -1,9 +1,50 @@
1
1
  import { Address } from "viem";
2
2
  import { DataBundleDetails } from "../types.js";
3
- import { SmartAccountClient } from "@aa-sdk/core";
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
- 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 _owner: (client: SmartAccountClient, address: Address) => Promise<Address>;
7
- export declare const _requestTransferOwnership: (client: SmartAccountClient, address: Address, newOwner: Address) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
8
- export declare const _acceptOwnershipTransfer: (client: SmartAccountClient, address: Address) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
9
- export declare const _sendETHToDeviceWallet: (client: SmartAccountClient, address: Address, amount: bigint) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
3
+ import { KokioSmartAccountClient } from "../types.js";
4
+ /**
5
+ * Cap what this eSIM wallet may be charged for one data bundle. Zero hands it
6
+ * back to the registry's ceiling.
7
+ *
8
+ * `onlyDeviceWallet`, so it needs the user's own signature. That is the point:
9
+ * the admin names the price on `buyDataBundle`, so it must not be able to raise
10
+ * the ceiling on that price too. A handover clears the cap, and the new owner has
11
+ * to set it again.
12
+ */
13
+ export declare const _setDataBundlePriceCap: (client: KokioSmartAccountClient, address: Address, cap: bigint) => Promise<`0x${string}`>;
14
+ export declare const _buyDataBundle: (client: KokioSmartAccountClient, address: Address, dataBundleDetails: DataBundleDetails) => Promise<`0x${string}`>;
15
+ export declare const _owner: (client: KokioSmartAccountClient, address: Address) => Promise<Address>;
16
+ /**
17
+ * The ceiling that actually applies to this wallet's next purchase, in wei.
18
+ * Read it before naming a price on `buyDataBundle`, since a price above the
19
+ * ceiling reverts.
20
+ *
21
+ * Resolved the way the contract resolves it. The wallet's own cap wins when it
22
+ * has one. Zero there means "follow the registry", which is where a fresh wallet
23
+ * and a newly handed-over wallet both start. A zero on both means no ceiling at
24
+ * all, so this returns `maxUint256` rather than a zero that reads as "you may
25
+ * not spend anything".
26
+ *
27
+ * That last case cannot happen on a live deployment: the registry refuses a zero
28
+ * cap in both `initialize` and `setDefaultDataBundlePriceCap`. It is handled
29
+ * because the contract's own check treats zero as unlimited, not because the
30
+ * state is reachable.
31
+ */
32
+ export declare const _dataBundlePriceCap: (client: KokioSmartAccountClient, address: Address) => Promise<bigint>;
33
+ /**
34
+ * The device wallet this eSIM wallet belongs to. Tracks `owner`, but it is its
35
+ * own storage slot with its own getter, so read whichever one you mean.
36
+ */
37
+ export declare const _deviceWallet: (client: KokioSmartAccountClient, address: Address) => Promise<Address>;
38
+ /**
39
+ * One data bundle purchase, by position. Holds every purchase this wallet has
40
+ * made, and for a wallet that came off the fiat path it also holds the
41
+ * pre-deployment purchases the lazy registry copies in.
42
+ *
43
+ * There is no length getter on the contract. Read upwards from zero until a call
44
+ * reverts, or track the count from the `DataBundleBought` and
45
+ * `TransactionHistoryPopulated` events.
46
+ */
47
+ export declare const _transactionHistory: (client: KokioSmartAccountClient, address: Address, index: bigint) => Promise<DataBundleDetails>;
48
+ export declare const _requestTransferOwnership: (client: KokioSmartAccountClient, address: Address, newOwner: Address) => Promise<`0x${string}`>;
49
+ export declare const _acceptOwnershipTransfer: (client: KokioSmartAccountClient, address: Address) => Promise<`0x${string}`>;
50
+ export declare const _sendETHToDeviceWallet: (client: KokioSmartAccountClient, address: Address, amount: bigint) => Promise<`0x${string}`>;
@@ -1,4 +1,4 @@
1
1
  import { Address } from "viem";
2
- import { SmartAccountClient } from "@aa-sdk/core";
3
- export declare const _deployESIMWalletWithUserOp: (client: SmartAccountClient, deviceWalletAddress: Address, salt: bigint) => Promise<import("@aa-sdk/core").SendUserOperationResult<keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>;
4
- export declare const _getCurrentESIMWalletImplementation: (client: SmartAccountClient) => Promise<Address>;
2
+ import { KokioSmartAccountClient } from "../types.js";
3
+ export declare const _deployESIMWalletWithUserOp: (client: KokioSmartAccountClient, deviceWalletAddress: Address, salt: bigint) => Promise<`0x${string}`>;
4
+ export declare const _getCurrentESIMWalletImplementation: (client: KokioSmartAccountClient) => Promise<Address>;
@@ -42,6 +42,51 @@ export declare class CounterfactualMismatchError extends KokioError {
42
42
  readonly onChain: Hex;
43
43
  constructor(offChain: Hex, onChain: Hex);
44
44
  }
45
+ /**
46
+ * A batch size outside what the contract accepts. Both paginated calls refuse a
47
+ * request above their cap rather than clamping it, so this is caught locally to
48
+ * save the caller a reverted transaction.
49
+ */
50
+ export declare class BatchSizeOutOfRangeError extends KokioError {
51
+ readonly requested: bigint;
52
+ readonly max: bigint;
53
+ constructor(what: string, requested: bigint, max: bigint);
54
+ }
55
+ /**
56
+ * A deposit was passed to a lazy deployment that turned out to be a resume. Only
57
+ * the first batch is payable and it already took the deposit, so carrying on
58
+ * would fund the device with less than the caller asked for.
59
+ */
60
+ export declare class DepositOnResumeError extends KokioError {
61
+ readonly deviceUniqueIdentifier: string;
62
+ readonly depositAmount: bigint;
63
+ constructor(deviceUniqueIdentifier: string, depositAmount: bigint);
64
+ }
65
+ /**
66
+ * History was aimed at an eSIM this registry never deployed a wallet for. That
67
+ * lookup is the whole authorisation on chain, so it cannot be worked around.
68
+ */
69
+ export declare class ESIMWalletNotLazyDeployedError extends KokioError {
70
+ readonly eSIMIdentifier: string;
71
+ constructor(eSIMIdentifier: string);
72
+ }
73
+ /**
74
+ * A batch landed but its receipt carried no event from the lazy registry. The
75
+ * loop reads its position from that event, so it cannot continue without one.
76
+ */
77
+ export declare class MissingBatchEventError extends KokioError {
78
+ readonly hash: Hex;
79
+ constructor(eventName: string, hash: Hex);
80
+ }
81
+ /**
82
+ * A batch reported work outstanding but did none of it. Nothing on chain should
83
+ * produce this; it stops the loop rather than letting it spin.
84
+ */
85
+ export declare class StalledBatchError extends KokioError {
86
+ readonly hash: Hex;
87
+ readonly remaining: bigint;
88
+ constructor(hash: Hex, remaining: bigint);
89
+ }
45
90
  export interface DecodedRevert {
46
91
  errorName: string;
47
92
  args: readonly unknown[];
@@ -0,0 +1,78 @@
1
+ import { Address } from "viem";
2
+ import { KokioSmartAccountClient } from "../types.js";
3
+ /**
4
+ * Take on an eSIM wallet and clear any standby flag left by a transfer.
5
+ *
6
+ * The registry only accepts the calling device wallet as the new holder, so the
7
+ * SDK fills that in and there is nothing to pass. The eSIM wallet's `owner()`
8
+ * has to already be this device wallet: accept the ownership transfer first,
9
+ * then bind.
10
+ *
11
+ * Reverts while a transfer is still pending on the eSIM wallet, and for any
12
+ * address the eSIM wallet factory did not deploy.
13
+ */
14
+ export declare const _bindESIMWallet: (client: KokioSmartAccountClient, eSIMWalletAddress: Address) => Promise<`0x${string}`>;
15
+ /**
16
+ * Flag an eSIM wallet as mid-transfer, or clear the flag when the move settles or
17
+ * is called off.
18
+ *
19
+ * Only the flag moves. The registry keeps naming this device wallet as the eSIM
20
+ * wallet's holder either way, so raising standby on a wallet still held here is
21
+ * the ordinary case rather than a contradiction.
22
+ */
23
+ export declare const _toggleESIMWalletStandbyStatus: (client: KokioSmartAccountClient, eSIMWalletAddress: Address, isOnStandby: boolean) => Promise<`0x${string}`>;
24
+ /**
25
+ * True once the device has a wallet on chain. Note this is not the same question
26
+ * as `LazyWalletRegistry.isDeviceIdentifierReserved`, which only says whether
27
+ * history has been recorded for the device, and is true well before anything is
28
+ * deployed.
29
+ */
30
+ export declare const _isDeviceIdentifierAlreadyUsed: (client: KokioSmartAccountClient, deviceUniqueIdentifier: string) => Promise<boolean>;
31
+ /**
32
+ * Whether the protocol is paused. While true, every ETH-moving path on the device
33
+ * wallets and eSIM wallets reverts, so check this before offering a purchase.
34
+ */
35
+ export declare const _paused: (client: KokioSmartAccountClient) => Promise<boolean>;
36
+ /**
37
+ * The same pause check the wallets themselves run, which throws rather than
38
+ * returning false. Use `_paused` to branch on it; use this when you want the
39
+ * failure to carry the protocol's own revert reason.
40
+ */
41
+ export declare const _requireNotPaused: (client: KokioSmartAccountClient) => Promise<void>;
42
+ /**
43
+ * The device wallet holding an eSIM wallet, zero if it was never registered.
44
+ * Despite the name this returns an address, not a boolean, and it keeps naming
45
+ * the last holder after a release, so a non-zero answer is not proof anyone
46
+ * holds it now. Ask `deviceWallet.isValidESIMWallet` for that.
47
+ */
48
+ export declare const _isESIMWalletValid: (client: KokioSmartAccountClient, eSIMWalletAddress: Address) => Promise<Address>;
49
+ /**
50
+ * Whether a transfer is outstanding on an eSIM wallet. `bindESIMWallet` clears
51
+ * it once the new device wallet takes the eSIM wallet on.
52
+ *
53
+ * Independent of `isESIMWalletValid`, and neither implies the other. A `true`
54
+ * here is not a claim the wallet left the protocol, and it is normal for the
55
+ * association to still name the device wallet that raised the flag.
56
+ */
57
+ export declare const _isESIMWalletOnStandby: (client: KokioSmartAccountClient, eSIMWalletAddress: Address) => Promise<boolean>;
58
+ /** Whether a device wallet is registered with the protocol. */
59
+ export declare const _isDeviceWalletValid: (client: KokioSmartAccountClient, deviceWalletAddress: Address) => Promise<boolean>;
60
+ /** The device wallet registered for a device identifier, zero if none. */
61
+ export declare const _uniqueIdentifierToDeviceWallet: (client: KokioSmartAccountClient, deviceUniqueIdentifier: string) => Promise<Address>;
62
+ /** Whether an eSIM identifier is already held by a wallet. */
63
+ export declare const _isESIMIdentifierClaimed: (client: KokioSmartAccountClient, eSIMUniqueIdentifier: string) => Promise<boolean>;
64
+ /**
65
+ * The one eSIM wallet holding an eSIM identifier, zero if nobody holds it. Set
66
+ * once and never cleared, an ownership transfer included, because the eSIM
67
+ * belongs to the wallet rather than to whichever device is holding it.
68
+ */
69
+ export declare const _eSIMWalletForIdentifier: (client: KokioSmartAccountClient, eSIMUniqueIdentifier: string) => Promise<Address>;
70
+ /** The fallback price ceiling in wei for a wallet holding no cap of its own. */
71
+ export declare const _defaultDataBundlePriceCap: (client: KokioSmartAccountClient) => Promise<bigint>;
72
+ /**
73
+ * Throws if a fiat user's eSIMs are already waiting on this device identifier.
74
+ * Worth calling before a deployment: taking a reserved identifier strands the
75
+ * lazy user, since the history copy, the wallet deployment and the device switch
76
+ * all then refuse it.
77
+ */
78
+ export declare const _requireDeviceIdentifierNotReserved: (client: KokioSmartAccountClient, deviceUniqueIdentifier: string) => Promise<void>;
@@ -1 +1 @@
1
- export type { P256Key, WebAuthnSignature, P256Credential, DataBundleDetails, SignedRequest } from './types';
1
+ export type { P256Key, Call, WebAuthnSignature, P256Credential, DataBundleDetails, SignedRequest, KokioSmartAccount, KokioSmartAccountClient, OwnerCall, OperationOptions, ScheduledOperation, ScheduledBatchOperation } from './types';
@@ -1,5 +1,77 @@
1
- import { Hex } from "viem";
1
+ import { Abi, Address, Chain, Hex, PublicActions, Transport } from "viem";
2
+ import type { BundlerClient, SmartAccount } from "viem/account-abstraction";
2
3
  export type P256Key = [Hex, Hex];
4
+ /**
5
+ * One call inside a user operation: target, optional ETH value, optional
6
+ * calldata. A single `Call` encodes to the account's `execute`, several
7
+ * batch atomically through `executeBatch`.
8
+ */
9
+ export type Call = {
10
+ to: Address;
11
+ value?: bigint;
12
+ data?: Hex;
13
+ };
14
+ /**
15
+ * A call the `ProtocolAdmin` timelock makes on a contract it owns. Same shape as
16
+ * a viem `writeContract`, because that is what it becomes once the delay is served.
17
+ */
18
+ export type OwnerCall = {
19
+ address: Address;
20
+ abi: Abi;
21
+ functionName: string;
22
+ args?: readonly unknown[];
23
+ /** ETH sent with the call. The timelock has to be holding it. */
24
+ value?: bigint;
25
+ };
26
+ /**
27
+ * Optional operation fields. Both default to zero, which makes the operation id a
28
+ * function of the call alone, so it can be recomputed later from the same
29
+ * arguments. Pass a `salt` to schedule a call the timelock has already run once.
30
+ */
31
+ export type OperationOptions = {
32
+ salt?: Hex;
33
+ /** Operation that has to be done before this one can execute. */
34
+ predecessor?: Hex;
35
+ };
36
+ /**
37
+ * What `schedule` returns. Hand the whole object to `execute`: the timelock
38
+ * recomputes the id from these fields, so anything altered makes it look up an
39
+ * operation that was never scheduled.
40
+ */
41
+ export type ScheduledOperation = {
42
+ /** Transaction hash of the `schedule` call, not the operation id. */
43
+ hash: Hex;
44
+ id: Hex;
45
+ target: Address;
46
+ value: bigint;
47
+ payload: Hex;
48
+ predecessor: Hex;
49
+ salt: Hex;
50
+ /** Delay requested. `getTimestamp(id)` is when it can actually run. */
51
+ delay: bigint;
52
+ };
53
+ /**
54
+ * What `scheduleBatch` returns. A batch hashes differently from a single call, so
55
+ * this stays a separate type: a one-call batch is not the same operation as the
56
+ * same call scheduled on its own, and only `executeBatch` can run it.
57
+ */
58
+ export type ScheduledBatchOperation = {
59
+ hash: Hex;
60
+ id: Hex;
61
+ targets: readonly Address[];
62
+ values: readonly bigint[];
63
+ payloads: readonly Hex[];
64
+ predecessor: Hex;
65
+ salt: Hex;
66
+ delay: bigint;
67
+ };
68
+ /** The device wallet, as an ERC-4337 account on EntryPoint v0.8. */
69
+ export type KokioSmartAccount = SmartAccount;
70
+ /**
71
+ * Sends user operations and reads contracts through one client. viem's bundler
72
+ * client carries no public actions, so the SDK adds them.
73
+ */
74
+ export type KokioSmartAccountClient = BundlerClient<Transport, Chain, SmartAccount> & PublicActions<Transport, Chain>;
3
75
  export type WebAuthnSignature = {
4
76
  authenticatorData: Hex;
5
77
  clientDataJSON: string;
@@ -26,6 +98,44 @@ export type DataBundleDetails = {
26
98
  dataBundleID: string;
27
99
  dataBundlePrice: bigint;
28
100
  };
101
+ /** One `deployMoreESIMWalletsForLazyDevice` (or first) transaction, read back from its receipt. */
102
+ export type LazyDeploymentBatch = {
103
+ hash: Hex;
104
+ /** Wallets this batch deployed, in the order of the device's identifier list. */
105
+ eSIMWallets: readonly Address[];
106
+ eSIMIdentifiers: readonly string[];
107
+ /** eSIM wallets still waiting after this batch. Zero means the device is done. */
108
+ remaining: bigint;
109
+ };
110
+ /**
111
+ * What a fully paginated lazy deployment did. `eSIMWallets` and `eSIMIdentifiers`
112
+ * cover only the batches this call ran, so a resume reports what it finished
113
+ * rather than the device's whole set.
114
+ */
115
+ export type LazyDeployment = {
116
+ deviceWallet: Address;
117
+ eSIMWallets: readonly Address[];
118
+ eSIMIdentifiers: readonly string[];
119
+ batches: readonly LazyDeploymentBatch[];
120
+ /** Every eSIM wallet already existed, so nothing was sent. */
121
+ alreadyComplete: boolean;
122
+ };
123
+ /** One `setHistoryForLazyWallet` transaction, read back from its receipt. */
124
+ export type LazyHistoryBatch = {
125
+ hash: Hex;
126
+ copied: bigint;
127
+ /** Entries still waiting after this batch. Zero means the copy is done. */
128
+ remaining: bigint;
129
+ };
130
+ /** What a fully paginated history copy did, for one eSIM. */
131
+ export type LazyHistoryCopy = {
132
+ eSIMWallet: Address;
133
+ /** Entries written by this call, across every batch it ran. */
134
+ copied: bigint;
135
+ batches: readonly LazyHistoryBatch[];
136
+ /** The history was already fully copied, so nothing was sent. */
137
+ alreadyComplete: boolean;
138
+ };
29
139
  export type SignedRequest = {
30
140
  body: string;
31
141
  stamp: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kokio-sdk",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/config.js",
@@ -48,22 +48,20 @@
48
48
  },
49
49
  "homepage": "https://github.com/Blockchain-Powered-eSIM/kokio-sdk#readme",
50
50
  "devDependencies": {
51
- "dotenv": "^16.5.0",
52
- "typescript": "^5.7.3",
53
- "vitest": "4.1.10"
51
+ "@types/node": "22.20.1",
52
+ "dotenv": "17.4.2",
53
+ "typescript": "5.9.3",
54
+ "vitest": "4.1.11"
54
55
  },
55
56
  "dependencies": {
56
- "@aa-sdk/core": "4.88.4",
57
- "@noble/curves": "2.2.0",
58
- "@peculiar/asn1-ecc": "2.8.0",
59
- "@peculiar/asn1-schema": "2.8.0",
57
+ "@noble/curves": "2.3.0",
58
+ "@peculiar/asn1-ecc": "2.9.3",
59
+ "@peculiar/asn1-schema": "2.9.3",
60
60
  "@simplewebauthn/server": "13.3.2",
61
- "react-native-passkey": "3.5.0",
62
- "viem": "2.53.1"
61
+ "react-native-passkey": "3.6.1",
62
+ "viem": "2.55.19"
63
63
  },
64
64
  "overrides": {
65
- "ws": "8.21.0",
66
- "uuid": "14.0.0",
67
- "js-cookie": "3.0.8"
65
+ "ws": "8.21.0"
68
66
  }
69
67
  }
@@ -1,10 +0,0 @@
1
- import { _isLazyWalletDeployed } from "../logic/lazyWalletRegistry.js";
2
- export class LazyWalletRegistrySubPackage {
3
- client;
4
- constructor(client) {
5
- this.client = client;
6
- }
7
- isLazyWalletDeployed(deviceUniqueIdentifier) {
8
- return _isLazyWalletDeployed(this.client, deviceUniqueIdentifier);
9
- }
10
- }
@@ -1,19 +0,0 @@
1
- import { _getChainSpecificConstants } from "./constants.js";
2
- import { LazyWalletRegistry } from "../abis/index.js";
3
- // batchPopulateHistory, deployLazyWalletAndSetESIMIdentifier and
4
- // switchESIMIdentifierToNewDeviceIdentifier are all `onlyESIMWalletAdmin`, so a
5
- // device-wallet userOp (msg.sender = the device wallet account) always reverts. They
6
- // are exposed on `KokioAdmin.lazyWalletRegistry` instead. Only the `view` lookup
7
- // belongs on this surface, exposed as a direct read.
8
- export const _isLazyWalletDeployed = async (client, deviceUniqueIdentifier) => {
9
- const chainID = await client.getChainId();
10
- const rpcURL = client.transport.url;
11
- const values = _getChainSpecificConstants(chainID, rpcURL);
12
- // `isLazyWalletDeployed` is a `view` - read it directly instead of spending a userOp.
13
- return client.readContract({
14
- address: values.factoryAddresses.LAZY_WALLET_REGISTRY,
15
- abi: LazyWalletRegistry,
16
- functionName: "isLazyWalletDeployed",
17
- args: [deviceUniqueIdentifier]
18
- });
19
- };
@@ -1,6 +0,0 @@
1
- import { SmartAccountClient } from "@aa-sdk/core";
2
- export declare class LazyWalletRegistrySubPackage {
3
- client: SmartAccountClient;
4
- constructor(client: SmartAccountClient);
5
- isLazyWalletDeployed(deviceUniqueIdentifier: string): Promise<boolean>;
6
- }
@@ -1,2 +0,0 @@
1
- import { SmartAccountClient } from "@aa-sdk/core";
2
- export declare const _isLazyWalletDeployed: (client: SmartAccountClient, deviceUniqueIdentifier: string) => Promise<boolean>;