@metamask/multichain-account-service 10.0.2 → 11.0.0

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 (78) hide show
  1. package/CHANGELOG.md +39 -2
  2. package/dist/MultichainAccountGroup.cjs +15 -0
  3. package/dist/MultichainAccountGroup.cjs.map +1 -1
  4. package/dist/MultichainAccountGroup.d.cts +10 -0
  5. package/dist/MultichainAccountGroup.d.cts.map +1 -1
  6. package/dist/MultichainAccountGroup.d.mts +10 -0
  7. package/dist/MultichainAccountGroup.d.mts.map +1 -1
  8. package/dist/MultichainAccountGroup.mjs +15 -0
  9. package/dist/MultichainAccountGroup.mjs.map +1 -1
  10. package/dist/MultichainAccountService-method-action-types.cjs.map +1 -1
  11. package/dist/MultichainAccountService-method-action-types.d.cts +10 -6
  12. package/dist/MultichainAccountService-method-action-types.d.cts.map +1 -1
  13. package/dist/MultichainAccountService-method-action-types.d.mts +10 -6
  14. package/dist/MultichainAccountService-method-action-types.d.mts.map +1 -1
  15. package/dist/MultichainAccountService-method-action-types.mjs.map +1 -1
  16. package/dist/MultichainAccountService.cjs +67 -8
  17. package/dist/MultichainAccountService.cjs.map +1 -1
  18. package/dist/MultichainAccountService.d.cts +31 -7
  19. package/dist/MultichainAccountService.d.cts.map +1 -1
  20. package/dist/MultichainAccountService.d.mts +31 -7
  21. package/dist/MultichainAccountService.d.mts.map +1 -1
  22. package/dist/MultichainAccountService.mjs +67 -8
  23. package/dist/MultichainAccountService.mjs.map +1 -1
  24. package/dist/MultichainAccountWallet.cjs +20 -0
  25. package/dist/MultichainAccountWallet.cjs.map +1 -1
  26. package/dist/MultichainAccountWallet.d.cts +10 -0
  27. package/dist/MultichainAccountWallet.d.cts.map +1 -1
  28. package/dist/MultichainAccountWallet.d.mts +10 -0
  29. package/dist/MultichainAccountWallet.d.mts.map +1 -1
  30. package/dist/MultichainAccountWallet.mjs +20 -0
  31. package/dist/MultichainAccountWallet.mjs.map +1 -1
  32. package/dist/providers/AccountProviderWrapper.cjs +43 -0
  33. package/dist/providers/AccountProviderWrapper.cjs.map +1 -1
  34. package/dist/providers/AccountProviderWrapper.d.cts +37 -0
  35. package/dist/providers/AccountProviderWrapper.d.cts.map +1 -1
  36. package/dist/providers/AccountProviderWrapper.d.mts +37 -0
  37. package/dist/providers/AccountProviderWrapper.d.mts.map +1 -1
  38. package/dist/providers/AccountProviderWrapper.mjs +43 -0
  39. package/dist/providers/AccountProviderWrapper.mjs.map +1 -1
  40. package/dist/providers/BaseBip44AccountProvider.cjs +3 -18
  41. package/dist/providers/BaseBip44AccountProvider.cjs.map +1 -1
  42. package/dist/providers/BaseBip44AccountProvider.d.cts +36 -16
  43. package/dist/providers/BaseBip44AccountProvider.d.cts.map +1 -1
  44. package/dist/providers/BaseBip44AccountProvider.d.mts +36 -16
  45. package/dist/providers/BaseBip44AccountProvider.d.mts.map +1 -1
  46. package/dist/providers/BaseBip44AccountProvider.mjs +3 -18
  47. package/dist/providers/BaseBip44AccountProvider.mjs.map +1 -1
  48. package/dist/providers/EvmAccountProvider.cjs +19 -0
  49. package/dist/providers/EvmAccountProvider.cjs.map +1 -1
  50. package/dist/providers/EvmAccountProvider.d.cts +12 -0
  51. package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
  52. package/dist/providers/EvmAccountProvider.d.mts +12 -0
  53. package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
  54. package/dist/providers/EvmAccountProvider.mjs +19 -0
  55. package/dist/providers/EvmAccountProvider.mjs.map +1 -1
  56. package/dist/providers/SnapAccountProvider.cjs +28 -11
  57. package/dist/providers/SnapAccountProvider.cjs.map +1 -1
  58. package/dist/providers/SnapAccountProvider.d.cts +16 -4
  59. package/dist/providers/SnapAccountProvider.d.cts.map +1 -1
  60. package/dist/providers/SnapAccountProvider.d.mts +16 -4
  61. package/dist/providers/SnapAccountProvider.d.mts.map +1 -1
  62. package/dist/providers/SnapAccountProvider.mjs +28 -11
  63. package/dist/providers/SnapAccountProvider.mjs.map +1 -1
  64. package/dist/tests/providers.cjs +4 -0
  65. package/dist/tests/providers.cjs.map +1 -1
  66. package/dist/tests/providers.d.cts +2 -0
  67. package/dist/tests/providers.d.cts.map +1 -1
  68. package/dist/tests/providers.d.mts +2 -0
  69. package/dist/tests/providers.d.mts.map +1 -1
  70. package/dist/tests/providers.mjs +4 -0
  71. package/dist/tests/providers.mjs.map +1 -1
  72. package/dist/utils.cjs.map +1 -1
  73. package/dist/utils.d.cts +14 -1
  74. package/dist/utils.d.cts.map +1 -1
  75. package/dist/utils.d.mts +14 -1
  76. package/dist/utils.d.mts.map +1 -1
  77. package/dist/utils.mjs.map +1 -1
  78. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"providers.mjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,8BAA8B;AAI/E,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,+BAAqB;AAsB1E,MAAM,UAAU,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,YAAY,EAAE;YACZ,MAAM,EAAE;gBACN,QAAQ,CAAC,MAAM;gBACf,QAAQ,CAAC,OAAO;gBAChB,QAAQ,CAAC,OAAO;gBAChB,QAAQ,CAAC,MAAM;gBACf,QAAQ,CAAC,GAAG;aACb;YACD,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;SAC7B;QACD,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;QACxB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,WAAW,EAAE,IAAI,CAAC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AC;QACH,CAAC;QACD,iEAAiE;QACjE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACrB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,IAAI,GAAG,CAAC,EACR,EAAE,GACc;IAChB,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { BtcScope, EthScope, SolScope, TrxScope } from '@metamask/keyring-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\nimport type { KeyringCapabilities } from '@metamask/keyring-api/v2';\n\nimport { AccountProviderWrapper, EvmAccountProvider } from '../providers';\nimport { GroupIndexRange } from '../utils';\n\nexport type MockAccountProvider = {\n mockAccounts: KeyringAccount[];\n accounts: Set<KeyringAccount['id']>;\n capabilities: KeyringCapabilities;\n constructor: jest.Mock;\n alignAccounts: jest.Mock;\n init: jest.Mock;\n resyncAccounts: 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 isEnabled: boolean;\n isDisabled: jest.Mock;\n setEnabled: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n mockAccounts: accounts,\n accounts: new Set(),\n capabilities: {\n scopes: [\n SolScope.Devnet,\n SolScope.Testnet,\n BtcScope.Testnet,\n TrxScope.Shasta,\n EthScope.Eoa,\n ],\n bip44: { deriveIndex: true },\n },\n constructor: jest.fn(),\n alignAccounts: jest.fn(),\n init: jest.fn(),\n resyncAccounts: 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 isDisabled: jest.fn(),\n setEnabled: jest.fn(),\n isEnabled: true,\n };\n}\n\nexport function setupBip44AccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n index,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n index?: number;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.mockAccounts = accounts;\n mocks.accounts = new Set(accounts.map((account) => account.id));\n // Toggle enabled state only\n mocks.setEnabled.mockImplementation((enabled: boolean) => {\n mocks.isEnabled = enabled;\n });\n mocks.isDisabled.mockImplementation(() => !mocks.isEnabled);\n\n const getAccounts = (): KeyringAccount[] =>\n mocks.mockAccounts.filter((account) =>\n [...mocks.accounts].includes(account.id),\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 mocks.createAccounts.mockResolvedValue([]);\n mocks.init.mockImplementation(\n (accountIds: Bip44Account<KeyringAccount>['id'][]) => {\n accountIds.forEach((id) => mocks.accounts.add(id));\n },\n );\n\n if (index === 0) {\n // Make the first provider to always be an `EvmAccountProvider`, since we\n // check for this pre-condition in some methods.\n Object.setPrototypeOf(mocks, EvmAccountProvider.prototype);\n }\n\n if (index !== 0) {\n Object.setPrototypeOf(mocks, AccountProviderWrapper.prototype);\n }\n\n return mocks;\n}\n\n/**\n * Helper to mock a single createAccounts call while updating the provider's\n * internal state so subsequent getAccount/getAccounts can resolve the accounts.\n *\n * @param provider - The mock provider whose createAccounts call to mock.\n * @param created - The accounts to be returned and persisted in the mock state.\n */\nexport function mockCreateAccountsOnce(\n provider: MockAccountProvider,\n created: KeyringAccount[],\n): void {\n provider.createAccounts.mockImplementationOnce(async () => {\n // Add newly created accounts to the provider's internal store\n for (const acc of created) {\n if (!provider.mockAccounts.some((a) => a.id === acc.id)) {\n provider.mockAccounts.push(acc);\n }\n }\n // Merge IDs into the visible list used by getAccounts/getAccount\n const ids = created.map((a) => a.id);\n for (const id of ids) {\n provider.accounts.add(id);\n }\n\n return created;\n });\n}\n\n/**\n * Helper to convert a group index range to an array of group indices, inclusive of the\n * start and end indices.\n *\n * @param range - The range.\n * @param range.from - The starting index of the range (inclusive).\n * @param range.to - The ending index of the range (inclusive).\n * @returns An array of group indices from `from` to `to`, inclusive.\n */\nexport function toGroupIndexRangeArray({\n from = 0,\n to,\n}: GroupIndexRange): number[] {\n return Array.from({ length: to - from + 1 }, (_, i) => from + i);\n}\n"]}
1
+ {"version":3,"file":"providers.mjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,8BAA8B;AAI/E,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,+BAAqB;AAwB1E,MAAM,UAAU,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,YAAY,EAAE;YACZ,MAAM,EAAE;gBACN,QAAQ,CAAC,MAAM;gBACf,QAAQ,CAAC,OAAO;gBAChB,QAAQ,CAAC,OAAO;gBAChB,QAAQ,CAAC,MAAM;gBACf,QAAQ,CAAC,GAAG;aACb;YACD,KAAK,EAAE,EAAE,WAAW,E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'@metamask/account-api';\nimport { BtcScope, EthScope, SolScope, TrxScope } from '@metamask/keyring-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\nimport type { KeyringCapabilities } from '@metamask/keyring-api/v2';\n\nimport { AccountProviderWrapper, EvmAccountProvider } from '../providers';\nimport { GroupIndexRange } from '../utils';\n\nexport type MockAccountProvider = {\n mockAccounts: KeyringAccount[];\n accounts: Set<KeyringAccount['id']>;\n capabilities: KeyringCapabilities;\n constructor: jest.Mock;\n alignAccounts: jest.Mock;\n init: jest.Mock;\n resyncAccounts: jest.Mock;\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n deleteAccount: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible: jest.Mock;\n isAligned: jest.Mock;\n getName: jest.Mock;\n isEnabled: boolean;\n isDisabled: jest.Mock;\n setEnabled: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n mockAccounts: accounts,\n accounts: new Set(),\n capabilities: {\n scopes: [\n SolScope.Devnet,\n SolScope.Testnet,\n BtcScope.Testnet,\n TrxScope.Shasta,\n EthScope.Eoa,\n ],\n bip44: { deriveIndex: true },\n },\n constructor: jest.fn(),\n alignAccounts: jest.fn(),\n init: jest.fn(),\n resyncAccounts: jest.fn(),\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n deleteAccount: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n isAligned: jest.fn().mockReturnValue(false),\n getName: jest.fn(),\n isDisabled: jest.fn(),\n setEnabled: jest.fn(),\n isEnabled: true,\n };\n}\n\nexport function setupBip44AccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n index,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n index?: number;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.mockAccounts = accounts;\n mocks.accounts = new Set(accounts.map((account) => account.id));\n // Toggle enabled state only\n mocks.setEnabled.mockImplementation((enabled: boolean) => {\n mocks.isEnabled = enabled;\n });\n mocks.isDisabled.mockImplementation(() => !mocks.isEnabled);\n\n const getAccounts = (): KeyringAccount[] =>\n mocks.mockAccounts.filter((account) =>\n [...mocks.accounts].includes(account.id),\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 mocks.createAccounts.mockResolvedValue([]);\n mocks.init.mockImplementation(\n (accountIds: Bip44Account<KeyringAccount>['id'][]) => {\n accountIds.forEach((id) => mocks.accounts.add(id));\n },\n );\n\n mocks.isAligned.mockImplementation(\n (\n _context: { entropySource: string; groupIndex: number },\n accountIds: string[],\n ) =>\n accountIds.length >= 1 &&\n accountIds.every((id) => mocks.accounts.has(id)),\n );\n\n if (index === 0) {\n // Make the first provider to always be an `EvmAccountProvider`, since we\n // check for this pre-condition in some methods.\n Object.setPrototypeOf(mocks, EvmAccountProvider.prototype);\n }\n\n if (index !== 0) {\n Object.setPrototypeOf(mocks, AccountProviderWrapper.prototype);\n }\n\n return mocks;\n}\n\n/**\n * Helper to mock a single createAccounts call while updating the provider's\n * internal state so subsequent getAccount/getAccounts can resolve the accounts.\n *\n * @param provider - The mock provider whose createAccounts call to mock.\n * @param created - The accounts to be returned and persisted in the mock state.\n */\nexport function mockCreateAccountsOnce(\n provider: MockAccountProvider,\n created: KeyringAccount[],\n): void {\n provider.createAccounts.mockImplementationOnce(async () => {\n // Add newly created accounts to the provider's internal store\n for (const acc of created) {\n if (!provider.mockAccounts.some((a) => a.id === acc.id)) {\n provider.mockAccounts.push(acc);\n }\n }\n // Merge IDs into the visible list used by getAccounts/getAccount\n const ids = created.map((a) => a.id);\n for (const id of ids) {\n provider.accounts.add(id);\n }\n\n return created;\n });\n}\n\n/**\n * Helper to convert a group index range to an array of group indices, inclusive of the\n * start and end indices.\n *\n * @param range - The range.\n * @param range.from - The starting index of the range (inclusive).\n * @param range.to - The ending index of the range (inclusive).\n * @returns An array of group indices from `from` to `to`, inclusive.\n */\nexport function toGroupIndexRangeArray({\n from = 0,\n to,\n}: GroupIndexRange): number[] {\n return Array.from({ length: to - from + 1 }, (_, i) => from + i);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAQA;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAAC,EAC3C,IAAI,GAAG,CAAC,EACR,EAAE,GACc;IAChB,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,gBAAgB,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,sBAAsB,IAAI,GAAG,CAAC,CAAC;IACrE,CAAC;AACH,CAAC;AAfD,oEAeC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,UAAkB,EAClB,cAAsB;IAEtB,IAAI,UAAU,GAAG,cAAc,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,gCAAgC,UAAU,sDAAsD,cAAc,GAAG,CAClH,CAAC;IACJ,CAAC;AACH,CAAC;AATD,0DASC;AAED;;;;;;;;;;GAUG;AACI,MAAM,iBAAiB,GAAG,CAC/B,OAAe,EACf,UAAiB,EACjB,OAAiC,EAC1B,EAAE;IACT,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAG9B,CAAC;IACF,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC;IACzB,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IAC1B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAdW,QAAA,iBAAiB,qBAc5B;AAEF;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAFD,wCAEC","sourcesContent":["/**\n * Range-based multichain account creations type.\n */\nexport type GroupIndexRange = {\n from?: number;\n to: number;\n};\n\n/**\n * Asserts that a range is valid.\n *\n * @param range - The range to assert.\n * @param range.from - The starting index of the range (inclusive).\n * @param range.to - The ending index of the range (inclusive).\n */\nexport function assertGroupIndexRangeIsValid({\n from = 0,\n to,\n}: GroupIndexRange): void {\n if (from < 0) {\n throw new Error(`Bad range, from (${from}) must be >= 0`);\n }\n\n if (to < 0) {\n throw new Error(`Bad range, to (${to}) must be >= 0`);\n }\n\n if (to < from) {\n throw new Error(`Bad range, to (${to}) must be >= from (${from})`);\n }\n}\n\n/**\n * Asserts that a group index is valid given the next available group index.\n *\n * @param groupIndex - The group index to assert.\n * @param nextGroupIndex - The next available group index.\n */\nexport function assertGroupIndexIsValid(\n groupIndex: number,\n nextGroupIndex: number,\n): void {\n if (groupIndex > nextGroupIndex) {\n throw new Error(\n `Bad group index, groupIndex (${groupIndex}) cannot be higher than the next available one (<= ${nextGroupIndex})`,\n );\n }\n}\n\n/**\n * Creates a Sentry error from an error message, an inner error and a context.\n *\n * NOTE: Sentry defaults to a depth of 3 when extracting non-native attributes.\n * As such, the context depth shouldn't be too deep.\n *\n * @param message - The error message to create a Sentry error from.\n * @param innerError - The inner error to create a Sentry error from.\n * @param context - The context to add to the Sentry error.\n * @returns A Sentry error.\n */\nexport const createSentryError = (\n message: string,\n innerError: Error,\n context?: Record<string, unknown>,\n): Error => {\n const error = new Error(message) as Error & {\n cause: Error;\n context: typeof context;\n };\n error.cause = innerError;\n if (context) {\n error.context = context;\n }\n return error;\n};\n\n/**\n * Converts an unknown error value to a string message.\n *\n * @param error - The error to convert.\n * @returns The error message if the error is an `Error` instance, otherwise\n * the string representation of the value.\n */\nexport function toErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"]}
1
+ {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAQA;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAAC,EAC3C,IAAI,GAAG,CAAC,EACR,EAAE,GACc;IAChB,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,gBAAgB,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,sBAAsB,IAAI,GAAG,CAAC,CAAC;IACrE,CAAC;AACH,CAAC;AAfD,oEAeC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,UAAkB,EAClB,cAAsB;IAEtB,IAAI,UAAU,GAAG,cAAc,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,gCAAgC,UAAU,sDAAsD,cAAc,GAAG,CAClH,CAAC;IACJ,CAAC;AACH,CAAC;AATD,0DASC;AAkBD;;;;;;;;;;GAUG;AACI,MAAM,iBAAiB,GAAG,CAG/B,OAAe,EACf,UAAiB,EACjB,OAAkB,EACK,EAAE;IACzB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAA0B,CAAC;IAC1D,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC;IACzB,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IAC1B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAbW,QAAA,iBAAiB,qBAa5B;AAEF;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAFD,wCAEC","sourcesContent":["/**\n * Range-based multichain account creations type.\n */\nexport type GroupIndexRange = {\n from?: number;\n to: number;\n};\n\n/**\n * Asserts that a range is valid.\n *\n * @param range - The range to assert.\n * @param range.from - The starting index of the range (inclusive).\n * @param range.to - The ending index of the range (inclusive).\n */\nexport function assertGroupIndexRangeIsValid({\n from = 0,\n to,\n}: GroupIndexRange): void {\n if (from < 0) {\n throw new Error(`Bad range, from (${from}) must be >= 0`);\n }\n\n if (to < 0) {\n throw new Error(`Bad range, to (${to}) must be >= 0`);\n }\n\n if (to < from) {\n throw new Error(`Bad range, to (${to}) must be >= from (${from})`);\n }\n}\n\n/**\n * Asserts that a group index is valid given the next available group index.\n *\n * @param groupIndex - The group index to assert.\n * @param nextGroupIndex - The next available group index.\n */\nexport function assertGroupIndexIsValid(\n groupIndex: number,\n nextGroupIndex: number,\n): void {\n if (groupIndex > nextGroupIndex) {\n throw new Error(\n `Bad group index, groupIndex (${groupIndex}) cannot be higher than the next available one (<= ${nextGroupIndex})`,\n );\n }\n}\n\n/**\n * Augmented `Error` shape produced by {@link createSentryError}. The runtime\n * value carries a `cause` and (optionally) a structured `context` payload\n * that downstream Sentry tooling can read.\n *\n * The `TContext` type parameter narrows the shape of `context` for callers\n * that know what they put in — most useful in tests when asserting on a\n * captured error.\n */\nexport type SentryError<\n TContext extends Record<string, unknown> = Record<string, unknown>,\n> = Error & {\n cause: Error;\n context?: TContext;\n};\n\n/**\n * Creates a Sentry error from an error message, an inner error and a context.\n *\n * NOTE: Sentry defaults to a depth of 3 when extracting non-native attributes.\n * As such, the context depth shouldn't be too deep.\n *\n * @param message - The error message to create a Sentry error from.\n * @param innerError - The inner error to create a Sentry error from.\n * @param context - The context to add to the Sentry error.\n * @returns A Sentry error.\n */\nexport const createSentryError = <\n TContext extends Record<string, unknown> = Record<string, unknown>,\n>(\n message: string,\n innerError: Error,\n context?: TContext,\n): SentryError<TContext> => {\n const error = new Error(message) as SentryError<TContext>;\n error.cause = innerError;\n if (context) {\n error.context = context;\n }\n return error;\n};\n\n/**\n * Converts an unknown error value to a string message.\n *\n * @param error - The error to convert.\n * @returns The error message if the error is an `Error` instance, otherwise\n * the string representation of the value.\n */\nexport function toErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"]}
package/dist/utils.d.cts CHANGED
@@ -20,6 +20,19 @@ export declare function assertGroupIndexRangeIsValid({ from, to, }: GroupIndexRa
20
20
  * @param nextGroupIndex - The next available group index.
21
21
  */
22
22
  export declare function assertGroupIndexIsValid(groupIndex: number, nextGroupIndex: number): void;
23
+ /**
24
+ * Augmented `Error` shape produced by {@link createSentryError}. The runtime
25
+ * value carries a `cause` and (optionally) a structured `context` payload
26
+ * that downstream Sentry tooling can read.
27
+ *
28
+ * The `TContext` type parameter narrows the shape of `context` for callers
29
+ * that know what they put in — most useful in tests when asserting on a
30
+ * captured error.
31
+ */
32
+ export type SentryError<TContext extends Record<string, unknown> = Record<string, unknown>> = Error & {
33
+ cause: Error;
34
+ context?: TContext;
35
+ };
23
36
  /**
24
37
  * Creates a Sentry error from an error message, an inner error and a context.
25
38
  *
@@ -31,7 +44,7 @@ export declare function assertGroupIndexIsValid(groupIndex: number, nextGroupInd
31
44
  * @param context - The context to add to the Sentry error.
32
45
  * @returns A Sentry error.
33
46
  */
34
- export declare const createSentryError: (message: string, innerError: Error, context?: Record<string, unknown>) => Error;
47
+ export declare const createSentryError: <TContext extends Record<string, unknown> = Record<string, unknown>>(message: string, innerError: Error, context?: TContext | undefined) => SentryError<TContext>;
35
48
  /**
36
49
  * Converts an unknown error value to a string message.
37
50
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,IAAQ,EACR,EAAE,GACH,EAAE,eAAe,GAAG,IAAI,CAYxB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACrB,IAAI,CAMN;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,YACnB,MAAM,cACH,KAAK,YACP,OAAO,MAAM,EAAE,OAAO,CAAC,KAChC,KAUF,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAErD"}
1
+ {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,IAAQ,EACR,EAAE,GACH,EAAE,eAAe,GAAG,IAAI,CAYxB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACrB,IAAI,CAMN;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,CACrB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAChE,KAAK,GAAG;IACV,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,gFAGnB,MAAM,cACH,KAAK,0DASlB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAErD"}
package/dist/utils.d.mts CHANGED
@@ -20,6 +20,19 @@ export declare function assertGroupIndexRangeIsValid({ from, to, }: GroupIndexRa
20
20
  * @param nextGroupIndex - The next available group index.
21
21
  */
22
22
  export declare function assertGroupIndexIsValid(groupIndex: number, nextGroupIndex: number): void;
23
+ /**
24
+ * Augmented `Error` shape produced by {@link createSentryError}. The runtime
25
+ * value carries a `cause` and (optionally) a structured `context` payload
26
+ * that downstream Sentry tooling can read.
27
+ *
28
+ * The `TContext` type parameter narrows the shape of `context` for callers
29
+ * that know what they put in — most useful in tests when asserting on a
30
+ * captured error.
31
+ */
32
+ export type SentryError<TContext extends Record<string, unknown> = Record<string, unknown>> = Error & {
33
+ cause: Error;
34
+ context?: TContext;
35
+ };
23
36
  /**
24
37
  * Creates a Sentry error from an error message, an inner error and a context.
25
38
  *
@@ -31,7 +44,7 @@ export declare function assertGroupIndexIsValid(groupIndex: number, nextGroupInd
31
44
  * @param context - The context to add to the Sentry error.
32
45
  * @returns A Sentry error.
33
46
  */
34
- export declare const createSentryError: (message: string, innerError: Error, context?: Record<string, unknown>) => Error;
47
+ export declare const createSentryError: <TContext extends Record<string, unknown> = Record<string, unknown>>(message: string, innerError: Error, context?: TContext | undefined) => SentryError<TContext>;
35
48
  /**
36
49
  * Converts an unknown error value to a string message.
37
50
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B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CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC","sourcesContent":["/**\n * Range-based multichain account creations type.\n */\nexport type GroupIndexRange = {\n from?: number;\n to: number;\n};\n\n/**\n * Asserts that a range is valid.\n *\n * @param range - The range to assert.\n * @param range.from - The starting index of the range (inclusive).\n * @param range.to - The ending index of the range (inclusive).\n */\nexport function assertGroupIndexRangeIsValid({\n from = 0,\n to,\n}: GroupIndexRange): void {\n if (from < 0) {\n throw new Error(`Bad range, from (${from}) must be >= 0`);\n }\n\n if (to < 0) {\n throw new Error(`Bad range, to (${to}) must be >= 0`);\n }\n\n if (to < from) {\n throw new Error(`Bad range, to (${to}) must be >= from (${from})`);\n }\n}\n\n/**\n * Asserts that a group index is valid given the next available group index.\n *\n * @param groupIndex - The group index to assert.\n * @param nextGroupIndex - The next available group index.\n */\nexport function assertGroupIndexIsValid(\n groupIndex: number,\n nextGroupIndex: number,\n): void {\n if (groupIndex > nextGroupIndex) {\n throw new Error(\n `Bad group index, groupIndex (${groupIndex}) cannot be higher than the next available one (<= ${nextGroupIndex})`,\n );\n }\n}\n\n/**\n * Creates a Sentry error from an error message, an inner error and a context.\n *\n * NOTE: Sentry defaults to a depth of 3 when extracting non-native attributes.\n * As such, the context depth shouldn't be too deep.\n *\n * @param message - The error message to create a Sentry error from.\n * @param innerError - The inner error to create a Sentry error from.\n * @param context - The context to add to the Sentry error.\n * @returns A Sentry error.\n */\nexport const createSentryError = (\n message: string,\n innerError: Error,\n context?: Record<string, unknown>,\n): Error => {\n const error = new Error(message) as Error & {\n cause: Error;\n context: typeof context;\n };\n error.cause = innerError;\n if (context) {\n error.context = context;\n }\n return error;\n};\n\n/**\n * Converts an unknown error value to a string message.\n *\n * @param error - The error to convert.\n * @returns The error message if the error is an `Error` instance, otherwise\n * the string representation of the value.\n */\nexport function toErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"]}
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KAAK,CAAC,CAAC;AAChE,CAAC","sourcesContent":["/**\n * Range-based multichain account creations type.\n */\nexport type GroupIndexRange = {\n from?: number;\n to: number;\n};\n\n/**\n * Asserts that a range is valid.\n *\n * @param range - The range to assert.\n * @param range.from - The starting index of the range (inclusive).\n * @param range.to - The ending index of the range (inclusive).\n */\nexport function assertGroupIndexRangeIsValid({\n from = 0,\n to,\n}: GroupIndexRange): void {\n if (from < 0) {\n throw new Error(`Bad range, from (${from}) must be >= 0`);\n }\n\n if (to < 0) {\n throw new Error(`Bad range, to (${to}) must be >= 0`);\n }\n\n if (to < from) {\n throw new Error(`Bad range, to (${to}) must be >= from (${from})`);\n }\n}\n\n/**\n * Asserts that a group index is valid given the next available group index.\n *\n * @param groupIndex - The group index to assert.\n * @param nextGroupIndex - The next available group index.\n */\nexport function assertGroupIndexIsValid(\n groupIndex: number,\n nextGroupIndex: number,\n): void {\n if (groupIndex > nextGroupIndex) {\n throw new Error(\n `Bad group index, groupIndex (${groupIndex}) cannot be higher than the next available one (<= ${nextGroupIndex})`,\n );\n }\n}\n\n/**\n * Augmented `Error` shape produced by {@link createSentryError}. The runtime\n * value carries a `cause` and (optionally) a structured `context` payload\n * that downstream Sentry tooling can read.\n *\n * The `TContext` type parameter narrows the shape of `context` for callers\n * that know what they put in — most useful in tests when asserting on a\n * captured error.\n */\nexport type SentryError<\n TContext extends Record<string, unknown> = Record<string, unknown>,\n> = Error & {\n cause: Error;\n context?: TContext;\n};\n\n/**\n * Creates a Sentry error from an error message, an inner error and a context.\n *\n * NOTE: Sentry defaults to a depth of 3 when extracting non-native attributes.\n * As such, the context depth shouldn't be too deep.\n *\n * @param message - The error message to create a Sentry error from.\n * @param innerError - The inner error to create a Sentry error from.\n * @param context - The context to add to the Sentry error.\n * @returns A Sentry error.\n */\nexport const createSentryError = <\n TContext extends Record<string, unknown> = Record<string, unknown>,\n>(\n message: string,\n innerError: Error,\n context?: TContext,\n): SentryError<TContext> => {\n const error = new Error(message) as SentryError<TContext>;\n error.cause = innerError;\n if (context) {\n error.context = context;\n }\n return error;\n};\n\n/**\n * Converts an unknown error value to a string message.\n *\n * @param error - The error to convert.\n * @returns The error message if the error is an `Error` instance, otherwise\n * the string representation of the value.\n */\nexport function toErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/multichain-account-service",
3
- "version": "10.0.2",
3
+ "version": "11.0.0",
4
4
  "description": "Service to manage multichain accounts",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -54,29 +54,29 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@ethereumjs/util": "^9.1.0",
57
- "@metamask/accounts-controller": "^39.0.0",
57
+ "@metamask/accounts-controller": "^39.0.3",
58
58
  "@metamask/base-controller": "^9.1.0",
59
- "@metamask/eth-snap-keyring": "^22.0.1",
59
+ "@metamask/eth-snap-keyring": "^22.3.0",
60
60
  "@metamask/key-tree": "^10.1.1",
61
61
  "@metamask/keyring-api": "^23.1.0",
62
- "@metamask/keyring-controller": "^26.0.0",
62
+ "@metamask/keyring-controller": "^27.1.0",
63
63
  "@metamask/keyring-internal-api": "^11.0.1",
64
64
  "@metamask/keyring-snap-client": "^9.0.2",
65
65
  "@metamask/keyring-utils": "^3.2.1",
66
66
  "@metamask/messenger": "^1.2.0",
67
- "@metamask/snap-account-service": "^0.3.0",
67
+ "@metamask/snap-account-service": "^1.0.0",
68
68
  "@metamask/snaps-controllers": "^19.0.0",
69
69
  "@metamask/snaps-sdk": "^11.0.0",
70
70
  "@metamask/snaps-utils": "^12.1.2",
71
71
  "@metamask/superstruct": "^3.1.0",
72
- "@metamask/utils": "^11.9.0",
72
+ "@metamask/utils": "^11.11.0",
73
73
  "async-mutex": "^0.5.0",
74
74
  "lodash": "^4.17.21"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@metamask/account-api": "^1.0.4",
78
78
  "@metamask/auto-changelog": "^6.1.0",
79
- "@metamask/controller-utils": "^12.1.0",
79
+ "@metamask/controller-utils": "^12.3.0",
80
80
  "@metamask/eth-hd-keyring": "^14.1.1",
81
81
  "@metamask/providers": "^22.1.0",
82
82
  "@ts-bridge/cli": "^0.6.4",