kokio-sdk 3.0.2 → 3.1.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 (49) hide show
  1. package/README.md +15 -15
  2. package/dist/esm/admin/config-admin.js +1 -1
  3. package/dist/esm/config.js +1 -1
  4. package/dist/esm/interface/deviceWalletClass.js +10 -1
  5. package/dist/esm/interface/eSIMWalletClass.js +9 -1
  6. package/dist/esm/interface/eSIMWalletFactoryClass.js +9 -1
  7. package/dist/esm/interface/registryClass.js +8 -0
  8. package/dist/esm/interface/smartAccountClass.js +9 -2
  9. package/dist/esm/logic/P256Verifier.js +2 -2
  10. package/dist/esm/logic/account-kit/createSmartAccount.js +47 -36
  11. package/dist/esm/logic/admin/deviceWallet.eoa.js +5 -5
  12. package/dist/esm/logic/admin/deviceWalletFactory.eoa.js +13 -13
  13. package/dist/esm/logic/admin/eSIMWallet.eoa.js +3 -3
  14. package/dist/esm/logic/admin/eSIMWalletFactory.eoa.js +9 -9
  15. package/dist/esm/logic/admin/lazyWalletRegistry.eoa.js +13 -13
  16. package/dist/esm/logic/admin/paymentAdapter.eoa.js +11 -11
  17. package/dist/esm/logic/admin/protocolAdmin.eoa.js +14 -14
  18. package/dist/esm/logic/admin/reads/deviceWalletFactory.reads.js +9 -9
  19. package/dist/esm/logic/admin/reads/eSIMWalletFactory.reads.js +7 -7
  20. package/dist/esm/logic/admin/reads/lazyWalletRegistry.reads.js +18 -18
  21. package/dist/esm/logic/admin/reads/paymentAdapter.reads.js +8 -8
  22. package/dist/esm/logic/admin/reads/protocolAdmin.reads.js +2 -2
  23. package/dist/esm/logic/admin/reads/registry.reads.js +31 -31
  24. package/dist/esm/logic/admin/registry.eoa.js +27 -27
  25. package/dist/esm/logic/constants.js +14 -1
  26. package/dist/esm/logic/deviceWallet.js +35 -1
  27. package/dist/esm/logic/deviceWalletFactory.js +11 -11
  28. package/dist/esm/logic/eSIMWallet.js +50 -2
  29. package/dist/esm/logic/eSIMWalletFactory.js +15 -3
  30. package/dist/esm/logic/errors.js +15 -9
  31. package/dist/esm/logic/paymentAdapter.js +8 -8
  32. package/dist/esm/logic/registry.js +17 -17
  33. package/dist/esm/logic/utils.js +1 -81
  34. package/dist/types/admin/config-admin.d.ts +1 -1
  35. package/dist/types/config.d.ts +1 -1
  36. package/dist/types/interface/deviceWalletClass.d.ts +12 -0
  37. package/dist/types/interface/eSIMWalletClass.d.ts +6 -0
  38. package/dist/types/interface/eSIMWalletFactoryClass.d.ts +6 -0
  39. package/dist/types/interface/registryClass.d.ts +8 -0
  40. package/dist/types/interface/smartAccountClass.d.ts +10 -1
  41. package/dist/types/logic/account-kit/createSmartAccount.d.ts +1 -1
  42. package/dist/types/logic/constants.d.ts +3 -0
  43. package/dist/types/logic/deviceWallet.d.ts +12 -0
  44. package/dist/types/logic/eSIMWallet.d.ts +8 -0
  45. package/dist/types/logic/eSIMWalletFactory.d.ts +2 -0
  46. package/dist/types/logic/errors.d.ts +6 -5
  47. package/dist/types/logic/utils.d.ts +0 -21
  48. package/dist/types/types.d.ts +1 -1
  49. package/package.json +21 -7
@@ -1,5 +1,5 @@
1
1
  import { BaseError, ContractFunctionRevertedError, isAddressEqual, parseEventLogs, publicActions, } from "viem";
2
- import { _getChainSpecificConstants } from "../constants.js";
2
+ import { _chainId, _getChainSpecificConstants } from "../constants.js";
3
3
  import { BatchSizeOutOfRangeError, DepositOnResumeError, ESIMWalletNotLazyDeployedError, MissingBatchEventError, MissingEOAWalletError, StalledBatchError, writeContractOrThrow, } from "../errors.js";
4
4
  import { LazyWalletRegistry, Registry } from "../../abis/index.js";
5
5
  import { _eSIMWalletsDeployed, _lazyDeployedESIMWallet } from "./reads/lazyWalletRegistry.reads.js";
@@ -33,7 +33,7 @@ export const MAX_HISTORY_ENTRIES_PER_CALL = 50n;
33
33
  export const DEFAULT_ESIM_WALLETS_PER_CALL = 10n;
34
34
  export const DEFAULT_HISTORY_ENTRIES_PER_CALL = 25n;
35
35
  const _resolve = async (client) => {
36
- const chainID = await client.getChainId();
36
+ const chainID = await _chainId(client);
37
37
  const rpcURL = client.transport.url;
38
38
  return _getChainSpecificConstants(chainID, rpcURL);
39
39
  };
@@ -48,7 +48,7 @@ export const _batchPopulateHistory = async (client, deviceUniqueIdentifiers, eSI
48
48
  return writeContractOrThrow(client, {
49
49
  address: values.factoryAddresses.LAZY_WALLET_REGISTRY,
50
50
  chain: values.chain,
51
- account: client.account.address,
51
+ account: client.account,
52
52
  abi: LazyWalletRegistry,
53
53
  functionName: 'batchPopulateHistory',
54
54
  args: [deviceUniqueIdentifiers, eSIMUniqueIdentifiers, dataBundleDetails]
@@ -70,7 +70,7 @@ export const _deployLazyWalletAndSetESIMIdentifier = async (client, deviceOwnerP
70
70
  return writeContractOrThrow(client, {
71
71
  address: values.factoryAddresses.LAZY_WALLET_REGISTRY,
72
72
  chain: values.chain,
73
- account: client.account.address,
73
+ account: client.account,
74
74
  abi: LazyWalletRegistry,
75
75
  functionName: 'deployLazyWalletAndSetESIMIdentifier',
76
76
  args: [deviceOwnerPublicKey, deviceUniqueIdentifier, salt, depositAmount, maxWallets],
@@ -93,7 +93,7 @@ export const _deployMoreESIMWalletsForLazyDevice = async (client, deviceUniqueId
93
93
  return writeContractOrThrow(client, {
94
94
  address: values.factoryAddresses.LAZY_WALLET_REGISTRY,
95
95
  chain: values.chain,
96
- account: client.account.address,
96
+ account: client.account,
97
97
  abi: LazyWalletRegistry,
98
98
  functionName: 'deployMoreESIMWalletsForLazyDevice',
99
99
  args: [deviceUniqueIdentifier, maxWallets]
@@ -113,7 +113,7 @@ export const _setHistoryForLazyWallet = async (client, eSIMIdentifier, maxEntrie
113
113
  return writeContractOrThrow(client, {
114
114
  address: values.factoryAddresses.LAZY_WALLET_REGISTRY,
115
115
  chain: values.chain,
116
- account: client.account.address,
116
+ account: client.account,
117
117
  abi: LazyWalletRegistry,
118
118
  functionName: 'setHistoryForLazyWallet',
119
119
  args: [eSIMIdentifier, maxEntries]
@@ -127,7 +127,7 @@ export const _switchESIMIdentifierToNewDeviceIdentifier = async (client, eSIMIde
127
127
  return writeContractOrThrow(client, {
128
128
  address: values.factoryAddresses.LAZY_WALLET_REGISTRY,
129
129
  chain: values.chain,
130
- account: client.account.address,
130
+ account: client.account,
131
131
  abi: LazyWalletRegistry,
132
132
  functionName: 'switchESIMIdentifierToNewDeviceIdentifier',
133
133
  args: [eSIMIdentifier, oldDeviceIdentifier, newDeviceIdentifier]
@@ -227,7 +227,7 @@ export const _deployLazyWalletAllBatches = async (client, deviceOwnerPublicKey,
227
227
  abi: LazyWalletRegistry,
228
228
  functionName: "deployMoreESIMWalletsForLazyDevice",
229
229
  args: [deviceUniqueIdentifier, maxWallets],
230
- account: client.account.address,
230
+ account: client.account,
231
231
  }, "AllESIMWalletsDeployed");
232
232
  if (finished) {
233
233
  return { deviceWallet, eSIMWallets: [], eSIMIdentifiers: [], batches: [], alreadyComplete: true };
@@ -287,7 +287,7 @@ export const _setHistoryForLazyWalletAllBatches = async (client, eSIMIdentifier,
287
287
  abi: LazyWalletRegistry,
288
288
  functionName: "setHistoryForLazyWallet",
289
289
  args: [eSIMIdentifier, maxEntries],
290
- account: client.account.address,
290
+ account: client.account,
291
291
  }, "HistoryAlreadyCopied");
292
292
  if (finished)
293
293
  return { eSIMWallet, copied: 0n, batches: [], alreadyComplete: true };
@@ -318,7 +318,7 @@ export const _setHistoryForLazyWalletAllBatches = async (client, eSIMIdentifier,
318
318
  * `acceptOwnership`. Until then the current owner keeps every power.
319
319
  */
320
320
  export const _transferOwnershipCall = async (client, newOwner) => {
321
- const chainID = await client.getChainId();
321
+ const chainID = await _chainId(client);
322
322
  const rpcURL = client.transport.url;
323
323
  const values = _getChainSpecificConstants(chainID, rpcURL);
324
324
  return {
@@ -338,7 +338,7 @@ export const _transferOwnershipCall = async (client, newOwner) => {
338
338
  * where a `reinitializer` goes.
339
339
  */
340
340
  export const _upgradeCall = async (client, newImplementation, data = '0x') => {
341
- const chainID = await client.getChainId();
341
+ const chainID = await _chainId(client);
342
342
  const rpcURL = client.transport.url;
343
343
  const values = _getChainSpecificConstants(chainID, rpcURL);
344
344
  return {
@@ -357,7 +357,7 @@ export const _upgradeCall = async (client, newImplementation, data = '0x') => {
357
357
  * at once.
358
358
  */
359
359
  export const _acceptOwnership = async (client) => {
360
- const chainID = await client.getChainId();
360
+ const chainID = await _chainId(client);
361
361
  const rpcURL = client.transport.url;
362
362
  const values = _getChainSpecificConstants(chainID, rpcURL);
363
363
  if (!client.account)
@@ -365,7 +365,7 @@ export const _acceptOwnership = async (client) => {
365
365
  return writeContractOrThrow(client, {
366
366
  address: values.factoryAddresses.LAZY_WALLET_REGISTRY,
367
367
  chain: values.chain,
368
- account: client.account.address,
368
+ account: client.account,
369
369
  abi: LazyWalletRegistry,
370
370
  functionName: 'acceptOwnership',
371
371
  args: []
@@ -1,4 +1,4 @@
1
- import { _getChainSpecificConstants } from "../constants.js";
1
+ import { _chainId, _getChainSpecificConstants } from "../constants.js";
2
2
  import { MissingEOAWalletError, writeContractOrThrow } from "../errors.js";
3
3
  import { PaymentAdapter } from "../../abis/index.js";
4
4
  // Admin-EOA logic for `PaymentAdapter`. `registerAsset`/`updateAsset` are
@@ -9,7 +9,7 @@ import { PaymentAdapter } from "../../abis/index.js";
9
9
  // `protocolAdmin.proposer.schedule` instead, via the payload builders below.
10
10
  /** Add a currency the adapter has never seen. Reverts if `_symbol` is already registered. Owner only. */
11
11
  export const _registerAsset = async (client, symbol, asset) => {
12
- const chainID = await client.getChainId();
12
+ const chainID = await _chainId(client);
13
13
  const rpcURL = client.transport.url;
14
14
  const values = _getChainSpecificConstants(chainID, rpcURL);
15
15
  if (!client.account)
@@ -17,7 +17,7 @@ export const _registerAsset = async (client, symbol, asset) => {
17
17
  return writeContractOrThrow(client, {
18
18
  address: values.factoryAddresses.PAYMENT_ADAPTER,
19
19
  chain: values.chain,
20
- account: client.account.address,
20
+ account: client.account,
21
21
  abi: PaymentAdapter,
22
22
  functionName: 'registerAsset',
23
23
  args: [symbol, asset]
@@ -25,7 +25,7 @@ export const _registerAsset = async (client, symbol, asset) => {
25
25
  };
26
26
  /** Change a currency already in the table (its decimals, token, or allowed flag). Owner only. */
27
27
  export const _updateAsset = async (client, symbol, asset) => {
28
- const chainID = await client.getChainId();
28
+ const chainID = await _chainId(client);
29
29
  const rpcURL = client.transport.url;
30
30
  const values = _getChainSpecificConstants(chainID, rpcURL);
31
31
  if (!client.account)
@@ -33,7 +33,7 @@ export const _updateAsset = async (client, symbol, asset) => {
33
33
  return writeContractOrThrow(client, {
34
34
  address: values.factoryAddresses.PAYMENT_ADAPTER,
35
35
  chain: values.chain,
36
- account: client.account.address,
36
+ account: client.account,
37
37
  abi: PaymentAdapter,
38
38
  functionName: 'updateAsset',
39
39
  args: [symbol, asset]
@@ -47,7 +47,7 @@ export const _updateAsset = async (client, symbol, asset) => {
47
47
  // `OwnerCall` to hand to `protocolAdmin.schedule`.
48
48
  /** Add or change a currency, scheduled through the timelock. Pass the result to `schedule`. */
49
49
  export const _registerAssetCall = async (client, symbol, asset) => {
50
- const chainID = await client.getChainId();
50
+ const chainID = await _chainId(client);
51
51
  const rpcURL = client.transport.url;
52
52
  const values = _getChainSpecificConstants(chainID, rpcURL);
53
53
  return {
@@ -59,7 +59,7 @@ export const _registerAssetCall = async (client, symbol, asset) => {
59
59
  };
60
60
  /** Change a currency already in the table, scheduled through the timelock. Pass the result to `schedule`. */
61
61
  export const _updateAssetCall = async (client, symbol, asset) => {
62
- const chainID = await client.getChainId();
62
+ const chainID = await _chainId(client);
63
63
  const rpcURL = client.transport.url;
64
64
  const values = _getChainSpecificConstants(chainID, rpcURL);
65
65
  return {
@@ -76,7 +76,7 @@ export const _updateAssetCall = async (client, symbol, asset) => {
76
76
  * `acceptOwnership`.
77
77
  */
78
78
  export const _transferOwnershipCall = async (client, newOwner) => {
79
- const chainID = await client.getChainId();
79
+ const chainID = await _chainId(client);
80
80
  const rpcURL = client.transport.url;
81
81
  const values = _getChainSpecificConstants(chainID, rpcURL);
82
82
  return {
@@ -88,7 +88,7 @@ export const _transferOwnershipCall = async (client, newOwner) => {
88
88
  };
89
89
  /** Point the adapter's proxy at a new implementation. Builds `upgradeToAndCall`. Pass the result to `schedule`. */
90
90
  export const _upgradeCall = async (client, newImplementation, data = '0x') => {
91
- const chainID = await client.getChainId();
91
+ const chainID = await _chainId(client);
92
92
  const rpcURL = client.transport.url;
93
93
  const values = _getChainSpecificConstants(chainID, rpcURL);
94
94
  return {
@@ -107,7 +107,7 @@ export const _upgradeCall = async (client, newImplementation, data = '0x') => {
107
107
  * contract at once.
108
108
  */
109
109
  export const _acceptOwnership = async (client) => {
110
- const chainID = await client.getChainId();
110
+ const chainID = await _chainId(client);
111
111
  const rpcURL = client.transport.url;
112
112
  const values = _getChainSpecificConstants(chainID, rpcURL);
113
113
  if (!client.account)
@@ -115,7 +115,7 @@ export const _acceptOwnership = async (client) => {
115
115
  return writeContractOrThrow(client, {
116
116
  address: values.factoryAddresses.PAYMENT_ADAPTER,
117
117
  chain: values.chain,
118
- account: client.account.address,
118
+ account: client.account,
119
119
  abi: PaymentAdapter,
120
120
  functionName: 'acceptOwnership',
121
121
  args: []
@@ -1,5 +1,5 @@
1
1
  import { encodeFunctionData, publicActions } from "viem";
2
- import { _getChainSpecificConstants } from "../constants.js";
2
+ import { _chainId, _getChainSpecificConstants } from "../constants.js";
3
3
  import { MissingEOAWalletError, writeContractOrThrow } from "../errors.js";
4
4
  import { ProtocolAdmin, Registry } from "../../abis/index.js";
5
5
  // Admin-EOA logic for `ProtocolAdmin`, the timelock that owns `Registry`,
@@ -14,7 +14,7 @@ import { ProtocolAdmin, Registry } from "../../abis/index.js";
14
14
  // straight away with no delay.
15
15
  const ZERO_BYTES32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
16
16
  const _resolve = async (client) => {
17
- const chainID = await client.getChainId();
17
+ const chainID = await _chainId(client);
18
18
  const rpcURL = client.transport.url;
19
19
  return _getChainSpecificConstants(chainID, rpcURL);
20
20
  };
@@ -119,7 +119,7 @@ export const _schedule = async (client, call, opts = {}, delay) => {
119
119
  const hash = await writeContractOrThrow(client, {
120
120
  address: values.factoryAddresses.PROTOCOL_ADMIN,
121
121
  chain: values.chain,
122
- account: client.account.address,
122
+ account: client.account,
123
123
  abi: ProtocolAdmin,
124
124
  functionName: 'schedule',
125
125
  args: [target, value, payload, predecessor, salt, resolvedDelay]
@@ -159,7 +159,7 @@ export const _scheduleBatch = async (client, calls, opts = {}, delay) => {
159
159
  const hash = await writeContractOrThrow(client, {
160
160
  address: values.factoryAddresses.PROTOCOL_ADMIN,
161
161
  chain: values.chain,
162
- account: client.account.address,
162
+ account: client.account,
163
163
  abi: ProtocolAdmin,
164
164
  functionName: 'scheduleBatch',
165
165
  args: [targets, callValues, payloads, predecessor, salt, resolvedDelay]
@@ -186,7 +186,7 @@ export const _scheduleRaw = async (client, target, value, payload, predecessor,
186
186
  const hash = await writeContractOrThrow(client, {
187
187
  address: values.factoryAddresses.PROTOCOL_ADMIN,
188
188
  chain: values.chain,
189
- account: client.account.address,
189
+ account: client.account,
190
190
  abi: ProtocolAdmin,
191
191
  functionName: 'schedule',
192
192
  args: [target, value, payload, predecessor, salt, delay]
@@ -211,7 +211,7 @@ export const _execute = async (client, operation) => {
211
211
  return writeContractOrThrow(client, {
212
212
  address: values.factoryAddresses.PROTOCOL_ADMIN,
213
213
  chain: values.chain,
214
- account: client.account.address,
214
+ account: client.account,
215
215
  abi: ProtocolAdmin,
216
216
  functionName: 'execute',
217
217
  args: [operation.target, operation.value, operation.payload, operation.predecessor, operation.salt],
@@ -226,7 +226,7 @@ export const _executeBatch = async (client, operation) => {
226
226
  return writeContractOrThrow(client, {
227
227
  address: values.factoryAddresses.PROTOCOL_ADMIN,
228
228
  chain: values.chain,
229
- account: client.account.address,
229
+ account: client.account,
230
230
  abi: ProtocolAdmin,
231
231
  functionName: 'executeBatch',
232
232
  args: [operation.targets, operation.values, operation.payloads, operation.predecessor, operation.salt],
@@ -241,7 +241,7 @@ export const _executeRaw = async (client, target, value, payload, predecessor, s
241
241
  return writeContractOrThrow(client, {
242
242
  address: values.factoryAddresses.PROTOCOL_ADMIN,
243
243
  chain: values.chain,
244
- account: client.account.address,
244
+ account: client.account,
245
245
  abi: ProtocolAdmin,
246
246
  functionName: 'execute',
247
247
  args: [target, value, payload, predecessor, salt],
@@ -262,7 +262,7 @@ export const _cancel = async (client, id) => {
262
262
  return writeContractOrThrow(client, {
263
263
  address: values.factoryAddresses.PROTOCOL_ADMIN,
264
264
  chain: values.chain,
265
- account: client.account.address,
265
+ account: client.account,
266
266
  abi: ProtocolAdmin,
267
267
  functionName: 'cancel',
268
268
  args: [id]
@@ -284,7 +284,7 @@ export const _unpauseInstantly = async (client, target) => {
284
284
  return writeContractOrThrow(client, {
285
285
  address: values.factoryAddresses.PROTOCOL_ADMIN,
286
286
  chain: values.chain,
287
- account: client.account.address,
287
+ account: client.account,
288
288
  abi: ProtocolAdmin,
289
289
  functionName: 'unpauseInstantly',
290
290
  args: [target]
@@ -304,7 +304,7 @@ export const _revokeCancellersInstantly = async (client, accounts) => {
304
304
  return writeContractOrThrow(client, {
305
305
  address: values.factoryAddresses.PROTOCOL_ADMIN,
306
306
  chain: values.chain,
307
- account: client.account.address,
307
+ account: client.account,
308
308
  abi: ProtocolAdmin,
309
309
  functionName: 'revokeCancellersInstantly',
310
310
  args: [accounts]
@@ -327,7 +327,7 @@ export const _disableAdminInstantly = async (client, target) => {
327
327
  return writeContractOrThrow(client, {
328
328
  address: values.factoryAddresses.PROTOCOL_ADMIN,
329
329
  chain: values.chain,
330
- account: client.account.address,
330
+ account: client.account,
331
331
  abi: ProtocolAdmin,
332
332
  functionName: 'disableAdminInstantly',
333
333
  args: [target ?? values.factoryAddresses.REGISTRY]
@@ -348,7 +348,7 @@ export const _acceptOwnershipBatch = async (client, targets) => {
348
348
  return writeContractOrThrow(client, {
349
349
  address: values.factoryAddresses.PROTOCOL_ADMIN,
350
350
  chain: values.chain,
351
- account: client.account.address,
351
+ account: client.account,
352
352
  abi: ProtocolAdmin,
353
353
  functionName: 'acceptOwnershipBatch',
354
354
  args: [targets]
@@ -365,7 +365,7 @@ export const _renounceRole = async (client, role, account) => {
365
365
  return writeContractOrThrow(client, {
366
366
  address: values.factoryAddresses.PROTOCOL_ADMIN,
367
367
  chain: values.chain,
368
- account: client.account.address,
368
+ account: client.account,
369
369
  abi: ProtocolAdmin,
370
370
  functionName: 'renounceRole',
371
371
  args: [role, account]
@@ -1,5 +1,5 @@
1
1
  import { publicActions } from "viem";
2
- import { _getChainSpecificConstants } from "../../constants.js";
2
+ import { _chainId, _getChainSpecificConstants } from "../../constants.js";
3
3
  import { DeviceWalletFactory } from "../../../abis/index.js";
4
4
  // Read-only admin logic for `DeviceWalletFactory` - the contract's public
5
5
  // storage getters and `view` functions, surfaced for the backend.
@@ -10,7 +10,7 @@ import { DeviceWalletFactory } from "../../../abis/index.js";
10
10
  // `MissingEOAWalletError` guard.
11
11
  /** The admin EOA (`eSIMWalletAdmin`) currently set on the factory. */
12
12
  export const _eSIMWalletAdmin = async (client) => {
13
- const chainID = await client.getChainId();
13
+ const chainID = await _chainId(client);
14
14
  const rpcURL = client.transport.url;
15
15
  const values = _getChainSpecificConstants(chainID, rpcURL);
16
16
  return client.extend(publicActions).readContract({
@@ -22,7 +22,7 @@ export const _eSIMWalletAdmin = async (client) => {
22
22
  };
23
23
  /** Whether a device wallet has been registered with the factory. */
24
24
  export const _deviceWalletInfoAdded = async (client, deviceWallet) => {
25
- const chainID = await client.getChainId();
25
+ const chainID = await _chainId(client);
26
26
  const rpcURL = client.transport.url;
27
27
  const values = _getChainSpecificConstants(chainID, rpcURL);
28
28
  return client.extend(publicActions).readContract({
@@ -34,7 +34,7 @@ export const _deviceWalletInfoAdded = async (client, deviceWallet) => {
34
34
  };
35
35
  /** The current device-wallet beacon implementation. */
36
36
  export const _getCurrentDeviceWalletImplementation = async (client) => {
37
- const chainID = await client.getChainId();
37
+ const chainID = await _chainId(client);
38
38
  const rpcURL = client.transport.url;
39
39
  const values = _getChainSpecificConstants(chainID, rpcURL);
40
40
  return client.extend(publicActions).readContract({
@@ -57,7 +57,7 @@ export const _getCurrentDeviceWalletImplementation = async (client) => {
57
57
  * Reverts on an empty identifier or a key that is not a point on the P256 curve.
58
58
  */
59
59
  export const _preCreateAccountValidation = async (client, deviceUniqueIdentifier, deviceWalletOwnerKey) => {
60
- const chainID = await client.getChainId();
60
+ const chainID = await _chainId(client);
61
61
  const rpcURL = client.transport.url;
62
62
  const values = _getChainSpecificConstants(chainID, rpcURL);
63
63
  return client.extend(publicActions).readContract({
@@ -68,7 +68,7 @@ export const _preCreateAccountValidation = async (client, deviceUniqueIdentifier
68
68
  });
69
69
  };
70
70
  const _addressGetter = async (client, functionName) => {
71
- const chainID = await client.getChainId();
71
+ const chainID = await _chainId(client);
72
72
  const rpcURL = client.transport.url;
73
73
  const values = _getChainSpecificConstants(chainID, rpcURL);
74
74
  return client.extend(publicActions).readContract({
@@ -106,7 +106,7 @@ export const _pendingOwner = (client) => _addressGetter(client, "pendingOwner");
106
106
  * arg order is `(ownerKey, uid, salt)` - note this differs from `createAccount`.
107
107
  */
108
108
  export const _getCounterFactualAddress = async (client, deviceWalletOwnerKey, deviceUniqueIdentifier, salt) => {
109
- const chainID = await client.getChainId();
109
+ const chainID = await _chainId(client);
110
110
  const rpcURL = client.transport.url;
111
111
  const values = _getChainSpecificConstants(chainID, rpcURL);
112
112
  return client.extend(publicActions).readContract({
@@ -122,7 +122,7 @@ export const _getCounterFactualAddress = async (client, deviceWalletOwnerKey, de
122
122
  * is what stops a non-UUPS address being installed.
123
123
  */
124
124
  export const _proxiableUUID = async (client) => {
125
- const chainID = await client.getChainId();
125
+ const chainID = await _chainId(client);
126
126
  const rpcURL = client.transport.url;
127
127
  const values = _getChainSpecificConstants(chainID, rpcURL);
128
128
  return client.extend(publicActions).readContract({
@@ -134,7 +134,7 @@ export const _proxiableUUID = async (client) => {
134
134
  };
135
135
  /** The OpenZeppelin upgrade interface this proxy speaks, currently `"5.0.0"`. */
136
136
  export const _upgradeInterfaceVersion = async (client) => {
137
- const chainID = await client.getChainId();
137
+ const chainID = await _chainId(client);
138
138
  const rpcURL = client.transport.url;
139
139
  const values = _getChainSpecificConstants(chainID, rpcURL);
140
140
  return client.extend(publicActions).readContract({
@@ -1,12 +1,12 @@
1
1
  import { publicActions } from "viem";
2
- import { _getChainSpecificConstants } from "../../constants.js";
2
+ import { _chainId, _getChainSpecificConstants } from "../../constants.js";
3
3
  import { ESIMWalletFactory } from "../../../abis/index.js";
4
4
  // Read-only admin logic for `ESIMWalletFactory` - its public storage getter and
5
5
  // `view` function, surfaced for the backend. Each read extends the `WalletClient`
6
6
  // with `publicActions` (no EOA account required).
7
7
  /** Whether an eSIM wallet was deployed by this factory. */
8
8
  export const _isESIMWalletDeployed = async (client, eSIMWallet) => {
9
- const chainID = await client.getChainId();
9
+ const chainID = await _chainId(client);
10
10
  const rpcURL = client.transport.url;
11
11
  const values = _getChainSpecificConstants(chainID, rpcURL);
12
12
  return client.extend(publicActions).readContract({
@@ -18,7 +18,7 @@ export const _isESIMWalletDeployed = async (client, eSIMWallet) => {
18
18
  };
19
19
  /** The current eSIM-wallet beacon implementation. */
20
20
  export const _getCurrentESIMWalletImplementation = async (client) => {
21
- const chainID = await client.getChainId();
21
+ const chainID = await _chainId(client);
22
22
  const rpcURL = client.transport.url;
23
23
  const values = _getChainSpecificConstants(chainID, rpcURL);
24
24
  return client.extend(publicActions).readContract({
@@ -34,7 +34,7 @@ export const _getCurrentESIMWalletImplementation = async (client) => {
34
34
  * is what stops a non-UUPS address being installed.
35
35
  */
36
36
  export const _proxiableUUID = async (client) => {
37
- const chainID = await client.getChainId();
37
+ const chainID = await _chainId(client);
38
38
  const rpcURL = client.transport.url;
39
39
  const values = _getChainSpecificConstants(chainID, rpcURL);
40
40
  return client.extend(publicActions).readContract({
@@ -46,7 +46,7 @@ export const _proxiableUUID = async (client) => {
46
46
  };
47
47
  /** The OpenZeppelin upgrade interface this proxy speaks, currently `"5.0.0"`. */
48
48
  export const _upgradeInterfaceVersion = async (client) => {
49
- const chainID = await client.getChainId();
49
+ const chainID = await _chainId(client);
50
50
  const rpcURL = client.transport.url;
51
51
  const values = _getChainSpecificConstants(chainID, rpcURL);
52
52
  return client.extend(publicActions).readContract({
@@ -62,7 +62,7 @@ export const _upgradeInterfaceVersion = async (client) => {
62
62
  * be scheduled instead.
63
63
  */
64
64
  export const _owner = async (client) => {
65
- const chainID = await client.getChainId();
65
+ const chainID = await _chainId(client);
66
66
  const rpcURL = client.transport.url;
67
67
  const values = _getChainSpecificConstants(chainID, rpcURL);
68
68
  return client.extend(publicActions).readContract({
@@ -78,7 +78,7 @@ export const _owner = async (client) => {
78
78
  * been offered to the timelock.
79
79
  */
80
80
  export const _pendingOwner = async (client) => {
81
- const chainID = await client.getChainId();
81
+ const chainID = await _chainId(client);
82
82
  const rpcURL = client.transport.url;
83
83
  const values = _getChainSpecificConstants(chainID, rpcURL);
84
84
  return client.extend(publicActions).readContract({
@@ -1,5 +1,5 @@
1
1
  import { publicActions } from "viem";
2
- import { _getChainSpecificConstants } from "../../constants.js";
2
+ import { _chainId, _getChainSpecificConstants } from "../../constants.js";
3
3
  import { LazyWalletRegistry } from "../../../abis/index.js";
4
4
  // Read-only admin logic for `LazyWalletRegistry` - its public storage getters,
5
5
  // surfaced for the backend's fiat/lazy provisioning flows. Each read extends the
@@ -11,7 +11,7 @@ import { LazyWalletRegistry } from "../../../abis/index.js";
11
11
  // callers iterate indices to read the whole list (there is no full-array getter).
12
12
  /** The upgrade-manager (owner) EOA of the lazy registry. */
13
13
  export const _upgradeManager = async (client) => {
14
- const chainID = await client.getChainId();
14
+ const chainID = await _chainId(client);
15
15
  const rpcURL = client.transport.url;
16
16
  const values = _getChainSpecificConstants(chainID, rpcURL);
17
17
  return client.extend(publicActions).readContract({
@@ -23,7 +23,7 @@ export const _upgradeManager = async (client) => {
23
23
  };
24
24
  /** The device identifier an eSIM identifier is currently associated with. */
25
25
  export const _eSIMIdentifierToDeviceIdentifier = async (client, eSIMIdentifier) => {
26
- const chainID = await client.getChainId();
26
+ const chainID = await _chainId(client);
27
27
  const rpcURL = client.transport.url;
28
28
  const values = _getChainSpecificConstants(chainID, rpcURL);
29
29
  return client.extend(publicActions).readContract({
@@ -35,7 +35,7 @@ export const _eSIMIdentifierToDeviceIdentifier = async (client, eSIMIdentifier)
35
35
  };
36
36
  /** One data-bundle history entry for a (device, eSIM) pair, by array index. */
37
37
  export const _deviceIdentifierToESIMDetails = async (client, deviceIdentifier, eSIMIdentifier, index) => {
38
- const chainID = await client.getChainId();
38
+ const chainID = await _chainId(client);
39
39
  const rpcURL = client.transport.url;
40
40
  const values = _getChainSpecificConstants(chainID, rpcURL);
41
41
  const [id, priceUSDCents, settlement] = await client.extend(publicActions).readContract({
@@ -48,7 +48,7 @@ export const _deviceIdentifierToESIMDetails = async (client, deviceIdentifier, e
48
48
  };
49
49
  /** Most eSIM wallets one `deployLazyWalletAndSetESIMIdentifier` call will deploy. */
50
50
  export const _maxESIMWalletsPerCall = async (client) => {
51
- const chainID = await client.getChainId();
51
+ const chainID = await _chainId(client);
52
52
  const rpcURL = client.transport.url;
53
53
  const values = _getChainSpecificConstants(chainID, rpcURL);
54
54
  return client.extend(publicActions).readContract({
@@ -60,7 +60,7 @@ export const _maxESIMWalletsPerCall = async (client) => {
60
60
  };
61
61
  /** Most history entries one `setHistoryForLazyWallet` call will copy. */
62
62
  export const _maxHistoryEntriesPerCall = async (client) => {
63
- const chainID = await client.getChainId();
63
+ const chainID = await _chainId(client);
64
64
  const rpcURL = client.transport.url;
65
65
  const values = _getChainSpecificConstants(chainID, rpcURL);
66
66
  return client.extend(publicActions).readContract({
@@ -76,7 +76,7 @@ export const _maxHistoryEntriesPerCall = async (client) => {
76
76
  * the route itself.
77
77
  */
78
78
  export const _eSIMWalletsDeployed = async (client, deviceIdentifier) => {
79
- const chainID = await client.getChainId();
79
+ const chainID = await _chainId(client);
80
80
  const rpcURL = client.transport.url;
81
81
  const values = _getChainSpecificConstants(chainID, rpcURL);
82
82
  return client.extend(publicActions).readContract({
@@ -88,7 +88,7 @@ export const _eSIMWalletsDeployed = async (client, deviceIdentifier) => {
88
88
  };
89
89
  /** Salt the device's first deployment batch started from. Every later batch derives from it. */
90
90
  export const _lazyDeploymentSalt = async (client, deviceIdentifier) => {
91
- const chainID = await client.getChainId();
91
+ const chainID = await _chainId(client);
92
92
  const rpcURL = client.transport.url;
93
93
  const values = _getChainSpecificConstants(chainID, rpcURL);
94
94
  return client.extend(publicActions).readContract({
@@ -103,7 +103,7 @@ export const _lazyDeploymentSalt = async (client, deviceIdentifier) => {
103
103
  * did not deploy, which is what authorises the history copy.
104
104
  */
105
105
  export const _lazyDeployedESIMWallet = async (client, eSIMIdentifier) => {
106
- const chainID = await client.getChainId();
106
+ const chainID = await _chainId(client);
107
107
  const rpcURL = client.transport.url;
108
108
  const values = _getChainSpecificConstants(chainID, rpcURL);
109
109
  return client.extend(publicActions).readContract({
@@ -115,7 +115,7 @@ export const _lazyDeployedESIMWallet = async (client, eSIMIdentifier) => {
115
115
  };
116
116
  /** How many of an eSIM's stored purchase entries have already reached its wallet. */
117
117
  export const _historyEntriesCopied = async (client, eSIMIdentifier) => {
118
- const chainID = await client.getChainId();
118
+ const chainID = await _chainId(client);
119
119
  const rpcURL = client.transport.url;
120
120
  const values = _getChainSpecificConstants(chainID, rpcURL);
121
121
  return client.extend(publicActions).readContract({
@@ -132,7 +132,7 @@ export const _historyEntriesCopied = async (client, eSIMIdentifier) => {
132
132
  * has not arrived yet.
133
133
  */
134
134
  export const _outstandingHistoryEntries = async (client, eSIMIdentifier) => {
135
- const chainID = await client.getChainId();
135
+ const chainID = await _chainId(client);
136
136
  const rpcURL = client.transport.url;
137
137
  const values = _getChainSpecificConstants(chainID, rpcURL);
138
138
  return client.extend(publicActions).readContract({
@@ -144,7 +144,7 @@ export const _outstandingHistoryEntries = async (client, eSIMIdentifier) => {
144
144
  };
145
145
  /** Whether a device identifier has purchases recorded against it here. */
146
146
  export const _isDeviceIdentifierReserved = async (client, deviceIdentifier) => {
147
- const chainID = await client.getChainId();
147
+ const chainID = await _chainId(client);
148
148
  const rpcURL = client.transport.url;
149
149
  const values = _getChainSpecificConstants(chainID, rpcURL);
150
150
  return client.extend(publicActions).readContract({
@@ -156,7 +156,7 @@ export const _isDeviceIdentifierReserved = async (client, deviceIdentifier) => {
156
156
  };
157
157
  /** Whether an eSIM identifier is bound to a device here. */
158
158
  export const _isESIMIdentifierReserved = async (client, eSIMIdentifier) => {
159
- const chainID = await client.getChainId();
159
+ const chainID = await _chainId(client);
160
160
  const rpcURL = client.transport.url;
161
161
  const values = _getChainSpecificConstants(chainID, rpcURL);
162
162
  return client.extend(publicActions).readContract({
@@ -168,7 +168,7 @@ export const _isESIMIdentifierReserved = async (client, eSIMIdentifier) => {
168
168
  };
169
169
  /** One eSIM identifier associated with a device identifier, by array index. */
170
170
  export const _eSIMIdentifiersAssociatedWithDeviceIdentifier = async (client, deviceIdentifier, index) => {
171
- const chainID = await client.getChainId();
171
+ const chainID = await _chainId(client);
172
172
  const rpcURL = client.transport.url;
173
173
  const values = _getChainSpecificConstants(chainID, rpcURL);
174
174
  return client.extend(publicActions).readContract({
@@ -184,7 +184,7 @@ export const _eSIMIdentifiersAssociatedWithDeviceIdentifier = async (client, dev
184
184
  * is what stops a non-UUPS address being installed.
185
185
  */
186
186
  export const _proxiableUUID = async (client) => {
187
- const chainID = await client.getChainId();
187
+ const chainID = await _chainId(client);
188
188
  const rpcURL = client.transport.url;
189
189
  const values = _getChainSpecificConstants(chainID, rpcURL);
190
190
  return client.extend(publicActions).readContract({
@@ -196,7 +196,7 @@ export const _proxiableUUID = async (client) => {
196
196
  };
197
197
  /** The OpenZeppelin upgrade interface this proxy speaks, currently `"5.0.0"`. */
198
198
  export const _upgradeInterfaceVersion = async (client) => {
199
- const chainID = await client.getChainId();
199
+ const chainID = await _chainId(client);
200
200
  const rpcURL = client.transport.url;
201
201
  const values = _getChainSpecificConstants(chainID, rpcURL);
202
202
  return client.extend(publicActions).readContract({
@@ -212,7 +212,7 @@ export const _upgradeInterfaceVersion = async (client) => {
212
212
  * be scheduled instead.
213
213
  */
214
214
  export const _owner = async (client) => {
215
- const chainID = await client.getChainId();
215
+ const chainID = await _chainId(client);
216
216
  const rpcURL = client.transport.url;
217
217
  const values = _getChainSpecificConstants(chainID, rpcURL);
218
218
  return client.extend(publicActions).readContract({
@@ -228,7 +228,7 @@ export const _owner = async (client) => {
228
228
  * been offered to the timelock.
229
229
  */
230
230
  export const _pendingOwner = async (client) => {
231
- const chainID = await client.getChainId();
231
+ const chainID = await _chainId(client);
232
232
  const rpcURL = client.transport.url;
233
233
  const values = _getChainSpecificConstants(chainID, rpcURL);
234
234
  return client.extend(publicActions).readContract({