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
@@ -0,0 +1,95 @@
1
+ import { Address, Hex, WalletClient } from "viem";
2
+ import type { OperationOptions, OwnerCall, ScheduledBatchOperation, ScheduledOperation } from "../../types.js";
3
+ /** Schedules operations. Needs an EOA holding `PROPOSER_ROLE`. */
4
+ export declare class ProtocolAdminProposerSubPackage {
5
+ walletClient: WalletClient;
6
+ constructor(walletClient: WalletClient);
7
+ schedule(call: OwnerCall, opts?: OperationOptions, delay?: bigint): Promise<ScheduledOperation>;
8
+ scheduleBatch(calls: readonly OwnerCall[], opts?: OperationOptions, delay?: bigint): Promise<ScheduledBatchOperation>;
9
+ scheduleRaw(target: Address, value: bigint, payload: Hex, predecessor: Hex, salt: Hex, delay: bigint): Promise<ScheduledOperation>;
10
+ }
11
+ /** Runs operations whose delay has elapsed. Open to any funded EOA. */
12
+ export declare class ProtocolAdminExecutorSubPackage {
13
+ walletClient: WalletClient;
14
+ constructor(walletClient: WalletClient);
15
+ execute(operation: ScheduledOperation): Promise<`0x${string}`>;
16
+ executeBatch(operation: ScheduledBatchOperation): Promise<`0x${string}`>;
17
+ executeRaw(target: Address, value: bigint, payload: Hex, predecessor: Hex, salt: Hex): Promise<`0x${string}`>;
18
+ }
19
+ /** Drops a scheduled operation. Needs `CANCELLER_ROLE`, which proposers also hold. */
20
+ export declare class ProtocolAdminCancellerSubPackage {
21
+ walletClient: WalletClient;
22
+ constructor(walletClient: WalletClient);
23
+ cancel(id: Hex): Promise<`0x${string}`>;
24
+ }
25
+ /**
26
+ * The three instant powers. Needs `GUARDIAN_ROLE`.
27
+ *
28
+ * Each one takes something away and none grants anything, which is what keeps
29
+ * the role away from user funds. Undoing any of them is an owner action and
30
+ * waits, so the side taking power away wins the race against the side handing it
31
+ * back.
32
+ */
33
+ export declare class ProtocolAdminGuardianSubPackage {
34
+ walletClient: WalletClient;
35
+ constructor(walletClient: WalletClient);
36
+ unpauseInstantly(target: Address): Promise<`0x${string}`>;
37
+ revokeCancellersInstantly(accounts: readonly Address[]): Promise<`0x${string}`>;
38
+ disableAdminInstantly(target?: Address): Promise<`0x${string}`>;
39
+ }
40
+ /**
41
+ * The timelock that owns `Registry`, `LazyWalletRegistry`, `DeviceWalletFactory`
42
+ * and `ESIMWalletFactory`.
43
+ *
44
+ * Owner calls go one way: `proposer.schedule` announces one, the delay elapses,
45
+ * and `executor.execute` runs it. The role surfaces are separate because they
46
+ * need different keys, and `executor` needs no role at all.
47
+ *
48
+ * ```ts
49
+ * const op = await admin.protocolAdmin.proposer.schedule({
50
+ * address: registryAddress,
51
+ * abi: Registry,
52
+ * functionName: "updateVaultAddress",
53
+ * args: [newVault],
54
+ * });
55
+ * // ... wait out admin.protocolAdmin.getMinDelay() ...
56
+ * await admin.protocolAdmin.executor.execute(op);
57
+ * ```
58
+ */
59
+ export declare class AdminProtocolAdminSubPackage {
60
+ walletClient: WalletClient;
61
+ proposer: ProtocolAdminProposerSubPackage;
62
+ executor: ProtocolAdminExecutorSubPackage;
63
+ canceller: ProtocolAdminCancellerSubPackage;
64
+ guardian: ProtocolAdminGuardianSubPackage;
65
+ constructor(walletClient: WalletClient);
66
+ acceptOwnershipBatch(targets: readonly Address[]): Promise<`0x${string}`>;
67
+ renounceRole(role: Hex, account: Address): Promise<`0x${string}`>;
68
+ grantRoleCall(role: Hex, account: Address): Promise<OwnerCall>;
69
+ revokeRoleCall(role: Hex, account: Address): Promise<OwnerCall>;
70
+ updateDelayCall(newDelay: bigint): Promise<OwnerCall>;
71
+ disableAndNominateCall(target: Address, newAdmin: Address): Promise<OwnerCall>;
72
+ disableAdminCall(target?: Address): Promise<OwnerCall>;
73
+ enableAdminCall(target?: Address): Promise<OwnerCall>;
74
+ unpauseCall(target?: Address): Promise<OwnerCall>;
75
+ setDefaultDataBundlePriceCapCall(cap: bigint, target?: Address): Promise<OwnerCall>;
76
+ operationId(call: OwnerCall, opts?: OperationOptions): Promise<`0x${string}`>;
77
+ operationIdBatch(calls: readonly OwnerCall[], opts?: OperationOptions): Promise<`0x${string}`>;
78
+ operationIdRaw(target: Address, value: bigint, payload: Hex, predecessor: Hex, salt: Hex): Promise<`0x${string}`>;
79
+ operationIdBatchRaw(targets: readonly Address[], values: readonly bigint[], payloads: readonly Hex[], predecessor: Hex, salt: Hex): Promise<`0x${string}`>;
80
+ getMinDelay(): Promise<bigint>;
81
+ minDelayFloor(): Promise<bigint>;
82
+ getOperationState(id: Hex): Promise<import("../config-admin.js").OperationState>;
83
+ getTimestamp(id: Hex): Promise<bigint>;
84
+ isOperation(id: Hex): Promise<boolean>;
85
+ isOperationPending(id: Hex): Promise<boolean>;
86
+ isOperationReady(id: Hex): Promise<boolean>;
87
+ isOperationDone(id: Hex): Promise<boolean>;
88
+ hasRole(role: Hex, account: Address): Promise<boolean>;
89
+ getRoleAdmin(role: Hex): Promise<`0x${string}`>;
90
+ DEFAULT_ADMIN_ROLE(): Promise<`0x${string}`>;
91
+ PROPOSER_ROLE(): Promise<`0x${string}`>;
92
+ CANCELLER_ROLE(): Promise<`0x${string}`>;
93
+ EXECUTOR_ROLE(): Promise<`0x${string}`>;
94
+ GUARDIAN_ROLE(): Promise<`0x${string}`>;
95
+ }
@@ -4,7 +4,23 @@ export declare class AdminRegistrySubPackage {
4
4
  walletClient: WalletClient;
5
5
  constructor(walletClient: WalletClient);
6
6
  addOrUpdateLazyWalletRegistryAddress(lazyWalletRegistry: Address): Promise<`0x${string}`>;
7
+ updateVaultAddress(newVaultAddress: Address): Promise<`0x${string}`>;
8
+ requestAdminUpdate(newAdmin: Address): Promise<`0x${string}`>;
9
+ disableAdmin(): Promise<`0x${string}`>;
10
+ enableAdmin(): Promise<`0x${string}`>;
11
+ acceptAdminUpdate(): Promise<`0x${string}`>;
12
+ assignESIMIdentifier(eSIMWalletAddress: Address, eSIMUniqueIdentifier: string): Promise<`0x${string}`>;
13
+ pause(): Promise<`0x${string}`>;
14
+ unpause(): Promise<`0x${string}`>;
15
+ setDefaultDataBundlePriceCap(cap: bigint): Promise<`0x${string}`>;
16
+ acceptOwnership(): Promise<`0x${string}`>;
17
+ transferOwnershipCall(newOwner: Address): Promise<import("../../types.js").OwnerCall>;
18
+ upgradeCall(newImplementation: Address, data?: Hex): Promise<import("../../types.js").OwnerCall>;
19
+ owner(): Promise<`0x${string}`>;
7
20
  eSIMWalletAdmin(): Promise<`0x${string}`>;
21
+ adminOfRecord(): Promise<`0x${string}`>;
22
+ adminDisabled(): Promise<boolean>;
23
+ newRequestedAdmin(): Promise<`0x${string}`>;
8
24
  vault(): Promise<`0x${string}`>;
9
25
  upgradeManager(): Promise<`0x${string}`>;
10
26
  lazyWalletRegistry(): Promise<`0x${string}`>;
@@ -14,4 +30,18 @@ export declare class AdminRegistrySubPackage {
14
30
  isDeviceWalletValid(deviceWallet: Address): Promise<boolean>;
15
31
  isESIMWalletValid(eSIMWallet: Address): Promise<`0x${string}`>;
16
32
  isESIMWalletOnStandby(eSIMWallet: Address): Promise<boolean>;
33
+ paused(): Promise<boolean>;
34
+ defaultDataBundlePriceCap(): Promise<bigint>;
35
+ isDeviceIdentifierAlreadyUsed(deviceUniqueIdentifier: string): Promise<boolean>;
36
+ isESIMIdentifierClaimed(eSIMUniqueIdentifier: string): Promise<boolean>;
37
+ eSIMWalletForIdentifier(eSIMUniqueIdentifier: string): Promise<`0x${string}`>;
38
+ claimedESIMIdentifiers(hashOfESIMIdentifier: Hex): Promise<`0x${string}`>;
39
+ requireDeviceIdentifierNotReserved(deviceUniqueIdentifier: string): Promise<void>;
40
+ requireNotPaused(): Promise<void>;
41
+ pendingOwner(): Promise<`0x${string}`>;
42
+ deviceWalletFactory(): Promise<`0x${string}`>;
43
+ eSIMWalletFactory(): Promise<`0x${string}`>;
44
+ entryPoint(): Promise<`0x${string}`>;
45
+ proxiableUUID(): Promise<`0x${string}`>;
46
+ upgradeInterfaceVersion(): Promise<string>;
17
47
  }
@@ -3,29 +3,31 @@ import { KokioConstants } from "./interface/constantsClass.js";
3
3
  import { SmartAccountSubPackage } from "./interface/smartAccountClass.js";
4
4
  import { DeviceWalletFactorySubPackage } from "./interface/deviceWalletFactoryClass.js";
5
5
  import { P256VerifierSubPackage } from "./interface/P256VerifierClass.js";
6
- import { LazyWalletRegistrySubPackage } from "./interface/lazyWalletRegistryClass.js";
6
+ import { RegistrySubPackage } from "./interface/registryClass.js";
7
7
  import { DeviceWalletSubPackage } from "./interface/deviceWalletClass.js";
8
8
  import { ESIMWalletSubPackage } from "./interface/eSIMWalletClass.js";
9
9
  import { ESIMWalletFactorySubPackage } from "./interface/eSIMWalletFactoryClass.js";
10
- import { SmartAccountClient } from "@aa-sdk/core";
10
+ import { KokioSmartAccountClient } from "./types.js";
11
11
  export { KokioError, NullOrUndefinedValueError, MissingSmartWalletError, MissingEOAWalletError, InvalidClientError, UnsupportedChainError, UnconfiguredChainError, CounterfactualMismatchError, ContractRevertError, decodeContractRevert, } from "./logic/errors.js";
12
12
  export type { DecodedRevert } from "./logic/errors.js";
13
13
  export declare class Kokio {
14
14
  viemWalletClient: WalletClient;
15
15
  credentialId: string;
16
16
  rpId: string;
17
- organizationId: string;
18
17
  pimlicoAPIKey: string;
19
18
  gasPolicyId: string;
19
+ smartAccountClient?: KokioSmartAccountClient;
20
+ deviceWalletAddress?: Address;
21
+ eSIMWalletAddress?: Address;
20
22
  private _constants;
21
23
  smartAccount: SmartAccountSubPackage;
22
24
  deviceWalletFactory?: DeviceWalletFactorySubPackage;
23
25
  eSIMWalletFactory?: ESIMWalletFactorySubPackage;
24
- lazyWalletRegistry?: LazyWalletRegistrySubPackage;
26
+ registry?: RegistrySubPackage;
25
27
  deviceWallet?: DeviceWalletSubPackage;
26
28
  eSIMWallet?: ESIMWalletSubPackage;
27
29
  P256Verifier?: P256VerifierSubPackage;
28
- constructor(viemWalletClient: WalletClient, credentialId: string, rpId: string, organizationId: string, pimlicoAPIKey: string, gasPolicyId: string, smartAccountClient?: SmartAccountClient, deviceWalletAddress?: Address, eSIMWalletAddress?: Address);
30
+ constructor(viemWalletClient: WalletClient, credentialId: string, rpId: string, pimlicoAPIKey: string, gasPolicyId: string, smartAccountClient?: KokioSmartAccountClient, deviceWalletAddress?: Address, eSIMWalletAddress?: Address);
29
31
  /**
30
32
  * Chain-specific constants (factory addresses, chain, RPC URLs, custom errors)
31
33
  * for the wallet client's connected chain. Resolution is asynchronous because
@@ -36,4 +38,23 @@ export declare class Kokio {
36
38
  * The underlying value is memoized, so repeated awaits do not re-fetch.
37
39
  */
38
40
  get constants(): Promise<KokioConstants>;
41
+ /**
42
+ * Bind a `DeviceWallet` instance address after construction and (re)wire
43
+ * the `deviceWallet` surface to it. Returns `this` for chaining.
44
+ *
45
+ * Needs a `smartAccountClient` already on this instance - every write on
46
+ * `deviceWallet` sends a user operation through it. Without one,
47
+ * `deviceWallet` stays `undefined`, same as when no address is passed to
48
+ * the constructor.
49
+ */
50
+ setDeviceWalletAddress(deviceWalletAddress: Address): this;
51
+ /**
52
+ * Bind an `ESIMWallet` instance address after construction and (re)wire
53
+ * the `eSIMWallet` surface to it. Returns `this` for chaining.
54
+ *
55
+ * A user holding several eSIM wallets can call this to switch which one
56
+ * `kokio.eSIMWallet` acts on, without re-creating `Kokio`. Same
57
+ * `smartAccountClient` requirement as {@link setDeviceWalletAddress}.
58
+ */
59
+ setESIMWalletAddress(eSIMWalletAddress: Address): this;
39
60
  }
@@ -1,8 +1,7 @@
1
1
  import { Hex } from "viem";
2
- import { WebAuthnSignature } from "../types";
3
- import { SmartAccountClient } from "@aa-sdk/core";
2
+ import { WebAuthnSignature, KokioSmartAccountClient } from "../types.js";
4
3
  export declare class P256VerifierSubPackage {
5
- client: SmartAccountClient;
6
- constructor(client: SmartAccountClient);
4
+ client: KokioSmartAccountClient;
5
+ constructor(client: KokioSmartAccountClient);
7
6
  verifySignature(message: Hex, requireMessageVerification: boolean, webAuthnSignature: WebAuthnSignature, x: bigint, y: bigint): Promise<boolean>;
8
7
  }
@@ -16,9 +16,9 @@ export interface KokioConstants {
16
16
  */
17
17
  export declare class ConstantsSubPackage {
18
18
  private client;
19
- private pimlicoAPIKey;
19
+ private pimlicoAPIKey?;
20
20
  private cache?;
21
- constructor(client: WalletClient, pimlicoAPIKey: string);
21
+ constructor(client: WalletClient, pimlicoAPIKey?: string);
22
22
  /**
23
23
  * Resolves and caches the chain-specific constants. Subsequent calls
24
24
  * return the same promise, so the chain id is only fetched once.