MultichainAccountService Actions
14 actions registered.
MultichainAccountService:alignWallet
Package: @metamask/multichain-account-service
Align a specific multichain account wallet.
Parameters:
| Name | Description |
|---|---|
entropySource | The entropy source of the multichain account wallet. |
Handler signature:
(entropySource: EntropySourceId) => Promise<void>
MultichainAccountService:alignWallets
Package: @metamask/multichain-account-service
Align all multichain account wallets.
Handler signature:
() => Promise<void>
MultichainAccountService:createMultichainAccountGroup
Package: @metamask/multichain-account-service
Creates a multichain account group.
Parameters:
| Name | Description |
|---|---|
options | Options. |
options.groupIndex | The group index to use. |
options.entropySource | The wallet's entropy source. |
Returns: The multichain account group for this group index.
Handler signature:
({ groupIndex, entropySource, }: {
groupIndex: number;
entropySource: EntropySourceId;
}) => Promise<MultichainAccountGroup<Bip44Account<KeyringAccount>>>
MultichainAccountService:createMultichainAccountGroups
Package: @metamask/multichain-account-service
Creates multiple multichain account groups up to maxGroupIndex.
Parameters:
| Name | Description |
|---|---|
params | Parameters for creating account groups. |
params.fromGroupIndex | Starting group index to create (inclusive) (defaults to 0). |
params.toGroupIndex | Maximum group index to create (inclusive). |
params.entropySource | The entropy source ID. |
Returns: Array of created multichain account groups.
Handler signature:
({ fromGroupIndex, toGroupIndex, entropySource, }: {
fromGroupIndex?: number;
toGroupIndex: number;
entropySource: EntropySourceId;
}) => Promise<MultichainAccountGroup<Bip44Account<KeyringAccount>>[]>
MultichainAccountService:createMultichainAccountWallet
Package: @metamask/multichain-account-service
Creates a new multichain account wallet by either importing an existing mnemonic, creating a new vault and keychain, or restoring a vault and keyring.
NOTE: This method should only be called in client code where a mutex lock is acquired.
discoverAccounts should be called after this method to discover and create accounts.
Parameters:
| Name | Description |
|---|---|
params | The parameters to use to create the new wallet. |
params.mnemonic | The mnemonic to use to create the new wallet. |
params.password | The password to encrypt the vault with. |
params.type | The flow type to use to create the new wallet. |
Returns: The new multichain account wallet.
Handler signature:
(params: CreateWalletParams) => Promise<MultichainAccountWallet<Bip44Account<KeyringAccount>>>
MultichainAccountService:createNextMultichainAccountGroup
Package: @metamask/multichain-account-service
Creates the next multichain account group.
Parameters:
| Name | Description |
|---|---|
options | Options. |
options.entropySource | The wallet's entropy source. |
Returns: The next multichain account group.
Handler signature:
({ entropySource, }: {
entropySource: EntropySourceId;
}) => Promise<MultichainAccountGroup<Bip44Account<KeyringAccount>>>
MultichainAccountService:getMultichainAccountGroup
Package: @metamask/multichain-account-service
Gets a reference to the multichain account group matching this entropy source and a group index.
Parameters:
| Name | Description |
|---|---|
options | Options. |
options.entropySource | The entropy source of the multichain account. |
options.groupIndex | The group index of the multichain account. |
Returns: A reference to the multichain account.
Handler signature:
({ entropySource, groupIndex, }: {
entropySource: EntropySourceId;
groupIndex: number;
}) => MultichainAccountGroup<Bip44Account<KeyringAccount>>
MultichainAccountService:getMultichainAccountGroups
Package: @metamask/multichain-account-service
Gets all multichain account groups for a given entropy source.
Parameters:
| Name | Description |
|---|---|
options | Options. |
options.entropySource | The entropy source to query. |
Returns: A list of all multichain accounts.
Handler signature:
({ entropySource, }: {
entropySource: EntropySourceId;
}) => MultichainAccountGroup<Bip44Account<KeyringAccount>>[]
MultichainAccountService:getMultichainAccountWallet
Package: @metamask/multichain-account-service
Gets a reference to the multichain account wallet matching this entropy source.
Parameters:
| Name | Description |
|---|---|
options | Options. |
options.entropySource | The entropy source of the multichain account. |
Returns: A reference to the multichain account wallet.
Handler signature:
({ entropySource, }: {
entropySource: EntropySourceId;
}) => MultichainAccountWallet<Bip44Account<KeyringAccount>>
MultichainAccountService:getMultichainAccountWallets
Package: @metamask/multichain-account-service
Gets an array of all multichain account wallets.
Returns: An array of all multichain account wallets.
Handler signature:
() => MultichainAccountWallet<Bip44Account<KeyringAccount>>[]
MultichainAccountService:init
Package: @metamask/multichain-account-service
Initialize the service and constructs the internal reprensentation of multichain accounts and wallets.
Handler signature:
() => Promise<void>
MultichainAccountService:removeMultichainAccountWallet
Package: @metamask/multichain-account-service
Removes a multichain account wallet, deleting all of its accounts across every registered provider (EVM and snap-based).
EVM deletion is required because every multichain account group must have an EVM account and EVM keyring state cannot be recovered from a Snap. If EVM deletion partially fails, only non-EVM accounts whose EVM counterpart was successfully deleted are removed. The wallet remains registered and this method throws.
Once every EVM account has been deleted, non-EVM cleanup is best-effort: failures are reported together and the wallet is removed.
Parameters:
| Name | Description |
|---|---|
entropySource | The entropy source of the multichain account wallet. |
Handler signature:
(entropySource: EntropySourceId) => Promise<void>
MultichainAccountService:resyncAccounts
Package: @metamask/multichain-account-service
Re-synchronize MetaMask accounts and the providers accounts if needed.
NOTE: This is mostly required if one of the providers (keyrings or Snaps) have different sets of accounts. This method would ensure that both are in-sync and use the same accounts (and same IDs).
READ THIS CAREFULLY (State inconsistency bugs/de-sync) We've seen some problems were keyring accounts on some Snaps were not synchronized with the accounts on MM side. This causes problems where we cannot interact with those accounts because the Snap does know about them. To "workaround" this de-sync problem for now, we make sure that both parties are in-sync when the service boots up.
Handler signature:
() => Promise<void>
MultichainAccountService:setBasicFunctionality
Package: @metamask/multichain-account-service
Set basic functionality state and trigger alignment if enabled. When basic functionality is disabled, snap-based providers are disabled. When enabled, all snap providers are enabled and wallet alignment is triggered. EVM providers are never disabled as they're required for basic wallet functionality.
Parameters:
| Name | Description |
|---|---|
enabled | Whether basic functionality is enabled. |
Handler signature:
(enabled: boolean) => Promise<void>