getStarknetAccount method
Future<Account>
getStarknetAccount(
{ - SecureStore? secureStore,
- required Future<String?> getPassword(),
})
Implementation
Future<s.Account> getStarknetAccount({
SecureStore? secureStore,
required Future<String?> Function() getPassword,
}) async {
final wallet = state.selectedWallet;
if (wallet == null) {
throw Exception("Wallet not found");
}
final account = state.selectedAccount;
if (account == null) {
throw Exception("Account not found");
}
secureStore = secureStore ??
await getSecureStore(
getPassword: getPassword,
type: wallet.secureStoreType,
);
final privateKey =
await secureStore.getSecret(key: privateKeyKey(wallet.id, account.id));
if (privateKey == null) {
throw Exception("Private key not found");
}
return s.Account(
accountAddress: s.Felt.fromHexString(account.address),
chainId: WalletKit().chainId,
provider: WalletKit().provider,
signer: s.StarkAccountSigner(
signer: s.StarkSigner(
privateKey: s.Felt.fromHexString(privateKey),
),
),
);
}