11import type { KeyringAccount } from '@metamask/keyring-api' ;
22
33// Circular import are allowed when using `import type`.
4+ import type { Bip44Account } from './bip44' ;
45import type { AccountGroup , AccountGroupId } from './group' ;
6+ import type { MultichainAccountWallet } from './multichain' ;
57
68/**
79 * Wallet type.
@@ -37,7 +39,7 @@ export const ACCOUNT_WALLET_ID_REGEX =
3739 * in. All of those operations cannot run concurrently, thus, the wallet
3840 * cannot have multiple status at once.
3941 */
40- export type BaseAccountWalletStatus =
42+ export type AccountWalletStatus =
4143 /**
4244 * The wallet is not initialized yet.
4345 */
@@ -47,20 +49,6 @@ export type BaseAccountWalletStatus =
4749 */
4850 | 'ready' ;
4951
50- /**
51- * Wallet status.
52- *
53- * Those status are used to report in which "state" the wallet is currently
54- * in. All of those operations cannot run concurrently, thus, the wallet
55- * cannot have multiple status at once.
56- */
57- export type AccountWalletStatus =
58- | BaseAccountWalletStatus
59- /**
60- * The wallet is running an operation.
61- */
62- | `in-progress:${string } `;
63-
6452/**
6553 * Parsed account wallet ID with its wallet type and sub-ID.
6654 */
@@ -70,16 +58,16 @@ export type ParsedAccountWalletId = {
7058} ;
7159
7260/**
73- * Account wallet that can hold multiple account groups.
61+ * Keyring account wallet that can hold multiple account groups.
7462 */
75- export type AccountWallet < Account extends KeyringAccount > = {
63+ export type BaseAccountWallet < Account extends KeyringAccount > = {
7664 /**
7765 * Account wallet ID.
7866 */
7967 get id ( ) : AccountWalletId ;
8068
8169 /**
82- * Account wallet type.
70+ * Keyring account wallet type.
8371 */
8472 get type ( ) : AccountWalletType ;
8573
@@ -104,6 +92,50 @@ export type AccountWallet<Account extends KeyringAccount> = {
10492 getAccountGroups ( ) : AccountGroup < Account > [ ] ;
10593} ;
10694
95+ /**
96+ * Keyring account wallet that can hold multiple account groups.
97+ */
98+ export type KeyringAccountWallet < Account extends KeyringAccount > =
99+ BaseAccountWallet < Account > & {
100+ /**
101+ * Keyring account wallet type.
102+ */
103+ get type ( ) : AccountWalletType . Keyring ;
104+ } ;
105+
106+ /**
107+ * Snap keyring account wallet that can hold multiple account groups.
108+ */
109+ export type SnapAccountWallet < Account extends KeyringAccount > =
110+ BaseAccountWallet < Account > & {
111+ /**
112+ * Snap account wallet type.
113+ */
114+ get type ( ) : AccountWalletType . Snap ;
115+ } ;
116+
117+ /**
118+ * Type constraint for a {@link AccountGroupObject}. If one of its union-members
119+ * does not match this contraint, {@link AccountGroupObject} will resolve
120+ * to `never`.
121+ */
122+ type IsAccountWallet <
123+ Wallet extends BaseAccountWallet < Account > & {
124+ get type ( ) : AccountWalletType ;
125+ } ,
126+ Account extends KeyringAccount ,
127+ > = Wallet ;
128+
129+ /**
130+ * Account wallet that can hold multiple account groups.
131+ */
132+ export type AccountWallet < Account extends KeyringAccount > = IsAccountWallet <
133+ | KeyringAccountWallet < Account >
134+ | SnapAccountWallet < Account >
135+ | MultichainAccountWallet < Bip44Account < Account > > ,
136+ Account
137+ > ;
138+
107139/**
108140 * Type utility to compute a constrained {@link AccountWalletId} type given a
109141 * specifc {@link AccountWalletType}.
0 commit comments