@metamask-previews/account-api 2.1.1-preview-3d69c27 → 2.2.0-preview-5daa013
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/index.cjs +1 -0
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +1 -0
- package/dist/api/index.d.cts.map +1 -1
- package/dist/api/index.d.mts +1 -0
- package/dist/api/index.d.mts.map +1 -1
- package/dist/api/index.mjs +1 -0
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/mpc.cjs +29 -0
- package/dist/api/mpc.cjs.map +1 -0
- package/dist/api/mpc.d.cts +24 -0
- package/dist/api/mpc.d.cts.map +1 -0
- package/dist/api/mpc.d.mts +24 -0
- package/dist/api/mpc.d.mts.map +1 -0
- package/dist/api/mpc.mjs +24 -0
- package/dist/api/mpc.mjs.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.2.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `MpcAccount<Account>` type helper + `isMpcAccount` helper ([#677](https://github.com/MetaMask/accounts/pull/677))
|
|
15
|
+
|
|
10
16
|
### Changed
|
|
11
17
|
|
|
12
18
|
- Bump `@metamask/keyring-api` from `^24.2.0` to `^24.3.0` ([#674](https://github.com/MetaMask/accounts/pull/674))
|
|
@@ -209,7 +215,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
209
215
|
|
|
210
216
|
- Add `AccountGroup` and `AccountWallet` ([#307](https://github.com/MetaMask/accounts/pull/307))
|
|
211
217
|
|
|
212
|
-
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@2.
|
|
218
|
+
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@2.2.0...HEAD
|
|
219
|
+
[2.2.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@2.1.1...@metamask/account-api@2.2.0
|
|
213
220
|
[2.1.1]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@2.1.0...@metamask/account-api@2.1.1
|
|
214
221
|
[2.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@2.0.0...@metamask/account-api@2.1.0
|
|
215
222
|
[2.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@1.1.1...@metamask/account-api@2.0.0
|
package/dist/api/index.cjs
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./bip44.cjs"), exports);
|
|
18
18
|
__exportStar(require("./group.cjs"), exports);
|
|
19
|
+
__exportStar(require("./mpc.cjs"), exports);
|
|
19
20
|
__exportStar(require("./wallet.cjs"), exports);
|
|
20
21
|
__exportStar(require("./selector.cjs"), exports);
|
|
21
22
|
__exportStar(require("./multichain/index.cjs"), exports);
|
package/dist/api/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,8CAAwB;AACxB,+CAAyB;AAEzB,iDAA2B;AAC3B,yDAA6B;AAE7B,+CAA+C","sourcesContent":["export * from './bip44';\nexport * from './group';\nexport * from './wallet';\nexport type * from './provider';\nexport * from './selector';\nexport * from './multichain';\n\n// NOTE: Do not export the `internal` sub-path.\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,8CAAwB;AACxB,4CAAsB;AACtB,+CAAyB;AAEzB,iDAA2B;AAC3B,yDAA6B;AAE7B,+CAA+C","sourcesContent":["export * from './bip44';\nexport * from './group';\nexport * from './mpc';\nexport * from './wallet';\nexport type * from './provider';\nexport * from './selector';\nexport * from './multichain';\n\n// NOTE: Do not export the `internal` sub-path.\n"]}
|
package/dist/api/index.d.cts
CHANGED
package/dist/api/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,4BAAwB;AACxB,6BAAyB;AACzB,oCAAgC;AAChC,+BAA2B;AAC3B,uCAA6B"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,4BAAwB;AACxB,0BAAsB;AACtB,6BAAyB;AACzB,oCAAgC;AAChC,+BAA2B;AAC3B,uCAA6B"}
|
package/dist/api/index.d.mts
CHANGED
package/dist/api/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,4BAAwB;AACxB,6BAAyB;AACzB,oCAAgC;AAChC,+BAA2B;AAC3B,uCAA6B"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,4BAAwB;AACxB,0BAAsB;AACtB,6BAAyB;AACzB,oCAAgC;AAChC,+BAA2B;AAC3B,uCAA6B"}
|
package/dist/api/index.mjs
CHANGED
package/dist/api/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,4BAAwB;AACxB,6BAAyB;AAEzB,+BAA2B;AAC3B,uCAA6B;AAE7B,+CAA+C","sourcesContent":["export * from './bip44';\nexport * from './group';\nexport * from './wallet';\nexport type * from './provider';\nexport * from './selector';\nexport * from './multichain';\n\n// NOTE: Do not export the `internal` sub-path.\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,4BAAwB;AACxB,0BAAsB;AACtB,6BAAyB;AAEzB,+BAA2B;AAC3B,uCAA6B;AAE7B,+CAA+C","sourcesContent":["export * from './bip44';\nexport * from './group';\nexport * from './mpc';\nexport * from './wallet';\nexport type * from './provider';\nexport * from './selector';\nexport * from './multichain';\n\n// NOTE: Do not export the `internal` sub-path.\n"]}
|
package/dist/api/mpc.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertIsMpcAccount = exports.isMpcAccount = void 0;
|
|
4
|
+
const keyring_api_1 = require("@metamask/keyring-api");
|
|
5
|
+
/**
|
|
6
|
+
* Checks if an account is an MPC account.
|
|
7
|
+
*
|
|
8
|
+
* @param account - The account to be tested.
|
|
9
|
+
* @returns True if the account is an MPC account.
|
|
10
|
+
*/
|
|
11
|
+
function isMpcAccount(account) {
|
|
12
|
+
// To be MPC compatible, we just check for the entropy type (the
|
|
13
|
+
// the `entropy` shape will be inferred automatically).
|
|
14
|
+
return (account.options.entropy?.type === `${keyring_api_1.KeyringAccountEntropyTypeOption.Mpc}`);
|
|
15
|
+
}
|
|
16
|
+
exports.isMpcAccount = isMpcAccount;
|
|
17
|
+
/**
|
|
18
|
+
* Asserts a keyring account is an MPC account.
|
|
19
|
+
*
|
|
20
|
+
* @param account - Keyring account to check.
|
|
21
|
+
* @throws If the keyring account is not an MPC account.
|
|
22
|
+
*/
|
|
23
|
+
function assertIsMpcAccount(account) {
|
|
24
|
+
if (!isMpcAccount(account)) {
|
|
25
|
+
throw new Error('Account is not an MPC account');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.assertIsMpcAccount = assertIsMpcAccount;
|
|
29
|
+
//# sourceMappingURL=mpc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpc.cjs","sourceRoot":"","sources":["../../src/api/mpc.ts"],"names":[],"mappings":";;;AAAA,uDAAwE;AAiBxE;;;;;GAKG;AACH,SAAgB,YAAY,CAC1B,OAAgB;IAEhB,gEAAgE;IAChE,uDAAuD;IACvD,OAAO,CACL,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,KAAK,GAAG,6CAA+B,CAAC,GAAG,EAAE,CAC3E,CAAC;AACJ,CAAC;AARD,oCAQC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,OAAgB;IAEhB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAND,gDAMC","sourcesContent":["import { KeyringAccountEntropyTypeOption } from '@metamask/keyring-api';\nimport type {\n KeyringAccount,\n KeyringAccountEntropyMpcOptions,\n} from '@metamask/keyring-api';\n\n/**\n * MPC account type.\n */\nexport type MpcAccount<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is MPC compatible).\n options: {\n entropy: KeyringAccountEntropyMpcOptions;\n };\n};\n\n/**\n * Checks if an account is an MPC account.\n *\n * @param account - The account to be tested.\n * @returns True if the account is an MPC account.\n */\nexport function isMpcAccount<Account extends KeyringAccount>(\n account: Account,\n): account is MpcAccount<Account> {\n // To be MPC compatible, we just check for the entropy type (the\n // the `entropy` shape will be inferred automatically).\n return (\n account.options.entropy?.type === `${KeyringAccountEntropyTypeOption.Mpc}`\n );\n}\n\n/**\n * Asserts a keyring account is an MPC account.\n *\n * @param account - Keyring account to check.\n * @throws If the keyring account is not an MPC account.\n */\nexport function assertIsMpcAccount<Account extends KeyringAccount>(\n account: Account,\n): asserts account is MpcAccount<Account> {\n if (!isMpcAccount(account)) {\n throw new Error('Account is not an MPC account');\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { KeyringAccount, KeyringAccountEntropyMpcOptions } from "@metamask/keyring-api";
|
|
2
|
+
/**
|
|
3
|
+
* MPC account type.
|
|
4
|
+
*/
|
|
5
|
+
export type MpcAccount<Account extends KeyringAccount> = Account & {
|
|
6
|
+
options: {
|
|
7
|
+
entropy: KeyringAccountEntropyMpcOptions;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Checks if an account is an MPC account.
|
|
12
|
+
*
|
|
13
|
+
* @param account - The account to be tested.
|
|
14
|
+
* @returns True if the account is an MPC account.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isMpcAccount<Account extends KeyringAccount>(account: Account): account is MpcAccount<Account>;
|
|
17
|
+
/**
|
|
18
|
+
* Asserts a keyring account is an MPC account.
|
|
19
|
+
*
|
|
20
|
+
* @param account - Keyring account to check.
|
|
21
|
+
* @throws If the keyring account is not an MPC account.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertIsMpcAccount<Account extends KeyringAccount>(account: Account): asserts account is MpcAccount<Account>;
|
|
24
|
+
//# sourceMappingURL=mpc.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpc.d.cts","sourceRoot":"","sources":["../../src/api/mpc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,+BAA+B,EAChC,8BAA8B;AAE/B;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGjE,OAAO,EAAE;QACP,OAAO,EAAE,+BAA+B,CAAC;KAC1C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,SAAS,cAAc,EACzD,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAMhC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,SAAS,cAAc,EAC/D,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAIxC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { KeyringAccount, KeyringAccountEntropyMpcOptions } from "@metamask/keyring-api";
|
|
2
|
+
/**
|
|
3
|
+
* MPC account type.
|
|
4
|
+
*/
|
|
5
|
+
export type MpcAccount<Account extends KeyringAccount> = Account & {
|
|
6
|
+
options: {
|
|
7
|
+
entropy: KeyringAccountEntropyMpcOptions;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Checks if an account is an MPC account.
|
|
12
|
+
*
|
|
13
|
+
* @param account - The account to be tested.
|
|
14
|
+
* @returns True if the account is an MPC account.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isMpcAccount<Account extends KeyringAccount>(account: Account): account is MpcAccount<Account>;
|
|
17
|
+
/**
|
|
18
|
+
* Asserts a keyring account is an MPC account.
|
|
19
|
+
*
|
|
20
|
+
* @param account - Keyring account to check.
|
|
21
|
+
* @throws If the keyring account is not an MPC account.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertIsMpcAccount<Account extends KeyringAccount>(account: Account): asserts account is MpcAccount<Account>;
|
|
24
|
+
//# sourceMappingURL=mpc.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpc.d.mts","sourceRoot":"","sources":["../../src/api/mpc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,+BAA+B,EAChC,8BAA8B;AAE/B;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGjE,OAAO,EAAE;QACP,OAAO,EAAE,+BAA+B,CAAC;KAC1C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,SAAS,cAAc,EACzD,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAMhC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,SAAS,cAAc,EAC/D,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAIxC"}
|
package/dist/api/mpc.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { KeyringAccountEntropyTypeOption } from "@metamask/keyring-api";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if an account is an MPC account.
|
|
4
|
+
*
|
|
5
|
+
* @param account - The account to be tested.
|
|
6
|
+
* @returns True if the account is an MPC account.
|
|
7
|
+
*/
|
|
8
|
+
export function isMpcAccount(account) {
|
|
9
|
+
// To be MPC compatible, we just check for the entropy type (the
|
|
10
|
+
// the `entropy` shape will be inferred automatically).
|
|
11
|
+
return (account.options.entropy?.type === `${KeyringAccountEntropyTypeOption.Mpc}`);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Asserts a keyring account is an MPC account.
|
|
15
|
+
*
|
|
16
|
+
* @param account - Keyring account to check.
|
|
17
|
+
* @throws If the keyring account is not an MPC account.
|
|
18
|
+
*/
|
|
19
|
+
export function assertIsMpcAccount(account) {
|
|
20
|
+
if (!isMpcAccount(account)) {
|
|
21
|
+
throw new Error('Account is not an MPC account');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=mpc.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpc.mjs","sourceRoot":"","sources":["../../src/api/mpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,8BAA8B;AAiBxE;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAgB;IAEhB,gEAAgE;IAChE,uDAAuD;IACvD,OAAO,CACL,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,KAAK,GAAG,+BAA+B,CAAC,GAAG,EAAE,CAC3E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAgB;IAEhB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;AACH,CAAC","sourcesContent":["import { KeyringAccountEntropyTypeOption } from '@metamask/keyring-api';\nimport type {\n KeyringAccount,\n KeyringAccountEntropyMpcOptions,\n} from '@metamask/keyring-api';\n\n/**\n * MPC account type.\n */\nexport type MpcAccount<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is MPC compatible).\n options: {\n entropy: KeyringAccountEntropyMpcOptions;\n };\n};\n\n/**\n * Checks if an account is an MPC account.\n *\n * @param account - The account to be tested.\n * @returns True if the account is an MPC account.\n */\nexport function isMpcAccount<Account extends KeyringAccount>(\n account: Account,\n): account is MpcAccount<Account> {\n // To be MPC compatible, we just check for the entropy type (the\n // the `entropy` shape will be inferred automatically).\n return (\n account.options.entropy?.type === `${KeyringAccountEntropyTypeOption.Mpc}`\n );\n}\n\n/**\n * Asserts a keyring account is an MPC account.\n *\n * @param account - Keyring account to check.\n * @throws If the keyring account is not an MPC account.\n */\nexport function assertIsMpcAccount<Account extends KeyringAccount>(\n account: Account,\n): asserts account is MpcAccount<Account> {\n if (!isMpcAccount(account)) {\n throw new Error('Account is not an MPC account');\n }\n}\n"]}
|