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.
- package/README.md +68 -19
- package/dist/esm/abis/BeaconProxy.js +30 -46
- package/dist/esm/abis/DeviceWallet.js +546 -535
- package/dist/esm/abis/DeviceWalletFactory.js +537 -544
- package/dist/esm/abis/ESIMWallet.js +440 -299
- package/dist/esm/abis/ESIMWalletFactory.js +372 -289
- package/dist/esm/abis/LazyWalletRegistry.js +941 -421
- package/dist/esm/abis/P256Verifier.js +29 -29
- package/dist/esm/abis/ProtocolAdmin.js +1228 -0
- package/dist/esm/abis/Registry.js +1207 -466
- package/dist/esm/abis/RegistryHelper.js +414 -20
- package/dist/esm/abis/index.js +2 -1
- package/dist/esm/admin/config-admin.js +7 -0
- package/dist/esm/admin/interface/deviceWalletClass.js +27 -6
- package/dist/esm/admin/interface/deviceWalletFactoryClass.js +41 -19
- package/dist/esm/admin/interface/eSIMWalletClass.js +10 -1
- package/dist/esm/admin/interface/eSIMWalletFactoryClass.js +24 -2
- package/dist/esm/admin/interface/lazyWalletRegistryClass.js +83 -4
- package/dist/esm/admin/interface/protocolAdminClass.js +195 -0
- package/dist/esm/admin/interface/registryClass.js +93 -2
- package/dist/esm/config.js +42 -7
- package/dist/esm/interface/deviceWalletClass.js +45 -5
- package/dist/esm/interface/deviceWalletFactoryClass.js +20 -1
- package/dist/esm/interface/eSIMWalletClass.js +12 -3
- package/dist/esm/interface/registryClass.js +47 -0
- package/dist/esm/interface/smartAccountClass.js +2 -4
- package/dist/esm/logic/account-kit/createSmartAccount.js +156 -102
- package/dist/esm/logic/admin/deviceWallet.eoa.js +26 -15
- package/dist/esm/logic/admin/deviceWalletFactory.eoa.js +69 -48
- package/dist/esm/logic/admin/eSIMWallet.eoa.js +5 -7
- package/dist/esm/logic/admin/eSIMWalletFactory.eoa.js +79 -11
- package/dist/esm/logic/admin/lazyWalletRegistry.eoa.js +333 -22
- package/dist/esm/logic/admin/protocolAdmin.eoa.js +524 -0
- package/dist/esm/logic/admin/reads/deviceWallet.reads.js +82 -7
- package/dist/esm/logic/admin/reads/deviceWalletFactory.reads.js +82 -23
- package/dist/esm/logic/admin/reads/eSIMWallet.reads.js +50 -6
- package/dist/esm/logic/admin/reads/eSIMWalletFactory.reads.js +63 -5
- package/dist/esm/logic/admin/reads/lazyWalletRegistry.reads.js +171 -10
- package/dist/esm/logic/admin/reads/protocolAdmin.reads.js +154 -0
- package/dist/esm/logic/admin/reads/registry.reads.js +289 -9
- package/dist/esm/logic/admin/registry.eoa.js +276 -6
- package/dist/esm/logic/constants.js +53 -26
- package/dist/esm/logic/deviceWallet.js +224 -31
- package/dist/esm/logic/deviceWalletFactory.js +89 -0
- package/dist/esm/logic/eSIMWallet.js +113 -43
- package/dist/esm/logic/eSIMWalletFactory.js +8 -8
- package/dist/esm/logic/errors.js +94 -1
- package/dist/esm/logic/registry.js +236 -0
- package/dist/esm/logic/utils.js +2 -1
- package/dist/types/abis/BeaconProxy.d.ts +21 -33
- package/dist/types/abis/DeviceWallet.d.ts +372 -365
- package/dist/types/abis/DeviceWalletFactory.d.ts +438 -448
- package/dist/types/abis/ESIMWallet.d.ts +352 -245
- package/dist/types/abis/ESIMWalletFactory.d.ts +278 -216
- package/dist/types/abis/LazyWalletRegistry.d.ts +710 -317
- package/dist/types/abis/P256Verifier.d.ts +16 -16
- package/dist/types/abis/ProtocolAdmin.d.ts +947 -0
- package/dist/types/abis/Registry.d.ts +960 -393
- package/dist/types/abis/RegistryHelper.d.ts +317 -16
- package/dist/types/abis/index.d.ts +2 -1
- package/dist/types/admin/config-admin.d.ts +3 -0
- package/dist/types/admin/interface/deviceWalletClass.d.ts +10 -3
- package/dist/types/admin/interface/deviceWalletFactoryClass.d.ts +14 -7
- package/dist/types/admin/interface/eSIMWalletClass.d.ts +3 -0
- package/dist/types/admin/interface/eSIMWalletFactoryClass.d.ts +8 -1
- package/dist/types/admin/interface/lazyWalletRegistryClass.d.ts +38 -2
- package/dist/types/admin/interface/protocolAdminClass.d.ts +95 -0
- package/dist/types/admin/interface/registryClass.d.ts +30 -0
- package/dist/types/config.d.ts +26 -5
- package/dist/types/interface/P256VerifierClass.d.ts +3 -4
- package/dist/types/interface/deviceWalletClass.d.ts +22 -2569
- package/dist/types/interface/deviceWalletFactoryClass.d.ts +10 -2564
- package/dist/types/interface/eSIMWalletClass.d.ts +11 -8
- package/dist/types/interface/eSIMWalletFactoryClass.d.ts +5 -2565
- package/dist/types/interface/registryClass.d.ts +19 -0
- package/dist/types/interface/smartAccountClass.d.ts +6 -2568
- package/dist/types/logic/P256Verifier.d.ts +2 -2
- package/dist/types/logic/account-kit/createSmartAccount.d.ts +43 -19
- package/dist/types/logic/admin/deviceWallet.eoa.d.ts +15 -9
- package/dist/types/logic/admin/deviceWalletFactory.eoa.d.ts +34 -23
- package/dist/types/logic/admin/eSIMWallet.eoa.d.ts +0 -5
- package/dist/types/logic/admin/eSIMWalletFactory.eoa.d.ts +27 -9
- package/dist/types/logic/admin/lazyWalletRegistry.eoa.d.ts +102 -10
- package/dist/types/logic/admin/protocolAdmin.eoa.d.ts +163 -0
- package/dist/types/logic/admin/reads/deviceWallet.reads.d.ts +28 -8
- package/dist/types/logic/admin/reads/deviceWalletFactory.reads.d.ts +45 -14
- package/dist/types/logic/admin/reads/eSIMWallet.reads.d.ts +25 -6
- package/dist/types/logic/admin/reads/eSIMWalletFactory.reads.d.ts +21 -6
- package/dist/types/logic/admin/reads/lazyWalletRegistry.reads.d.ts +44 -11
- package/dist/types/logic/admin/reads/protocolAdmin.reads.d.ts +53 -0
- package/dist/types/logic/admin/reads/registry.reads.d.ts +105 -9
- package/dist/types/logic/admin/registry.eoa.d.ts +102 -5
- package/dist/types/logic/constants.d.ts +2 -0
- package/dist/types/logic/deviceWallet.d.ts +78 -6
- package/dist/types/logic/deviceWalletFactory.d.ts +32 -3
- package/dist/types/logic/eSIMWallet.d.ts +48 -7
- package/dist/types/logic/eSIMWalletFactory.d.ts +3 -3
- package/dist/types/logic/errors.d.ts +61 -1
- package/dist/types/logic/registry.d.ts +78 -0
- package/dist/types/types-export.d.ts +1 -1
- package/dist/types/types.d.ts +111 -1
- package/package.json +11 -13
- package/dist/esm/interface/lazyWalletRegistryClass.js +0 -10
- package/dist/esm/logic/lazyWalletRegistry.js +0 -19
- package/dist/types/interface/lazyWalletRegistryClass.d.ts +0 -6
- 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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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
|
-
/**
|
|
35
|
-
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
67
|
-
export const
|
|
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
|
|
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: '
|
|
79
|
-
args: [
|
|
85
|
+
functionName: 'updateDeviceWalletImplementation',
|
|
86
|
+
args: [newDeviceImpl]
|
|
80
87
|
});
|
|
81
88
|
};
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
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: '
|
|
95
|
-
args: [
|
|
96
|
-
}
|
|
109
|
+
functionName: 'transferOwnership',
|
|
110
|
+
args: [newOwner],
|
|
111
|
+
};
|
|
97
112
|
};
|
|
98
113
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
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
|
|
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
|
-
|
|
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: '
|
|
115
|
-
args: []
|
|
116
|
-
}
|
|
128
|
+
functionName: 'upgradeToAndCall',
|
|
129
|
+
args: [newImplementation, data],
|
|
130
|
+
};
|
|
117
131
|
};
|
|
118
|
-
/**
|
|
119
|
-
|
|
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
|
|
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: '
|
|
131
|
-
args: [
|
|
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
|
-
|
|
6
|
-
|
|
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
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
|
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
|
+
};
|