addAccount method

(Wallet, Account) addAccount({
  1. required Felt accountAddress,
  2. int? accountId,
})

Implementation

(Wallet, Account) addAccount({
  required Felt accountAddress,
  int? accountId,
}) {
  accountId = accountId ?? newAccountId;
  final account = Account(
    id: accountId,
    walletId: id,
    name: 'Account ${accountId + 1}',
    address: accountAddress.toHexString(),
  );
  final updatedWallet = copyWith(
    accounts: {...accounts, account.id: account},
  );
  return (updatedWallet, account);
}