@metamask-previews/account-api 0.9.0-a621908 → 0.10.0-9fbf2ff
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 +17 -1
- package/dist/api/group.cjs +53 -1
- package/dist/api/group.cjs.map +1 -1
- package/dist/api/group.d.cts +41 -1
- package/dist/api/group.d.cts.map +1 -1
- package/dist/api/group.d.mts +41 -1
- package/dist/api/group.d.mts.map +1 -1
- package/dist/api/group.mjs +49 -0
- package/dist/api/group.mjs.map +1 -1
- package/dist/api/multichain/group.cjs +35 -10
- package/dist/api/multichain/group.cjs.map +1 -1
- package/dist/api/multichain/group.d.cts +27 -0
- package/dist/api/multichain/group.d.cts.map +1 -1
- package/dist/api/multichain/group.d.mts +27 -0
- package/dist/api/multichain/group.d.mts.map +1 -1
- package/dist/api/multichain/group.mjs +32 -9
- package/dist/api/multichain/group.mjs.map +1 -1
- package/dist/api/multichain/wallet.cjs +34 -0
- package/dist/api/multichain/wallet.cjs.map +1 -1
- package/dist/api/multichain/wallet.d.cts +57 -2
- package/dist/api/multichain/wallet.d.cts.map +1 -1
- package/dist/api/multichain/wallet.d.mts +57 -2
- package/dist/api/multichain/wallet.d.mts.map +1 -1
- package/dist/api/multichain/wallet.mjs +31 -0
- package/dist/api/multichain/wallet.mjs.map +1 -1
- package/dist/api/provider.cjs.map +1 -1
- package/dist/api/provider.d.cts +8 -0
- package/dist/api/provider.d.cts.map +1 -1
- package/dist/api/provider.d.mts +8 -0
- package/dist/api/provider.d.mts.map +1 -1
- package/dist/api/provider.mjs.map +1 -1
- package/dist/api/wallet.cjs +45 -1
- package/dist/api/wallet.cjs.map +1 -1
- package/dist/api/wallet.d.cts +91 -3
- package/dist/api/wallet.d.cts.map +1 -1
- package/dist/api/wallet.d.mts +91 -3
- package/dist/api/wallet.d.mts.map +1 -1
- package/dist/api/wallet.mjs +41 -0
- package/dist/api/wallet.mjs.map +1 -1
- package/dist/mocks/accounts.cjs +10 -27
- package/dist/mocks/accounts.cjs.map +1 -1
- package/dist/mocks/accounts.d.cts +0 -18
- package/dist/mocks/accounts.d.cts.map +1 -1
- package/dist/mocks/accounts.d.mts +0 -18
- package/dist/mocks/accounts.d.mts.map +1 -1
- package/dist/mocks/accounts.mjs +3 -20
- package/dist/mocks/accounts.mjs.map +1 -1
- package/dist/mocks/groups.cjs +9 -0
- package/dist/mocks/groups.cjs.map +1 -0
- package/dist/mocks/groups.d.cts +5 -0
- package/dist/mocks/groups.d.cts.map +1 -0
- package/dist/mocks/groups.d.mts +5 -0
- package/dist/mocks/groups.d.mts.map +1 -0
- package/dist/mocks/groups.mjs +6 -0
- package/dist/mocks/groups.mjs.map +1 -0
- package/dist/mocks/index.cjs +4 -0
- package/dist/mocks/index.cjs.map +1 -1
- package/dist/mocks/index.d.cts +4 -0
- package/dist/mocks/index.d.cts.map +1 -1
- package/dist/mocks/index.d.mts +4 -0
- package/dist/mocks/index.d.mts.map +1 -1
- package/dist/mocks/index.mjs +4 -0
- package/dist/mocks/index.mjs.map +1 -1
- package/dist/mocks/keyrings.cjs +7 -0
- package/dist/mocks/keyrings.cjs.map +1 -0
- package/dist/mocks/keyrings.d.cts +4 -0
- package/dist/mocks/keyrings.d.cts.map +1 -0
- package/dist/mocks/keyrings.d.mts +4 -0
- package/dist/mocks/keyrings.d.mts.map +1 -0
- package/dist/mocks/keyrings.mjs +4 -0
- package/dist/mocks/keyrings.mjs.map +1 -0
- package/dist/mocks/snaps.cjs +20 -0
- package/dist/mocks/snaps.cjs.map +1 -0
- package/dist/mocks/snaps.d.cts +17 -0
- package/dist/mocks/snaps.d.cts.map +1 -0
- package/dist/mocks/snaps.d.mts +17 -0
- package/dist/mocks/snaps.d.mts.map +1 -0
- package/dist/mocks/snaps.mjs +17 -0
- package/dist/mocks/snaps.mjs.map +1 -0
- package/dist/mocks/wallets.cjs +11 -0
- package/dist/mocks/wallets.cjs.map +1 -0
- package/dist/mocks/wallets.d.cts +5 -0
- package/dist/mocks/wallets.d.cts.map +1 -0
- package/dist/mocks/wallets.d.mts +5 -0
- package/dist/mocks/wallets.d.mts.map +1 -0
- package/dist/mocks/wallets.mjs +8 -0
- package/dist/mocks/wallets.mjs.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.cts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAG5D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAgB;AAE5D;;;;GAIG;AACH,oBAAY,iBAAiB;IAC3B,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,2EAA2E;IAC3E,IAAI,SAAS;CACd;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,GAAG,iBAAiB,IAAI,MAAM,EAAE,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"wallet.d.cts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAG5D,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAgB;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,+BAAqB;AAE5D;;;;GAIG;AACH,oBAAY,iBAAiB;IAC3B,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,2EAA2E;IAC3E,IAAI,SAAS;CACd;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,GAAG,iBAAiB,IAAI,MAAM,EAAE,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,uBAAuB,QACyB,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB;AAC7B;;GAE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CAAC,GAC1B,uBAAuB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EAChD,OAAO,CACR,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,CAAC,UAAU,SAAS,iBAAiB,IAChE,GAAG,UAAU,IAAI,MAAM,EAAE,CAAC;AAE5B;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,SAAS,iBAAiB,EACpE,IAAI,EAAE,UAAU,EAChB,EAAE,EAAE,MAAM,GACT,iBAAiB,CAAC,UAAU,CAAC,CAE/B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,eAAe,CAEzE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CAU5E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
package/dist/api/wallet.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { KeyringAccount } from "@metamask/keyring-api";
|
|
2
|
+
import type { Bip44Account } from "./bip44.mjs";
|
|
2
3
|
import type { AccountGroup, AccountGroupId } from "./group.mjs";
|
|
4
|
+
import type { MultichainAccountWallet } from "./multichain/index.mjs";
|
|
3
5
|
/**
|
|
4
6
|
* Wallet type.
|
|
5
7
|
*
|
|
@@ -18,17 +20,48 @@ export declare enum AccountWalletType {
|
|
|
18
20
|
*/
|
|
19
21
|
export type AccountWalletId = `${AccountWalletType}:${string}`;
|
|
20
22
|
/**
|
|
21
|
-
*
|
|
23
|
+
* Regex to validate an account wallet ID.
|
|
24
|
+
*/
|
|
25
|
+
export declare const ACCOUNT_WALLET_ID_REGEX: RegExp;
|
|
26
|
+
/**
|
|
27
|
+
* Wallet status.
|
|
28
|
+
*
|
|
29
|
+
* Those status are used to report in which "state" the wallet is currently
|
|
30
|
+
* in. All of those operations cannot run concurrently, thus, the wallet
|
|
31
|
+
* cannot have multiple status at once.
|
|
32
|
+
*/
|
|
33
|
+
export type AccountWalletStatus =
|
|
34
|
+
/**
|
|
35
|
+
* The wallet is not initialized yet.
|
|
36
|
+
*/
|
|
37
|
+
'uninitialized'
|
|
38
|
+
/**
|
|
39
|
+
* The wallet is ready to run any operation.
|
|
40
|
+
*/
|
|
41
|
+
| 'ready';
|
|
42
|
+
/**
|
|
43
|
+
* Parsed account wallet ID with its wallet type and sub-ID.
|
|
22
44
|
*/
|
|
23
|
-
export type
|
|
45
|
+
export type ParsedAccountWalletId = {
|
|
46
|
+
type: AccountWalletType;
|
|
47
|
+
subId: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Keyring account wallet that can hold multiple account groups.
|
|
51
|
+
*/
|
|
52
|
+
export type BaseAccountWallet<Account extends KeyringAccount> = {
|
|
24
53
|
/**
|
|
25
54
|
* Account wallet ID.
|
|
26
55
|
*/
|
|
27
56
|
get id(): AccountWalletId;
|
|
28
57
|
/**
|
|
29
|
-
*
|
|
58
|
+
* Keyring account wallet type.
|
|
30
59
|
*/
|
|
31
60
|
get type(): AccountWalletType;
|
|
61
|
+
/**
|
|
62
|
+
* Account wallet status.
|
|
63
|
+
*/
|
|
64
|
+
get status(): AccountWalletStatus;
|
|
32
65
|
/**
|
|
33
66
|
* Gets account group for a given ID.
|
|
34
67
|
*
|
|
@@ -43,6 +76,36 @@ export type AccountWallet<Account extends KeyringAccount> = {
|
|
|
43
76
|
*/
|
|
44
77
|
getAccountGroups(): AccountGroup<Account>[];
|
|
45
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* Keyring account wallet that can hold multiple account groups.
|
|
81
|
+
*/
|
|
82
|
+
export type KeyringAccountWallet<Account extends KeyringAccount> = BaseAccountWallet<Account> & {
|
|
83
|
+
/**
|
|
84
|
+
* Keyring account wallet type.
|
|
85
|
+
*/
|
|
86
|
+
get type(): AccountWalletType.Keyring;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Snap keyring account wallet that can hold multiple account groups.
|
|
90
|
+
*/
|
|
91
|
+
export type SnapAccountWallet<Account extends KeyringAccount> = BaseAccountWallet<Account> & {
|
|
92
|
+
/**
|
|
93
|
+
* Snap account wallet type.
|
|
94
|
+
*/
|
|
95
|
+
get type(): AccountWalletType.Snap;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Type constraint for a {@link AccountGroupObject}. If one of its union-members
|
|
99
|
+
* does not match this contraint, {@link AccountGroupObject} will resolve
|
|
100
|
+
* to `never`.
|
|
101
|
+
*/
|
|
102
|
+
type IsAccountWallet<Wallet extends BaseAccountWallet<Account> & {
|
|
103
|
+
get type(): AccountWalletType;
|
|
104
|
+
}, Account extends KeyringAccount> = Wallet;
|
|
105
|
+
/**
|
|
106
|
+
* Account wallet that can hold multiple account groups.
|
|
107
|
+
*/
|
|
108
|
+
export type AccountWallet<Account extends KeyringAccount> = IsAccountWallet<KeyringAccountWallet<Account> | SnapAccountWallet<Account> | MultichainAccountWallet<Bip44Account<Account>>, Account>;
|
|
46
109
|
/**
|
|
47
110
|
* Type utility to compute a constrained {@link AccountWalletId} type given a
|
|
48
111
|
* specifc {@link AccountWalletType}.
|
|
@@ -56,4 +119,29 @@ export type AccountWalletIdOf<WalletType extends AccountWalletType> = `${WalletT
|
|
|
56
119
|
* @returns A wallet ID.
|
|
57
120
|
*/
|
|
58
121
|
export declare function toAccountWalletId<WalletType extends AccountWalletType>(type: WalletType, id: string): AccountWalletIdOf<WalletType>;
|
|
122
|
+
/**
|
|
123
|
+
* Checks if the given value is {@link AccountWalletId}.
|
|
124
|
+
*
|
|
125
|
+
* @param value - The value to check.
|
|
126
|
+
* @returns Whether the value is a {@link AccountWalletId}.
|
|
127
|
+
*/
|
|
128
|
+
export declare function isAccountWalletId(value: string): value is AccountWalletId;
|
|
129
|
+
/**
|
|
130
|
+
* Parse an account wallet ID to an object containing a wallet ID information
|
|
131
|
+
* (wallet type and wallet sub-ID).
|
|
132
|
+
*
|
|
133
|
+
* @param walletId - The account wallet ID to validate and parse.
|
|
134
|
+
* @returns The parsed account wallet ID.
|
|
135
|
+
* @throws When the wallet ID format is invalid.
|
|
136
|
+
*/
|
|
137
|
+
export declare function parseAccountWalletId(walletId: string): ParsedAccountWalletId;
|
|
138
|
+
/**
|
|
139
|
+
* Strip the account wallet type from an account wallet ID.
|
|
140
|
+
*
|
|
141
|
+
* @param walletId - Account wallet ID.
|
|
142
|
+
* @returns Account wallet sub-ID.
|
|
143
|
+
* @throws When the wallet ID format is invalid.
|
|
144
|
+
*/
|
|
145
|
+
export declare function stripAccountWalletType(walletId: string): string;
|
|
146
|
+
export {};
|
|
59
147
|
//# sourceMappingURL=wallet.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.mts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAG5D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAgB;AAE5D;;;;GAIG;AACH,oBAAY,iBAAiB;IAC3B,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,2EAA2E;IAC3E,IAAI,SAAS;CACd;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,GAAG,iBAAiB,IAAI,MAAM,EAAE,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"wallet.d.mts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAG5D,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAgB;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,+BAAqB;AAE5D;;;;GAIG;AACH,oBAA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C;AAEJ;;;;GAIG;AACH,KAAK,eAAe,CAClB,MAAM,SAAS,iBAAiB,CAAC,OAAO,CAAC,GAAG;IAC1C,IAAI,IAAI,IAAI,iBAAiB,CAAC;CAC/B,EACD,OAAO,SAAS,cAAc,IAC5B,MAAM,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,OAAO,SAAS,cAAc,IAAI,eAAe,CACvE,oBAAoB,CAAC,OAAO,CAAC,GAC7B,iBAAiB,CAAC,OAAO,CAAC,GAC1B,uBAAuB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EAChD,OAAO,CACR,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,CAAC,UAAU,SAAS,iBAAiB,IAChE,GAAG,UAAU,IAAI,MAAM,EAAE,CAAC;AAE5B;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,SAAS,iBAAiB,EACpE,IAAI,EAAE,UAAU,EAChB,EAAE,EAAE,MAAM,GACT,iBAAiB,CAAC,UAAU,CAAC,CAE/B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,eAAe,CAEzE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CAU5E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
package/dist/api/wallet.mjs
CHANGED
|
@@ -12,6 +12,10 @@ export var AccountWalletType;
|
|
|
12
12
|
/** Wallet grouping accounts associated with an account management Snap. */
|
|
13
13
|
AccountWalletType["Snap"] = "snap";
|
|
14
14
|
})(AccountWalletType || (AccountWalletType = {}));
|
|
15
|
+
/**
|
|
16
|
+
* Regex to validate an account wallet ID.
|
|
17
|
+
*/
|
|
18
|
+
export const ACCOUNT_WALLET_ID_REGEX = /^(?<walletType>entropy|keyring|snap):(?<walletSubId>.+)$/u;
|
|
15
19
|
/**
|
|
16
20
|
* Convert a unique ID to a wallet ID for a given type.
|
|
17
21
|
*
|
|
@@ -22,4 +26,41 @@ export var AccountWalletType;
|
|
|
22
26
|
export function toAccountWalletId(type, id) {
|
|
23
27
|
return `${type}:${id}`;
|
|
24
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the given value is {@link AccountWalletId}.
|
|
31
|
+
*
|
|
32
|
+
* @param value - The value to check.
|
|
33
|
+
* @returns Whether the value is a {@link AccountWalletId}.
|
|
34
|
+
*/
|
|
35
|
+
export function isAccountWalletId(value) {
|
|
36
|
+
return ACCOUNT_WALLET_ID_REGEX.test(value);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parse an account wallet ID to an object containing a wallet ID information
|
|
40
|
+
* (wallet type and wallet sub-ID).
|
|
41
|
+
*
|
|
42
|
+
* @param walletId - The account wallet ID to validate and parse.
|
|
43
|
+
* @returns The parsed account wallet ID.
|
|
44
|
+
* @throws When the wallet ID format is invalid.
|
|
45
|
+
*/
|
|
46
|
+
export function parseAccountWalletId(walletId) {
|
|
47
|
+
const match = ACCOUNT_WALLET_ID_REGEX.exec(walletId);
|
|
48
|
+
if (!match?.groups) {
|
|
49
|
+
throw new Error(`Invalid account wallet ID: "${walletId}"`);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
type: match.groups.walletType,
|
|
53
|
+
subId: match.groups.walletSubId,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Strip the account wallet type from an account wallet ID.
|
|
58
|
+
*
|
|
59
|
+
* @param walletId - Account wallet ID.
|
|
60
|
+
* @returns Account wallet sub-ID.
|
|
61
|
+
* @throws When the wallet ID format is invalid.
|
|
62
|
+
*/
|
|
63
|
+
export function stripAccountWalletType(walletId) {
|
|
64
|
+
return parseAccountWalletId(walletId).subId;
|
|
65
|
+
}
|
|
25
66
|
//# sourceMappingURL=wallet.mjs.map
|
package/dist/api/wallet.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.mjs","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.mjs","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAN,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC3B,8DAA8D;IAC9D,wCAAmB,CAAA;IAEnB,8DAA8D;IAC9D,wCAAmB,CAAA;IAEnB,2EAA2E;IAC3E,kCAAa,CAAA;AACf,CAAC,EATW,iBAAiB,KAAjB,iBAAiB,QAS5B;AAOD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAClC,2DAA2D,CAAC;AAiH9D;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAgB,EAChB,EAAU;IAEV,OAAO,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,MAAM,KAAK,GAAG,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAA+B;QAClD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,WAAqB;KAC1C,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\n\n// Circular import are allowed when using `import type`.\nimport type { Bip44Account } from './bip44';\nimport type { AccountGroup, AccountGroupId } from './group';\nimport type { MultichainAccountWallet } from './multichain';\n\n/**\n * Wallet type.\n *\n * Each wallet types groups accounts using different criterias.\n */\nexport enum AccountWalletType {\n /** Wallet grouping accounts based on their entropy source. */\n Entropy = 'entropy',\n\n /** Wallet grouping accounts based on their keyring's type. */\n Keyring = 'keyring',\n\n /** Wallet grouping accounts associated with an account management Snap. */\n Snap = 'snap',\n}\n\n/**\n * Account wallet ID.\n */\nexport type AccountWalletId = `${AccountWalletType}:${string}`;\n\n/**\n * Regex to validate an account wallet ID.\n */\nexport const ACCOUNT_WALLET_ID_REGEX =\n /^(?<walletType>entropy|keyring|snap):(?<walletSubId>.+)$/u;\n\n/**\n * Wallet status.\n *\n * Those status are used to report in which \"state\" the wallet is currently\n * in. All of those operations cannot run concurrently, thus, the wallet\n * cannot have multiple status at once.\n */\nexport type AccountWalletStatus =\n /**\n * The wallet is not initialized yet.\n */\n | 'uninitialized'\n /**\n * The wallet is ready to run any operation.\n */\n | 'ready';\n\n/**\n * Parsed account wallet ID with its wallet type and sub-ID.\n */\nexport type ParsedAccountWalletId = {\n type: AccountWalletType;\n subId: string;\n};\n\n/**\n * Keyring account wallet that can hold multiple account groups.\n */\nexport type BaseAccountWallet<Account extends KeyringAccount> = {\n /**\n * Account wallet ID.\n */\n get id(): AccountWalletId;\n\n /**\n * Keyring account wallet type.\n */\n get type(): AccountWalletType;\n\n /**\n * Account wallet status.\n */\n get status(): AccountWalletStatus;\n\n /**\n * Gets account group for a given ID.\n *\n * @param id - Account group ID.\n * @returns Account group.\n */\n getAccountGroup(id: AccountGroupId): AccountGroup<Account> | undefined;\n\n /**\n * Gets all account groups.\n *\n * @returns Account groups.\n */\n getAccountGroups(): AccountGroup<Account>[];\n};\n\n/**\n * Keyring account wallet that can hold multiple account groups.\n */\nexport type KeyringAccountWallet<Account extends KeyringAccount> =\n BaseAccountWallet<Account> & {\n /**\n * Keyring account wallet type.\n */\n get type(): AccountWalletType.Keyring;\n };\n\n/**\n * Snap keyring account wallet that can hold multiple account groups.\n */\nexport type SnapAccountWallet<Account extends KeyringAccount> =\n BaseAccountWallet<Account> & {\n /**\n * Snap account wallet type.\n */\n get type(): AccountWalletType.Snap;\n };\n\n/**\n * Type constraint for a {@link AccountGroupObject}. If one of its union-members\n * does not match this contraint, {@link AccountGroupObject} will resolve\n * to `never`.\n */\ntype IsAccountWallet<\n Wallet extends BaseAccountWallet<Account> & {\n get type(): AccountWalletType;\n },\n Account extends KeyringAccount,\n> = Wallet;\n\n/**\n * Account wallet that can hold multiple account groups.\n */\nexport type AccountWallet<Account extends KeyringAccount> = IsAccountWallet<\n | KeyringAccountWallet<Account>\n | SnapAccountWallet<Account>\n | MultichainAccountWallet<Bip44Account<Account>>,\n Account\n>;\n\n/**\n * Type utility to compute a constrained {@link AccountWalletId} type given a\n * specifc {@link AccountWalletType}.\n */\nexport type AccountWalletIdOf<WalletType extends AccountWalletType> =\n `${WalletType}:${string}`;\n\n/**\n * Convert a unique ID to a wallet ID for a given type.\n *\n * @param type - A wallet type.\n * @param id - A unique ID.\n * @returns A wallet ID.\n */\nexport function toAccountWalletId<WalletType extends AccountWalletType>(\n type: WalletType,\n id: string,\n): AccountWalletIdOf<WalletType> {\n return `${type}:${id}`;\n}\n\n/**\n * Checks if the given value is {@link AccountWalletId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link AccountWalletId}.\n */\nexport function isAccountWalletId(value: string): value is AccountWalletId {\n return ACCOUNT_WALLET_ID_REGEX.test(value);\n}\n\n/**\n * Parse an account wallet ID to an object containing a wallet ID information\n * (wallet type and wallet sub-ID).\n *\n * @param walletId - The account wallet ID to validate and parse.\n * @returns The parsed account wallet ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function parseAccountWalletId(walletId: string): ParsedAccountWalletId {\n const match = ACCOUNT_WALLET_ID_REGEX.exec(walletId);\n if (!match?.groups) {\n throw new Error(`Invalid account wallet ID: \"${walletId}\"`);\n }\n\n return {\n type: match.groups.walletType as AccountWalletType,\n subId: match.groups.walletSubId as string,\n };\n}\n\n/**\n * Strip the account wallet type from an account wallet ID.\n *\n * @param walletId - Account wallet ID.\n * @returns Account wallet sub-ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function stripAccountWalletType(walletId: string): string {\n return parseAccountWalletId(walletId).subId;\n}\n"]}
|
package/dist/mocks/accounts.cjs
CHANGED
|
@@ -13,9 +13,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
};
|
|
14
14
|
var _MockAccountBuilder_account;
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.MOCK_WALLET_1_BTC_P2TR_ACCOUNT = exports.MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = exports.MOCK_WALLET_1_SOL_ACCOUNT = exports.MOCK_WALLET_1_EVM_ACCOUNT = exports.MOCK_WALLET_1_ENTROPY_SOURCE = exports.MockAccountBuilder = exports.MOCK_HARDWARE_ACCOUNT_1 = exports.MOCK_SNAP_ACCOUNT_4 = exports.MOCK_SNAP_ACCOUNT_3 = exports.MOCK_SNAP_ACCOUNT_2 = exports.MOCK_SNAP_ACCOUNT_1 = exports.MOCK_BTC_P2TR_ACCOUNT_1 = exports.MOCK_BTC_P2WPKH_ACCOUNT_1 = exports.MOCK_SOL_ACCOUNT_1 = exports.MOCK_HD_ACCOUNT_2 = exports.MOCK_HD_ACCOUNT_1 =
|
|
16
|
+
exports.MOCK_WALLET_1_BTC_P2TR_ACCOUNT = exports.MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = exports.MOCK_WALLET_1_SOL_ACCOUNT = exports.MOCK_WALLET_1_EVM_ACCOUNT = exports.MOCK_WALLET_1_ENTROPY_SOURCE = exports.MockAccountBuilder = exports.MOCK_HARDWARE_ACCOUNT_1 = exports.MOCK_SNAP_ACCOUNT_4 = exports.MOCK_SNAP_ACCOUNT_3 = exports.MOCK_SNAP_ACCOUNT_2 = exports.MOCK_SNAP_ACCOUNT_1 = exports.MOCK_BTC_P2TR_ACCOUNT_1 = exports.MOCK_BTC_P2WPKH_ACCOUNT_1 = exports.MOCK_SOL_ACCOUNT_1 = exports.MOCK_HD_ACCOUNT_2 = exports.MOCK_HD_ACCOUNT_1 = void 0;
|
|
17
17
|
const keyring_api_1 = require("@metamask/keyring-api");
|
|
18
18
|
const uuid_1 = require("uuid");
|
|
19
|
+
const keyrings_1 = require("./keyrings.cjs");
|
|
19
20
|
const api_1 = require("../api/index.cjs");
|
|
20
21
|
const ETH_EOA_METHODS = [
|
|
21
22
|
keyring_api_1.EthMethod.PersonalSign,
|
|
@@ -26,31 +27,13 @@ const ETH_EOA_METHODS = [
|
|
|
26
27
|
keyring_api_1.EthMethod.SignTypedDataV4,
|
|
27
28
|
];
|
|
28
29
|
const SOL_METHODS = Object.values(keyring_api_1.SolMethod);
|
|
29
|
-
exports.MOCK_SNAP_1 = {
|
|
30
|
-
id: 'local:mock-snap-id-1',
|
|
31
|
-
name: 'Mock Snap 1',
|
|
32
|
-
enabled: true,
|
|
33
|
-
manifest: {
|
|
34
|
-
proposedName: 'Mock Snap 1',
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
exports.MOCK_SNAP_2 = {
|
|
38
|
-
id: 'local:mock-snap-id-2',
|
|
39
|
-
name: 'Mock Snap 2',
|
|
40
|
-
enabled: true,
|
|
41
|
-
manifest: {
|
|
42
|
-
proposedName: 'Mock Snap 2',
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
exports.MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';
|
|
46
|
-
exports.MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';
|
|
47
30
|
exports.MOCK_HD_ACCOUNT_1 = {
|
|
48
31
|
id: 'mock-id-1',
|
|
49
32
|
address: '0x123',
|
|
50
33
|
options: {
|
|
51
34
|
entropy: {
|
|
52
35
|
type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
|
|
53
|
-
id:
|
|
36
|
+
id: keyrings_1.MOCK_ENTROPY_SOURCE_1,
|
|
54
37
|
groupIndex: 0,
|
|
55
38
|
derivationPath: '',
|
|
56
39
|
},
|
|
@@ -65,7 +48,7 @@ exports.MOCK_HD_ACCOUNT_2 = {
|
|
|
65
48
|
options: {
|
|
66
49
|
entropy: {
|
|
67
50
|
type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
|
|
68
|
-
id:
|
|
51
|
+
id: keyrings_1.MOCK_ENTROPY_SOURCE_2,
|
|
69
52
|
groupIndex: 0,
|
|
70
53
|
derivationPath: '',
|
|
71
54
|
},
|
|
@@ -81,7 +64,7 @@ exports.MOCK_SOL_ACCOUNT_1 = {
|
|
|
81
64
|
entropy: {
|
|
82
65
|
type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
|
|
83
66
|
// NOTE: shares entropy with MOCK_HD_ACCOUNT_2
|
|
84
|
-
id:
|
|
67
|
+
id: keyrings_1.MOCK_ENTROPY_SOURCE_2,
|
|
85
68
|
groupIndex: 0,
|
|
86
69
|
derivationPath: '',
|
|
87
70
|
},
|
|
@@ -93,13 +76,13 @@ exports.MOCK_SOL_ACCOUNT_1 = {
|
|
|
93
76
|
exports.MOCK_BTC_P2WPKH_ACCOUNT_1 = {
|
|
94
77
|
id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',
|
|
95
78
|
type: keyring_api_1.BtcAccountType.P2wpkh,
|
|
96
|
-
methods:
|
|
79
|
+
methods: Object.values(keyring_api_1.BtcMethod),
|
|
97
80
|
address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',
|
|
98
81
|
options: {
|
|
99
82
|
entropy: {
|
|
100
83
|
type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
|
|
101
84
|
// NOTE: shares entropy with MOCK_HD_ACCOUNT_2
|
|
102
|
-
id:
|
|
85
|
+
id: keyrings_1.MOCK_ENTROPY_SOURCE_2,
|
|
103
86
|
groupIndex: 0,
|
|
104
87
|
derivationPath: '',
|
|
105
88
|
},
|
|
@@ -109,13 +92,13 @@ exports.MOCK_BTC_P2WPKH_ACCOUNT_1 = {
|
|
|
109
92
|
exports.MOCK_BTC_P2TR_ACCOUNT_1 = {
|
|
110
93
|
id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',
|
|
111
94
|
type: keyring_api_1.BtcAccountType.P2tr,
|
|
112
|
-
methods:
|
|
95
|
+
methods: Object.values(keyring_api_1.BtcMethod),
|
|
113
96
|
address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',
|
|
114
97
|
options: {
|
|
115
98
|
entropy: {
|
|
116
99
|
type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
|
|
117
100
|
// NOTE: shares entropy with MOCK_HD_ACCOUNT_2
|
|
118
|
-
id:
|
|
101
|
+
id: keyrings_1.MOCK_ENTROPY_SOURCE_2,
|
|
119
102
|
groupIndex: 0,
|
|
120
103
|
derivationPath: '',
|
|
121
104
|
},
|
|
@@ -180,7 +163,7 @@ class MockAccountBuilder {
|
|
|
180
163
|
}
|
|
181
164
|
exports.MockAccountBuilder = MockAccountBuilder;
|
|
182
165
|
_MockAccountBuilder_account = new WeakMap();
|
|
183
|
-
exports.MOCK_WALLET_1_ENTROPY_SOURCE =
|
|
166
|
+
exports.MOCK_WALLET_1_ENTROPY_SOURCE = keyrings_1.MOCK_ENTROPY_SOURCE_1;
|
|
184
167
|
exports.MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(exports.MOCK_HD_ACCOUNT_1)
|
|
185
168
|
.withEntropySource(exports.MOCK_WALLET_1_ENTROPY_SOURCE)
|
|
186
169
|
.withGroupIndex(0)
|
|
@@ -1 +1 @@
|
|
|
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EAAE,CAAC;AACI,QAAA,gCAAgC,GAAG,kBAAkB,CAAC,IAAI,CACrE,iCAAyB,CAC1B;KACE,iBAAiB,CAAC,oCAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACI,QAAA,8BAA8B,GAAG,kBAAkB,CAAC,IAAI,CACnE,+BAAuB,CACxB;KACE,iBAAiB,CAAC,oCAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC","sourcesContent":["// istanbul ignore file\n\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcMethod,\n BtcScope,\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { v4 as uuid } from 'uuid';\n\nimport { isBip44Account, type Bip44Account } from '../api';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_1,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount> = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet],\n};\n\nexport const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',\n type: BtcAccountType.P2wpkh,\n methods: [BtcMethod.SendBitcoin],\n address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Mainnet],\n};\n\nexport const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',\n type: BtcAccountType.P2tr,\n methods: [BtcMethod.SendBitcoin],\n address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Testnet],\n};\n\nexport const MOCK_SNAP_ACCOUNT_1 = MOCK_SOL_ACCOUNT_1;\n\nexport const MOCK_SNAP_ACCOUNT_2: KeyringAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SNAP_ACCOUNT_3 = MOCK_BTC_P2WPKH_ACCOUNT_1;\nexport const MOCK_SNAP_ACCOUNT_4 = MOCK_BTC_P2TR_ACCOUNT_1;\n\nexport const MOCK_HARDWARE_ACCOUNT_1: KeyringAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport class MockAccountBuilder<Account extends KeyringAccount> {\n readonly #account: Account;\n\n constructor(account: Account) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from<Account extends KeyringAccount>(\n account: Account,\n ): MockAccountBuilder<Account> {\n return new MockAccountBuilder(account);\n }\n\n withId(id: KeyringAccount['id']): MockAccountBuilder<Account> {\n this.#account.id = id;\n return this;\n }\n\n withUuid(): MockAccountBuilder<Account> {\n this.#account.id = uuid();\n return this;\n }\n\n withAddressSuffix(suffix: string): MockAccountBuilder<Account> {\n this.#account.address += suffix;\n return this;\n }\n\n withEntropySource(\n entropySource: EntropySourceId,\n ): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get(): Account {\n return this.#account;\n }\n}\n\nexport const MOCK_WALLET_1_ENTROPY_SOURCE = MOCK_ENTROPY_SOURCE_1;\n\nexport const MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(\n MOCK_HD_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(\n MOCK_SOL_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2WPKH_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2TR_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\n"]}
|
|
1
|
+
{"version":3,"file":"accounts.cjs","sourceRoot":"","sources":["../../src/mocks/accounts.ts"],"names":[],"mappings":";AAAA,uBAAuB;;;;;;;;;;;;;;;AAGvB,uDAW+B;AAC/B,+BAAkC;AAElC,6CAA0E;AAC1E,0CAA2D;AAE3D,MAAM,eAAe,GAAG;IACtB,uBAAS,CAAC,YAAY;IACtB,uBAAS,CAAC,IAAI;IACd,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;CACjB,CAAC;AAEX,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAS,CAAC,CAAC;AAEhC,QAAA,iBAAiB,GAA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AAO,uBAAA,IAAI,mCAAS,CAAC;IACvB,CAAC;CACF;AAhDD,gDAgDC;;AAEY,QAAA,4BAA4B,GAAG,gCAAqB,CAAC;AAErD,QAAA,yBAAyB,GAAG,kBAAkB,CAAC,IAAI,CAC9D,yBAAiB,CAClB;KACE,iBAAiB,CAAC,oCAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACI,QAAA,yBAAyB,GAAG,kBAAkB,CAAC,IAAI,CAC9D,0BAAkB,CACnB;KACE,iBAAiB,CAAC,oCAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACI,QAAA,gCAAgC,GAAG,kBAAkB,CAAC,IAAI,CACrE,iCAAyB,CAC1B;KACE,iBAAiB,CAAC,oCAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACI,QAAA,8BAA8B,GAAG,kBAAkB,CAAC,IAAI,CACnE,+BAAuB,CACxB;KACE,iBAAiB,CAAC,oCAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC","sourcesContent":["// istanbul ignore file\n\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcMethod,\n BtcScope,\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { v4 as uuid } from 'uuid';\n\nimport { MOCK_ENTROPY_SOURCE_1, MOCK_ENTROPY_SOURCE_2 } from './keyrings';\nimport { isBip44Account, type Bip44Account } from '../api';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_1,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount> = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet],\n};\n\nexport const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',\n type: BtcAccountType.P2wpkh,\n methods: Object.values(BtcMethod),\n address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Mainnet],\n};\n\nexport const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',\n type: BtcAccountType.P2tr,\n methods: Object.values(BtcMethod),\n address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Testnet],\n};\n\nexport const MOCK_SNAP_ACCOUNT_1 = MOCK_SOL_ACCOUNT_1;\n\nexport const MOCK_SNAP_ACCOUNT_2: KeyringAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SNAP_ACCOUNT_3 = MOCK_BTC_P2WPKH_ACCOUNT_1;\nexport const MOCK_SNAP_ACCOUNT_4 = MOCK_BTC_P2TR_ACCOUNT_1;\n\nexport const MOCK_HARDWARE_ACCOUNT_1: KeyringAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport class MockAccountBuilder<Account extends KeyringAccount> {\n readonly #account: Account;\n\n constructor(account: Account) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from<Account extends KeyringAccount>(\n account: Account,\n ): MockAccountBuilder<Account> {\n return new MockAccountBuilder(account);\n }\n\n withId(id: KeyringAccount['id']): MockAccountBuilder<Account> {\n this.#account.id = id;\n return this;\n }\n\n withUuid(): MockAccountBuilder<Account> {\n this.#account.id = uuid();\n return this;\n }\n\n withAddressSuffix(suffix: string): MockAccountBuilder<Account> {\n this.#account.address += suffix;\n return this;\n }\n\n withEntropySource(\n entropySource: EntropySourceId,\n ): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get(): Account {\n return this.#account;\n }\n}\n\nexport const MOCK_WALLET_1_ENTROPY_SOURCE = MOCK_ENTROPY_SOURCE_1;\n\nexport const MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(\n MOCK_HD_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(\n MOCK_SOL_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2WPKH_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2TR_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\n"]}
|
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
|
|
2
2
|
import { type Bip44Account } from "../api/index.cjs";
|
|
3
|
-
export declare const MOCK_SNAP_1: {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
enabled: boolean;
|
|
7
|
-
manifest: {
|
|
8
|
-
proposedName: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export declare const MOCK_SNAP_2: {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
enabled: boolean;
|
|
15
|
-
manifest: {
|
|
16
|
-
proposedName: string;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export declare const MOCK_ENTROPY_SOURCE_1 = "mock-keyring-id-1";
|
|
20
|
-
export declare const MOCK_ENTROPY_SOURCE_2 = "mock-keyring-id-2";
|
|
21
3
|
export declare const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
22
4
|
export declare const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount>;
|
|
23
5
|
export declare const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.cts","sourceRoot":"","sources":["../../src/mocks/accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;
|
|
1
|
+
{"version":3,"file":"accounts.d.cts","sourceRoot":"","sources":["../../src/mocks/accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAgB7E,OAAO,EAAkB,KAAK,YAAY,EAAE,yBAAe;AAa3D,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,CAc1D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,CAc1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,cAAc,CAe3D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,YAAY,CAAC,cAAc,CAelE,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,YAAY,CAAC,cAAc,CAehE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;eA5CpB,CAAC;;;;;;;;kBAOkD,CAAC;;;;;EAqCX,CAAC;AAEtD,eAAO,MAAM,mBAAmB,EAAE,cAOjC,CAAC;AAEF,eAAO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
|
2
2
|
import { type Bip44Account } from "../api/index.mjs";
|
|
3
|
-
export declare const MOCK_SNAP_1: {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
enabled: boolean;
|
|
7
|
-
manifest: {
|
|
8
|
-
proposedName: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export declare const MOCK_SNAP_2: {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
enabled: boolean;
|
|
15
|
-
manifest: {
|
|
16
|
-
proposedName: string;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export declare const MOCK_ENTROPY_SOURCE_1 = "mock-keyring-id-1";
|
|
20
|
-
export declare const MOCK_ENTROPY_SOURCE_2 = "mock-keyring-id-2";
|
|
21
3
|
export declare const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
22
4
|
export declare const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount>;
|
|
23
5
|
export declare const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.mts","sourceRoot":"","sources":["../../src/mocks/accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;
|
|
1
|
+
{"version":3,"file":"accounts.d.mts","sourceRoot":"","sources":["../../src/mocks/accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAgB7E,OAAO,EAAkB,KAAK,YAAY,EAAE,yBAAe;AAa3D,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,CAc1D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,CAc1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,cAAc,CAe3D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,YA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AAgC;;;;eAnIjC,CAAC;;;;;;;;kBAOkD,CAAC;;;;;EAiIxD,CAAC;AACT,eAAO,MAAM,8BAA8B;;;;eAzI/B,CAAC;;;;;;;;kBAOkD,CAAC;;;;;EAuIxD,CAAC"}
|
package/dist/mocks/accounts.mjs
CHANGED
|
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _MockAccountBuilder_account;
|
|
14
14
|
import { BtcAccountType, BtcMethod, BtcScope, EthAccountType, EthMethod, EthScope, KeyringAccountEntropyTypeOption, SolAccountType, SolMethod, SolScope } from "@metamask/keyring-api";
|
|
15
15
|
import { v4 as uuid } from "uuid";
|
|
16
|
+
import { MOCK_ENTROPY_SOURCE_1, MOCK_ENTROPY_SOURCE_2 } from "./keyrings.mjs";
|
|
16
17
|
import { isBip44Account } from "../api/index.mjs";
|
|
17
18
|
const ETH_EOA_METHODS = [
|
|
18
19
|
EthMethod.PersonalSign,
|
|
@@ -23,24 +24,6 @@ const ETH_EOA_METHODS = [
|
|
|
23
24
|
EthMethod.SignTypedDataV4,
|
|
24
25
|
];
|
|
25
26
|
const SOL_METHODS = Object.values(SolMethod);
|
|
26
|
-
export const MOCK_SNAP_1 = {
|
|
27
|
-
id: 'local:mock-snap-id-1',
|
|
28
|
-
name: 'Mock Snap 1',
|
|
29
|
-
enabled: true,
|
|
30
|
-
manifest: {
|
|
31
|
-
proposedName: 'Mock Snap 1',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
export const MOCK_SNAP_2 = {
|
|
35
|
-
id: 'local:mock-snap-id-2',
|
|
36
|
-
name: 'Mock Snap 2',
|
|
37
|
-
enabled: true,
|
|
38
|
-
manifest: {
|
|
39
|
-
proposedName: 'Mock Snap 2',
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
export const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';
|
|
43
|
-
export const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';
|
|
44
27
|
export const MOCK_HD_ACCOUNT_1 = {
|
|
45
28
|
id: 'mock-id-1',
|
|
46
29
|
address: '0x123',
|
|
@@ -90,7 +73,7 @@ export const MOCK_SOL_ACCOUNT_1 = {
|
|
|
90
73
|
export const MOCK_BTC_P2WPKH_ACCOUNT_1 = {
|
|
91
74
|
id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',
|
|
92
75
|
type: BtcAccountType.P2wpkh,
|
|
93
|
-
methods:
|
|
76
|
+
methods: Object.values(BtcMethod),
|
|
94
77
|
address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',
|
|
95
78
|
options: {
|
|
96
79
|
entropy: {
|
|
@@ -106,7 +89,7 @@ export const MOCK_BTC_P2WPKH_ACCOUNT_1 = {
|
|
|
106
89
|
export const MOCK_BTC_P2TR_ACCOUNT_1 = {
|
|
107
90
|
id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',
|
|
108
91
|
type: BtcAccountType.P2tr,
|
|
109
|
-
methods:
|
|
92
|
+
methods: Object.values(BtcMethod),
|
|
110
93
|
address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',
|
|
111
94
|
options: {
|
|
112
95
|
entropy: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.mjs","sourceRoot":"","sources":["../../src/mocks/accounts.ts"],"names":[],"mappings":"AAAA,uBAAuB;;;;;;;;;;;;;AAGvB,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,cAAc,EACd,SAAS,EACT,QAAQ,EACR,+BAA+B,EAC/B,cAAc,EACd,SAAS,EACT,QAAQ,EACT,8BAA8B;AAC/B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,aAAa;AAElC,OAAO,EAAE,cAAc,EAAqB,yBAAe;AAE3D,MAAM,eAAe,GAAG;IACtB,SAAS,CAAC,YAAY;IACtB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AAI,CACrE,yBAAyB,CAC1B;KACE,iBAAiB,CAAC,4BAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACT,MAAM,CAAC,MAAM,8BAA8B,GAAG,kBAAkB,CAAC,IAAI,CACnE,uBAAuB,CACxB;KACE,iBAAiB,CAAC,4BAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC","sourcesContent":["// istanbul ignore file\n\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcMethod,\n BtcScope,\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { v4 as uuid } from 'uuid';\n\nimport { isBip44Account, type Bip44Account } from '../api';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_1,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount> = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet],\n};\n\nexport const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',\n type: BtcAccountType.P2wpkh,\n methods: [BtcMethod.SendBitcoin],\n address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Mainnet],\n};\n\nexport const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',\n type: BtcAccountType.P2tr,\n methods: [BtcMethod.SendBitcoin],\n address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Testnet],\n};\n\nexport const MOCK_SNAP_ACCOUNT_1 = MOCK_SOL_ACCOUNT_1;\n\nexport const MOCK_SNAP_ACCOUNT_2: KeyringAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SNAP_ACCOUNT_3 = MOCK_BTC_P2WPKH_ACCOUNT_1;\nexport const MOCK_SNAP_ACCOUNT_4 = MOCK_BTC_P2TR_ACCOUNT_1;\n\nexport const MOCK_HARDWARE_ACCOUNT_1: KeyringAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport class MockAccountBuilder<Account extends KeyringAccount> {\n readonly #account: Account;\n\n constructor(account: Account) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from<Account extends KeyringAccount>(\n account: Account,\n ): MockAccountBuilder<Account> {\n return new MockAccountBuilder(account);\n }\n\n withId(id: KeyringAccount['id']): MockAccountBuilder<Account> {\n this.#account.id = id;\n return this;\n }\n\n withUuid(): MockAccountBuilder<Account> {\n this.#account.id = uuid();\n return this;\n }\n\n withAddressSuffix(suffix: string): MockAccountBuilder<Account> {\n this.#account.address += suffix;\n return this;\n }\n\n withEntropySource(\n entropySource: EntropySourceId,\n ): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get(): Account {\n return this.#account;\n }\n}\n\nexport const MOCK_WALLET_1_ENTROPY_SOURCE = MOCK_ENTROPY_SOURCE_1;\n\nexport const MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(\n MOCK_HD_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(\n MOCK_SOL_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2WPKH_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2TR_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\n"]}
|
|
1
|
+
{"version":3,"file":"accounts.mjs","sourceRoot":"","sources":["../../src/mocks/accounts.ts"],"names":[],"mappings":"AAAA,uBAAuB;;;;;;;;;;;;;AAGvB,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,cAAc,EACd,SAAS,EACT,QAAQ,EACR,+BAA+B,EAC/B,cAAc,EACd,SAAS,EACT,QAAQ,EACT,8BAA8B;AAC/B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,aAAa;AAElC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,uBAAmB;AAC1E,OAAO,EAAE,cAAc,EAAqB,yBAAe;AAE3D,MAAM,eAAe,GAAG;IACtB,SAAS,CAAC,YAAY;IACtB,SAAS,CAAC,IAAI;IACd,SAAS,CAAC,eAAe;I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OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,UAAkB;QAC/B,IAAI,cAAc,CAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE,CAAC;YAClC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;QACxD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG;QACD,OAAO,uBAAA,IAAI,mCAAS,CAAC;IACvB,CAAC;CACF;;AAED,MAAM,CAAC,MAAM,4BAA4B,GAAG,qBAAqB,CAAC;AAElE,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAAC,IAAI,CAC9D,iBAAiB,CAClB;KACE,iBAAiB,CAAC,4BAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACT,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAAC,IAAI,CAC9D,kBAAkB,CACnB;KACE,iBAAiB,CAAC,4BAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACT,MAAM,CAAC,MAAM,gCAAgC,GAAG,kBAAkB,CAAC,IAAI,CACrE,yBAAyB,CAC1B;KACE,iBAAiB,CAAC,4BAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACT,MAAM,CAAC,MAAM,8BAA8B,GAAG,kBAAkB,CAAC,IAAI,CACnE,uBAAuB,CACxB;KACE,iBAAiB,CAAC,4BAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC","sourcesContent":["// istanbul ignore file\n\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcMethod,\n BtcScope,\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { v4 as uuid } from 'uuid';\n\nimport { MOCK_ENTROPY_SOURCE_1, MOCK_ENTROPY_SOURCE_2 } from './keyrings';\nimport { isBip44Account, type Bip44Account } from '../api';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_1,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount> = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet],\n};\n\nexport const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',\n type: BtcAccountType.P2wpkh,\n methods: Object.values(BtcMethod),\n address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Mainnet],\n};\n\nexport const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',\n type: BtcAccountType.P2tr,\n methods: Object.values(BtcMethod),\n address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Testnet],\n};\n\nexport const MOCK_SNAP_ACCOUNT_1 = MOCK_SOL_ACCOUNT_1;\n\nexport const MOCK_SNAP_ACCOUNT_2: KeyringAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SNAP_ACCOUNT_3 = MOCK_BTC_P2WPKH_ACCOUNT_1;\nexport const MOCK_SNAP_ACCOUNT_4 = MOCK_BTC_P2TR_ACCOUNT_1;\n\nexport const MOCK_HARDWARE_ACCOUNT_1: KeyringAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport class MockAccountBuilder<Account extends KeyringAccount> {\n readonly #account: Account;\n\n constructor(account: Account) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from<Account extends KeyringAccount>(\n account: Account,\n ): MockAccountBuilder<Account> {\n return new MockAccountBuilder(account);\n }\n\n withId(id: KeyringAccount['id']): MockAccountBuilder<Account> {\n this.#account.id = id;\n return this;\n }\n\n withUuid(): MockAccountBuilder<Account> {\n this.#account.id = uuid();\n return this;\n }\n\n withAddressSuffix(suffix: string): MockAccountBuilder<Account> {\n this.#account.address += suffix;\n return this;\n }\n\n withEntropySource(\n entropySource: EntropySourceId,\n ): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get(): Account {\n return this.#account;\n }\n}\n\nexport const MOCK_WALLET_1_ENTROPY_SOURCE = MOCK_ENTROPY_SOURCE_1;\n\nexport const MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(\n MOCK_HD_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(\n MOCK_SOL_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2WPKH_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2TR_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MOCK_KEYRING_GROUP_ID = exports.MOCK_SNAP_NPM_GROUP_ID = exports.MOCK_SNAP_LOCAL_GROUP_ID = exports.MOCK_ENTROPY_GROUP_ID = void 0;
|
|
4
|
+
const wallets_1 = require("./wallets.cjs");
|
|
5
|
+
exports.MOCK_ENTROPY_GROUP_ID = `${wallets_1.MOCK_ENTROPY_WALLET_ID}/0`;
|
|
6
|
+
exports.MOCK_SNAP_LOCAL_GROUP_ID = `${wallets_1.MOCK_SNAP_LOCAL_WALLET_ID}/0x123`;
|
|
7
|
+
exports.MOCK_SNAP_NPM_GROUP_ID = `${wallets_1.MOCK_SNAP_NPM_WALLET_ID}/0x456`;
|
|
8
|
+
exports.MOCK_KEYRING_GROUP_ID = `${wallets_1.MOCK_KEYRING_WALLET_ID}/0x789`;
|
|
9
|
+
//# sourceMappingURL=groups.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups.cjs","sourceRoot":"","sources":["../../src/mocks/groups.ts"],"names":[],"mappings":";;;AAAA,2CAKmB;AAEN,QAAA,qBAAqB,GAAG,GAAG,gCAAsB,IAAI,CAAC;AACtD,QAAA,wBAAwB,GAAG,GAAG,mCAAyB,QAAQ,CAAC;AAChE,QAAA,sBAAsB,GAAG,GAAG,iCAAuB,QAAQ,CAAC;AAC5D,QAAA,qBAAqB,GAAG,GAAG,gCAAsB,QAAQ,CAAC","sourcesContent":["import {\n MOCK_ENTROPY_WALLET_ID,\n MOCK_KEYRING_WALLET_ID,\n MOCK_SNAP_LOCAL_WALLET_ID,\n MOCK_SNAP_NPM_WALLET_ID,\n} from './wallets';\n\nexport const MOCK_ENTROPY_GROUP_ID = `${MOCK_ENTROPY_WALLET_ID}/0`;\nexport const MOCK_SNAP_LOCAL_GROUP_ID = `${MOCK_SNAP_LOCAL_WALLET_ID}/0x123`;\nexport const MOCK_SNAP_NPM_GROUP_ID = `${MOCK_SNAP_NPM_WALLET_ID}/0x456`;\nexport const MOCK_KEYRING_GROUP_ID = `${MOCK_KEYRING_WALLET_ID}/0x789`;\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const MOCK_ENTROPY_GROUP_ID = "entropy:mock-keyring-id-1/0";
|
|
2
|
+
export declare const MOCK_SNAP_LOCAL_GROUP_ID: string;
|
|
3
|
+
export declare const MOCK_SNAP_NPM_GROUP_ID: string;
|
|
4
|
+
export declare const MOCK_KEYRING_GROUP_ID = "keyring:Simple Key Pair/0x789";
|
|
5
|
+
//# sourceMappingURL=groups.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups.d.cts","sourceRoot":"","sources":["../../src/mocks/groups.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,qBAAqB,gCAAgC,CAAC;AACnE,eAAO,MAAM,wBAAwB,QAAuC,CAAC;AAC7E,eAAO,MAAM,sBAAsB,QAAqC,CAAC;AACzE,eAAO,MAAM,qBAAqB,kCAAoC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const MOCK_ENTROPY_GROUP_ID = "entropy:mock-keyring-id-1/0";
|
|
2
|
+
export declare const MOCK_SNAP_LOCAL_GROUP_ID: string;
|
|
3
|
+
export declare const MOCK_SNAP_NPM_GROUP_ID: string;
|
|
4
|
+
export declare const MOCK_KEYRING_GROUP_ID = "keyring:Simple Key Pair/0x789";
|
|
5
|
+
//# sourceMappingURL=groups.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups.d.mts","sourceRoot":"","sources":["../../src/mocks/groups.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,qBAAqB,gCAAgC,CAAC;AACnE,eAAO,MAAM,wBAAwB,QAAuC,CAAC;AAC7E,eAAO,MAAM,sBAAsB,QAAqC,CAAC;AACzE,eAAO,MAAM,qBAAqB,kCAAoC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MOCK_ENTROPY_WALLET_ID, MOCK_KEYRING_WALLET_ID, MOCK_SNAP_LOCAL_WALLET_ID, MOCK_SNAP_NPM_WALLET_ID } from "./wallets.mjs";
|
|
2
|
+
export const MOCK_ENTROPY_GROUP_ID = `${MOCK_ENTROPY_WALLET_ID}/0`;
|
|
3
|
+
export const MOCK_SNAP_LOCAL_GROUP_ID = `${MOCK_SNAP_LOCAL_WALLET_ID}/0x123`;
|
|
4
|
+
export const MOCK_SNAP_NPM_GROUP_ID = `${MOCK_SNAP_NPM_WALLET_ID}/0x456`;
|
|
5
|
+
export const MOCK_KEYRING_GROUP_ID = `${MOCK_KEYRING_WALLET_ID}/0x789`;
|
|
6
|
+
//# sourceMappingURL=groups.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups.mjs","sourceRoot":"","sources":["../../src/mocks/groups.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACxB,sBAAkB;AAEnB,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,sBAAsB,IAAI,CAAC;AACnE,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,yBAAyB,QAAQ,CAAC;AAC7E,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,uBAAuB,QAAQ,CAAC;AACzE,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,sBAAsB,QAAQ,CAAC","sourcesContent":["import {\n MOCK_ENTROPY_WALLET_ID,\n MOCK_KEYRING_WALLET_ID,\n MOCK_SNAP_LOCAL_WALLET_ID,\n MOCK_SNAP_NPM_WALLET_ID,\n} from './wallets';\n\nexport const MOCK_ENTROPY_GROUP_ID = `${MOCK_ENTROPY_WALLET_ID}/0`;\nexport const MOCK_SNAP_LOCAL_GROUP_ID = `${MOCK_SNAP_LOCAL_WALLET_ID}/0x123`;\nexport const MOCK_SNAP_NPM_GROUP_ID = `${MOCK_SNAP_NPM_WALLET_ID}/0x456`;\nexport const MOCK_KEYRING_GROUP_ID = `${MOCK_KEYRING_WALLET_ID}/0x789`;\n"]}
|
package/dist/mocks/index.cjs
CHANGED
|
@@ -15,4 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./accounts.cjs"), exports);
|
|
18
|
+
__exportStar(require("./keyrings.cjs"), exports);
|
|
19
|
+
__exportStar(require("./groups.cjs"), exports);
|
|
20
|
+
__exportStar(require("./wallets.cjs"), exports);
|
|
21
|
+
__exportStar(require("./snaps.cjs"), exports);
|
|
18
22
|
//# sourceMappingURL=index.cjs.map
|
package/dist/mocks/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/mocks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA2B","sourcesContent":["export * from './accounts';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/mocks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA2B;AAC3B,iDAA2B;AAC3B,+CAAyB;AACzB,gDAA0B;AAC1B,8CAAwB","sourcesContent":["export * from './accounts';\nexport * from './keyrings';\nexport * from './groups';\nexport * from './wallets';\nexport * from './snaps';\n"]}
|