From 801469ec3b822f356f7767821e242182315ee6df Mon Sep 17 00:00:00 2001 From: shawn Date: Thu, 8 Jul 2021 12:56:24 +0800 Subject: [PATCH] add minNominatorBond --- CHANGELOG.md | 6 ++++++ example/lib/main.dart | 7 +++---- example/pubspec.lock | 14 ++++++-------- example/pubspec.yaml | 8 ++++---- lib/pages/staking/actions/bondPage.dart | 14 ++++++++++---- lib/pages/staking/validators/overview.dart | 4 +++- lib/polkawallet_plugin_kusama.dart | 1 + lib/store/staking/staking.dart | 1 + lib/utils/i18n/en/staking.dart | 5 +++-- lib/utils/i18n/zh/staking.dart | 5 +++-- pubspec.lock | 20 +++++++++----------- pubspec.yaml | 11 ++++++++--- 12 files changed, 57 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35815ab88..b376e39ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [0.2.4] - 20210708. + +* bump polkawallet_sdk: 0.2.4. +* add XCM support. +* add minNominatorBond. + ## [0.2.3] - 20210628. * bump polkawallet_sdk: 0.2.3. diff --git a/example/lib/main.dart b/example/lib/main.dart index c64e54f76..5d63382bc 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,17 +1,16 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:polkawallet_plugin_kusama/polkawallet_plugin_kusama.dart'; import 'package:polkawallet_plugin_kusama_example/pages/assetsContent.dart'; +import 'package:polkawallet_plugin_kusama_example/pages/homePage.dart'; import 'package:polkawallet_plugin_kusama_example/pages/profileContent.dart'; import 'package:polkawallet_plugin_kusama_example/pages/selectListPage.dart'; - import 'package:polkawallet_sdk/api/types/networkParams.dart'; import 'package:polkawallet_sdk/plugin/index.dart'; import 'package:polkawallet_sdk/storage/keyring.dart'; import 'package:polkawallet_sdk/storage/types/keyPairData.dart'; import 'package:polkawallet_sdk/utils/i18n.dart'; -import 'package:polkawallet_plugin_kusama/polkawallet_plugin_kusama.dart'; -import 'package:polkawallet_plugin_kusama_example/pages/homePage.dart'; import 'package:polkawallet_ui/components/passwordInputDialog.dart'; import 'package:polkawallet_ui/pages/accountListPage.dart'; import 'package:polkawallet_ui/pages/qrSenderPage.dart'; @@ -98,7 +97,7 @@ class _MyAppState extends State { } Future _startPlugin() async { - await _keyring.init(); + await _keyring.init([2]); await _network.beforeStart(_keyring); final connected = await _network.start(_keyring); diff --git a/example/pubspec.lock b/example/pubspec.lock index 60bcbb99c..0bd2fe7a4 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -395,23 +395,21 @@ packages: path: ".." relative: true source: path - version: "0.1.8" + version: "0.2.3" polkawallet_sdk: dependency: transitive description: name: polkawallet_sdk url: "https://pub.dartlang.org" source: hosted - version: "0.1.8" + version: "0.2.3" polkawallet_ui: dependency: "direct main" description: - path: "." - ref: a181a240a0c2b098a2e4140e07d036ea8222cea1 - resolved-ref: a181a240a0c2b098a2e4140e07d036ea8222cea1 - url: "https://github.com/polkawallet-io/ui.git" - source: git - version: "0.1.8" + path: "../../ui" + relative: true + source: path + version: "0.2.2" process: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 95beffcc3..d5b64c0ca 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -27,10 +27,10 @@ dependencies: sdk: flutter flutter_mobx: ^2.0.0 polkawallet_ui: - git: - url: https://github.com/polkawallet-io/ui.git - ref: a181a240a0c2b098a2e4140e07d036ea8222cea1 -# path: ../../ui +# git: +# url: https://github.com/polkawallet-io/ui.git +# ref: a181a240a0c2b098a2e4140e07d036ea8222cea1 + path: ../../ui # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. diff --git a/lib/pages/staking/actions/bondPage.dart b/lib/pages/staking/actions/bondPage.dart index 71a3c29c0..f219b65cf 100644 --- a/lib/pages/staking/actions/bondPage.dart +++ b/lib/pages/staking/actions/bondPage.dart @@ -124,7 +124,7 @@ class _BondPageState extends State { labelText: '${dic['amount']} (${dicStaking['available']}: ${Fmt.priceFloor( available, - lengthMax: 3, + lengthMax: 4, )} $symbol)', ), inputFormatters: [UI.decimalInputFormatter(decimals)], @@ -135,9 +135,15 @@ class _BondPageState extends State { if (v.isEmpty) { return dic['amount.error']; } - // if (double.parse(v.trim()) >= available) { - // return dic['amount.low']; - // } + final amount = double.parse(v.trim()); + if (amount >= available) { + return dic['amount.low']; + } + final minBond = Fmt.balanceInt(widget + .plugin.store.staking.overview['minNominatorBond']); + if (amount < Fmt.bigIntToDouble(minBond, decimals)) { + return '${dicStaking['stake.bond.min']} ${Fmt.priceCeilBigInt(minBond, decimals)}'; + } return null; }, ), diff --git a/lib/pages/staking/validators/overview.dart b/lib/pages/staking/validators/overview.dart index 7732a390b..a598b56a1 100644 --- a/lib/pages/staking/validators/overview.dart +++ b/lib/pages/staking/validators/overview.dart @@ -234,7 +234,9 @@ class _StakingOverviewPageState extends State { InfoItem( crossAxisAlignment: CrossAxisAlignment.center, title: dicStaking['overview.min'], - content: Fmt.balance(overview['minNominated'], decimals), + content: Fmt.balance(overview['minNominated'], decimals) + + ' / ' + + Fmt.balance(overview['minNominatorBond'], decimals), ), ], ), diff --git a/lib/polkawallet_plugin_kusama.dart b/lib/polkawallet_plugin_kusama.dart index 380d48a07..e998985ee 100644 --- a/lib/polkawallet_plugin_kusama.dart +++ b/lib/polkawallet_plugin_kusama.dart @@ -72,6 +72,7 @@ class PluginKusama extends PolkawalletPlugin { 'packages/polkawallet_plugin_kusama/assets/images/public/${name}_gray.png'), jsCodeVersion: 21101, isTestNet: false, + isXCMSupport: name == network_name_kusama, ), recoveryEnabled = name == network_name_kusama, _cache = name == network_name_kusama diff --git a/lib/store/staking/staking.dart b/lib/store/staking/staking.dart index d96421f5f..a5d2b3c9c 100644 --- a/lib/store/staking/staking.dart +++ b/lib/store/staking/staking.dart @@ -96,6 +96,7 @@ abstract class _StakingStore with Store { 'totalStaked': data['totalStaked'], 'totalIssuance': data['totalIssuance'], 'minNominated': data['minNominated'], + 'minNominatorBond': data['minNominatorBond'], }; // all validators diff --git a/lib/utils/i18n/en/staking.dart b/lib/utils/i18n/en/staking.dart index cbf820352..024fcefdb 100644 --- a/lib/utils/i18n/en/staking.dart +++ b/lib/utils/i18n/en/staking.dart @@ -2,7 +2,7 @@ const Map enStaking = { 'overview': 'Overview', 'overview.total': 'Total staked', 'overview.reward': 'Returns', - 'overview.min': 'Min nominated', + 'overview.min': 'Min nominated/bond', 'actions': 'Account Actions', 'validators': 'Validators', 'validator': 'Validator', @@ -19,10 +19,11 @@ const Map enStaking = { 'stake.ratio': 'Staked', 'stake.own': 'Own', 'stake.other': 'Other', + 'stake.bond.min': 'Min nominator bond', 'stake.warn': '1: The bonded Tokens will be locked for about 28 days on Polkadot(7 days on Kusama) after unbonding.\n' '2: Your account should always have transferable balance for paying tx fees, so do not bond all your tokens.\n' - '3: The amount of bonded Tokens needs to meet the minimum requirements(see page: Validators), otherwise no reward will be generated.', + '3: The amount of bonded Tokens needs to meet the minimum requirements(see page: Validators).', 'stake.payee.warn': 'Tips: The balance of the destination account should not be 0, otherwise you may lose your reward due to existential deposit not met.', 'staked': 'Staked', diff --git a/lib/utils/i18n/zh/staking.dart b/lib/utils/i18n/zh/staking.dart index c6ce88012..3ed73a403 100644 --- a/lib/utils/i18n/zh/staking.dart +++ b/lib/utils/i18n/zh/staking.dart @@ -2,7 +2,7 @@ const Map zhStaking = { 'overview': '概览', 'overview.total': '质押总量', 'overview.reward': '平均收益', - 'overview.min': '最低金额', + 'overview.min': '最低提名/绑定', 'actions': '账户操作', 'validators': '验证人', 'validator': '验证人', @@ -19,9 +19,10 @@ const Map zhStaking = { 'stake.ratio': '质押率', 'stake.own': '节点', 'stake.other': '他人', + 'stake.bond.min': '最低质押金额', 'stake.warn': '1:绑定的资产在解绑时需要约28天的锁定时间(在 Kusama 网络上需要约7天)。\n' '2:你的账户应该留有余额以支付交易费,因此不要绑定全部资产。\n' - '3:你的绑定数量应该满足最低数量要求(见验证人页面),否则将不会产生质押收益。', + '3:你的绑定数量应该满足最低数量要求(见验证人页面)。', 'stake.payee.warn': '提示: 目标地址余额不能为空,否则您可能会因为不满足存活余额而丢失收益。', 'staked': '总质押', 'commission': '佣金', diff --git a/pubspec.lock b/pubspec.lock index ac59fbd52..d5e229e0a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -581,19 +581,17 @@ packages: polkawallet_sdk: dependency: "direct main" description: - name: polkawallet_sdk - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.8" + path: "../sdk" + relative: true + source: path + version: "0.2.3" polkawallet_ui: dependency: "direct main" description: - path: "." - ref: a181a240a0c2b098a2e4140e07d036ea8222cea1 - resolved-ref: a181a240a0c2b098a2e4140e07d036ea8222cea1 - url: "https://github.com/polkawallet-io/ui.git" - source: git - version: "0.1.8" + path: "../ui" + relative: true + source: path + version: "0.2.2" pool: dependency: transitive description: @@ -838,7 +836,7 @@ packages: name: webview_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.0.9" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 5403ce1a2..9e56670c0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,9 +20,14 @@ dependencies: json_annotation: ^4.0.1 polkawallet_sdk: ^0.2.2 polkawallet_ui: - git: - url: https://github.com/polkawallet-io/ui.git - ref: dee6fc6074f546e914c8794fd5e3a3e2b829b53c +# git: +# url: https://github.com/polkawallet-io/ui.git +# ref: dee6fc6074f546e914c8794fd5e3a3e2b829b53c + path: ../ui + +dependency_overrides: + polkawallet_sdk: + path: ../sdk dev_dependencies: build_runner: ^2.0.3