@metamask-previews/account-api 2.1.1-preview-4fafbec → 2.2.0-preview-adbfbdd

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 CHANGED
@@ -7,6 +7,16 @@ 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
+
16
+ ### Changed
17
+
18
+ - Bump `@metamask/keyring-api` from `^24.2.0` to `^24.3.0` ([#674](https://github.com/MetaMask/accounts/pull/674))
19
+
10
20
  ## [2.1.1]
11
21
 
12
22
  ### Changed
@@ -205,7 +215,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
205
215
 
206
216
  - Add `AccountGroup` and `AccountWallet` ([#307](https://github.com/MetaMask/accounts/pull/307))
207
217
 
208
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@2.1.1...HEAD
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
209
220
  [2.1.1]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@2.1.0...@metamask/account-api@2.1.1
210
221
  [2.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@2.0.0...@metamask/account-api@2.1.0
211
222
  [2.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@1.1.1...@metamask/account-api@2.0.0
@@ -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);
@@ -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"]}
@@ -1,5 +1,6 @@
1
1
  export * from "./bip44.cjs";
2
2
  export * from "./group.cjs";
3
+ export * from "./mpc.cjs";
3
4
  export * from "./wallet.cjs";
4
5
  export type * from "./provider.cjs";
5
6
  export * from "./selector.cjs";
@@ -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"}
@@ -1,5 +1,6 @@
1
1
  export * from "./bip44.mjs";
2
2
  export * from "./group.mjs";
3
+ export * from "./mpc.mjs";
3
4
  export * from "./wallet.mjs";
4
5
  export type * from "./provider.mjs";
5
6
  export * from "./selector.mjs";
@@ -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"}
@@ -1,5 +1,6 @@
1
1
  export * from "./bip44.mjs";
2
2
  export * from "./group.mjs";
3
+ export * from "./mpc.mjs";
3
4
  export * from "./wallet.mjs";
4
5
  export * from "./selector.mjs";
5
6
  export * from "./multichain/index.mjs";
@@ -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"]}
@@ -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"}
@@ -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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/account-api",
3
- "version": "2.1.1-preview-4fafbec",
3
+ "version": "2.2.0-preview-adbfbdd",
4
4
  "description": "MetaMask Account API",
5
5
  "keywords": [
6
6
  "account",
@@ -65,7 +65,7 @@
65
65
  "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
66
66
  },
67
67
  "dependencies": {
68
- "@metamask/keyring-api": "^24.2.0",
68
+ "@metamask/keyring-api": "^24.3.0",
69
69
  "@metamask/keyring-utils": "^5.0.0",
70
70
  "uuid": "^9.0.1"
71
71
  },