kokio-sdk 1.1.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 (106) 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 +7 -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 +3 -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/deviceWalletClass.d.ts +22 -2569
  72. package/dist/types/interface/deviceWalletFactoryClass.d.ts +10 -2564
  73. package/dist/types/interface/eSIMWalletClass.d.ts +11 -8
  74. package/dist/types/interface/eSIMWalletFactoryClass.d.ts +5 -2565
  75. package/dist/types/interface/registryClass.d.ts +19 -0
  76. package/dist/types/interface/smartAccountClass.d.ts +6 -2568
  77. package/dist/types/logic/P256Verifier.d.ts +2 -2
  78. package/dist/types/logic/account-kit/createSmartAccount.d.ts +43 -19
  79. package/dist/types/logic/admin/deviceWallet.eoa.d.ts +15 -9
  80. package/dist/types/logic/admin/deviceWalletFactory.eoa.d.ts +34 -23
  81. package/dist/types/logic/admin/eSIMWallet.eoa.d.ts +0 -5
  82. package/dist/types/logic/admin/eSIMWalletFactory.eoa.d.ts +27 -9
  83. package/dist/types/logic/admin/lazyWalletRegistry.eoa.d.ts +102 -10
  84. package/dist/types/logic/admin/protocolAdmin.eoa.d.ts +163 -0
  85. package/dist/types/logic/admin/reads/deviceWallet.reads.d.ts +28 -8
  86. package/dist/types/logic/admin/reads/deviceWalletFactory.reads.d.ts +45 -14
  87. package/dist/types/logic/admin/reads/eSIMWallet.reads.d.ts +25 -6
  88. package/dist/types/logic/admin/reads/eSIMWalletFactory.reads.d.ts +21 -6
  89. package/dist/types/logic/admin/reads/lazyWalletRegistry.reads.d.ts +44 -11
  90. package/dist/types/logic/admin/reads/protocolAdmin.reads.d.ts +53 -0
  91. package/dist/types/logic/admin/reads/registry.reads.d.ts +105 -9
  92. package/dist/types/logic/admin/registry.eoa.d.ts +102 -5
  93. package/dist/types/logic/constants.d.ts +2 -0
  94. package/dist/types/logic/deviceWallet.d.ts +78 -6
  95. package/dist/types/logic/deviceWalletFactory.d.ts +32 -3
  96. package/dist/types/logic/eSIMWallet.d.ts +48 -7
  97. package/dist/types/logic/eSIMWalletFactory.d.ts +3 -3
  98. package/dist/types/logic/errors.d.ts +45 -0
  99. package/dist/types/logic/registry.d.ts +78 -0
  100. package/dist/types/types-export.d.ts +1 -1
  101. package/dist/types/types.d.ts +111 -1
  102. package/package.json +11 -13
  103. package/dist/esm/interface/lazyWalletRegistryClass.js +0 -10
  104. package/dist/esm/logic/lazyWalletRegistry.js +0 -19
  105. package/dist/types/interface/lazyWalletRegistryClass.d.ts +0 -6
  106. package/dist/types/logic/lazyWalletRegistry.d.ts +0 -2
@@ -1,26 +1,57 @@
1
- import { Address, WalletClient } from "viem";
1
+ import { Address, Hex, WalletClient } from "viem";
2
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
3
  /** The admin EOA (`eSIMWalletAdmin`) currently set on the factory. */
13
4
  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
5
  /** Whether a device wallet has been registered with the factory. */
19
6
  export declare const _deviceWalletInfoAdded: (client: WalletClient, deviceWallet: Address) => Promise<boolean>;
20
7
  /** The current device-wallet beacon implementation. */
21
8
  export declare const _getCurrentDeviceWalletImplementation: (client: WalletClient) => Promise<Address>;
9
+ /**
10
+ * Check an identifier and owner key before deploying. Answers the zero address
11
+ * when both are free, or the wallet already holding one of them.
12
+ *
13
+ * `createAccount` runs inside EntryPoint validation, where the 4337 rules bar it
14
+ * from reading the registry, so it cannot see that an identifier or a key is
15
+ * taken: it deploys a second wallet at a fresh address and the
16
+ * `postCreateAccount` that would register it fails afterwards. Checking here
17
+ * first is what stops that.
18
+ *
19
+ * Reverts on an empty identifier or a key that is not a point on the P256 curve.
20
+ */
21
+ export declare const _preCreateAccountValidation: (client: WalletClient, deviceUniqueIdentifier: string, deviceWalletOwnerKey: P256Key) => Promise<Address>;
22
+ /**
23
+ * The beacon every device wallet reads its implementation from. One update moves
24
+ * all of them and no wallet can decline it.
25
+ */
26
+ export declare const _beacon: (client: WalletClient) => Promise<`0x${string}`>;
27
+ /** The registry the factory writes new wallets into. */
28
+ export declare const _registry: (client: WalletClient) => Promise<`0x${string}`>;
29
+ /** The EntryPoint baked into every device wallet this factory deploys. */
30
+ export declare const _entryPoint: (client: WalletClient) => Promise<`0x${string}`>;
31
+ /** The contract new device wallets verify WebAuthn assertions through. */
32
+ export declare const _verifier: (client: WalletClient) => Promise<`0x${string}`>;
33
+ /**
34
+ * Who holds `onlyOwner` on the factory. On the live deployment this is the
35
+ * `ProtocolAdmin` timelock, so an owner call sent from an EOA reverts and has to
36
+ * be scheduled instead.
37
+ */
38
+ export declare const _owner: (client: WalletClient) => Promise<`0x${string}`>;
39
+ /**
40
+ * The address a `transferOwnership` is waiting on. Worth reading before
41
+ * `protocolAdmin.acceptOwnershipBatch`, which reverts on any target that has not
42
+ * been offered to the timelock.
43
+ */
44
+ export declare const _pendingOwner: (client: WalletClient) => Promise<`0x${string}`>;
22
45
  /**
23
46
  * The counterfactual (CREATE2) device-wallet address for an owner key. On-chain
24
47
  * arg order is `(ownerKey, uid, salt)` - note this differs from `createAccount`.
25
48
  */
26
49
  export declare const _getCounterFactualAddress: (client: WalletClient, deviceWalletOwnerKey: P256Key, deviceUniqueIdentifier: string, salt: bigint) => Promise<Address>;
50
+ /**
51
+ * The ERC-1822 storage slot this proxy keeps its implementation in. An upgrade
52
+ * reverts unless the incoming implementation answers with the same value, which
53
+ * is what stops a non-UUPS address being installed.
54
+ */
55
+ export declare const _proxiableUUID: (client: WalletClient) => Promise<Hex>;
56
+ /** The OpenZeppelin upgrade interface this proxy speaks, currently `"5.0.0"`. */
57
+ export declare const _upgradeInterfaceVersion: (client: WalletClient) => Promise<string>;
@@ -1,15 +1,34 @@
1
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
- */
2
+ import { DataBundleDetails } from "../../../types.js";
8
3
  /** The `ESIMWalletFactory` that deployed this eSIM wallet. */
9
4
  export declare const _eSIMWalletFactory: (client: WalletClient, eSIMWalletAddress: Address) => Promise<Address>;
10
5
  /** The eSIM's unique identifier string (empty until set by the admin). */
11
6
  export declare const _eSIMUniqueIdentifier: (client: WalletClient, eSIMWalletAddress: Address) => Promise<string>;
7
+ /**
8
+ * This wallet's own price ceiling in wei. Zero means it follows the registry's
9
+ * `defaultDataBundlePriceCap` instead, which is the state a fresh wallet and a
10
+ * newly handed-over wallet both start in. Worth reading before naming a price on
11
+ * `buyDataBundle`, since a price over the ceiling reverts.
12
+ */
13
+ export declare const _dataBundlePriceCap: (client: WalletClient, eSIMWalletAddress: Address) => Promise<bigint>;
12
14
  /** The pending owner proposed via `requestTransferOwnership` (zero if none). */
13
15
  export declare const _newRequestedOwner: (client: WalletClient, eSIMWalletAddress: Address) => Promise<Address>;
14
16
  /** The current owner (device wallet) of this eSIM wallet. */
15
17
  export declare const _owner: (client: WalletClient, eSIMWalletAddress: Address) => Promise<Address>;
18
+ /**
19
+ * The device wallet this eSIM wallet belongs to. Tracks `owner` today, but it is
20
+ * a separate storage slot with its own typed getter, so read whichever one the
21
+ * calling code actually means.
22
+ */
23
+ export declare const _deviceWallet: (client: WalletClient, eSIMWalletAddress: Address) => Promise<Address>;
24
+ /**
25
+ * One data bundle purchase, by position. The array holds every purchase this
26
+ * wallet has made, and for a wallet that started life on the fiat path it also
27
+ * holds the pre-deployment purchases the lazy registry copies in.
28
+ *
29
+ * The contract publishes no length getter, so there is no way to ask how many
30
+ * entries exist. Read upwards from zero until a call reverts, or track the count
31
+ * from the `DataBundleBought` and `TransactionHistoryPopulated` events, whose
32
+ * `_totalEntries` is the length after the batch landed.
33
+ */
34
+ export declare const _transactionHistory: (client: WalletClient, eSIMWalletAddress: Address, index: bigint) => Promise<DataBundleDetails>;
@@ -1,10 +1,25 @@
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
- */
1
+ import { Address, Hex, WalletClient } from "viem";
7
2
  /** Whether an eSIM wallet was deployed by this factory. */
8
3
  export declare const _isESIMWalletDeployed: (client: WalletClient, eSIMWallet: Address) => Promise<boolean>;
9
4
  /** The current eSIM-wallet beacon implementation. */
10
5
  export declare const _getCurrentESIMWalletImplementation: (client: WalletClient) => Promise<Address>;
6
+ /**
7
+ * The ERC-1822 storage slot this proxy keeps its implementation in. An upgrade
8
+ * reverts unless the incoming implementation answers with the same value, which
9
+ * is what stops a non-UUPS address being installed.
10
+ */
11
+ export declare const _proxiableUUID: (client: WalletClient) => Promise<Hex>;
12
+ /** The OpenZeppelin upgrade interface this proxy speaks, currently `"5.0.0"`. */
13
+ export declare const _upgradeInterfaceVersion: (client: WalletClient) => Promise<string>;
14
+ /**
15
+ * Who holds `onlyOwner` here. On the live deployment this is the
16
+ * `ProtocolAdmin` timelock, so an owner call sent from an EOA reverts and has to
17
+ * be scheduled instead.
18
+ */
19
+ export declare const _owner: (client: WalletClient) => Promise<Address>;
20
+ /**
21
+ * The address a `transferOwnership` is waiting on. Worth reading before
22
+ * `protocolAdmin.acceptOwnershipBatch`, which reverts on any target that has not
23
+ * been offered to the timelock.
24
+ */
25
+ export declare const _pendingOwner: (client: WalletClient) => Promise<Address>;
@@ -1,20 +1,53 @@
1
- import { WalletClient } from "viem";
1
+ import { Address, Hex, WalletClient } from "viem";
2
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
3
  /** The upgrade-manager (owner) EOA of the lazy registry. */
14
4
  export declare const _upgradeManager: (client: WalletClient) => Promise<`0x${string}`>;
15
5
  /** The device identifier an eSIM identifier is currently associated with. */
16
6
  export declare const _eSIMIdentifierToDeviceIdentifier: (client: WalletClient, eSIMIdentifier: string) => Promise<string>;
17
7
  /** One data-bundle history entry for a (device, eSIM) pair, by array index. */
18
8
  export declare const _deviceIdentifierToESIMDetails: (client: WalletClient, deviceIdentifier: string, eSIMIdentifier: string, index: bigint) => Promise<DataBundleDetails>;
9
+ /** Most eSIM wallets one `deployLazyWalletAndSetESIMIdentifier` call will deploy. */
10
+ export declare const _maxESIMWalletsPerCall: (client: WalletClient) => Promise<bigint>;
11
+ /** Most history entries one `setHistoryForLazyWallet` call will copy. */
12
+ export declare const _maxHistoryEntriesPerCall: (client: WalletClient) => Promise<bigint>;
13
+ /**
14
+ * How many of a device's eSIM wallets are already deployed. Non-zero exactly when
15
+ * the lazy route ran the device's first batch, so it doubles as the marker for
16
+ * the route itself.
17
+ */
18
+ export declare const _eSIMWalletsDeployed: (client: WalletClient, deviceIdentifier: string) => Promise<bigint>;
19
+ /** Salt the device's first deployment batch started from. Every later batch derives from it. */
20
+ export declare const _lazyDeploymentSalt: (client: WalletClient, deviceIdentifier: string) => Promise<bigint>;
21
+ /**
22
+ * The eSIM wallet this registry deployed for an identifier. Zero for anything it
23
+ * did not deploy, which is what authorises the history copy.
24
+ */
25
+ export declare const _lazyDeployedESIMWallet: (client: WalletClient, eSIMIdentifier: string) => Promise<`0x${string}`>;
26
+ /** How many of an eSIM's stored purchase entries have already reached its wallet. */
27
+ export declare const _historyEntriesCopied: (client: WalletClient, eSIMIdentifier: string) => Promise<bigint>;
28
+ /** Whether a device identifier has purchases recorded against it here. */
29
+ export declare const _isDeviceIdentifierReserved: (client: WalletClient, deviceIdentifier: string) => Promise<boolean>;
30
+ /** Whether an eSIM identifier is bound to a device here. */
31
+ export declare const _isESIMIdentifierReserved: (client: WalletClient, eSIMIdentifier: string) => Promise<boolean>;
19
32
  /** One eSIM identifier associated with a device identifier, by array index. */
20
33
  export declare const _eSIMIdentifiersAssociatedWithDeviceIdentifier: (client: WalletClient, deviceIdentifier: string, index: bigint) => Promise<string>;
34
+ /**
35
+ * The ERC-1822 storage slot this proxy keeps its implementation in. An upgrade
36
+ * reverts unless the incoming implementation answers with the same value, which
37
+ * is what stops a non-UUPS address being installed.
38
+ */
39
+ export declare const _proxiableUUID: (client: WalletClient) => Promise<Hex>;
40
+ /** The OpenZeppelin upgrade interface this proxy speaks, currently `"5.0.0"`. */
41
+ export declare const _upgradeInterfaceVersion: (client: WalletClient) => Promise<string>;
42
+ /**
43
+ * Who holds `onlyOwner` here. On the live deployment this is the
44
+ * `ProtocolAdmin` timelock, so an owner call sent from an EOA reverts and has to
45
+ * be scheduled instead.
46
+ */
47
+ export declare const _owner: (client: WalletClient) => Promise<Address>;
48
+ /**
49
+ * The address a `transferOwnership` is waiting on. Worth reading before
50
+ * `protocolAdmin.acceptOwnershipBatch`, which reverts on any target that has not
51
+ * been offered to the timelock.
52
+ */
53
+ export declare const _pendingOwner: (client: WalletClient) => Promise<Address>;
@@ -0,0 +1,53 @@
1
+ import { Address, Hex, WalletClient } from "viem";
2
+ /** Operation lifecycle, matching the on-chain `OperationState` enum. */
3
+ export declare enum OperationState {
4
+ Unset = 0,
5
+ Waiting = 1,
6
+ Ready = 2,
7
+ Done = 3
8
+ }
9
+ /**
10
+ * Shortest delay a new operation will be given. Read this rather than following
11
+ * `MinDelayChange`, which carries the value `updateDelay` stored and not the
12
+ * floor that overrides it.
13
+ */
14
+ export declare const _getMinDelay: (client: WalletClient) => Promise<bigint>;
15
+ /**
16
+ * The floor `getMinDelay` clamps to. Immutable, so `updateDelay` can never bring
17
+ * the timelock below it.
18
+ */
19
+ export declare const _minDelayFloor: (client: WalletClient) => Promise<bigint>;
20
+ /** Where an operation is in its lifecycle. */
21
+ export declare const _getOperationState: (client: WalletClient, id: Hex) => Promise<OperationState>;
22
+ /**
23
+ * When an operation becomes executable, as a unix timestamp. Reads `0` for an
24
+ * unknown operation and the literal `1` for one already done, so compare against
25
+ * the state rather than treating this as a time in both cases.
26
+ */
27
+ export declare const _getTimestamp: (client: WalletClient, id: Hex) => Promise<bigint>;
28
+ /** Whether the timelock has ever seen this operation. */
29
+ export declare const _isOperation: (client: WalletClient, id: Hex) => Promise<boolean>;
30
+ /** Scheduled and not yet executed, whether or not the delay has elapsed. */
31
+ export declare const _isOperationPending: (client: WalletClient, id: Hex) => Promise<boolean>;
32
+ /** The delay has elapsed and the operation can be executed now. */
33
+ export declare const _isOperationReady: (client: WalletClient, id: Hex) => Promise<boolean>;
34
+ /** The operation has already run. */
35
+ export declare const _isOperationDone: (client: WalletClient, id: Hex) => Promise<boolean>;
36
+ /** Whether an account holds a role. Role ids come from the constants below. */
37
+ export declare const _hasRole: (client: WalletClient, role: Hex, account: Address) => Promise<boolean>;
38
+ /**
39
+ * The role that can grant and revoke the given one. Always `DEFAULT_ADMIN_ROLE`,
40
+ * which only the timelock itself holds, so every role change is a scheduled
41
+ * operation.
42
+ */
43
+ export declare const _getRoleAdmin: (client: WalletClient, role: Hex) => Promise<Hex>;
44
+ /** Held only by the timelock itself, which is what makes role changes wait. */
45
+ export declare const _defaultAdminRole: (client: WalletClient) => Promise<`0x${string}`>;
46
+ /** Can schedule operations, and can cancel them. */
47
+ export declare const _proposerRole: (client: WalletClient) => Promise<`0x${string}`>;
48
+ /** Can cancel a scheduled operation and nothing else. */
49
+ export declare const _cancellerRole: (client: WalletClient) => Promise<`0x${string}`>;
50
+ /** Granted to the zero address, so execution is open to anyone. */
51
+ export declare const _executorRole: (client: WalletClient) => Promise<`0x${string}`>;
52
+ /** The three instant powers. Cannot be held alongside proposer or canceller. */
53
+ export declare const _guardianRole: (client: WalletClient) => Promise<`0x${string}`>;
@@ -1,16 +1,62 @@
1
1
  import { Address, Hex, WalletClient } from "viem";
2
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.
3
+ * The admin EOA (`eSIMWalletAdmin`) recorded in the registry. Reads zero while a
4
+ * nomination is pending or the admin is suspended, which means the role is
5
+ * dormant rather than unset.
7
6
  */
8
- /** The admin EOA (`eSIMWalletAdmin`) recorded in the registry. */
9
7
  export declare const _eSIMWalletAdmin: (client: WalletClient) => Promise<Address>;
8
+ /**
9
+ * The admin address on the books, which keeps naming a suspended admin so the
10
+ * suspension can be lifted without supplying it again. Ask `_eSIMWalletAdmin`
11
+ * who may actually act.
12
+ */
13
+ export declare const _adminOfRecord: (client: WalletClient) => Promise<Address>;
14
+ /**
15
+ * Whether the admin's powers are suspended protocol-wide. True and a pending
16
+ * nomination are separate reasons for `_eSIMWalletAdmin` to read zero, so read
17
+ * this alongside `_newRequestedAdmin` to tell them apart.
18
+ */
19
+ export declare const _adminDisabled: (client: WalletClient) => Promise<boolean>;
20
+ /**
21
+ * Whether the protocol is paused. While true, every ETH-moving path on the
22
+ * device wallets and eSIM wallets reverts `ProtocolPaused`.
23
+ */
24
+ export declare const _paused: (client: WalletClient) => Promise<boolean>;
25
+ /**
26
+ * The fallback price ceiling in wei, applied to any eSIM wallet holding no cap of
27
+ * its own. Never zero.
28
+ */
29
+ export declare const _defaultDataBundlePriceCap: (client: WalletClient) => Promise<bigint>;
10
30
  /** The vault EOA recorded in the registry. */
11
31
  export declare const _vault: (client: WalletClient) => Promise<Address>;
32
+ /** The pending admin nominated via `requestAdminUpdate` (zero address if none). */
33
+ export declare const _newRequestedAdmin: (client: WalletClient) => Promise<Address>;
34
+ /**
35
+ * Who holds `onlyOwner` on the registry. On the live deployment this is the
36
+ * `ProtocolAdmin` timelock, so an owner call sent from an EOA reverts and has to
37
+ * be scheduled instead.
38
+ */
39
+ export declare const _owner: (client: WalletClient) => Promise<Address>;
12
40
  /** The upgrade-manager (owner) EOA recorded in the registry. */
13
41
  export declare const _upgradeManager: (client: WalletClient) => Promise<Address>;
42
+ /**
43
+ * The address a `transferOwnership` is waiting on. Worth reading before
44
+ * `protocolAdmin.acceptOwnershipBatch`, which reverts on any target that has not
45
+ * been offered to the timelock.
46
+ */
47
+ export declare const _pendingOwner: (client: WalletClient) => Promise<Address>;
48
+ /** The `DeviceWalletFactory` address wired into the registry. */
49
+ export declare const _deviceWalletFactory: (client: WalletClient) => Promise<Address>;
50
+ /** The `ESIMWalletFactory` address wired into the registry. */
51
+ export declare const _eSIMWalletFactory: (client: WalletClient) => Promise<Address>;
52
+ /** The EntryPoint the registry recognises. One per chain. */
53
+ export declare const _entryPoint: (client: WalletClient) => Promise<Address>;
54
+ /**
55
+ * The same pause check the wallets themselves run, which throws rather than
56
+ * returning false. Use `_paused` to branch on it; use this when you want the
57
+ * failure to carry the protocol's own revert reason.
58
+ */
59
+ export declare const _requireNotPaused: (client: WalletClient) => Promise<void>;
14
60
  /** The `LazyWalletRegistry` address wired into the registry. */
15
61
  export declare const _lazyWalletRegistry: (client: WalletClient) => Promise<Address>;
16
62
  /** The device wallet registered for a device unique identifier (zero if none). */
@@ -25,10 +71,60 @@ export declare const _registeredP256Keys: (client: WalletClient, hashOfOwnerP256
25
71
  /** Whether a device wallet is registered/valid. */
26
72
  export declare const _isDeviceWalletValid: (client: WalletClient, deviceWallet: Address) => Promise<boolean>;
27
73
  /**
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.
74
+ * The device wallet an eSIM wallet is registered against, zero if the protocol
75
+ * never deployed it. Despite the name this returns an address, not a boolean.
76
+ *
77
+ * This is a registration record, not a current holder. Once it goes non-zero it
78
+ * stays non-zero for the rest of the wallet's life, and mid-transfer it still
79
+ * names the device wallet that last held it. To ask who holds it now, read
80
+ * `DeviceWallet.isValidESIMWallet` on the device wallet.
31
81
  */
32
82
  export declare const _isESIMWalletValid: (client: WalletClient, eSIMWallet: Address) => Promise<Address>;
33
- /** Whether an eSIM wallet is currently on standby. */
83
+ /**
84
+ * Whether a transfer is outstanding on an eSIM wallet. `bindESIMWallet` clears
85
+ * it once the new device wallet takes the eSIM wallet on.
86
+ *
87
+ * Independent of `isESIMWalletValid`, and neither implies the other. A `true`
88
+ * here is not a claim the wallet left the protocol, and it is normal for the
89
+ * association to still name the device wallet that raised the flag. Do not use
90
+ * this to decide whether an eSIM wallet belongs to the protocol.
91
+ */
34
92
  export declare const _isESIMWalletOnStandby: (client: WalletClient, eSIMWallet: Address) => Promise<boolean>;
93
+ /**
94
+ * Whether a device identifier already has a wallet on chain. Not the same
95
+ * question as `lazyWalletRegistry.isDeviceIdentifierReserved`, which reads true
96
+ * as soon as history is recorded and well before anything is deployed.
97
+ */
98
+ export declare const _isDeviceIdentifierAlreadyUsed: (client: WalletClient, deviceUniqueIdentifier: string) => Promise<boolean>;
99
+ /** Whether an eSIM identifier is already held by a wallet. */
100
+ export declare const _isESIMIdentifierClaimed: (client: WalletClient, eSIMUniqueIdentifier: string) => Promise<boolean>;
101
+ /**
102
+ * The one eSIM wallet holding an eSIM identifier, zero if nobody holds it. Set
103
+ * once and never cleared, an ownership transfer included, because the eSIM
104
+ * belongs to the wallet rather than to whichever device is holding it.
105
+ */
106
+ export declare const _eSIMWalletForIdentifier: (client: WalletClient, eSIMUniqueIdentifier: string) => Promise<Address>;
107
+ /**
108
+ * The same answer as `_eSIMWalletForIdentifier`, keyed by the keccak256 of the
109
+ * identifier. Use it when the hash is what you already have; otherwise take the
110
+ * string version and skip the hashing.
111
+ */
112
+ export declare const _claimedESIMIdentifiers: (client: WalletClient, hashOfESIMIdentifier: Hex) => Promise<Address>;
113
+ /**
114
+ * The check `DeviceWalletFactory` runs before taking a device identifier.
115
+ * Resolves if the identifier is free, reverts `DeviceIdentifierReservedForLazyWallet`
116
+ * if a fiat user's eSIMs are already waiting on it.
117
+ *
118
+ * Worth calling ahead of a deployment: taking a reserved identifier strands the
119
+ * lazy user, since the history copy, the wallet deployment and the device switch
120
+ * all then refuse it.
121
+ */
122
+ export declare const _requireDeviceIdentifierNotReserved: (client: WalletClient, deviceUniqueIdentifier: string) => Promise<void>;
123
+ /**
124
+ * The ERC-1822 storage slot this proxy keeps its implementation in. An upgrade
125
+ * reverts unless the incoming implementation answers with the same value, which
126
+ * is what stops a non-UUPS address being installed.
127
+ */
128
+ export declare const _proxiableUUID: (client: WalletClient) => Promise<Hex>;
129
+ /** The OpenZeppelin upgrade interface this proxy speaks, currently `"5.0.0"`. */
130
+ export declare const _upgradeInterfaceVersion: (client: WalletClient) => Promise<string>;
@@ -1,7 +1,104 @@
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
- */
1
+ import { Address, Hex, WalletClient } from "viem";
2
+ import type { OwnerCall } from "../../types.js";
6
3
  /** Wire (or rewire) the LazyWalletRegistry into the Registry. `onlyOwner`. */
7
4
  export declare const _addOrUpdateLazyWalletRegistryAddress: (client: WalletClient, lazyWalletRegistry: Address) => Promise<`0x${string}`>;
5
+ /** Update the vault that receives eSIM payments. `onlyOwner`. */
6
+ export declare const _updateVaultAddress: (client: WalletClient, newVaultAddress: Address) => Promise<`0x${string}`>;
7
+ /**
8
+ * Step 1 of the 2-step admin handover: nominate the next admin. `onlyOwner`, so
9
+ * the `client` is the owner EOA, not the outgoing admin.
10
+ *
11
+ * The nomination takes the role off the incumbent straight away: `eSIMWalletAdmin`
12
+ * reads zero until the nominee accepts, and every admin gated call across the
13
+ * protocol reverts in that window. Send the two steps close together. Naming the
14
+ * incumbent instead withdraws a pending nomination and hands the role back.
15
+ */
16
+ export declare const _requestAdminUpdate: (client: WalletClient, newAdmin: Address) => Promise<`0x${string}`>;
17
+ /**
18
+ * Suspend the admin's powers protocol-wide. `onlyOwner`.
19
+ *
20
+ * The address stays on the books as `adminOfRecord`, so lifting the suspension
21
+ * does not need it supplied again. Reverts if the admin is already suspended,
22
+ * rather than passing quietly and leaving the caller believing it acted.
23
+ */
24
+ export declare const _disableAdmin: (client: WalletClient) => Promise<`0x${string}`>;
25
+ /**
26
+ * Give the suspended admin its powers back. `onlyOwner`.
27
+ *
28
+ * Does nothing about an outstanding nomination, which keeps the incumbent
29
+ * powerless on its own. Withdraw that with `_requestAdminUpdate` naming the
30
+ * incumbent. Reverts if the admin was never suspended.
31
+ */
32
+ export declare const _enableAdmin: (client: WalletClient) => Promise<`0x${string}`>;
33
+ /**
34
+ * Stop the ETH-moving paths on every device wallet and eSIM wallet.
35
+ * `onlyESIMWalletAdmin`, so this is the one emergency lever the backend key can
36
+ * pull on its own.
37
+ *
38
+ * It cannot release it again: `_unpause` is `onlyOwner`. That split is what stops
39
+ * a compromised backend key holding user funds. Owners can still spend their own
40
+ * ETH through their device wallet's `execute`, which a pause never reaches.
41
+ */
42
+ export declare const _pause: (client: WalletClient) => Promise<`0x${string}`>;
43
+ /**
44
+ * Release the pause. `onlyOwner`, not the admin, see `_pause`.
45
+ *
46
+ * On the live deployment the owner is the timelock, so this reverts from an EOA.
47
+ * Schedule `protocolAdmin.unpauseCall` instead, or have a guardian call
48
+ * `unpauseInstantly` if the wait is not acceptable.
49
+ */
50
+ export declare const _unpause: (client: WalletClient) => Promise<`0x${string}`>;
51
+ /**
52
+ * Set the price ceiling every eSIM wallet falls back to when it holds none of its
53
+ * own. `onlyOwner`, deliberately not the admin: the admin names the price on
54
+ * `buyDataBundle`, so it must not also be able to raise its own limit.
55
+ *
56
+ * Zero reverts `ZeroDataBundlePriceCap`, since a zero would read as "no ceiling"
57
+ * for every wallet without one of its own.
58
+ */
59
+ export declare const _setDefaultDataBundlePriceCap: (client: WalletClient, cap: bigint) => Promise<`0x${string}`>;
60
+ /**
61
+ * Bind an eSIM's unique identifier to its wallet. `onlyESIMWalletAdmin`.
62
+ *
63
+ * The identifier is claimed protocol-wide, so a string already bound to another
64
+ * wallet reverts rather than moving.
65
+ */
66
+ export declare const _assignESIMIdentifier: (client: WalletClient, eSIMWalletAddress: Address, eSIMUniqueIdentifier: string) => Promise<`0x${string}`>;
67
+ /**
68
+ * Step 2 of the 2-step admin handover: the nominee accepts. The chain requires
69
+ * `msg.sender` to equal the pending admin, so the `client` here must be the
70
+ * newly nominated admin EOA.
71
+ */
72
+ export declare const _acceptAdminUpdate: (client: WalletClient) => Promise<`0x${string}`>;
73
+ /**
74
+ * Take ownership after a `transferOwnership` named this client. The chain
75
+ * requires `msg.sender` to equal `pendingOwner`, so the `client` is the incoming
76
+ * owner, not the outgoing one.
77
+ *
78
+ * Permissionless in the sense that it needs no role, so where the incoming owner
79
+ * is the timelock this is not the call to use: `protocolAdmin.acceptOwnershipBatch`
80
+ * accepts for every contract at once and needs no delay.
81
+ */
82
+ export declare const _acceptOwnership: (client: WalletClient) => Promise<`0x${string}`>;
83
+ /**
84
+ * Offer ownership to a new address. Pass the result to `schedule`.
85
+ *
86
+ * Ownable2Step, so the offer alone changes nothing: the named address has to
87
+ * call `acceptOwnership` before it holds anything. Until then the current owner
88
+ * keeps every power. Naming an address that cannot call back leaves the
89
+ * ownership where it is rather than stranding it.
90
+ */
91
+ export declare const _transferOwnershipCall: (client: WalletClient, newOwner: Address) => Promise<OwnerCall>;
92
+ /**
93
+ * Point the proxy at a new implementation. Builds `upgradeToAndCall`. Pass the
94
+ * result to `schedule`.
95
+ *
96
+ * `data` runs on the proxy straight after the swap, in the same transaction, and
97
+ * is where a `reinitializer` goes. Leave it empty when the new implementation
98
+ * needs no setup.
99
+ *
100
+ * There is no undo. The implementation is checked for a matching `proxiableUUID`
101
+ * and nothing else, so an address that answers correctly but cannot upgrade
102
+ * again ends the proxy's life. Diff the storage layout before scheduling.
103
+ */
104
+ export declare const _upgradeCall: (client: WalletClient, newImplementation: Address, data?: Hex) => Promise<OwnerCall>;
@@ -2,6 +2,8 @@ import { WalletClient, Address } from 'viem';
2
2
  import { mainnet, sepolia, optimism, optimismSepolia, arbitrum, arbitrumSepolia, base, baseSepolia } from "viem/chains";
3
3
  export declare const ZERO: bigint;
4
4
  export declare const SIGNATURE_VALIDITY_SECONDS = 180;
5
+ export declare const STUB_VERIFICATION_GAS_PAD: bigint;
6
+ export declare const STUB_PRE_VERIFICATION_GAS_PAD: bigint;
5
7
  export declare enum CHAIN_ID {
6
8
  MAINNET = 1,
7
9
  SEPOLIA = 11155111,
@@ -1,8 +1,80 @@
1
- import { Address, WalletClient } from "viem";
2
- import { SmartAccountClient } from "@aa-sdk/core";
1
+ import { Address, Hex, WalletClient } from "viem";
2
+ import { Call, KokioSmartAccountClient } from "../types.js";
3
3
  import { P256Key } from "../types.js";
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>>>;
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>>>;
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>;
4
+ /**
5
+ * Send one or more calls from this device wallet as a single user operation.
6
+ * The only escape hatch on this surface for anything not named below: sending
7
+ * ETH to any address, calling another contract, moving tokens, interacting
8
+ * with a DeFi protocol. A lone call encodes to `execute`, several batch
9
+ * atomically through `executeBatch`.
10
+ */
11
+ export declare const _sendUserOperation: (client: KokioSmartAccountClient, calls: Call[]) => Promise<`0x${string}`>;
12
+ export declare const _toggleAccessToETH: (client: KokioSmartAccountClient, address: Address, eSIMWalletAddress: Address, hasAccessToETH: boolean) => Promise<`0x${string}`>;
13
+ /**
14
+ * Bind an eSIM wallet this device wallet already owns.
15
+ *
16
+ * A bind never carries ETH access: the contract reverts on a `true` rather than
17
+ * downgrading it quietly, so the SDK passes `false` and there is nothing to
18
+ * choose. `toggleAccessToETH` is the only way to grant it, which is what stops a
19
+ * bind from undoing the owner's revocation.
20
+ */
21
+ export declare const _addESIMWallet: (client: KokioSmartAccountClient, address: Address, eSIMWalletAddress: Address) => Promise<`0x${string}`>;
22
+ /**
23
+ * Release an eSIM wallet and put it on standby for a transfer.
24
+ *
25
+ * `callBackETH` sweeps whatever ETH the eSIM wallet still holds back here. It
26
+ * runs after the release, so a wallet whose handler misbehaves has already lost
27
+ * its ETH access and its registry association. A failed sweep is swallowed by
28
+ * the contract, so a `true` is not a promise that anything arrived.
29
+ */
30
+ export declare const _removeESIMWallet: (client: KokioSmartAccountClient, address: Address, eSIMWalletAddress: Address, callBackETH: boolean) => Promise<`0x${string}`>;
31
+ /**
32
+ * Rotate the P256 key that owns this wallet. The registry is told in the same
33
+ * call, so its record of the owner cannot drift from the wallet's.
34
+ *
35
+ * A key that cannot produce a verifiable signature bricks the wallet: this is
36
+ * reachable only through a signed userOp, so there is no rotating back and no
37
+ * reaching the balance afterwards. The contract rejects a key it can tell is
38
+ * unusable, but check the new key can sign before calling.
39
+ */
40
+ export declare const _transferOwnership: (client: KokioSmartAccountClient, address: Address, newOwner: P256Key) => Promise<`0x${string}`>;
41
+ /**
42
+ * Top up the gas deposit the EntryPoint holds for this wallet, from the wallet's
43
+ * own balance. Anyone may pay into any account's deposit, so an EOA can do this
44
+ * with a plain transfer too and not spend a userOp on it.
45
+ */
46
+ export declare const _addDeposit: (client: KokioSmartAccountClient, address: Address, amount: bigint) => Promise<`0x${string}`>;
47
+ /** Pull part of the EntryPoint gas deposit back out to any address. */
48
+ export declare const _withdrawDepositTo: (client: KokioSmartAccountClient, address: Address, withdrawAddress: Address, amount: bigint) => Promise<`0x${string}`>;
49
+ export declare const _getVaultAddress: (client: KokioSmartAccountClient, address: Address) => Promise<Address>;
50
+ /** Gas this wallet has on deposit at the EntryPoint. */
51
+ export declare const _getDeposit: (client: KokioSmartAccountClient, address: Address) => Promise<bigint>;
52
+ /** The device identifier this wallet was deployed for. Set once, at deploy. */
53
+ export declare const _deviceUniqueIdentifier: (client: KokioSmartAccountClient, address: Address) => Promise<string>;
54
+ /** Whether this wallet currently holds the given eSIM wallet. */
55
+ export declare const _isValidESIMWallet: (client: KokioSmartAccountClient, address: Address, eSIMWalletAddress: Address) => Promise<boolean>;
56
+ /**
57
+ * Whether an eSIM wallet may pull ETH from this one. Binding a wallet never
58
+ * grants it, so this stays false until `toggleAccessToETH` says otherwise.
59
+ */
60
+ export declare const _canPullETH: (client: KokioSmartAccountClient, address: Address, eSIMWalletAddress: Address) => Promise<boolean>;
61
+ /**
62
+ * Check a signature over an arbitrary message, per ERC-1271. Returns
63
+ * `0x1626ba7e` when the signature is valid and unexpired, `0xffffffff` otherwise.
64
+ *
65
+ * The signature is a version byte, then six bytes of `validUntil`, then the
66
+ * ABI-encoded WebAuthn assertion. What was signed is not `messageHash` itself but
67
+ * an EIP-191 digest over version, validUntil, chain id, this wallet's address and
68
+ * `messageHash`, so a signature cannot be replayed on another chain or against
69
+ * the same owner key's wallet at a different salt.
70
+ */
71
+ export declare const _isValidSignature: (client: KokioSmartAccountClient, address: Address, messageHash: Hex, signature: Hex) => Promise<Hex>;
72
+ /** The registry this wallet reports its ownership changes to. */
73
+ export declare const _registry: (client: KokioSmartAccountClient, address: Address) => Promise<Address>;
74
+ /** The factory that deploys this wallet's eSIM wallets. */
75
+ export declare const _eSIMWalletFactory: (client: KokioSmartAccountClient, address: Address) => Promise<Address>;
76
+ /** The ERC-4337 EntryPoint this wallet answers to. Immutable. */
77
+ export declare const _entryPoint: (client: KokioSmartAccountClient, address: Address) => Promise<Address>;
78
+ /** The P256 verifier used when the RIP-7212 precompile is unavailable. */
79
+ export declare const _verifier: (client: KokioSmartAccountClient, address: Address) => Promise<Address>;
8
80
  export declare const _getOwner: (client: WalletClient, address: Address) => Promise<P256Key>;