@metamask/multichain-account-service
Version:
Service to manage multichain accounts
37 lines • 1.42 kB
JavaScript
import { BtcAccountType, BtcScope } from "@metamask/keyring-api";
import { traceFallback } from "../analytics/index.mjs";
import { SnapAccountProvider } from "./SnapAccountProvider.mjs";
export const BTC_ACCOUNT_PROVIDER_NAME = 'Bitcoin';
export const BTC_ACCOUNT_PROVIDER_DEFAULT_CONFIG = {
maxConcurrency: 3,
createAccounts: {
timeoutMs: 3000,
},
discovery: {
enabled: true,
timeoutMs: 2000,
maxAttempts: 3,
backOffMs: 1000,
},
resyncAccounts: {
autoRemoveExtraSnapAccounts: true,
},
};
export class BtcAccountProvider extends SnapAccountProvider {
constructor(messenger, config = BTC_ACCOUNT_PROVIDER_DEFAULT_CONFIG, trace = traceFallback) {
super(BtcAccountProvider.BTC_SNAP_ID, messenger, config, trace);
// TODO: Remove once the Snap is fully v2 — discovery is then driven by the
// Snap's own supported scopes via `createAccounts({ bip44:discover })`.
this.v1DiscoveryScopes = [BtcScope.Mainnet];
}
getName() {
return BtcAccountProvider.NAME;
}
isAccountCompatible(account) {
return (account.type === BtcAccountType.P2wpkh &&
Object.values(BtcAccountType).includes(account.type));
}
}
BtcAccountProvider.NAME = BTC_ACCOUNT_PROVIDER_NAME;
BtcAccountProvider.BTC_SNAP_ID = 'npm:@metamask/bitcoin-wallet-snap';
//# sourceMappingURL=BtcAccountProvider.mjs.map