addAccount static method

Future<(Wallet, Account)> addAccount({
  1. required SecureStore secureStore,
  2. required Wallet wallet,
  3. required String seedPhrase,
})

Implementation

static Future<(Wallet, Account)> addAccount({
  required SecureStore secureStore,
  required Wallet wallet,
  required String seedPhrase,
}) async {
  final accountId = wallet.newAccountId;
  final privateKey = await WalletService.derivePrivateKey(
    seedPhrase: seedPhrase,
    derivationIndex: accountId,
  );

  await secureStore.storeSecret(
    key: privateKeyKey(wallet.id, accountId),
    secret: privateKey.toHexString(),
  );

  final accountAddress = await WalletService.computeAddress(
    privateKey: privateKey,
  );

  return wallet.addAccount(
    accountAddress: accountAddress,
    accountId: accountId,
  );
}