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.
- 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 +24 -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 +23 -12
- package/dist/esm/logic/admin/deviceWalletFactory.eoa.js +63 -42
- package/dist/esm/logic/admin/eSIMWallet.eoa.js +3 -5
- package/dist/esm/logic/admin/eSIMWalletFactory.eoa.js +76 -8
- package/dist/esm/logic/admin/lazyWalletRegistry.eoa.js +330 -19
- 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 +274 -4
- 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 +64 -0
- 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 +16 -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/constantsClass.d.ts +2 -2
- 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 +45 -0
- 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,6 +1,6 @@
|
|
|
1
1
|
import { _createAccountWithEOA } from "../../logic/deviceWalletFactory.js";
|
|
2
|
-
import { _deployDeviceWalletForUsers, _postCreateAccount, _addRegistryAddress,
|
|
3
|
-
import { _eSIMWalletAdmin,
|
|
2
|
+
import { _deployDeviceWalletForUsers, _postCreateAccount, _addRegistryAddress, _updateDeviceWalletImplementation, _acceptOwnership, _transferOwnershipCall, _upgradeCall, } from "../../logic/admin/deviceWalletFactory.eoa.js";
|
|
3
|
+
import { _eSIMWalletAdmin, _deviceWalletInfoAdded, _getCurrentDeviceWalletImplementation, _getCounterFactualAddress, _preCreateAccountValidation, _beacon, _registry, _entryPoint, _verifier, _owner, _pendingOwner, _proxiableUUID, _upgradeInterfaceVersion, } from "../../logic/admin/reads/deviceWalletFactory.reads.js";
|
|
4
4
|
/**
|
|
5
5
|
* Thin EOA wrapper around `DeviceWalletFactory`. Holds only the wallet client;
|
|
6
6
|
* every method forwards to a logic function. `createAccountWithEOA` reuses the
|
|
@@ -17,21 +17,12 @@ export class AdminDeviceWalletFactorySubPackage {
|
|
|
17
17
|
deployDeviceWalletForUsers(deviceUniqueIdentifiers, deviceWalletOwnersKey, salts, depositAmounts, value) {
|
|
18
18
|
return _deployDeviceWalletForUsers(this.walletClient, deviceUniqueIdentifiers, deviceWalletOwnersKey, salts, depositAmounts, value);
|
|
19
19
|
}
|
|
20
|
-
postCreateAccount(deviceWallet, deviceUniqueIdentifier, deviceWalletOwnerKey) {
|
|
21
|
-
return _postCreateAccount(this.walletClient, deviceWallet, deviceUniqueIdentifier, deviceWalletOwnerKey);
|
|
20
|
+
postCreateAccount(deviceWallet, deviceUniqueIdentifier, deviceWalletOwnerKey, salt) {
|
|
21
|
+
return _postCreateAccount(this.walletClient, deviceWallet, deviceUniqueIdentifier, deviceWalletOwnerKey, salt);
|
|
22
22
|
}
|
|
23
23
|
addRegistryAddress(registryContractAddress) {
|
|
24
24
|
return _addRegistryAddress(this.walletClient, registryContractAddress);
|
|
25
25
|
}
|
|
26
|
-
updateVaultAddress(newVaultAddress) {
|
|
27
|
-
return _updateVaultAddress(this.walletClient, newVaultAddress);
|
|
28
|
-
}
|
|
29
|
-
requestAdminUpdate(newAdmin) {
|
|
30
|
-
return _requestAdminUpdate(this.walletClient, newAdmin);
|
|
31
|
-
}
|
|
32
|
-
acceptAdminUpdate() {
|
|
33
|
-
return _acceptAdminUpdate(this.walletClient);
|
|
34
|
-
}
|
|
35
26
|
updateDeviceWalletImplementation(newDeviceImpl) {
|
|
36
27
|
return _updateDeviceWalletImplementation(this.walletClient, newDeviceImpl);
|
|
37
28
|
}
|
|
@@ -39,12 +30,6 @@ export class AdminDeviceWalletFactorySubPackage {
|
|
|
39
30
|
eSIMWalletAdmin() {
|
|
40
31
|
return _eSIMWalletAdmin(this.walletClient);
|
|
41
32
|
}
|
|
42
|
-
vault() {
|
|
43
|
-
return _vault(this.walletClient);
|
|
44
|
-
}
|
|
45
|
-
newRequestedAdmin() {
|
|
46
|
-
return _newRequestedAdmin(this.walletClient);
|
|
47
|
-
}
|
|
48
33
|
deviceWalletInfoAdded(deviceWallet) {
|
|
49
34
|
return _deviceWalletInfoAdded(this.walletClient, deviceWallet);
|
|
50
35
|
}
|
|
@@ -54,4 +39,41 @@ export class AdminDeviceWalletFactorySubPackage {
|
|
|
54
39
|
getCounterFactualAddress(deviceWalletOwnerKey, deviceUniqueIdentifier, salt) {
|
|
55
40
|
return _getCounterFactualAddress(this.walletClient, deviceWalletOwnerKey, deviceUniqueIdentifier, salt);
|
|
56
41
|
}
|
|
42
|
+
preCreateAccountValidation(deviceUniqueIdentifier, deviceWalletOwnerKey) {
|
|
43
|
+
return _preCreateAccountValidation(this.walletClient, deviceUniqueIdentifier, deviceWalletOwnerKey);
|
|
44
|
+
}
|
|
45
|
+
beacon() {
|
|
46
|
+
return _beacon(this.walletClient);
|
|
47
|
+
}
|
|
48
|
+
registry() {
|
|
49
|
+
return _registry(this.walletClient);
|
|
50
|
+
}
|
|
51
|
+
entryPoint() {
|
|
52
|
+
return _entryPoint(this.walletClient);
|
|
53
|
+
}
|
|
54
|
+
verifier() {
|
|
55
|
+
return _verifier(this.walletClient);
|
|
56
|
+
}
|
|
57
|
+
owner() {
|
|
58
|
+
return _owner(this.walletClient);
|
|
59
|
+
}
|
|
60
|
+
pendingOwner() {
|
|
61
|
+
return _pendingOwner(this.walletClient);
|
|
62
|
+
}
|
|
63
|
+
proxiableUUID() {
|
|
64
|
+
return _proxiableUUID(this.walletClient);
|
|
65
|
+
}
|
|
66
|
+
upgradeInterfaceVersion() {
|
|
67
|
+
return _upgradeInterfaceVersion(this.walletClient);
|
|
68
|
+
}
|
|
69
|
+
acceptOwnership() {
|
|
70
|
+
return _acceptOwnership(this.walletClient);
|
|
71
|
+
}
|
|
72
|
+
// Owner payloads: hand the result to `protocolAdmin.schedule`
|
|
73
|
+
transferOwnershipCall(newOwner) {
|
|
74
|
+
return _transferOwnershipCall(this.walletClient, newOwner);
|
|
75
|
+
}
|
|
76
|
+
upgradeCall(newImplementation, data) {
|
|
77
|
+
return _upgradeCall(this.walletClient, newImplementation, data);
|
|
78
|
+
}
|
|
57
79
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _buyDataBundle } from "../../logic/admin/eSIMWallet.eoa.js";
|
|
2
|
-
import { _eSIMWalletFactory, _eSIMUniqueIdentifier, _newRequestedOwner, _owner, } from "../../logic/admin/reads/eSIMWallet.reads.js";
|
|
2
|
+
import { _eSIMWalletFactory, _eSIMUniqueIdentifier, _newRequestedOwner, _owner, _dataBundlePriceCap, _deviceWallet, _transactionHistory, } from "../../logic/admin/reads/eSIMWallet.reads.js";
|
|
3
3
|
/**
|
|
4
4
|
* Thin EOA wrapper around a specific `ESIMWallet` instance. The instance address
|
|
5
5
|
* is bound at construction; `KokioAdmin.setESIMWalletAddress` swaps it by
|
|
@@ -28,4 +28,13 @@ export class AdminESIMWalletSubPackage {
|
|
|
28
28
|
owner() {
|
|
29
29
|
return _owner(this.walletClient, this.eSIMWalletAddress);
|
|
30
30
|
}
|
|
31
|
+
dataBundlePriceCap() {
|
|
32
|
+
return _dataBundlePriceCap(this.walletClient, this.eSIMWalletAddress);
|
|
33
|
+
}
|
|
34
|
+
deviceWallet() {
|
|
35
|
+
return _deviceWallet(this.walletClient, this.eSIMWalletAddress);
|
|
36
|
+
}
|
|
37
|
+
transactionHistory(index) {
|
|
38
|
+
return _transactionHistory(this.walletClient, this.eSIMWalletAddress, index);
|
|
39
|
+
}
|
|
31
40
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _addRegistryAddress, _updateESIMWalletImplementation, } from "../../logic/admin/eSIMWalletFactory.eoa.js";
|
|
2
|
-
import { _isESIMWalletDeployed, _getCurrentESIMWalletImplementation, } from "../../logic/admin/reads/eSIMWalletFactory.reads.js";
|
|
1
|
+
import { _addRegistryAddress, _updateESIMWalletImplementation, _acceptOwnership, _transferOwnershipCall, _upgradeCall, } from "../../logic/admin/eSIMWalletFactory.eoa.js";
|
|
2
|
+
import { _isESIMWalletDeployed, _getCurrentESIMWalletImplementation, _owner, _pendingOwner, _proxiableUUID, _upgradeInterfaceVersion, } from "../../logic/admin/reads/eSIMWalletFactory.reads.js";
|
|
3
3
|
/** Thin EOA (owner) wrapper around `ESIMWalletFactory`. */
|
|
4
4
|
export class AdminESIMWalletFactorySubPackage {
|
|
5
5
|
walletClient;
|
|
@@ -12,6 +12,16 @@ export class AdminESIMWalletFactorySubPackage {
|
|
|
12
12
|
updateESIMWalletImplementation(eSIMWalletImpl) {
|
|
13
13
|
return _updateESIMWalletImplementation(this.walletClient, eSIMWalletImpl);
|
|
14
14
|
}
|
|
15
|
+
acceptOwnership() {
|
|
16
|
+
return _acceptOwnership(this.walletClient);
|
|
17
|
+
}
|
|
18
|
+
// Owner payloads: hand the result to `protocolAdmin.schedule`
|
|
19
|
+
transferOwnershipCall(newOwner) {
|
|
20
|
+
return _transferOwnershipCall(this.walletClient, newOwner);
|
|
21
|
+
}
|
|
22
|
+
upgradeCall(newImplementation, data) {
|
|
23
|
+
return _upgradeCall(this.walletClient, newImplementation, data);
|
|
24
|
+
}
|
|
15
25
|
// Reads: public storage getters and views
|
|
16
26
|
isESIMWalletDeployed(eSIMWallet) {
|
|
17
27
|
return _isESIMWalletDeployed(this.walletClient, eSIMWallet);
|
|
@@ -19,4 +29,16 @@ export class AdminESIMWalletFactorySubPackage {
|
|
|
19
29
|
getCurrentESIMWalletImplementation() {
|
|
20
30
|
return _getCurrentESIMWalletImplementation(this.walletClient);
|
|
21
31
|
}
|
|
32
|
+
owner() {
|
|
33
|
+
return _owner(this.walletClient);
|
|
34
|
+
}
|
|
35
|
+
pendingOwner() {
|
|
36
|
+
return _pendingOwner(this.walletClient);
|
|
37
|
+
}
|
|
38
|
+
proxiableUUID() {
|
|
39
|
+
return _proxiableUUID(this.walletClient);
|
|
40
|
+
}
|
|
41
|
+
upgradeInterfaceVersion() {
|
|
42
|
+
return _upgradeInterfaceVersion(this.walletClient);
|
|
43
|
+
}
|
|
22
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _batchPopulateHistory, _deployLazyWalletAndSetESIMIdentifier, _switchESIMIdentifierToNewDeviceIdentifier, } from "../../logic/admin/lazyWalletRegistry.eoa.js";
|
|
2
|
-
import { _upgradeManager, _eSIMIdentifierToDeviceIdentifier, _deviceIdentifierToESIMDetails, _eSIMIdentifiersAssociatedWithDeviceIdentifier, } from "../../logic/admin/reads/lazyWalletRegistry.reads.js";
|
|
1
|
+
import { _batchPopulateHistory, _deployLazyWalletAllBatches, _deployLazyWalletAndSetESIMIdentifier, _deployMoreESIMWalletsForLazyDevice, _setHistoryForLazyWallet, _setHistoryForLazyWalletAllBatches, _switchESIMIdentifierToNewDeviceIdentifier, _acceptOwnership, _transferOwnershipCall, _upgradeCall, } from "../../logic/admin/lazyWalletRegistry.eoa.js";
|
|
2
|
+
import { _upgradeManager, _eSIMIdentifierToDeviceIdentifier, _deviceIdentifierToESIMDetails, _eSIMIdentifiersAssociatedWithDeviceIdentifier, _eSIMWalletsDeployed, _historyEntriesCopied, _isDeviceIdentifierReserved, _isESIMIdentifierReserved, _lazyDeployedESIMWallet, _lazyDeploymentSalt, _maxESIMWalletsPerCall, _maxHistoryEntriesPerCall, _owner, _pendingOwner, _proxiableUUID, _upgradeInterfaceVersion, } from "../../logic/admin/reads/lazyWalletRegistry.reads.js";
|
|
3
3
|
/** Thin EOA (eSIMWalletAdmin) wrapper around `LazyWalletRegistry`. */
|
|
4
4
|
export class AdminLazyWalletRegistrySubPackage {
|
|
5
5
|
walletClient;
|
|
@@ -9,12 +9,43 @@ export class AdminLazyWalletRegistrySubPackage {
|
|
|
9
9
|
batchPopulateHistory(deviceUniqueIdentifiers, eSIMUniqueIdentifiers, dataBundleDetails) {
|
|
10
10
|
return _batchPopulateHistory(this.walletClient, deviceUniqueIdentifiers, eSIMUniqueIdentifiers, dataBundleDetails);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Deploy a lazy device and all of its eSIM wallets. Sends as many transactions
|
|
14
|
+
* as the device needs and resolves once every wallet exists, so the caller
|
|
15
|
+
* does not deal with the on-chain batching at all.
|
|
16
|
+
*
|
|
17
|
+
* Resumable: call it again with the same arguments (and a deposit of 0) to
|
|
18
|
+
* pick a part-deployed device up from where it stopped.
|
|
19
|
+
*
|
|
20
|
+
* Record all of the device's purchase history before this runs.
|
|
21
|
+
*/
|
|
22
|
+
deployLazyWalletAndSetESIMIdentifier(deviceOwnerPublicKey, deviceUniqueIdentifier, salt, depositAmount, maxWallets) {
|
|
23
|
+
return _deployLazyWalletAllBatches(this.walletClient, deviceOwnerPublicKey, deviceUniqueIdentifier, salt, depositAmount, maxWallets);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Copy an eSIM's whole purchase history onto its wallet, over as many
|
|
27
|
+
* transactions as it takes. Resumable, and safe to run while the device's
|
|
28
|
+
* other eSIM wallets are still being deployed.
|
|
29
|
+
*/
|
|
30
|
+
setHistoryForLazyWallet(eSIMIdentifier, maxEntries) {
|
|
31
|
+
return _setHistoryForLazyWalletAllBatches(this.walletClient, eSIMIdentifier, maxEntries);
|
|
14
32
|
}
|
|
15
33
|
switchESIMIdentifierToNewDeviceIdentifier(eSIMIdentifier, oldDeviceIdentifier, newDeviceIdentifier) {
|
|
16
34
|
return _switchESIMIdentifierToNewDeviceIdentifier(this.walletClient, eSIMIdentifier, oldDeviceIdentifier, newDeviceIdentifier);
|
|
17
35
|
}
|
|
36
|
+
// Single-transaction calls, mirroring the contract one for one. The paginated
|
|
37
|
+
// versions above are the ones to reach for; these are here for a caller that
|
|
38
|
+
// wants to drive the batching itself, and each returns a transaction hash
|
|
39
|
+
// rather than waiting for a receipt.
|
|
40
|
+
deployLazyWalletFirstBatch(deviceOwnerPublicKey, deviceUniqueIdentifier, salt, depositAmount, maxWallets) {
|
|
41
|
+
return _deployLazyWalletAndSetESIMIdentifier(this.walletClient, deviceOwnerPublicKey, deviceUniqueIdentifier, salt, depositAmount, maxWallets);
|
|
42
|
+
}
|
|
43
|
+
deployMoreESIMWalletsForLazyDevice(deviceUniqueIdentifier, maxWallets) {
|
|
44
|
+
return _deployMoreESIMWalletsForLazyDevice(this.walletClient, deviceUniqueIdentifier, maxWallets);
|
|
45
|
+
}
|
|
46
|
+
setHistoryForLazyWalletBatch(eSIMIdentifier, maxEntries) {
|
|
47
|
+
return _setHistoryForLazyWallet(this.walletClient, eSIMIdentifier, maxEntries);
|
|
48
|
+
}
|
|
18
49
|
// Reads: public storage getters
|
|
19
50
|
upgradeManager() {
|
|
20
51
|
return _upgradeManager(this.walletClient);
|
|
@@ -22,6 +53,32 @@ export class AdminLazyWalletRegistrySubPackage {
|
|
|
22
53
|
eSIMIdentifierToDeviceIdentifier(eSIMIdentifier) {
|
|
23
54
|
return _eSIMIdentifierToDeviceIdentifier(this.walletClient, eSIMIdentifier);
|
|
24
55
|
}
|
|
56
|
+
MAX_ESIM_WALLETS_PER_CALL() {
|
|
57
|
+
return _maxESIMWalletsPerCall(this.walletClient);
|
|
58
|
+
}
|
|
59
|
+
MAX_HISTORY_ENTRIES_PER_CALL() {
|
|
60
|
+
return _maxHistoryEntriesPerCall(this.walletClient);
|
|
61
|
+
}
|
|
62
|
+
/** Deploy cursor. Non-zero exactly when the lazy route ran this device's first batch. */
|
|
63
|
+
eSIMWalletsDeployed(deviceIdentifier) {
|
|
64
|
+
return _eSIMWalletsDeployed(this.walletClient, deviceIdentifier);
|
|
65
|
+
}
|
|
66
|
+
lazyDeploymentSalt(deviceIdentifier) {
|
|
67
|
+
return _lazyDeploymentSalt(this.walletClient, deviceIdentifier);
|
|
68
|
+
}
|
|
69
|
+
lazyDeployedESIMWallet(eSIMIdentifier) {
|
|
70
|
+
return _lazyDeployedESIMWallet(this.walletClient, eSIMIdentifier);
|
|
71
|
+
}
|
|
72
|
+
/** History cursor, per eSIM. */
|
|
73
|
+
historyEntriesCopied(eSIMIdentifier) {
|
|
74
|
+
return _historyEntriesCopied(this.walletClient, eSIMIdentifier);
|
|
75
|
+
}
|
|
76
|
+
isDeviceIdentifierReserved(deviceIdentifier) {
|
|
77
|
+
return _isDeviceIdentifierReserved(this.walletClient, deviceIdentifier);
|
|
78
|
+
}
|
|
79
|
+
isESIMIdentifierReserved(eSIMIdentifier) {
|
|
80
|
+
return _isESIMIdentifierReserved(this.walletClient, eSIMIdentifier);
|
|
81
|
+
}
|
|
25
82
|
// Array-backed getters take an element index and return one entry - iterate
|
|
26
83
|
// indices to read the full list (there is no on-chain full-array getter).
|
|
27
84
|
deviceIdentifierToESIMDetails(deviceIdentifier, eSIMIdentifier, index) {
|
|
@@ -30,4 +87,26 @@ export class AdminLazyWalletRegistrySubPackage {
|
|
|
30
87
|
eSIMIdentifiersAssociatedWithDeviceIdentifier(deviceIdentifier, index) {
|
|
31
88
|
return _eSIMIdentifiersAssociatedWithDeviceIdentifier(this.walletClient, deviceIdentifier, index);
|
|
32
89
|
}
|
|
90
|
+
owner() {
|
|
91
|
+
return _owner(this.walletClient);
|
|
92
|
+
}
|
|
93
|
+
pendingOwner() {
|
|
94
|
+
return _pendingOwner(this.walletClient);
|
|
95
|
+
}
|
|
96
|
+
proxiableUUID() {
|
|
97
|
+
return _proxiableUUID(this.walletClient);
|
|
98
|
+
}
|
|
99
|
+
upgradeInterfaceVersion() {
|
|
100
|
+
return _upgradeInterfaceVersion(this.walletClient);
|
|
101
|
+
}
|
|
102
|
+
acceptOwnership() {
|
|
103
|
+
return _acceptOwnership(this.walletClient);
|
|
104
|
+
}
|
|
105
|
+
// Owner payloads: hand the result to `protocolAdmin.schedule`
|
|
106
|
+
transferOwnershipCall(newOwner) {
|
|
107
|
+
return _transferOwnershipCall(this.walletClient, newOwner);
|
|
108
|
+
}
|
|
109
|
+
upgradeCall(newImplementation, data) {
|
|
110
|
+
return _upgradeCall(this.walletClient, newImplementation, data);
|
|
111
|
+
}
|
|
33
112
|
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { _operationId, _operationIdBatch, _operationIdRaw, _operationIdBatchRaw, _schedule, _scheduleBatch, _scheduleRaw, _execute, _executeBatch, _executeRaw, _cancel, _unpauseInstantly, _revokeCancellersInstantly, _disableAdminInstantly, _acceptOwnershipBatch, _renounceRole, _grantRoleCall, _revokeRoleCall, _updateDelayCall, _disableAndNominateCall, _disableAdminCall, _enableAdminCall, _unpauseCall, _setDefaultDataBundlePriceCapCall, } from "../../logic/admin/protocolAdmin.eoa.js";
|
|
2
|
+
import { _getMinDelay, _minDelayFloor, _getOperationState, _getTimestamp, _isOperation, _isOperationPending, _isOperationReady, _isOperationDone, _hasRole, _getRoleAdmin, _defaultAdminRole, _proposerRole, _cancellerRole, _executorRole, _guardianRole, } from "../../logic/admin/reads/protocolAdmin.reads.js";
|
|
3
|
+
/** Schedules operations. Needs an EOA holding `PROPOSER_ROLE`. */
|
|
4
|
+
export class ProtocolAdminProposerSubPackage {
|
|
5
|
+
walletClient;
|
|
6
|
+
constructor(walletClient) {
|
|
7
|
+
this.walletClient = walletClient;
|
|
8
|
+
}
|
|
9
|
+
schedule(call, opts, delay) {
|
|
10
|
+
return _schedule(this.walletClient, call, opts, delay);
|
|
11
|
+
}
|
|
12
|
+
scheduleBatch(calls, opts, delay) {
|
|
13
|
+
return _scheduleBatch(this.walletClient, calls, opts, delay);
|
|
14
|
+
}
|
|
15
|
+
scheduleRaw(target, value, payload, predecessor, salt, delay) {
|
|
16
|
+
return _scheduleRaw(this.walletClient, target, value, payload, predecessor, salt, delay);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Runs operations whose delay has elapsed. Open to any funded EOA. */
|
|
20
|
+
export class ProtocolAdminExecutorSubPackage {
|
|
21
|
+
walletClient;
|
|
22
|
+
constructor(walletClient) {
|
|
23
|
+
this.walletClient = walletClient;
|
|
24
|
+
}
|
|
25
|
+
execute(operation) {
|
|
26
|
+
return _execute(this.walletClient, operation);
|
|
27
|
+
}
|
|
28
|
+
executeBatch(operation) {
|
|
29
|
+
return _executeBatch(this.walletClient, operation);
|
|
30
|
+
}
|
|
31
|
+
executeRaw(target, value, payload, predecessor, salt) {
|
|
32
|
+
return _executeRaw(this.walletClient, target, value, payload, predecessor, salt);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Drops a scheduled operation. Needs `CANCELLER_ROLE`, which proposers also hold. */
|
|
36
|
+
export class ProtocolAdminCancellerSubPackage {
|
|
37
|
+
walletClient;
|
|
38
|
+
constructor(walletClient) {
|
|
39
|
+
this.walletClient = walletClient;
|
|
40
|
+
}
|
|
41
|
+
cancel(id) {
|
|
42
|
+
return _cancel(this.walletClient, id);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The three instant powers. Needs `GUARDIAN_ROLE`.
|
|
47
|
+
*
|
|
48
|
+
* Each one takes something away and none grants anything, which is what keeps
|
|
49
|
+
* the role away from user funds. Undoing any of them is an owner action and
|
|
50
|
+
* waits, so the side taking power away wins the race against the side handing it
|
|
51
|
+
* back.
|
|
52
|
+
*/
|
|
53
|
+
export class ProtocolAdminGuardianSubPackage {
|
|
54
|
+
walletClient;
|
|
55
|
+
constructor(walletClient) {
|
|
56
|
+
this.walletClient = walletClient;
|
|
57
|
+
}
|
|
58
|
+
unpauseInstantly(target) {
|
|
59
|
+
return _unpauseInstantly(this.walletClient, target);
|
|
60
|
+
}
|
|
61
|
+
revokeCancellersInstantly(accounts) {
|
|
62
|
+
return _revokeCancellersInstantly(this.walletClient, accounts);
|
|
63
|
+
}
|
|
64
|
+
disableAdminInstantly(target) {
|
|
65
|
+
return _disableAdminInstantly(this.walletClient, target);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The timelock that owns `Registry`, `LazyWalletRegistry`, `DeviceWalletFactory`
|
|
70
|
+
* and `ESIMWalletFactory`.
|
|
71
|
+
*
|
|
72
|
+
* Owner calls go one way: `proposer.schedule` announces one, the delay elapses,
|
|
73
|
+
* and `executor.execute` runs it. The role surfaces are separate because they
|
|
74
|
+
* need different keys, and `executor` needs no role at all.
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* const op = await admin.protocolAdmin.proposer.schedule({
|
|
78
|
+
* address: registryAddress,
|
|
79
|
+
* abi: Registry,
|
|
80
|
+
* functionName: "updateVaultAddress",
|
|
81
|
+
* args: [newVault],
|
|
82
|
+
* });
|
|
83
|
+
* // ... wait out admin.protocolAdmin.getMinDelay() ...
|
|
84
|
+
* await admin.protocolAdmin.executor.execute(op);
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export class AdminProtocolAdminSubPackage {
|
|
88
|
+
walletClient;
|
|
89
|
+
proposer;
|
|
90
|
+
executor;
|
|
91
|
+
canceller;
|
|
92
|
+
guardian;
|
|
93
|
+
constructor(walletClient) {
|
|
94
|
+
this.walletClient = walletClient;
|
|
95
|
+
this.proposer = new ProtocolAdminProposerSubPackage(walletClient);
|
|
96
|
+
this.executor = new ProtocolAdminExecutorSubPackage(walletClient);
|
|
97
|
+
this.canceller = new ProtocolAdminCancellerSubPackage(walletClient);
|
|
98
|
+
this.guardian = new ProtocolAdminGuardianSubPackage(walletClient);
|
|
99
|
+
}
|
|
100
|
+
// Writes that need no role
|
|
101
|
+
acceptOwnershipBatch(targets) {
|
|
102
|
+
return _acceptOwnershipBatch(this.walletClient, targets);
|
|
103
|
+
}
|
|
104
|
+
renounceRole(role, account) {
|
|
105
|
+
return _renounceRole(this.walletClient, role, account);
|
|
106
|
+
}
|
|
107
|
+
// Payload builders for the self-call-only functions. Hand the result to
|
|
108
|
+
// `proposer.schedule`; there is no way to call these directly.
|
|
109
|
+
grantRoleCall(role, account) {
|
|
110
|
+
return _grantRoleCall(this.walletClient, role, account);
|
|
111
|
+
}
|
|
112
|
+
revokeRoleCall(role, account) {
|
|
113
|
+
return _revokeRoleCall(this.walletClient, role, account);
|
|
114
|
+
}
|
|
115
|
+
updateDelayCall(newDelay) {
|
|
116
|
+
return _updateDelayCall(this.walletClient, newDelay);
|
|
117
|
+
}
|
|
118
|
+
disableAndNominateCall(target, newAdmin) {
|
|
119
|
+
return _disableAndNominateCall(this.walletClient, target, newAdmin);
|
|
120
|
+
}
|
|
121
|
+
// Payload builders for the target contract's own owner functions. Same
|
|
122
|
+
// route: hand the result to `proposer.schedule`.
|
|
123
|
+
disableAdminCall(target) {
|
|
124
|
+
return _disableAdminCall(this.walletClient, target);
|
|
125
|
+
}
|
|
126
|
+
enableAdminCall(target) {
|
|
127
|
+
return _enableAdminCall(this.walletClient, target);
|
|
128
|
+
}
|
|
129
|
+
unpauseCall(target) {
|
|
130
|
+
return _unpauseCall(this.walletClient, target);
|
|
131
|
+
}
|
|
132
|
+
setDefaultDataBundlePriceCapCall(cap, target) {
|
|
133
|
+
return _setDefaultDataBundlePriceCapCall(this.walletClient, cap, target);
|
|
134
|
+
}
|
|
135
|
+
// Operation ids
|
|
136
|
+
operationId(call, opts) {
|
|
137
|
+
return _operationId(this.walletClient, call, opts);
|
|
138
|
+
}
|
|
139
|
+
operationIdBatch(calls, opts) {
|
|
140
|
+
return _operationIdBatch(this.walletClient, calls, opts);
|
|
141
|
+
}
|
|
142
|
+
operationIdRaw(target, value, payload, predecessor, salt) {
|
|
143
|
+
return _operationIdRaw(this.walletClient, target, value, payload, predecessor, salt);
|
|
144
|
+
}
|
|
145
|
+
operationIdBatchRaw(targets, values, payloads, predecessor, salt) {
|
|
146
|
+
return _operationIdBatchRaw(this.walletClient, targets, values, payloads, predecessor, salt);
|
|
147
|
+
}
|
|
148
|
+
// Reads
|
|
149
|
+
getMinDelay() {
|
|
150
|
+
return _getMinDelay(this.walletClient);
|
|
151
|
+
}
|
|
152
|
+
minDelayFloor() {
|
|
153
|
+
return _minDelayFloor(this.walletClient);
|
|
154
|
+
}
|
|
155
|
+
getOperationState(id) {
|
|
156
|
+
return _getOperationState(this.walletClient, id);
|
|
157
|
+
}
|
|
158
|
+
getTimestamp(id) {
|
|
159
|
+
return _getTimestamp(this.walletClient, id);
|
|
160
|
+
}
|
|
161
|
+
isOperation(id) {
|
|
162
|
+
return _isOperation(this.walletClient, id);
|
|
163
|
+
}
|
|
164
|
+
isOperationPending(id) {
|
|
165
|
+
return _isOperationPending(this.walletClient, id);
|
|
166
|
+
}
|
|
167
|
+
isOperationReady(id) {
|
|
168
|
+
return _isOperationReady(this.walletClient, id);
|
|
169
|
+
}
|
|
170
|
+
isOperationDone(id) {
|
|
171
|
+
return _isOperationDone(this.walletClient, id);
|
|
172
|
+
}
|
|
173
|
+
hasRole(role, account) {
|
|
174
|
+
return _hasRole(this.walletClient, role, account);
|
|
175
|
+
}
|
|
176
|
+
getRoleAdmin(role) {
|
|
177
|
+
return _getRoleAdmin(this.walletClient, role);
|
|
178
|
+
}
|
|
179
|
+
// Role ids, read off the contract rather than hardcoded
|
|
180
|
+
DEFAULT_ADMIN_ROLE() {
|
|
181
|
+
return _defaultAdminRole(this.walletClient);
|
|
182
|
+
}
|
|
183
|
+
PROPOSER_ROLE() {
|
|
184
|
+
return _proposerRole(this.walletClient);
|
|
185
|
+
}
|
|
186
|
+
CANCELLER_ROLE() {
|
|
187
|
+
return _cancellerRole(this.walletClient);
|
|
188
|
+
}
|
|
189
|
+
EXECUTOR_ROLE() {
|
|
190
|
+
return _executorRole(this.walletClient);
|
|
191
|
+
}
|
|
192
|
+
GUARDIAN_ROLE() {
|
|
193
|
+
return _guardianRole(this.walletClient);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _addOrUpdateLazyWalletRegistryAddress } from "../../logic/admin/registry.eoa.js";
|
|
2
|
-
import { _eSIMWalletAdmin, _vault, _upgradeManager, _lazyWalletRegistry, _uniqueIdentifierToDeviceWallet, _deviceWalletToOwner, _registeredP256Keys, _isDeviceWalletValid, _isESIMWalletValid, _isESIMWalletOnStandby, } from "../../logic/admin/reads/registry.reads.js";
|
|
1
|
+
import { _addOrUpdateLazyWalletRegistryAddress, _updateVaultAddress, _requestAdminUpdate, _disableAdmin, _enableAdmin, _acceptAdminUpdate, _assignESIMIdentifier, _pause, _unpause, _setDefaultDataBundlePriceCap, _acceptOwnership, _transferOwnershipCall, _upgradeCall, } from "../../logic/admin/registry.eoa.js";
|
|
2
|
+
import { _owner, _eSIMWalletAdmin, _adminOfRecord, _adminDisabled, _newRequestedAdmin, _vault, _upgradeManager, _lazyWalletRegistry, _uniqueIdentifierToDeviceWallet, _deviceWalletToOwner, _registeredP256Keys, _isDeviceWalletValid, _isESIMWalletValid, _isESIMWalletOnStandby, _paused, _defaultDataBundlePriceCap, _isDeviceIdentifierAlreadyUsed, _isESIMIdentifierClaimed, _eSIMWalletForIdentifier, _claimedESIMIdentifiers, _requireDeviceIdentifierNotReserved, _pendingOwner, _deviceWalletFactory, _eSIMWalletFactory, _entryPoint, _requireNotPaused, _proxiableUUID, _upgradeInterfaceVersion, } from "../../logic/admin/reads/registry.reads.js";
|
|
3
3
|
/** Thin EOA (owner) wrapper around `Registry`. */
|
|
4
4
|
export class AdminRegistrySubPackage {
|
|
5
5
|
walletClient;
|
|
@@ -9,10 +9,59 @@ export class AdminRegistrySubPackage {
|
|
|
9
9
|
addOrUpdateLazyWalletRegistryAddress(lazyWalletRegistry) {
|
|
10
10
|
return _addOrUpdateLazyWalletRegistryAddress(this.walletClient, lazyWalletRegistry);
|
|
11
11
|
}
|
|
12
|
+
updateVaultAddress(newVaultAddress) {
|
|
13
|
+
return _updateVaultAddress(this.walletClient, newVaultAddress);
|
|
14
|
+
}
|
|
15
|
+
requestAdminUpdate(newAdmin) {
|
|
16
|
+
return _requestAdminUpdate(this.walletClient, newAdmin);
|
|
17
|
+
}
|
|
18
|
+
disableAdmin() {
|
|
19
|
+
return _disableAdmin(this.walletClient);
|
|
20
|
+
}
|
|
21
|
+
enableAdmin() {
|
|
22
|
+
return _enableAdmin(this.walletClient);
|
|
23
|
+
}
|
|
24
|
+
acceptAdminUpdate() {
|
|
25
|
+
return _acceptAdminUpdate(this.walletClient);
|
|
26
|
+
}
|
|
27
|
+
assignESIMIdentifier(eSIMWalletAddress, eSIMUniqueIdentifier) {
|
|
28
|
+
return _assignESIMIdentifier(this.walletClient, eSIMWalletAddress, eSIMUniqueIdentifier);
|
|
29
|
+
}
|
|
30
|
+
pause() {
|
|
31
|
+
return _pause(this.walletClient);
|
|
32
|
+
}
|
|
33
|
+
unpause() {
|
|
34
|
+
return _unpause(this.walletClient);
|
|
35
|
+
}
|
|
36
|
+
setDefaultDataBundlePriceCap(cap) {
|
|
37
|
+
return _setDefaultDataBundlePriceCap(this.walletClient, cap);
|
|
38
|
+
}
|
|
39
|
+
acceptOwnership() {
|
|
40
|
+
return _acceptOwnership(this.walletClient);
|
|
41
|
+
}
|
|
42
|
+
// Owner payloads: hand the result to `protocolAdmin.schedule`
|
|
43
|
+
transferOwnershipCall(newOwner) {
|
|
44
|
+
return _transferOwnershipCall(this.walletClient, newOwner);
|
|
45
|
+
}
|
|
46
|
+
upgradeCall(newImplementation, data) {
|
|
47
|
+
return _upgradeCall(this.walletClient, newImplementation, data);
|
|
48
|
+
}
|
|
12
49
|
// Reads: public storage getters, including the inherited RegistryHelper mappings
|
|
50
|
+
owner() {
|
|
51
|
+
return _owner(this.walletClient);
|
|
52
|
+
}
|
|
13
53
|
eSIMWalletAdmin() {
|
|
14
54
|
return _eSIMWalletAdmin(this.walletClient);
|
|
15
55
|
}
|
|
56
|
+
adminOfRecord() {
|
|
57
|
+
return _adminOfRecord(this.walletClient);
|
|
58
|
+
}
|
|
59
|
+
adminDisabled() {
|
|
60
|
+
return _adminDisabled(this.walletClient);
|
|
61
|
+
}
|
|
62
|
+
newRequestedAdmin() {
|
|
63
|
+
return _newRequestedAdmin(this.walletClient);
|
|
64
|
+
}
|
|
16
65
|
vault() {
|
|
17
66
|
return _vault(this.walletClient);
|
|
18
67
|
}
|
|
@@ -40,4 +89,46 @@ export class AdminRegistrySubPackage {
|
|
|
40
89
|
isESIMWalletOnStandby(eSIMWallet) {
|
|
41
90
|
return _isESIMWalletOnStandby(this.walletClient, eSIMWallet);
|
|
42
91
|
}
|
|
92
|
+
paused() {
|
|
93
|
+
return _paused(this.walletClient);
|
|
94
|
+
}
|
|
95
|
+
defaultDataBundlePriceCap() {
|
|
96
|
+
return _defaultDataBundlePriceCap(this.walletClient);
|
|
97
|
+
}
|
|
98
|
+
isDeviceIdentifierAlreadyUsed(deviceUniqueIdentifier) {
|
|
99
|
+
return _isDeviceIdentifierAlreadyUsed(this.walletClient, deviceUniqueIdentifier);
|
|
100
|
+
}
|
|
101
|
+
isESIMIdentifierClaimed(eSIMUniqueIdentifier) {
|
|
102
|
+
return _isESIMIdentifierClaimed(this.walletClient, eSIMUniqueIdentifier);
|
|
103
|
+
}
|
|
104
|
+
eSIMWalletForIdentifier(eSIMUniqueIdentifier) {
|
|
105
|
+
return _eSIMWalletForIdentifier(this.walletClient, eSIMUniqueIdentifier);
|
|
106
|
+
}
|
|
107
|
+
claimedESIMIdentifiers(hashOfESIMIdentifier) {
|
|
108
|
+
return _claimedESIMIdentifiers(this.walletClient, hashOfESIMIdentifier);
|
|
109
|
+
}
|
|
110
|
+
requireDeviceIdentifierNotReserved(deviceUniqueIdentifier) {
|
|
111
|
+
return _requireDeviceIdentifierNotReserved(this.walletClient, deviceUniqueIdentifier);
|
|
112
|
+
}
|
|
113
|
+
requireNotPaused() {
|
|
114
|
+
return _requireNotPaused(this.walletClient);
|
|
115
|
+
}
|
|
116
|
+
pendingOwner() {
|
|
117
|
+
return _pendingOwner(this.walletClient);
|
|
118
|
+
}
|
|
119
|
+
deviceWalletFactory() {
|
|
120
|
+
return _deviceWalletFactory(this.walletClient);
|
|
121
|
+
}
|
|
122
|
+
eSIMWalletFactory() {
|
|
123
|
+
return _eSIMWalletFactory(this.walletClient);
|
|
124
|
+
}
|
|
125
|
+
entryPoint() {
|
|
126
|
+
return _entryPoint(this.walletClient);
|
|
127
|
+
}
|
|
128
|
+
proxiableUUID() {
|
|
129
|
+
return _proxiableUUID(this.walletClient);
|
|
130
|
+
}
|
|
131
|
+
upgradeInterfaceVersion() {
|
|
132
|
+
return _upgradeInterfaceVersion(this.walletClient);
|
|
133
|
+
}
|
|
43
134
|
}
|
package/dist/esm/config.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ConstantsSubPackage } from "./interface/constantsClass.js";
|
|
|
2
2
|
import { SmartAccountSubPackage } from "./interface/smartAccountClass.js";
|
|
3
3
|
import { DeviceWalletFactorySubPackage } from "./interface/deviceWalletFactoryClass.js";
|
|
4
4
|
import { P256VerifierSubPackage } from "./interface/P256VerifierClass.js";
|
|
5
|
-
import {
|
|
5
|
+
import { RegistrySubPackage } from "./interface/registryClass.js";
|
|
6
6
|
import { DeviceWalletSubPackage } from "./interface/deviceWalletClass.js";
|
|
7
7
|
import { ESIMWalletSubPackage } from "./interface/eSIMWalletClass.js";
|
|
8
8
|
import { ESIMWalletFactorySubPackage } from "./interface/eSIMWalletFactoryClass.js";
|
|
@@ -14,29 +14,33 @@ export class Kokio {
|
|
|
14
14
|
viemWalletClient;
|
|
15
15
|
credentialId;
|
|
16
16
|
rpId;
|
|
17
|
-
organizationId;
|
|
18
17
|
pimlicoAPIKey;
|
|
19
18
|
gasPolicyId;
|
|
19
|
+
smartAccountClient;
|
|
20
|
+
deviceWalletAddress;
|
|
21
|
+
eSIMWalletAddress;
|
|
20
22
|
_constants;
|
|
21
23
|
smartAccount;
|
|
22
24
|
deviceWalletFactory;
|
|
23
25
|
eSIMWalletFactory;
|
|
24
|
-
|
|
26
|
+
registry;
|
|
25
27
|
deviceWallet;
|
|
26
28
|
eSIMWallet;
|
|
27
29
|
P256Verifier;
|
|
28
|
-
constructor(viemWalletClient, credentialId, rpId,
|
|
30
|
+
constructor(viemWalletClient, credentialId, rpId, pimlicoAPIKey, gasPolicyId, smartAccountClient, deviceWalletAddress, eSIMWalletAddress) {
|
|
29
31
|
this.viemWalletClient = viemWalletClient;
|
|
30
32
|
this.credentialId = credentialId;
|
|
31
33
|
this.rpId = rpId;
|
|
32
|
-
this.organizationId = organizationId;
|
|
33
34
|
this.pimlicoAPIKey = pimlicoAPIKey;
|
|
34
35
|
this.gasPolicyId = gasPolicyId;
|
|
36
|
+
this.smartAccountClient = smartAccountClient;
|
|
37
|
+
this.deviceWalletAddress = deviceWalletAddress;
|
|
38
|
+
this.eSIMWalletAddress = eSIMWalletAddress;
|
|
35
39
|
this._constants = new ConstantsSubPackage(this.viemWalletClient, this.pimlicoAPIKey);
|
|
36
|
-
this.smartAccount = new SmartAccountSubPackage(this.viemWalletClient, this.credentialId, this.rpId, this.
|
|
40
|
+
this.smartAccount = new SmartAccountSubPackage(this.viemWalletClient, this.credentialId, this.rpId, this.pimlicoAPIKey, this.gasPolicyId);
|
|
37
41
|
this.deviceWalletFactory = smartAccountClient ? new DeviceWalletFactorySubPackage(viemWalletClient, smartAccountClient) : undefined;
|
|
38
42
|
this.eSIMWalletFactory = smartAccountClient ? new ESIMWalletFactorySubPackage(viemWalletClient, smartAccountClient) : undefined;
|
|
39
|
-
this.
|
|
43
|
+
this.registry = smartAccountClient ? new RegistrySubPackage(smartAccountClient) : undefined;
|
|
40
44
|
this.P256Verifier = smartAccountClient ? new P256VerifierSubPackage(smartAccountClient) : undefined;
|
|
41
45
|
this.deviceWallet = deviceWalletAddress && smartAccountClient ? new DeviceWalletSubPackage(viemWalletClient, smartAccountClient, deviceWalletAddress) : undefined;
|
|
42
46
|
this.eSIMWallet = eSIMWalletAddress && smartAccountClient ? new ESIMWalletSubPackage(smartAccountClient, eSIMWalletAddress) : undefined;
|
|
@@ -53,4 +57,35 @@ export class Kokio {
|
|
|
53
57
|
get constants() {
|
|
54
58
|
return this._constants.load();
|
|
55
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Bind a `DeviceWallet` instance address after construction and (re)wire
|
|
62
|
+
* the `deviceWallet` surface to it. Returns `this` for chaining.
|
|
63
|
+
*
|
|
64
|
+
* Needs a `smartAccountClient` already on this instance - every write on
|
|
65
|
+
* `deviceWallet` sends a user operation through it. Without one,
|
|
66
|
+
* `deviceWallet` stays `undefined`, same as when no address is passed to
|
|
67
|
+
* the constructor.
|
|
68
|
+
*/
|
|
69
|
+
setDeviceWalletAddress(deviceWalletAddress) {
|
|
70
|
+
this.deviceWalletAddress = deviceWalletAddress;
|
|
71
|
+
this.deviceWallet = this.smartAccountClient
|
|
72
|
+
? new DeviceWalletSubPackage(this.viemWalletClient, this.smartAccountClient, deviceWalletAddress)
|
|
73
|
+
: undefined;
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Bind an `ESIMWallet` instance address after construction and (re)wire
|
|
78
|
+
* the `eSIMWallet` surface to it. Returns `this` for chaining.
|
|
79
|
+
*
|
|
80
|
+
* A user holding several eSIM wallets can call this to switch which one
|
|
81
|
+
* `kokio.eSIMWallet` acts on, without re-creating `Kokio`. Same
|
|
82
|
+
* `smartAccountClient` requirement as {@link setDeviceWalletAddress}.
|
|
83
|
+
*/
|
|
84
|
+
setESIMWalletAddress(eSIMWalletAddress) {
|
|
85
|
+
this.eSIMWalletAddress = eSIMWalletAddress;
|
|
86
|
+
this.eSIMWallet = this.smartAccountClient
|
|
87
|
+
? new ESIMWalletSubPackage(this.smartAccountClient, eSIMWalletAddress)
|
|
88
|
+
: undefined;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
56
91
|
}
|