@metamask-previews/account-api 1.0.4-e51c895 → 1.1.0-1fa477f
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 +9 -2
- package/dist/api/bip44.cjs +3 -1
- package/dist/api/bip44.cjs.map +1 -1
- package/dist/api/bip44.d.cts.map +1 -1
- package/dist/api/bip44.d.mts.map +1 -1
- package/dist/api/bip44.mjs +3 -1
- package/dist/api/bip44.mjs.map +1 -1
- package/dist/api/private-key.cjs +30 -0
- package/dist/api/private-key.cjs.map +1 -0
- package/dist/api/private-key.d.cts +24 -0
- package/dist/api/private-key.d.cts.map +1 -0
- package/dist/api/private-key.d.mts +24 -0
- package/dist/api/private-key.d.mts.map +1 -0
- package/dist/api/private-key.mjs +25 -0
- package/dist/api/private-key.mjs.map +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.1.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `PrivateKeyAccount<Account>` type helper ([#590](https://github.com/MetaMask/accounts/pull/590))
|
|
15
|
+
|
|
10
16
|
### Changed
|
|
11
17
|
|
|
12
18
|
- Bump `@metamask/keyring-utils` from `^3.2.0` to `^3.3.1` ([#544](https://github.com/MetaMask/accounts/pull/544), [#546](https://github.com/MetaMask/accounts/pull/546))
|
|
13
|
-
- Bump `@metamask/keyring-api` from `^23.1.0` to `^23.
|
|
19
|
+
- Bump `@metamask/keyring-api` from `^23.1.0` to `^23.5.0` ([#562](https://github.com/MetaMask/accounts/pull/562), [#569](https://github.com/MetaMask/accounts/pull/569), [#583](https://github.com/MetaMask/accounts/pull/583), [#587](https://github.com/MetaMask/accounts/pull/587))
|
|
14
20
|
|
|
15
21
|
## [1.0.4]
|
|
16
22
|
|
|
@@ -168,7 +174,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
168
174
|
|
|
169
175
|
- Add `AccountGroup` and `AccountWallet` ([#307](https://github.com/MetaMask/accounts/pull/307))
|
|
170
176
|
|
|
171
|
-
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@1.0
|
|
177
|
+
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@1.1.0...HEAD
|
|
178
|
+
[1.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@1.0.4...@metamask/account-api@1.1.0
|
|
172
179
|
[1.0.4]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@1.0.3...@metamask/account-api@1.0.4
|
|
173
180
|
[1.0.3]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@1.0.2...@metamask/account-api@1.0.3
|
|
174
181
|
[1.0.2]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@1.0.1...@metamask/account-api@1.0.2
|
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.assertIsBip44Account = exports.isBip44Account = void 0;
|
|
4
|
+
const keyring_api_1 = require("@metamask/keyring-api");
|
|
4
5
|
/**
|
|
5
6
|
* Checks if an account is BIP-44 compatible.
|
|
6
7
|
*
|
|
@@ -10,7 +11,8 @@ exports.assertIsBip44Account = exports.isBip44Account = void 0;
|
|
|
10
11
|
function isBip44Account(account) {
|
|
11
12
|
// To be BIP-44 compatible, we just check for the entropy type (the
|
|
12
13
|
// the `entropy` shape will be inferred automatically).
|
|
13
|
-
return account.options.entropy?.type ===
|
|
14
|
+
return (account.options.entropy?.type ===
|
|
15
|
+
`${keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic}`);
|
|
14
16
|
}
|
|
15
17
|
exports.isBip44Account = isBip44Account;
|
|
16
18
|
/**
|
package/dist/api/bip44.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bip44.cjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"bip44.cjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":";;;AAIA,uDAAwE;AAaxE;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,OAAgB;IAEhB,mEAAmE;IACnE,uDAAuD;IACvD,OAAO,CACL,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QAC7B,GAAG,6CAA+B,CAAC,QAAQ,EAAE,CAC9C,CAAC;AACJ,CAAC;AATD,wCASC;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;AAND,oDAMC","sourcesContent":["import type {\n KeyringAccount,\n KeyringAccountEntropyMnemonicOptions,\n} from '@metamask/keyring-api';\nimport { KeyringAccountEntropyTypeOption } from '@metamask/keyring-api';\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, we just check for the entropy type (the\n // the `entropy` shape will be inferred automatically).\n return (\n account.options.entropy?.type ===\n `${KeyringAccountEntropyTypeOption.Mnemonic}`\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.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;
|
|
1
|
+
{"version":3,"file":"bip44.d.cts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAG/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,CAOlC;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.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;
|
|
1
|
+
{"version":3,"file":"bip44.d.mts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAG/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,CAOlC;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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KeyringAccountEntropyTypeOption } from "@metamask/keyring-api";
|
|
1
2
|
/**
|
|
2
3
|
* Checks if an account is BIP-44 compatible.
|
|
3
4
|
*
|
|
@@ -7,7 +8,8 @@
|
|
|
7
8
|
export function isBip44Account(account) {
|
|
8
9
|
// To be BIP-44 compatible, we just check for the entropy type (the
|
|
9
10
|
// the `entropy` shape will be inferred automatically).
|
|
10
|
-
return account.options.entropy?.type ===
|
|
11
|
+
return (account.options.entropy?.type ===
|
|
12
|
+
`${KeyringAccountEntropyTypeOption.Mnemonic}`);
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Asserts a keyring account is BIP-44 compatible.
|
package/dist/api/bip44.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,+BAA+B,EAAE,8BAA8B;AAaxE;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB;IAEhB,mEAAmE;IACnE,uDAAuD;IACvD,OAAO,CACL,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QAC7B,GAAG,+BAA+B,CAAC,QAAQ,EAAE,CAC9C,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 { KeyringAccountEntropyTypeOption } from '@metamask/keyring-api';\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, we just check for the entropy type (the\n // the `entropy` shape will be inferred automatically).\n return (\n account.options.entropy?.type ===\n `${KeyringAccountEntropyTypeOption.Mnemonic}`\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"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertIsPrivateKeyAccount = exports.isPrivateKeyAccount = void 0;
|
|
4
|
+
const keyring_api_1 = require("@metamask/keyring-api");
|
|
5
|
+
/**
|
|
6
|
+
* Checks if an account is a private key account.
|
|
7
|
+
*
|
|
8
|
+
* @param account - The account to be tested.
|
|
9
|
+
* @returns True if the account is a private key account.
|
|
10
|
+
*/
|
|
11
|
+
function isPrivateKeyAccount(account) {
|
|
12
|
+
// To be private key compatible, we just check for the entropy type (the
|
|
13
|
+
// the `entropy` shape will be inferred automatically).
|
|
14
|
+
return (account.options.entropy?.type ===
|
|
15
|
+
`${keyring_api_1.KeyringAccountEntropyTypeOption.PrivateKey}`);
|
|
16
|
+
}
|
|
17
|
+
exports.isPrivateKeyAccount = isPrivateKeyAccount;
|
|
18
|
+
/**
|
|
19
|
+
* Asserts a keyring account is a private key account.
|
|
20
|
+
*
|
|
21
|
+
* @param account - Keyring account to check.
|
|
22
|
+
* @throws If the keyring account is not a private key account.
|
|
23
|
+
*/
|
|
24
|
+
function assertIsPrivateKeyAccount(account) {
|
|
25
|
+
if (!isPrivateKeyAccount(account)) {
|
|
26
|
+
throw new Error('Account is not private key account');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.assertIsPrivateKeyAccount = assertIsPrivateKeyAccount;
|
|
30
|
+
//# sourceMappingURL=private-key.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-key.cjs","sourceRoot":"","sources":["../../src/api/private-key.ts"],"names":[],"mappings":";;;AAAA,uDAAwE;AAiBxE;;;;;GAKG;AACH,SAAgB,mBAAmB,CACjC,OAAgB;IAEhB,wEAAwE;IACxE,uDAAuD;IACvD,OAAO,CACL,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QAC7B,GAAG,6CAA+B,CAAC,UAAU,EAAE,CAChD,CAAC;AACJ,CAAC;AATD,kDASC;AAED;;;;;GAKG;AACH,SAAgB,yBAAyB,CACvC,OAAgB;IAEhB,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAND,8DAMC","sourcesContent":["import { KeyringAccountEntropyTypeOption } from '@metamask/keyring-api';\nimport type {\n KeyringAccount,\n KeyringAccountEntropyPrivateKeyOptions,\n} from '@metamask/keyring-api';\n\n/**\n * Private key account type.\n */\nexport type PrivateKeyAccount<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is private key compatible).\n options: {\n entropy: KeyringAccountEntropyPrivateKeyOptions;\n };\n};\n\n/**\n * Checks if an account is a private key account.\n *\n * @param account - The account to be tested.\n * @returns True if the account is a private key account.\n */\nexport function isPrivateKeyAccount<Account extends KeyringAccount>(\n account: Account,\n): account is PrivateKeyAccount<Account> {\n // To be private key compatible, we just check for the entropy type (the\n // the `entropy` shape will be inferred automatically).\n return (\n account.options.entropy?.type ===\n `${KeyringAccountEntropyTypeOption.PrivateKey}`\n );\n}\n\n/**\n * Asserts a keyring account is a private key account.\n *\n * @param account - Keyring account to check.\n * @throws If the keyring account is not a private key account.\n */\nexport function assertIsPrivateKeyAccount<Account extends KeyringAccount>(\n account: Account,\n): asserts account is PrivateKeyAccount<Account> {\n if (!isPrivateKeyAccount(account)) {\n throw new Error('Account is not private key account');\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { KeyringAccount, KeyringAccountEntropyPrivateKeyOptions } from "@metamask/keyring-api";
|
|
2
|
+
/**
|
|
3
|
+
* Private key account type.
|
|
4
|
+
*/
|
|
5
|
+
export type PrivateKeyAccount<Account extends KeyringAccount> = Account & {
|
|
6
|
+
options: {
|
|
7
|
+
entropy: KeyringAccountEntropyPrivateKeyOptions;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Checks if an account is a private key account.
|
|
12
|
+
*
|
|
13
|
+
* @param account - The account to be tested.
|
|
14
|
+
* @returns True if the account is a private key account.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isPrivateKeyAccount<Account extends KeyringAccount>(account: Account): account is PrivateKeyAccount<Account>;
|
|
17
|
+
/**
|
|
18
|
+
* Asserts a keyring account is a private key account.
|
|
19
|
+
*
|
|
20
|
+
* @param account - Keyring account to check.
|
|
21
|
+
* @throws If the keyring account is not a private key account.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertIsPrivateKeyAccount<Account extends KeyringAccount>(account: Account): asserts account is PrivateKeyAccount<Account>;
|
|
24
|
+
//# sourceMappingURL=private-key.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-key.d.cts","sourceRoot":"","sources":["../../src/api/private-key.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,sCAAsC,EACvC,8BAA8B;AAE/B;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGxE,OAAO,EAAE;QACP,OAAO,EAAE,sCAAsC,CAAC;KACjD,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,SAAS,cAAc,EAChE,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAOvC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,SAAS,cAAc,EACtE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAI/C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { KeyringAccount, KeyringAccountEntropyPrivateKeyOptions } from "@metamask/keyring-api";
|
|
2
|
+
/**
|
|
3
|
+
* Private key account type.
|
|
4
|
+
*/
|
|
5
|
+
export type PrivateKeyAccount<Account extends KeyringAccount> = Account & {
|
|
6
|
+
options: {
|
|
7
|
+
entropy: KeyringAccountEntropyPrivateKeyOptions;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Checks if an account is a private key account.
|
|
12
|
+
*
|
|
13
|
+
* @param account - The account to be tested.
|
|
14
|
+
* @returns True if the account is a private key account.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isPrivateKeyAccount<Account extends KeyringAccount>(account: Account): account is PrivateKeyAccount<Account>;
|
|
17
|
+
/**
|
|
18
|
+
* Asserts a keyring account is a private key account.
|
|
19
|
+
*
|
|
20
|
+
* @param account - Keyring account to check.
|
|
21
|
+
* @throws If the keyring account is not a private key account.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertIsPrivateKeyAccount<Account extends KeyringAccount>(account: Account): asserts account is PrivateKeyAccount<Account>;
|
|
24
|
+
//# sourceMappingURL=private-key.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-key.d.mts","sourceRoot":"","sources":["../../src/api/private-key.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,sCAAsC,EACvC,8BAA8B;AAE/B;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGxE,OAAO,EAAE;QACP,OAAO,EAAE,sCAAsC,CAAC;KACjD,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,SAAS,cAAc,EAChE,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAOvC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,SAAS,cAAc,EACtE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAI/C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { KeyringAccountEntropyTypeOption } from "@metamask/keyring-api";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if an account is a private key account.
|
|
4
|
+
*
|
|
5
|
+
* @param account - The account to be tested.
|
|
6
|
+
* @returns True if the account is a private key account.
|
|
7
|
+
*/
|
|
8
|
+
export function isPrivateKeyAccount(account) {
|
|
9
|
+
// To be private key compatible, we just check for the entropy type (the
|
|
10
|
+
// the `entropy` shape will be inferred automatically).
|
|
11
|
+
return (account.options.entropy?.type ===
|
|
12
|
+
`${KeyringAccountEntropyTypeOption.PrivateKey}`);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Asserts a keyring account is a private key account.
|
|
16
|
+
*
|
|
17
|
+
* @param account - Keyring account to check.
|
|
18
|
+
* @throws If the keyring account is not a private key account.
|
|
19
|
+
*/
|
|
20
|
+
export function assertIsPrivateKeyAccount(account) {
|
|
21
|
+
if (!isPrivateKeyAccount(account)) {
|
|
22
|
+
throw new Error('Account is not private key account');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=private-key.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-key.mjs","sourceRoot":"","sources":["../../src/api/private-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,8BAA8B;AAiBxE;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAgB;IAEhB,wEAAwE;IACxE,uDAAuD;IACvD,OAAO,CACL,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QAC7B,GAAG,+BAA+B,CAAC,UAAU,EAAE,CAChD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAgB;IAEhB,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;AACH,CAAC","sourcesContent":["import { KeyringAccountEntropyTypeOption } from '@metamask/keyring-api';\nimport type {\n KeyringAccount,\n KeyringAccountEntropyPrivateKeyOptions,\n} from '@metamask/keyring-api';\n\n/**\n * Private key account type.\n */\nexport type PrivateKeyAccount<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is private key compatible).\n options: {\n entropy: KeyringAccountEntropyPrivateKeyOptions;\n };\n};\n\n/**\n * Checks if an account is a private key account.\n *\n * @param account - The account to be tested.\n * @returns True if the account is a private key account.\n */\nexport function isPrivateKeyAccount<Account extends KeyringAccount>(\n account: Account,\n): account is PrivateKeyAccount<Account> {\n // To be private key compatible, we just check for the entropy type (the\n // the `entropy` shape will be inferred automatically).\n return (\n account.options.entropy?.type ===\n `${KeyringAccountEntropyTypeOption.PrivateKey}`\n );\n}\n\n/**\n * Asserts a keyring account is a private key account.\n *\n * @param account - Keyring account to check.\n * @throws If the keyring account is not a private key account.\n */\nexport function assertIsPrivateKeyAccount<Account extends KeyringAccount>(\n account: Account,\n): asserts account is PrivateKeyAccount<Account> {\n if (!isPrivateKeyAccount(account)) {\n throw new Error('Account is not private key account');\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/account-api",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-1fa477f",
|
|
4
4
|
"description": "MetaMask Account API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"account",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@metamask/keyring-api": "23.
|
|
69
|
+
"@metamask/keyring-api": "23.5.0",
|
|
70
70
|
"@metamask/keyring-utils": "3.3.1",
|
|
71
71
|
"uuid": "^9.0.1"
|
|
72
72
|
},
|