-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update wallet_app tutorial (#431)
* docs: add step about Android minimun SDK version required by `wallet_kit` * feat(wallet_kit): add deploy account support * fix(wallet_kit): refresh accounts ETH balance when wallet is expanded * wallet_kit: fix analyze issue * fix(wallet_kit): disable 'Send ETH' button when account is not deployed * docs: add missing Scaffold in mobile wallet tutorial * fix(wallet_kit): use `TokenSymbol.name` instead of hardcoded string for account balances keys * fix(wallet_kit): disable 'Deploy account' button if ETH account balance is not enough * feat(wallet_kit): also refresh STRK balance when wallet is expanded * docs: add info for Android biometric support and devnet minting in mobile-wallet tutorial * fix(wallet_kit): check if account is deployed when wallet is expanded * fix(wallet_kit): ensure private key is not null before signer creation * wallet_kit: apply some code rabbit recommendation * docs: fix typo
- Loading branch information
1 parent
e890801
commit ad394cb
Showing
8 changed files
with
240 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/wallet_kit/lib/widgets/deploy_account_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import '../wallet_kit.dart'; | ||
|
||
class DeployAccountButton extends HookConsumerWidget { | ||
const DeployAccountButton({ | ||
super.key, | ||
}); | ||
|
||
// ignore: constant_identifier_names | ||
static const double MINIMUN_ETH_BALANCE = 0.00001; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final selectedAccount = ref.watch( | ||
walletsProvider.select((value) => value.selectedAccount), | ||
); | ||
if (selectedAccount?.isDeployed == false) { | ||
final ethBalance = | ||
selectedAccount!.balances[TokenSymbol.ETH.name] ?? 0.00; | ||
final enoughBalance = ethBalance >= MINIMUN_ETH_BALANCE; | ||
return PrimaryButton( | ||
label: enoughBalance ? 'Deploy account' : 'Not enough ETH', | ||
onPressed: enoughBalance | ||
? () async { | ||
final secureStore = await ref | ||
.read(walletsProvider.notifier) | ||
.getSecureStoreForWallet(context: context); | ||
await ref.read(walletsProvider.notifier).deployAccount( | ||
secureStore: secureStore, | ||
account: selectedAccount, | ||
); | ||
} | ||
: null); | ||
} else { | ||
return const SizedBox.shrink(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.