diff --git a/starport_template/lib/entities/wallet_additional_data.dart b/starport_template/lib/entities/account_additional_data.dart similarity index 52% rename from starport_template/lib/entities/wallet_additional_data.dart rename to starport_template/lib/entities/account_additional_data.dart index c9c12698..605f7c6c 100644 --- a/starport_template/lib/entities/wallet_additional_data.dart +++ b/starport_template/lib/entities/account_additional_data.dart @@ -2,13 +2,13 @@ import 'dart:convert'; import 'package:transaction_signing_gateway/transaction_signing_gateway.dart'; -class WalletAdditionalData { - WalletAdditionalData({ +class AccountAdditionalData { + AccountAdditionalData({ required this.isBackedUp, }); - factory WalletAdditionalData.fromJson(Map map) { - return WalletAdditionalData( + factory AccountAdditionalData.fromJson(Map map) { + return AccountAdditionalData( isBackedUp: map['isBackedUp'] as bool? ?? false, ); } @@ -24,7 +24,7 @@ class WalletAdditionalData { String toJsonString() => jsonEncode(toJson()); } -extension AdditionalDataParsing on WalletPublicInfo { - WalletAdditionalData get data => - WalletAdditionalData.fromJson(jsonDecode(additionalData ?? '{}') as Map); +extension AdditionalDataParsing on AccountPublicInfo { + AccountAdditionalData get data => + AccountAdditionalData.fromJson(jsonDecode(additionalData ?? '{}') as Map); } diff --git a/starport_template/lib/entities/import_wallet_form_data.dart b/starport_template/lib/entities/import_account_form_data.dart similarity index 51% rename from starport_template/lib/entities/import_wallet_form_data.dart rename to starport_template/lib/entities/import_account_form_data.dart index fec2208a..950daaa7 100644 --- a/starport_template/lib/entities/import_wallet_form_data.dart +++ b/starport_template/lib/entities/import_account_form_data.dart @@ -1,7 +1,7 @@ -import 'package:starport_template/entities/wallet_additional_data.dart'; +import 'package:starport_template/entities/account_additional_data.dart'; -class ImportWalletFormData { - const ImportWalletFormData({ +class ImportAccountFormData { + const ImportAccountFormData({ required this.mnemonic, required this.name, required this.password, @@ -11,5 +11,5 @@ class ImportWalletFormData { final String mnemonic; final String name; final String password; - final WalletAdditionalData additionalData; + final AccountAdditionalData additionalData; } diff --git a/starport_template/lib/main.dart b/starport_template/lib/main.dart index 87a4fc56..50731486 100644 --- a/starport_template/lib/main.dart +++ b/starport_template/lib/main.dart @@ -3,9 +3,9 @@ import 'package:cosmos_auth/cosmos_auth.dart'; import 'package:cosmos_utils/cosmos_utils.dart'; import 'package:flutter/material.dart'; import 'package:starport_template/starport_app.dart'; +import 'package:starport_template/stores/accounts_store.dart'; import 'package:starport_template/stores/settings_store.dart'; import 'package:starport_template/stores/transactions_store.dart'; -import 'package:starport_template/stores/wallets_store.dart'; import 'package:starport_template/utils/base_env.dart'; import 'package:transaction_signing_gateway/mobile/no_op_transaction_summary_ui.dart'; import 'package:transaction_signing_gateway/transaction_signing_gateway.dart'; @@ -37,7 +37,7 @@ void _buildDependencies() { ); StarportApp.cosmosAuth = CosmosAuth(); - StarportApp.walletsStore = WalletsStore(StarportApp.signingGateway, StarportApp.baseEnv); + StarportApp.accountsStore = AccountsStore(StarportApp.signingGateway, StarportApp.baseEnv); StarportApp.settingsStore = SettingsStore(StarportApp.cosmosAuth, StarportApp.secureDataStore, StarportApp.baseEnv); StarportApp.transactionsStore = TransactionsStore(StarportApp.baseEnv); } diff --git a/starport_template/lib/pages/wallet_name_page.dart b/starport_template/lib/pages/account_name_page.dart similarity index 91% rename from starport_template/lib/pages/wallet_name_page.dart rename to starport_template/lib/pages/account_name_page.dart index 5a4c6fba..15bbd871 100644 --- a/starport_template/lib/pages/wallet_name_page.dart +++ b/starport_template/lib/pages/account_name_page.dart @@ -2,8 +2,8 @@ import 'package:cosmos_ui_components/cosmos_ui_components.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -class WalletNamePage extends StatefulWidget { - const WalletNamePage({ +class AccountNamePage extends StatefulWidget { + const AccountNamePage({ required this.name, this.actionTitle = 'Save', Key? key, @@ -13,7 +13,7 @@ class WalletNamePage extends StatefulWidget { final String actionTitle; @override - State createState() => _WalletNamePageState(); + State createState() => _AccountNamePageState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { @@ -24,7 +24,7 @@ class WalletNamePage extends StatefulWidget { } } -class _WalletNamePageState extends State { +class _AccountNamePageState extends State { late String name; @override diff --git a/starport_template/lib/pages/wallets_list_sheet.dart b/starport_template/lib/pages/accounts_list_sheet.dart similarity index 64% rename from starport_template/lib/pages/wallets_list_sheet.dart rename to starport_template/lib/pages/accounts_list_sheet.dart index 7baed91a..752e6d97 100644 --- a/starport_template/lib/pages/wallets_list_sheet.dart +++ b/starport_template/lib/pages/accounts_list_sheet.dart @@ -1,35 +1,36 @@ import 'package:cosmos_ui_components/cosmos_text_theme.dart'; import 'package:cosmos_ui_components/cosmos_ui_components.dart'; +import 'package:cosmos_ui_components/models/account_info.dart'; import 'package:cosmos_utils/cosmos_utils.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; -import 'package:starport_template/pages/create_wallet_page.dart'; -import 'package:starport_template/pages/import_wallet_page.dart'; -import 'package:starport_template/pages/wallet_name_page.dart'; +import 'package:starport_template/pages/account_name_page.dart'; +import 'package:starport_template/pages/create_account_page.dart'; +import 'package:starport_template/pages/import_account_page.dart'; import 'package:starport_template/starport_app.dart'; -import 'package:transaction_signing_gateway/model/wallet_public_info.dart'; +import 'package:transaction_signing_gateway/transaction_signing_gateway.dart'; -class WalletsListSheet extends StatefulWidget { - const WalletsListSheet({ +class AccountsListSheet extends StatefulWidget { + const AccountsListSheet({ Key? key, }) : super(key: key); @override - State createState() => _WalletsListSheetState(); + State createState() => _AccountsListSheetState(); } -class _WalletsListSheetState extends State { - List get publicInfos => StarportApp.walletsStore.wallets; +class _AccountsListSheetState extends State { + List get publicInfos => StarportApp.accountsStore.accounts; - WalletPublicInfo get selectedWallet => StarportApp.walletsStore.selectedWallet; + AccountPublicInfo get selectedAccount => StarportApp.accountsStore.selectedAccount; - List get walletInfos => publicInfos + List get accountInfos => publicInfos .map( - (publicInfo) => WalletInfo( + (publicInfo) => AccountInfo( name: publicInfo.name, address: publicInfo.publicAddress, - walletId: publicInfo.walletId, + accountId: publicInfo.accountId, ), ) .toList(); @@ -46,10 +47,10 @@ class _WalletsListSheetState extends State { child: Observer( builder: (context) => ContentStateSwitcher( emptyChild: const EmptyListMessage( - message: 'No wallets found. Add one.', + message: 'No accounts found. Add one.', ), - isLoading: StarportApp.walletsStore.isRenamingWallet, - isEmpty: walletInfos.isEmpty, + isLoading: StarportApp.accountsStore.isRenamingAccount, + isEmpty: accountInfos.isEmpty, contentChild: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -88,20 +89,20 @@ class _WalletsListSheetState extends State { } void _onTapCreateAccount() { - Navigator.of(context).push(MaterialPageRoute(builder: (context) => const CreateWalletPage())); + Navigator.of(context).push(MaterialPageRoute(builder: (context) => const CreateAccountPage())); } void _onTapImportAccount() { - Navigator.of(context).push(MaterialPageRoute(builder: (context) => const ImportWalletPage())); + Navigator.of(context).push(MaterialPageRoute(builder: (context) => const ImportAccountPage())); } Expanded _buildMainList() { return Expanded( child: Observer( - builder: (context) => CosmosWalletsListView( - list: walletInfos, - selectedWallet: walletInfos.firstWhere((element) => element.address == selectedWallet.publicAddress), - onClicked: _walletClicked, + builder: (context) => CosmosAccountsListView( + list: accountInfos, + selectedAccount: accountInfos.firstWhere((element) => element.address == selectedAccount.publicAddress), + onClicked: _accountClicked, isEditing: isEditingAccountList, onEditIconPressed: _onEditIconPressed, ), @@ -109,10 +110,10 @@ class _WalletsListSheetState extends State { ); } - Future _onTapRenameAccount(WalletInfo walletInfo) async { + Future _onTapRenameAccount(AccountInfo accountInfo) async { final newName = await Navigator.of(context).push( MaterialPageRoute( - builder: (context) => WalletNamePage(name: walletInfo.name), + builder: (context) => AccountNamePage(name: accountInfo.name), ), ); if (!mounted) { @@ -120,13 +121,13 @@ class _WalletsListSheetState extends State { } if (newName != null) { Navigator.of(context).pop(); - await _renameWallet(newName); + await _renameAccount(newName); } } - Future _renameWallet(String newName) async { - await StarportApp.walletsStore.renameWallet(newName); - if (StarportApp.walletsStore.renameWalletFailure != null) { + Future _renameAccount(String newName) async { + await StarportApp.accountsStore.renameAccount(newName); + if (StarportApp.accountsStore.renameAccountFailure != null) { await showCosmosAlertDialog( context: context, dialogBuilder: (context) => CosmosAlertDialog( @@ -143,15 +144,15 @@ class _WalletsListSheetState extends State { } } - void _walletClicked(int index) => Navigator.of(context).pop(publicInfos[index]); + void _accountClicked(int index) => Navigator.of(context).pop(publicInfos[index]); - void _onEditIconPressed(WalletInfo walletInfo) { + void _onEditIconPressed(AccountInfo accountInfo) { showCosmosActionSheet( context: context, actions: [ CosmosModalAction( text: 'Rename Account', - onPressed: () => _onTapRenameAccount(walletInfo), + onPressed: () => _onTapRenameAccount(accountInfo), ), CosmosModalAction( text: 'Delete Account', @@ -159,7 +160,7 @@ class _WalletsListSheetState extends State { isCriticalAction: true, ), ], - title: Text(walletInfo.name), + title: Text(accountInfo.name), ); } @@ -168,8 +169,8 @@ class _WalletsListSheetState extends State { super.debugFillProperties(properties); properties ..add(DiagnosticsProperty('isEditingAccountList', isEditingAccountList)) - ..add(IterableProperty('walletInfos', walletInfos)) - ..add(IterableProperty('publicInfos', publicInfos)) - ..add(DiagnosticsProperty('selectedWallet', selectedWallet)); + ..add(IterableProperty('accountInfos', accountInfos)) + ..add(IterableProperty('publicInfos', publicInfos)) + ..add(DiagnosticsProperty('selectedAccount', selectedAccount)); } } diff --git a/starport_template/lib/pages/assets_portfolio_page.dart b/starport_template/lib/pages/assets_portfolio_page.dart index ad477d67..65deb9c1 100644 --- a/starport_template/lib/pages/assets_portfolio_page.dart +++ b/starport_template/lib/pages/assets_portfolio_page.dart @@ -7,15 +7,15 @@ import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; import 'package:starport_template/entities/balance.dart'; +import 'package:starport_template/pages/accounts_list_sheet.dart'; import 'package:starport_template/pages/receive_money_sheet.dart'; import 'package:starport_template/pages/select_asset_page.dart'; import 'package:starport_template/pages/transaction_history_page.dart'; -import 'package:starport_template/pages/wallets_list_sheet.dart'; import 'package:starport_template/starport_app.dart'; import 'package:starport_template/widgets/asset_portfolio_heading.dart'; import 'package:starport_template/widgets/balance_card_list.dart'; import 'package:starport_template/widgets/starport_button_bar.dart'; -import 'package:transaction_signing_gateway/model/wallet_public_info.dart'; +import 'package:transaction_signing_gateway/transaction_signing_gateway.dart'; class AssetsPortfolioPage extends StatefulWidget { const AssetsPortfolioPage({ @@ -27,15 +27,15 @@ class AssetsPortfolioPage extends StatefulWidget { } class _AssetsPortfolioPageState extends State { - ObservableList get balancesList => StarportApp.walletsStore.balancesList; + ObservableList get balancesList => StarportApp.accountsStore.balancesList; - bool get isBalancesLoading => StarportApp.walletsStore.isBalancesLoading; + bool get isBalancesLoading => StarportApp.accountsStore.isBalancesLoading; - bool get isSendMoneyLoading => StarportApp.walletsStore.isSendMoneyLoading; + bool get isSendMoneyLoading => StarportApp.accountsStore.isSendMoneyLoading; - bool get isError => StarportApp.walletsStore.isBalancesLoadingError; + bool get isError => StarportApp.accountsStore.isBalancesLoadingError; - WalletPublicInfo get selectedWallet => StarportApp.walletsStore.selectedWallet; + AccountPublicInfo get selectedAccount => StarportApp.accountsStore.selectedAccount; @override Widget build(BuildContext context) { @@ -51,7 +51,7 @@ class _AssetsPortfolioPageState extends State { children: [ _gradientAvatar(context), AssetPortfolioHeading( - title: selectedWallet.name, + title: selectedAccount.name, onTap: _onTapDropDown, ), SizedBox(height: CosmosTheme.of(context).spacingXL), @@ -92,7 +92,7 @@ class _AssetsPortfolioPageState extends State { height: 35, child: InkWell( onTap: () => _onTapAvatar(context), - child: GradientAvatar(stringKey: selectedWallet.publicAddress), + child: GradientAvatar(stringKey: selectedAccount.publicAddress), ), ), ), @@ -104,17 +104,17 @@ class _AssetsPortfolioPageState extends State { ); Future _onTapDropDown() async { - final wallet = await showMaterialModalBottomSheet( + final account = await showMaterialModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) => SizedBox( height: MediaQuery.of(context).size.height / 1.06, - child: const WalletsListSheet(), + child: const AccountsListSheet(), ), - ) as WalletPublicInfo?; + ) as AccountPublicInfo?; - if (wallet != null) { - StarportApp.walletsStore.selectWallet(wallet); + if (account != null) { + StarportApp.accountsStore.selectAccount(account); } } @@ -125,7 +125,7 @@ class _AssetsPortfolioPageState extends State { builder: (context) => SizedBox( height: MediaQuery.of(context).size.height / 1.06, child: ReceiveMoneySheet( - walletInfo: StarportApp.walletsStore.selectedWallet, + accountInfo: StarportApp.accountsStore.selectedAccount, ), ), ); @@ -136,9 +136,9 @@ class _AssetsPortfolioPageState extends State { super.debugFillProperties(properties); properties ..add( - DiagnosticsProperty( - 'selectedWallet', - selectedWallet, + DiagnosticsProperty( + 'selectedAccount', + selectedAccount, ), ) ..add(DiagnosticsProperty('isBalancesLoading', isBalancesLoading)) diff --git a/starport_template/lib/pages/assets_transfer_sheet.dart b/starport_template/lib/pages/assets_transfer_sheet.dart index f861bf08..94dcb048 100644 --- a/starport_template/lib/pages/assets_transfer_sheet.dart +++ b/starport_template/lib/pages/assets_transfer_sheet.dart @@ -30,7 +30,7 @@ class AssetsTransferSheet extends StatefulWidget { } class _AssetsTransferSheetState extends State { - bool get isLoading => StarportApp.walletsStore.isSendMoneyLoading; + bool get isLoading => StarportApp.accountsStore.isSendMoneyLoading; @override Widget build(BuildContext context) { diff --git a/starport_template/lib/pages/back_up_wallet_page.dart b/starport_template/lib/pages/back_up_account_page.dart similarity index 94% rename from starport_template/lib/pages/back_up_wallet_page.dart rename to starport_template/lib/pages/back_up_account_page.dart index 5e856a5c..e087fb12 100644 --- a/starport_template/lib/pages/back_up_wallet_page.dart +++ b/starport_template/lib/pages/back_up_account_page.dart @@ -6,8 +6,8 @@ import 'package:flutter/material.dart'; import 'package:starport_template/pages/repeat_mnemonic_page.dart'; import 'package:starport_template/widgets/copy_to_clipboard_button.dart'; -class BackUpWalletPage extends StatefulWidget { - const BackUpWalletPage({ +class BackUpAccountPage extends StatefulWidget { + const BackUpAccountPage({ required this.mnemonic, Key? key, }) : super(key: key); @@ -15,7 +15,7 @@ class BackUpWalletPage extends StatefulWidget { final String mnemonic; @override - State createState() => _BackUpWalletPageState(); + State createState() => _BackUpAccountPageState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { @@ -24,7 +24,7 @@ class BackUpWalletPage extends StatefulWidget { } } -class _BackUpWalletPageState extends State { +class _BackUpAccountPageState extends State { List get mnemonicWords => widget.mnemonic.splitToWords(); var _confirmChecked = false; diff --git a/starport_template/lib/pages/create_wallet_page.dart b/starport_template/lib/pages/create_account_page.dart similarity index 75% rename from starport_template/lib/pages/create_wallet_page.dart rename to starport_template/lib/pages/create_account_page.dart index 3ad2601d..e52ef28d 100644 --- a/starport_template/lib/pages/create_wallet_page.dart +++ b/starport_template/lib/pages/create_account_page.dart @@ -6,43 +6,43 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; import 'package:starport_template/pages/assets_portfolio_page.dart'; -import 'package:starport_template/pages/back_up_wallet_page.dart'; +import 'package:starport_template/pages/back_up_account_page.dart'; import 'package:starport_template/pages/backup_later_bottom_sheet.dart'; import 'package:starport_template/pages/passcode_prompt_page.dart'; import 'package:starport_template/starport_app.dart'; import 'package:starport_template/widgets/loading_splash.dart'; -class CreateWalletPage extends StatefulWidget { - const CreateWalletPage({Key? key}) : super(key: key); +class CreateAccountPage extends StatefulWidget { + const CreateAccountPage({Key? key}) : super(key: key); @override - State createState() => _CreateWalletPageState(); + State createState() => _CreateAccountPageState(); } -class _CreateWalletPageState extends State { +class _CreateAccountPageState extends State { bool? _isAuthenticated; String? _mnemonic; bool get isLoading => _isAuthenticated == null || - StarportApp.walletsStore.isMnemonicCreating || - StarportApp.walletsStore.isWalletImporting; + StarportApp.accountsStore.isMnemonicCreating || + StarportApp.accountsStore.isAccountImporting; bool get isError => !(_isAuthenticated ?? true) || - StarportApp.walletsStore.isMnemonicCreatingError || - StarportApp.walletsStore.isWalletImportingError; + StarportApp.accountsStore.isMnemonicCreatingError || + StarportApp.accountsStore.isAccountImportingError; bool get isAuthenticating => _isAuthenticated == null; - bool get isMnemonicCreating => StarportApp.walletsStore.isMnemonicCreating; + bool get isMnemonicCreating => StarportApp.accountsStore.isMnemonicCreating; - bool get isWalletImporting => StarportApp.walletsStore.isWalletImporting; + bool get isAccountImporting => StarportApp.accountsStore.isAccountImporting; - bool get isMnemonicCreatingError => StarportApp.walletsStore.isMnemonicCreatingError; + bool get isMnemonicCreatingError => StarportApp.accountsStore.isMnemonicCreatingError; - bool get isWalletImportingError => StarportApp.walletsStore.isWalletImportingError; + bool get isAccountImportingError => StarportApp.accountsStore.isAccountImportingError; @override void initState() { @@ -60,7 +60,7 @@ class _CreateWalletPageState extends State { loadingChild: LoadingSplash( text: isAuthenticating ? 'Authenticating..' - : (isMnemonicCreating ? 'Creating a recovery phrase..' : 'Creating wallet..'), + : (isMnemonicCreating ? 'Creating a recovery phrase..' : 'Creating account..'), ), contentChild: Scaffold( body: _contentUI(), @@ -106,7 +106,7 @@ class _CreateWalletPageState extends State { const InfoCard(text: 'Never share your recovery phrase with anyone, store it securely.'), SizedBox(height: theme.spacingL), const InfoCard( - text: 'If you don’t backup your wallet or lose your recovery phrase, ' + text: 'If you don’t backup your account or lose your recovery phrase, ' 'you will not able to recover your account', ), const Spacer(), @@ -139,14 +139,14 @@ class _CreateWalletPageState extends State { void _onTapAdvanced() => notImplemented(context); Future _onTapBackUpNow() async { - _mnemonic ??= await StarportApp.walletsStore.createMnemonic(); + _mnemonic ??= await StarportApp.accountsStore.createMnemonic(); final mnemonic = _mnemonic; if (mnemonic == null) { return; } if (mounted) { await Navigator.of(context).pushReplacement( - MaterialPageRoute(builder: (context) => BackUpWalletPage(mnemonic: mnemonic)), + MaterialPageRoute(builder: (context) => BackUpAccountPage(mnemonic: mnemonic)), ); } } @@ -155,22 +155,22 @@ class _CreateWalletPageState extends State { context: context, backgroundColor: Colors.transparent, builder: (context) => BackupLaterBottomSheet( - onTapSkipBackup: () => _createWallet(isBackedUp: false), + onTapSkipBackup: () => _createAccount(isBackedUp: false), ), ); - Future _createWallet({required bool isBackedUp}) async { + Future _createAccount({required bool isBackedUp}) async { final password = await PasswordPromptPage.promptPassword( context, ); if (password == null) { return; } - await StarportApp.walletsStore.createNewWallet( + await StarportApp.accountsStore.createNewAccount( password: password, isBackedUp: isBackedUp, onMnemonicGenerationStarted: () => setState(() {}), - onWalletCreationStarted: () => setState(() {}), //this will cause the loading message to update + onAccountCreationStarted: () => setState(() {}), //this will cause the loading message to update ); if (mounted) { await Navigator.of(context).pushAndRemoveUntil( @@ -188,10 +188,10 @@ class _CreateWalletPageState extends State { properties ..add(DiagnosticsProperty('isMnemonicCreatingError', isMnemonicCreatingError)) ..add(DiagnosticsProperty('isMnemonicCreating', isMnemonicCreating)) - ..add(DiagnosticsProperty('isWalletImporting', isWalletImporting)) + ..add(DiagnosticsProperty('isAccountImporting', isAccountImporting)) ..add(DiagnosticsProperty('isLoading', isLoading)) ..add(DiagnosticsProperty('isAuthenticating', isAuthenticating)) - ..add(DiagnosticsProperty('isWalletImportingError', isWalletImportingError)) + ..add(DiagnosticsProperty('isAccountImportingError', isAccountImportingError)) ..add(DiagnosticsProperty('isError', isError)); } } diff --git a/starport_template/lib/pages/custom_fee_page.dart b/starport_template/lib/pages/custom_fee_page.dart index c8c46e56..266a0898 100644 --- a/starport_template/lib/pages/custom_fee_page.dart +++ b/starport_template/lib/pages/custom_fee_page.dart @@ -32,7 +32,7 @@ class _CustomFeePageState extends State { @override void initState() { super.initState(); - fee = widget.initialFee ?? StarportApp.walletsStore.defaultFee; + fee = widget.initialFee ?? StarportApp.accountsStore.defaultFee; } @override diff --git a/starport_template/lib/pages/import_wallet_page.dart b/starport_template/lib/pages/import_account_page.dart similarity index 82% rename from starport_template/lib/pages/import_wallet_page.dart rename to starport_template/lib/pages/import_account_page.dart index 3532528d..42590461 100644 --- a/starport_template/lib/pages/import_wallet_page.dart +++ b/starport_template/lib/pages/import_account_page.dart @@ -3,27 +3,27 @@ import 'package:cosmos_utils/cosmos_utils.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; -import 'package:starport_template/entities/import_wallet_form_data.dart'; -import 'package:starport_template/entities/wallet_additional_data.dart'; +import 'package:starport_template/entities/account_additional_data.dart'; +import 'package:starport_template/entities/import_account_form_data.dart'; +import 'package:starport_template/pages/account_name_page.dart'; import 'package:starport_template/pages/assets_portfolio_page.dart'; import 'package:starport_template/pages/passcode_prompt_page.dart'; -import 'package:starport_template/pages/wallet_name_page.dart'; import 'package:starport_template/starport_app.dart'; import 'package:starport_template/widgets/loading_splash.dart'; -class ImportWalletPage extends StatefulWidget { - const ImportWalletPage({Key? key}) : super(key: key); +class ImportAccountPage extends StatefulWidget { + const ImportAccountPage({Key? key}) : super(key: key); @override - State createState() => _ImportWalletPageState(); + State createState() => _ImportAccountPageState(); } -class _ImportWalletPageState extends State { +class _ImportAccountPageState extends State { MnemonicValidationError? _mnemonicValidError; String _mnemonic = ''; - bool get isImporting => StarportApp.walletsStore.isWalletImporting; + bool get isImporting => StarportApp.accountsStore.isAccountImporting; bool get _importEnabled => _mnemonicValidError == null && _mnemonic.isNotEmpty; @@ -86,12 +86,12 @@ class _ImportWalletPageState extends State { void _onTapAdvanced() => notImplemented(context); Future _onTapImport() async { - if (StarportApp.walletsStore.wallets.isEmpty) { - await _importWallet(); + if (StarportApp.accountsStore.accounts.isEmpty) { + await _importAccount(); } else { final name = await _chooseName(); if (name != null) { - await _importWallet(name: name); + await _importAccount(name: name); } } } @@ -99,7 +99,7 @@ class _ImportWalletPageState extends State { Future _chooseName() { return Navigator.of(context).push( MaterialPageRoute( - builder: (_) => const WalletNamePage( + builder: (_) => const AccountNamePage( name: '', actionTitle: 'Import', ), @@ -107,20 +107,20 @@ class _ImportWalletPageState extends State { ); } - Future _importWallet({String name = 'Account 1'}) async { + Future _importAccount({String name = 'Account 1'}) async { final password = await PasswordPromptPage.promptPassword(context); if (password == null) { return; } - await StarportApp.walletsStore.importAlanWallet( - ImportWalletFormData( + await StarportApp.accountsStore.importAlanAccount( + ImportAccountFormData( mnemonic: _mnemonic, name: name, password: password, - additionalData: WalletAdditionalData(isBackedUp: true), + additionalData: AccountAdditionalData(isBackedUp: true), ), ); - if (StarportApp.walletsStore.isWalletImportingError) { + if (StarportApp.accountsStore.isAccountImportingError) { _showImportErrorDialog(); } else if (mounted) { await Navigator.of(context).pushAndRemoveUntil( diff --git a/starport_template/lib/pages/onboarding_page.dart b/starport_template/lib/pages/onboarding_page.dart index 03b2e392..ce69ffca 100644 --- a/starport_template/lib/pages/onboarding_page.dart +++ b/starport_template/lib/pages/onboarding_page.dart @@ -1,17 +1,17 @@ import 'package:cosmos_ui_components/cosmos_ui_components.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:starport_template/pages/create_wallet_page.dart'; -import 'package:starport_template/pages/import_wallet_page.dart'; +import 'package:starport_template/pages/create_account_page.dart'; +import 'package:starport_template/pages/import_account_page.dart'; import 'package:starport_template/starport_app.dart'; class OnboardingPage extends StatefulWidget { const OnboardingPage({ - this.openWalletsListOnDone = true, + this.openAccountsListOnDone = true, Key? key, }) : super(key: key); - final bool openWalletsListOnDone; + final bool openAccountsListOnDone; @override State createState() => _OnboardingPageState(); @@ -19,7 +19,7 @@ class OnboardingPage extends StatefulWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(DiagnosticsProperty('openWalletsListOnDone', openWalletsListOnDone)); + properties.add(DiagnosticsProperty('openAccountsListOnDone', openAccountsListOnDone)); } } @@ -54,7 +54,7 @@ class _OnboardingPageState extends State { ), SizedBox(height: theme.spacingL), Text( - 'Access your wallet for $nodeNetwork.', + 'Access your account for $nodeNetwork.', style: Theme.of(context).textTheme.caption, ), SizedBox(height: theme.spacingXL), @@ -79,12 +79,13 @@ class _OnboardingPageState extends State { } void _onTapCreateAccount() => Navigator.of(context).push( - MaterialPageRoute(builder: (_) => const CreateWalletPage()), + MaterialPageRoute(builder: (_) => const CreateAccountPage()), ); void _onTapImportAccount() => Navigator.of(context).push( - MaterialPageRoute(builder: (_) => const ImportWalletPage()), + MaterialPageRoute(builder: (_) => const ImportAccountPage()), ); + @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); diff --git a/starport_template/lib/pages/passcode_prompt_page.dart b/starport_template/lib/pages/passcode_prompt_page.dart index 3f1538b3..dddd640c 100644 --- a/starport_template/lib/pages/passcode_prompt_page.dart +++ b/starport_template/lib/pages/passcode_prompt_page.dart @@ -21,7 +21,7 @@ class PasswordPromptPage extends StatefulWidget { return _showPage( context, setUpPasscode: !hasPassword, - message: hasPassword ? message : 'Provide passcode that we will use to secure your wallet data', + message: hasPassword ? message : 'Provide passcode that we will use to secure your account data', ); } diff --git a/starport_template/lib/pages/receive_money_sheet.dart b/starport_template/lib/pages/receive_money_sheet.dart index c3eea7c3..fa47f0da 100644 --- a/starport_template/lib/pages/receive_money_sheet.dart +++ b/starport_template/lib/pages/receive_money_sheet.dart @@ -4,17 +4,17 @@ import 'package:cosmos_ui_components/cosmos_ui_components.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:share_plus/share_plus.dart'; -import 'package:transaction_signing_gateway/model/wallet_public_info.dart'; +import 'package:transaction_signing_gateway/transaction_signing_gateway.dart'; class ReceiveMoneySheet extends StatelessWidget { const ReceiveMoneySheet({ - required this.walletInfo, + required this.accountInfo, Key? key, }) : super(key: key); - final WalletPublicInfo walletInfo; + final AccountPublicInfo accountInfo; - String get walletAddress => walletInfo.publicAddress; + String get accountAddress => accountInfo.publicAddress; @override Widget build(BuildContext context) { @@ -39,7 +39,7 @@ class ReceiveMoneySheet extends StatelessWidget { horizontal: MediaQuery.of(context).size.width / 5, ), child: CosmosQrImage( - data: walletInfo.publicAddress, + data: accountInfo.publicAddress, ), ), SizedBox(height: theme.spacingXXL), @@ -48,18 +48,18 @@ class ReceiveMoneySheet extends StatelessWidget { children: [ SizedBox( height: 35, - child: GradientAvatar(stringKey: walletInfo.publicAddress), + child: GradientAvatar(stringKey: accountInfo.publicAddress), ), SizedBox(width: theme.spacingL), Text( - walletInfo.name, + accountInfo.name, style: CosmosTextTheme.title1Medium, ) ], ), SizedBox(height: theme.spacingL), Text( - maskAddress(walletAddress), + maskAddress(accountAddress), style: CosmosTextTheme.title1Medium, ), const Spacer(), @@ -89,16 +89,16 @@ class ReceiveMoneySheet extends StatelessWidget { ); } - void _onTapCopyAddress() => FlutterClipboard.copy(walletAddress); + void _onTapCopyAddress() => FlutterClipboard.copy(accountAddress); - void _onTapShare() => Share.share(walletAddress); + void _onTapShare() => Share.share(accountAddress); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add(DiagnosticsProperty('walletInfo', walletInfo)) - ..add(StringProperty('walletAddress', walletAddress)); + ..add(DiagnosticsProperty('accountInfo', accountInfo)) + ..add(StringProperty('accountAddress', accountAddress)); } } diff --git a/starport_template/lib/pages/repeat_mnemonic_page.dart b/starport_template/lib/pages/repeat_mnemonic_page.dart index 76cd6d1d..212e7679 100644 --- a/starport_template/lib/pages/repeat_mnemonic_page.dart +++ b/starport_template/lib/pages/repeat_mnemonic_page.dart @@ -2,8 +2,8 @@ import 'package:cosmos_ui_components/cosmos_ui_components.dart'; import 'package:cosmos_utils/cosmos_utils.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:starport_template/entities/import_wallet_form_data.dart'; -import 'package:starport_template/entities/wallet_additional_data.dart'; +import 'package:starport_template/entities/account_additional_data.dart'; +import 'package:starport_template/entities/import_account_form_data.dart'; import 'package:starport_template/pages/assets_portfolio_page.dart'; import 'package:starport_template/pages/passcode_prompt_page.dart'; import 'package:starport_template/starport_app.dart'; @@ -34,9 +34,9 @@ class _RepeatMnemonicPageState extends State { bool get _createButtonEnabled => listEquals(_mnemonicWords, _selectedWords); - bool get _isLoading => StarportApp.walletsStore.isWalletImporting; + bool get _isLoading => StarportApp.accountsStore.isAccountImporting; - bool get _isError => StarportApp.walletsStore.isWalletImportingError; + bool get _isError => StarportApp.accountsStore.isAccountImportingError; @override void initState() { @@ -52,7 +52,7 @@ class _RepeatMnemonicPageState extends State { errorChild: _errorUI(), isLoading: _isLoading, loadingChild: const LoadingSplash( - text: 'Creating wallet..', + text: 'Creating account..', ), contentChild: Scaffold( body: _contentUI(), @@ -126,14 +126,14 @@ class _RepeatMnemonicPageState extends State { if (password == null) { return; } - await StarportApp.walletsStore.importAlanWallet( - ImportWalletFormData( - name: 'Wallet ${StarportApp.walletsStore.wallets.length}', + await StarportApp.accountsStore.importAlanAccount( + ImportAccountFormData( + name: 'Account ${StarportApp.accountsStore.accounts.length}', password: password, mnemonic: widget.mnemonic, - additionalData: WalletAdditionalData(isBackedUp: true), + additionalData: AccountAdditionalData(isBackedUp: true), ), - onWalletCreationStarted: () => setState(() {}), + onAccountCreationStarted: () => setState(() {}), ); setState(() {}); if (!mounted) { diff --git a/starport_template/lib/pages/routing_page.dart b/starport_template/lib/pages/routing_page.dart index 9e22079d..6e0f4f03 100644 --- a/starport_template/lib/pages/routing_page.dart +++ b/starport_template/lib/pages/routing_page.dart @@ -16,7 +16,7 @@ class RoutingPage extends StatefulWidget { } class _RoutingPageState extends State { - bool get isLoading => StarportApp.walletsStore.areWalletsLoading || !StarportApp.settingsStore.isInitialized; + bool get isLoading => StarportApp.accountsStore.areAccountsLoading || !StarportApp.settingsStore.isInitialized; @override void initState() { @@ -29,10 +29,10 @@ class _RoutingPageState extends State { return Scaffold( body: ContentStateSwitcher( isLoading: isLoading, - isError: StarportApp.walletsStore.loadWalletsFailure.value != null, + isError: StarportApp.accountsStore.loadAccountsFailure.value != null, errorChild: const CosmosErrorView( title: 'Something went wrong', - message: 'We had problems retrieving wallets from secure storage.', + message: 'We had problems retrieving accounts from secure storage.', ), contentChild: const SizedBox(), ), @@ -41,22 +41,22 @@ class _RoutingPageState extends State { Future initialize() async { await _initSettings(); - await _loadWallets(); + await _loadAccounts(); await _performRouting(); } Future _initSettings() => StarportApp.settingsStore.init(); - Future _loadWallets() async { - final store = StarportApp.walletsStore; - await store.loadWallets(); + Future _loadAccounts() async { + final store = StarportApp.accountsStore; + await store.loadAccounts(); } Future _performRouting() async { - if (StarportApp.walletsStore.loadWalletsFailure.value != null || !(await _isPasscodeValid()) || !mounted) { + if (StarportApp.accountsStore.loadAccountsFailure.value != null || !(await _isPasscodeValid()) || !mounted) { return; } - if (StarportApp.walletsStore.wallets.isEmpty) { + if (StarportApp.accountsStore.accounts.isEmpty) { unawaited( Navigator.of(context).pushReplacement( MaterialPageRoute(builder: (_) => const OnboardingPage()), diff --git a/starport_template/lib/pages/send_money_sheet.dart b/starport_template/lib/pages/send_money_sheet.dart index ccde499f..428fb971 100644 --- a/starport_template/lib/pages/send_money_sheet.dart +++ b/starport_template/lib/pages/send_money_sheet.dart @@ -1,7 +1,6 @@ import 'package:cosmos_ui_components/components/content_state_switcher.dart'; import 'package:cosmos_ui_components/components/cosmos_elevated_button.dart'; import 'package:cosmos_ui_components/components/template/cosmos_password_field.dart'; -import 'package:cosmos_ui_components/components/template/cosmos_wallets_list_view.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; @@ -9,18 +8,18 @@ import 'package:starport_template/entities/amount.dart'; import 'package:starport_template/entities/balance.dart'; import 'package:starport_template/entities/denom.dart'; import 'package:starport_template/starport_app.dart'; -import 'package:starport_template/stores/wallets_store.dart'; -import 'package:transaction_signing_gateway/model/wallet_public_info.dart'; +import 'package:starport_template/stores/accounts_store.dart'; +import 'package:transaction_signing_gateway/transaction_signing_gateway.dart'; class SendMoneySheet extends StatefulWidget { const SendMoneySheet({ required this.denom, - required this.walletInfo, + required this.accountInfo, Key? key, }) : super(key: key); final Denom denom; - final WalletInfo walletInfo; + final AccountPublicInfo accountInfo; @override State createState() => _SendMoneySheetState(); @@ -30,7 +29,7 @@ class SendMoneySheet extends StatefulWidget { super.debugFillProperties(properties); properties ..add(DiagnosticsProperty('denom', denom)) - ..add(DiagnosticsProperty('walletInfo', walletInfo)); + ..add(DiagnosticsProperty('accountInfo', accountInfo)); } } @@ -43,7 +42,7 @@ class _SendMoneySheetState extends State { Widget build(BuildContext context) { return Observer( builder: (context) => ContentStateSwitcher( - isLoading: StarportApp.walletsStore.isSendMoneyLoading, + isLoading: StarportApp.accountsStore.isSendMoneyLoading, contentChild: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -55,7 +54,7 @@ class _SendMoneySheetState extends State { ListTile( title: TextFormField( decoration: const InputDecoration( - labelText: 'Enter wallet address', + labelText: 'Enter account address', border: OutlineInputBorder(), ), onChanged: (value) => toAddress = value, @@ -87,14 +86,14 @@ class _SendMoneySheetState extends State { Future _onSendMoneyClicked() async { final amount = Amount.fromString(this.amount); - final info = WalletPublicInfo( - name: widget.walletInfo.name, - publicAddress: widget.walletInfo.address, - walletId: widget.walletInfo.walletId, - chainId: WalletsStore.chainId, + final info = AccountPublicInfo( + name: widget.accountInfo.name, + publicAddress: widget.accountInfo.publicAddress, + accountId: widget.accountInfo.accountId, + chainId: AccountsStore.chainId, ); final balance = Balance(denom: widget.denom, amount: amount); - await StarportApp.walletsStore.sendTokens(info: info, balance: balance, toAddress: toAddress, password: password); + await StarportApp.accountsStore.sendTokens(info: info, balance: balance, toAddress: toAddress, password: password); if (!mounted) { return; } diff --git a/starport_template/lib/pages/sign_transaction_page.dart b/starport_template/lib/pages/sign_transaction_page.dart index ede8f561..0b19b75f 100644 --- a/starport_template/lib/pages/sign_transaction_page.dart +++ b/starport_template/lib/pages/sign_transaction_page.dart @@ -42,7 +42,7 @@ class SignTransactionPage extends StatefulWidget { class _SignTransactionPageState extends State { double get recipientGetsAmount => widget.transaction.amount.value.toDouble() - widget.transaction.fee; - WalletPublicInfo get selectedWallet => StarportApp.walletsStore.selectedWallet; + AccountPublicInfo get selectedAccount => StarportApp.accountsStore.selectedAccount; Balance get recipientGetsAmountBalance => widget.balance.copyWith( amount: Amount.fromString('$recipientGetsAmount'), @@ -111,8 +111,8 @@ class _SignTransactionPageState extends State { return; } unawaited( - StarportApp.walletsStore.sendTokens( - info: StarportApp.walletsStore.selectedWallet, + StarportApp.accountsStore.sendTokens( + info: StarportApp.accountsStore.selectedAccount, balance: Balance( amount: widget.transaction.amount, denom: widget.balance.denom, @@ -181,7 +181,7 @@ class _SignTransactionPageState extends State { ..add(DoubleProperty('recipientGetsAmount', recipientGetsAmount)) ..add(DiagnosticsProperty('balance', widget.balance)) ..add( - DiagnosticsProperty('selectedWallet', selectedWallet), + DiagnosticsProperty('selectedAccount', selectedAccount), ) ..add(DiagnosticsProperty('recipientGetsAmountBalance', recipientGetsAmountBalance)); } diff --git a/starport_template/lib/pages/transaction_history_page.dart b/starport_template/lib/pages/transaction_history_page.dart index a01349c9..7f22b52f 100644 --- a/starport_template/lib/pages/transaction_history_page.dart +++ b/starport_template/lib/pages/transaction_history_page.dart @@ -5,11 +5,11 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; +import 'package:starport_template/entities/account_additional_data.dart'; import 'package:starport_template/entities/transaction_history_item.dart'; -import 'package:starport_template/entities/wallet_additional_data.dart'; +import 'package:starport_template/pages/accounts_list_sheet.dart'; import 'package:starport_template/pages/receive_money_sheet.dart'; import 'package:starport_template/pages/settings_sheet.dart'; -import 'package:starport_template/pages/wallets_list_sheet.dart'; import 'package:starport_template/starport_app.dart'; import 'package:starport_template/widgets/asset_portfolio_heading.dart'; import 'package:starport_template/widgets/transaction_history_list.dart'; @@ -23,9 +23,9 @@ class TransactionHistoryPage extends StatefulWidget { } class _TransactionHistoryPageState extends State { - WalletPublicInfo get selectedWallet => StarportApp.walletsStore.selectedWallet; + AccountPublicInfo get selectedAccount => StarportApp.accountsStore.selectedAccount; - String get walletAddress => selectedWallet.publicAddress; + String get accountAddress => selectedAccount.publicAddress; bool get isLoading => StarportApp.transactionsStore.isTransactionHistoryLoading; @@ -34,7 +34,7 @@ class _TransactionHistoryPageState extends State { @override void initState() { super.initState(); - StarportApp.transactionsStore.getTransactionHistory(walletAddress); + StarportApp.transactionsStore.getTransactionHistory(accountAddress); } @override @@ -47,9 +47,9 @@ class _TransactionHistoryPageState extends State { _appBar(theme, context), SizedBox(height: theme.spacingM), _gradientAvatar(context), - AssetPortfolioHeading(title: selectedWallet.name, onTap: _onDropDownTapped, isCentered: true), + AssetPortfolioHeading(title: selectedAccount.name, onTap: _onDropDownTapped, isCentered: true), _textButtonRow(context, theme), - if (!selectedWallet.data.isBackedUp) + if (!selectedAccount.data.isBackedUp) Padding( padding: EdgeInsets.all(theme.spacingL), child: CosmosWarningBox( @@ -124,28 +124,28 @@ class _TransactionHistoryPageState extends State { onTap: () {}, child: Padding( padding: EdgeInsets.all(CosmosTheme.of(context).spacingL), - child: SizedBox(height: 48, child: GradientAvatar(stringKey: walletAddress)), + child: SizedBox(height: 48, child: GradientAvatar(stringKey: accountAddress)), ), ); } Future _onDropDownTapped() async { - final wallet = await showMaterialModalBottomSheet( + final account = await showMaterialModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) => SizedBox( height: MediaQuery.of(context).size.height / 1.06, - child: const WalletsListSheet(), + child: const AccountsListSheet(), ), - ) as WalletPublicInfo?; + ) as AccountPublicInfo?; - if (wallet != null) { - StarportApp.walletsStore.selectWallet(wallet); - await StarportApp.transactionsStore.getTransactionHistory(walletAddress); + if (account != null) { + StarportApp.accountsStore.selectAccount(account); + await StarportApp.transactionsStore.getTransactionHistory(accountAddress); } } - void _onTapCopyAddress() => FlutterClipboard.copy(walletAddress); + void _onTapCopyAddress() => FlutterClipboard.copy(accountAddress); void _onTapReceive() { showMaterialModalBottomSheet( @@ -153,7 +153,7 @@ class _TransactionHistoryPageState extends State { backgroundColor: Colors.transparent, builder: (context) => SizedBox( height: MediaQuery.of(context).size.height / 1.06, - child: ReceiveMoneySheet(walletInfo: selectedWallet), + child: ReceiveMoneySheet(accountInfo: selectedAccount), ), ); } @@ -163,8 +163,8 @@ class _TransactionHistoryPageState extends State { super.debugFillProperties(properties); properties ..add(IterableProperty('transactionsList', transactionsList)) - ..add(DiagnosticsProperty('selectedWallet', selectedWallet)) - ..add(StringProperty('walletAddress', walletAddress)) + ..add(DiagnosticsProperty('selectedAccount', selectedAccount)) + ..add(StringProperty('accountAddress', accountAddress)) ..add(DiagnosticsProperty('isLoading', isLoading)); } diff --git a/starport_template/lib/pages/transfer_asset_page.dart b/starport_template/lib/pages/transfer_asset_page.dart index 6644117e..1983886c 100644 --- a/starport_template/lib/pages/transfer_asset_page.dart +++ b/starport_template/lib/pages/transfer_asset_page.dart @@ -31,10 +31,10 @@ class TransferAssetPage extends StatefulWidget { class _TransferAssetPageState extends State { double amount = 0; - double fee = StarportApp.walletsStore.defaultFee; - String walletAddress = ''; + double fee = StarportApp.accountsStore.defaultFee; + String accountAddress = ''; - bool get isTransferValidated => amount != 0.0 && walletAddress.isNotEmpty && fee != 0.0; + bool get isTransferValidated => amount != 0.0 && accountAddress.isNotEmpty && fee != 0.0; @override Widget build(BuildContext context) { @@ -56,7 +56,7 @@ class _TransferAssetPageState extends State { SizedBox(height: theme.spacingXXL), SendMoneyForm( onAddressChanged: (value) { - walletAddress = value; + accountAddress = value; setState(() {}); }, onAmountChanged: (value) { @@ -127,7 +127,7 @@ class _TransferAssetPageState extends State { transaction: MsgSendTransaction( amount: Amount.fromString(amount.toString()), fee: fee, - recipient: walletAddress, + recipient: accountAddress, ), balance: widget.balance, ), @@ -140,7 +140,7 @@ class _TransferAssetPageState extends State { super.debugFillProperties(properties); properties ..add(DoubleProperty('amount', amount)) - ..add(StringProperty('walletAddress', walletAddress)) + ..add(StringProperty('accountAddress', accountAddress)) ..add(DiagnosticsProperty('isTransferValidated', isTransferValidated)) ..add(DoubleProperty('fee', fee)); } diff --git a/starport_template/lib/starport_app.dart b/starport_template/lib/starport_app.dart index e6991030..9bda7735 100644 --- a/starport_template/lib/starport_app.dart +++ b/starport_template/lib/starport_app.dart @@ -4,9 +4,9 @@ import 'package:cosmos_ui_components/cosmos_theme.dart'; import 'package:cosmos_utils/cosmos_utils.dart'; import 'package:flutter/material.dart'; import 'package:starport_template/pages/routing_page.dart'; +import 'package:starport_template/stores/accounts_store.dart'; import 'package:starport_template/stores/settings_store.dart'; import 'package:starport_template/stores/transactions_store.dart'; -import 'package:starport_template/stores/wallets_store.dart'; import 'package:starport_template/utils/base_env.dart'; import 'package:transaction_signing_gateway/gateway/transaction_signing_gateway.dart'; @@ -16,7 +16,7 @@ class StarportApp extends StatelessWidget { }) : super(key: key); static late TransactionSigningGateway signingGateway; - static late WalletsStore walletsStore; + static late AccountsStore accountsStore; static late TransactionsStore transactionsStore; static late BaseEnv baseEnv; static late NetworkInfo networkInfo; diff --git a/starport_template/lib/stores/wallets_store.dart b/starport_template/lib/stores/accounts_store.dart similarity index 54% rename from starport_template/lib/stores/wallets_store.dart rename to starport_template/lib/stores/accounts_store.dart index 27879956..3c16ad1a 100644 --- a/starport_template/lib/stores/wallets_store.dart +++ b/starport_template/lib/stores/accounts_store.dart @@ -1,17 +1,17 @@ import 'package:cosmos_utils/cosmos_utils.dart'; import 'package:flutter/foundation.dart'; import 'package:mobx/mobx.dart'; +import 'package:starport_template/entities/account_additional_data.dart'; import 'package:starport_template/entities/balance.dart'; -import 'package:starport_template/entities/import_wallet_form_data.dart'; -import 'package:starport_template/entities/wallet_additional_data.dart'; +import 'package:starport_template/entities/import_account_form_data.dart'; import 'package:starport_template/utils/base_env.dart'; import 'package:starport_template/utils/cosmos_balances.dart'; import 'package:starport_template/utils/token_sender.dart'; -import 'package:transaction_signing_gateway/alan/alan_wallet_derivation_info.dart'; +import 'package:transaction_signing_gateway/alan/alan_account_derivation_info.dart'; import 'package:transaction_signing_gateway/transaction_signing_gateway.dart'; -class WalletsStore { - WalletsStore( +class AccountsStore { + AccountsStore( this._transactionSigningGateway, this.baseEnv, ); @@ -21,38 +21,38 @@ class WalletsStore { final BaseEnv baseEnv; - final Observable _areWalletsLoading = Observable(false); + final Observable _areAccountsLoading = Observable(false); final Observable _isSendMoneyLoading = Observable(false); final Observable _isSendMoneyError = Observable(false); final Observable _isBalancesLoading = Observable(false); - final Observable _isWalletImporting = Observable(false); - final Observable _isWalletImportingError = Observable(false); + final Observable _isAccountImporting = Observable(false); + final Observable _isAccountImportingError = Observable(false); final Observable _isMnemonicCreatingError = Observable(false); final Observable _isMnemonicCreating = Observable(false); final Observable _isBalancesLoadingError = Observable(false); - final Observable _isRenamingWallet = Observable(false); + final Observable _isRenamingAccount = Observable(false); final Observable _isSendingMoney = Observable(false); final ObservableList balancesList = ObservableList(); - final Observable loadWalletsFailure = Observable(null); - final Observable _renameWalletFailure = Observable(null); - final ObservableList wallets = ObservableList(); + final Observable loadAccountsFailure = Observable(null); + final Observable _renameAccountFailure = Observable(null); + final ObservableList accounts = ObservableList(); - int? get selectedWalletIndex => _selectedWalletIndex.value; + int? get selectedAccountIndex => _selectetAccountIndex.value; double get defaultFee => 0.02; - bool get areWalletsLoading => _areWalletsLoading.value; + bool get areAccountsLoading => _areAccountsLoading.value; - set areWalletsLoading(bool val) => Action(() => _areWalletsLoading.value = val)(); + set areAccountsLoading(bool val) => Action(() => _areAccountsLoading.value = val)(); bool get isSendingMoney => _isSendingMoney.value; set isSendingMoney(bool val) => Action(() => _isSendingMoney.value = val)(); - bool get isRenamingWallet => _isRenamingWallet.value; + bool get isRenamingAccount => _isRenamingAccount.value; - set isRenamingWallet(bool val) => Action(() => _isRenamingWallet.value = val)(); + set isRenamingAccount(bool val) => Action(() => _isRenamingAccount.value = val)(); bool get isSendMoneyError => _isSendMoneyError.value; @@ -70,9 +70,9 @@ class WalletsStore { set isBalancesLoading(bool val) => Action(() => _isBalancesLoading.value = val)(); - bool get isWalletImportingError => _isWalletImportingError.value; + bool get isAccountImportingError => _isAccountImportingError.value; - set isWalletImportingError(bool val) => Action(() => _isWalletImportingError.value = val)(); + set isAccountImportingError(bool val) => Action(() => _isAccountImportingError.value = val)(); bool get isMnemonicCreatingError => _isMnemonicCreatingError.value; @@ -82,74 +82,74 @@ class WalletsStore { set isMnemonicCreating(bool val) => Action(() => _isMnemonicCreating.value = val)(); - bool get isWalletImporting => _isWalletImporting.value; + bool get isAccountImporting => _isAccountImporting.value; - set isWalletImporting(bool val) => Action(() => _isWalletImporting.value = val)(); + set isAccountImporting(bool val) => Action(() => _isAccountImporting.value = val)(); - CredentialsStorageFailure? get renameWalletFailure => _renameWalletFailure.value; + CredentialsStorageFailure? get renameAccountFailure => _renameAccountFailure.value; - set renameWalletFailure(CredentialsStorageFailure? val) => Action(() => _renameWalletFailure.value = val)(); + set renameAccountFailure(CredentialsStorageFailure? val) => Action(() => _renameAccountFailure.value = val)(); - WalletPublicInfo get selectedWallet { - final index = _selectedWalletIndex.value; + AccountPublicInfo get selectedAccount { + final index = _selectetAccountIndex.value; if (index == null) { - return const WalletPublicInfo( + return const AccountPublicInfo( chainId: '', name: '', publicAddress: '', - walletId: '', + accountId: '', ); } - return wallets[index]; + return accounts[index]; } - final Observable _selectedWalletIndex = Observable(null); + final Observable _selectetAccountIndex = Observable(null); - set selectedWalletIndex(int? value) { - if (_selectedWalletIndex.value != value) { - Action(() => _selectedWalletIndex.value = value)(); - getBalances(selectedWallet.publicAddress); - debugLog('wallet address: ${selectedWallet.publicAddress}'); + set selectedAccountIndex(int? value) { + if (_selectetAccountIndex.value != value) { + Action(() => _selectetAccountIndex.value = value)(); + getBalances(selectedAccount.publicAddress); + debugLog('account address: ${selectedAccount.publicAddress}'); } } - Future loadWallets() async { - areWalletsLoading = true; - (await _transactionSigningGateway.getWalletsList()).fold( - (fail) => Action(() => loadWalletsFailure.value = fail)(), - (newWallets) { - wallets + Future loadAccounts() async { + areAccountsLoading = true; + (await _transactionSigningGateway.getAccountsList()).fold( + (fail) => Action(() => loadAccountsFailure.value = fail)(), + (newAccounts) { + accounts ..clear() - ..addAll(newWallets); - if (wallets.isNotEmpty) { - selectedWalletIndex = 0; + ..addAll(newAccounts); + if (accounts.isNotEmpty) { + selectedAccountIndex = 0; } }, ); - areWalletsLoading = false; + areAccountsLoading = false; } - Future renameWallet(String name) async { - isRenamingWallet = true; - final newInfo = selectedWallet.copyWith(name: name); - (await _transactionSigningGateway.updateWalletPublicInfo( + Future renameAccount(String name) async { + isRenamingAccount = true; + final newInfo = selectedAccount.copyWith(name: name); + (await _transactionSigningGateway.updateAccountPublicInfo( info: newInfo, )) .fold( - (fail) => Action(() => renameWalletFailure = fail)(), + (fail) => Action(() => renameAccountFailure = fail)(), (success) { - final index = wallets.indexWhere((it) => it.walletId == newInfo.walletId); - wallets[index] = newInfo; + final index = accounts.indexWhere((it) => it.accountId == newInfo.accountId); + accounts[index] = newInfo; }, ); - isRenamingWallet = false; + isRenamingAccount = false; } - Future getBalances(String walletAddress) async { + Future getBalances(String accountAddress) async { isBalancesLoadingError = false; isBalancesLoading = true; try { - final newBalances = await CosmosBalances(baseEnv).getBalances(walletAddress); + final newBalances = await CosmosBalances(baseEnv).getBalances(accountAddress); balancesList ..clear() ..addAll(newBalances); @@ -160,16 +160,16 @@ class WalletsStore { isBalancesLoading = false; } - Future importAlanWallet( - ImportWalletFormData data, { - VoidCallback? onWalletCreationStarted, + Future importAlanAccount( + ImportAccountFormData data, { + VoidCallback? onAccountCreationStarted, }) async { - isWalletImportingError = false; - isWalletImporting = true; + isAccountImportingError = false; + isAccountImporting = true; final result = await _transactionSigningGateway - .deriveWallet( - walletDerivationInfo: AlanWalletDerivationInfo( - walletAlias: data.name, + .deriveAccount( + accountDerivationInfo: AlanAccountDerivationInfo( + accountAlias: data.name, networkInfo: baseEnv.networkInfo, mnemonic: data.mnemonic, chainId: chainId, @@ -180,13 +180,13 @@ class WalletsStore { }).flatMap( (credentials) { return _transactionSigningGateway - .storeWalletCredentials( + .storeAccountCredentials( credentials: credentials, password: data.password, ) .flatMap( (_) async { - return _transactionSigningGateway.updateWalletPublicInfo( + return _transactionSigningGateway.updateAccountPublicInfo( info: credentials.publicInfo.copyWith( additionalData: data.additionalData.toJsonString(), ), @@ -198,17 +198,17 @@ class WalletsStore { }, ); - isWalletImporting = false; + isAccountImporting = false; return result.fold( (fail) { logError(fail); - isWalletImportingError = true; + isAccountImportingError = true; return null; }, (credentials) { - wallets.add(credentials.publicInfo); - if (selectedWallet.publicAddress.isEmpty) { - selectedWalletIndex = 0; + accounts.add(credentials.publicInfo); + if (selectedAccount.publicAddress.isEmpty) { + selectedAccountIndex = 0; } return credentials.publicInfo; }, @@ -216,7 +216,7 @@ class WalletsStore { } Future sendTokens({ - required WalletPublicInfo info, + required AccountPublicInfo info, required Balance balance, required String toAddress, required String password, @@ -231,7 +231,7 @@ class WalletsStore { password, ); - await getBalances(selectedWallet.publicAddress); + await getBalances(selectedAccount.publicAddress); } catch (ex, stack) { logError(ex, stack); isSendMoneyError = true; @@ -239,24 +239,24 @@ class WalletsStore { isSendMoneyLoading = false; } - Future createNewWallet({ + Future createNewAccount({ required String password, required bool isBackedUp, VoidCallback? onMnemonicGenerationStarted, - VoidCallback? onWalletCreationStarted, + VoidCallback? onAccountCreationStarted, }) async { final mnemonic = await createMnemonic(onMnemonicGenerationStarted); if (mnemonic == null) { return null; } - return importAlanWallet( - ImportWalletFormData( + return importAlanAccount( + ImportAccountFormData( mnemonic: mnemonic, - name: 'Wallet ${wallets.length + 1}', - additionalData: WalletAdditionalData(isBackedUp: isBackedUp), + name: 'Account ${accounts.length + 1}', + additionalData: AccountAdditionalData(isBackedUp: isBackedUp), password: password, ), - onWalletCreationStarted: onWalletCreationStarted, + onAccountCreationStarted: onAccountCreationStarted, ); } @@ -277,9 +277,9 @@ class WalletsStore { return mnemonic; } - void selectWallet(WalletPublicInfo wallet) { + void selectAccount(AccountPublicInfo account) { try { - selectedWalletIndex = wallets.indexWhere((element) => element.walletId == wallet.walletId); + selectedAccountIndex = accounts.indexWhere((element) => element.accountId == account.accountId); } catch (ex, stack) { logError(ex, stack); } diff --git a/starport_template/lib/stores/transactions_store.dart b/starport_template/lib/stores/transactions_store.dart index ec273e75..fa4eadf0 100644 --- a/starport_template/lib/stores/transactions_store.dart +++ b/starport_template/lib/stores/transactions_store.dart @@ -21,10 +21,10 @@ class TransactionsStore { set isTransactionHistoryError(bool val) => Action(() => _isTransactionHistoryError.value = val)(); - Future getTransactionHistory(String walletAddress) async { + Future getTransactionHistory(String accountAddress) async { isTransactionHistoryLoading = true; try { - final list = await CosmosTransactionHistoryLoader(baseEnv).getTransactionHistory(walletAddress); + final list = await CosmosTransactionHistoryLoader(baseEnv).getTransactionHistory(accountAddress); transactionsList ..clear() ..addAll(list); diff --git a/starport_template/lib/utils/cosmos_balances.dart b/starport_template/lib/utils/cosmos_balances.dart index ee31589f..a9c84b12 100644 --- a/starport_template/lib/utils/cosmos_balances.dart +++ b/starport_template/lib/utils/cosmos_balances.dart @@ -12,8 +12,8 @@ class CosmosBalances { BaseEnv baseEnv; - Future> getBalances(String walletAddress) async { - final uri = '${baseEnv.baseApiUrl}/cosmos/bank/v1beta1/balances/$walletAddress'; + Future> getBalances(String accountAddress) async { + final uri = '${baseEnv.baseApiUrl}/cosmos/bank/v1beta1/balances/$accountAddress'; final response = await http.get(Uri.parse(uri)); final map = jsonDecode(response.body) as Map; if (map['balances'] == null) { diff --git a/starport_template/lib/utils/cosmos_transaction_history_loader.dart b/starport_template/lib/utils/cosmos_transaction_history_loader.dart index 6058326f..1b7271bf 100644 --- a/starport_template/lib/utils/cosmos_transaction_history_loader.dart +++ b/starport_template/lib/utils/cosmos_transaction_history_loader.dart @@ -12,9 +12,9 @@ class CosmosTransactionHistoryLoader { BaseEnv baseEnv; - Future> getTransactionHistory(String walletAddress) async { - final outGoingTransactions = await _getTransactionResponses(walletAddress, TransactionType.Send); - final incomingTransactions = await _getTransactionResponses(walletAddress, TransactionType.Receive); + Future> getTransactionHistory(String accountAddress) async { + final outGoingTransactions = await _getTransactionResponses(accountAddress, TransactionType.Send); + final incomingTransactions = await _getTransactionResponses(accountAddress, TransactionType.Receive); final list = [...outGoingTransactions, ...incomingTransactions] // ..sort((a, b) => b.date.compareTo(a.date)); @@ -22,9 +22,9 @@ class CosmosTransactionHistoryLoader { return list; } - Future> _getTransactionResponses(String walletAddress, TransactionType type) async { + Future> _getTransactionResponses(String accountAddress, TransactionType type) async { final uri = - '${baseEnv.baseApiUrl}/cosmos/tx/v1beta1/txs?events=transfer.${type == TransactionType.Send ? 'sender' : 'recipient'}%3D%27$walletAddress%27'; + '${baseEnv.baseApiUrl}/cosmos/tx/v1beta1/txs?events=transfer.${type == TransactionType.Send ? 'sender' : 'recipient'}%3D%27$accountAddress%27'; final response = await http.get(Uri.parse(uri)); final map = jsonDecode(response.body) as Map; if (map['tx_responses'] == null) { diff --git a/starport_template/lib/utils/token_sender.dart b/starport_template/lib/utils/token_sender.dart index 345dd4df..c3e91c89 100644 --- a/starport_template/lib/utils/token_sender.dart +++ b/starport_template/lib/utils/token_sender.dart @@ -3,10 +3,8 @@ import 'package:alan/proto/cosmos/bank/v1beta1/export.dart' as bank; import 'package:cosmos_utils/cosmos_utils.dart'; import 'package:flutter/foundation.dart'; import 'package:starport_template/entities/balance.dart'; -import 'package:transaction_signing_gateway/alan/alan_transaction.dart'; -import 'package:transaction_signing_gateway/gateway/transaction_signing_gateway.dart'; -import 'package:transaction_signing_gateway/model/wallet_lookup_key.dart'; -import 'package:transaction_signing_gateway/model/wallet_public_info.dart'; +import 'package:transaction_signing_gateway/model/account_lookup_key.dart'; +import 'package:transaction_signing_gateway/transaction_signing_gateway.dart'; class TokenSender { TokenSender(this.transactionSigningGateway); @@ -14,7 +12,7 @@ class TokenSender { TransactionSigningGateway transactionSigningGateway; Future sendCosmosMoney( - WalletPublicInfo info, + AccountPublicInfo info, Balance balance, String toAddress, String password, @@ -31,8 +29,8 @@ class TokenSender { final unsignedTransaction = UnsignedAlanTransaction(messages: [message]); - final walletLookupKey = WalletLookupKey( - walletId: info.walletId, + final accountLookupKey = AccountLookupKey( + accountId: info.accountId, chainId: info.chainId, password: password, ); @@ -40,12 +38,12 @@ class TokenSender { final result = await transactionSigningGateway .signTransaction( transaction: unsignedTransaction, - walletLookupKey: walletLookupKey, + accountLookupKey: accountLookupKey, ) .mapError((error) => throw error) .flatMap( (signed) => transactionSigningGateway.broadcastTransaction( - walletLookupKey: walletLookupKey, + accountLookupKey: accountLookupKey, transaction: signed, ), ); diff --git a/starport_template/lib/widgets/send_money_form.dart b/starport_template/lib/widgets/send_money_form.dart index 92ab4033..e7847ae6 100644 --- a/starport_template/lib/widgets/send_money_form.dart +++ b/starport_template/lib/widgets/send_money_form.dart @@ -55,7 +55,7 @@ class _SendMoneyFormState extends State { controller: controller, onChanged: widget.onAddressChanged, initialText: text, - hint: "Enter receiver's wallet address", + hint: "Enter receiver's account address", suffix: CosmosTextButton( onTap: _onTapPaste, text: 'Paste', diff --git a/starport_template/pubspec.lock b/starport_template/pubspec.lock index 6d980f1f..ac99cb98 100644 --- a/starport_template/pubspec.lock +++ b/starport_template/pubspec.lock @@ -28,7 +28,7 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "3.2.0" + version: "3.2.1" args: dependency: transitive description: @@ -153,7 +153,7 @@ packages: description: path: "packages/cosmos_auth" ref: main - resolved-ref: b30a9c089effaf83a9df78777b302411258d5f36 + resolved-ref: c55ed8cf98b7510245502b113a98b299b7659f37 url: "https://github.com/tendermint/flutter.git" source: git version: "0.0.1" @@ -162,7 +162,7 @@ packages: description: path: "packages/cosmos_ui_components" ref: main - resolved-ref: b30a9c089effaf83a9df78777b302411258d5f36 + resolved-ref: c55ed8cf98b7510245502b113a98b299b7659f37 url: "https://github.com/tendermint/flutter.git" source: git version: "0.0.1" @@ -171,7 +171,7 @@ packages: description: path: "packages/cosmos_utils" ref: main - resolved-ref: b30a9c089effaf83a9df78777b302411258d5f36 + resolved-ref: c55ed8cf98b7510245502b113a98b299b7659f37 url: "https://github.com/tendermint/flutter.git" source: git version: "0.0.1" @@ -392,7 +392,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "3.1.1" + version: "3.1.3" intl: dependency: "direct main" description: @@ -581,7 +581,7 @@ packages: name: pointycastle url: "https://pub.dartlang.org" source: hosted - version: "3.5.1" + version: "3.5.2" process: dependency: transitive description: @@ -693,7 +693,7 @@ packages: name: shared_preferences_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.10" + version: "2.1.0" shared_preferences_linux: dependency: transitive description: @@ -788,7 +788,7 @@ packages: description: path: "packages/transaction_signing_gateway" ref: main - resolved-ref: b30a9c089effaf83a9df78777b302411258d5f36 + resolved-ref: c55ed8cf98b7510245502b113a98b299b7659f37 url: "https://github.com/tendermint/flutter.git" source: git version: "0.0.1" @@ -847,7 +847,7 @@ packages: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.0.9" url_launcher_windows: dependency: transitive description: @@ -906,4 +906,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.15.0 <3.0.0" - flutter: ">=2.8.0" + flutter: ">=2.10.0"