UNPKG

@metamask/multichain-account-service

Version:
45 lines 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SolAccountProvider = void 0; const keyring_api_1 = require("@metamask/keyring-api"); const keyring_controller_1 = require("@metamask/keyring-controller"); const BaseAccountProvider_1 = require("./BaseAccountProvider.cjs"); const SnapAccountProvider_1 = require("./SnapAccountProvider.cjs"); class SolAccountProvider extends SnapAccountProvider_1.SnapAccountProvider { constructor(messenger) { super(SolAccountProvider.SOLANA_SNAP_ID, messenger); } isAccountCompatible(account) { return (account.type === keyring_api_1.SolAccountType.DataAccount && account.metadata.keyring.type === keyring_controller_1.KeyringTypes.snap); } async createAccounts({ entropySource, groupIndex, }) { const createAccount = await this.getRestrictedSnapAccountCreator(); // Create account without any confirmation nor selecting it. // TODO: Use the new keyring API `createAccounts` method with the "bip-44:derive-index" // type once ready. const derivationPath = `m/44'/501'/${groupIndex}'/0'`; const account = await createAccount({ entropySource, derivationPath, }); // Solana Snap does not use BIP-44 typed options for the moment // so we "inject" them (the `AccountsController` does a similar thing // for the moment). account.options.entropy = { type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic, id: entropySource, groupIndex, derivationPath, }; const accounts = [account]; (0, BaseAccountProvider_1.assertAreBip44Accounts)(accounts); return accounts; } async discoverAndCreateAccounts(_) { return []; // TODO: Implement account discovery. } } exports.SolAccountProvider = SolAccountProvider; SolAccountProvider.SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap'; //# sourceMappingURL=SolAccountProvider.cjs.map