Skip to content

Commit

Permalink
add minNominatorBond
Browse files Browse the repository at this point in the history
  • Loading branch information
RomeroYang committed Jul 8, 2021
1 parent 08ee203 commit 801469e
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 39 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 3 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -98,7 +97,7 @@ class _MyAppState extends State<MyApp> {
}

Future<void> _startPlugin() async {
await _keyring.init();
await _keyring.init([2]);

await _network.beforeStart(_keyring);
final connected = await _network.start(_keyring);
Expand Down
14 changes: 6 additions & 8 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 10 additions & 4 deletions lib/pages/staking/actions/bondPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class _BondPageState extends State<BondPage> {
labelText:
'${dic['amount']} (${dicStaking['available']}: ${Fmt.priceFloor(
available,
lengthMax: 3,
lengthMax: 4,
)} $symbol)',
),
inputFormatters: [UI.decimalInputFormatter(decimals)],
Expand All @@ -135,9 +135,15 @@ class _BondPageState extends State<BondPage> {
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;
},
),
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/staking/validators/overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ class _StakingOverviewPageState extends State<StakingOverviewPage> {
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),
),
],
),
Expand Down
1 change: 1 addition & 0 deletions lib/polkawallet_plugin_kusama.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/store/staking/staking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ abstract class _StakingStore with Store {
'totalStaked': data['totalStaked'],
'totalIssuance': data['totalIssuance'],
'minNominated': data['minNominated'],
'minNominatorBond': data['minNominatorBond'],
};

// all validators
Expand Down
5 changes: 3 additions & 2 deletions lib/utils/i18n/en/staking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Map<String, String> 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',
Expand All @@ -19,10 +19,11 @@ const Map<String, String> 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',
Expand Down
5 changes: 3 additions & 2 deletions lib/utils/i18n/zh/staking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Map<String, String> zhStaking = {
'overview': '概览',
'overview.total': '质押总量',
'overview.reward': '平均收益',
'overview.min': '最低金额',
'overview.min': '最低提名/绑定',
'actions': '账户操作',
'validators': '验证人',
'validator': '验证人',
Expand All @@ -19,9 +19,10 @@ const Map<String, String> 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': '佣金',
Expand Down
20 changes: 9 additions & 11 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
11 changes: 8 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 801469e

Please sign in to comment.