@metamask-previews/multichain-account-service 2.1.0-preview-037e3643 → 2.1.0-preview-1a8571ae

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 (122) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/MultichainAccountGroup.cjs.map +1 -1
  3. package/dist/MultichainAccountGroup.d.cts +2 -2
  4. package/dist/MultichainAccountGroup.d.mts +2 -2
  5. package/dist/MultichainAccountGroup.mjs.map +1 -1
  6. package/dist/MultichainAccountService.cjs +49 -5
  7. package/dist/MultichainAccountService.cjs.map +1 -1
  8. package/dist/MultichainAccountService.d.cts +23 -6
  9. package/dist/MultichainAccountService.d.cts.map +1 -1
  10. package/dist/MultichainAccountService.d.mts +23 -6
  11. package/dist/MultichainAccountService.d.mts.map +1 -1
  12. package/dist/MultichainAccountService.mjs +49 -5
  13. package/dist/MultichainAccountService.mjs.map +1 -1
  14. package/dist/MultichainAccountWallet.cjs.map +1 -1
  15. package/dist/MultichainAccountWallet.d.cts +2 -2
  16. package/dist/MultichainAccountWallet.d.mts +2 -2
  17. package/dist/MultichainAccountWallet.mjs.map +1 -1
  18. package/dist/analytics/index.cjs +18 -0
  19. package/dist/analytics/index.cjs.map +1 -0
  20. package/dist/analytics/index.d.cts +2 -0
  21. package/dist/analytics/index.d.cts.map +1 -0
  22. package/dist/analytics/index.d.mts +2 -0
  23. package/dist/analytics/index.d.mts.map +1 -0
  24. package/dist/analytics/index.mjs +2 -0
  25. package/dist/analytics/index.mjs.map +1 -0
  26. package/dist/analytics/traces.cjs +21 -0
  27. package/dist/analytics/traces.cjs.map +1 -0
  28. package/dist/analytics/traces.d.cts +13 -0
  29. package/dist/analytics/traces.d.cts.map +1 -0
  30. package/dist/analytics/traces.d.mts +13 -0
  31. package/dist/analytics/traces.d.mts.map +1 -0
  32. package/dist/analytics/traces.mjs +17 -0
  33. package/dist/analytics/traces.mjs.map +1 -0
  34. package/dist/constants/traces.cjs +9 -0
  35. package/dist/constants/traces.cjs.map +1 -0
  36. package/dist/constants/traces.d.cts +5 -0
  37. package/dist/constants/traces.d.cts.map +1 -0
  38. package/dist/constants/traces.d.mts +5 -0
  39. package/dist/constants/traces.d.mts.map +1 -0
  40. package/dist/constants/traces.mjs +6 -0
  41. package/dist/constants/traces.mjs.map +1 -0
  42. package/dist/providers/AccountProviderWrapper.cjs +11 -0
  43. package/dist/providers/AccountProviderWrapper.cjs.map +1 -1
  44. package/dist/providers/AccountProviderWrapper.d.cts +7 -0
  45. package/dist/providers/AccountProviderWrapper.d.cts.map +1 -1
  46. package/dist/providers/AccountProviderWrapper.d.mts +7 -0
  47. package/dist/providers/AccountProviderWrapper.d.mts.map +1 -1
  48. package/dist/providers/AccountProviderWrapper.mjs +11 -0
  49. package/dist/providers/AccountProviderWrapper.mjs.map +1 -1
  50. package/dist/providers/BaseBip44AccountProvider.cjs.map +1 -1
  51. package/dist/providers/BaseBip44AccountProvider.d.cts +13 -3
  52. package/dist/providers/BaseBip44AccountProvider.d.cts.map +1 -1
  53. package/dist/providers/BaseBip44AccountProvider.d.mts +13 -3
  54. package/dist/providers/BaseBip44AccountProvider.d.mts.map +1 -1
  55. package/dist/providers/BaseBip44AccountProvider.mjs.map +1 -1
  56. package/dist/providers/BtcAccountProvider.cjs +23 -43
  57. package/dist/providers/BtcAccountProvider.cjs.map +1 -1
  58. package/dist/providers/BtcAccountProvider.d.cts +3 -21
  59. package/dist/providers/BtcAccountProvider.d.cts.map +1 -1
  60. package/dist/providers/BtcAccountProvider.d.mts +3 -21
  61. package/dist/providers/BtcAccountProvider.d.mts.map +1 -1
  62. package/dist/providers/BtcAccountProvider.mjs +23 -43
  63. package/dist/providers/BtcAccountProvider.mjs.map +1 -1
  64. package/dist/providers/EvmAccountProvider.cjs +37 -22
  65. package/dist/providers/EvmAccountProvider.cjs.map +1 -1
  66. package/dist/providers/EvmAccountProvider.d.cts +3 -1
  67. package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
  68. package/dist/providers/EvmAccountProvider.d.mts +3 -1
  69. package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
  70. package/dist/providers/EvmAccountProvider.mjs +37 -22
  71. package/dist/providers/EvmAccountProvider.mjs.map +1 -1
  72. package/dist/providers/SnapAccountProvider.cjs +80 -9
  73. package/dist/providers/SnapAccountProvider.cjs.map +1 -1
  74. package/dist/providers/SnapAccountProvider.d.cts +6 -1
  75. package/dist/providers/SnapAccountProvider.d.cts.map +1 -1
  76. package/dist/providers/SnapAccountProvider.d.mts +6 -1
  77. package/dist/providers/SnapAccountProvider.d.mts.map +1 -1
  78. package/dist/providers/SnapAccountProvider.mjs +80 -9
  79. package/dist/providers/SnapAccountProvider.mjs.map +1 -1
  80. package/dist/providers/SolAccountProvider.cjs +25 -38
  81. package/dist/providers/SolAccountProvider.cjs.map +1 -1
  82. package/dist/providers/SolAccountProvider.d.cts +2 -1
  83. package/dist/providers/SolAccountProvider.d.cts.map +1 -1
  84. package/dist/providers/SolAccountProvider.d.mts +2 -1
  85. package/dist/providers/SolAccountProvider.d.mts.map +1 -1
  86. package/dist/providers/SolAccountProvider.mjs +25 -38
  87. package/dist/providers/SolAccountProvider.mjs.map +1 -1
  88. package/dist/providers/TrxAccountProvider.cjs +22 -43
  89. package/dist/providers/TrxAccountProvider.cjs.map +1 -1
  90. package/dist/providers/TrxAccountProvider.d.cts +2 -2
  91. package/dist/providers/TrxAccountProvider.d.cts.map +1 -1
  92. package/dist/providers/TrxAccountProvider.d.mts +2 -2
  93. package/dist/providers/TrxAccountProvider.d.mts.map +1 -1
  94. package/dist/providers/TrxAccountProvider.mjs +22 -43
  95. package/dist/providers/TrxAccountProvider.mjs.map +1 -1
  96. package/dist/providers/utils.cjs.map +1 -1
  97. package/dist/providers/utils.mjs.map +1 -1
  98. package/dist/tests/accounts.cjs +28 -1
  99. package/dist/tests/accounts.cjs.map +1 -1
  100. package/dist/tests/accounts.d.cts +11 -7
  101. package/dist/tests/accounts.d.cts.map +1 -1
  102. package/dist/tests/accounts.d.mts +11 -7
  103. package/dist/tests/accounts.d.mts.map +1 -1
  104. package/dist/tests/accounts.mjs +25 -0
  105. package/dist/tests/accounts.mjs.map +1 -1
  106. package/dist/tests/providers.cjs +1 -0
  107. package/dist/tests/providers.cjs.map +1 -1
  108. package/dist/tests/providers.d.cts +1 -0
  109. package/dist/tests/providers.d.cts.map +1 -1
  110. package/dist/tests/providers.d.mts +1 -0
  111. package/dist/tests/providers.d.mts.map +1 -1
  112. package/dist/tests/providers.mjs +1 -0
  113. package/dist/tests/providers.mjs.map +1 -1
  114. package/dist/types.cjs.map +1 -1
  115. package/dist/types.d.cts +9 -1
  116. package/dist/types.d.cts.map +1 -1
  117. package/dist/types.d.mts +9 -1
  118. package/dist/types.d.mts.map +1 -1
  119. package/dist/types.mjs.map +1 -1
  120. package/dist/utils.cjs.map +1 -1
  121. package/dist/utils.mjs.map +1 -1
  122. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"SnapAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/SnapAccountProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,SAAS,EAAE,oBAAoB;AAExC,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AAmBtE,MAAM,OAAgB,mBAAoB,SAAQ,wBAAwB;IAOxE,YACE,MAAc,EACd,SAA4C,EAC5C,MAAiC;QAEjC,KAAK,CAAC,SAAS,CAAC,CAAC;QAPV,6CAAmB;QAS1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,QAAQ,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,MAAM;YACT,cAAc;SACf,CAAC;QAEF,kDAAkD;QAClD,IAAI,QAAQ,CAAC,cAAc,CAAC,EAAE;YAC5B,uBAAA,IAAI,8BAAU,IAAI,SAAS,CAAC,cAAc,CAAC,MAAA,CAAC;SAC7C;IACH,CAAC;IAED;;;;;;;OAOG;IACO,KAAK,CAAC,kBAAkB,CAChC,SAA2B;QAE3B,IAAI,uBAAA,IAAI,kCAAO,EAAE;YACf,OAAO,uBAAA,IAAI,kCAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;SAC5C;QACD,OAAO,SAAS,EAAE,CAAC;IACrB,CAAC;IAES,KAAK,CAAC,+BAA+B;QAC7C,iFAAiF;QACjF,gFAAgF;QAChF,sCAAsC;QACtC,+EAA+E;QAC/E,iFAAiF;QACjF,wDAAwD;QACxD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,WAAW,CAG1C,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CACnD,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CACpC,CAAC;QAEF,OAAO,CAAC,OAAO,EAAE,EAAE,CACjB,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE;YAClC,4BAA4B,EAAE,KAAK;YACnC,mBAAmB,EAAE,KAAK;YAC1B,kBAAkB,EAAE,KAAK;SAC1B,CAAC,CAAC;IACP,CAAC;CAaF;;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAAiB,EACgB,EAAE;IACnC,OAAO,QAAQ,YAAY,mBAAmB,CAAC;AACjD,CAAC,CAAC","sourcesContent":["import { type Bip44Account } from '@metamask/account-api';\nimport type { SnapKeyring } from '@metamask/eth-snap-keyring';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { Json, SnapId } from '@metamask/snaps-sdk';\nimport { Semaphore } from 'async-mutex';\n\nimport { BaseBip44AccountProvider } from './BaseBip44AccountProvider';\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type RestrictedSnapKeyringCreateAccount = (\n options: Record<string, Json>,\n) => Promise<KeyringAccount>;\n\nexport type SnapAccountProviderConfig = {\n maxConcurrency?: number;\n discovery: {\n maxAttempts: number;\n timeoutMs: number;\n backOffMs: number;\n };\n createAccounts: {\n timeoutMs: number;\n };\n};\n\nexport abstract class SnapAccountProvider extends BaseBip44AccountProvider {\n readonly snapId: SnapId;\n\n protected readonly config: SnapAccountProviderConfig;\n\n readonly #queue?: Semaphore;\n\n constructor(\n snapId: SnapId,\n messenger: MultichainAccountServiceMessenger,\n config: SnapAccountProviderConfig,\n ) {\n super(messenger);\n\n this.snapId = snapId;\n\n const maxConcurrency = config.maxConcurrency ?? Infinity;\n this.config = {\n ...config,\n maxConcurrency,\n };\n\n // Create semaphore only if concurrency is limited\n if (isFinite(maxConcurrency)) {\n this.#queue = new Semaphore(maxConcurrency);\n }\n }\n\n /**\n * Wraps an async operation with concurrency limiting based on maxConcurrency config.\n * If maxConcurrency is Infinity (the default), the operation runs immediately without throttling.\n * Otherwise, it's queued through the semaphore to respect the concurrency limit.\n *\n * @param operation - The async operation to execute.\n * @returns The result of the operation.\n */\n protected async withMaxConcurrency<T>(\n operation: () => Promise<T>,\n ): Promise<T> {\n if (this.#queue) {\n return this.#queue.runExclusive(operation);\n }\n return operation();\n }\n\n protected async getRestrictedSnapAccountCreator(): Promise<RestrictedSnapKeyringCreateAccount> {\n // NOTE: We're not supposed to make the keyring instance escape `withKeyring` but\n // we have to use the `SnapKeyring` instance to be able to create Solana account\n // without triggering UI confirmation.\n // Also, creating account that way won't invalidate the Snap keyring state. The\n // account will get created and persisted properly with the Snap account creation\n // flow \"asynchronously\" (with `notify:accountCreated`).\n const createAccount = await this.withKeyring<\n SnapKeyring,\n SnapKeyring['createAccount']\n >({ type: KeyringTypes.snap }, async ({ keyring }) =>\n keyring.createAccount.bind(keyring),\n );\n\n return (options) =>\n createAccount(this.snapId, options, {\n displayAccountNameSuggestion: false,\n displayConfirmation: false,\n setSelectedAccount: false,\n });\n }\n\n abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;\n\n abstract createAccounts(options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]>;\n\n abstract discoverAccounts(options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]>;\n}\n\nexport const isSnapAccountProvider = (\n provider: unknown,\n): provider is SnapAccountProvider => {\n return provider instanceof SnapAccountProvider;\n};\n"]}
1
+ {"version":3,"file":"SnapAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/SnapAccountProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAE5D,OAAO,EAAE,aAAa,EAAE,sCAAsC;AAE9D,OAAO,EAAE,WAAW,EAAE,8BAA8B;AACpD,OAAO,EAAE,SAAS,EAAE,oBAAoB;AAExC,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,aAAa,EAAE,+BAAqB;AAE7C,OAAO,EAAE,iBAAiB,EAAE,qBAAiB;AAkB7C,MAAM,OAAgB,mBAAoB,SAAQ,wBAAwB;IAWxE,YACE,MAAc,EACd,SAA4C,EAC5C,MAAiC;IACjC,0BAA0B;IAC1B,QAAuB,aAAa;QAEpC,KAAK,CAAC,SAAS,CAAC,CAAC;;QAXV,6CAAmB;QAEnB,6CAAsB;QAW7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,uBAAA,IAAI,uFAA4B,MAAhC,IAAI,EAA6B,MAAM,CAAC,CAAC;QAEvD,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,QAAQ,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,MAAM;YACT,cAAc;SACf,CAAC;QAEF,kDAAkD;QAClD,IAAI,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YAC7B,uBAAA,I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I,CAAC,cAAc,CAAC;4BACxB,aAAa;4BACb,UAAU;yBACX,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,WAAW,GAAG,iBAAiB,CACnC,8BAA8B,UAAU,EAAE,EAC1C,KAAc,EACd;wBACE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE;wBACxB,UAAU;qBACX,CACF,CAAC;oBACF,IAAI,CAAC,SAAS,CAAC,IAAI,CACjB,wCAAwC,EACxC,WAAW,CACZ,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;CA8BF;mPA1H6B,MAAc;IACxC,OAAO,IAAI,aAAa,CAAC;QACvB,IAAI,EAAE,KAAK,EAAE,OAAuB,EAAE,EAAE;YACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACxC,8BAA8B,EAC9B;gBACE,MAAM,EAAE,MAAgB;gBACxB,MAAM,EAAE,UAAU;gBAClB,OAAO,EAAE,WAAW,CAAC,gBAAgB;gBACrC,OAAO;aACR,CACF,CAAC;YACF,OAAO,QAAgB,CAAC;QAC1B,CAAC;KACF,CAAC,CAAC;AACL,CAAC,yCA+ED,KAAK,+CACH,SAM6B;IAE7B,OAAO,IAAI,CAAC,WAAW,CACrB,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,EAC3B,CAAC,IAAI,EAAE,EAAE;QACP,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CACF,CAAC;AACJ,CAAC;AAeH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAAiB,EACgB,EAAE;IACnC,OAAO,QAAQ,YAAY,mBAAmB,CAAC;AACjD,CAAC,CAAC","sourcesContent":["import { type Bip44Account } from '@metamask/account-api';\nimport type { TraceCallback, TraceRequest } from '@metamask/controller-utils';\nimport type { SnapKeyring } from '@metamask/eth-snap-keyring';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport type { KeyringMetadata } from '@metamask/keyring-controller';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { KeyringClient } from '@metamask/keyring-snap-client';\nimport type { Json, JsonRpcRequest, SnapId } from '@metamask/snaps-sdk';\nimport { HandlerType } from '@metamask/snaps-utils';\nimport { Semaphore } from 'async-mutex';\n\nimport { BaseBip44AccountProvider } from './BaseBip44AccountProvider';\nimport { traceFallback } from '../analytics';\nimport type { MultichainAccountServiceMessenger } from '../types';\nimport { createSentryError } from '../utils';\n\nexport type RestrictedSnapKeyringCreateAccount = (\n options: Record<string, Json>,\n) => Promise<KeyringAccount>;\n\nexport type SnapAccountProviderConfig = {\n maxConcurrency?: number;\n discovery: {\n maxAttempts: number;\n timeoutMs: number;\n backOffMs: number;\n };\n createAccounts: {\n timeoutMs: number;\n };\n};\n\nexport abstract class SnapAccountProvider extends BaseBip44AccountProvider {\n readonly snapId: SnapId;\n\n protected readonly config: SnapAccountProviderConfig;\n\n protected readonly client: KeyringClient;\n\n readonly #queue?: Semaphore;\n\n readonly #trace: TraceCallback;\n\n constructor(\n snapId: SnapId,\n messenger: MultichainAccountServiceMessenger,\n config: SnapAccountProviderConfig,\n /* istanbul ignore next */\n trace: TraceCallback = traceFallback,\n ) {\n super(messenger);\n\n this.snapId = snapId;\n this.client = this.#getKeyringClientFromSnapId(snapId);\n\n const maxConcurrency = config.maxConcurrency ?? Infinity;\n this.config = {\n ...config,\n maxConcurrency,\n };\n\n // Create semaphore only if concurrency is limited\n if (isFinite(maxConcurrency)) {\n this.#queue = new Semaphore(maxConcurrency);\n }\n\n this.#trace = trace;\n }\n\n /**\n * Wraps an async operation with concurrency limiting based on maxConcurrency config.\n * If maxConcurrency is Infinity (the default), the operation runs immediately without throttling.\n * Otherwise, it's queued through the semaphore to respect the concurrency limit.\n *\n * @param operation - The async operation to execute.\n * @returns The result of the operation.\n */\n protected async withMaxConcurrency<T>(\n operation: () => Promise<T>,\n ): Promise<T> {\n if (this.#queue) {\n return this.#queue.runExclusive(operation);\n }\n return operation();\n }\n\n protected async trace<ReturnType>(\n request: TraceRequest,\n fn: () => Promise<ReturnType>,\n ): Promise<ReturnType> {\n return this.#trace(request, fn);\n }\n\n protected async getRestrictedSnapAccountCreator(): Promise<RestrictedSnapKeyringCreateAccount> {\n // NOTE: We're not supposed to make the keyring instance escape `withKeyring` but\n // we have to use the `SnapKeyring` instance to be able to create Solana account\n // without triggering UI confirmation.\n // Also, creating account that way won't invalidate the Snap keyring state. The\n // account will get created and persisted properly with the Snap account creation\n // flow \"asynchronously\" (with `notify:accountCreated`).\n const createAccount = await this.#withSnapKeyring<\n SnapKeyring['createAccount']\n >(async ({ keyring }) => keyring.createAccount.bind(keyring));\n\n return (options) =>\n createAccount(this.snapId, options, {\n displayAccountNameSuggestion: false,\n displayConfirmation: false,\n setSelectedAccount: false,\n });\n }\n\n #getKeyringClientFromSnapId(snapId: string): KeyringClient {\n return new KeyringClient({\n send: async (request: JsonRpcRequest) => {\n const response = await this.messenger.call(\n 'SnapController:handleRequest',\n {\n snapId: snapId as SnapId,\n origin: 'metamask',\n handler: HandlerType.OnKeyringRequest,\n request,\n },\n );\n return response as Json;\n },\n });\n }\n\n async resyncAccounts(\n accounts: Bip44Account<InternalAccount>[],\n ): Promise<void> {\n const localSnapAccounts = accounts.filter(\n (account) =>\n account.metadata.snap && account.metadata.snap.id === this.snapId,\n );\n const snapAccounts = new Set(\n (await this.client.listAccounts()).map((account) => account.id),\n );\n\n // NOTE: This should never happen, but we want to report that kind of errors still\n // in case states are de-sync.\n if (localSnapAccounts.length < snapAccounts.size) {\n this.messenger.call(\n 'ErrorReportingService:captureException',\n new Error(\n `Snap \"${this.snapId}\" has de-synced accounts, Snap has more accounts than MetaMask!`,\n ),\n );\n\n // We don't recover from this case yet.\n return;\n }\n\n // We want this part to be fast, so we only check for sizes, but we might need\n // to make a real \"diff\" between the 2 states to not miss any de-sync.\n if (localSnapAccounts.length > snapAccounts.size) {\n // Accounts should never really be de-synced, so we want to log this to see how often this\n // happens, cause that means that something else is buggy elsewhere...\n this.messenger.call(\n 'ErrorReportingService:captureException',\n new Error(\n `Snap \"${this.snapId}\" has de-synced accounts, we'll attempt to re-sync them...`,\n ),\n );\n\n // We always use the MetaMask list as the main reference here.\n await Promise.all(\n localSnapAccounts.map(async (account) => {\n const { id: entropySource, groupIndex } = account.options.entropy;\n\n try {\n if (!snapAccounts.has(account.id)) {\n // We still need to remove the accounts from the Snap keyring since we're\n // about to create the same account again, which will use a new ID, but will\n // keep using the same address, and the Snap keyring does not allow this.\n await this.#withSnapKeyring(\n async ({ keyring }) =>\n await keyring.removeAccount(account.address),\n );\n\n // The Snap has no account in its state for this one, we re-create it.\n await this.createAccounts({\n entropySource,\n groupIndex,\n });\n }\n } catch (error) {\n const sentryError = createSentryError(\n `Unable to re-sync account: ${groupIndex}`,\n error as Error,\n {\n provider: this.getName(),\n groupIndex,\n },\n );\n this.messenger.call(\n 'ErrorReportingService:captureException',\n sentryError,\n );\n }\n }),\n );\n }\n }\n\n async #withSnapKeyring<CallbackResult = void>(\n operation: ({\n keyring,\n metadata,\n }: {\n keyring: SnapKeyring;\n metadata: KeyringMetadata;\n }) => Promise<CallbackResult>,\n ): Promise<CallbackResult> {\n return this.withKeyring<SnapKeyring, CallbackResult>(\n { type: KeyringTypes.snap },\n (args) => {\n return operation(args);\n },\n );\n }\n\n abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;\n\n abstract createAccounts(options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]>;\n\n abstract discoverAccounts(options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]>;\n}\n\nexport const isSnapAccountProvider = (\n provider: unknown,\n): provider is SnapAccountProvider => {\n return provider instanceof SnapAccountProvider;\n};\n"]}
@@ -4,23 +4,17 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
5
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
6
  };
7
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
- if (kind === "m") throw new TypeError("Private method is not writable");
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
- };
13
- var _SolAccountProvider_instances, _SolAccountProvider_client, _SolAccountProvider_getKeyringClientFromSnapId, _SolAccountProvider_createAccount;
7
+ var _SolAccountProvider_instances, _SolAccountProvider_createAccount;
14
8
  Object.defineProperty(exports, "__esModule", { value: true });
15
9
  exports.SolAccountProvider = exports.SOL_ACCOUNT_PROVIDER_NAME = void 0;
16
10
  const account_api_1 = require("@metamask/account-api");
17
11
  const keyring_api_1 = require("@metamask/keyring-api");
18
12
  const keyring_api_2 = require("@metamask/keyring-api");
19
13
  const keyring_controller_1 = require("@metamask/keyring-controller");
20
- const keyring_snap_client_1 = require("@metamask/keyring-snap-client");
21
- const snaps_utils_1 = require("@metamask/snaps-utils");
22
14
  const SnapAccountProvider_1 = require("./SnapAccountProvider.cjs");
23
15
  const utils_1 = require("./utils.cjs");
16
+ const analytics_1 = require("../analytics/index.cjs");
17
+ const traces_1 = require("../constants/traces.cjs");
24
18
  exports.SOL_ACCOUNT_PROVIDER_NAME = 'Solana';
25
19
  class SolAccountProvider extends SnapAccountProvider_1.SnapAccountProvider {
26
20
  constructor(messenger, config = {
@@ -33,11 +27,9 @@ class SolAccountProvider extends SnapAccountProvider_1.SnapAccountProvider {
33
27
  createAccounts: {
34
28
  timeoutMs: 3000,
35
29
  },
36
- }) {
37
- super(SolAccountProvider.SOLANA_SNAP_ID, messenger, config);
30
+ }, trace = analytics_1.traceFallback) {
31
+ super(SolAccountProvider.SOLANA_SNAP_ID, messenger, config, trace);
38
32
  _SolAccountProvider_instances.add(this);
39
- _SolAccountProvider_client.set(this, void 0);
40
- __classPrivateFieldSet(this, _SolAccountProvider_client, __classPrivateFieldGet(this, _SolAccountProvider_instances, "m", _SolAccountProvider_getKeyringClientFromSnapId).call(this, SolAccountProvider.SOLANA_SNAP_ID), "f");
41
33
  }
42
34
  getName() {
43
35
  return SolAccountProvider.NAME;
@@ -58,35 +50,30 @@ class SolAccountProvider extends SnapAccountProvider_1.SnapAccountProvider {
58
50
  });
59
51
  }
60
52
  async discoverAccounts({ entropySource, groupIndex, }) {
61
- const discoveredAccounts = await (0, utils_1.withRetry)(() => (0, utils_1.withTimeout)(__classPrivateFieldGet(this, _SolAccountProvider_client, "f").discoverAccounts([keyring_api_1.SolScope.Mainnet], entropySource, groupIndex), this.config.discovery.timeoutMs), {
62
- maxAttempts: this.config.discovery.maxAttempts,
63
- backOffMs: this.config.discovery.backOffMs,
53
+ return await super.trace({
54
+ name: traces_1.TraceName.SnapDiscoverAccounts,
55
+ data: {
56
+ provider: this.getName(),
57
+ },
58
+ }, async () => {
59
+ const discoveredAccounts = await (0, utils_1.withRetry)(() => (0, utils_1.withTimeout)(this.client.discoverAccounts([keyring_api_1.SolScope.Mainnet], entropySource, groupIndex), this.config.discovery.timeoutMs), {
60
+ maxAttempts: this.config.discovery.maxAttempts,
61
+ backOffMs: this.config.discovery.backOffMs,
62
+ });
63
+ if (!discoveredAccounts.length) {
64
+ return [];
65
+ }
66
+ const createdAccounts = await Promise.all(discoveredAccounts.map((d) => __classPrivateFieldGet(this, _SolAccountProvider_instances, "m", _SolAccountProvider_createAccount).call(this, {
67
+ entropySource,
68
+ groupIndex,
69
+ derivationPath: d.derivationPath,
70
+ })));
71
+ return createdAccounts;
64
72
  });
65
- if (!discoveredAccounts.length) {
66
- return [];
67
- }
68
- const createdAccounts = await Promise.all(discoveredAccounts.map((d) => __classPrivateFieldGet(this, _SolAccountProvider_instances, "m", _SolAccountProvider_createAccount).call(this, {
69
- entropySource,
70
- groupIndex,
71
- derivationPath: d.derivationPath,
72
- })));
73
- return createdAccounts;
74
73
  }
75
74
  }
76
75
  exports.SolAccountProvider = SolAccountProvider;
77
- _SolAccountProvider_client = new WeakMap(), _SolAccountProvider_instances = new WeakSet(), _SolAccountProvider_getKeyringClientFromSnapId = function _SolAccountProvider_getKeyringClientFromSnapId(snapId) {
78
- return new keyring_snap_client_1.KeyringClient({
79
- send: async (request) => {
80
- const response = await this.messenger.call('SnapController:handleRequest', {
81
- snapId: snapId,
82
- origin: 'metamask',
83
- handler: snaps_utils_1.HandlerType.OnKeyringRequest,
84
- request,
85
- });
86
- return response;
87
- },
88
- });
89
- }, _SolAccountProvider_createAccount = async function _SolAccountProvider_createAccount({ entropySource, groupIndex, derivationPath, }) {
76
+ _SolAccountProvider_instances = new WeakSet(), _SolAccountProvider_createAccount = async function _SolAccountProvider_createAccount({ entropySource, groupIndex, derivationPath, }) {
90
77
  const createAccount = await this.getRestrictedSnapAccountCreator();
91
78
  const account = await (0, utils_1.withTimeout)(createAccount({ entropySource, derivationPath }), this.config.createAccounts.timeoutMs);
92
79
  // Ensure entropy is present before type assertion validation
@@ -1 +1 @@
1
- {"version":3,"file":"SolAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAgF;AAEhF,uDAAiD;AACjD,uDAG+B;AAC/B,qEAA4D;AAE5D,uEAA8D;AAE9D,uDAAoD;AAGpD,mEAG+B;AAC/B,uCAAiD;AAKpC,QAAA,yBAAyB,GAAG,QAAiB,CAAC;AAE3D,MAAa,kBAAmB,SAAQ,yCAAmB;IAOzD,YACE,SAA4C,EAC5C,SAAmC;QACjC,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE;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IAAI,EAAE,6CAA+B,CAAC,QAAQ;QAC9C,EAAE,EAAE,aAAa;QACjB,UAAU;QACV,cAAc;KACf,CAAC;IAEF,IAAA,kCAAoB,EAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AA/EM,uBAAI,GAAG,iCAAyB,AAA5B,CAA6B;AAEjC,iCAAc,GAAG,kCAA4C,AAA/C,CAAgD","sourcesContent":["import { assertIsBip44Account, type Bip44Account } from '@metamask/account-api';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport { SolScope } from '@metamask/keyring-api';\nimport {\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { KeyringClient } from '@metamask/keyring-snap-client';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { HandlerType } from '@metamask/snaps-utils';\nimport type { Json, JsonRpcRequest } from '@metamask/utils';\n\nimport {\n SnapAccountProvider,\n type SnapAccountProviderConfig,\n} from './SnapAccountProvider';\nimport { withRetry, withTimeout } from './utils';\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type SolAccountProviderConfig = SnapAccountProviderConfig;\n\nexport const SOL_ACCOUNT_PROVIDER_NAME = 'Solana' as const;\n\nexport class SolAccountProvider extends SnapAccountProvider {\n static NAME = SOL_ACCOUNT_PROVIDER_NAME;\n\n static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n readonly #client: KeyringClient;\n\n constructor(\n messenger: MultichainAccountServiceMessenger,\n config: SolAccountProviderConfig = {\n maxConcurrency: 3,\n discovery: {\n timeoutMs: 2000,\n maxAttempts: 3,\n backOffMs: 1000,\n },\n createAccounts: {\n timeoutMs: 3000,\n },\n },\n ) {\n super(SolAccountProvider.SOLANA_SNAP_ID, messenger, config);\n this.#client = this.#getKeyringClientFromSnapId(\n SolAccountProvider.SOLANA_SNAP_ID,\n );\n }\n\n getName(): string {\n return SolAccountProvider.NAME;\n }\n\n #getKeyringClientFromSnapId(snapId: string): KeyringClient {\n return new KeyringClient({\n send: async (request: JsonRpcRequest) => {\n const response = await this.messenger.call(\n 'SnapController:handleRequest',\n {\n snapId: snapId as SnapId,\n origin: 'metamask',\n handler: HandlerType.OnKeyringRequest,\n request,\n },\n );\n return response as Json;\n },\n });\n }\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === SolAccountType.DataAccount &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n\n async #createAccount({\n entropySource,\n groupIndex,\n derivationPath,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n derivationPath: string;\n }): Promise<Bip44Account<KeyringAccount>> {\n const createAccount = await this.getRestrictedSnapAccountCreator();\n const account = await withTimeout(\n createAccount({ entropySource, derivationPath }),\n this.config.createAccounts.timeoutMs,\n );\n\n // Ensure entropy is present before type assertion validation\n account.options.entropy = {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: entropySource,\n groupIndex,\n derivationPath,\n };\n\n assertIsBip44Account(account);\n return account;\n }\n\n async createAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return this.withMaxConcurrency(async () => {\n const derivationPath = `m/44'/501'/${groupIndex}'/0'`;\n const account = await this.#createAccount({\n entropySource,\n groupIndex,\n derivationPath,\n });\n\n return [account];\n });\n }\n\n async discoverAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n const discoveredAccounts = await withRetry(\n () =>\n withTimeout(\n this.#client.discoverAccounts(\n [SolScope.Mainnet],\n entropySource,\n groupIndex,\n ),\n this.config.discovery.timeoutMs,\n ),\n {\n maxAttempts: this.config.discovery.maxAttempts,\n backOffMs: this.config.discovery.backOffMs,\n },\n );\n\n if (!discoveredAccounts.length) {\n return [];\n }\n\n const createdAccounts = await Promise.all(\n discoveredAccounts.map((d) =>\n this.#createAccount({\n entropySource,\n groupIndex,\n derivationPath: d.derivationPath,\n }),\n ),\n );\n\n return createdAccounts;\n }\n}\n"]}
1
+ {"version":3,"file":"SolAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uDAAgF;AAGhF,uDAAiD;AACjD,uDAG+B;AAC/B,qEAA4D;AAI5D,mEAG+B;AAC/B,uCAAiD;AACjD,sDAA6C;AAC7C,oDAAgD;AAKnC,QAAA,yBAAyB,GAAG,QAAiB,CAAC;AAE3D,MAAa,kBAAmB,SAAQ,yCAAmB;IAKzD,YACE,SAA4C,EAC5C,SAAmC;QACjC,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE;YACT,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,CAAC;YACd,SAAS,EAAE,IAAI;SAChB;QACD,cAAc,EAAE;YACd,SAAS,EAAE,IAAI;SAChB;KACF,EACD,QAAuB,yBAAa;QAEpC,KAAK,CAAC,kBAAkB,CAAC,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;;IACrE,CAAC;IAED,OAAO;QACL,OAAO,kBAAkB,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,mBAAmB,CAAC,OAAsC;QACxD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,4BAAc,CAAC,WAAW;YAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,iCAAY,CAAC,IAAe,CAChE,CAAC;IACJ,CAAC;IA6BD,KAAK,CAAC,cAAc,CAAC,EACnB,aAAa,EACb,UAAU,GAIX;QACC,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE;YACxC,MAAM,cAAc,GAAG,cAAc,UAAU,MAAM,CAAC;YACtD,MAAM,OAAO,GAAG,MAAM,uBAAA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ACV,cAAc,GAKf;IACC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,+BAA+B,EAAE,CAAC;IACnE,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAW,EAC/B,aAAa,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,EAChD,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CACrC,CAAC;IAEF,6DAA6D;IAC7D,OAAO,CAAC,OAAO,CAAC,OAAO,GAAG;QACxB,IAAI,EAAE,6CAA+B,CAAC,QAAQ;QAC9C,EAAE,EAAE,aAAa;QACjB,UAAU;QACV,cAAc;KACf,CAAC;IAEF,IAAA,kCAAoB,EAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AA1DM,uBAAI,GAAG,iCAAyB,AAA5B,CAA6B;AAEjC,iCAAc,GAAG,kCAA4C,AAA/C,CAAgD","sourcesContent":["import { assertIsBip44Account, type Bip44Account } from '@metamask/account-api';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport { SolScope } from '@metamask/keyring-api';\nimport {\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport {\n SnapAccountProvider,\n type SnapAccountProviderConfig,\n} from './SnapAccountProvider';\nimport { withRetry, withTimeout } from './utils';\nimport { traceFallback } from '../analytics';\nimport { TraceName } from '../constants/traces';\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type SolAccountProviderConfig = SnapAccountProviderConfig;\n\nexport const SOL_ACCOUNT_PROVIDER_NAME = 'Solana' as const;\n\nexport class SolAccountProvider extends SnapAccountProvider {\n static NAME = SOL_ACCOUNT_PROVIDER_NAME;\n\n static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n constructor(\n messenger: MultichainAccountServiceMessenger,\n config: SolAccountProviderConfig = {\n maxConcurrency: 3,\n discovery: {\n timeoutMs: 2000,\n maxAttempts: 3,\n backOffMs: 1000,\n },\n createAccounts: {\n timeoutMs: 3000,\n },\n },\n trace: TraceCallback = traceFallback,\n ) {\n super(SolAccountProvider.SOLANA_SNAP_ID, messenger, config, trace);\n }\n\n getName(): string {\n return SolAccountProvider.NAME;\n }\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === SolAccountType.DataAccount &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n\n async #createAccount({\n entropySource,\n groupIndex,\n derivationPath,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n derivationPath: string;\n }): Promise<Bip44Account<KeyringAccount>> {\n const createAccount = await this.getRestrictedSnapAccountCreator();\n const account = await withTimeout(\n createAccount({ entropySource, derivationPath }),\n this.config.createAccounts.timeoutMs,\n );\n\n // Ensure entropy is present before type assertion validation\n account.options.entropy = {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: entropySource,\n groupIndex,\n derivationPath,\n };\n\n assertIsBip44Account(account);\n return account;\n }\n\n async createAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return this.withMaxConcurrency(async () => {\n const derivationPath = `m/44'/501'/${groupIndex}'/0'`;\n const account = await this.#createAccount({\n entropySource,\n groupIndex,\n derivationPath,\n });\n\n return [account];\n });\n }\n\n async discoverAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return await super.trace(\n {\n name: TraceName.SnapDiscoverAccounts,\n data: {\n provider: this.getName(),\n },\n },\n async () => {\n const discoveredAccounts = await withRetry(\n () =>\n withTimeout(\n this.client.discoverAccounts(\n [SolScope.Mainnet],\n entropySource,\n groupIndex,\n ),\n this.config.discovery.timeoutMs,\n ),\n {\n maxAttempts: this.config.discovery.maxAttempts,\n backOffMs: this.config.discovery.backOffMs,\n },\n );\n\n if (!discoveredAccounts.length) {\n return [];\n }\n\n const createdAccounts = await Promise.all(\n discoveredAccounts.map((d) =>\n this.#createAccount({\n entropySource,\n groupIndex,\n derivationPath: d.derivationPath,\n }),\n ),\n );\n\n return createdAccounts;\n },\n );\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { type Bip44Account } from "@metamask/account-api";
2
+ import type { TraceCallback } from "@metamask/controller-utils";
2
3
  import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
3
4
  import type { InternalAccount } from "@metamask/keyring-internal-api";
4
5
  import type { SnapId } from "@metamask/snaps-sdk";
@@ -10,7 +11,7 @@ export declare class SolAccountProvider extends SnapAccountProvider {
10
11
  #private;
11
12
  static NAME: "Solana";
12
13
  static SOLANA_SNAP_ID: SnapId;
13
- constructor(messenger: MultichainAccountServiceMessenger, config?: SolAccountProviderConfig);
14
+ constructor(messenger: MultichainAccountServiceMessenger, config?: SolAccountProviderConfig, trace?: TraceCallback);
14
15
  getName(): string;
15
16
  isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
16
17
  createAccounts({ entropySource, groupIndex, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"SolAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,YAAY,EAAE,8BAA8B;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAO7E,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAIlD,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC/B,kCAA8B;AAE/B,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,MAAM,MAAM,wBAAwB,GAAG,yBAAyB,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CAAC,IAAI,WAA6B;IAExC,MAAM,CAAC,cAAc,SAAgD;gBAGnE,SAAS,EAAE,iCAAiC,EAC5C,MAAM,GAAE,wBAUP,EACD,KAAK,GAAE,aAA6B;IAKtC,OAAO,IAAI,MAAM;IAIjB,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;IAkC9D,cAAc,CAAC,EACnB,aAAa,EACb,UAAU,GACX,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;IAarC,gBAAgB,CAAC,EACrB,aAAa,EACb,UAAU,GACX,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;CA2C5C"}
@@ -1,4 +1,5 @@
1
1
  import { type Bip44Account } from "@metamask/account-api";
2
+ import type { TraceCallback } from "@metamask/controller-utils";
2
3
  import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
3
4
  import type { InternalAccount } from "@metamask/keyring-internal-api";
4
5
  import type { SnapId } from "@metamask/snaps-sdk";
@@ -10,7 +11,7 @@ export declare class SolAccountProvider extends SnapAccountProvider {
10
11
  #private;
11
12
  static NAME: "Solana";
12
13
  static SOLANA_SNAP_ID: SnapId;
13
- constructor(messenger: MultichainAccountServiceMessenger, config?: SolAccountProviderConfig);
14
+ constructor(messenger: MultichainAccountServiceMessenger, config?: SolAccountProviderConfig, trace?: TraceCallback);
14
15
  getName(): string;
15
16
  isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
16
17
  createAccounts({ entropySource, groupIndex, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"SolAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,Y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AAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC/B,kCAA8B;AAI/B,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,MAAM,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAEjE,eAAO,MAAM,yBAAyB,UAAoB,CAAC;AAE3D,qBAAa,kBAAmB,SAAQ,mBAAmB;;IACzD,MAAM,CAAC,IAAI,WAA6B;IAExC,MAAM,CAAC,cAAc,SAAgD;gBAGnE,SAAS,EAAE,iCAAiC,EAC5C,MAAM,GAAE,wBAUP,EACD,KAAK,GAAE,aAA6B;IAKtC,OAAO,IAAI,MAAM;IAIjB,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;IAkC9D,cAAc,CAAC,EACnB,aAAa,EACb,UAAU,GACX,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;IAarC,gBAAgB,CAAC,EACrB,aAAa,EACb,UAAU,GACX,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;CA2C5C"}
@@ -3,21 +3,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
3
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _SolAccountProvider_instances, _SolAccountProvider_client, _SolAccountProvider_getKeyringClientFromSnapId, _SolAccountProvider_createAccount;
6
+ var _SolAccountProvider_instances, _SolAccountProvider_createAccount;
13
7
  import { assertIsBip44Account } from "@metamask/account-api";
14
8
  import { SolScope } from "@metamask/keyring-api";
15
9
  import { KeyringAccountEntropyTypeOption, SolAccountType } from "@metamask/keyring-api";
16
10
  import { KeyringTypes } from "@metamask/keyring-controller";
17
- import { KeyringClient } from "@metamask/keyring-snap-client";
18
- import { HandlerType } from "@metamask/snaps-utils";
19
11
  import { SnapAccountProvider } from "./SnapAccountProvider.mjs";
20
12
  import { withRetry, withTimeout } from "./utils.mjs";
13
+ import { traceFallback } from "../analytics/index.mjs";
14
+ import { TraceName } from "../constants/traces.mjs";
21
15
  export const SOL_ACCOUNT_PROVIDER_NAME = 'Solana';
22
16
  export class SolAccountProvider extends SnapAccountProvider {
23
17
  constructor(messenger, config = {
@@ -30,11 +24,9 @@ export class SolAccountProvider extends SnapAccountProvider {
30
24
  createAccounts: {
31
25
  timeoutMs: 3000,
32
26
  },
33
- }) {
34
- super(SolAccountProvider.SOLANA_SNAP_ID, messenger, config);
27
+ }, trace = traceFallback) {
28
+ super(SolAccountProvider.SOLANA_SNAP_ID, messenger, config, trace);
35
29
  _SolAccountProvider_instances.add(this);
36
- _SolAccountProvider_client.set(this, void 0);
37
- __classPrivateFieldSet(this, _SolAccountProvider_client, __classPrivateFieldGet(this, _SolAccountProvider_instances, "m", _SolAccountProvider_getKeyringClientFromSnapId).call(this, SolAccountProvider.SOLANA_SNAP_ID), "f");
38
30
  }
39
31
  getName() {
40
32
  return SolAccountProvider.NAME;
@@ -55,34 +47,29 @@ export class SolAccountProvider extends SnapAccountProvider {
55
47
  });
56
48
  }
57
49
  async discoverAccounts({ entropySource, groupIndex, }) {
58
- const discoveredAccounts = await withRetry(() => withTimeout(__classPrivateFieldGet(this, _SolAccountProvider_client, "f").discoverAccounts([SolScope.Mainnet], entropySource, groupIndex), this.config.discovery.timeoutMs), {
59
- maxAttempts: this.config.discovery.maxAttempts,
60
- backOffMs: this.config.discovery.backOffMs,
50
+ return await super.trace({
51
+ name: TraceName.SnapDiscoverAccounts,
52
+ data: {
53
+ provider: this.getName(),
54
+ },
55
+ }, async () => {
56
+ const discoveredAccounts = await withRetry(() => withTimeout(this.client.discoverAccounts([SolScope.Mainnet], entropySource, groupIndex), this.config.discovery.timeoutMs), {
57
+ maxAttempts: this.config.discovery.maxAttempts,
58
+ backOffMs: this.config.discovery.backOffMs,
59
+ });
60
+ if (!discoveredAccounts.length) {
61
+ return [];
62
+ }
63
+ const createdAccounts = await Promise.all(discoveredAccounts.map((d) => __classPrivateFieldGet(this, _SolAccountProvider_instances, "m", _SolAccountProvider_createAccount).call(this, {
64
+ entropySource,
65
+ groupIndex,
66
+ derivationPath: d.derivationPath,
67
+ })));
68
+ return createdAccounts;
61
69
  });
62
- if (!discoveredAccounts.length) {
63
- return [];
64
- }
65
- const createdAccounts = await Promise.all(discoveredAccounts.map((d) => __classPrivateFieldGet(this, _SolAccountProvider_instances, "m", _SolAccountProvider_createAccount).call(this, {
66
- entropySource,
67
- groupIndex,
68
- derivationPath: d.derivationPath,
69
- })));
70
- return createdAccounts;
71
70
  }
72
71
  }
73
- _SolAccountProvider_client = new WeakMap(), _SolAccountProvider_instances = new WeakSet(), _SolAccountProvider_getKeyringClientFromSnapId = function _SolAccountProvider_getKeyringClientFromSnapId(snapId) {
74
- return new KeyringClient({
75
- send: async (request) => {
76
- const response = await this.messenger.call('SnapController:handleRequest', {
77
- snapId: snapId,
78
- origin: 'metamask',
79
- handler: HandlerType.OnKeyringRequest,
80
- request,
81
- });
82
- return response;
83
- },
84
- });
85
- }, _SolAccountProvider_createAccount = async function _SolAccountProvider_createAccount({ entropySource, groupIndex, derivationPath, }) {
72
+ _SolAccountProvider_instances = new WeakSet(), _SolAccountProvider_createAccount = async function _SolAccountProvider_createAccount({ entropySource, groupIndex, derivationPath, }) {
86
73
  const createAccount = await this.getRestrictedSnapAccountCreator();
87
74
  const account = await withTimeout(createAccount({ entropySource, derivationPath }), this.config.createAccounts.timeoutMs);
88
75
  // Ensure entropy is present before type assertion validation
@@ -1 +1 @@
1
- {"version":3,"file":"SolAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,oBAAoB,EAAqB,8BAA8B;AAEhF,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AACjD,OAAO,EACL,+BAA+B,EAC/B,cAAc,EACf,8BAA8B;AAC/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAE5D,OAAO,EAAE,aAAa,EAAE,sCAAsC;AAE9D,OAAO,EAAE,WAAW,EAAE,8BAA8B;AAGpD,OAAO,EACL,mBAAmB,EAEpB,kCAA8B;AAC/B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,oBAAgB;AAKjD,MAAM,CAAC,MAAM,yBAAyB,GAAG,QAAiB,CAAC;AAE3D,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB;IAOzD,YACE,SAA4C,EAC5C,SAAmC;QACjC,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE;YACT,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,CAAC;YACd,SAAS,EAAE,IAAI;SAChB;QACD,cAAc,EAAE;YACd,SAAS,EAAE,IAAI;SAChB;KACF;QAED,KAAK,CAAC,kBAAkB,CAAC,cAAc,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;;QAhBrD,6CAAuB;QAiB9B,uBAAA,IAAI,8BAAW,uBAAA,IAAI,qFAA4B,MAAhC,IAAI,EACjB,kBAAkB,CAAC,cAAc,CAClC,MAAA,CAAC;IACJ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AAA,IAAI,wEAAe,MAAnB,IAAI,EAAgB;YAClB,aAAa;YACb,UAAU;YACV,cAAc,EAAE,CAAC,CAAC,cAAc;SACjC,CAAC,CACH,CACF,CAAC;QAEF,OAAO,eAAe,CAAC;IACzB,CAAC;;oMA5G2B,MAAc;IACxC,OAAO,IAAI,aAAa,CAAC;QACvB,IAAI,EAAE,KAAK,EAAE,OAAuB,EAAE,EAAE;YACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACxC,8BAA8B,EAC9B;gBACE,MAAM,EAAE,MAAgB;gBACxB,MAAM,EAAE,UAAU;gBAClB,OAAO,EAAE,WAAW,CAAC,gBAAgB;gBACrC,OAAO;aACR,CACF,CAAC;YACF,OAAO,QAAgB,CAAC;QAC1B,CAAC;KACF,CAAC,CAAC;AACL,CAAC,sCASD,KAAK,4CAAgB,EACnB,aAAa,EACb,UAAU,EACV,cAAc,GAKf;IACC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,+BAA+B,EAAE,CAAC;IACnE,MAAM,OAAO,GAAG,MAAM,WAAW,CAC/B,aAAa,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,EAChD,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CACrC,CAAC;IAEF,6DAA6D;IAC7D,OAAO,CAAC,OAAO,CAAC,OAAO,GAAG;QACxB,IAAI,EAAE,+BAA+B,CAAC,QAAQ;QAC9C,EAAE,EAAE,aAAa;QACjB,UAAU;QACV,cAAc;KACf,CAAC;IAEF,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AA/EM,uBAAI,GAAG,yBAAyB,AAA5B,CAA6B;AAEjC,iCAAc,GAAG,kCAA4C,AAA/C,CAAgD","sourcesContent":["import { assertIsBip44Account, type Bip44Account } from '@metamask/account-api';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport { SolScope } from '@metamask/keyring-api';\nimport {\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { KeyringClient } from '@metamask/keyring-snap-client';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { HandlerType } from '@metamask/snaps-utils';\nimport type { Json, JsonRpcRequest } from '@metamask/utils';\n\nimport {\n SnapAccountProvider,\n type SnapAccountProviderConfig,\n} from './SnapAccountProvider';\nimport { withRetry, withTimeout } from './utils';\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type SolAccountProviderConfig = SnapAccountProviderConfig;\n\nexport const SOL_ACCOUNT_PROVIDER_NAME = 'Solana' as const;\n\nexport class SolAccountProvider extends SnapAccountProvider {\n static NAME = SOL_ACCOUNT_PROVIDER_NAME;\n\n static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n readonly #client: KeyringClient;\n\n constructor(\n messenger: MultichainAccountServiceMessenger,\n config: SolAccountProviderConfig = {\n maxConcurrency: 3,\n discovery: {\n timeoutMs: 2000,\n maxAttempts: 3,\n backOffMs: 1000,\n },\n createAccounts: {\n timeoutMs: 3000,\n },\n },\n ) {\n super(SolAccountProvider.SOLANA_SNAP_ID, messenger, config);\n this.#client = this.#getKeyringClientFromSnapId(\n SolAccountProvider.SOLANA_SNAP_ID,\n );\n }\n\n getName(): string {\n return SolAccountProvider.NAME;\n }\n\n #getKeyringClientFromSnapId(snapId: string): KeyringClient {\n return new KeyringClient({\n send: async (request: JsonRpcRequest) => {\n const response = await this.messenger.call(\n 'SnapController:handleRequest',\n {\n snapId: snapId as SnapId,\n origin: 'metamask',\n handler: HandlerType.OnKeyringRequest,\n request,\n },\n );\n return response as Json;\n },\n });\n }\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === SolAccountType.DataAccount &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n\n async #createAccount({\n entropySource,\n groupIndex,\n derivationPath,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n derivationPath: string;\n }): Promise<Bip44Account<KeyringAccount>> {\n const createAccount = await this.getRestrictedSnapAccountCreator();\n const account = await withTimeout(\n createAccount({ entropySource, derivationPath }),\n this.config.createAccounts.timeoutMs,\n );\n\n // Ensure entropy is present before type assertion validation\n account.options.entropy = {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: entropySource,\n groupIndex,\n derivationPath,\n };\n\n assertIsBip44Account(account);\n return account;\n }\n\n async createAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return this.withMaxConcurrency(async () => {\n const derivationPath = `m/44'/501'/${groupIndex}'/0'`;\n const account = await this.#createAccount({\n entropySource,\n groupIndex,\n derivationPath,\n });\n\n return [account];\n });\n }\n\n async discoverAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n const discoveredAccounts = await withRetry(\n () =>\n withTimeout(\n this.#client.discoverAccounts(\n [SolScope.Mainnet],\n entropySource,\n groupIndex,\n ),\n this.config.discovery.timeoutMs,\n ),\n {\n maxAttempts: this.config.discovery.maxAttempts,\n backOffMs: this.config.discovery.backOffMs,\n },\n );\n\n if (!discoveredAccounts.length) {\n return [];\n }\n\n const createdAccounts = await Promise.all(\n discoveredAccounts.map((d) =>\n this.#createAccount({\n entropySource,\n groupIndex,\n derivationPath: d.derivationPath,\n }),\n ),\n );\n\n return createdAccounts;\n }\n}\n"]}
1
+ {"version":3,"file":"SolAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,oBAAoB,EAAqB,8BAA8B;AAGhF,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AACjD,OAAO,EACL,+BAA+B,EAC/B,c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IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CACrC,CAAC;IAEF,6DAA6D;IAC7D,OAAO,CAAC,OAAO,CAAC,OAAO,GAAG;QACxB,IAAI,EAAE,+BAA+B,CAAC,QAAQ;QAC9C,EAAE,EAAE,aAAa;QACjB,UAAU;QACV,cAAc;KACf,CAAC;IAEF,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AA1DM,uBAAI,GAAG,yBAAyB,AAA5B,CAA6B;AAEjC,iCAAc,GAAG,kCAA4C,AAA/C,CAAgD","sourcesContent":["import { assertIsBip44Account, type Bip44Account } from '@metamask/account-api';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport { SolScope } from '@metamask/keyring-api';\nimport {\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport {\n SnapAccountProvider,\n type SnapAccountProviderConfig,\n} from './SnapAccountProvider';\nimport { withRetry, withTimeout } from './utils';\nimport { traceFallback } from '../analytics';\nimport { TraceName } from '../constants/traces';\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type SolAccountProviderConfig = SnapAccountProviderConfig;\n\nexport const SOL_ACCOUNT_PROVIDER_NAME = 'Solana' as const;\n\nexport class SolAccountProvider extends SnapAccountProvider {\n static NAME = SOL_ACCOUNT_PROVIDER_NAME;\n\n static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n constructor(\n messenger: MultichainAccountServiceMessenger,\n config: SolAccountProviderConfig = {\n maxConcurrency: 3,\n discovery: {\n timeoutMs: 2000,\n maxAttempts: 3,\n backOffMs: 1000,\n },\n createAccounts: {\n timeoutMs: 3000,\n },\n },\n trace: TraceCallback = traceFallback,\n ) {\n super(SolAccountProvider.SOLANA_SNAP_ID, messenger, config, trace);\n }\n\n getName(): string {\n return SolAccountProvider.NAME;\n }\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === SolAccountType.DataAccount &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n\n async #createAccount({\n entropySource,\n groupIndex,\n derivationPath,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n derivationPath: string;\n }): Promise<Bip44Account<KeyringAccount>> {\n const createAccount = await this.getRestrictedSnapAccountCreator();\n const account = await withTimeout(\n createAccount({ entropySource, derivationPath }),\n this.config.createAccounts.timeoutMs,\n );\n\n // Ensure entropy is present before type assertion validation\n account.options.entropy = {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: entropySource,\n groupIndex,\n derivationPath,\n };\n\n assertIsBip44Account(account);\n return account;\n }\n\n async createAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return this.withMaxConcurrency(async () => {\n const derivationPath = `m/44'/501'/${groupIndex}'/0'`;\n const account = await this.#createAccount({\n entropySource,\n groupIndex,\n derivationPath,\n });\n\n return [account];\n });\n }\n\n async discoverAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return await super.trace(\n {\n name: TraceName.SnapDiscoverAccounts,\n data: {\n provider: this.getName(),\n },\n },\n async () => {\n const discoveredAccounts = await withRetry(\n () =>\n withTimeout(\n this.client.discoverAccounts(\n [SolScope.Mainnet],\n entropySource,\n groupIndex,\n ),\n this.config.discovery.timeoutMs,\n ),\n {\n maxAttempts: this.config.discovery.maxAttempts,\n backOffMs: this.config.discovery.backOffMs,\n },\n );\n\n if (!discoveredAccounts.length) {\n return [];\n }\n\n const createdAccounts = await Promise.all(\n discoveredAccounts.map((d) =>\n this.#createAccount({\n entropySource,\n groupIndex,\n derivationPath: d.derivationPath,\n }),\n ),\n );\n\n return createdAccounts;\n },\n );\n }\n}\n"]}
@@ -1,25 +1,13 @@
1
1
  "use strict";
2
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
- };
7
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
- if (kind === "m") throw new TypeError("Private method is not writable");
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
- };
13
- var _TrxAccountProvider_instances, _TrxAccountProvider_client, _TrxAccountProvider_getKeyringClientFromSnapId;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.TrxAccountProvider = exports.TRX_ACCOUNT_PROVIDER_NAME = void 0;
16
4
  const account_api_1 = require("@metamask/account-api");
17
5
  const keyring_api_1 = require("@metamask/keyring-api");
18
6
  const keyring_controller_1 = require("@metamask/keyring-controller");
19
- const keyring_snap_client_1 = require("@metamask/keyring-snap-client");
20
- const snaps_utils_1 = require("@metamask/snaps-utils");
21
7
  const SnapAccountProvider_1 = require("./SnapAccountProvider.cjs");
22
8
  const utils_1 = require("./utils.cjs");
9
+ const analytics_1 = require("../analytics/index.cjs");
10
+ const traces_1 = require("../constants/traces.cjs");
23
11
  exports.TRX_ACCOUNT_PROVIDER_NAME = 'Tron';
24
12
  class TrxAccountProvider extends SnapAccountProvider_1.SnapAccountProvider {
25
13
  constructor(messenger, config = {
@@ -32,11 +20,8 @@ class TrxAccountProvider extends SnapAccountProvider_1.SnapAccountProvider {
32
20
  createAccounts: {
33
21
  timeoutMs: 3000,
34
22
  },
35
- }) {
36
- super(TrxAccountProvider.TRX_SNAP_ID, messenger, config);
37
- _TrxAccountProvider_instances.add(this);
38
- _TrxAccountProvider_client.set(this, void 0);
39
- __classPrivateFieldSet(this, _TrxAccountProvider_client, __classPrivateFieldGet(this, _TrxAccountProvider_instances, "m", _TrxAccountProvider_getKeyringClientFromSnapId).call(this, TrxAccountProvider.TRX_SNAP_ID), "f");
23
+ }, trace = analytics_1.traceFallback) {
24
+ super(TrxAccountProvider.TRX_SNAP_ID, messenger, config, trace);
40
25
  }
41
26
  getName() {
42
27
  return TrxAccountProvider.NAME;
@@ -59,34 +44,28 @@ class TrxAccountProvider extends SnapAccountProvider_1.SnapAccountProvider {
59
44
  });
60
45
  }
61
46
  async discoverAccounts({ entropySource, groupIndex, }) {
62
- const discoveredAccounts = await (0, utils_1.withRetry)(() => (0, utils_1.withTimeout)(__classPrivateFieldGet(this, _TrxAccountProvider_client, "f").discoverAccounts([keyring_api_1.TrxScope.Mainnet], entropySource, groupIndex), this.config.discovery.timeoutMs), {
63
- maxAttempts: this.config.discovery.maxAttempts,
64
- backOffMs: this.config.discovery.backOffMs,
65
- });
66
- if (!discoveredAccounts.length) {
67
- return [];
68
- }
69
- const createdAccounts = await this.createAccounts({
70
- entropySource,
71
- groupIndex,
47
+ return await super.trace({
48
+ name: traces_1.TraceName.SnapDiscoverAccounts,
49
+ data: {
50
+ provider: this.getName(),
51
+ },
52
+ }, async () => {
53
+ const discoveredAccounts = await (0, utils_1.withRetry)(() => (0, utils_1.withTimeout)(this.client.discoverAccounts([keyring_api_1.TrxScope.Mainnet], entropySource, groupIndex), this.config.discovery.timeoutMs), {
54
+ maxAttempts: this.config.discovery.maxAttempts,
55
+ backOffMs: this.config.discovery.backOffMs,
56
+ });
57
+ if (!discoveredAccounts.length) {
58
+ return [];
59
+ }
60
+ const createdAccounts = await this.createAccounts({
61
+ entropySource,
62
+ groupIndex,
63
+ });
64
+ return createdAccounts;
72
65
  });
73
- return createdAccounts;
74
66
  }
75
67
  }
76
68
  exports.TrxAccountProvider = TrxAccountProvider;
77
- _TrxAccountProvider_client = new WeakMap(), _TrxAccountProvider_instances = new WeakSet(), _TrxAccountProvider_getKeyringClientFromSnapId = function _TrxAccountProvider_getKeyringClientFromSnapId(snapId) {
78
- return new keyring_snap_client_1.KeyringClient({
79
- send: async (request) => {
80
- const response = await this.messenger.call('SnapController:handleRequest', {
81
- snapId: snapId,
82
- origin: 'metamask',
83
- handler: snaps_utils_1.HandlerType.OnKeyringRequest,
84
- request,
85
- });
86
- return response;
87
- },
88
- });
89
- };
90
69
  TrxAccountProvider.NAME = exports.TRX_ACCOUNT_PROVIDER_NAME;
91
70
  TrxAccountProvider.TRX_SNAP_ID = 'npm:@metamask/tron-wallet-snap';
92
71
  //# sourceMappingURL=TrxAccountProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"TrxAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/TrxAccountProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAgF;AAEhF,uDAAiE;AACjE,qEAA4D;AAE5D,uEAA8D;AAE9D,uDAAoD;AAGpD,mEAG+B;AAC/B,uCAAiD;AAKpC,QAAA,yBAAyB,GAAG,MAAe,CAAC;AAEzD,MAAa,kBAAmB,SAAQ,yCAAmB;IAOzD,YACE,SAA4C,EAC5C,SAAmC;QACjC,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE;YACT,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,CAAC;YACd,SAAS,EAAE,IAAI;SAChB;QACD,cAAc,EAAE;YACd,SAAS,EAAE,IAAI;SAChB;KACF;QAED,KAAK,CAAC,kBAAkB,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;;QAhBlD,6CAAuB;QAiB9B,uBAAA,IAAI,8BAAW,uBAAA,IAAI,qF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W;YAC9C,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS;SAC3C,CACF,CAAC;QAEF,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE;YAC9B,OAAO,EAAE,CAAC;SACX;QAED,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC;YAChD,aAAa;YACb,UAAU;SACX,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;IACzB,CAAC;;AAjHH,gDAkHC;oMAnF6B,MAAc;IACxC,OAAO,IAAI,mCAAa,CAAC;QACvB,IAAI,EAAE,KAAK,EAAE,OAAuB,EAAE,EAAE;YACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACxC,8BAA8B,EAC9B;gBACE,MAAM,EAAE,MAAgB;gBACxB,MAAM,EAAE,UAAU;gBAClB,OAAO,EAAE,yBAAW,CAAC,gBAAgB;gBACrC,OAAO;aACR,CACF,CAAC;YACF,OAAO,QAAgB,CAAC;QAC1B,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AA7CM,uBAAI,GAAG,iCAAyB,AAA5B,CAA6B;AAEjC,8BAAW,GAAG,gCAA0C,AAA7C,CAA8C","sourcesContent":["import { assertIsBip44Account, type Bip44Account } from '@metamask/account-api';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport { TrxAccountType, TrxScope } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { KeyringClient } from '@metamask/keyring-snap-client';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { HandlerType } from '@metamask/snaps-utils';\nimport type { Json, JsonRpcRequest } from '@metamask/utils';\n\nimport {\n SnapAccountProvider,\n type SnapAccountProviderConfig,\n} from './SnapAccountProvider';\nimport { withRetry, withTimeout } from './utils';\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type TrxAccountProviderConfig = SnapAccountProviderConfig;\n\nexport const TRX_ACCOUNT_PROVIDER_NAME = 'Tron' as const;\n\nexport class TrxAccountProvider extends SnapAccountProvider {\n static NAME = TRX_ACCOUNT_PROVIDER_NAME;\n\n static TRX_SNAP_ID = 'npm:@metamask/tron-wallet-snap' as SnapId;\n\n readonly #client: KeyringClient;\n\n constructor(\n messenger: MultichainAccountServiceMessenger,\n config: TrxAccountProviderConfig = {\n maxConcurrency: 3,\n discovery: {\n timeoutMs: 2000,\n maxAttempts: 3,\n backOffMs: 1000,\n },\n createAccounts: {\n timeoutMs: 3000,\n },\n },\n ) {\n super(TrxAccountProvider.TRX_SNAP_ID, messenger, config);\n this.#client = this.#getKeyringClientFromSnapId(\n TrxAccountProvider.TRX_SNAP_ID,\n );\n }\n\n getName(): string {\n return TrxAccountProvider.NAME;\n }\n\n #getKeyringClientFromSnapId(snapId: string): KeyringClient {\n return new KeyringClient({\n send: async (request: JsonRpcRequest) => {\n const response = await this.messenger.call(\n 'SnapController:handleRequest',\n {\n snapId: snapId as SnapId,\n origin: 'metamask',\n handler: HandlerType.OnKeyringRequest,\n request,\n },\n );\n return response as Json;\n },\n });\n }\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === TrxAccountType.Eoa &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n\n async createAccounts({\n entropySource,\n groupIndex: index,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return this.withMaxConcurrency(async () => {\n const createAccount = await this.getRestrictedSnapAccountCreator();\n\n const account = await withTimeout(\n createAccount({\n entropySource,\n index,\n addressType: TrxAccountType.Eoa,\n scope: TrxScope.Mainnet,\n }),\n this.config.createAccounts.timeoutMs,\n );\n\n assertIsBip44Account(account);\n return [account];\n });\n }\n\n async discoverAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n const discoveredAccounts = await withRetry(\n () =>\n withTimeout(\n this.#client.discoverAccounts(\n [TrxScope.Mainnet],\n entropySource,\n groupIndex,\n ),\n this.config.discovery.timeoutMs,\n ),\n {\n maxAttempts: this.config.discovery.maxAttempts,\n backOffMs: this.config.discovery.backOffMs,\n },\n );\n\n if (!discoveredAccounts.length) {\n return [];\n }\n\n const createdAccounts = await this.createAccounts({\n entropySource,\n groupIndex,\n });\n\n return createdAccounts;\n }\n}\n"]}
1
+ {"version":3,"file":"TrxAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/TrxAccountProvider.ts"],"names":[],"mappings":";;;AAAA,uDAAgF;AAGhF,uDAAiE;AACjE,qEAA4D;AAI5D,mEAG+B;AAC/B,uCAAiD;AACjD,sDAA6C;AAC7C,oDAAgD;AAKnC,QAAA,yBAAyB,GAAG,MAAe,CAAC;AAEzD,MAAa,kBAAmB,SAAQ,yCAAmB;IAKzD,YACE,SAA4C,EAC5C,SAAmC;QACjC,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE;YACT,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,CAAC;YACd,SAAS,EAAE,IAAI;SAChB;QACD,cAAc,EAAE;YACd,SAAS,EAAE,IAAI;SAChB;KACF,EACD,QAAuB,yBAAa;QAEpC,KAAK,CAAC,kBAAkB,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,OAAO,kBAAkB,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,mBAAmB,CAAC,OAAsC;QACxD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,4BAAc,CAAC,GAAG;YACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,iCAAY,CAAC,IAAe,CAChE,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EACnB,aAAa,EACb,UAAU,EAAE,KAAK,GAIlB;QACC,OAAO,IAAI,CAAC,kBAAkB,CAAC,K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CAAC;YAEH,OAAO,eAAe,CAAC;QACzB,CAAC,CACF,CAAC;IACJ,CAAC;;AAtGH,gDAuGC;AAtGQ,uBAAI,GAAG,iCAAyB,CAAC;AAEjC,8BAAW,GAAG,gCAA0C,CAAC","sourcesContent":["import { assertIsBip44Account, type Bip44Account } from '@metamask/account-api';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport { TrxAccountType, TrxScope } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport {\n SnapAccountProvider,\n type SnapAccountProviderConfig,\n} from './SnapAccountProvider';\nimport { withRetry, withTimeout } from './utils';\nimport { traceFallback } from '../analytics';\nimport { TraceName } from '../constants/traces';\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type TrxAccountProviderConfig = SnapAccountProviderConfig;\n\nexport const TRX_ACCOUNT_PROVIDER_NAME = 'Tron' as const;\n\nexport class TrxAccountProvider extends SnapAccountProvider {\n static NAME = TRX_ACCOUNT_PROVIDER_NAME;\n\n static TRX_SNAP_ID = 'npm:@metamask/tron-wallet-snap' as SnapId;\n\n constructor(\n messenger: MultichainAccountServiceMessenger,\n config: TrxAccountProviderConfig = {\n maxConcurrency: 3,\n discovery: {\n timeoutMs: 2000,\n maxAttempts: 3,\n backOffMs: 1000,\n },\n createAccounts: {\n timeoutMs: 3000,\n },\n },\n trace: TraceCallback = traceFallback,\n ) {\n super(TrxAccountProvider.TRX_SNAP_ID, messenger, config, trace);\n }\n\n getName(): string {\n return TrxAccountProvider.NAME;\n }\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === TrxAccountType.Eoa &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n\n async createAccounts({\n entropySource,\n groupIndex: index,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return this.withMaxConcurrency(async () => {\n const createAccount = await this.getRestrictedSnapAccountCreator();\n\n const account = await withTimeout(\n createAccount({\n entropySource,\n index,\n addressType: TrxAccountType.Eoa,\n scope: TrxScope.Mainnet,\n }),\n this.config.createAccounts.timeoutMs,\n );\n\n assertIsBip44Account(account);\n return [account];\n });\n }\n\n async discoverAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return await super.trace(\n {\n name: TraceName.SnapDiscoverAccounts,\n data: {\n provider: this.getName(),\n },\n },\n async () => {\n const discoveredAccounts = await withRetry(\n () =>\n withTimeout(\n this.client.discoverAccounts(\n [TrxScope.Mainnet],\n entropySource,\n groupIndex,\n ),\n this.config.discovery.timeoutMs,\n ),\n {\n maxAttempts: this.config.discovery.maxAttempts,\n backOffMs: this.config.discovery.backOffMs,\n },\n );\n\n if (!discoveredAccounts.length) {\n return [];\n }\n\n const createdAccounts = await this.createAccounts({\n entropySource,\n groupIndex,\n });\n\n return createdAccounts;\n },\n );\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { type Bip44Account } from "@metamask/account-api";
2
+ import type { TraceCallback } from "@metamask/controller-utils";
2
3
  import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
3
4
  import type { InternalAccount } from "@metamask/keyring-internal-api";
4
5
  import type { SnapId } from "@metamask/snaps-sdk";
@@ -7,10 +8,9 @@ import type { MultichainAccountServiceMessenger } from "../types.cjs";
7
8
  export type TrxAccountProviderConfig = SnapAccountProviderConfig;
8
9
  export declare const TRX_ACCOUNT_PROVIDER_NAME: "Tron";
9
10
  export declare class TrxAccountProvider extends SnapAccountProvider {
10
- #private;
11
11
  static NAME: "Tron";
12
12
  static TRX_SNAP_ID: SnapId;
13
- constructor(messenger: MultichainAccountServiceMessenger, config?: TrxAccountProviderConfig);
13
+ constructor(messenger: MultichainAccountServiceMessenger, config?: TrxAccountProviderConfig, trace?: TraceCallback);
14
14
  getName(): string;
15
15
  isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
16
16
  createAccounts({ entropySource, groupIndex: index, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"TrxAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/TrxAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,YAAY,EAAE,8BAA8B;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAG7E,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAIlD,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC/B,kCAA8B;AAE/B,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,MAAM,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAEjE,eAAO,MAAM,yBAAyB,QAAkB,CAAC;AAEzD,qBAAa,kBAAmB,SAAQ,mBAAmB;;IACzD,MAAM,CAAC,IAAI,SAA6B;IAExC,MAAM,CAAC,WAAW,SAA8C;gBAK9D,SAAS,EAAE,iCAAiC,EAC5C,MAAM,GAAE,wBAUP;IAQH,OAAO,IAAI,MAAM;IAqBjB,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;IAO9D,cAAc,CAAC,EACnB,aAAa,EACb,UAAU,EAAE,KAAK,GAClB,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;IAmBrC,gBAAgB,CAAC,EACrB,aAAa,EACb,UAAU,GACX,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;CA4B5C"}
1
+ {"version":3,"file":"TrxAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/TrxAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,YAAY,EAAE,8BAA8B;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAG7E,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC/B,kCAA8B;AAI/B,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,MAAM,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAEjE,eAAO,MAAM,yBAAyB,QAAkB,CAAC;AAEzD,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,MAAM,CAAC,IAAI,SAA6B;IAExC,MAAM,CAAC,WAAW,SAA8C;gBAG9D,SAAS,EAAE,iCAAiC,EAC5C,MAAM,GAAE,wBAUP,EACD,KAAK,GAAE,aAA6B;IAKtC,OAAO,IAAI,MAAM;IAIjB,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;IAO9D,cAAc,CAAC,EACnB,aAAa,EACb,UAAU,EAAE,KAAK,GAClB,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;IAmBrC,gBAAgB,CAAC,EACrB,aAAa,EACb,UAAU,GACX,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;CAsC5C"}
@@ -1,4 +1,5 @@
1
1
  import { type Bip44Account } from "@metamask/account-api";
2
+ import type { TraceCallback } from "@metamask/controller-utils";
2
3
  import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
3
4
  import type { InternalAccount } from "@metamask/keyring-internal-api";
4
5
  import type { SnapId } from "@metamask/snaps-sdk";
@@ -7,10 +8,9 @@ import type { MultichainAccountServiceMessenger } from "../types.mjs";
7
8
  export type TrxAccountProviderConfig = SnapAccountProviderConfig;
8
9
  export declare const TRX_ACCOUNT_PROVIDER_NAME: "Tron";
9
10
  export declare class TrxAccountProvider extends SnapAccountProvider {
10
- #private;
11
11
  static NAME: "Tron";
12
12
  static TRX_SNAP_ID: SnapId;
13
- constructor(messenger: MultichainAccountServiceMessenger, config?: TrxAccountProviderConfig);
13
+ constructor(messenger: MultichainAccountServiceMessenger, config?: TrxAccountProviderConfig, trace?: TraceCallback);
14
14
  getName(): string;
15
15
  isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
16
16
  createAccounts({ entropySource, groupIndex: index, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"TrxAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/TrxAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,YAAY,EAAE,8BAA8B;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAG7E,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAIlD,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC/B,kCAA8B;AAE/B,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,MAAM,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAEjE,eAAO,MAAM,yBAAyB,QAAkB,CAAC;AAEzD,qBAAa,kBAAmB,SAAQ,mBAAmB;;IACzD,MAAM,CAAC,IAAI,SAA6B;IAExC,MAAM,CAAC,WAAW,SAA8C;gBAK9D,SAAS,EAAE,iCAAi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