@metamask-previews/account-api 0.6.0-9cb78a8 → 0.7.0-58aa483
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 +8 -1
- package/dist/api/bip44.cjs +12 -0
- package/dist/api/bip44.cjs.map +1 -1
- package/dist/api/bip44.d.cts +7 -0
- package/dist/api/bip44.d.cts.map +1 -1
- package/dist/api/bip44.d.mts +7 -0
- package/dist/api/bip44.d.mts.map +1 -1
- package/dist/api/bip44.mjs +11 -0
- package/dist/api/bip44.mjs.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -1
- package/dist/tests/accounts.cjs +199 -0
- package/dist/tests/accounts.cjs.map +1 -0
- package/dist/tests/accounts.d.cts +166 -0
- package/dist/tests/accounts.d.cts.map +1 -0
- package/dist/tests/accounts.d.mts +166 -0
- package/dist/tests/accounts.d.mts.map +1 -0
- package/dist/tests/accounts.mjs +195 -0
- package/dist/tests/accounts.mjs.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
- Add `assertIsBip44Account` ([#339](https://github.com/MetaMask/accounts/pull/339))
|
|
13
|
+
|
|
14
|
+
## [0.7.0]
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
12
18
|
- Add `AccountProvider.{createAccounts,discoverAndCreateAccounts}` ([#337](https://github.com/MetaMask/accounts/pull/337))
|
|
13
19
|
|
|
14
20
|
### Changed
|
|
@@ -77,7 +83,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
77
83
|
|
|
78
84
|
- Add `AccountGroup` and `AccountWallet` ([#307](https://github.com/MetaMask/accounts/pull/307))
|
|
79
85
|
|
|
80
|
-
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.
|
|
86
|
+
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.7.0...HEAD
|
|
87
|
+
[0.7.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.6.0...@metamask/account-api@0.7.0
|
|
81
88
|
[0.6.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.5.0...@metamask/account-api@0.6.0
|
|
82
89
|
[0.5.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.4.0...@metamask/account-api@0.5.0
|
|
83
90
|
[0.4.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.3.0...@metamask/account-api@0.4.0
|
package/dist/api/bip44.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isBip44Account = isBip44Account;
|
|
4
|
+
exports.assertIsBip44Account = assertIsBip44Account;
|
|
4
5
|
const keyring_api_1 = require("@metamask/keyring-api");
|
|
5
6
|
const superstruct_1 = require("@metamask/superstruct");
|
|
6
7
|
/**
|
|
@@ -13,4 +14,15 @@ function isBip44Account(account) {
|
|
|
13
14
|
// To be BIP-44 compatible, you just need to use this set of options:
|
|
14
15
|
return (0, superstruct_1.is)(account.options.entropy, keyring_api_1.KeyringAccountEntropyMnemonicOptionsStruct);
|
|
15
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Asserts a keyring account is BIP-44 compatible.
|
|
19
|
+
*
|
|
20
|
+
* @param account - Keyring account to check.
|
|
21
|
+
* @throws If the keyring account is not compatible.
|
|
22
|
+
*/
|
|
23
|
+
function assertIsBip44Account(account) {
|
|
24
|
+
if (!isBip44Account(account)) {
|
|
25
|
+
throw new Error('Account is not BIP-44 compatible');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
16
28
|
//# sourceMappingURL=bip44.cjs.map
|
package/dist/api/bip44.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bip44.cjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":";;AAwBA,wCAQC;
|
|
1
|
+
{"version":3,"file":"bip44.cjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":";;AAwBA,wCAQC;AAQD,oDAMC;AA1CD,uDAAmF;AACnF,uDAA2C;AAa3C;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,OAAgB;IAEhB,qEAAqE;IACrE,OAAO,IAAA,gBAAE,EACP,OAAO,CAAC,OAAO,CAAC,OAAO,EACvB,wDAA0C,CAC3C,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAClC,OAAgB;IAEhB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;AACH,CAAC","sourcesContent":["import type {\n KeyringAccount,\n KeyringAccountEntropyMnemonicOptions,\n} from '@metamask/keyring-api';\nimport { KeyringAccountEntropyMnemonicOptionsStruct } from '@metamask/keyring-api';\nimport { is } from '@metamask/superstruct';\n\n/**\n * BIP-44 compatible account type.\n */\nexport type Bip44Account<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is BIP-44 compatible).\n options: {\n entropy: KeyringAccountEntropyMnemonicOptions;\n };\n};\n\n/**\n * Checks if an account is BIP-44 compatible.\n *\n * @param account - The account to be tested.\n * @returns True if the account is BIP-44 compatible.\n */\nexport function isBip44Account<Account extends KeyringAccount>(\n account: Account,\n): account is Bip44Account<Account> {\n // To be BIP-44 compatible, you just need to use this set of options:\n return is(\n account.options.entropy,\n KeyringAccountEntropyMnemonicOptionsStruct,\n );\n}\n\n/**\n * Asserts a keyring account is BIP-44 compatible.\n *\n * @param account - Keyring account to check.\n * @throws If the keyring account is not compatible.\n */\nexport function assertIsBip44Account<Account extends KeyringAccount>(\n account: Account,\n): asserts account is Bip44Account<Account> {\n if (!isBip44Account(account)) {\n throw new Error('Account is not BIP-44 compatible');\n }\n}\n"]}
|
package/dist/api/bip44.d.cts
CHANGED
|
@@ -14,4 +14,11 @@ export type Bip44Account<Account extends KeyringAccount> = Account & {
|
|
|
14
14
|
* @returns True if the account is BIP-44 compatible.
|
|
15
15
|
*/
|
|
16
16
|
export declare function isBip44Account<Account extends KeyringAccount>(account: Account): account is Bip44Account<Account>;
|
|
17
|
+
/**
|
|
18
|
+
* Asserts a keyring account is BIP-44 compatible.
|
|
19
|
+
*
|
|
20
|
+
* @param account - Keyring account to check.
|
|
21
|
+
* @throws If the keyring account is not compatible.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertIsBip44Account<Account extends KeyringAccount>(account: Account): asserts account is Bip44Account<Account>;
|
|
17
24
|
//# sourceMappingURL=bip44.d.cts.map
|
package/dist/api/bip44.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bip44.d.cts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAI/B;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGnE,OAAO,EAAE;QACP,OAAO,EAAE,oCAAoC,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAMlC"}
|
|
1
|
+
{"version":3,"file":"bip44.d.cts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAI/B;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGnE,OAAO,EAAE;QACP,OAAO,EAAE,oCAAoC,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAMlC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,cAAc,EACjE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAI1C"}
|
package/dist/api/bip44.d.mts
CHANGED
|
@@ -14,4 +14,11 @@ export type Bip44Account<Account extends KeyringAccount> = Account & {
|
|
|
14
14
|
* @returns True if the account is BIP-44 compatible.
|
|
15
15
|
*/
|
|
16
16
|
export declare function isBip44Account<Account extends KeyringAccount>(account: Account): account is Bip44Account<Account>;
|
|
17
|
+
/**
|
|
18
|
+
* Asserts a keyring account is BIP-44 compatible.
|
|
19
|
+
*
|
|
20
|
+
* @param account - Keyring account to check.
|
|
21
|
+
* @throws If the keyring account is not compatible.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertIsBip44Account<Account extends KeyringAccount>(account: Account): asserts account is Bip44Account<Account>;
|
|
17
24
|
//# sourceMappingURL=bip44.d.mts.map
|
package/dist/api/bip44.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bip44.d.mts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAI/B;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGnE,OAAO,EAAE;QACP,OAAO,EAAE,oCAAoC,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAMlC"}
|
|
1
|
+
{"version":3,"file":"bip44.d.mts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAI/B;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGnE,OAAO,EAAE;QACP,OAAO,EAAE,oCAAoC,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAMlC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,cAAc,EACjE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAI1C"}
|
package/dist/api/bip44.mjs
CHANGED
|
@@ -10,4 +10,15 @@ export function isBip44Account(account) {
|
|
|
10
10
|
// To be BIP-44 compatible, you just need to use this set of options:
|
|
11
11
|
return is(account.options.entropy, KeyringAccountEntropyMnemonicOptionsStruct);
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Asserts a keyring account is BIP-44 compatible.
|
|
15
|
+
*
|
|
16
|
+
* @param account - Keyring account to check.
|
|
17
|
+
* @throws If the keyring account is not compatible.
|
|
18
|
+
*/
|
|
19
|
+
export function assertIsBip44Account(account) {
|
|
20
|
+
if (!isBip44Account(account)) {
|
|
21
|
+
throw new Error('Account is not BIP-44 compatible');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
13
24
|
//# sourceMappingURL=bip44.mjs.map
|
package/dist/api/bip44.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0CAA0C,EAAE,8BAA8B;AACnF,OAAO,EAAE,EAAE,EAAE,8BAA8B;AAa3C;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB;IAEhB,qEAAqE;IACrE,OAAO,EAAE,CACP,OAAO,CAAC,OAAO,CAAC,OAAO,EACvB,0CAA0C,CAC3C,CAAC;AACJ,CAAC","sourcesContent":["import type {\n KeyringAccount,\n KeyringAccountEntropyMnemonicOptions,\n} from '@metamask/keyring-api';\nimport { KeyringAccountEntropyMnemonicOptionsStruct } from '@metamask/keyring-api';\nimport { is } from '@metamask/superstruct';\n\n/**\n * BIP-44 compatible account type.\n */\nexport type Bip44Account<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is BIP-44 compatible).\n options: {\n entropy: KeyringAccountEntropyMnemonicOptions;\n };\n};\n\n/**\n * Checks if an account is BIP-44 compatible.\n *\n * @param account - The account to be tested.\n * @returns True if the account is BIP-44 compatible.\n */\nexport function isBip44Account<Account extends KeyringAccount>(\n account: Account,\n): account is Bip44Account<Account> {\n // To be BIP-44 compatible, you just need to use this set of options:\n return is(\n account.options.entropy,\n KeyringAccountEntropyMnemonicOptionsStruct,\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0CAA0C,EAAE,8BAA8B;AACnF,OAAO,EAAE,EAAE,EAAE,8BAA8B;AAa3C;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB;IAEhB,qEAAqE;IACrE,OAAO,EAAE,CACP,OAAO,CAAC,OAAO,CAAC,OAAO,EACvB,0CAA0C,CAC3C,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAgB;IAEhB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;AACH,CAAC","sourcesContent":["import type {\n KeyringAccount,\n KeyringAccountEntropyMnemonicOptions,\n} from '@metamask/keyring-api';\nimport { KeyringAccountEntropyMnemonicOptionsStruct } from '@metamask/keyring-api';\nimport { is } from '@metamask/superstruct';\n\n/**\n * BIP-44 compatible account type.\n */\nexport type Bip44Account<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is BIP-44 compatible).\n options: {\n entropy: KeyringAccountEntropyMnemonicOptions;\n };\n};\n\n/**\n * Checks if an account is BIP-44 compatible.\n *\n * @param account - The account to be tested.\n * @returns True if the account is BIP-44 compatible.\n */\nexport function isBip44Account<Account extends KeyringAccount>(\n account: Account,\n): account is Bip44Account<Account> {\n // To be BIP-44 compatible, you just need to use this set of options:\n return is(\n account.options.entropy,\n KeyringAccountEntropyMnemonicOptionsStruct,\n );\n}\n\n/**\n * Asserts a keyring account is BIP-44 compatible.\n *\n * @param account - Keyring account to check.\n * @throws If the keyring account is not compatible.\n */\nexport function assertIsBip44Account<Account extends KeyringAccount>(\n account: Account,\n): asserts account is Bip44Account<Account> {\n if (!isBip44Account(account)) {\n throw new Error('Account is not BIP-44 compatible');\n }\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -15,4 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./api/index.cjs"), exports);
|
|
18
|
+
// NOTE: We do not export the test utilities as part of the public API, but they
|
|
19
|
+
// are still available through `@metamask/account-api/tests`.
|
|
18
20
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAsB","sourcesContent":["export * from './api';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAsB;AAEtB,gFAAgF;AAChF,6DAA6D","sourcesContent":["export * from './api';\n\n// NOTE: We do not export the test utilities as part of the public API, but they\n// are still available through `@metamask/account-api/tests`.\n"]}
|
package/dist/index.mjs
CHANGED
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAsB","sourcesContent":["export * from './api';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAsB;AAEtB,gFAAgF;AAChF,6DAA6D","sourcesContent":["export * from './api';\n\n// NOTE: We do not export the test utilities as part of the public API, but they\n// are still available through `@metamask/account-api/tests`.\n"]}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _MockAccountBuilder_account;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
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 = exports.MOCK_ENTROPY_SOURCE_2 = exports.MOCK_ENTROPY_SOURCE_1 = exports.MOCK_SNAP_2 = exports.MOCK_SNAP_1 = void 0;
|
|
16
|
+
const keyring_api_1 = require("@metamask/keyring-api");
|
|
17
|
+
const uuid_1 = require("uuid");
|
|
18
|
+
const api_1 = require("../api/index.cjs");
|
|
19
|
+
const ETH_EOA_METHODS = [
|
|
20
|
+
keyring_api_1.EthMethod.PersonalSign,
|
|
21
|
+
keyring_api_1.EthMethod.Sign,
|
|
22
|
+
keyring_api_1.EthMethod.SignTransaction,
|
|
23
|
+
keyring_api_1.EthMethod.SignTypedDataV1,
|
|
24
|
+
keyring_api_1.EthMethod.SignTypedDataV3,
|
|
25
|
+
keyring_api_1.EthMethod.SignTypedDataV4,
|
|
26
|
+
];
|
|
27
|
+
const SOL_METHODS = Object.values(keyring_api_1.SolMethod);
|
|
28
|
+
exports.MOCK_SNAP_1 = {
|
|
29
|
+
id: 'local:mock-snap-id-1',
|
|
30
|
+
name: 'Mock Snap 1',
|
|
31
|
+
enabled: true,
|
|
32
|
+
manifest: {
|
|
33
|
+
proposedName: 'Mock Snap 1',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
exports.MOCK_SNAP_2 = {
|
|
37
|
+
id: 'local:mock-snap-id-2',
|
|
38
|
+
name: 'Mock Snap 2',
|
|
39
|
+
enabled: true,
|
|
40
|
+
manifest: {
|
|
41
|
+
proposedName: 'Mock Snap 2',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
exports.MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';
|
|
45
|
+
exports.MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';
|
|
46
|
+
exports.MOCK_HD_ACCOUNT_1 = {
|
|
47
|
+
id: 'mock-id-1',
|
|
48
|
+
address: '0x123',
|
|
49
|
+
options: {
|
|
50
|
+
entropy: {
|
|
51
|
+
type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
|
|
52
|
+
id: exports.MOCK_ENTROPY_SOURCE_1,
|
|
53
|
+
groupIndex: 0,
|
|
54
|
+
derivationPath: '',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
methods: [...ETH_EOA_METHODS],
|
|
58
|
+
type: keyring_api_1.EthAccountType.Eoa,
|
|
59
|
+
scopes: [keyring_api_1.EthScope.Eoa],
|
|
60
|
+
};
|
|
61
|
+
exports.MOCK_HD_ACCOUNT_2 = {
|
|
62
|
+
id: 'mock-id-2',
|
|
63
|
+
address: '0x456',
|
|
64
|
+
options: {
|
|
65
|
+
entropy: {
|
|
66
|
+
type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
|
|
67
|
+
id: exports.MOCK_ENTROPY_SOURCE_2,
|
|
68
|
+
groupIndex: 0,
|
|
69
|
+
derivationPath: '',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
methods: [...ETH_EOA_METHODS],
|
|
73
|
+
type: keyring_api_1.EthAccountType.Eoa,
|
|
74
|
+
scopes: [keyring_api_1.EthScope.Eoa],
|
|
75
|
+
};
|
|
76
|
+
exports.MOCK_SOL_ACCOUNT_1 = {
|
|
77
|
+
id: 'mock-snap-id-1',
|
|
78
|
+
address: 'aabbccdd',
|
|
79
|
+
options: {
|
|
80
|
+
entropy: {
|
|
81
|
+
type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
|
|
82
|
+
// NOTE: shares entropy with MOCK_HD_ACCOUNT_2
|
|
83
|
+
id: exports.MOCK_ENTROPY_SOURCE_2,
|
|
84
|
+
groupIndex: 0,
|
|
85
|
+
derivationPath: '',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
methods: SOL_METHODS,
|
|
89
|
+
type: keyring_api_1.SolAccountType.DataAccount,
|
|
90
|
+
scopes: [keyring_api_1.SolScope.Mainnet, keyring_api_1.SolScope.Testnet, keyring_api_1.SolScope.Devnet],
|
|
91
|
+
};
|
|
92
|
+
exports.MOCK_BTC_P2WPKH_ACCOUNT_1 = {
|
|
93
|
+
id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',
|
|
94
|
+
type: keyring_api_1.BtcAccountType.P2wpkh,
|
|
95
|
+
methods: [keyring_api_1.BtcMethod.SendBitcoin],
|
|
96
|
+
address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',
|
|
97
|
+
options: {
|
|
98
|
+
entropy: {
|
|
99
|
+
type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
|
|
100
|
+
// NOTE: shares entropy with MOCK_HD_ACCOUNT_2
|
|
101
|
+
id: exports.MOCK_ENTROPY_SOURCE_2,
|
|
102
|
+
groupIndex: 0,
|
|
103
|
+
derivationPath: '',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
scopes: [keyring_api_1.BtcScope.Mainnet],
|
|
107
|
+
};
|
|
108
|
+
exports.MOCK_BTC_P2TR_ACCOUNT_1 = {
|
|
109
|
+
id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',
|
|
110
|
+
type: keyring_api_1.BtcAccountType.P2tr,
|
|
111
|
+
methods: [keyring_api_1.BtcMethod.SendBitcoin],
|
|
112
|
+
address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',
|
|
113
|
+
options: {
|
|
114
|
+
entropy: {
|
|
115
|
+
type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
|
|
116
|
+
// NOTE: shares entropy with MOCK_HD_ACCOUNT_2
|
|
117
|
+
id: exports.MOCK_ENTROPY_SOURCE_2,
|
|
118
|
+
groupIndex: 0,
|
|
119
|
+
derivationPath: '',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
scopes: [keyring_api_1.BtcScope.Testnet],
|
|
123
|
+
};
|
|
124
|
+
exports.MOCK_SNAP_ACCOUNT_1 = exports.MOCK_SOL_ACCOUNT_1;
|
|
125
|
+
exports.MOCK_SNAP_ACCOUNT_2 = {
|
|
126
|
+
id: 'mock-snap-id-2',
|
|
127
|
+
address: '0x789',
|
|
128
|
+
options: {},
|
|
129
|
+
methods: [...ETH_EOA_METHODS],
|
|
130
|
+
type: keyring_api_1.EthAccountType.Eoa,
|
|
131
|
+
scopes: [keyring_api_1.EthScope.Eoa],
|
|
132
|
+
};
|
|
133
|
+
exports.MOCK_SNAP_ACCOUNT_3 = exports.MOCK_BTC_P2WPKH_ACCOUNT_1;
|
|
134
|
+
exports.MOCK_SNAP_ACCOUNT_4 = exports.MOCK_BTC_P2TR_ACCOUNT_1;
|
|
135
|
+
exports.MOCK_HARDWARE_ACCOUNT_1 = {
|
|
136
|
+
id: 'mock-hardware-id-1',
|
|
137
|
+
address: '0xABC',
|
|
138
|
+
options: {},
|
|
139
|
+
methods: [...ETH_EOA_METHODS],
|
|
140
|
+
type: keyring_api_1.EthAccountType.Eoa,
|
|
141
|
+
scopes: [keyring_api_1.EthScope.Eoa],
|
|
142
|
+
};
|
|
143
|
+
class MockAccountBuilder {
|
|
144
|
+
constructor(account) {
|
|
145
|
+
_MockAccountBuilder_account.set(this, void 0);
|
|
146
|
+
// Make a deep-copy to avoid mutating the same ref.
|
|
147
|
+
__classPrivateFieldSet(this, _MockAccountBuilder_account, JSON.parse(JSON.stringify(account)), "f");
|
|
148
|
+
}
|
|
149
|
+
static from(account) {
|
|
150
|
+
return new MockAccountBuilder(account);
|
|
151
|
+
}
|
|
152
|
+
withId(id) {
|
|
153
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = id;
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
withUuid() {
|
|
157
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = (0, uuid_1.v4)();
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
withAddressSuffix(suffix) {
|
|
161
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").address += suffix;
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
withEntropySource(entropySource) {
|
|
165
|
+
if ((0, api_1.isBip44Account)(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
|
|
166
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.id = entropySource;
|
|
167
|
+
}
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
withGroupIndex(groupIndex) {
|
|
171
|
+
if ((0, api_1.isBip44Account)(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
|
|
172
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.groupIndex = groupIndex;
|
|
173
|
+
}
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
get() {
|
|
177
|
+
return __classPrivateFieldGet(this, _MockAccountBuilder_account, "f");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.MockAccountBuilder = MockAccountBuilder;
|
|
181
|
+
_MockAccountBuilder_account = new WeakMap();
|
|
182
|
+
exports.MOCK_WALLET_1_ENTROPY_SOURCE = exports.MOCK_ENTROPY_SOURCE_1;
|
|
183
|
+
exports.MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(exports.MOCK_HD_ACCOUNT_1)
|
|
184
|
+
.withEntropySource(exports.MOCK_WALLET_1_ENTROPY_SOURCE)
|
|
185
|
+
.withGroupIndex(0)
|
|
186
|
+
.get();
|
|
187
|
+
exports.MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(exports.MOCK_SOL_ACCOUNT_1)
|
|
188
|
+
.withEntropySource(exports.MOCK_WALLET_1_ENTROPY_SOURCE)
|
|
189
|
+
.withGroupIndex(0)
|
|
190
|
+
.get();
|
|
191
|
+
exports.MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(exports.MOCK_BTC_P2WPKH_ACCOUNT_1)
|
|
192
|
+
.withEntropySource(exports.MOCK_WALLET_1_ENTROPY_SOURCE)
|
|
193
|
+
.withGroupIndex(0)
|
|
194
|
+
.get();
|
|
195
|
+
exports.MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(exports.MOCK_BTC_P2TR_ACCOUNT_1)
|
|
196
|
+
.withEntropySource(exports.MOCK_WALLET_1_ENTROPY_SOURCE)
|
|
197
|
+
.withGroupIndex(0)
|
|
198
|
+
.get();
|
|
199
|
+
//# sourceMappingURL=accounts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.cjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,uDAW+B;AAC/B,+BAAkC;AAElC,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,C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AAC","sourcesContent":["import 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"]}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
|
|
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
|
+
export declare const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
22
|
+
export declare const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount>;
|
|
23
|
+
export declare const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
24
|
+
export declare const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
25
|
+
export declare const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
26
|
+
export declare const MOCK_SNAP_ACCOUNT_1: Bip44Account<{
|
|
27
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
28
|
+
id: string;
|
|
29
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
30
|
+
entropy?: {
|
|
31
|
+
type: "mnemonic";
|
|
32
|
+
id: string;
|
|
33
|
+
derivationPath: string;
|
|
34
|
+
groupIndex: number;
|
|
35
|
+
} | {
|
|
36
|
+
type: "private-key";
|
|
37
|
+
};
|
|
38
|
+
exportable?: boolean;
|
|
39
|
+
};
|
|
40
|
+
address: string;
|
|
41
|
+
scopes: `${string}:${string}`[];
|
|
42
|
+
methods: string[];
|
|
43
|
+
}>;
|
|
44
|
+
export declare const MOCK_SNAP_ACCOUNT_2: KeyringAccount;
|
|
45
|
+
export declare const MOCK_SNAP_ACCOUNT_3: Bip44Account<{
|
|
46
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
47
|
+
id: string;
|
|
48
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
49
|
+
entropy?: {
|
|
50
|
+
type: "mnemonic";
|
|
51
|
+
id: string;
|
|
52
|
+
derivationPath: string;
|
|
53
|
+
groupIndex: number;
|
|
54
|
+
} | {
|
|
55
|
+
type: "private-key";
|
|
56
|
+
};
|
|
57
|
+
exportable?: boolean;
|
|
58
|
+
};
|
|
59
|
+
address: string;
|
|
60
|
+
scopes: `${string}:${string}`[];
|
|
61
|
+
methods: string[];
|
|
62
|
+
}>;
|
|
63
|
+
export declare const MOCK_SNAP_ACCOUNT_4: Bip44Account<{
|
|
64
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
65
|
+
id: string;
|
|
66
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
67
|
+
entropy?: {
|
|
68
|
+
type: "mnemonic";
|
|
69
|
+
id: string;
|
|
70
|
+
derivationPath: string;
|
|
71
|
+
groupIndex: number;
|
|
72
|
+
} | {
|
|
73
|
+
type: "private-key";
|
|
74
|
+
};
|
|
75
|
+
exportable?: boolean;
|
|
76
|
+
};
|
|
77
|
+
address: string;
|
|
78
|
+
scopes: `${string}:${string}`[];
|
|
79
|
+
methods: string[];
|
|
80
|
+
}>;
|
|
81
|
+
export declare const MOCK_HARDWARE_ACCOUNT_1: KeyringAccount;
|
|
82
|
+
export declare class MockAccountBuilder<Account extends KeyringAccount> {
|
|
83
|
+
#private;
|
|
84
|
+
constructor(account: Account);
|
|
85
|
+
static from<Account extends KeyringAccount>(account: Account): MockAccountBuilder<Account>;
|
|
86
|
+
withId(id: KeyringAccount['id']): MockAccountBuilder<Account>;
|
|
87
|
+
withUuid(): MockAccountBuilder<Account>;
|
|
88
|
+
withAddressSuffix(suffix: string): MockAccountBuilder<Account>;
|
|
89
|
+
withEntropySource(entropySource: EntropySourceId): MockAccountBuilder<Account>;
|
|
90
|
+
withGroupIndex(groupIndex: number): MockAccountBuilder<Account>;
|
|
91
|
+
get(): Account;
|
|
92
|
+
}
|
|
93
|
+
export declare const MOCK_WALLET_1_ENTROPY_SOURCE = "mock-keyring-id-1";
|
|
94
|
+
export declare const MOCK_WALLET_1_EVM_ACCOUNT: Bip44Account<{
|
|
95
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
96
|
+
id: string;
|
|
97
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
98
|
+
entropy?: {
|
|
99
|
+
type: "mnemonic";
|
|
100
|
+
id: string;
|
|
101
|
+
derivationPath: string;
|
|
102
|
+
groupIndex: number;
|
|
103
|
+
} | {
|
|
104
|
+
type: "private-key";
|
|
105
|
+
};
|
|
106
|
+
exportable?: boolean;
|
|
107
|
+
};
|
|
108
|
+
address: string;
|
|
109
|
+
scopes: `${string}:${string}`[];
|
|
110
|
+
methods: string[];
|
|
111
|
+
}>;
|
|
112
|
+
export declare const MOCK_WALLET_1_SOL_ACCOUNT: Bip44Account<{
|
|
113
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
114
|
+
id: string;
|
|
115
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
116
|
+
entropy?: {
|
|
117
|
+
type: "mnemonic";
|
|
118
|
+
id: string;
|
|
119
|
+
derivationPath: string;
|
|
120
|
+
groupIndex: number;
|
|
121
|
+
} | {
|
|
122
|
+
type: "private-key";
|
|
123
|
+
};
|
|
124
|
+
exportable?: boolean;
|
|
125
|
+
};
|
|
126
|
+
address: string;
|
|
127
|
+
scopes: `${string}:${string}`[];
|
|
128
|
+
methods: string[];
|
|
129
|
+
}>;
|
|
130
|
+
export declare const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT: Bip44Account<{
|
|
131
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
132
|
+
id: string;
|
|
133
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
134
|
+
entropy?: {
|
|
135
|
+
type: "mnemonic";
|
|
136
|
+
id: string;
|
|
137
|
+
derivationPath: string;
|
|
138
|
+
groupIndex: number;
|
|
139
|
+
} | {
|
|
140
|
+
type: "private-key";
|
|
141
|
+
};
|
|
142
|
+
exportable?: boolean;
|
|
143
|
+
};
|
|
144
|
+
address: string;
|
|
145
|
+
scopes: `${string}:${string}`[];
|
|
146
|
+
methods: string[];
|
|
147
|
+
}>;
|
|
148
|
+
export declare const MOCK_WALLET_1_BTC_P2TR_ACCOUNT: Bip44Account<{
|
|
149
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
150
|
+
id: string;
|
|
151
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
152
|
+
entropy?: {
|
|
153
|
+
type: "mnemonic";
|
|
154
|
+
id: string;
|
|
155
|
+
derivationPath: string;
|
|
156
|
+
groupIndex: number;
|
|
157
|
+
} | {
|
|
158
|
+
type: "private-key";
|
|
159
|
+
};
|
|
160
|
+
exportable?: boolean;
|
|
161
|
+
};
|
|
162
|
+
address: string;
|
|
163
|
+
scopes: `${string}:${string}`[];
|
|
164
|
+
methods: string[];
|
|
165
|
+
}>;
|
|
166
|
+
//# sourceMappingURL=accounts.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.d.cts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAe7E,OAAO,EAAkB,KAAK,YAAY,EAAE,yBAAe;AAa3D,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,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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;;;;;;;;kBAS/B,CAAC;;;;;EAiJO,CAAC;AACT,eAAO,MAAM,8BAA8B;;;;eA3Jb,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EAuJO,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
|
|
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
|
+
export declare const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
22
|
+
export declare const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount>;
|
|
23
|
+
export declare const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
24
|
+
export declare const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
25
|
+
export declare const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<KeyringAccount>;
|
|
26
|
+
export declare const MOCK_SNAP_ACCOUNT_1: Bip44Account<{
|
|
27
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
28
|
+
id: string;
|
|
29
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
30
|
+
entropy?: {
|
|
31
|
+
type: "mnemonic";
|
|
32
|
+
id: string;
|
|
33
|
+
derivationPath: string;
|
|
34
|
+
groupIndex: number;
|
|
35
|
+
} | {
|
|
36
|
+
type: "private-key";
|
|
37
|
+
};
|
|
38
|
+
exportable?: boolean;
|
|
39
|
+
};
|
|
40
|
+
address: string;
|
|
41
|
+
scopes: `${string}:${string}`[];
|
|
42
|
+
methods: string[];
|
|
43
|
+
}>;
|
|
44
|
+
export declare const MOCK_SNAP_ACCOUNT_2: KeyringAccount;
|
|
45
|
+
export declare const MOCK_SNAP_ACCOUNT_3: Bip44Account<{
|
|
46
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
47
|
+
id: string;
|
|
48
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
49
|
+
entropy?: {
|
|
50
|
+
type: "mnemonic";
|
|
51
|
+
id: string;
|
|
52
|
+
derivationPath: string;
|
|
53
|
+
groupIndex: number;
|
|
54
|
+
} | {
|
|
55
|
+
type: "private-key";
|
|
56
|
+
};
|
|
57
|
+
exportable?: boolean;
|
|
58
|
+
};
|
|
59
|
+
address: string;
|
|
60
|
+
scopes: `${string}:${string}`[];
|
|
61
|
+
methods: string[];
|
|
62
|
+
}>;
|
|
63
|
+
export declare const MOCK_SNAP_ACCOUNT_4: Bip44Account<{
|
|
64
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
65
|
+
id: string;
|
|
66
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
67
|
+
entropy?: {
|
|
68
|
+
type: "mnemonic";
|
|
69
|
+
id: string;
|
|
70
|
+
derivationPath: string;
|
|
71
|
+
groupIndex: number;
|
|
72
|
+
} | {
|
|
73
|
+
type: "private-key";
|
|
74
|
+
};
|
|
75
|
+
exportable?: boolean;
|
|
76
|
+
};
|
|
77
|
+
address: string;
|
|
78
|
+
scopes: `${string}:${string}`[];
|
|
79
|
+
methods: string[];
|
|
80
|
+
}>;
|
|
81
|
+
export declare const MOCK_HARDWARE_ACCOUNT_1: KeyringAccount;
|
|
82
|
+
export declare class MockAccountBuilder<Account extends KeyringAccount> {
|
|
83
|
+
#private;
|
|
84
|
+
constructor(account: Account);
|
|
85
|
+
static from<Account extends KeyringAccount>(account: Account): MockAccountBuilder<Account>;
|
|
86
|
+
withId(id: KeyringAccount['id']): MockAccountBuilder<Account>;
|
|
87
|
+
withUuid(): MockAccountBuilder<Account>;
|
|
88
|
+
withAddressSuffix(suffix: string): MockAccountBuilder<Account>;
|
|
89
|
+
withEntropySource(entropySource: EntropySourceId): MockAccountBuilder<Account>;
|
|
90
|
+
withGroupIndex(groupIndex: number): MockAccountBuilder<Account>;
|
|
91
|
+
get(): Account;
|
|
92
|
+
}
|
|
93
|
+
export declare const MOCK_WALLET_1_ENTROPY_SOURCE = "mock-keyring-id-1";
|
|
94
|
+
export declare const MOCK_WALLET_1_EVM_ACCOUNT: Bip44Account<{
|
|
95
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
96
|
+
id: string;
|
|
97
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
98
|
+
entropy?: {
|
|
99
|
+
type: "mnemonic";
|
|
100
|
+
id: string;
|
|
101
|
+
derivationPath: string;
|
|
102
|
+
groupIndex: number;
|
|
103
|
+
} | {
|
|
104
|
+
type: "private-key";
|
|
105
|
+
};
|
|
106
|
+
exportable?: boolean;
|
|
107
|
+
};
|
|
108
|
+
address: string;
|
|
109
|
+
scopes: `${string}:${string}`[];
|
|
110
|
+
methods: string[];
|
|
111
|
+
}>;
|
|
112
|
+
export declare const MOCK_WALLET_1_SOL_ACCOUNT: Bip44Account<{
|
|
113
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
114
|
+
id: string;
|
|
115
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
116
|
+
entropy?: {
|
|
117
|
+
type: "mnemonic";
|
|
118
|
+
id: string;
|
|
119
|
+
derivationPath: string;
|
|
120
|
+
groupIndex: number;
|
|
121
|
+
} | {
|
|
122
|
+
type: "private-key";
|
|
123
|
+
};
|
|
124
|
+
exportable?: boolean;
|
|
125
|
+
};
|
|
126
|
+
address: string;
|
|
127
|
+
scopes: `${string}:${string}`[];
|
|
128
|
+
methods: string[];
|
|
129
|
+
}>;
|
|
130
|
+
export declare const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT: Bip44Account<{
|
|
131
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
132
|
+
id: string;
|
|
133
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
134
|
+
entropy?: {
|
|
135
|
+
type: "mnemonic";
|
|
136
|
+
id: string;
|
|
137
|
+
derivationPath: string;
|
|
138
|
+
groupIndex: number;
|
|
139
|
+
} | {
|
|
140
|
+
type: "private-key";
|
|
141
|
+
};
|
|
142
|
+
exportable?: boolean;
|
|
143
|
+
};
|
|
144
|
+
address: string;
|
|
145
|
+
scopes: `${string}:${string}`[];
|
|
146
|
+
methods: string[];
|
|
147
|
+
}>;
|
|
148
|
+
export declare const MOCK_WALLET_1_BTC_P2TR_ACCOUNT: Bip44Account<{
|
|
149
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
|
|
150
|
+
id: string;
|
|
151
|
+
options: Record<string, import("@metamask/utils").Json> & {
|
|
152
|
+
entropy?: {
|
|
153
|
+
type: "mnemonic";
|
|
154
|
+
id: string;
|
|
155
|
+
derivationPath: string;
|
|
156
|
+
groupIndex: number;
|
|
157
|
+
} | {
|
|
158
|
+
type: "private-key";
|
|
159
|
+
};
|
|
160
|
+
exportable?: boolean;
|
|
161
|
+
};
|
|
162
|
+
address: string;
|
|
163
|
+
scopes: `${string}:${string}`[];
|
|
164
|
+
methods: string[];
|
|
165
|
+
}>;
|
|
166
|
+
//# sourceMappingURL=accounts.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.d.mts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAe7E,OAAO,EAAkB,KAAK,YAAY,EAAE,yBAAe;AAa3D,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,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;;;;eA9DF,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EAqDoD,CAAC;AAEtD,eAAO,MAAM,mBAAmB,EAAE,cAOjC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;eAzEF,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EAgE2D,CAAC;AAC7D,eAAO,MAAM,mBAAmB;;;;eA1EF,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EAiEyD,CAAC;AAE3D,eAAO,MAAM,uBAAuB,EAAE,cAOrC,CAAC;AAEF,qBAAa,kBAAkB,CAAC,OAAO,SAAS,cAAc;;gBAGhD,OAAO,EAAE,OAAO;IAK5B,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,cAAc,EACxC,OAAO,EAAE,OAAO,GACf,kBAAkB,CAAC,OAAO,CAAC;IAI9B,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC;IAK7D,QAAQ,IAAI,kBAAkB,CAAC,OAAO,CAAC;IAKvC,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC;IAK9D,iBAAiB,CACf,aAAa,EAAE,eAAe,GAC7B,kBAAkB,CAAC,OAAO,CAAC;IAO9B,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC;IAO/D,GAAG,IAAI,OAAO;CAGf;AAED,eAAO,MAAM,4BAA4B,sBAAwB,CAAC;AAElE,eAAO,MAAM,yBAAyB;;;;eAzIR,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EAqIO,CAAC;AACT,eAAO,MAAM,yBAAyB;;;;eA/IR,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EA2IO,CAAC;AACT,eAAO,MAAM,gCAAgC;;;;eArJf,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EAiJO,CAAC;AACT,eAAO,MAAM,8BAA8B;;;;eA3Jb,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EAuJO,CAAC"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _MockAccountBuilder_account;
|
|
13
|
+
import { BtcAccountType, BtcMethod, BtcScope, EthAccountType, EthMethod, EthScope, KeyringAccountEntropyTypeOption, SolAccountType, SolMethod, SolScope } from "@metamask/keyring-api";
|
|
14
|
+
import { v4 as uuid } from "uuid";
|
|
15
|
+
import { isBip44Account } from "../api/index.mjs";
|
|
16
|
+
const ETH_EOA_METHODS = [
|
|
17
|
+
EthMethod.PersonalSign,
|
|
18
|
+
EthMethod.Sign,
|
|
19
|
+
EthMethod.SignTransaction,
|
|
20
|
+
EthMethod.SignTypedDataV1,
|
|
21
|
+
EthMethod.SignTypedDataV3,
|
|
22
|
+
EthMethod.SignTypedDataV4,
|
|
23
|
+
];
|
|
24
|
+
const SOL_METHODS = Object.values(SolMethod);
|
|
25
|
+
export const MOCK_SNAP_1 = {
|
|
26
|
+
id: 'local:mock-snap-id-1',
|
|
27
|
+
name: 'Mock Snap 1',
|
|
28
|
+
enabled: true,
|
|
29
|
+
manifest: {
|
|
30
|
+
proposedName: 'Mock Snap 1',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const MOCK_SNAP_2 = {
|
|
34
|
+
id: 'local:mock-snap-id-2',
|
|
35
|
+
name: 'Mock Snap 2',
|
|
36
|
+
enabled: true,
|
|
37
|
+
manifest: {
|
|
38
|
+
proposedName: 'Mock Snap 2',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
export const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';
|
|
42
|
+
export const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';
|
|
43
|
+
export const MOCK_HD_ACCOUNT_1 = {
|
|
44
|
+
id: 'mock-id-1',
|
|
45
|
+
address: '0x123',
|
|
46
|
+
options: {
|
|
47
|
+
entropy: {
|
|
48
|
+
type: KeyringAccountEntropyTypeOption.Mnemonic,
|
|
49
|
+
id: MOCK_ENTROPY_SOURCE_1,
|
|
50
|
+
groupIndex: 0,
|
|
51
|
+
derivationPath: '',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
methods: [...ETH_EOA_METHODS],
|
|
55
|
+
type: EthAccountType.Eoa,
|
|
56
|
+
scopes: [EthScope.Eoa],
|
|
57
|
+
};
|
|
58
|
+
export const MOCK_HD_ACCOUNT_2 = {
|
|
59
|
+
id: 'mock-id-2',
|
|
60
|
+
address: '0x456',
|
|
61
|
+
options: {
|
|
62
|
+
entropy: {
|
|
63
|
+
type: KeyringAccountEntropyTypeOption.Mnemonic,
|
|
64
|
+
id: MOCK_ENTROPY_SOURCE_2,
|
|
65
|
+
groupIndex: 0,
|
|
66
|
+
derivationPath: '',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
methods: [...ETH_EOA_METHODS],
|
|
70
|
+
type: EthAccountType.Eoa,
|
|
71
|
+
scopes: [EthScope.Eoa],
|
|
72
|
+
};
|
|
73
|
+
export const MOCK_SOL_ACCOUNT_1 = {
|
|
74
|
+
id: 'mock-snap-id-1',
|
|
75
|
+
address: 'aabbccdd',
|
|
76
|
+
options: {
|
|
77
|
+
entropy: {
|
|
78
|
+
type: KeyringAccountEntropyTypeOption.Mnemonic,
|
|
79
|
+
// NOTE: shares entropy with MOCK_HD_ACCOUNT_2
|
|
80
|
+
id: MOCK_ENTROPY_SOURCE_2,
|
|
81
|
+
groupIndex: 0,
|
|
82
|
+
derivationPath: '',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
methods: SOL_METHODS,
|
|
86
|
+
type: SolAccountType.DataAccount,
|
|
87
|
+
scopes: [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet],
|
|
88
|
+
};
|
|
89
|
+
export const MOCK_BTC_P2WPKH_ACCOUNT_1 = {
|
|
90
|
+
id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',
|
|
91
|
+
type: BtcAccountType.P2wpkh,
|
|
92
|
+
methods: [BtcMethod.SendBitcoin],
|
|
93
|
+
address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',
|
|
94
|
+
options: {
|
|
95
|
+
entropy: {
|
|
96
|
+
type: KeyringAccountEntropyTypeOption.Mnemonic,
|
|
97
|
+
// NOTE: shares entropy with MOCK_HD_ACCOUNT_2
|
|
98
|
+
id: MOCK_ENTROPY_SOURCE_2,
|
|
99
|
+
groupIndex: 0,
|
|
100
|
+
derivationPath: '',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
scopes: [BtcScope.Mainnet],
|
|
104
|
+
};
|
|
105
|
+
export const MOCK_BTC_P2TR_ACCOUNT_1 = {
|
|
106
|
+
id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',
|
|
107
|
+
type: BtcAccountType.P2tr,
|
|
108
|
+
methods: [BtcMethod.SendBitcoin],
|
|
109
|
+
address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',
|
|
110
|
+
options: {
|
|
111
|
+
entropy: {
|
|
112
|
+
type: KeyringAccountEntropyTypeOption.Mnemonic,
|
|
113
|
+
// NOTE: shares entropy with MOCK_HD_ACCOUNT_2
|
|
114
|
+
id: MOCK_ENTROPY_SOURCE_2,
|
|
115
|
+
groupIndex: 0,
|
|
116
|
+
derivationPath: '',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
scopes: [BtcScope.Testnet],
|
|
120
|
+
};
|
|
121
|
+
export const MOCK_SNAP_ACCOUNT_1 = MOCK_SOL_ACCOUNT_1;
|
|
122
|
+
export const MOCK_SNAP_ACCOUNT_2 = {
|
|
123
|
+
id: 'mock-snap-id-2',
|
|
124
|
+
address: '0x789',
|
|
125
|
+
options: {},
|
|
126
|
+
methods: [...ETH_EOA_METHODS],
|
|
127
|
+
type: EthAccountType.Eoa,
|
|
128
|
+
scopes: [EthScope.Eoa],
|
|
129
|
+
};
|
|
130
|
+
export const MOCK_SNAP_ACCOUNT_3 = MOCK_BTC_P2WPKH_ACCOUNT_1;
|
|
131
|
+
export const MOCK_SNAP_ACCOUNT_4 = MOCK_BTC_P2TR_ACCOUNT_1;
|
|
132
|
+
export const MOCK_HARDWARE_ACCOUNT_1 = {
|
|
133
|
+
id: 'mock-hardware-id-1',
|
|
134
|
+
address: '0xABC',
|
|
135
|
+
options: {},
|
|
136
|
+
methods: [...ETH_EOA_METHODS],
|
|
137
|
+
type: EthAccountType.Eoa,
|
|
138
|
+
scopes: [EthScope.Eoa],
|
|
139
|
+
};
|
|
140
|
+
export class MockAccountBuilder {
|
|
141
|
+
constructor(account) {
|
|
142
|
+
_MockAccountBuilder_account.set(this, void 0);
|
|
143
|
+
// Make a deep-copy to avoid mutating the same ref.
|
|
144
|
+
__classPrivateFieldSet(this, _MockAccountBuilder_account, JSON.parse(JSON.stringify(account)), "f");
|
|
145
|
+
}
|
|
146
|
+
static from(account) {
|
|
147
|
+
return new MockAccountBuilder(account);
|
|
148
|
+
}
|
|
149
|
+
withId(id) {
|
|
150
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = id;
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
withUuid() {
|
|
154
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = uuid();
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
withAddressSuffix(suffix) {
|
|
158
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").address += suffix;
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
withEntropySource(entropySource) {
|
|
162
|
+
if (isBip44Account(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
|
|
163
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.id = entropySource;
|
|
164
|
+
}
|
|
165
|
+
return this;
|
|
166
|
+
}
|
|
167
|
+
withGroupIndex(groupIndex) {
|
|
168
|
+
if (isBip44Account(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
|
|
169
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.groupIndex = groupIndex;
|
|
170
|
+
}
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
get() {
|
|
174
|
+
return __classPrivateFieldGet(this, _MockAccountBuilder_account, "f");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
_MockAccountBuilder_account = new WeakMap();
|
|
178
|
+
export const MOCK_WALLET_1_ENTROPY_SOURCE = MOCK_ENTROPY_SOURCE_1;
|
|
179
|
+
export const MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(MOCK_HD_ACCOUNT_1)
|
|
180
|
+
.withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)
|
|
181
|
+
.withGroupIndex(0)
|
|
182
|
+
.get();
|
|
183
|
+
export const MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(MOCK_SOL_ACCOUNT_1)
|
|
184
|
+
.withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)
|
|
185
|
+
.withGroupIndex(0)
|
|
186
|
+
.get();
|
|
187
|
+
export const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(MOCK_BTC_P2WPKH_ACCOUNT_1)
|
|
188
|
+
.withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)
|
|
189
|
+
.withGroupIndex(0)
|
|
190
|
+
.get();
|
|
191
|
+
export const MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(MOCK_BTC_P2TR_ACCOUNT_1)
|
|
192
|
+
.withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)
|
|
193
|
+
.withGroupIndex(0)
|
|
194
|
+
.get();
|
|
195
|
+
//# sourceMappingURL=accounts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.mjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,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,SAAS,CAAC,IAAI;IACd,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;CACjB,CAAC;AAEX,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC;AAEF,MA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I,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":["import 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"]}
|