{"version":3,"file":"SolAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":";;;AAEA,uDAG+B;AAC/B,qEAA4D;AAK5D,mEAA+D;AAC/D,mEAA4D;AAE5D,MAAa,kBAAmB,SAAQ,yCAAmB;IAGzD,YAAY,SAA4C;QACtD,KAAK,CAAC,kBAAkB,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IACtD,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;IAED,KAAK,CAAC,cAAc,CAAC,EACnB,aAAa,EACb,UAAU,GAIX;QACC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,+BAA+B,EAAE,CAAC;QAEnE,4DAA4D;QAC5D,uFAAuF;QACvF,mBAAmB;QACnB,MAAM,cAAc,GAAG,cAAc,UAAU,MAAM,CAAC;QACtD,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;YAClC,aAAa;YACb,cAAc;SACf,CAAC,CAAC;QAEH,+DAA+D;QAC/D,qEAAqE;QACrE,mBAAmB;QACnB,OAAO,CAAC,OAAO,CAAC,OAAO,GAAG;YACxB,IAAI,EAAE,6CAA+B,CAAC,QAAQ;YAC9C,EAAE,EAAE,aAAa;YACjB,UAAU;YACV,cAAc;SACf,CAAC;QAEF,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAA,4CAAsB,EAAC,QAAQ,CAAC,CAAC;QAEjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,CAG/B;QACC,OAAO,EAAE,CAAC,CAAC,qCAAqC;IAClD,CAAC;;AArDH,gDAsDC;AArDQ,iCAAc,GAAG,kCAA4C,CAAC","sourcesContent":["import { type Bip44Account } from '@metamask/account-api';\nimport type { EntropySourceId, KeyringAccount } 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';\nimport type { MultichainAccountServiceMessenger } from 'src/types';\n\nimport { assertAreBip44Accounts } from './BaseAccountProvider';\nimport { SnapAccountProvider } from './SnapAccountProvider';\n\nexport class SolAccountProvider extends SnapAccountProvider {\n  static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n  constructor(messenger: MultichainAccountServiceMessenger) {\n    super(SolAccountProvider.SOLANA_SNAP_ID, messenger);\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 createAccounts({\n    entropySource,\n    groupIndex,\n  }: {\n    entropySource: EntropySourceId;\n    groupIndex: number;\n  }): Promise<Bip44Account<KeyringAccount>[]> {\n    const createAccount = await this.getRestrictedSnapAccountCreator();\n\n    // Create account without any confirmation nor selecting it.\n    // TODO: Use the new keyring API `createAccounts` method with the \"bip-44:derive-index\"\n    // type once ready.\n    const derivationPath = `m/44'/501'/${groupIndex}'/0'`;\n    const account = await createAccount({\n      entropySource,\n      derivationPath,\n    });\n\n    // Solana Snap does not use BIP-44 typed options for the moment\n    // so we \"inject\" them (the `AccountsController` does a similar thing\n    // for the moment).\n    account.options.entropy = {\n      type: KeyringAccountEntropyTypeOption.Mnemonic,\n      id: entropySource,\n      groupIndex,\n      derivationPath,\n    };\n\n    const accounts = [account];\n    assertAreBip44Accounts(accounts);\n\n    return accounts;\n  }\n\n  async discoverAndCreateAccounts(_: {\n    entropySource: EntropySourceId;\n    groupIndex: number;\n  }) {\n    return []; // TODO: Implement account discovery.\n  }\n}\n"]}