@metamask/keyring-api 21.2.0 → 21.4.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/CHANGELOG.md +44 -1
- package/README.md +11 -0
- package/dist/api/account-options.cjs +44 -7
- package/dist/api/account-options.cjs.map +1 -1
- package/dist/api/account-options.d.cts +41 -3
- package/dist/api/account-options.d.cts.map +1 -1
- package/dist/api/account-options.d.mts +41 -3
- package/dist/api/account-options.d.mts.map +1 -1
- package/dist/api/account-options.mjs +43 -6
- package/dist/api/account-options.mjs.map +1 -1
- package/dist/api/account.cjs +15 -1
- package/dist/api/account.cjs.map +1 -1
- package/dist/api/account.d.cts +18 -0
- package/dist/api/account.d.cts.map +1 -1
- package/dist/api/account.d.mts +18 -0
- package/dist/api/account.d.mts.map +1 -1
- package/dist/api/account.mjs +14 -0
- package/dist/api/account.mjs.map +1 -1
- package/dist/api/index.cjs +1 -0
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +1 -0
- package/dist/api/index.d.cts.map +1 -1
- package/dist/api/index.d.mts +1 -0
- package/dist/api/index.d.mts.map +1 -1
- package/dist/api/index.mjs +1 -0
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/keyring.cjs +0 -2
- package/dist/api/keyring.cjs.map +1 -1
- package/dist/api/keyring.d.cts +13 -0
- package/dist/api/keyring.d.cts.map +1 -1
- package/dist/api/keyring.d.mts +13 -0
- package/dist/api/keyring.d.mts.map +1 -1
- package/dist/api/keyring.mjs +0 -2
- package/dist/api/keyring.mjs.map +1 -1
- package/dist/api/v2/create-account/bip44.cjs +83 -0
- package/dist/api/v2/create-account/bip44.cjs.map +1 -0
- package/dist/api/v2/create-account/bip44.d.cts +129 -0
- package/dist/api/v2/create-account/bip44.d.cts.map +1 -0
- package/dist/api/v2/create-account/bip44.d.mts +129 -0
- package/dist/api/v2/create-account/bip44.d.mts.map +1 -0
- package/dist/api/v2/create-account/bip44.mjs +80 -0
- package/dist/api/v2/create-account/bip44.mjs.map +1 -0
- package/dist/api/v2/create-account/custom.cjs +14 -0
- package/dist/api/v2/create-account/custom.cjs.map +1 -0
- package/dist/api/v2/create-account/custom.d.cts +25 -0
- package/dist/api/v2/create-account/custom.d.cts.map +1 -0
- package/dist/api/v2/create-account/custom.d.mts +25 -0
- package/dist/api/v2/create-account/custom.d.mts.map +1 -0
- package/dist/api/v2/create-account/custom.mjs +11 -0
- package/dist/api/v2/create-account/custom.mjs.map +1 -0
- package/dist/api/v2/create-account/index.cjs +93 -0
- package/dist/api/v2/create-account/index.cjs.map +1 -0
- package/dist/api/v2/create-account/index.d.cts +83 -0
- package/dist/api/v2/create-account/index.d.cts.map +1 -0
- package/dist/api/v2/create-account/index.d.mts +83 -0
- package/dist/api/v2/create-account/index.d.mts.map +1 -0
- package/dist/api/v2/create-account/index.mjs +76 -0
- package/dist/api/v2/create-account/index.mjs.map +1 -0
- package/dist/api/v2/create-account/private-key.cjs +28 -0
- package/dist/api/v2/create-account/private-key.cjs.map +1 -0
- package/dist/api/v2/create-account/private-key.d.cts +45 -0
- package/dist/api/v2/create-account/private-key.d.cts.map +1 -0
- package/dist/api/v2/create-account/private-key.d.mts +45 -0
- package/dist/api/v2/create-account/private-key.d.mts.map +1 -0
- package/dist/api/v2/create-account/private-key.mjs +25 -0
- package/dist/api/v2/create-account/private-key.mjs.map +1 -0
- package/dist/api/v2/export-account/index.cjs +38 -0
- package/dist/api/v2/export-account/index.cjs.map +1 -0
- package/dist/api/v2/export-account/index.d.cts +48 -0
- package/dist/api/v2/export-account/index.d.cts.map +1 -0
- package/dist/api/v2/export-account/index.d.mts +48 -0
- package/dist/api/v2/export-account/index.d.mts.map +1 -0
- package/dist/api/v2/export-account/index.mjs +21 -0
- package/dist/api/v2/export-account/index.mjs.map +1 -0
- package/dist/api/v2/export-account/private-key.cjs +36 -0
- package/dist/api/v2/export-account/private-key.cjs.map +1 -0
- package/dist/api/v2/export-account/private-key.d.cts +53 -0
- package/dist/api/v2/export-account/private-key.d.cts.map +1 -0
- package/dist/api/v2/export-account/private-key.d.mts +53 -0
- package/dist/api/v2/export-account/private-key.d.mts.map +1 -0
- package/dist/api/v2/export-account/private-key.mjs +33 -0
- package/dist/api/v2/export-account/private-key.mjs.map +1 -0
- package/dist/api/v2/index.cjs +23 -0
- package/dist/api/v2/index.cjs.map +1 -0
- package/dist/api/v2/index.d.cts +8 -0
- package/dist/api/v2/index.d.cts.map +1 -0
- package/dist/api/v2/index.d.mts +8 -0
- package/dist/api/v2/index.d.mts.map +1 -0
- package/dist/api/v2/index.mjs +7 -0
- package/dist/api/v2/index.mjs.map +1 -0
- package/dist/api/v2/keyring-capabilities.cjs +60 -0
- package/dist/api/v2/keyring-capabilities.cjs.map +1 -0
- package/dist/api/v2/keyring-capabilities.d.cts +150 -0
- package/dist/api/v2/keyring-capabilities.d.cts.map +1 -0
- package/dist/api/v2/keyring-capabilities.d.mts +150 -0
- package/dist/api/v2/keyring-capabilities.d.mts.map +1 -0
- package/dist/api/v2/keyring-capabilities.mjs +57 -0
- package/dist/api/v2/keyring-capabilities.mjs.map +1 -0
- package/dist/api/v2/keyring-type.cjs +44 -0
- package/dist/api/v2/keyring-type.cjs.map +1 -0
- package/dist/api/v2/keyring-type.d.cts +40 -0
- package/dist/api/v2/keyring-type.d.cts.map +1 -0
- package/dist/api/v2/keyring-type.d.mts +40 -0
- package/dist/api/v2/keyring-type.d.mts.map +1 -0
- package/dist/api/v2/keyring-type.mjs +41 -0
- package/dist/api/v2/keyring-type.mjs.map +1 -0
- package/dist/api/v2/keyring.cjs +3 -0
- package/dist/api/v2/keyring.cjs.map +1 -0
- package/dist/api/v2/keyring.d.cts +107 -0
- package/dist/api/v2/keyring.d.cts.map +1 -0
- package/dist/api/v2/keyring.d.mts +107 -0
- package/dist/api/v2/keyring.d.mts.map +1 -0
- package/dist/api/v2/keyring.mjs +2 -0
- package/dist/api/v2/keyring.mjs.map +1 -0
- package/dist/api/v2/private-key.cjs +53 -0
- package/dist/api/v2/private-key.cjs.map +1 -0
- package/dist/api/v2/private-key.d.cts +77 -0
- package/dist/api/v2/private-key.d.cts.map +1 -0
- package/dist/api/v2/private-key.d.mts +77 -0
- package/dist/api/v2/private-key.d.mts.map +1 -0
- package/dist/api/v2/private-key.mjs +50 -0
- package/dist/api/v2/private-key.mjs.map +1 -0
- package/dist/api/v2/wrapper/index.cjs +19 -0
- package/dist/api/v2/wrapper/index.cjs.map +1 -0
- package/dist/api/v2/wrapper/index.d.cts +3 -0
- package/dist/api/v2/wrapper/index.d.cts.map +1 -0
- package/dist/api/v2/wrapper/index.d.mts +3 -0
- package/dist/api/v2/wrapper/index.d.mts.map +1 -0
- package/dist/api/v2/wrapper/index.mjs +3 -0
- package/dist/api/v2/wrapper/index.mjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.cjs +135 -0
- package/dist/api/v2/wrapper/keyring-account-registry.cjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.cts +88 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.cts.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.mts +88 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.mts.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.mjs +131 -0
- package/dist/api/v2/wrapper/keyring-account-registry.mjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.cjs +134 -0
- package/dist/api/v2/wrapper/keyring-wrapper.cjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.cts +154 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.cts.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.mts +154 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.mts.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.mjs +130 -0
- package/dist/api/v2/wrapper/keyring-wrapper.mjs.map +1 -0
- package/dist/btc/types.d.cts +16 -0
- package/dist/btc/types.d.cts.map +1 -1
- package/dist/btc/types.d.mts +16 -0
- package/dist/btc/types.d.mts.map +1 -1
- package/dist/eth/erc4337/types.d.cts +4 -4
- package/dist/eth/erc4337/types.d.mts +4 -4
- package/dist/eth/index.cjs +2 -0
- package/dist/eth/index.cjs.map +1 -1
- package/dist/eth/index.d.cts +2 -0
- package/dist/eth/index.d.cts.map +1 -1
- package/dist/eth/index.d.mts +2 -0
- package/dist/eth/index.d.mts.map +1 -1
- package/dist/eth/index.mjs +2 -0
- package/dist/eth/index.mjs.map +1 -1
- package/dist/eth/rpc/index.cjs +18 -0
- package/dist/eth/rpc/index.cjs.map +1 -0
- package/dist/eth/rpc/index.d.cts +2 -0
- package/dist/eth/rpc/index.d.cts.map +1 -0
- package/dist/eth/rpc/index.d.mts +2 -0
- package/dist/eth/rpc/index.d.mts.map +1 -0
- package/dist/eth/rpc/index.mjs +2 -0
- package/dist/eth/rpc/index.mjs.map +1 -0
- package/dist/eth/rpc/params.cjs +151 -0
- package/dist/eth/rpc/params.cjs.map +1 -0
- package/dist/eth/rpc/params.d.cts +215 -0
- package/dist/eth/rpc/params.d.cts.map +1 -0
- package/dist/eth/rpc/params.d.mts +215 -0
- package/dist/eth/rpc/params.d.mts.map +1 -0
- package/dist/eth/rpc/params.mjs +148 -0
- package/dist/eth/rpc/params.mjs.map +1 -0
- package/dist/eth/types.cjs.map +1 -1
- package/dist/eth/types.d.cts +13 -5
- package/dist/eth/types.d.cts.map +1 -1
- package/dist/eth/types.d.mts +13 -5
- package/dist/eth/types.d.mts.map +1 -1
- package/dist/eth/types.mjs.map +1 -1
- package/dist/eth/v2/eth-keyring-wrapper.cjs +165 -0
- package/dist/eth/v2/eth-keyring-wrapper.cjs.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.cts +54 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.cts.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.mts +54 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.mts.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.mjs +161 -0
- package/dist/eth/v2/eth-keyring-wrapper.mjs.map +1 -0
- package/dist/eth/v2/index.cjs +18 -0
- package/dist/eth/v2/index.cjs.map +1 -0
- package/dist/eth/v2/index.d.cts +2 -0
- package/dist/eth/v2/index.d.cts.map +1 -0
- package/dist/eth/v2/index.d.mts +2 -0
- package/dist/eth/v2/index.d.mts.map +1 -0
- package/dist/eth/v2/index.mjs +2 -0
- package/dist/eth/v2/index.mjs.map +1 -0
- package/dist/events.cjs +0 -2
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +16 -0
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.mts +16 -0
- package/dist/events.d.mts.map +1 -1
- package/dist/events.mjs +0 -2
- package/dist/events.mjs.map +1 -1
- package/dist/rpc.cjs +27 -12
- package/dist/rpc.cjs.map +1 -1
- package/dist/rpc.d.cts +200 -12
- package/dist/rpc.d.cts.map +1 -1
- package/dist/rpc.d.mts +200 -12
- package/dist/rpc.d.mts.map +1 -1
- package/dist/rpc.mjs +27 -12
- package/dist/rpc.mjs.map +1 -1
- package/dist/sol/types.d.cts +4 -0
- package/dist/sol/types.d.cts.map +1 -1
- package/dist/sol/types.d.mts +4 -0
- package/dist/sol/types.d.mts.map +1 -1
- package/dist/trx/types.cjs +4 -0
- package/dist/trx/types.cjs.map +1 -1
- package/dist/trx/types.d.cts +8 -0
- package/dist/trx/types.d.cts.map +1 -1
- package/dist/trx/types.d.mts +8 -0
- package/dist/trx/types.d.mts.map +1 -1
- package/dist/trx/types.mjs +4 -0
- package/dist/trx/types.mjs.map +1 -1
- package/package.json +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [21.4.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `Keyring.createAccounts` optional method ([#448](https://github.com/MetaMask/accounts/pull/448))
|
|
15
|
+
- This method is part of the keyring v2 specification and set as optional for backwards compatibility.
|
|
16
|
+
- This method can be used to create one or more accounts using the new keyring v2 account creation typed options.
|
|
17
|
+
- Add RPC support for this method through `KeyringRpcMethod.CreateAccounts`.
|
|
18
|
+
- Add support for account derivations using range of indices in `KeyringV2` ([#451](https://github.com/MetaMask/accounts/pull/451))
|
|
19
|
+
- Add `bip44:derive-index-range` capability to `KeyringCapabilities`.
|
|
20
|
+
- Add `AccountCreationType.Bip44DeriveIndexRange` and `CreateAccountBip44DeriveIndexRangeOptions`.
|
|
21
|
+
- Add support for custom capabilities and entropy types in `KeyringV2` ([#415](https://github.com/MetaMask/accounts/pull/415))
|
|
22
|
+
- Add `custom` capability to `KeyringCapabilities` for keyrings with non-standard `createAccounts` method.
|
|
23
|
+
- Add `KeyringAccountEntropyTypeOption.Custom` for custom/opaque entropy sources.
|
|
24
|
+
- Add `AccountCreationType.Custom` and `CreateAccountCustomOptions` for custom account creation flows.
|
|
25
|
+
- Add `EthKeyringWrapper` abstract class for Ethereum-based `KeyringV2` implementations ([#404](https://github.com/MetaMask/accounts/pull/404))
|
|
26
|
+
- Provides common Ethereum signing method routing (`submitRequest`) for all Ethereum-based keyrings.
|
|
27
|
+
- Add `KeyringWrapper` base class to adapt legacy keyrings to `KeyringV2` ([#398](https://github.com/MetaMask/accounts/pull/398)),([#402](https://github.com/MetaMask/accounts/pull/402)), ([#409](https://github.com/MetaMask/accounts/pull/409)), ([#410](https://github.com/MetaMask/accounts/pull/410))
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Make BIP-44 capabilities optional in `KeyringCapabilities` ([#453](https://github.com/MetaMask/accounts/pull/453))
|
|
32
|
+
- The `derivePath`, `deriveIndex`, `deriveIndexRange`, and `discover` capabilities are now optional.
|
|
33
|
+
- A capability set to `true` indicates support, while `false` or `undefined` indicates no support.
|
|
34
|
+
- Keyrings no longer need to explicitly set unsupported capabilities to `false`.
|
|
35
|
+
- Change `KeyringWrapper.capabilities` from a readonly property to a getter ([#447](https://github.com/MetaMask/accounts/pull/447))
|
|
36
|
+
- Allows subclasses to override and return capabilities dynamically based on runtime state.
|
|
37
|
+
- Refine `EthAddressStruct` in order to make it compatible with the `Hex` type from `@metamask/utils` ([#405](https://github.com/MetaMask/accounts/pull/405))
|
|
38
|
+
|
|
39
|
+
## [21.3.0]
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- Add initial `KeyringV2` interface ([#397](https://github.com/MetaMask/accounts/pull/397))
|
|
44
|
+
- This is an on-going work and should not be used for now.
|
|
45
|
+
- Add new Tron methods `signMessage` and `signTransaction` ([#401](https://github.com/MetaMask/accounts/pull/401))
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- Deprecate Tron methods `signMessageV2` and `verifyMessageV2` ([#401](https://github.com/MetaMask/accounts/pull/401))
|
|
50
|
+
|
|
10
51
|
## [21.2.0]
|
|
11
52
|
|
|
12
53
|
### Added
|
|
@@ -643,7 +684,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
643
684
|
- SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
|
|
644
685
|
- Helper functions to create keyring handler in the snap.
|
|
645
686
|
|
|
646
|
-
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.
|
|
687
|
+
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.4.0...HEAD
|
|
688
|
+
[21.4.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.3.0...@metamask/keyring-api@21.4.0
|
|
689
|
+
[21.3.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.2.0...@metamask/keyring-api@21.3.0
|
|
647
690
|
[21.2.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.1.0...@metamask/keyring-api@21.2.0
|
|
648
691
|
[21.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.0.0...@metamask/keyring-api@21.1.0
|
|
649
692
|
[21.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@20.1.1...@metamask/keyring-api@21.0.0
|
package/README.md
CHANGED
|
@@ -223,6 +223,17 @@ these instruction assume that you are already familiar with the process of
|
|
|
223
223
|
const accounts = await client.listAccounts();
|
|
224
224
|
```
|
|
225
225
|
|
|
226
|
+
## KeyringV2 Interface (WIP, not implemented yet)
|
|
227
|
+
|
|
228
|
+
A unified keyring interface, designed to work for both native (EVM) keyrings and Snap keyrings, and to support non‑EVM chains and new features like backup & sync.
|
|
229
|
+
|
|
230
|
+
- Interface name: `KeyringV2`
|
|
231
|
+
- Location: `@metamask/keyring-api/src/api/v2/keyring.ts`
|
|
232
|
+
|
|
233
|
+
### Keyring wrapper
|
|
234
|
+
|
|
235
|
+
The `KeyringWrapper` helper adapts existing keyrings that implement the legacy `Keyring` interface to the new `KeyringV2` interface. It is intended to be subclassed in concrete keyrings, overriding the account management and request-handling methods to delegate to the underlying implementation.
|
|
236
|
+
|
|
226
237
|
## Migrating from 0.1.x to 0.2.x
|
|
227
238
|
|
|
228
239
|
The following changes were made to the API, which may require changes to your
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KeyringAccountOptionsStruct = exports.KeyringAccountEntropyOptionsStruct = exports.KeyringAccountEntropyPrivateKeyOptionsStruct = exports.KeyringAccountEntropyMnemonicOptionsStruct = exports.KeyringAccountEntropyTypeOption = void 0;
|
|
3
|
+
exports.KeyringAccountOptionsStruct = exports.KeyringAccountEntropyOptionsStruct = exports.KeyringAccountEntropyCustomOptionsStruct = exports.KeyringAccountEntropyPrivateKeyOptionsStruct = exports.KeyringAccountEntropyMnemonicOptionsStruct = exports.KeyringAccountEntropyTypeOption = void 0;
|
|
4
4
|
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
5
5
|
const superstruct_1 = require("@metamask/superstruct");
|
|
6
6
|
const utils_1 = require("@metamask/utils");
|
|
@@ -17,6 +17,11 @@ var KeyringAccountEntropyTypeOption;
|
|
|
17
17
|
* Indicates that the account was imported from a private key.
|
|
18
18
|
*/
|
|
19
19
|
KeyringAccountEntropyTypeOption["PrivateKey"] = "private-key";
|
|
20
|
+
/**
|
|
21
|
+
* Indicates that the account was created with custom, keyring-specific entropy.
|
|
22
|
+
* This is an opaque type where the entropy source is managed internally by the keyring.
|
|
23
|
+
*/
|
|
24
|
+
KeyringAccountEntropyTypeOption["Custom"] = "custom";
|
|
20
25
|
})(KeyringAccountEntropyTypeOption || (exports.KeyringAccountEntropyTypeOption = KeyringAccountEntropyTypeOption = {}));
|
|
21
26
|
/**
|
|
22
27
|
* Keyring account options struct for mnemonics (BIP-44).
|
|
@@ -51,20 +56,43 @@ exports.KeyringAccountEntropyPrivateKeyOptionsStruct = (0, superstruct_1.object)
|
|
|
51
56
|
*/
|
|
52
57
|
type: (0, superstruct_1.literal)(`${KeyringAccountEntropyTypeOption.PrivateKey}`),
|
|
53
58
|
});
|
|
59
|
+
/**
|
|
60
|
+
* Keyring account options struct for custom entropy.
|
|
61
|
+
*
|
|
62
|
+
* This is an opaque type where the entropy source is managed internally by the keyring.
|
|
63
|
+
* It behaves similarly to a private key import but allows keyrings to define their own
|
|
64
|
+
* entropy management strategy.
|
|
65
|
+
*/
|
|
66
|
+
exports.KeyringAccountEntropyCustomOptionsStruct = (0, superstruct_1.object)({
|
|
67
|
+
/**
|
|
68
|
+
* Indicates that the account was created with custom, keyring-specific entropy.
|
|
69
|
+
*/
|
|
70
|
+
type: (0, superstruct_1.literal)(`${KeyringAccountEntropyTypeOption.Custom}`),
|
|
71
|
+
});
|
|
54
72
|
/**
|
|
55
73
|
* Keyring account entropy options struct.
|
|
56
74
|
*/
|
|
57
75
|
exports.KeyringAccountEntropyOptionsStruct = (0, keyring_utils_1.selectiveUnion)((value) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
if (!(0, utils_1.isPlainObject)(value)) {
|
|
77
|
+
return exports.KeyringAccountEntropyMnemonicOptionsStruct;
|
|
78
|
+
}
|
|
79
|
+
switch (value.type) {
|
|
80
|
+
case KeyringAccountEntropyTypeOption.PrivateKey:
|
|
81
|
+
return exports.KeyringAccountEntropyPrivateKeyOptionsStruct;
|
|
82
|
+
case KeyringAccountEntropyTypeOption.Custom:
|
|
83
|
+
return exports.KeyringAccountEntropyCustomOptionsStruct;
|
|
84
|
+
case KeyringAccountEntropyTypeOption.Mnemonic:
|
|
85
|
+
return exports.KeyringAccountEntropyMnemonicOptionsStruct;
|
|
86
|
+
default:
|
|
87
|
+
return exports.KeyringAccountEntropyMnemonicOptionsStruct;
|
|
88
|
+
}
|
|
62
89
|
});
|
|
63
90
|
/**
|
|
64
91
|
* Keyring options struct. This represents various options for a Keyring account object.
|
|
65
92
|
*
|
|
66
|
-
* See {@link KeyringAccountEntropyMnemonicOptionsStruct}
|
|
67
|
-
* {@link KeyringAccountEntropyPrivateKeyOptionsStruct}
|
|
93
|
+
* See {@link KeyringAccountEntropyMnemonicOptionsStruct},
|
|
94
|
+
* {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and
|
|
95
|
+
* {@link KeyringAccountEntropyCustomOptionsStruct}.
|
|
68
96
|
*
|
|
69
97
|
* @example
|
|
70
98
|
* ```ts
|
|
@@ -91,6 +119,15 @@ exports.KeyringAccountEntropyOptionsStruct = (0, keyring_utils_1.selectiveUnion)
|
|
|
91
119
|
* @example
|
|
92
120
|
* ```ts
|
|
93
121
|
* {
|
|
122
|
+
* entropy: {
|
|
123
|
+
* type: 'custom',
|
|
124
|
+
* },
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* {
|
|
94
131
|
* some: {
|
|
95
132
|
* untyped: 'options',
|
|
96
133
|
* something: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-options.cjs","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":";;;AAAA,2DAA8E;AAE9E,uDAQ+B;AAC/B,2CAA4D;AAE5D;;GAEG;AACH,IAAY,+
|
|
1
|
+
{"version":3,"file":"account-options.cjs","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":";;;AAAA,2DAA8E;AAE9E,uDAQ+B;AAC/B,2CAA4D;AAE5D;;GAEG;AACH,IAAY,+BAgBX;AAhBD,WAAY,+BAA+B;IACzC;;OAEG;IACH,wDAAqB,CAAA;IAErB;;OAEG;IACH,6DAA0B,CAAA;IAE1B;;;OAGG;IACH,oDAAiB,CAAA;AACnB,CAAC,EAhBW,+BAA+B,+CAA/B,+BAA+B,QAgB1C;AAED;;GAEG;AACU,QAAA,0CAA0C,GAAG,IAAA,oBAAM,EAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,+BAA+B,CAAC,QAAQ,EAAE,CAAC;IAE5D;;OAEG;IACH,EAAE,EAAE,IAAA,oBAAM,GAAE,EAAE,4CAA4C;IAE1D;;OAEG;IACH,cAAc,EAAE,IAAA,oBAAM,GAAE;IAExB;;;;;OAKG;IACH,UAAU,EAAE,IAAA,oBAAM,GAAE;CACrB,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,4CAA4C,GAAG,IAAA,oBAAM,EAAC;IACjE;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,+BAA+B,CAAC,UAAU,EAAE,CAAC;CAC/D,CAAC,CAAC;AASH;;;;;;GAMG;AACU,QAAA,wCAAwC,GAAG,IAAA,oBAAM,EAAC;IAC7D;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,+BAA+B,CAAC,MAAM,EAAE,CAAC;CAC3D,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,kCAAkC,GAAG,IAAA,8BAAc,EAC9D,CAAC,KAAU,EAAE,EAAE;IACb,IAAI,CAAC,IAAA,qBAAa,EAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,kDAA0C,CAAC;IACpD,CAAC;IAED,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,+BAA+B,CAAC,UAAU;YAC7C,OAAO,oDAA4C,CAAC;QACtD,KAAK,+BAA+B,CAAC,MAAM;YACzC,OAAO,gDAAwC,CAAC;QAClD,KAAK,+BAA+B,CAAC,QAAQ;YAC3C,OAAO,kDAA0C,CAAC;QACpD;YACE,OAAO,kDAA0C,CAAC;IACtD,CAAC;AACH,CAAC,CACF,CAAC;AASF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACU,QAAA,2BAA2B,GAAG,IAAA,0BAAY,EAAC;IACtD,2CAA2C;IAC3C,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;IAE5B,kEAAkE;IAClE,oEAAoE;IACpE,oEAAoE;IACpE,EAAE;IACF,uBAAuB;IACvB,uEAAuE;IACvE,oCAAoC;IACpC,IAAA,oBAAI,EAAC;QACH;;WAEG;QACH,OAAO,EAAE,IAAA,6BAAa,EAAC,0CAAkC,CAAC;QAE1D;;WAEG;QACH,UAAU,EAAE,IAAA,6BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;KACrC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { exactOptional, selectiveUnion, type } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n boolean,\n intersection,\n literal,\n number,\n object,\n record,\n string,\n} from '@metamask/superstruct';\nimport { isPlainObject, JsonStruct } from '@metamask/utils';\n\n/**\n * Keyring account entropy valid types.\n */\nexport enum KeyringAccountEntropyTypeOption {\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n Mnemonic = 'mnemonic',\n\n /**\n * Indicates that the account was imported from a private key.\n */\n PrivateKey = 'private-key',\n\n /**\n * Indicates that the account was created with custom, keyring-specific entropy.\n * This is an opaque type where the entropy source is managed internally by the keyring.\n */\n Custom = 'custom',\n}\n\n/**\n * Keyring account options struct for mnemonics (BIP-44).\n */\nexport const KeyringAccountEntropyMnemonicOptionsStruct = object({\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Mnemonic}`),\n\n /**\n * The ID of the entropy source.\n */\n id: string(), // TODO: Define a struct for entropy source.\n\n /**\n * The BIP-44 derivation path used to derive the account.\n */\n derivationPath: string(),\n\n /**\n * Index used to group accounts in the UI.\n *\n * Accounts sharing the same `groupIndex` are displayed together as a\n * multichain account group.\n */\n groupIndex: number(),\n});\n\n/**\n * Keyring account options for mnemonics (BIP-44) {@link KeyringAccountEntropyMnemonicOptionsStruct}.\n */\nexport type KeyringAccountEntropyMnemonicOptions = Infer<\n typeof KeyringAccountEntropyMnemonicOptionsStruct\n>;\n\n/**\n * Keyring account options struct for private keys.\n */\nexport const KeyringAccountEntropyPrivateKeyOptionsStruct = object({\n /**\n * Indicates that the account was imported from a private key.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),\n});\n\n/**\n * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n */\nexport type KeyringAccountEntropyPrivateKeyOptions = Infer<\n typeof KeyringAccountEntropyPrivateKeyOptionsStruct\n>;\n\n/**\n * Keyring account options struct for custom entropy.\n *\n * This is an opaque type where the entropy source is managed internally by the keyring.\n * It behaves similarly to a private key import but allows keyrings to define their own\n * entropy management strategy.\n */\nexport const KeyringAccountEntropyCustomOptionsStruct = object({\n /**\n * Indicates that the account was created with custom, keyring-specific entropy.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Custom}`),\n});\n\n/**\n * Keyring account options for custom entropy {@link KeyringAccountEntropyCustomOptionsStruct}.\n */\nexport type KeyringAccountEntropyCustomOptions = Infer<\n typeof KeyringAccountEntropyCustomOptionsStruct\n>;\n\n/**\n * Keyring account entropy options struct.\n */\nexport const KeyringAccountEntropyOptionsStruct = selectiveUnion(\n (value: any) => {\n if (!isPlainObject(value)) {\n return KeyringAccountEntropyMnemonicOptionsStruct;\n }\n\n switch (value.type) {\n case KeyringAccountEntropyTypeOption.PrivateKey:\n return KeyringAccountEntropyPrivateKeyOptionsStruct;\n case KeyringAccountEntropyTypeOption.Custom:\n return KeyringAccountEntropyCustomOptionsStruct;\n case KeyringAccountEntropyTypeOption.Mnemonic:\n return KeyringAccountEntropyMnemonicOptionsStruct;\n default:\n return KeyringAccountEntropyMnemonicOptionsStruct;\n }\n },\n);\n\n/**\n * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.\n */\nexport type KeyringAccountEntropyOptions = Infer<\n typeof KeyringAccountEntropyOptionsStruct\n>;\n\n/**\n * Keyring options struct. This represents various options for a Keyring account object.\n *\n * See {@link KeyringAccountEntropyMnemonicOptionsStruct},\n * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and\n * {@link KeyringAccountEntropyCustomOptionsStruct}.\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'mnemonic',\n * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',\n * derivationPath: \"m/44'/60'/0'/0/0\",\n * groupIndex: 0,\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'private-key',\n * },\n * exportable: true,\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'custom',\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * some: {\n * untyped: 'options',\n * something: true,\n * },\n * }\n * ```\n */\nexport const KeyringAccountOptionsStruct = intersection([\n // Non-Typed options (retro-compatibility):\n record(string(), JsonStruct),\n\n // Typed options. We use `type` instead of `object` here, to allow\n // extra properties. Also, since we use `record` + `intersection` we\n // are guaranteed that all field values will match the `JsonStruct`.\n //\n // READ THIS CAREFULLY:\n // Previous options that can be matched by this struct will be breaking\n // existing keyring account options.\n type({\n /**\n * Entropy options.\n */\n entropy: exactOptional(KeyringAccountEntropyOptionsStruct),\n\n /**\n * Indicates whether the account can be exported.\n */\n exportable: exactOptional(boolean()),\n }),\n]);\n\n/**\n * Keyring account options {@link KeyringAccountOptionsStruct}.\n */\nexport type KeyringAccountOptions = Infer<typeof KeyringAccountOptionsStruct>;\n"]}
|
|
@@ -10,7 +10,12 @@ export declare enum KeyringAccountEntropyTypeOption {
|
|
|
10
10
|
/**
|
|
11
11
|
* Indicates that the account was imported from a private key.
|
|
12
12
|
*/
|
|
13
|
-
PrivateKey = "private-key"
|
|
13
|
+
PrivateKey = "private-key",
|
|
14
|
+
/**
|
|
15
|
+
* Indicates that the account was created with custom, keyring-specific entropy.
|
|
16
|
+
* This is an opaque type where the entropy source is managed internally by the keyring.
|
|
17
|
+
*/
|
|
18
|
+
Custom = "custom"
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
21
|
* Keyring account options struct for mnemonics (BIP-44).
|
|
@@ -60,6 +65,25 @@ export declare const KeyringAccountEntropyPrivateKeyOptionsStruct: import("@meta
|
|
|
60
65
|
* Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
|
|
61
66
|
*/
|
|
62
67
|
export type KeyringAccountEntropyPrivateKeyOptions = Infer<typeof KeyringAccountEntropyPrivateKeyOptionsStruct>;
|
|
68
|
+
/**
|
|
69
|
+
* Keyring account options struct for custom entropy.
|
|
70
|
+
*
|
|
71
|
+
* This is an opaque type where the entropy source is managed internally by the keyring.
|
|
72
|
+
* It behaves similarly to a private key import but allows keyrings to define their own
|
|
73
|
+
* entropy management strategy.
|
|
74
|
+
*/
|
|
75
|
+
export declare const KeyringAccountEntropyCustomOptionsStruct: import("@metamask/superstruct").Struct<{
|
|
76
|
+
type: "custom";
|
|
77
|
+
}, {
|
|
78
|
+
/**
|
|
79
|
+
* Indicates that the account was created with custom, keyring-specific entropy.
|
|
80
|
+
*/
|
|
81
|
+
type: import("@metamask/superstruct").Struct<"custom", "custom">;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Keyring account options for custom entropy {@link KeyringAccountEntropyCustomOptionsStruct}.
|
|
85
|
+
*/
|
|
86
|
+
export type KeyringAccountEntropyCustomOptions = Infer<typeof KeyringAccountEntropyCustomOptionsStruct>;
|
|
63
87
|
/**
|
|
64
88
|
* Keyring account entropy options struct.
|
|
65
89
|
*/
|
|
@@ -70,6 +94,8 @@ export declare const KeyringAccountEntropyOptionsStruct: import("@metamask/super
|
|
|
70
94
|
groupIndex: number;
|
|
71
95
|
} | {
|
|
72
96
|
type: "private-key";
|
|
97
|
+
} | {
|
|
98
|
+
type: "custom";
|
|
73
99
|
}, null>;
|
|
74
100
|
/**
|
|
75
101
|
* Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.
|
|
@@ -78,8 +104,9 @@ export type KeyringAccountEntropyOptions = Infer<typeof KeyringAccountEntropyOpt
|
|
|
78
104
|
/**
|
|
79
105
|
* Keyring options struct. This represents various options for a Keyring account object.
|
|
80
106
|
*
|
|
81
|
-
* See {@link KeyringAccountEntropyMnemonicOptionsStruct}
|
|
82
|
-
* {@link KeyringAccountEntropyPrivateKeyOptionsStruct}
|
|
107
|
+
* See {@link KeyringAccountEntropyMnemonicOptionsStruct},
|
|
108
|
+
* {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and
|
|
109
|
+
* {@link KeyringAccountEntropyCustomOptionsStruct}.
|
|
83
110
|
*
|
|
84
111
|
* @example
|
|
85
112
|
* ```ts
|
|
@@ -106,6 +133,15 @@ export type KeyringAccountEntropyOptions = Infer<typeof KeyringAccountEntropyOpt
|
|
|
106
133
|
* @example
|
|
107
134
|
* ```ts
|
|
108
135
|
* {
|
|
136
|
+
* entropy: {
|
|
137
|
+
* type: 'custom',
|
|
138
|
+
* },
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* {
|
|
109
145
|
* some: {
|
|
110
146
|
* untyped: 'options',
|
|
111
147
|
* something: true,
|
|
@@ -121,6 +157,8 @@ export declare const KeyringAccountOptionsStruct: import("@metamask/superstruct"
|
|
|
121
157
|
groupIndex: number;
|
|
122
158
|
} | {
|
|
123
159
|
type: "private-key";
|
|
160
|
+
} | {
|
|
161
|
+
type: "custom";
|
|
124
162
|
};
|
|
125
163
|
exportable?: boolean;
|
|
126
164
|
}, null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-options.d.cts","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD;;GAEG;AACH,oBAAY,+BAA+B;IACzC;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,UAAU,gBAAgB;
|
|
1
|
+
{"version":3,"file":"account-options.d.cts","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD;;GAEG;AACH,oBAAY,+BAA+B;IACzC;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,UAAU,gBAAgB;IAE1B;;;OAGG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;;IACrD;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4CAA4C;;;IACvD;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,KAAK,CACxD,OAAO,4CAA4C,CACpD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wCAAwC;;;IACnD;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,KAAK,CACpD,OAAO,wCAAwC,CAChD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;QAiB9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,CAC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;QAsBtC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -10,7 +10,12 @@ export declare enum KeyringAccountEntropyTypeOption {
|
|
|
10
10
|
/**
|
|
11
11
|
* Indicates that the account was imported from a private key.
|
|
12
12
|
*/
|
|
13
|
-
PrivateKey = "private-key"
|
|
13
|
+
PrivateKey = "private-key",
|
|
14
|
+
/**
|
|
15
|
+
* Indicates that the account was created with custom, keyring-specific entropy.
|
|
16
|
+
* This is an opaque type where the entropy source is managed internally by the keyring.
|
|
17
|
+
*/
|
|
18
|
+
Custom = "custom"
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
21
|
* Keyring account options struct for mnemonics (BIP-44).
|
|
@@ -60,6 +65,25 @@ export declare const KeyringAccountEntropyPrivateKeyOptionsStruct: import("@meta
|
|
|
60
65
|
* Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
|
|
61
66
|
*/
|
|
62
67
|
export type KeyringAccountEntropyPrivateKeyOptions = Infer<typeof KeyringAccountEntropyPrivateKeyOptionsStruct>;
|
|
68
|
+
/**
|
|
69
|
+
* Keyring account options struct for custom entropy.
|
|
70
|
+
*
|
|
71
|
+
* This is an opaque type where the entropy source is managed internally by the keyring.
|
|
72
|
+
* It behaves similarly to a private key import but allows keyrings to define their own
|
|
73
|
+
* entropy management strategy.
|
|
74
|
+
*/
|
|
75
|
+
export declare const KeyringAccountEntropyCustomOptionsStruct: import("@metamask/superstruct").Struct<{
|
|
76
|
+
type: "custom";
|
|
77
|
+
}, {
|
|
78
|
+
/**
|
|
79
|
+
* Indicates that the account was created with custom, keyring-specific entropy.
|
|
80
|
+
*/
|
|
81
|
+
type: import("@metamask/superstruct").Struct<"custom", "custom">;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Keyring account options for custom entropy {@link KeyringAccountEntropyCustomOptionsStruct}.
|
|
85
|
+
*/
|
|
86
|
+
export type KeyringAccountEntropyCustomOptions = Infer<typeof KeyringAccountEntropyCustomOptionsStruct>;
|
|
63
87
|
/**
|
|
64
88
|
* Keyring account entropy options struct.
|
|
65
89
|
*/
|
|
@@ -70,6 +94,8 @@ export declare const KeyringAccountEntropyOptionsStruct: import("@metamask/super
|
|
|
70
94
|
groupIndex: number;
|
|
71
95
|
} | {
|
|
72
96
|
type: "private-key";
|
|
97
|
+
} | {
|
|
98
|
+
type: "custom";
|
|
73
99
|
}, null>;
|
|
74
100
|
/**
|
|
75
101
|
* Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.
|
|
@@ -78,8 +104,9 @@ export type KeyringAccountEntropyOptions = Infer<typeof KeyringAccountEntropyOpt
|
|
|
78
104
|
/**
|
|
79
105
|
* Keyring options struct. This represents various options for a Keyring account object.
|
|
80
106
|
*
|
|
81
|
-
* See {@link KeyringAccountEntropyMnemonicOptionsStruct}
|
|
82
|
-
* {@link KeyringAccountEntropyPrivateKeyOptionsStruct}
|
|
107
|
+
* See {@link KeyringAccountEntropyMnemonicOptionsStruct},
|
|
108
|
+
* {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and
|
|
109
|
+
* {@link KeyringAccountEntropyCustomOptionsStruct}.
|
|
83
110
|
*
|
|
84
111
|
* @example
|
|
85
112
|
* ```ts
|
|
@@ -106,6 +133,15 @@ export type KeyringAccountEntropyOptions = Infer<typeof KeyringAccountEntropyOpt
|
|
|
106
133
|
* @example
|
|
107
134
|
* ```ts
|
|
108
135
|
* {
|
|
136
|
+
* entropy: {
|
|
137
|
+
* type: 'custom',
|
|
138
|
+
* },
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* {
|
|
109
145
|
* some: {
|
|
110
146
|
* untyped: 'options',
|
|
111
147
|
* something: true,
|
|
@@ -121,6 +157,8 @@ export declare const KeyringAccountOptionsStruct: import("@metamask/superstruct"
|
|
|
121
157
|
groupIndex: number;
|
|
122
158
|
} | {
|
|
123
159
|
type: "private-key";
|
|
160
|
+
} | {
|
|
161
|
+
type: "custom";
|
|
124
162
|
};
|
|
125
163
|
exportable?: boolean;
|
|
126
164
|
}, null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-options.d.mts","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD;;GAEG;AACH,oBAAY,+BAA+B;IACzC;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,UAAU,gBAAgB;
|
|
1
|
+
{"version":3,"file":"account-options.d.mts","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD;;GAEG;AACH,oBAAY,+BAA+B;IACzC;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,UAAU,gBAAgB;IAE1B;;;OAGG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;;IACrD;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4CAA4C;;;IACvD;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,KAAK,CACxD,OAAO,4CAA4C,CACpD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wCAAwC;;;IACnD;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,KAAK,CACpD,OAAO,wCAAwC,CAChD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;QAiB9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,CAC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;QAsBtC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -14,6 +14,11 @@ export var KeyringAccountEntropyTypeOption;
|
|
|
14
14
|
* Indicates that the account was imported from a private key.
|
|
15
15
|
*/
|
|
16
16
|
KeyringAccountEntropyTypeOption["PrivateKey"] = "private-key";
|
|
17
|
+
/**
|
|
18
|
+
* Indicates that the account was created with custom, keyring-specific entropy.
|
|
19
|
+
* This is an opaque type where the entropy source is managed internally by the keyring.
|
|
20
|
+
*/
|
|
21
|
+
KeyringAccountEntropyTypeOption["Custom"] = "custom";
|
|
17
22
|
})(KeyringAccountEntropyTypeOption || (KeyringAccountEntropyTypeOption = {}));
|
|
18
23
|
/**
|
|
19
24
|
* Keyring account options struct for mnemonics (BIP-44).
|
|
@@ -48,20 +53,43 @@ export const KeyringAccountEntropyPrivateKeyOptionsStruct = object({
|
|
|
48
53
|
*/
|
|
49
54
|
type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),
|
|
50
55
|
});
|
|
56
|
+
/**
|
|
57
|
+
* Keyring account options struct for custom entropy.
|
|
58
|
+
*
|
|
59
|
+
* This is an opaque type where the entropy source is managed internally by the keyring.
|
|
60
|
+
* It behaves similarly to a private key import but allows keyrings to define their own
|
|
61
|
+
* entropy management strategy.
|
|
62
|
+
*/
|
|
63
|
+
export const KeyringAccountEntropyCustomOptionsStruct = object({
|
|
64
|
+
/**
|
|
65
|
+
* Indicates that the account was created with custom, keyring-specific entropy.
|
|
66
|
+
*/
|
|
67
|
+
type: literal(`${KeyringAccountEntropyTypeOption.Custom}`),
|
|
68
|
+
});
|
|
51
69
|
/**
|
|
52
70
|
* Keyring account entropy options struct.
|
|
53
71
|
*/
|
|
54
72
|
export const KeyringAccountEntropyOptionsStruct = selectiveUnion((value) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
if (!isPlainObject(value)) {
|
|
74
|
+
return KeyringAccountEntropyMnemonicOptionsStruct;
|
|
75
|
+
}
|
|
76
|
+
switch (value.type) {
|
|
77
|
+
case KeyringAccountEntropyTypeOption.PrivateKey:
|
|
78
|
+
return KeyringAccountEntropyPrivateKeyOptionsStruct;
|
|
79
|
+
case KeyringAccountEntropyTypeOption.Custom:
|
|
80
|
+
return KeyringAccountEntropyCustomOptionsStruct;
|
|
81
|
+
case KeyringAccountEntropyTypeOption.Mnemonic:
|
|
82
|
+
return KeyringAccountEntropyMnemonicOptionsStruct;
|
|
83
|
+
default:
|
|
84
|
+
return KeyringAccountEntropyMnemonicOptionsStruct;
|
|
85
|
+
}
|
|
59
86
|
});
|
|
60
87
|
/**
|
|
61
88
|
* Keyring options struct. This represents various options for a Keyring account object.
|
|
62
89
|
*
|
|
63
|
-
* See {@link KeyringAccountEntropyMnemonicOptionsStruct}
|
|
64
|
-
* {@link KeyringAccountEntropyPrivateKeyOptionsStruct}
|
|
90
|
+
* See {@link KeyringAccountEntropyMnemonicOptionsStruct},
|
|
91
|
+
* {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and
|
|
92
|
+
* {@link KeyringAccountEntropyCustomOptionsStruct}.
|
|
65
93
|
*
|
|
66
94
|
* @example
|
|
67
95
|
* ```ts
|
|
@@ -88,6 +116,15 @@ export const KeyringAccountEntropyOptionsStruct = selectiveUnion((value) => {
|
|
|
88
116
|
* @example
|
|
89
117
|
* ```ts
|
|
90
118
|
* {
|
|
119
|
+
* entropy: {
|
|
120
|
+
* type: 'custom',
|
|
121
|
+
* },
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* {
|
|
91
128
|
* some: {
|
|
92
129
|
* untyped: 'options',
|
|
93
130
|
* something: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-options.mjs","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,gCAAgC;AAE9E,OAAO,EACL,OAAO,EACP,YAAY,EACZ,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACP,8BAA8B;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,wBAAwB;AAE5D;;GAEG;AACH,MAAM,CAAN,IAAY,+
|
|
1
|
+
{"version":3,"file":"account-options.mjs","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,gCAAgC;AAE9E,OAAO,EACL,OAAO,EACP,YAAY,EACZ,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACP,8BAA8B;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,wBAAwB;AAE5D;;GAEG;AACH,MAAM,CAAN,IAAY,+BAgBX;AAhBD,WAAY,+BAA+B;IACzC;;OAEG;IACH,wDAAqB,CAAA;IAErB;;OAEG;IACH,6DAA0B,CAAA;IAE1B;;;OAGG;IACH,oDAAiB,CAAA;AACnB,CAAC,EAhBW,+BAA+B,KAA/B,+BAA+B,QAgB1C;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,MAAM,CAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,+BAA+B,CAAC,QAAQ,EAAE,CAAC;IAE5D;;OAEG;IACH,EAAE,EAAE,MAAM,EAAE,EAAE,4CAA4C;IAE1D;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE;IAExB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,4CAA4C,GAAG,MAAM,CAAC;IACjE;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,+BAA+B,CAAC,UAAU,EAAE,CAAC;CAC/D,CAAC,CAAC;AASH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wCAAwC,GAAG,MAAM,CAAC;IAC7D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,+BAA+B,CAAC,MAAM,EAAE,CAAC;CAC3D,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,cAAc,CAC9D,CAAC,KAAU,EAAE,EAAE;IACb,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,0CAA0C,CAAC;IACpD,CAAC;IAED,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,+BAA+B,CAAC,UAAU;YAC7C,OAAO,4CAA4C,CAAC;QACtD,KAAK,+BAA+B,CAAC,MAAM;YACzC,OAAO,wCAAwC,CAAC;QAClD,KAAK,+BAA+B,CAAC,QAAQ;YAC3C,OAAO,0CAA0C,CAAC;QACpD;YACE,OAAO,0CAA0C,CAAC;IACtD,CAAC;AACH,CAAC,CACF,CAAC;AASF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,YAAY,CAAC;IACtD,2CAA2C;IAC3C,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC;IAE5B,kEAAkE;IAClE,oEAAoE;IACpE,oEAAoE;IACpE,EAAE;IACF,uBAAuB;IACvB,uEAAuE;IACvE,oCAAoC;IACpC,IAAI,CAAC;QACH;;WAEG;QACH,OAAO,EAAE,aAAa,CAAC,kCAAkC,CAAC;QAE1D;;WAEG;QACH,UAAU,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;KACrC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { exactOptional, selectiveUnion, type } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n boolean,\n intersection,\n literal,\n number,\n object,\n record,\n string,\n} from '@metamask/superstruct';\nimport { isPlainObject, JsonStruct } from '@metamask/utils';\n\n/**\n * Keyring account entropy valid types.\n */\nexport enum KeyringAccountEntropyTypeOption {\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n Mnemonic = 'mnemonic',\n\n /**\n * Indicates that the account was imported from a private key.\n */\n PrivateKey = 'private-key',\n\n /**\n * Indicates that the account was created with custom, keyring-specific entropy.\n * This is an opaque type where the entropy source is managed internally by the keyring.\n */\n Custom = 'custom',\n}\n\n/**\n * Keyring account options struct for mnemonics (BIP-44).\n */\nexport const KeyringAccountEntropyMnemonicOptionsStruct = object({\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Mnemonic}`),\n\n /**\n * The ID of the entropy source.\n */\n id: string(), // TODO: Define a struct for entropy source.\n\n /**\n * The BIP-44 derivation path used to derive the account.\n */\n derivationPath: string(),\n\n /**\n * Index used to group accounts in the UI.\n *\n * Accounts sharing the same `groupIndex` are displayed together as a\n * multichain account group.\n */\n groupIndex: number(),\n});\n\n/**\n * Keyring account options for mnemonics (BIP-44) {@link KeyringAccountEntropyMnemonicOptionsStruct}.\n */\nexport type KeyringAccountEntropyMnemonicOptions = Infer<\n typeof KeyringAccountEntropyMnemonicOptionsStruct\n>;\n\n/**\n * Keyring account options struct for private keys.\n */\nexport const KeyringAccountEntropyPrivateKeyOptionsStruct = object({\n /**\n * Indicates that the account was imported from a private key.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),\n});\n\n/**\n * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n */\nexport type KeyringAccountEntropyPrivateKeyOptions = Infer<\n typeof KeyringAccountEntropyPrivateKeyOptionsStruct\n>;\n\n/**\n * Keyring account options struct for custom entropy.\n *\n * This is an opaque type where the entropy source is managed internally by the keyring.\n * It behaves similarly to a private key import but allows keyrings to define their own\n * entropy management strategy.\n */\nexport const KeyringAccountEntropyCustomOptionsStruct = object({\n /**\n * Indicates that the account was created with custom, keyring-specific entropy.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Custom}`),\n});\n\n/**\n * Keyring account options for custom entropy {@link KeyringAccountEntropyCustomOptionsStruct}.\n */\nexport type KeyringAccountEntropyCustomOptions = Infer<\n typeof KeyringAccountEntropyCustomOptionsStruct\n>;\n\n/**\n * Keyring account entropy options struct.\n */\nexport const KeyringAccountEntropyOptionsStruct = selectiveUnion(\n (value: any) => {\n if (!isPlainObject(value)) {\n return KeyringAccountEntropyMnemonicOptionsStruct;\n }\n\n switch (value.type) {\n case KeyringAccountEntropyTypeOption.PrivateKey:\n return KeyringAccountEntropyPrivateKeyOptionsStruct;\n case KeyringAccountEntropyTypeOption.Custom:\n return KeyringAccountEntropyCustomOptionsStruct;\n case KeyringAccountEntropyTypeOption.Mnemonic:\n return KeyringAccountEntropyMnemonicOptionsStruct;\n default:\n return KeyringAccountEntropyMnemonicOptionsStruct;\n }\n },\n);\n\n/**\n * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.\n */\nexport type KeyringAccountEntropyOptions = Infer<\n typeof KeyringAccountEntropyOptionsStruct\n>;\n\n/**\n * Keyring options struct. This represents various options for a Keyring account object.\n *\n * See {@link KeyringAccountEntropyMnemonicOptionsStruct},\n * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and\n * {@link KeyringAccountEntropyCustomOptionsStruct}.\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'mnemonic',\n * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',\n * derivationPath: \"m/44'/60'/0'/0/0\",\n * groupIndex: 0,\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'private-key',\n * },\n * exportable: true,\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'custom',\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * some: {\n * untyped: 'options',\n * something: true,\n * },\n * }\n * ```\n */\nexport const KeyringAccountOptionsStruct = intersection([\n // Non-Typed options (retro-compatibility):\n record(string(), JsonStruct),\n\n // Typed options. We use `type` instead of `object` here, to allow\n // extra properties. Also, since we use `record` + `intersection` we\n // are guaranteed that all field values will match the `JsonStruct`.\n //\n // READ THIS CAREFULLY:\n // Previous options that can be matched by this struct will be breaking\n // existing keyring account options.\n type({\n /**\n * Entropy options.\n */\n entropy: exactOptional(KeyringAccountEntropyOptionsStruct),\n\n /**\n * Indicates whether the account can be exported.\n */\n exportable: exactOptional(boolean()),\n }),\n]);\n\n/**\n * Keyring account options {@link KeyringAccountOptionsStruct}.\n */\nexport type KeyringAccountOptions = Infer<typeof KeyringAccountOptionsStruct>;\n"]}
|
package/dist/api/account.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KeyringAccountStruct = exports.AnyAccountType = exports.TrxAccountType = exports.SolAccountType = exports.BtcAccountType = exports.EthAccountType = void 0;
|
|
3
|
+
exports.KeyringAccountStruct = exports.KeyringAccountTypeStruct = exports.AnyAccountType = exports.TrxAccountType = exports.SolAccountType = exports.BtcAccountType = exports.EthAccountType = void 0;
|
|
4
4
|
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
5
5
|
const superstruct_1 = require("@metamask/superstruct");
|
|
6
6
|
const account_options_1 = require("./account-options.cjs");
|
|
@@ -45,6 +45,20 @@ var AnyAccountType;
|
|
|
45
45
|
(function (AnyAccountType) {
|
|
46
46
|
AnyAccountType["Account"] = "any:account";
|
|
47
47
|
})(AnyAccountType || (exports.AnyAccountType = AnyAccountType = {}));
|
|
48
|
+
/**
|
|
49
|
+
* Struct for {@link KeyringAccountType}.
|
|
50
|
+
*/
|
|
51
|
+
exports.KeyringAccountTypeStruct = (0, superstruct_1.enums)([
|
|
52
|
+
`${EthAccountType.Eoa}`,
|
|
53
|
+
`${EthAccountType.Erc4337}`,
|
|
54
|
+
`${BtcAccountType.P2pkh}`,
|
|
55
|
+
`${BtcAccountType.P2sh}`,
|
|
56
|
+
`${BtcAccountType.P2wpkh}`,
|
|
57
|
+
`${BtcAccountType.P2tr}`,
|
|
58
|
+
`${SolAccountType.DataAccount}`,
|
|
59
|
+
`${TrxAccountType.Eoa}`,
|
|
60
|
+
`${AnyAccountType.Account}`,
|
|
61
|
+
]);
|
|
48
62
|
/**
|
|
49
63
|
* A struct which represents a Keyring account object. It is abstract enough to
|
|
50
64
|
* be used with any blockchain. Specific blockchain account types should extend
|
package/dist/api/account.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.cjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AAAA,2DAAkE;AAElE,uDAAuE;AAEvE,2DAAgE;AAChE,qCAA2C;AAE3C;;GAEG;AACH,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED;;GAEG;AACH,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,wCAAsB,CAAA;IACtB,sCAAoB,CAAA;IACpB,0CAAwB,CAAA;IACxB,sCAAoB,CAAA;AACtB,CAAC,EALW,cAAc,8BAAd,cAAc,QAKzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,qDAAmC,CAAA;AACrC,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,kCAAgB,CAAA;AAClB,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAED;;;GAGG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,yCAAuB,CAAA;AACzB,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAgBD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,+BAAe;IAEnB;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,KAAK,EAAE;QACzB,GAAG,cAAc,CAAC,IAAI,EAAE;QACxB,GAAG,cAAc,CAAC,MAAM,EAAE;QAC1B,GAAG,cAAc,CAAC,IAAI,EAAE;QACxB,GAAG,cAAc,CAAC,WAAW,EAAE;QAC/B,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;KAC5B,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,wBAAiB,CAAC,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,6CAA2B;IAEpC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import { AccountIdStruct, object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, string } from '@metamask/superstruct';\n\nimport { KeyringAccountOptionsStruct } from './account-options';\nimport { CaipChainIdStruct } from './caip';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2pkh = 'bip122:p2pkh',\n P2sh = 'bip122:p2sh',\n P2wpkh = 'bip122:p2wpkh',\n P2tr = 'bip122:p2tr',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * Supported Tron account types.\n */\nexport enum TrxAccountType {\n Eoa = 'tron:eoa',\n}\n\n/**\n * A generic account type. It can be used to represent any account type that is\n * not covered by the other account types. It only applies to non-EVM chains.\n */\nexport enum AnyAccountType {\n Account = 'any:account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2pkh}`\n | `${BtcAccountType.P2sh}`\n | `${BtcAccountType.P2wpkh}`\n | `${BtcAccountType.P2tr}`\n | `${SolAccountType.DataAccount}`\n | `${TrxAccountType.Eoa}`\n | `${AnyAccountType.Account}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: AccountIdStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2pkh}`,\n `${BtcAccountType.P2sh}`,\n `${BtcAccountType.P2wpkh}`,\n `${BtcAccountType.P2tr}`,\n `${SolAccountType.DataAccount}`,\n `${TrxAccountType.Eoa}`,\n `${AnyAccountType.Account}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account options.\n */\n options: KeyringAccountOptionsStruct,\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}
|
|
1
|
+
{"version":3,"file":"account.cjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AAAA,2DAAkE;AAElE,uDAAuE;AAEvE,2DAAgE;AAChE,qCAA2C;AAE3C;;GAEG;AACH,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED;;GAEG;AACH,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,wCAAsB,CAAA;IACtB,sCAAoB,CAAA;IACpB,0CAAwB,CAAA;IACxB,sCAAoB,CAAA;AACtB,CAAC,EALW,cAAc,8BAAd,cAAc,QAKzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,qDAAmC,CAAA;AACrC,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,kCAAgB,CAAA;AAClB,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAED;;;GAGG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,yCAAuB,CAAA;AACzB,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAgBD;;GAEG;AACU,QAAA,wBAAwB,GAAG,IAAA,mBAAK,EAAC;IAC5C,GAAG,cAAc,CAAC,GAAG,EAAE;IACvB,GAAG,cAAc,CAAC,OAAO,EAAE;IAC3B,GAAG,cAAc,CAAC,KAAK,EAAE;IACzB,GAAG,cAAc,CAAC,IAAI,EAAE;IACxB,GAAG,cAAc,CAAC,MAAM,EAAE;IAC1B,GAAG,cAAc,CAAC,IAAI,EAAE;IACxB,GAAG,cAAc,CAAC,WAAW,EAAE;IAC/B,GAAG,cAAc,CAAC,GAAG,EAAE;IACvB,GAAG,cAAc,CAAC,OAAO,EAAE;CAC5B,CAAC,CAAC;AAEH;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,+BAAe;IAEnB;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,KAAK,EAAE;QACzB,GAAG,cAAc,CAAC,IAAI,EAAE;QACxB,GAAG,cAAc,CAAC,MAAM,EAAE;QAC1B,GAAG,cAAc,CAAC,IAAI,EAAE;QACxB,GAAG,cAAc,CAAC,WAAW,EAAE;QAC/B,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;KAC5B,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,wBAAiB,CAAC,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,6CAA2B;IAEpC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import { AccountIdStruct, object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, string } from '@metamask/superstruct';\n\nimport { KeyringAccountOptionsStruct } from './account-options';\nimport { CaipChainIdStruct } from './caip';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2pkh = 'bip122:p2pkh',\n P2sh = 'bip122:p2sh',\n P2wpkh = 'bip122:p2wpkh',\n P2tr = 'bip122:p2tr',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * Supported Tron account types.\n */\nexport enum TrxAccountType {\n Eoa = 'tron:eoa',\n}\n\n/**\n * A generic account type. It can be used to represent any account type that is\n * not covered by the other account types. It only applies to non-EVM chains.\n */\nexport enum AnyAccountType {\n Account = 'any:account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2pkh}`\n | `${BtcAccountType.P2sh}`\n | `${BtcAccountType.P2wpkh}`\n | `${BtcAccountType.P2tr}`\n | `${SolAccountType.DataAccount}`\n | `${TrxAccountType.Eoa}`\n | `${AnyAccountType.Account}`;\n\n/**\n * Struct for {@link KeyringAccountType}.\n */\nexport const KeyringAccountTypeStruct = enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2pkh}`,\n `${BtcAccountType.P2sh}`,\n `${BtcAccountType.P2wpkh}`,\n `${BtcAccountType.P2tr}`,\n `${SolAccountType.DataAccount}`,\n `${TrxAccountType.Eoa}`,\n `${AnyAccountType.Account}`,\n]);\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: AccountIdStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2pkh}`,\n `${BtcAccountType.P2sh}`,\n `${BtcAccountType.P2wpkh}`,\n `${BtcAccountType.P2tr}`,\n `${SolAccountType.DataAccount}`,\n `${TrxAccountType.Eoa}`,\n `${AnyAccountType.Account}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account options.\n */\n options: KeyringAccountOptionsStruct,\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}
|
package/dist/api/account.d.cts
CHANGED
|
@@ -38,6 +38,20 @@ export declare enum AnyAccountType {
|
|
|
38
38
|
* Supported account types.
|
|
39
39
|
*/
|
|
40
40
|
export type KeyringAccountType = `${EthAccountType.Eoa}` | `${EthAccountType.Erc4337}` | `${BtcAccountType.P2pkh}` | `${BtcAccountType.P2sh}` | `${BtcAccountType.P2wpkh}` | `${BtcAccountType.P2tr}` | `${SolAccountType.DataAccount}` | `${TrxAccountType.Eoa}` | `${AnyAccountType.Account}`;
|
|
41
|
+
/**
|
|
42
|
+
* Struct for {@link KeyringAccountType}.
|
|
43
|
+
*/
|
|
44
|
+
export declare const KeyringAccountTypeStruct: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account", {
|
|
45
|
+
"eip155:eoa": "eip155:eoa";
|
|
46
|
+
"eip155:erc4337": "eip155:erc4337";
|
|
47
|
+
"bip122:p2pkh": "bip122:p2pkh";
|
|
48
|
+
"bip122:p2sh": "bip122:p2sh";
|
|
49
|
+
"bip122:p2wpkh": "bip122:p2wpkh";
|
|
50
|
+
"bip122:p2tr": "bip122:p2tr";
|
|
51
|
+
"solana:data-account": "solana:data-account";
|
|
52
|
+
"tron:eoa": "tron:eoa";
|
|
53
|
+
"any:account": "any:account";
|
|
54
|
+
}>;
|
|
41
55
|
/**
|
|
42
56
|
* A struct which represents a Keyring account object. It is abstract enough to
|
|
43
57
|
* be used with any blockchain. Specific blockchain account types should extend
|
|
@@ -56,6 +70,8 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
|
|
|
56
70
|
groupIndex: number;
|
|
57
71
|
} | {
|
|
58
72
|
type: "private-key";
|
|
73
|
+
} | {
|
|
74
|
+
type: "custom";
|
|
59
75
|
};
|
|
60
76
|
exportable?: boolean;
|
|
61
77
|
};
|
|
@@ -100,6 +116,8 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
|
|
|
100
116
|
groupIndex: number;
|
|
101
117
|
} | {
|
|
102
118
|
type: "private-key";
|
|
119
|
+
} | {
|
|
120
|
+
type: "custom";
|
|
103
121
|
};
|
|
104
122
|
exportable?: boolean;
|
|
105
123
|
}, null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,KAAK,iBAAiB;IACtB,IAAI,gBAAgB;IACpB,MAAM,kBAAkB;IACxB,IAAI,gBAAgB;CACrB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,aAAa;CACjB;AAED;;;GAGG;AACH,oBAAY,cAAc;IACxB,OAAO,gBAAgB;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,GAC3B,GAAG,cAAc,CAAC,KAAK,EAAE,GACzB,GAAG,cAAc,CAAC,IAAI,EAAE,GACxB,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,IAAI,EAAE,GACxB,GAAG,cAAc,CAAC,WAAW,EAAE,GAC/B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;AAEhC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,KAAK,iBAAiB;IACtB,IAAI,gBAAgB;IACpB,MAAM,kBAAkB;IACxB,IAAI,gBAAgB;CACrB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,aAAa;CACjB;AAED;;;GAGG;AACH,oBAAY,cAAc;IACxB,OAAO,gBAAgB;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,GAC3B,GAAG,cAAc,CAAC,KAAK,EAAE,GACzB,GAAG,cAAc,CAAC,IAAI,EAAE,GACxB,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,IAAI,EAAE,GACxB,GAAG,cAAc,CAAC,WAAW,EAAE,GAC/B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;EAUnC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;IAC/B;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;IAaH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/api/account.d.mts
CHANGED
|
@@ -38,6 +38,20 @@ export declare enum AnyAccountType {
|
|
|
38
38
|
* Supported account types.
|
|
39
39
|
*/
|
|
40
40
|
export type KeyringAccountType = `${EthAccountType.Eoa}` | `${EthAccountType.Erc4337}` | `${BtcAccountType.P2pkh}` | `${BtcAccountType.P2sh}` | `${BtcAccountType.P2wpkh}` | `${BtcAccountType.P2tr}` | `${SolAccountType.DataAccount}` | `${TrxAccountType.Eoa}` | `${AnyAccountType.Account}`;
|
|
41
|
+
/**
|
|
42
|
+
* Struct for {@link KeyringAccountType}.
|
|
43
|
+
*/
|
|
44
|
+
export declare const KeyringAccountTypeStruct: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account", {
|
|
45
|
+
"eip155:eoa": "eip155:eoa";
|
|
46
|
+
"eip155:erc4337": "eip155:erc4337";
|
|
47
|
+
"bip122:p2pkh": "bip122:p2pkh";
|
|
48
|
+
"bip122:p2sh": "bip122:p2sh";
|
|
49
|
+
"bip122:p2wpkh": "bip122:p2wpkh";
|
|
50
|
+
"bip122:p2tr": "bip122:p2tr";
|
|
51
|
+
"solana:data-account": "solana:data-account";
|
|
52
|
+
"tron:eoa": "tron:eoa";
|
|
53
|
+
"any:account": "any:account";
|
|
54
|
+
}>;
|
|
41
55
|
/**
|
|
42
56
|
* A struct which represents a Keyring account object. It is abstract enough to
|
|
43
57
|
* be used with any blockchain. Specific blockchain account types should extend
|
|
@@ -56,6 +70,8 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
|
|
|
56
70
|
groupIndex: number;
|
|
57
71
|
} | {
|
|
58
72
|
type: "private-key";
|
|
73
|
+
} | {
|
|
74
|
+
type: "custom";
|
|
59
75
|
};
|
|
60
76
|
exportable?: boolean;
|
|
61
77
|
};
|
|
@@ -100,6 +116,8 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
|
|
|
100
116
|
groupIndex: number;
|
|
101
117
|
} | {
|
|
102
118
|
type: "private-key";
|
|
119
|
+
} | {
|
|
120
|
+
type: "custom";
|
|
103
121
|
};
|
|
104
122
|
exportable?: boolean;
|
|
105
123
|
}, null>;
|