kokio-sdk 1.1.0 → 2.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 (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 +26 -15
  29. package/dist/esm/logic/admin/deviceWalletFactory.eoa.js +69 -48
  30. package/dist/esm/logic/admin/eSIMWallet.eoa.js +5 -7
  31. package/dist/esm/logic/admin/eSIMWalletFactory.eoa.js +79 -11
  32. package/dist/esm/logic/admin/lazyWalletRegistry.eoa.js +333 -22
  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 +276 -6
  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 +94 -1
  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 +61 -1
  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,15 +1,18 @@
1
1
  import { _getChainSpecificConstants } from "../constants.js";
2
- import { MissingEOAWalletError } from "../errors.js";
2
+ import { MissingEOAWalletError, writeContractOrThrow } from "../errors.js";
3
3
  import { DeviceWalletFactory } from "../../abis/index.js";
4
- /**
5
- * Admin-EOA logic for `DeviceWalletFactory`.
6
- *
7
- * Every function here is `onlyAdmin` / `onlyAdminOrRegistry` / `onlyOwner` on
8
- * chain, i.e. the caller must be the `eSIMWalletAdmin` (or `upgradeManager`)
9
- * EOA - never a device-wallet userOp. They therefore live on the EOA surface
10
- * (`KokioAdmin`) and use `writeContract`, mirroring `_createAccountWithEOA`
11
- * (which is reused as-is from `../deviceWalletFactory.js`).
12
- */
4
+ // Admin-EOA logic for `DeviceWalletFactory`.
5
+ //
6
+ // Every function here is `onlyAdmin` / `onlyAdminOrRegistry` / `onlyOwner` on
7
+ // chain, i.e. the caller must be the `eSIMWalletAdmin` (or `upgradeManager`)
8
+ // EOA - never a device-wallet userOp. They therefore live on the EOA surface
9
+ // (`KokioAdmin`) and use `writeContract`, mirroring `_createAccountWithEOA`
10
+ // (which is reused as-is from `../deviceWalletFactory.js`).
11
+ //
12
+ // On the live deployment the owner is the `ProtocolAdmin` timelock, not an EOA,
13
+ // so an `onlyOwner` call sent directly reverts. Route those through
14
+ // `protocolAdmin.proposer.schedule` instead. The direct path stays for
15
+ // deployments whose owner is a plain EOA or multisig.
13
16
  /**
14
17
  * Batch-deploy device wallets for lazy/fiat users. `onlyAdminOrRegistry`,
15
18
  * `payable`: `value` is the total ETH pot from which each `depositAmounts[i]`
@@ -21,7 +24,7 @@ export const _deployDeviceWalletForUsers = async (client, deviceUniqueIdentifier
21
24
  const values = _getChainSpecificConstants(chainID, rpcURL);
22
25
  if (!client.account)
23
26
  throw new MissingEOAWalletError();
24
- return client.writeContract({
27
+ return writeContractOrThrow(client, {
25
28
  address: values.factoryAddresses.DEVICE_WALLET_FACTORY,
26
29
  chain: values.chain,
27
30
  account: client.account.address,
@@ -31,20 +34,24 @@ export const _deployDeviceWalletForUsers = async (client, deviceUniqueIdentifier
31
34
  value
32
35
  });
33
36
  };
34
- /** Register a freshly created device wallet with the factory. `onlyAdminOrRegistry`. */
35
- export const _postCreateAccount = async (client, deviceWallet, deviceUniqueIdentifier, deviceWalletOwnerKey) => {
37
+ /**
38
+ * Register a freshly created device wallet with the factory. `onlyAdminOrRegistry`.
39
+ * The salt has to be the one the deploying `createAccount` used, since the
40
+ * factory rederives the counterfactual address from it to check the wallet.
41
+ */
42
+ export const _postCreateAccount = async (client, deviceWallet, deviceUniqueIdentifier, deviceWalletOwnerKey, salt) => {
36
43
  const chainID = await client.getChainId();
37
44
  const rpcURL = client.transport.url;
38
45
  const values = _getChainSpecificConstants(chainID, rpcURL);
39
46
  if (!client.account)
40
47
  throw new MissingEOAWalletError();
41
- return client.writeContract({
48
+ return writeContractOrThrow(client, {
42
49
  address: values.factoryAddresses.DEVICE_WALLET_FACTORY,
43
50
  chain: values.chain,
44
51
  account: client.account.address,
45
52
  abi: DeviceWalletFactory,
46
53
  functionName: 'postCreateAccount',
47
- args: [deviceWallet, deviceUniqueIdentifier, deviceWalletOwnerKey]
54
+ args: [deviceWallet, deviceUniqueIdentifier, deviceWalletOwnerKey, salt]
48
55
  });
49
56
  };
50
57
  /** One-time wiring of the registry into the factory. `onlyAdmin`. */
@@ -54,7 +61,7 @@ export const _addRegistryAddress = async (client, registryContractAddress) => {
54
61
  const values = _getChainSpecificConstants(chainID, rpcURL);
55
62
  if (!client.account)
56
63
  throw new MissingEOAWalletError();
57
- return client.writeContract({
64
+ return writeContractOrThrow(client, {
58
65
  address: values.factoryAddresses.DEVICE_WALLET_FACTORY,
59
66
  chain: values.chain,
60
67
  account: client.account.address,
@@ -63,71 +70,85 @@ export const _addRegistryAddress = async (client, registryContractAddress) => {
63
70
  args: [registryContractAddress]
64
71
  });
65
72
  };
66
- /** Update the vault that receives eSIM payments. `onlyAdmin`. */
67
- export const _updateVaultAddress = async (client, newVaultAddress) => {
73
+ /** Point the device-wallet beacon at a new implementation. `onlyOwner` (upgradeManager). */
74
+ export const _updateDeviceWalletImplementation = async (client, newDeviceImpl) => {
68
75
  const chainID = await client.getChainId();
69
76
  const rpcURL = client.transport.url;
70
77
  const values = _getChainSpecificConstants(chainID, rpcURL);
71
78
  if (!client.account)
72
79
  throw new MissingEOAWalletError();
73
- return client.writeContract({
80
+ return writeContractOrThrow(client, {
74
81
  address: values.factoryAddresses.DEVICE_WALLET_FACTORY,
75
82
  chain: values.chain,
76
83
  account: client.account.address,
77
84
  abi: DeviceWalletFactory,
78
- functionName: 'updateVaultAddress',
79
- args: [newVaultAddress]
85
+ functionName: 'updateDeviceWalletImplementation',
86
+ args: [newDeviceImpl]
80
87
  });
81
88
  };
82
- /** Step 1 of the 2-step admin handover: propose a new admin. `onlyAdmin`. */
83
- export const _requestAdminUpdate = async (client, newAdmin) => {
89
+ // ---------------------------------------------------------------------------
90
+ // Owner payloads - only reachable through schedule
91
+ // ---------------------------------------------------------------------------
92
+ // Both are `onlyOwner`, and on the live deployment the owner is the timelock, so
93
+ // they exist as something to schedule rather than to send. Each returns the
94
+ // `OwnerCall` to hand to `protocolAdmin.schedule`.
95
+ /**
96
+ * Offer ownership to a new address. Pass the result to `schedule`.
97
+ *
98
+ * Ownable2Step, so the offer changes nothing until the named address calls
99
+ * `acceptOwnership`. Note this hands over the beacon too, since the factory owns
100
+ * it, so the new owner can move every deployed device wallet at once.
101
+ */
102
+ export const _transferOwnershipCall = async (client, newOwner) => {
84
103
  const chainID = await client.getChainId();
85
104
  const rpcURL = client.transport.url;
86
105
  const values = _getChainSpecificConstants(chainID, rpcURL);
87
- if (!client.account)
88
- throw new MissingEOAWalletError();
89
- return client.writeContract({
106
+ return {
90
107
  address: values.factoryAddresses.DEVICE_WALLET_FACTORY,
91
- chain: values.chain,
92
- account: client.account.address,
93
108
  abi: DeviceWalletFactory,
94
- functionName: 'requestAdminUpdate',
95
- args: [newAdmin]
96
- });
109
+ functionName: 'transferOwnership',
110
+ args: [newOwner],
111
+ };
97
112
  };
98
113
  /**
99
- * Step 2 of the 2-step admin handover: the proposed admin accepts. The chain
100
- * requires `msg.sender` to equal the pending admin, so the `client` here must
101
- * be the newly proposed admin EOA.
114
+ * Point the factory's own proxy at a new implementation. Builds
115
+ * `upgradeToAndCall`. Pass the result to `schedule`.
116
+ *
117
+ * This does not touch deployed device wallets. They read their implementation
118
+ * from the beacon, which moves through `updateDeviceWalletImplementation`
119
+ * instead. Changing what the factory deploys next is a beacon update, not this.
102
120
  */
103
- export const _acceptAdminUpdate = async (client) => {
121
+ export const _upgradeCall = async (client, newImplementation, data = '0x') => {
104
122
  const chainID = await client.getChainId();
105
123
  const rpcURL = client.transport.url;
106
124
  const values = _getChainSpecificConstants(chainID, rpcURL);
107
- if (!client.account)
108
- throw new MissingEOAWalletError();
109
- return client.writeContract({
125
+ return {
110
126
  address: values.factoryAddresses.DEVICE_WALLET_FACTORY,
111
- chain: values.chain,
112
- account: client.account.address,
113
127
  abi: DeviceWalletFactory,
114
- functionName: 'acceptAdminUpdate',
115
- args: []
116
- });
128
+ functionName: 'upgradeToAndCall',
129
+ args: [newImplementation, data],
130
+ };
117
131
  };
118
- /** Point the device-wallet beacon at a new implementation. `onlyOwner` (upgradeManager). */
119
- export const _updateDeviceWalletImplementation = async (client, newDeviceImpl) => {
132
+ /**
133
+ * Take ownership after a `transferOwnership` named this client. `msg.sender`
134
+ * must equal `pendingOwner`, so the `client` is the incoming owner.
135
+ *
136
+ * Where the incoming owner is the timelock, use
137
+ * `protocolAdmin.acceptOwnershipBatch` instead, which accepts for every contract
138
+ * at once.
139
+ */
140
+ export const _acceptOwnership = async (client) => {
120
141
  const chainID = await client.getChainId();
121
142
  const rpcURL = client.transport.url;
122
143
  const values = _getChainSpecificConstants(chainID, rpcURL);
123
144
  if (!client.account)
124
145
  throw new MissingEOAWalletError();
125
- return client.writeContract({
146
+ return writeContractOrThrow(client, {
126
147
  address: values.factoryAddresses.DEVICE_WALLET_FACTORY,
127
148
  chain: values.chain,
128
149
  account: client.account.address,
129
150
  abi: DeviceWalletFactory,
130
- functionName: 'updateDeviceWalletImplementation',
131
- args: [newDeviceImpl]
151
+ functionName: 'acceptOwnership',
152
+ args: []
132
153
  });
133
154
  };
@@ -1,11 +1,9 @@
1
1
  import { _getChainSpecificConstants } from "../constants.js";
2
- import { MissingEOAWalletError } from "../errors.js";
2
+ import { MissingEOAWalletError, writeContractOrThrow } from "../errors.js";
3
3
  import { ESIMWallet } from "../../abis/index.js";
4
- /**
5
- * Admin-EOA logic targeting a specific `ESIMWallet` instance (address passed in).
6
- * `buyDataBundle` is `onlyDeviceWalletOrESIMWalletAdmin`, so the admin EOA can
7
- * call it directly.
8
- */
4
+ // Admin-EOA logic targeting a specific `ESIMWallet` instance (address passed in).
5
+ // `buyDataBundle` is `onlyDeviceWalletOrESIMWalletAdmin`, so the admin EOA can
6
+ // call it directly.
9
7
  /**
10
8
  * Buy a data bundle for an eSIM wallet. `onlyDeviceWalletOrESIMWalletAdmin`,
11
9
  * `payable`. `value` is optional: the contract pulls any shortfall from the
@@ -18,7 +16,7 @@ export const _buyDataBundle = async (client, eSIMWalletAddress, dataBundleDetail
18
16
  const values = _getChainSpecificConstants(chainID, rpcURL);
19
17
  if (!client.account)
20
18
  throw new MissingEOAWalletError();
21
- return client.writeContract({
19
+ return writeContractOrThrow(client, {
22
20
  address: eSIMWalletAddress,
23
21
  chain: values.chain,
24
22
  account: client.account.address,
@@ -1,14 +1,17 @@
1
1
  import { _getChainSpecificConstants } from "../constants.js";
2
- import { MissingEOAWalletError } from "../errors.js";
2
+ import { MissingEOAWalletError, writeContractOrThrow } from "../errors.js";
3
3
  import { ESIMWalletFactory } from "../../abis/index.js";
4
- /**
5
- * Admin-EOA logic for `ESIMWalletFactory`. Both functions are owner-gated
6
- * (`addRegistryAddress` requires `msg.sender == owner()`, `updateESIMWalletImplementation`
7
- * is `onlyOwner`), so the `client` must carry the `upgradeManager` EOA.
8
- *
9
- * Note: `ESIMWalletFactory.deployESIMWallet` is intentionally NOT exposed - it is
10
- * `onlyRegistryOrDeviceWalletFactoryOrDeviceWallet`, so a bare EOA always reverts.
11
- */
4
+ // Admin-EOA logic for `ESIMWalletFactory`. Both functions are owner-gated
5
+ // (`addRegistryAddress` requires `msg.sender == owner()`, `updateESIMWalletImplementation`
6
+ // is `onlyOwner`), so the `client` must carry the `upgradeManager` EOA.
7
+ //
8
+ // On the live deployment the owner is the `ProtocolAdmin` timelock, not an EOA,
9
+ // so either call sent directly reverts. Route them through
10
+ // `protocolAdmin.proposer.schedule` instead. The direct path stays for
11
+ // deployments whose owner is a plain EOA or multisig.
12
+ //
13
+ // Note: `ESIMWalletFactory.deployESIMWallet` is intentionally NOT exposed - it is
14
+ // `onlyRegistryOrDeviceWalletFactoryOrDeviceWallet`, so a bare EOA always reverts.
12
15
  /** One-time wiring of the registry into the eSIM factory. Owner only. */
13
16
  export const _addRegistryAddress = async (client, registryContractAddress) => {
14
17
  const chainID = await client.getChainId();
@@ -16,7 +19,7 @@ export const _addRegistryAddress = async (client, registryContractAddress) => {
16
19
  const values = _getChainSpecificConstants(chainID, rpcURL);
17
20
  if (!client.account)
18
21
  throw new MissingEOAWalletError();
19
- return client.writeContract({
22
+ return writeContractOrThrow(client, {
20
23
  address: values.factoryAddresses.ESIM_WALLET_FACTORY,
21
24
  chain: values.chain,
22
25
  account: client.account.address,
@@ -32,7 +35,7 @@ export const _updateESIMWalletImplementation = async (client, eSIMWalletImpl) =>
32
35
  const values = _getChainSpecificConstants(chainID, rpcURL);
33
36
  if (!client.account)
34
37
  throw new MissingEOAWalletError();
35
- return client.writeContract({
38
+ return writeContractOrThrow(client, {
36
39
  address: values.factoryAddresses.ESIM_WALLET_FACTORY,
37
40
  chain: values.chain,
38
41
  account: client.account.address,
@@ -41,3 +44,68 @@ export const _updateESIMWalletImplementation = async (client, eSIMWalletImpl) =>
41
44
  args: [eSIMWalletImpl]
42
45
  });
43
46
  };
47
+ // ---------------------------------------------------------------------------
48
+ // Owner payloads - only reachable through schedule
49
+ // ---------------------------------------------------------------------------
50
+ // Both are `onlyOwner`, and on the live deployment the owner is the timelock, so
51
+ // they exist as something to schedule rather than to send. Each returns the
52
+ // `OwnerCall` to hand to `protocolAdmin.schedule`.
53
+ /**
54
+ * Offer ownership to a new address. Pass the result to `schedule`.
55
+ *
56
+ * Ownable2Step, so the offer changes nothing until the named address calls
57
+ * `acceptOwnership`. Note this hands over the beacon too, since the factory owns
58
+ * it, so the new owner can move every deployed eSIM wallet at once.
59
+ */
60
+ export const _transferOwnershipCall = async (client, newOwner) => {
61
+ const chainID = await client.getChainId();
62
+ const rpcURL = client.transport.url;
63
+ const values = _getChainSpecificConstants(chainID, rpcURL);
64
+ return {
65
+ address: values.factoryAddresses.ESIM_WALLET_FACTORY,
66
+ abi: ESIMWalletFactory,
67
+ functionName: 'transferOwnership',
68
+ args: [newOwner],
69
+ };
70
+ };
71
+ /**
72
+ * Point the factory's own proxy at a new implementation. Builds
73
+ * `upgradeToAndCall`. Pass the result to `schedule`.
74
+ *
75
+ * This does not touch deployed eSIM wallets. They read their implementation from
76
+ * the beacon, which moves through `updateESIMWalletImplementation` instead.
77
+ */
78
+ export const _upgradeCall = async (client, newImplementation, data = '0x') => {
79
+ const chainID = await client.getChainId();
80
+ const rpcURL = client.transport.url;
81
+ const values = _getChainSpecificConstants(chainID, rpcURL);
82
+ return {
83
+ address: values.factoryAddresses.ESIM_WALLET_FACTORY,
84
+ abi: ESIMWalletFactory,
85
+ functionName: 'upgradeToAndCall',
86
+ args: [newImplementation, data],
87
+ };
88
+ };
89
+ /**
90
+ * Take ownership after a `transferOwnership` named this client. `msg.sender`
91
+ * must equal `pendingOwner`, so the `client` is the incoming owner.
92
+ *
93
+ * Where the incoming owner is the timelock, use
94
+ * `protocolAdmin.acceptOwnershipBatch` instead, which accepts for every contract
95
+ * at once.
96
+ */
97
+ export const _acceptOwnership = async (client) => {
98
+ const chainID = await client.getChainId();
99
+ const rpcURL = client.transport.url;
100
+ const values = _getChainSpecificConstants(chainID, rpcURL);
101
+ if (!client.account)
102
+ throw new MissingEOAWalletError();
103
+ return writeContractOrThrow(client, {
104
+ address: values.factoryAddresses.ESIM_WALLET_FACTORY,
105
+ chain: values.chain,
106
+ account: client.account.address,
107
+ abi: ESIMWalletFactory,
108
+ functionName: 'acceptOwnership',
109
+ args: []
110
+ });
111
+ };