@metamask/multichain-account-service 8.0.0 → 9.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.
- package/CHANGELOG.md +45 -12
- package/dist/MultichainAccountGroup.cjs.map +1 -1
- package/dist/MultichainAccountGroup.d.cts.map +1 -1
- package/dist/MultichainAccountGroup.d.mts.map +1 -1
- package/dist/MultichainAccountGroup.mjs.map +1 -1
- package/dist/MultichainAccountService-method-action-types.cjs.map +1 -1
- package/dist/MultichainAccountService-method-action-types.d.cts +9 -1
- package/dist/MultichainAccountService-method-action-types.d.cts.map +1 -1
- package/dist/MultichainAccountService-method-action-types.d.mts +9 -1
- package/dist/MultichainAccountService-method-action-types.d.mts.map +1 -1
- package/dist/MultichainAccountService-method-action-types.mjs.map +1 -1
- package/dist/MultichainAccountService.cjs +1 -0
- package/dist/MultichainAccountService.cjs.map +1 -1
- package/dist/MultichainAccountService.d.cts.map +1 -1
- package/dist/MultichainAccountService.d.mts.map +1 -1
- package/dist/MultichainAccountService.mjs +1 -0
- package/dist/MultichainAccountService.mjs.map +1 -1
- package/dist/MultichainAccountWallet.cjs.map +1 -1
- package/dist/MultichainAccountWallet.d.cts.map +1 -1
- package/dist/MultichainAccountWallet.d.mts.map +1 -1
- package/dist/MultichainAccountWallet.mjs.map +1 -1
- package/dist/analytics/perf.cjs +1 -1
- package/dist/analytics/perf.cjs.map +1 -1
- package/dist/analytics/perf.mjs +1 -1
- package/dist/analytics/perf.mjs.map +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +2 -2
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providers/AccountProviderWrapper.cjs.map +1 -1
- package/dist/providers/AccountProviderWrapper.d.cts +3 -2
- package/dist/providers/AccountProviderWrapper.d.cts.map +1 -1
- package/dist/providers/AccountProviderWrapper.d.mts +3 -2
- package/dist/providers/AccountProviderWrapper.d.mts.map +1 -1
- package/dist/providers/AccountProviderWrapper.mjs.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.cjs +29 -0
- package/dist/providers/BaseBip44AccountProvider.cjs.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.d.cts +29 -2
- package/dist/providers/BaseBip44AccountProvider.d.cts.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.d.mts +29 -2
- package/dist/providers/BaseBip44AccountProvider.d.mts.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.mjs +29 -0
- package/dist/providers/BaseBip44AccountProvider.mjs.map +1 -1
- package/dist/providers/BtcAccountProvider.cjs +2 -2
- package/dist/providers/BtcAccountProvider.cjs.map +1 -1
- package/dist/providers/BtcAccountProvider.d.cts +3 -2
- package/dist/providers/BtcAccountProvider.d.cts.map +1 -1
- package/dist/providers/BtcAccountProvider.d.mts +3 -2
- package/dist/providers/BtcAccountProvider.d.mts.map +1 -1
- package/dist/providers/BtcAccountProvider.mjs +2 -2
- package/dist/providers/BtcAccountProvider.mjs.map +1 -1
- package/dist/providers/EvmAccountProvider.cjs +63 -46
- package/dist/providers/EvmAccountProvider.cjs.map +1 -1
- package/dist/providers/EvmAccountProvider.d.cts +3 -2
- package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
- package/dist/providers/EvmAccountProvider.d.mts +3 -2
- package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
- package/dist/providers/EvmAccountProvider.mjs +63 -46
- package/dist/providers/EvmAccountProvider.mjs.map +1 -1
- package/dist/providers/SnapAccountProvider.cjs +2 -2
- package/dist/providers/SnapAccountProvider.cjs.map +1 -1
- package/dist/providers/SnapAccountProvider.d.cts +1 -1
- package/dist/providers/SnapAccountProvider.d.cts.map +1 -1
- package/dist/providers/SnapAccountProvider.d.mts +1 -1
- package/dist/providers/SnapAccountProvider.d.mts.map +1 -1
- package/dist/providers/SnapAccountProvider.mjs +2 -2
- package/dist/providers/SnapAccountProvider.mjs.map +1 -1
- package/dist/providers/SolAccountProvider.cjs +2 -2
- package/dist/providers/SolAccountProvider.cjs.map +1 -1
- package/dist/providers/SolAccountProvider.d.cts +3 -2
- package/dist/providers/SolAccountProvider.d.cts.map +1 -1
- package/dist/providers/SolAccountProvider.d.mts +3 -2
- package/dist/providers/SolAccountProvider.d.mts.map +1 -1
- package/dist/providers/SolAccountProvider.mjs +2 -2
- package/dist/providers/SolAccountProvider.mjs.map +1 -1
- package/dist/providers/TrxAccountProvider.cjs +2 -2
- package/dist/providers/TrxAccountProvider.cjs.map +1 -1
- package/dist/providers/TrxAccountProvider.d.cts +3 -2
- package/dist/providers/TrxAccountProvider.d.cts.map +1 -1
- package/dist/providers/TrxAccountProvider.d.mts +3 -2
- package/dist/providers/TrxAccountProvider.d.mts.map +1 -1
- package/dist/providers/TrxAccountProvider.mjs +2 -2
- package/dist/providers/TrxAccountProvider.mjs.map +1 -1
- package/dist/providers/utils.cjs +13 -1
- package/dist/providers/utils.cjs.map +1 -1
- package/dist/providers/utils.d.cts +7 -0
- package/dist/providers/utils.d.cts.map +1 -1
- package/dist/providers/utils.d.mts +7 -0
- package/dist/providers/utils.d.mts.map +1 -1
- package/dist/providers/utils.mjs +11 -0
- package/dist/providers/utils.mjs.map +1 -1
- package/dist/tests/accounts.cjs +4 -6
- package/dist/tests/accounts.cjs.map +1 -1
- package/dist/tests/accounts.d.cts +8 -21
- package/dist/tests/accounts.d.cts.map +1 -1
- package/dist/tests/accounts.d.mts +8 -21
- package/dist/tests/accounts.d.mts.map +1 -1
- package/dist/tests/accounts.mjs +4 -6
- package/dist/tests/accounts.mjs.map +1 -1
- package/dist/tests/messenger.cjs +1 -0
- package/dist/tests/messenger.cjs.map +1 -1
- package/dist/tests/messenger.d.cts.map +1 -1
- package/dist/tests/messenger.d.mts.map +1 -1
- package/dist/tests/messenger.mjs +1 -0
- package/dist/tests/messenger.mjs.map +1 -1
- package/dist/tests/providers.cjs.map +1 -1
- package/dist/tests/providers.d.cts +2 -1
- package/dist/tests/providers.d.cts.map +1 -1
- package/dist/tests/providers.d.mts +2 -1
- package/dist/tests/providers.d.mts.map +1 -1
- package/dist/tests/providers.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +4 -4
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +4 -4
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +32 -31
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,qBAAiB;AACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,qBAAiB;AACtC,OAAO,EACL,8BAA8B,EAC9B,cAAc,EACf,8BAA0B;AAC3B,OAAO,EAAE,iBAAiB,EAAE,oBAAgB;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CACzB,SAAwD,EACxD,OAAe,EACf,KAAc,EACd,OAAiC;IAEjC,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,8BAA8B,CAAC,KAAK,CAAC,EAAE,CAAC;QACnE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACpC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAE9B,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAc,EAAE,OAAO,CAAC,CAAC;QACxE,SAAS,CAAC,gBAAgB,EAAE,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["import { logErrorAs } from './logger';\nimport {\n isKeyringControllerLockedError,\n isTimeoutError,\n} from './providers/utils';\nimport { createSentryError } from './utils';\n\n/**\n * Reports an error by logging it and optionally capturing it in Sentry.\n *\n * Timeout errors are treated as warnings (not reported to Sentry). All other\n * errors are logged as errors and captured via `captureException`.\n *\n * @param messenger - Object with an optional `captureException` method.\n * @param messenger.captureException - Optional method to capture exceptions in Sentry.\n * @param message - The static message describing what failed.\n * @param error - The caught error.\n * @param context - Optional context to attach to the Sentry error.\n */\nexport function reportError(\n messenger: { captureException?: (error: Error) => void },\n message: string,\n error: unknown,\n context?: Record<string, unknown>,\n): void {\n if (isTimeoutError(error) || isKeyringControllerLockedError(error)) {\n logErrorAs('warn', message, error);\n console.warn(message, error);\n } else {\n logErrorAs('error', message, error);\n console.error(message, error);\n\n const sentryError = createSentryError(message, error as Error, context);\n messenger.captureException?.(sentryError);\n }\n}\n"]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAyBA,mDAaqB;AAZnB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,gHAAA,mBAAmB,OAAA;AACnB,yGAAA,YAAY,OAAA;AACZ,sHAAA,yBAAyB,OAAA;AACzB,+GAAA,kBAAkB,OAAA;AAClB,sHAAA,yBAAyB,OAAA;AACzB,+GAAA,kBAAkB,OAAA;AAClB,sHAAA,yBAAyB,OAAA;AACzB,+GAAA,kBAAkB,OAAA;AAClB,sHAAA,yBAAyB,OAAA;AACzB,+GAAA,kBAAkB,OAAA;AAEpB,yEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,uEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,2EAAsE;AAA7D,oIAAA,wBAAwB,OAAA","sourcesContent":["export type {\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n MultichainAccountServiceMultichainAccountGroupCreatedEvent,\n MultichainAccountServiceMultichainAccountGroupUpdatedEvent,\n MultichainAccountServiceWalletStatusChangeEvent,\n} from './types';\nexport type {\n MultichainAccountServiceResyncAccountsAction,\n MultichainAccountServiceEnsureCanUseSnapPlatformAction,\n MultichainAccountServiceGetMultichainAccountWalletAction,\n MultichainAccountServiceGetMultichainAccountWalletsAction,\n MultichainAccountServiceCreateMultichainAccountWalletAction,\n MultichainAccountServiceRemoveMultichainAccountWalletAction,\n MultichainAccountServiceGetMultichainAccountGroupAction,\n MultichainAccountServiceGetMultichainAccountGroupsAction,\n MultichainAccountServiceCreateNextMultichainAccountGroupAction,\n MultichainAccountServiceCreateMultichainAccountGroupAction,\n MultichainAccountServiceCreateMultichainAccountGroupsAction,\n MultichainAccountServiceSetBasicFunctionalityAction,\n MultichainAccountServiceAlignWalletsAction,\n MultichainAccountServiceAlignWalletAction,\n MultichainAccountServiceInitAction,\n} from './MultichainAccountService-method-action-types';\nexport {\n AccountProviderWrapper,\n BaseBip44AccountProvider,\n SnapAccountProvider,\n TimeoutError,\n EVM_ACCOUNT_PROVIDER_NAME,\n EvmAccountProvider,\n SOL_ACCOUNT_PROVIDER_NAME,\n SolAccountProvider,\n BTC_ACCOUNT_PROVIDER_NAME,\n BtcAccountProvider,\n TRX_ACCOUNT_PROVIDER_NAME,\n TrxAccountProvider,\n} from './providers';\nexport { MultichainAccountWallet } from './MultichainAccountWallet';\nexport { MultichainAccountGroup } from './MultichainAccountGroup';\nexport { MultichainAccountService } from './MultichainAccountService';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, MultichainAccountServiceMultichainAccountGroupCreatedEvent, MultichainAccountServiceMultichainAccountGroupUpdatedEvent, MultichainAccountServiceWalletStatusChangeEvent, } from "./types.cjs";
|
|
2
|
-
export type { MultichainAccountServiceResyncAccountsAction, MultichainAccountServiceEnsureCanUseSnapPlatformAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceCreateMultichainAccountWalletAction, MultichainAccountServiceRemoveMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountGroupAction, MultichainAccountServiceGetMultichainAccountGroupsAction, MultichainAccountServiceCreateNextMultichainAccountGroupAction, MultichainAccountServiceCreateMultichainAccountGroupAction, MultichainAccountServiceCreateMultichainAccountGroupsAction, MultichainAccountServiceSetBasicFunctionalityAction, MultichainAccountServiceAlignWalletsAction, MultichainAccountServiceAlignWalletAction, } from "./MultichainAccountService-method-action-types.cjs";
|
|
2
|
+
export type { MultichainAccountServiceResyncAccountsAction, MultichainAccountServiceEnsureCanUseSnapPlatformAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceCreateMultichainAccountWalletAction, MultichainAccountServiceRemoveMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountGroupAction, MultichainAccountServiceGetMultichainAccountGroupsAction, MultichainAccountServiceCreateNextMultichainAccountGroupAction, MultichainAccountServiceCreateMultichainAccountGroupAction, MultichainAccountServiceCreateMultichainAccountGroupsAction, MultichainAccountServiceSetBasicFunctionalityAction, MultichainAccountServiceAlignWalletsAction, MultichainAccountServiceAlignWalletAction, MultichainAccountServiceInitAction, } from "./MultichainAccountService-method-action-types.cjs";
|
|
3
3
|
export { AccountProviderWrapper, BaseBip44AccountProvider, SnapAccountProvider, TimeoutError, EVM_ACCOUNT_PROVIDER_NAME, EvmAccountProvider, SOL_ACCOUNT_PROVIDER_NAME, SolAccountProvider, BTC_ACCOUNT_PROVIDER_NAME, BtcAccountProvider, TRX_ACCOUNT_PROVIDER_NAME, TrxAccountProvider, } from "./providers/index.cjs";
|
|
4
4
|
export { MultichainAccountWallet } from "./MultichainAccountWallet.cjs";
|
|
5
5
|
export { MultichainAccountGroup } from "./MultichainAccountGroup.cjs";
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,0DAA0D,EAC1D,0DAA0D,EAC1D,+CAA+C,GAChD,oBAAgB;AACjB,YAAY,EACV,4CAA4C,EAC5C,sDAAsD,EACtD,wDAAwD,EACxD,yDAAyD,EACzD,2DAA2D,EAC3D,2DAA2D,EAC3D,uDAAuD,EACvD,wDAAwD,EACxD,8DAA8D,EAC9D,0DAA0D,EAC1D,2DAA2D,EAC3D,mDAAmD,EACnD,0CAA0C,EAC1C,yCAAyC,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,0DAA0D,EAC1D,0DAA0D,EAC1D,+CAA+C,GAChD,oBAAgB;AACjB,YAAY,EACV,4CAA4C,EAC5C,sDAAsD,EACtD,wDAAwD,EACxD,yDAAyD,EACzD,2DAA2D,EAC3D,2DAA2D,EAC3D,uDAAuD,EACvD,wDAAwD,EACxD,8DAA8D,EAC9D,0DAA0D,EAC1D,2DAA2D,EAC3D,mDAAmD,EACnD,0CAA0C,EAC1C,yCAAyC,EACzC,kCAAkC,GACnC,2DAAuD;AACxD,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,GACnB,8BAAoB;AACrB,OAAO,EAAE,uBAAuB,EAAE,sCAAkC;AACpE,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, MultichainAccountServiceMultichainAccountGroupCreatedEvent, MultichainAccountServiceMultichainAccountGroupUpdatedEvent, MultichainAccountServiceWalletStatusChangeEvent, } from "./types.mjs";
|
|
2
|
-
export type { MultichainAccountServiceResyncAccountsAction, MultichainAccountServiceEnsureCanUseSnapPlatformAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceCreateMultichainAccountWalletAction, MultichainAccountServiceRemoveMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountGroupAction, MultichainAccountServiceGetMultichainAccountGroupsAction, MultichainAccountServiceCreateNextMultichainAccountGroupAction, MultichainAccountServiceCreateMultichainAccountGroupAction, MultichainAccountServiceCreateMultichainAccountGroupsAction, MultichainAccountServiceSetBasicFunctionalityAction, MultichainAccountServiceAlignWalletsAction, MultichainAccountServiceAlignWalletAction, } from "./MultichainAccountService-method-action-types.mjs";
|
|
2
|
+
export type { MultichainAccountServiceResyncAccountsAction, MultichainAccountServiceEnsureCanUseSnapPlatformAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceCreateMultichainAccountWalletAction, MultichainAccountServiceRemoveMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountGroupAction, MultichainAccountServiceGetMultichainAccountGroupsAction, MultichainAccountServiceCreateNextMultichainAccountGroupAction, MultichainAccountServiceCreateMultichainAccountGroupAction, MultichainAccountServiceCreateMultichainAccountGroupsAction, MultichainAccountServiceSetBasicFunctionalityAction, MultichainAccountServiceAlignWalletsAction, MultichainAccountServiceAlignWalletAction, MultichainAccountServiceInitAction, } from "./MultichainAccountService-method-action-types.mjs";
|
|
3
3
|
export { AccountProviderWrapper, BaseBip44AccountProvider, SnapAccountProvider, TimeoutError, EVM_ACCOUNT_PROVIDER_NAME, EvmAccountProvider, SOL_ACCOUNT_PROVIDER_NAME, SolAccountProvider, BTC_ACCOUNT_PROVIDER_NAME, BtcAccountProvider, TRX_ACCOUNT_PROVIDER_NAME, TrxAccountProvider, } from "./providers/index.mjs";
|
|
4
4
|
export { MultichainAccountWallet } from "./MultichainAccountWallet.mjs";
|
|
5
5
|
export { MultichainAccountGroup } from "./MultichainAccountGroup.mjs";
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,0DAA0D,EAC1D,0DAA0D,EAC1D,+CAA+C,GAChD,oBAAgB;AACjB,YAAY,EACV,4CAA4C,EAC5C,sDAAsD,EACtD,wDAAwD,EACxD,yDAAyD,EACzD,2DAA2D,EAC3D,2DAA2D,EAC3D,uDAAuD,EACvD,wDAAwD,EACxD,8DAA8D,EAC9D,0DAA0D,EAC1D,2DAA2D,EAC3D,mDAAmD,EACnD,0CAA0C,EAC1C,yCAAyC,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,0DAA0D,EAC1D,0DAA0D,EAC1D,+CAA+C,GAChD,oBAAgB;AACjB,YAAY,EACV,4CAA4C,EAC5C,sDAAsD,EACtD,wDAAwD,EACxD,yDAAyD,EACzD,2DAA2D,EAC3D,2DAA2D,EAC3D,uDAAuD,EACvD,wDAAwD,EACxD,8DAA8D,EAC9D,0DAA0D,EAC1D,2DAA2D,EAC3D,mDAAmD,EACnD,0CAA0C,EAC1C,yCAAyC,EACzC,kCAAkC,GACnC,2DAAuD;AACxD,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,GACnB,8BAAoB;AACrB,OAAO,EAAE,uBAAuB,EAAE,sCAAkC;AACpE,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EACnB,8BAAoB;AACrB,OAAO,EAAE,uBAAuB,EAAE,sCAAkC;AACpE,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC","sourcesContent":["export type {\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n MultichainAccountServiceMultichainAccountGroupCreatedEvent,\n MultichainAccountServiceMultichainAccountGroupUpdatedEvent,\n MultichainAccountServiceWalletStatusChangeEvent,\n} from './types';\nexport type {\n MultichainAccountServiceResyncAccountsAction,\n MultichainAccountServiceEnsureCanUseSnapPlatformAction,\n MultichainAccountServiceGetMultichainAccountWalletAction,\n MultichainAccountServiceGetMultichainAccountWalletsAction,\n MultichainAccountServiceCreateMultichainAccountWalletAction,\n MultichainAccountServiceRemoveMultichainAccountWalletAction,\n MultichainAccountServiceGetMultichainAccountGroupAction,\n MultichainAccountServiceGetMultichainAccountGroupsAction,\n MultichainAccountServiceCreateNextMultichainAccountGroupAction,\n MultichainAccountServiceCreateMultichainAccountGroupAction,\n MultichainAccountServiceCreateMultichainAccountGroupsAction,\n MultichainAccountServiceSetBasicFunctionalityAction,\n MultichainAccountServiceAlignWalletsAction,\n MultichainAccountServiceAlignWalletAction,\n MultichainAccountServiceInitAction,\n} from './MultichainAccountService-method-action-types';\nexport {\n AccountProviderWrapper,\n BaseBip44AccountProvider,\n SnapAccountProvider,\n TimeoutError,\n EVM_ACCOUNT_PROVIDER_NAME,\n EvmAccountProvider,\n SOL_ACCOUNT_PROVIDER_NAME,\n SolAccountProvider,\n BTC_ACCOUNT_PROVIDER_NAME,\n BtcAccountProvider,\n TRX_ACCOUNT_PROVIDER_NAME,\n TrxAccountProvider,\n} from './providers';\nexport { MultichainAccountWallet } from './MultichainAccountWallet';\nexport { MultichainAccountGroup } from './MultichainAccountGroup';\nexport { MultichainAccountService } from './MultichainAccountService';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountProviderWrapper.cjs","sourceRoot":"","sources":["../../src/providers/AccountProviderWrapper.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AccountProviderWrapper.cjs","sourceRoot":"","sources":["../../src/providers/AccountProviderWrapper.ts"],"names":[],"mappings":";;;AAUA,6EAAsE;AAEtE;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,mDAAwB;IAKlE,YACE,SAA4C,EAC5C,QAAkC;QAElC,KAAK,CAAC,SAAS,CAAC,CAAC;QARX,cAAS,GAAY,IAAI,CAAC;QAShC,IAAI,CAAC,QAAQ,GAAG,QAA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CAAC,cAAc,CAClB,OAA6B;QAE7B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,gBAAgB,CAAC,OAGtB;QACC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACF;AAtID,wDAsIC;AAED;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,QAAiB;IAEjB,OAAO,QAAQ,YAAY,sBAAsB,CAAC;AACpD,CAAC;AAJD,4DAIC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport type {\n CreateAccountOptions,\n EntropySourceId,\n KeyringAccount,\n} from '@metamask/keyring-api';\nimport type { KeyringCapabilities } from '@metamask/keyring-api/v2';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\nimport { BaseBip44AccountProvider } from './BaseBip44AccountProvider';\n\n/**\n * A simple wrapper that adds disable functionality to any BaseBip44AccountProvider.\n * When disabled, the provider will not create new accounts and return empty results.\n */\nexport class AccountProviderWrapper extends BaseBip44AccountProvider {\n private isEnabled: boolean = true;\n\n private readonly provider: BaseBip44AccountProvider;\n\n constructor(\n messenger: MultichainAccountServiceMessenger,\n provider: BaseBip44AccountProvider,\n ) {\n super(messenger);\n this.provider = provider;\n }\n\n override getName(): string {\n return this.provider.getName();\n }\n\n get capabilities(): KeyringCapabilities {\n return this.provider.capabilities;\n }\n\n /**\n * Forward initialization to the wrapped provider to ensure both\n * instances share the same visible account IDs.\n *\n * @param accounts - Account IDs to initialize with.\n */\n override init(accounts: Bip44Account<KeyringAccount>['id'][]): void {\n this.provider.init(accounts);\n }\n\n /**\n * Set the enabled state for this provider.\n *\n * @param enabled - Whether the provider should be enabled.\n */\n setEnabled(enabled: boolean): void {\n this.isEnabled = enabled;\n }\n\n /**\n * Check if the provider is disabled.\n *\n * @returns True if the provider is disabled, false otherwise.\n */\n isDisabled(): boolean {\n return !this.isEnabled;\n }\n\n /**\n * Override resyncAccounts to not execute it when disabled.\n *\n * @param accounts - List of local accounts.\n */\n override async resyncAccounts(\n accounts: Bip44Account<InternalAccount>[],\n ): Promise<void> {\n if (!this.isEnabled) {\n return;\n }\n await this.provider.resyncAccounts(accounts);\n }\n\n /**\n * Override getAccounts to return empty array when disabled.\n *\n * @returns Array of accounts, or empty array if disabled.\n */\n override getAccounts(): Bip44Account<KeyringAccount>[] {\n if (!this.isEnabled) {\n return [];\n }\n return this.provider.getAccounts();\n }\n\n /**\n * Override getAccount to throw when disabled.\n *\n * @param id - The account ID to retrieve.\n * @returns The account with the specified ID.\n * @throws When disabled or account not found.\n */\n override getAccount(\n id: Bip44Account<KeyringAccount>['id'],\n ): Bip44Account<KeyringAccount> {\n if (!this.isEnabled) {\n throw new Error('Provider is disabled');\n }\n return this.provider.getAccount(id);\n }\n\n /**\n * Implement abstract method: Check if account is compatible.\n * Delegates directly to wrapped provider - no runtime checks needed!\n *\n * @param account - The account to check.\n * @returns True if the account is compatible.\n */\n isAccountCompatible(account: Bip44Account<KeyringAccount>): boolean {\n return this.provider.isAccountCompatible(account);\n }\n\n /**\n * Implement abstract method: Create accounts, returns empty array when disabled.\n *\n * @param options - Account creation options.\n * @returns Promise resolving to created accounts, or empty array if disabled.\n */\n async createAccounts(\n options: CreateAccountOptions,\n ): Promise<Bip44Account<KeyringAccount>[]> {\n if (!this.isEnabled) {\n return [];\n }\n return this.provider.createAccounts(options);\n }\n\n /**\n * Implement abstract method: Discover and create accounts, returns empty array when disabled.\n *\n * @param options - Account discovery options.\n * @param options.entropySource - The entropy source to use.\n * @param options.groupIndex - The group index to use.\n * @returns Promise resolving to discovered accounts, or empty array if disabled.\n */\n async discoverAccounts(options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n if (!this.isEnabled) {\n return [];\n }\n return this.provider.discoverAccounts(options);\n }\n}\n\n/**\n * Simple type guard to check if a provider is wrapped.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is an AccountProviderWrapper.\n */\nexport function isAccountProviderWrapper(\n provider: unknown,\n): provider is AccountProviderWrapper {\n return provider instanceof AccountProviderWrapper;\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Bip44Account } from "@metamask/account-api";
|
|
2
|
-
import type { CreateAccountOptions, EntropySourceId, KeyringAccount
|
|
2
|
+
import type { CreateAccountOptions, EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
|
|
3
|
+
import type { KeyringCapabilities } from "@metamask/keyring-api/v2";
|
|
3
4
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
4
|
-
import { BaseBip44AccountProvider } from "./BaseBip44AccountProvider.cjs";
|
|
5
5
|
import type { MultichainAccountServiceMessenger } from "../types.cjs";
|
|
6
|
+
import { BaseBip44AccountProvider } from "./BaseBip44AccountProvider.cjs";
|
|
6
7
|
/**
|
|
7
8
|
* A simple wrapper that adds disable functionality to any BaseBip44AccountProvider.
|
|
8
9
|
* When disabled, the provider will not create new accounts and return empty results.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountProviderWrapper.d.cts","sourceRoot":"","sources":["../../src/providers/AccountProviderWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAC1D,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,cAAc,
|
|
1
|
+
{"version":3,"file":"AccountProviderWrapper.d.cts","sourceRoot":"","sources":["../../src/providers/AccountProviderWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA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AgB,CAAC,OAAO,EAAE;QAC9B,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;CAM5C;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,sBAAsB,CAEpC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Bip44Account } from "@metamask/account-api";
|
|
2
|
-
import type { CreateAccountOptions, EntropySourceId, KeyringAccount
|
|
2
|
+
import type { CreateAccountOptions, EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
|
|
3
|
+
import type { KeyringCapabilities } from "@metamask/keyring-api/v2";
|
|
3
4
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
4
|
-
import { BaseBip44AccountProvider } from "./BaseBip44AccountProvider.mjs";
|
|
5
5
|
import type { MultichainAccountServiceMessenger } from "../types.mjs";
|
|
6
|
+
import { BaseBip44AccountProvider } from "./BaseBip44AccountProvider.mjs";
|
|
6
7
|
/**
|
|
7
8
|
* A simple wrapper that adds disable functionality to any BaseBip44AccountProvider.
|
|
8
9
|
* When disabled, the provider will not create new accounts and return empty results.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountProviderWrapper.d.mts","sourceRoot":"","sources":["../../src/providers/AccountProviderWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAC1D,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,cAAc,
|
|
1
|
+
{"version":3,"file":"AccountProviderWrapper.d.mts","sourceRoot":"","sources":["../../src/providers/AccountProviderWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAC1D,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,cAAc,EACf,8BAA8B;AAC/B,OAAO,KA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pB,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;CAM5C;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,sBAAsB,CAEpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountProviderWrapper.mjs","sourceRoot":"","sources":["../../src/providers/AccountProviderWrapper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AccountProviderWrapper.mjs","sourceRoot":"","sources":["../../src/providers/AccountProviderWrapper.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AAEtE;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,wBAAwB;IAKlE,YACE,SAA4C,EAC5C,QAAkC;QAElC,KAAK,CAAC,SAAS,CAAC,CAAC;QARX,cAAS,GAAY,IAAI,CAAC;QAShC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEQ,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACM,IAAI,CAAC,QAA8C;QAC1D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,OAAgB;QACzB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAC,cAAc,CAC3B,QAAyC;QAEzC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QACD,MAAM,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACM,WAAW;QAClB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACM,UAAU,CACjB,EAAsC;QAEtC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACH,mBAAmB,CAAC,OAAqC;QACvD,OAAO,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,cAAc,CAClB,OAA6B;QAE7B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,gBAAgB,CAAC,OAGtB;QACC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAiB;IAEjB,OAAO,QAAQ,YAAY,sBAAsB,CAAC;AACpD,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport type {\n CreateAccountOptions,\n EntropySourceId,\n KeyringAccount,\n} from '@metamask/keyring-api';\nimport type { KeyringCapabilities } from '@metamask/keyring-api/v2';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\nimport { BaseBip44AccountProvider } from './BaseBip44AccountProvider';\n\n/**\n * A simple wrapper that adds disable functionality to any BaseBip44AccountProvider.\n * When disabled, the provider will not create new accounts and return empty results.\n */\nexport class AccountProviderWrapper extends BaseBip44AccountProvider {\n private isEnabled: boolean = true;\n\n private readonly provider: BaseBip44AccountProvider;\n\n constructor(\n messenger: MultichainAccountServiceMessenger,\n provider: BaseBip44AccountProvider,\n ) {\n super(messenger);\n this.provider = provider;\n }\n\n override getName(): string {\n return this.provider.getName();\n }\n\n get capabilities(): KeyringCapabilities {\n return this.provider.capabilities;\n }\n\n /**\n * Forward initialization to the wrapped provider to ensure both\n * instances share the same visible account IDs.\n *\n * @param accounts - Account IDs to initialize with.\n */\n override init(accounts: Bip44Account<KeyringAccount>['id'][]): void {\n this.provider.init(accounts);\n }\n\n /**\n * Set the enabled state for this provider.\n *\n * @param enabled - Whether the provider should be enabled.\n */\n setEnabled(enabled: boolean): void {\n this.isEnabled = enabled;\n }\n\n /**\n * Check if the provider is disabled.\n *\n * @returns True if the provider is disabled, false otherwise.\n */\n isDisabled(): boolean {\n return !this.isEnabled;\n }\n\n /**\n * Override resyncAccounts to not execute it when disabled.\n *\n * @param accounts - List of local accounts.\n */\n override async resyncAccounts(\n accounts: Bip44Account<InternalAccount>[],\n ): Promise<void> {\n if (!this.isEnabled) {\n return;\n }\n await this.provider.resyncAccounts(accounts);\n }\n\n /**\n * Override getAccounts to return empty array when disabled.\n *\n * @returns Array of accounts, or empty array if disabled.\n */\n override getAccounts(): Bip44Account<KeyringAccount>[] {\n if (!this.isEnabled) {\n return [];\n }\n return this.provider.getAccounts();\n }\n\n /**\n * Override getAccount to throw when disabled.\n *\n * @param id - The account ID to retrieve.\n * @returns The account with the specified ID.\n * @throws When disabled or account not found.\n */\n override getAccount(\n id: Bip44Account<KeyringAccount>['id'],\n ): Bip44Account<KeyringAccount> {\n if (!this.isEnabled) {\n throw new Error('Provider is disabled');\n }\n return this.provider.getAccount(id);\n }\n\n /**\n * Implement abstract method: Check if account is compatible.\n * Delegates directly to wrapped provider - no runtime checks needed!\n *\n * @param account - The account to check.\n * @returns True if the account is compatible.\n */\n isAccountCompatible(account: Bip44Account<KeyringAccount>): boolean {\n return this.provider.isAccountCompatible(account);\n }\n\n /**\n * Implement abstract method: Create accounts, returns empty array when disabled.\n *\n * @param options - Account creation options.\n * @returns Promise resolving to created accounts, or empty array if disabled.\n */\n async createAccounts(\n options: CreateAccountOptions,\n ): Promise<Bip44Account<KeyringAccount>[]> {\n if (!this.isEnabled) {\n return [];\n }\n return this.provider.createAccounts(options);\n }\n\n /**\n * Implement abstract method: Discover and create accounts, returns empty array when disabled.\n *\n * @param options - Account discovery options.\n * @param options.entropySource - The entropy source to use.\n * @param options.groupIndex - The group index to use.\n * @returns Promise resolving to discovered accounts, or empty array if disabled.\n */\n async discoverAccounts(options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n if (!this.isEnabled) {\n return [];\n }\n return this.provider.discoverAccounts(options);\n }\n}\n\n/**\n * Simple type guard to check if a provider is wrapped.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is an AccountProviderWrapper.\n */\nexport function isAccountProviderWrapper(\n provider: unknown,\n): provider is AccountProviderWrapper {\n return provider instanceof AccountProviderWrapper;\n}\n"]}
|
|
@@ -75,6 +75,17 @@ class BaseBip44AccountProvider {
|
|
|
75
75
|
// but we know that the account is BIP-44 compatible here so it is safe to do so
|
|
76
76
|
return this.messenger.call('AccountsController:getAccount', id);
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Run an operation against a V1 keyring selected by `selector`.
|
|
80
|
+
*
|
|
81
|
+
* Forwards to `KeyringController:withKeyring`. Use this for keyrings that
|
|
82
|
+
* have not yet migrated to the unified V2 `Keyring` interface (e.g. the
|
|
83
|
+
* snap keyring).
|
|
84
|
+
*
|
|
85
|
+
* @param selector - The selector identifying the keyring.
|
|
86
|
+
* @param operation - The operation to run with the selected keyring.
|
|
87
|
+
* @returns The result of the operation.
|
|
88
|
+
*/
|
|
78
89
|
async withKeyring(selector, operation) {
|
|
79
90
|
const result = await this.messenger.call('KeyringController:withKeyring', selector, ({ keyring, metadata }) => operation({
|
|
80
91
|
keyring: keyring,
|
|
@@ -82,6 +93,24 @@ class BaseBip44AccountProvider {
|
|
|
82
93
|
}));
|
|
83
94
|
return result;
|
|
84
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Run an operation against a V2 keyring selected by `selector`.
|
|
98
|
+
*
|
|
99
|
+
* Forwards to `KeyringController:withKeyringV2`. Use this for keyrings
|
|
100
|
+
* that implement the unified V2 `Keyring` interface from
|
|
101
|
+
* `@metamask/keyring-api/v2`.
|
|
102
|
+
*
|
|
103
|
+
* @param selector - The selector identifying the keyring.
|
|
104
|
+
* @param operation - The operation to run with the selected keyring.
|
|
105
|
+
* @returns The result of the operation.
|
|
106
|
+
*/
|
|
107
|
+
async withKeyringV2(selector, operation) {
|
|
108
|
+
const result = await this.messenger.call('KeyringController:withKeyringV2', selector, ({ keyring, metadata }) => operation({
|
|
109
|
+
keyring: keyring,
|
|
110
|
+
metadata,
|
|
111
|
+
}));
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
85
114
|
}
|
|
86
115
|
exports.BaseBip44AccountProvider = BaseBip44AccountProvider;
|
|
87
116
|
_BaseBip44AccountProvider_instances = new WeakSet(), _BaseBip44AccountProvider_getAccountIds = function _BaseBip44AccountProvider_getAccountIds() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseBip44AccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/BaseBip44AccountProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uDAAuD;
|
|
1
|
+
{"version":3,"file":"BaseBip44AccountProvider.cjs","sourceRoot":"","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;QAChF,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CACxB,+BAA+B,EAC/B,EAAE,CACmB,CAAC;IAC1B,CAAC;IAED;;;;;;;;;;OAUG;IACO,KAAK,CAAC,WAAW,CACzB,QAAyB,EACzB,SAM6B;QAE7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACtC,+BAA+B,EAC/B,QAAQ,EACR,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CACxB,SAAS,CAAC;YACR,OAAO,EAAE,OAA0B;YACnC,QAAQ;SACT,CAAC,CACL,CAAC;QAEF,OAAO,MAAwB,CAAC;IAClC,CAAC;IAED;;;;;;;;;;OAUG;IACO,KAAK,CAAC,aAAa,CAI3B,QAA4C,EAC5C,SAM6B;QAE7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACtC,iCAAiC,EACjC,QAAQ,EACR,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CACxB,SAAS,CAAC;YACR,OAAO,EAAE,OAA0B;YACnC,QAAQ;SACT,CAAC,CACL,CAAC;QAEF,OAAO,MAAwB,CAAC;IAClC,CAAC;CAqBF;AAhKD,4DAgKC;;IAlIG,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { isBip44Account } from '@metamask/account-api';\nimport type { AccountProvider, Bip44Account } from '@metamask/account-api';\nimport type {\n CreateAccountOptions,\n EntropySourceId,\n KeyringAccount,\n} from '@metamask/keyring-api';\nimport type {\n Keyring as KeyringV2,\n KeyringCapabilities,\n} from '@metamask/keyring-api/v2';\nimport type {\n KeyringMetadata,\n KeyringSelector,\n KeyringSelectorV2,\n} from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\n/**\n * Asserts a keyring account is BIP-44 compatible.\n *\n * @param account - Keyring account to check.\n * @throws If the keyring account is not compatible.\n */\nexport function assertIsBip44Account(\n account: KeyringAccount,\n): asserts account is Bip44Account<KeyringAccount> {\n if (!isBip44Account(account)) {\n throw new Error('Created account is not BIP-44 compatible');\n }\n}\n\n/**\n * Asserts that a list of keyring accounts are all BIP-44 compatible.\n *\n * @param accounts - Keyring accounts to check.\n * @throws If any of the keyring account is not compatible.\n */\nexport function assertAreBip44Accounts(\n accounts: KeyringAccount[],\n): asserts accounts is Bip44Account<KeyringAccount>[] {\n accounts.forEach(assertIsBip44Account);\n}\n\nexport type Bip44AccountProvider<\n Account extends Bip44Account<KeyringAccount> = Bip44Account<KeyringAccount>,\n> = AccountProvider<Account> & {\n /**\n * Provider capabilities, including supported scopes and BIP-44 options.\n *\n * @returns The provider capabilities.\n */\n get capabilities(): KeyringCapabilities;\n /**\n * Get the name of the provider.\n *\n * @returns The name of the provider.\n */\n getName(): string;\n /**\n * Initialize the provider with the given accounts.\n *\n * @param accounts - The accounts to initialize the provider with.\n */\n init(accounts: Bip44Account<KeyringAccount>['id'][]): void;\n /**\n * Check if the account is compatible with the provider.\n */\n isAccountCompatible(account: Bip44Account<KeyringAccount>): boolean;\n /**\n * Create accounts for the provider.\n *\n * @param options - The options for creating the accounts.\n * @param options.entropySource - The entropy source.\n * @param options.groupIndex - The group index.\n * @param options.type - The type of account creation.\n * @returns The created accounts.\n */\n createAccounts(options: CreateAccountOptions): Promise<Account[]>;\n /**\n * Re-synchronize MetaMask accounts and the providers accounts if needed.\n *\n * NOTE: This is mostly required if one of the providers (keyrings or Snaps)\n * have different sets of accounts. This method would ensure that both are\n * in-sync and use the same accounts (and same IDs).\n */\n resyncAccounts(accounts: Bip44Account<InternalAccount>[]): Promise<void>;\n};\n\nexport abstract class BaseBip44AccountProvider<\n Account extends Bip44Account<KeyringAccount> = Bip44Account<KeyringAccount>,\n> implements Bip44AccountProvider<Account> {\n protected readonly messenger: MultichainAccountServiceMessenger;\n\n protected accounts: Set<Bip44Account<KeyringAccount>['id']> = new Set();\n\n constructor(messenger: MultichainAccountServiceMessenger) {\n this.messenger = messenger;\n }\n\n /**\n * Add accounts to the provider.\n *\n * Note: There's an implicit assumption that the accounts are BIP-44 compatible.\n *\n * @param accounts - The accounts to add.\n */\n init(accounts: Account['id'][]): void {\n for (const account of accounts) {\n this.accounts.add(account);\n }\n }\n\n /**\n * Get the accounts list for the provider.\n *\n * @returns The accounts list.\n */\n #getAccountIds(): Account['id'][] {\n return [...this.accounts];\n }\n\n /**\n * Get the accounts list for the provider from the AccountsController.\n *\n * @returns The accounts list.\n */\n getAccounts(): Account[] {\n const accountsIds = this.#getAccountIds();\n const internalAccounts = this.messenger.call(\n 'AccountsController:getAccounts',\n accountsIds,\n );\n // we cast here because we know that the accounts are BIP-44 compatible\n return internalAccounts as unknown as Account[];\n }\n\n /**\n * Get the account for the provider.\n *\n * @param id - The account ID.\n * @returns The account.\n * @throws If the account is not found.\n */\n getAccount(id: Account['id']): Account {\n const hasAccount = this.accounts.has(id);\n\n if (!hasAccount) {\n throw new Error(`Unable to find account: ${id}`);\n }\n\n // We need to upcast here since InternalAccounts are not always BIP-44 compatible\n // but we know that the account is BIP-44 compatible here so it is safe to do so\n return this.messenger.call(\n 'AccountsController:getAccount',\n id,\n ) as unknown as Account;\n }\n\n /**\n * Run an operation against a V1 keyring selected by `selector`.\n *\n * Forwards to `KeyringController:withKeyring`. Use this for keyrings that\n * have not yet migrated to the unified V2 `Keyring` interface (e.g. the\n * snap keyring).\n *\n * @param selector - The selector identifying the keyring.\n * @param operation - The operation to run with the selected keyring.\n * @returns The result of the operation.\n */\n protected async withKeyring<SelectedKeyring, CallbackResult = void>(\n selector: KeyringSelector,\n operation: ({\n keyring,\n metadata,\n }: {\n keyring: SelectedKeyring;\n metadata: KeyringMetadata;\n }) => Promise<CallbackResult>,\n ): Promise<CallbackResult> {\n const result = await this.messenger.call(\n 'KeyringController:withKeyring',\n selector,\n ({ keyring, metadata }) =>\n operation({\n keyring: keyring as SelectedKeyring,\n metadata,\n }),\n );\n\n return result as CallbackResult;\n }\n\n /**\n * Run an operation against a V2 keyring selected by `selector`.\n *\n * Forwards to `KeyringController:withKeyringV2`. Use this for keyrings\n * that implement the unified V2 `Keyring` interface from\n * `@metamask/keyring-api/v2`.\n *\n * @param selector - The selector identifying the keyring.\n * @param operation - The operation to run with the selected keyring.\n * @returns The result of the operation.\n */\n protected async withKeyringV2<\n SelectedKeyring extends KeyringV2 = KeyringV2,\n CallbackResult = void,\n >(\n selector: KeyringSelectorV2<SelectedKeyring>,\n operation: ({\n keyring,\n metadata,\n }: {\n keyring: SelectedKeyring;\n metadata: KeyringMetadata;\n }) => Promise<CallbackResult>,\n ): Promise<CallbackResult> {\n const result = await this.messenger.call(\n 'KeyringController:withKeyringV2',\n selector,\n ({ keyring, metadata }) =>\n operation({\n keyring: keyring as SelectedKeyring,\n metadata,\n }),\n );\n\n return result as CallbackResult;\n }\n\n abstract get capabilities(): KeyringCapabilities;\n\n abstract getName(): string;\n\n abstract resyncAccounts(\n accounts: Bip44Account<InternalAccount>[],\n ): Promise<void>;\n\n abstract isAccountCompatible(account: Bip44Account<KeyringAccount>): boolean;\n\n abstract createAccounts(options: CreateAccountOptions): Promise<Account[]>;\n\n abstract discoverAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Account[]>;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AccountProvider, Bip44Account } from "@metamask/account-api";
|
|
2
|
-
import type { CreateAccountOptions, EntropySourceId, KeyringAccount
|
|
3
|
-
import type {
|
|
2
|
+
import type { CreateAccountOptions, EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
|
|
3
|
+
import type { Keyring as KeyringV2, KeyringCapabilities } from "@metamask/keyring-api/v2";
|
|
4
|
+
import type { KeyringMetadata, KeyringSelector, KeyringSelectorV2 } from "@metamask/keyring-controller";
|
|
4
5
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
5
6
|
import type { MultichainAccountServiceMessenger } from "../types.cjs";
|
|
6
7
|
/**
|
|
@@ -86,10 +87,36 @@ export declare abstract class BaseBip44AccountProvider<Account extends Bip44Acco
|
|
|
86
87
|
* @throws If the account is not found.
|
|
87
88
|
*/
|
|
88
89
|
getAccount(id: Account['id']): Account;
|
|
90
|
+
/**
|
|
91
|
+
* Run an operation against a V1 keyring selected by `selector`.
|
|
92
|
+
*
|
|
93
|
+
* Forwards to `KeyringController:withKeyring`. Use this for keyrings that
|
|
94
|
+
* have not yet migrated to the unified V2 `Keyring` interface (e.g. the
|
|
95
|
+
* snap keyring).
|
|
96
|
+
*
|
|
97
|
+
* @param selector - The selector identifying the keyring.
|
|
98
|
+
* @param operation - The operation to run with the selected keyring.
|
|
99
|
+
* @returns The result of the operation.
|
|
100
|
+
*/
|
|
89
101
|
protected withKeyring<SelectedKeyring, CallbackResult = void>(selector: KeyringSelector, operation: ({ keyring, metadata, }: {
|
|
90
102
|
keyring: SelectedKeyring;
|
|
91
103
|
metadata: KeyringMetadata;
|
|
92
104
|
}) => Promise<CallbackResult>): Promise<CallbackResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Run an operation against a V2 keyring selected by `selector`.
|
|
107
|
+
*
|
|
108
|
+
* Forwards to `KeyringController:withKeyringV2`. Use this for keyrings
|
|
109
|
+
* that implement the unified V2 `Keyring` interface from
|
|
110
|
+
* `@metamask/keyring-api/v2`.
|
|
111
|
+
*
|
|
112
|
+
* @param selector - The selector identifying the keyring.
|
|
113
|
+
* @param operation - The operation to run with the selected keyring.
|
|
114
|
+
* @returns The result of the operation.
|
|
115
|
+
*/
|
|
116
|
+
protected withKeyringV2<SelectedKeyring extends KeyringV2 = KeyringV2, CallbackResult = void>(selector: KeyringSelectorV2<SelectedKeyring>, operation: ({ keyring, metadata, }: {
|
|
117
|
+
keyring: SelectedKeyring;
|
|
118
|
+
metadata: KeyringMetadata;
|
|
119
|
+
}) => Promise<CallbackResult>): Promise<CallbackResult>;
|
|
93
120
|
abstract get capabilities(): KeyringCapabilities;
|
|
94
121
|
abstract getName(): string;
|
|
95
122
|
abstract resyncAccounts(accounts: Bip44Account<InternalAccount>[]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseBip44AccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/BaseBip44AccountProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,8BAA8B;AAC3E,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,cAAc,
|
|
1
|
+
{"version":3,"file":"BaseBip44AccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/BaseBip44AccountProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,8BAA8B;AAC3E,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,cAAc,EACf,8BAA8B;AAC/B,OAAO,KAAK,EACV,OAAO,IAAI,SAAS,EACpB,mBAAmB,EACpB,iCAAiC;AAClC,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EAClB,qCAAqC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,cAAc,CAAC,CAIjD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,cAAc,EAAE,GACzB,OAAO,CAAC,QAAQ,IAAI,YAAY,CAAC,cAAc,CAAC,EAAE,CAEpD;AAED,MAAM,MAAM,oBAAoB,CAC9B,OAAO,SAAS,YAAY,CAAC,cAAc,CAAC,GAAG,YAAY,CAAC,cAAc,CAAC,IACzE,eAAe,CAAC,OAAO,CAAC,GAAG;IAC7B;;;;O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CAAC;QACzB,QAAQ,EAAE,eAAe,CAAC;KAC3B,KAAK,OAAO,CAAC,cAAc,CAAC,GAC5B,OAAO,CAAC,cAAc,CAAC;IAc1B;;;;;;;;;;OAUG;cACa,aAAa,CAC3B,eAAe,SAAS,SAAS,GAAG,SAAS,EAC7C,cAAc,GAAG,IAAI,EAErB,QAAQ,EAAE,iBAAiB,CAAC,eAAe,CAAC,EAC5C,SAAS,EAAE,CAAC,EACV,OAAO,EACP,QAAQ,GACT,EAAE;QACD,OAAO,EAAE,eAAe,CAAC;QACzB,QAAQ,EAAE,eAAe,CAAC;KAC3B,KAAK,OAAO,CAAC,cAAc,CAAC,GAC5B,OAAO,CAAC,cAAc,CAAC;IAc1B,QAAQ,KAAK,YAAY,IAAI,mBAAmB,CAAC;IAEjD,QAAQ,CAAC,OAAO,IAAI,MAAM;IAE1B,QAAQ,CAAC,cAAc,CACrB,QAAQ,EAAE,YAAY,CAAC,eAAe,CAAC,EAAE,GACxC,OAAO,CAAC,IAAI,CAAC;IAEhB,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,GAAG,OAAO;IAE5E,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAE1E,QAAQ,CAAC,gBAAgB,CAAC,EACxB,aAAa,EACb,UAAU,GACX,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CACvB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AccountProvider, Bip44Account } from "@metamask/account-api";
|
|
2
|
-
import type { CreateAccountOptions, EntropySourceId, KeyringAccount
|
|
3
|
-
import type {
|
|
2
|
+
import type { CreateAccountOptions, EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
|
|
3
|
+
import type { Keyring as KeyringV2, KeyringCapabilities } from "@metamask/keyring-api/v2";
|
|
4
|
+
import type { KeyringMetadata, KeyringSelector, KeyringSelectorV2 } from "@metamask/keyring-controller";
|
|
4
5
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
5
6
|
import type { MultichainAccountServiceMessenger } from "../types.mjs";
|
|
6
7
|
/**
|
|
@@ -86,10 +87,36 @@ export declare abstract class BaseBip44AccountProvider<Account extends Bip44Acco
|
|
|
86
87
|
* @throws If the account is not found.
|
|
87
88
|
*/
|
|
88
89
|
getAccount(id: Account['id']): Account;
|
|
90
|
+
/**
|
|
91
|
+
* Run an operation against a V1 keyring selected by `selector`.
|
|
92
|
+
*
|
|
93
|
+
* Forwards to `KeyringController:withKeyring`. Use this for keyrings that
|
|
94
|
+
* have not yet migrated to the unified V2 `Keyring` interface (e.g. the
|
|
95
|
+
* snap keyring).
|
|
96
|
+
*
|
|
97
|
+
* @param selector - The selector identifying the keyring.
|
|
98
|
+
* @param operation - The operation to run with the selected keyring.
|
|
99
|
+
* @returns The result of the operation.
|
|
100
|
+
*/
|
|
89
101
|
protected withKeyring<SelectedKeyring, CallbackResult = void>(selector: KeyringSelector, operation: ({ keyring, metadata, }: {
|
|
90
102
|
keyring: SelectedKeyring;
|
|
91
103
|
metadata: KeyringMetadata;
|
|
92
104
|
}) => Promise<CallbackResult>): Promise<CallbackResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Run an operation against a V2 keyring selected by `selector`.
|
|
107
|
+
*
|
|
108
|
+
* Forwards to `KeyringController:withKeyringV2`. Use this for keyrings
|
|
109
|
+
* that implement the unified V2 `Keyring` interface from
|
|
110
|
+
* `@metamask/keyring-api/v2`.
|
|
111
|
+
*
|
|
112
|
+
* @param selector - The selector identifying the keyring.
|
|
113
|
+
* @param operation - The operation to run with the selected keyring.
|
|
114
|
+
* @returns The result of the operation.
|
|
115
|
+
*/
|
|
116
|
+
protected withKeyringV2<SelectedKeyring extends KeyringV2 = KeyringV2, CallbackResult = void>(selector: KeyringSelectorV2<SelectedKeyring>, operation: ({ keyring, metadata, }: {
|
|
117
|
+
keyring: SelectedKeyring;
|
|
118
|
+
metadata: KeyringMetadata;
|
|
119
|
+
}) => Promise<CallbackResult>): Promise<CallbackResult>;
|
|
93
120
|
abstract get capabilities(): KeyringCapabilities;
|
|
94
121
|
abstract getName(): string;
|
|
95
122
|
abstract resyncAccounts(accounts: Bip44Account<InternalAccount>[]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseBip44AccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/BaseBip44AccountProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,8BAA8B;AAC3E,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,cAAc,
|
|
1
|
+
{"version":3,"file":"BaseBip44AccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/BaseBip44AccountProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,8BAA8B;AAC3E,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,cAAc,EACf,8BAA8B;AAC/B,OAAO,KAAK,EACV,OAAO,IAAI,SAAS,EACpB,mBAAmB,EACpB,iCAAiC;AAClC,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EAClB,qCAAqC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,cAAc,CAAC,CAIjD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,cAAc,EAAE,GACzB,OAAO,CAAC,QAAQ,IAAI,YAAY,CAAC,cAAc,CAAC,EAAE,CAEpD;AAED,MAAM,MAAM,oBAAoB,CAC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GAAG,IAAI,EAChE,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,CAAC,EACV,OAAO,EACP,QAAQ,GACT,EAAE;QACD,OAAO,EAAE,eAAe,CAAC;QACzB,QAAQ,EAAE,eAAe,CAAC;KAC3B,KAAK,OAAO,CAAC,cAAc,CAAC,GAC5B,OAAO,CAAC,cAAc,CAAC;IAc1B;;;;;;;;;;OAUG;cACa,aAAa,CAC3B,eAAe,SAAS,SAAS,GAAG,SAAS,EAC7C,cAAc,GAAG,IAAI,EAErB,QAAQ,EAAE,iBAAiB,CAAC,eAAe,CAAC,EAC5C,SAAS,EAAE,CAAC,EACV,OAAO,EACP,QAAQ,GACT,EAAE;QACD,OAAO,EAAE,eAAe,CAAC;QACzB,QAAQ,EAAE,eAAe,CAAC;KAC3B,KAAK,OAAO,CAAC,cAAc,CAAC,GAC5B,OAAO,CAAC,cAAc,CAAC;IAc1B,QAAQ,KAAK,YAAY,IAAI,mBAAmB,CAAC;IAEjD,QAAQ,CAAC,OAAO,IAAI,MAAM;IAE1B,QAAQ,CAAC,cAAc,CACrB,QAAQ,EAAE,YAAY,CAAC,eAAe,CAAC,EAAE,GACxC,OAAO,CAAC,IAAI,CAAC;IAEhB,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,GAAG,OAAO;IAE5E,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAE1E,QAAQ,CAAC,gBAAgB,CAAC,EACxB,aAAa,EACb,UAAU,GACX,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CACvB"}
|
|
@@ -70,6 +70,17 @@ export class BaseBip44AccountProvider {
|
|
|
70
70
|
// but we know that the account is BIP-44 compatible here so it is safe to do so
|
|
71
71
|
return this.messenger.call('AccountsController:getAccount', id);
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Run an operation against a V1 keyring selected by `selector`.
|
|
75
|
+
*
|
|
76
|
+
* Forwards to `KeyringController:withKeyring`. Use this for keyrings that
|
|
77
|
+
* have not yet migrated to the unified V2 `Keyring` interface (e.g. the
|
|
78
|
+
* snap keyring).
|
|
79
|
+
*
|
|
80
|
+
* @param selector - The selector identifying the keyring.
|
|
81
|
+
* @param operation - The operation to run with the selected keyring.
|
|
82
|
+
* @returns The result of the operation.
|
|
83
|
+
*/
|
|
73
84
|
async withKeyring(selector, operation) {
|
|
74
85
|
const result = await this.messenger.call('KeyringController:withKeyring', selector, ({ keyring, metadata }) => operation({
|
|
75
86
|
keyring: keyring,
|
|
@@ -77,6 +88,24 @@ export class BaseBip44AccountProvider {
|
|
|
77
88
|
}));
|
|
78
89
|
return result;
|
|
79
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Run an operation against a V2 keyring selected by `selector`.
|
|
93
|
+
*
|
|
94
|
+
* Forwards to `KeyringController:withKeyringV2`. Use this for keyrings
|
|
95
|
+
* that implement the unified V2 `Keyring` interface from
|
|
96
|
+
* `@metamask/keyring-api/v2`.
|
|
97
|
+
*
|
|
98
|
+
* @param selector - The selector identifying the keyring.
|
|
99
|
+
* @param operation - The operation to run with the selected keyring.
|
|
100
|
+
* @returns The result of the operation.
|
|
101
|
+
*/
|
|
102
|
+
async withKeyringV2(selector, operation) {
|
|
103
|
+
const result = await this.messenger.call('KeyringController:withKeyringV2', selector, ({ keyring, metadata }) => operation({
|
|
104
|
+
keyring: keyring,
|
|
105
|
+
metadata,
|
|
106
|
+
}));
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
80
109
|
}
|
|
81
110
|
_BaseBip44AccountProvider_instances = new WeakSet(), _BaseBip44AccountProvider_getAccountIds = function _BaseBip44AccountProvider_getAccountIds() {
|
|
82
111
|
return [...this.accounts];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseBip44AccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/BaseBip44AccountProvider.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;
|
|
1
|
+
{"version":3,"file":"BaseBip44AccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/BaseBip44AccountProvider.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AAoBvD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAuB;IAEvB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAA0B;IAE1B,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACzC,CAAC;AA+CD,MAAM,OAAgB,wBAAwB;IAO5C,YAAY,SAA4C;;QAF9C,aAAQ,GAA4C,IAAI,GAAG,EAAE,CAAC;QAGtE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACH,IAAI,CAAC,QAAyB;QAC5B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAWD;;;;OAIG;IACH,WAAW;QACT,MAAM,WAAW,GAAG,uBAAA,IAAI,oFAAe,MAAnB,IAAI,CAAiB,CAAC;QAC1C,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAC1C,gCAAgC,EAChC,WAAW,CACZ,CAAC;QACF,uEAAuE;QACvE,OAAO,gBAAwC,CAAC;IAClD,CAAC;IAED;;;;;;OAMG;IACH,UAAU,CAAC,EAAiB;QAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEzC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,iFAAiF;QACjF,gFAAgF;QAChF,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CACxB,+BAA+B,EAC/B,EAAE,CACmB,CAAC;IAC1B,CAAC;IAED;;;;;;;;;;OAUG;IACO,KAAK,CAAC,WAAW,CACzB,QAAyB,EACzB,SAM6B;QAE7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACtC,+BAA+B,EAC/B,QAAQ,EACR,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CACxB,SAAS,CAAC;YACR,OAAO,EAAE,OAA0B;YACnC,QAAQ;SACT,CAAC,CACL,CAAC;QAEF,OAAO,MAAwB,CAAC;IAClC,CAAC;IAED;;;;;;;;;;OAUG;IACO,KAAK,CAAC,aAAa,CAI3B,QAA4C,EAC5C,SAM6B;QAE7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACtC,iCAAiC,EACjC,QAAQ,EACR,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CACxB,SAAS,CAAC;YACR,OAAO,EAAE,OAA0B;YACnC,QAAQ;SACT,CAAC,CACL,CAAC;QAEF,OAAO,MAAwB,CAAC;IAClC,CAAC;CAqBF;;IAlIG,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { isBip44Account } from '@metamask/account-api';\nimport type { AccountProvider, Bip44Account } from '@metamask/account-api';\nimport type {\n CreateAccountOptions,\n EntropySourceId,\n KeyringAccount,\n} from '@metamask/keyring-api';\nimport type {\n Keyring as KeyringV2,\n KeyringCapabilities,\n} from '@metamask/keyring-api/v2';\nimport type {\n KeyringMetadata,\n KeyringSelector,\n KeyringSelectorV2,\n} from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\n/**\n * Asserts a keyring account is BIP-44 compatible.\n *\n * @param account - Keyring account to check.\n * @throws If the keyring account is not compatible.\n */\nexport function assertIsBip44Account(\n account: KeyringAccount,\n): asserts account is Bip44Account<KeyringAccount> {\n if (!isBip44Account(account)) {\n throw new Error('Created account is not BIP-44 compatible');\n }\n}\n\n/**\n * Asserts that a list of keyring accounts are all BIP-44 compatible.\n *\n * @param accounts - Keyring accounts to check.\n * @throws If any of the keyring account is not compatible.\n */\nexport function assertAreBip44Accounts(\n accounts: KeyringAccount[],\n): asserts accounts is Bip44Account<KeyringAccount>[] {\n accounts.forEach(assertIsBip44Account);\n}\n\nexport type Bip44AccountProvider<\n Account extends Bip44Account<KeyringAccount> = Bip44Account<KeyringAccount>,\n> = AccountProvider<Account> & {\n /**\n * Provider capabilities, including supported scopes and BIP-44 options.\n *\n * @returns The provider capabilities.\n */\n get capabilities(): KeyringCapabilities;\n /**\n * Get the name of the provider.\n *\n * @returns The name of the provider.\n */\n getName(): string;\n /**\n * Initialize the provider with the given accounts.\n *\n * @param accounts - The accounts to initialize the provider with.\n */\n init(accounts: Bip44Account<KeyringAccount>['id'][]): void;\n /**\n * Check if the account is compatible with the provider.\n */\n isAccountCompatible(account: Bip44Account<KeyringAccount>): boolean;\n /**\n * Create accounts for the provider.\n *\n * @param options - The options for creating the accounts.\n * @param options.entropySource - The entropy source.\n * @param options.groupIndex - The group index.\n * @param options.type - The type of account creation.\n * @returns The created accounts.\n */\n createAccounts(options: CreateAccountOptions): Promise<Account[]>;\n /**\n * Re-synchronize MetaMask accounts and the providers accounts if needed.\n *\n * NOTE: This is mostly required if one of the providers (keyrings or Snaps)\n * have different sets of accounts. This method would ensure that both are\n * in-sync and use the same accounts (and same IDs).\n */\n resyncAccounts(accounts: Bip44Account<InternalAccount>[]): Promise<void>;\n};\n\nexport abstract class BaseBip44AccountProvider<\n Account extends Bip44Account<KeyringAccount> = Bip44Account<KeyringAccount>,\n> implements Bip44AccountProvider<Account> {\n protected readonly messenger: MultichainAccountServiceMessenger;\n\n protected accounts: Set<Bip44Account<KeyringAccount>['id']> = new Set();\n\n constructor(messenger: MultichainAccountServiceMessenger) {\n this.messenger = messenger;\n }\n\n /**\n * Add accounts to the provider.\n *\n * Note: There's an implicit assumption that the accounts are BIP-44 compatible.\n *\n * @param accounts - The accounts to add.\n */\n init(accounts: Account['id'][]): void {\n for (const account of accounts) {\n this.accounts.add(account);\n }\n }\n\n /**\n * Get the accounts list for the provider.\n *\n * @returns The accounts list.\n */\n #getAccountIds(): Account['id'][] {\n return [...this.accounts];\n }\n\n /**\n * Get the accounts list for the provider from the AccountsController.\n *\n * @returns The accounts list.\n */\n getAccounts(): Account[] {\n const accountsIds = this.#getAccountIds();\n const internalAccounts = this.messenger.call(\n 'AccountsController:getAccounts',\n accountsIds,\n );\n // we cast here because we know that the accounts are BIP-44 compatible\n return internalAccounts as unknown as Account[];\n }\n\n /**\n * Get the account for the provider.\n *\n * @param id - The account ID.\n * @returns The account.\n * @throws If the account is not found.\n */\n getAccount(id: Account['id']): Account {\n const hasAccount = this.accounts.has(id);\n\n if (!hasAccount) {\n throw new Error(`Unable to find account: ${id}`);\n }\n\n // We need to upcast here since InternalAccounts are not always BIP-44 compatible\n // but we know that the account is BIP-44 compatible here so it is safe to do so\n return this.messenger.call(\n 'AccountsController:getAccount',\n id,\n ) as unknown as Account;\n }\n\n /**\n * Run an operation against a V1 keyring selected by `selector`.\n *\n * Forwards to `KeyringController:withKeyring`. Use this for keyrings that\n * have not yet migrated to the unified V2 `Keyring` interface (e.g. the\n * snap keyring).\n *\n * @param selector - The selector identifying the keyring.\n * @param operation - The operation to run with the selected keyring.\n * @returns The result of the operation.\n */\n protected async withKeyring<SelectedKeyring, CallbackResult = void>(\n selector: KeyringSelector,\n operation: ({\n keyring,\n metadata,\n }: {\n keyring: SelectedKeyring;\n metadata: KeyringMetadata;\n }) => Promise<CallbackResult>,\n ): Promise<CallbackResult> {\n const result = await this.messenger.call(\n 'KeyringController:withKeyring',\n selector,\n ({ keyring, metadata }) =>\n operation({\n keyring: keyring as SelectedKeyring,\n metadata,\n }),\n );\n\n return result as CallbackResult;\n }\n\n /**\n * Run an operation against a V2 keyring selected by `selector`.\n *\n * Forwards to `KeyringController:withKeyringV2`. Use this for keyrings\n * that implement the unified V2 `Keyring` interface from\n * `@metamask/keyring-api/v2`.\n *\n * @param selector - The selector identifying the keyring.\n * @param operation - The operation to run with the selected keyring.\n * @returns The result of the operation.\n */\n protected async withKeyringV2<\n SelectedKeyring extends KeyringV2 = KeyringV2,\n CallbackResult = void,\n >(\n selector: KeyringSelectorV2<SelectedKeyring>,\n operation: ({\n keyring,\n metadata,\n }: {\n keyring: SelectedKeyring;\n metadata: KeyringMetadata;\n }) => Promise<CallbackResult>,\n ): Promise<CallbackResult> {\n const result = await this.messenger.call(\n 'KeyringController:withKeyringV2',\n selector,\n ({ keyring, metadata }) =>\n operation({\n keyring: keyring as SelectedKeyring,\n metadata,\n }),\n );\n\n return result as CallbackResult;\n }\n\n abstract get capabilities(): KeyringCapabilities;\n\n abstract getName(): string;\n\n abstract resyncAccounts(\n accounts: Bip44Account<InternalAccount>[],\n ): Promise<void>;\n\n abstract isAccountCompatible(account: Bip44Account<KeyringAccount>): boolean;\n\n abstract createAccounts(options: CreateAccountOptions): Promise<Account[]>;\n\n abstract discoverAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Account[]>;\n}\n"]}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BtcAccountProvider = exports.BTC_ACCOUNT_PROVIDER_DEFAULT_CONFIG = exports.BTC_ACCOUNT_PROVIDER_NAME = void 0;
|
|
4
4
|
const keyring_api_1 = require("@metamask/keyring-api");
|
|
5
|
-
const SnapAccountProvider_1 = require("./SnapAccountProvider.cjs");
|
|
6
|
-
const utils_1 = require("./utils.cjs");
|
|
7
5
|
const analytics_1 = require("../analytics/index.cjs");
|
|
8
6
|
const traces_1 = require("../analytics/traces.cjs");
|
|
7
|
+
const SnapAccountProvider_1 = require("./SnapAccountProvider.cjs");
|
|
8
|
+
const utils_1 = require("./utils.cjs");
|
|
9
9
|
exports.BTC_ACCOUNT_PROVIDER_NAME = 'Bitcoin';
|
|
10
10
|
exports.BTC_ACCOUNT_PROVIDER_DEFAULT_CONFIG = {
|
|
11
11
|
maxConcurrency: 3,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BtcAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/BtcAccountProvider.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"BtcAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/BtcAccountProvider.ts"],"names":[],"mappings":";;;AAGA,uDAI+B;AAK/B,sDAA6C;AAC7C,oDAAgD;AAEhD,mEAA4D;AAK5D,uCAAiD;AAIpC,QAAA,yBAAyB,GAAG,SAAS,CAAC;AAEtC,QAAA,mCAAmC,GAA6B;IAC3E,cAAc,EAAE,CAAC;IACjB,cAAc,EAAE;QACd,OAAO,EAAE,KAAK,EAAE,+CAA+C;QAC/D,SAAS,EAAE,IAAI;KAChB;IACD,SAAS,EAAE;QACT,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,IAAI;KAChB;IACD,cAAc,EAAE;QACd,2BAA2B,EAAE,IAAI;KAClC;CACF,CAAC;AAEF,MAAa,kBAAmB,SAAQ,yCAAmB;IAazD,YACE,SAA4C,EAC5C,SAAmC,2CAAmC,EACtE,QAAuB,yBAAa;QAEpC,KAAK,CAAC,kBAAkB,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAbzD,iBAAY,GA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,CAAC,gBAAgB,CACrB,CAAC,sBAAQ,CAAC,OAAO,CAAC,EAClB,aAAa,EACb,UAAU,CACX,EACH,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAChC,EACH;oBACE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW;oBAC9C,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS;iBAC3C,CACF,CAAC;gBAEF,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC;oBAClC,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAC/B,CAAC;oBACD,OAAO,EAAE,CAAC;gBACZ,CAAC;gBAED,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE;oBAC7C,IAAI,EAAE,iCAAmB,CAAC,gBAAgB;oBAC1C,aAAa;oBACb,UAAU;iBACX,CAAC,CAAC;YACL,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;;AAnGH,gDAoGC;AAnGQ,uBAAI,GAAG,iCAAyB,AAA5B,CAA6B;AAEjC,8BAAW,GAAG,mCAA6C,AAAhD,CAAiD","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport {\n AccountCreationType,\n BtcAccountType,\n BtcScope,\n} from '@metamask/keyring-api';\nimport type { KeyringCapabilities } from '@metamask/keyring-api/v2';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport { traceFallback } from '../analytics';\nimport { TraceName } from '../analytics/traces';\nimport type { MultichainAccountServiceMessenger } from '../types';\nimport { SnapAccountProvider } from './SnapAccountProvider';\nimport type {\n RestrictedSnapKeyring,\n SnapAccountProviderConfig,\n} from './SnapAccountProvider';\nimport { withRetry, withTimeout } from './utils';\n\nexport type BtcAccountProviderConfig = SnapAccountProviderConfig;\n\nexport const BTC_ACCOUNT_PROVIDER_NAME = 'Bitcoin';\n\nexport const BTC_ACCOUNT_PROVIDER_DEFAULT_CONFIG: BtcAccountProviderConfig = {\n maxConcurrency: 3,\n createAccounts: {\n batched: false, // For now, the Snap is not fully v2 compliant.\n timeoutMs: 3000,\n },\n discovery: {\n enabled: true,\n timeoutMs: 2000,\n maxAttempts: 3,\n backOffMs: 1000,\n },\n resyncAccounts: {\n autoRemoveExtraSnapAccounts: true,\n },\n};\n\nexport class BtcAccountProvider extends SnapAccountProvider {\n static NAME = BTC_ACCOUNT_PROVIDER_NAME;\n\n static BTC_SNAP_ID = 'npm:@metamask/bitcoin-wallet-snap' as SnapId;\n\n readonly capabilities: KeyringCapabilities = {\n scopes: [BtcScope.Mainnet, BtcScope.Testnet],\n bip44: {\n deriveIndex: true,\n deriveIndexRange: true,\n },\n };\n\n constructor(\n messenger: MultichainAccountServiceMessenger,\n config: BtcAccountProviderConfig = BTC_ACCOUNT_PROVIDER_DEFAULT_CONFIG,\n trace: TraceCallback = traceFallback,\n ) {\n super(BtcAccountProvider.BTC_SNAP_ID, messenger, config, trace);\n }\n\n getName(): string {\n return BtcAccountProvider.NAME;\n }\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === BtcAccountType.P2wpkh &&\n Object.values<string>(BtcAccountType).includes(account.type)\n );\n }\n\n protected override createAccountV1(\n keyring: RestrictedSnapKeyring,\n {\n entropySource,\n groupIndex,\n }: { entropySource: EntropySourceId; groupIndex: number },\n ): Promise<KeyringAccount> {\n return keyring.createAccount({\n entropySource,\n index: groupIndex,\n addressType: BtcAccountType.P2wpkh,\n scope: BtcScope.Mainnet,\n });\n }\n\n async discoverAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return this.withSnap(async ({ client, keyring }) => {\n return await super.trace(\n {\n name: TraceName.SnapDiscoverAccounts,\n data: {\n provider: this.getName(),\n },\n },\n async () => {\n if (!this.config.discovery.enabled) {\n return [];\n }\n\n const discoveredAccounts = await withRetry(\n () =>\n withTimeout(\n () =>\n client.discoverAccounts(\n [BtcScope.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 (\n !Array.isArray(discoveredAccounts) ||\n discoveredAccounts.length === 0\n ) {\n return [];\n }\n\n return await this.createBip44Accounts(keyring, {\n type: AccountCreationType.Bip44DeriveIndex,\n entropySource,\n groupIndex,\n });\n },\n );\n });\n }\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Bip44Account } from "@metamask/account-api";
|
|
2
2
|
import type { TraceCallback } from "@metamask/controller-utils";
|
|
3
|
-
import type { EntropySourceId, KeyringAccount
|
|
3
|
+
import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
|
|
4
|
+
import type { KeyringCapabilities } from "@metamask/keyring-api/v2";
|
|
4
5
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
5
6
|
import type { SnapId } from "@metamask/snaps-sdk";
|
|
7
|
+
import type { MultichainAccountServiceMessenger } from "../types.cjs";
|
|
6
8
|
import { SnapAccountProvider } from "./SnapAccountProvider.cjs";
|
|
7
9
|
import type { RestrictedSnapKeyring, SnapAccountProviderConfig } from "./SnapAccountProvider.cjs";
|
|
8
|
-
import type { MultichainAccountServiceMessenger } from "../types.cjs";
|
|
9
10
|
export type BtcAccountProviderConfig = SnapAccountProviderConfig;
|
|
10
11
|
export declare const BTC_ACCOUNT_PROVIDER_NAME = "Bitcoin";
|
|
11
12
|
export declare const BTC_ACCOUNT_PROVIDER_DEFAULT_CONFIG: BtcAccountProviderConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BtcAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/BtcAccountProvider.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,UAAU,EAAE,MAAM,CAAA;KAAE,GACxD,OAAO,CAAC,cAAc,CAAC;IASpB,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;CA+C5C"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Bip44Account } from "@metamask/account-api";
|
|
2
2
|
import type { TraceCallback } from "@metamask/controller-utils";
|
|
3
|
-
import type { EntropySourceId, KeyringAccount
|
|
3
|
+
import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
|
|
4
|
+
import type { KeyringCapabilities } from "@metamask/keyring-api/v2";
|
|
4
5
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
5
6
|
import type { SnapId } from "@metamask/snaps-sdk";
|
|
7
|
+
import type { MultichainAccountServiceMessenger } from "../types.mjs";
|
|
6
8
|
import { SnapAccountProvider } from "./SnapAccountProvider.mjs";
|
|
7
9
|
import type { RestrictedSnapKeyring, SnapAccountProviderConfig } from "./SnapAccountProvider.mjs";
|
|
8
|
-
import type { MultichainAccountServiceMessenger } from "../types.mjs";
|
|
9
10
|
export type BtcAccountProviderConfig = SnapAccountProviderConfig;
|
|
10
11
|
export declare const BTC_ACCOUNT_PROVIDER_NAME = "Bitcoin";
|
|
11
12
|
export declare const BTC_ACCOUNT_PROVIDER_DEFAULT_CONFIG: BtcAccountProviderConfig;
|