@metamask-previews/multichain-account-service 0.9.0-preview-463efec → 0.9.0-preview-591781b

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/MultichainAccountService.cjs +4 -3
  3. package/dist/MultichainAccountService.cjs.map +1 -1
  4. package/dist/MultichainAccountService.d.cts +10 -3
  5. package/dist/MultichainAccountService.d.cts.map +1 -1
  6. package/dist/MultichainAccountService.d.mts +10 -3
  7. package/dist/MultichainAccountService.d.mts.map +1 -1
  8. package/dist/MultichainAccountService.mjs +4 -3
  9. package/dist/MultichainAccountService.mjs.map +1 -1
  10. package/dist/index.cjs +2 -1
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +1 -1
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +1 -1
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +1 -1
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/providers/EvmAccountProvider.cjs +28 -60
  19. package/dist/providers/EvmAccountProvider.cjs.map +1 -1
  20. package/dist/providers/EvmAccountProvider.d.cts +11 -0
  21. package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
  22. package/dist/providers/EvmAccountProvider.d.mts +11 -0
  23. package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
  24. package/dist/providers/EvmAccountProvider.mjs +27 -59
  25. package/dist/providers/EvmAccountProvider.mjs.map +1 -1
  26. package/dist/providers/SolAccountProvider.cjs +20 -6
  27. package/dist/providers/SolAccountProvider.cjs.map +1 -1
  28. package/dist/providers/SolAccountProvider.d.cts +10 -1
  29. package/dist/providers/SolAccountProvider.d.cts.map +1 -1
  30. package/dist/providers/SolAccountProvider.d.mts +10 -1
  31. package/dist/providers/SolAccountProvider.d.mts.map +1 -1
  32. package/dist/providers/SolAccountProvider.mjs +19 -5
  33. package/dist/providers/SolAccountProvider.mjs.map +1 -1
  34. package/dist/providers/index.cjs +4 -0
  35. package/dist/providers/index.cjs.map +1 -1
  36. package/dist/providers/index.d.cts +1 -0
  37. package/dist/providers/index.d.cts.map +1 -1
  38. package/dist/providers/index.d.mts +1 -0
  39. package/dist/providers/index.d.mts.map +1 -1
  40. package/dist/providers/index.mjs +2 -0
  41. package/dist/providers/index.mjs.map +1 -1
  42. package/dist/providers/utils.cjs +66 -0
  43. package/dist/providers/utils.cjs.map +1 -0
  44. package/dist/providers/utils.d.cts +27 -0
  45. package/dist/providers/utils.d.cts.map +1 -0
  46. package/dist/providers/utils.d.mts +27 -0
  47. package/dist/providers/utils.d.mts.map +1 -0
  48. package/dist/providers/utils.mjs +60 -0
  49. package/dist/providers/utils.mjs.map +1 -0
  50. package/dist/tests/providers.cjs +1 -0
  51. package/dist/tests/providers.cjs.map +1 -1
  52. package/dist/tests/providers.d.cts +1 -0
  53. package/dist/tests/providers.d.cts.map +1 -1
  54. package/dist/tests/providers.d.mts +1 -0
  55. package/dist/tests/providers.d.mts.map +1 -1
  56. package/dist/tests/providers.mjs +1 -0
  57. package/dist/tests/providers.mjs.map +1 -1
  58. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
1
  export * from "./BaseBip44AccountProvider.mjs";
2
2
  export * from "./SnapAccountProvider.mjs";
3
3
  export * from "./AccountProviderWrapper.mjs";
4
+ // Errors that can bubble up outside of provider calls.
5
+ export { TimeoutError } from "./utils.mjs";
4
6
  // Concrete providers:
5
7
  export * from "./SolAccountProvider.mjs";
6
8
  export * from "./EvmAccountProvider.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,+CAA2C;AAC3C,0CAAsC;AACtC,6CAAyC;AAEzC,sBAAsB;AACtB,yCAAqC;AACrC,yCAAqC","sourcesContent":["export * from './BaseBip44AccountProvider';\nexport * from './SnapAccountProvider';\nexport * from './AccountProviderWrapper';\n\n// Concrete providers:\nexport * from './SolAccountProvider';\nexport * from './EvmAccountProvider';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,+CAA2C;AAC3C,0CAAsC;AACtC,6CAAyC;AAEzC,uDAAuD;AACvD,OAAO,EAAE,YAAY,EAAE,oBAAgB;AAEvC,sBAAsB;AACtB,yCAAqC;AACrC,yCAAqC","sourcesContent":["export * from './BaseBip44AccountProvider';\nexport * from './SnapAccountProvider';\nexport * from './AccountProviderWrapper';\n\n// Errors that can bubble up outside of provider calls.\nexport { TimeoutError } from './utils';\n\n// Concrete providers:\nexport * from './SolAccountProvider';\nexport * from './EvmAccountProvider';\n"]}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withTimeout = exports.withRetry = exports.TimeoutError = void 0;
4
+ /** Timeout error. */
5
+ class TimeoutError extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = 'TimeoutError';
9
+ }
10
+ }
11
+ exports.TimeoutError = TimeoutError;
12
+ /**
13
+ * Execute a function with exponential backoff on transient failures.
14
+ *
15
+ * @param fnToExecute - The function to execute.
16
+ * @param options - The options for the retry.
17
+ * @param options.maxAttempts - The maximum number of attempts.
18
+ * @param options.backOffMs - The backoff in milliseconds.
19
+ * @throws An error if the transaction count cannot be retrieved.
20
+ * @returns The result of the function.
21
+ */
22
+ async function withRetry(fnToExecute, { maxAttempts = 3, backOffMs = 500, } = {}) {
23
+ let lastError;
24
+ let backOff = backOffMs;
25
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
26
+ try {
27
+ return await fnToExecute();
28
+ }
29
+ catch (error) {
30
+ lastError = error;
31
+ if (attempt >= maxAttempts) {
32
+ break;
33
+ }
34
+ const delay = backOff;
35
+ await new Promise((resolve) => setTimeout(resolve, delay));
36
+ backOff *= 2;
37
+ }
38
+ }
39
+ throw lastError;
40
+ }
41
+ exports.withRetry = withRetry;
42
+ /**
43
+ * Execute a promise with a timeout.
44
+ *
45
+ * @param promise - The promise to execute.
46
+ * @param timeoutMs - The timeout in milliseconds.
47
+ * @returns The result of the promise.
48
+ */
49
+ async function withTimeout(promise, timeoutMs = 500) {
50
+ let timer;
51
+ try {
52
+ return await Promise.race([
53
+ promise,
54
+ new Promise((_resolve, reject) => {
55
+ timer = setTimeout(() => reject(new TimeoutError('Timed out')), timeoutMs);
56
+ }),
57
+ ]);
58
+ }
59
+ finally {
60
+ if (timer) {
61
+ clearTimeout(timer);
62
+ }
63
+ }
64
+ }
65
+ exports.withTimeout = withTimeout;
66
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../src/providers/utils.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,SAAS,CAC7B,WAA6B,EAC7B,EACE,WAAW,GAAG,CAAC,EACf,SAAS,GAAG,GAAG,MACiC,EAAE;IAEpD,IAAI,SAAS,CAAC;IACd,IAAI,OAAO,GAAG,SAAS,CAAC;IACxB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,EAAE;QACvD,IAAI;YACF,OAAO,MAAM,WAAW,EAAE,CAAC;SAC5B;QAAC,OAAO,KAAK,EAAE;YACd,SAAS,GAAG,KAAK,CAAC;YAClB,IAAI,OAAO,IAAI,WAAW,EAAE;gBAC1B,MAAM;aACP;YACD,MAAM,KAAK,GAAG,OAAO,CAAC;YACtB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YAC3D,OAAO,IAAI,CAAC,CAAC;SACd;KACF;IACD,MAAM,SAAS,CAAC;AAClB,CAAC;AAvBD,8BAuBC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,WAAW,CAC/B,OAAmB,EACnB,YAAoB,GAAG;IAEvB,IAAI,KAAK,CAAC;IACV,IAAI;QACF,OAAO,MAAM,OAAO,CAAC,IAAI,CAAI;YAC3B,OAAO;YACP,IAAI,OAAO,CAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;gBAClC,KAAK,GAAG,UAAU,CAChB,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC,EAC3C,SAAS,CACV,CAAC;YACJ,CAAC,CAAC;SACH,CAAC,CAAC;KACJ;YAAS;QACR,IAAI,KAAK,EAAE;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;SACrB;KACF;AACH,CAAC;AApBD,kCAoBC","sourcesContent":["/** Timeout error. */\nexport class TimeoutError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Execute a function with exponential backoff on transient failures.\n *\n * @param fnToExecute - The function to execute.\n * @param options - The options for the retry.\n * @param options.maxAttempts - The maximum number of attempts.\n * @param options.backOffMs - The backoff in milliseconds.\n * @throws An error if the transaction count cannot be retrieved.\n * @returns The result of the function.\n */\nexport async function withRetry<T>(\n fnToExecute: () => Promise<T>,\n {\n maxAttempts = 3,\n backOffMs = 500,\n }: { maxAttempts?: number; backOffMs?: number } = {},\n): Promise<T> {\n let lastError;\n let backOff = backOffMs;\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fnToExecute();\n } catch (error) {\n lastError = error;\n if (attempt >= maxAttempts) {\n break;\n }\n const delay = backOff;\n await new Promise((resolve) => setTimeout(resolve, delay));\n backOff *= 2;\n }\n }\n throw lastError;\n}\n\n/**\n * Execute a promise with a timeout.\n *\n * @param promise - The promise to execute.\n * @param timeoutMs - The timeout in milliseconds.\n * @returns The result of the promise.\n */\nexport async function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number = 500,\n): Promise<T> {\n let timer;\n try {\n return await Promise.race<T>([\n promise,\n new Promise<T>((_resolve, reject) => {\n timer = setTimeout(\n () => reject(new TimeoutError('Timed out')),\n timeoutMs,\n );\n }),\n ]);\n } finally {\n if (timer) {\n clearTimeout(timer);\n }\n }\n}\n"]}
@@ -0,0 +1,27 @@
1
+ /** Timeout error. */
2
+ export declare class TimeoutError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /**
6
+ * Execute a function with exponential backoff on transient failures.
7
+ *
8
+ * @param fnToExecute - The function to execute.
9
+ * @param options - The options for the retry.
10
+ * @param options.maxAttempts - The maximum number of attempts.
11
+ * @param options.backOffMs - The backoff in milliseconds.
12
+ * @throws An error if the transaction count cannot be retrieved.
13
+ * @returns The result of the function.
14
+ */
15
+ export declare function withRetry<T>(fnToExecute: () => Promise<T>, { maxAttempts, backOffMs, }?: {
16
+ maxAttempts?: number;
17
+ backOffMs?: number;
18
+ }): Promise<T>;
19
+ /**
20
+ * Execute a promise with a timeout.
21
+ *
22
+ * @param promise - The promise to execute.
23
+ * @param timeoutMs - The timeout in milliseconds.
24
+ * @returns The result of the promise.
25
+ */
26
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs?: number): Promise<T>;
27
+ //# sourceMappingURL=utils.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../src/providers/utils.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,WAAW,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC7B,EACE,WAAe,EACf,SAAe,GAChB,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnD,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,GAAE,MAAY,GACtB,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
@@ -0,0 +1,27 @@
1
+ /** Timeout error. */
2
+ export declare class TimeoutError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /**
6
+ * Execute a function with exponential backoff on transient failures.
7
+ *
8
+ * @param fnToExecute - The function to execute.
9
+ * @param options - The options for the retry.
10
+ * @param options.maxAttempts - The maximum number of attempts.
11
+ * @param options.backOffMs - The backoff in milliseconds.
12
+ * @throws An error if the transaction count cannot be retrieved.
13
+ * @returns The result of the function.
14
+ */
15
+ export declare function withRetry<T>(fnToExecute: () => Promise<T>, { maxAttempts, backOffMs, }?: {
16
+ maxAttempts?: number;
17
+ backOffMs?: number;
18
+ }): Promise<T>;
19
+ /**
20
+ * Execute a promise with a timeout.
21
+ *
22
+ * @param promise - The promise to execute.
23
+ * @param timeoutMs - The timeout in milliseconds.
24
+ * @returns The result of the promise.
25
+ */
26
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs?: number): Promise<T>;
27
+ //# sourceMappingURL=utils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../src/providers/utils.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,WAAW,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC7B,EACE,WAAe,EACf,SAAe,GAChB,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnD,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,GAAE,MAAY,GACtB,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
@@ -0,0 +1,60 @@
1
+ /** Timeout error. */
2
+ export class TimeoutError extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = 'TimeoutError';
6
+ }
7
+ }
8
+ /**
9
+ * Execute a function with exponential backoff on transient failures.
10
+ *
11
+ * @param fnToExecute - The function to execute.
12
+ * @param options - The options for the retry.
13
+ * @param options.maxAttempts - The maximum number of attempts.
14
+ * @param options.backOffMs - The backoff in milliseconds.
15
+ * @throws An error if the transaction count cannot be retrieved.
16
+ * @returns The result of the function.
17
+ */
18
+ export async function withRetry(fnToExecute, { maxAttempts = 3, backOffMs = 500, } = {}) {
19
+ let lastError;
20
+ let backOff = backOffMs;
21
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
22
+ try {
23
+ return await fnToExecute();
24
+ }
25
+ catch (error) {
26
+ lastError = error;
27
+ if (attempt >= maxAttempts) {
28
+ break;
29
+ }
30
+ const delay = backOff;
31
+ await new Promise((resolve) => setTimeout(resolve, delay));
32
+ backOff *= 2;
33
+ }
34
+ }
35
+ throw lastError;
36
+ }
37
+ /**
38
+ * Execute a promise with a timeout.
39
+ *
40
+ * @param promise - The promise to execute.
41
+ * @param timeoutMs - The timeout in milliseconds.
42
+ * @returns The result of the promise.
43
+ */
44
+ export async function withTimeout(promise, timeoutMs = 500) {
45
+ let timer;
46
+ try {
47
+ return await Promise.race([
48
+ promise,
49
+ new Promise((_resolve, reject) => {
50
+ timer = setTimeout(() => reject(new TimeoutError('Timed out')), timeoutMs);
51
+ }),
52
+ ]);
53
+ }
54
+ finally {
55
+ if (timer) {
56
+ clearTimeout(timer);
57
+ }
58
+ }
59
+ }
60
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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CAAC;YACJ,CAAC,CAAC;SACH,CAAC,CAAC;KACJ;YAAS;QACR,IAAI,KAAK,EAAE;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;SACrB;KACF;AACH,CAAC","sourcesContent":["/** Timeout error. */\nexport class TimeoutError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Execute a function with exponential backoff on transient failures.\n *\n * @param fnToExecute - The function to execute.\n * @param options - The options for the retry.\n * @param options.maxAttempts - The maximum number of attempts.\n * @param options.backOffMs - The backoff in milliseconds.\n * @throws An error if the transaction count cannot be retrieved.\n * @returns The result of the function.\n */\nexport async function withRetry<T>(\n fnToExecute: () => Promise<T>,\n {\n maxAttempts = 3,\n backOffMs = 500,\n }: { maxAttempts?: number; backOffMs?: number } = {},\n): Promise<T> {\n let lastError;\n let backOff = backOffMs;\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fnToExecute();\n } catch (error) {\n lastError = error;\n if (attempt >= maxAttempts) {\n break;\n }\n const delay = backOff;\n await new Promise((resolve) => setTimeout(resolve, delay));\n backOff *= 2;\n }\n }\n throw lastError;\n}\n\n/**\n * Execute a promise with a timeout.\n *\n * @param promise - The promise to execute.\n * @param timeoutMs - The timeout in milliseconds.\n * @returns The result of the promise.\n */\nexport async function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number = 500,\n): Promise<T> {\n let timer;\n try {\n return await Promise.race<T>([\n promise,\n new Promise<T>((_resolve, reject) => {\n timer = setTimeout(\n () => reject(new TimeoutError('Timed out')),\n timeoutMs,\n );\n }),\n ]);\n } finally {\n if (timer) {\n clearTimeout(timer);\n }\n }\n}\n"]}
@@ -6,6 +6,7 @@ const account_api_1 = require("@metamask/account-api");
6
6
  function makeMockAccountProvider(accounts = []) {
7
7
  return {
8
8
  accounts,
9
+ constructor: jest.fn(),
9
10
  getAccount: jest.fn(),
10
11
  getAccounts: jest.fn(),
11
12
  createAccounts: jest.fn(),
@@ -1 +1 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CAAC;AACf,CAAC;AA9BD,8DA8BC","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\n\nimport type { Bip44Account } from '@metamask/account-api';\nimport { isBip44Account } from '@metamask/account-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\n\nexport type MockAccountProvider = {\n accounts: KeyringAccount[];\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible?: jest.Mock;\n getName: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n accounts,\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n getName: jest.fn(),\n };\n}\n\nexport function setupNamedAccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n filter = () => true,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.accounts = accounts;\n\n const getAccounts = () =>\n mocks.accounts.filter(\n (account) => isBip44Account(account) && filter(account),\n );\n\n mocks.getName.mockImplementation(() => name);\n\n mocks.getAccounts.mockImplementation(getAccounts);\n mocks.getAccount.mockImplementation(\n (id: Bip44Account<KeyringAccount>['id']) =>\n // Assuming this never fails.\n getAccounts().find((account) => account.id === id),\n );\n\n return mocks;\n}\n"]}
1
+ {"version":3,"file":"providers.cjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";AAAA,wCAAwC;;;AAGxC,uDAAuD;AAcvD,SAAgB,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,QAAQ;QACR,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC;AAbD,0DAaC;AAED,SAAgB,yBAAyB,CAAC,EACxC,IAAI,GAAG,iBAAiB,EACxB,QAAQ,EACR,KAAK,GAAG,uBAAuB,EAAE,EACjC,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,GAMpB;IACC,8DAA8D;IAC9D,eAAe;IACf,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAE1B,MAAM,WAAW,GAAG,GAAG,EAAE,CACvB,KAAK,CAAC,QAAQ,CAAC,MAAM,CACnB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,4BAAc,EAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CACxD,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAE7C,KAAK,CAAC,WAAW,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAClD,KAAK,CAAC,UAAU,CAAC,kBAAkB,CACjC,CAAC,EAAsC,EAAE,EAAE;IACzC,6BAA6B;IAC7B,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CACrD,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC;AA9BD,8DA8BC","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\n\nimport type { Bip44Account } from '@metamask/account-api';\nimport { isBip44Account } from '@metamask/account-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\n\nexport type MockAccountProvider = {\n accounts: KeyringAccount[];\n constructor: jest.Mock;\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible?: jest.Mock;\n getName: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n accounts,\n constructor: jest.fn(),\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n getName: jest.fn(),\n };\n}\n\nexport function setupNamedAccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n filter = () => true,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.accounts = accounts;\n\n const getAccounts = () =>\n mocks.accounts.filter(\n (account) => isBip44Account(account) && filter(account),\n );\n\n mocks.getName.mockImplementation(() => name);\n\n mocks.getAccounts.mockImplementation(getAccounts);\n mocks.getAccount.mockImplementation(\n (id: Bip44Account<KeyringAccount>['id']) =>\n // Assuming this never fails.\n getAccounts().find((account) => account.id === id),\n );\n\n return mocks;\n}\n"]}
@@ -2,6 +2,7 @@
2
2
  import type { KeyringAccount } from "@metamask/keyring-api";
3
3
  export type MockAccountProvider = {
4
4
  accounts: KeyringAccount[];
5
+ constructor: jest.Mock;
5
6
  getAccount: jest.Mock;
6
7
  getAccounts: jest.Mock;
7
8
  createAccounts: jest.Mock;
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.cts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAE5D,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;IACtB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;I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AmB,GACpB,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC;CAC/C,GAAG,mBAAmB,CAoBtB"}
@@ -2,6 +2,7 @@
2
2
  import type { KeyringAccount } from "@metamask/keyring-api";
3
3
  export type MockAccountProvider = {
4
4
  accounts: KeyringAccount[];
5
+ constructor: jest.Mock;
5
6
  getAccount: jest.Mock;
6
7
  getAccounts: jest.Mock;
7
8
  createAccounts: jest.Mock;
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.mts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAE5D,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;IACtB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC;IAC1B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;CACpB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,QAAQ,GAAE,cAAc,EAAO,GAC9B,mBAAmB,CAUrB;AAED,wBAAgB,yBAAyB,CAAC,EACxC,IAAwB,EACxB,QAAQ,EACR,KAAiC,EACjC,MAAmB,GACpB,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC;CAC/C,GAAG,mBAAmB,CAoBtB"}
1
+ {"version":3,"file":"providers.d.mts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAE5D,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;IACtB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC;IAC1B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;CACpB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,QAAQ,GAAE,cAAc,EAAO,GAC9B,mBAAmB,CAWrB;AAED,wBAAgB,yBAAyB,CAAC,EACxC,IAAwB,EACxB,QAAQ,EACR,KAAiC,EACjC,MAAmB,GACpB,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC;CAC/C,GAAG,mBAAmB,CAoBtB"}
@@ -3,6 +3,7 @@ import { isBip44Account } from "@metamask/account-api";
3
3
  export function makeMockAccountProvider(accounts = []) {
4
4
  return {
5
5
  accounts,
6
+ constructor: jest.fn(),
6
7
  getAccount: jest.fn(),
7
8
  getAccounts: jest.fn(),
8
9
  createAccounts: jest.fn(),
@@ -1 +1 @@
1
- {"version":3,"file":"providers.mjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAGxC,OAAO,EAAE,c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} from '@metamask/account-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\n\nexport type MockAccountProvider = {\n accounts: KeyringAccount[];\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible?: jest.Mock;\n getName: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n accounts,\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n getName: jest.fn(),\n };\n}\n\nexport function setupNamedAccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n filter = () => true,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.accounts = accounts;\n\n const getAccounts = () =>\n mocks.accounts.filter(\n (account) => isBip44Account(account) && filter(account),\n );\n\n mocks.getName.mockImplementation(() => name);\n\n mocks.getAccounts.mockImplementation(getAccounts);\n mocks.getAccount.mockImplementation(\n (id: Bip44Account<KeyringAccount>['id']) =>\n // Assuming this never fails.\n getAccounts().find((account) => account.id === id),\n );\n\n return mocks;\n}\n"]}
1
+ {"version":3,"file":"providers.mjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAGxC,OAAO,EAAE,cAAc,EAAE,8BAA8B;AAcvD,MAAM,UAAU,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,QAAQ;QACR,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,EACxC,IAAI,GAAG,iBAAiB,EACxB,QAAQ,EACR,KAAK,GAAG,uBAAuB,EAAE,EACjC,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,GAMpB;IACC,8DAA8D;IAC9D,eAAe;IACf,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAE1B,MAAM,WAAW,GAAG,GAAG,EAAE,CACvB,KAAK,CAAC,QAAQ,CAAC,MAAM,CACnB,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CACxD,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAE7C,KAAK,CAAC,WAAW,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAClD,KAAK,CAAC,UAAU,CAAC,kBAAkB,CACjC,CAAC,EAAsC,EAAE,EAAE;IACzC,6BAA6B;IAC7B,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CACrD,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\n\nimport type { Bip44Account } from '@metamask/account-api';\nimport { isBip44Account } from '@metamask/account-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\n\nexport type MockAccountProvider = {\n accounts: KeyringAccount[];\n constructor: jest.Mock;\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible?: jest.Mock;\n getName: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n accounts,\n constructor: jest.fn(),\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n getName: jest.fn(),\n };\n}\n\nexport function setupNamedAccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n filter = () => true,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.accounts = accounts;\n\n const getAccounts = () =>\n mocks.accounts.filter(\n (account) => isBip44Account(account) && filter(account),\n );\n\n mocks.getName.mockImplementation(() => name);\n\n mocks.getAccounts.mockImplementation(getAccounts);\n mocks.getAccount.mockImplementation(\n (id: Bip44Account<KeyringAccount>['id']) =>\n // Assuming this never fails.\n getAccounts().find((account) => account.id === id),\n );\n\n return mocks;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/multichain-account-service",
3
- "version": "0.9.0-preview-463efec",
3
+ "version": "0.9.0-preview-591781b",
4
4
  "description": "Service to manage multichain accounts",
5
5
  "keywords": [
6
6
  "MetaMask",