Skip to content

Commit

Permalink
add validator sort type: judgements
Browse files Browse the repository at this point in the history
  • Loading branch information
RomeroYang committed Sep 8, 2020
1 parent 328402b commit 62434ce
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 1.0.0
- rebuild staking module & update nominees list
- add validator sort type: judgements

# 0.9.9
- fix accountIndex parsing bug
Expand Down
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = WQ5H736A22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -518,7 +518,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = WQ5H736A22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -548,7 +548,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = WQ5H736A22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
2 changes: 1 addition & 1 deletion lib/common/components/validatorListFilter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:polka_wallet/utils/i18n/index.dart';

enum ValidatorSortOptions { staked, points, commission }
enum ValidatorSortOptions { staked, points, commission, judgements }

class ValidatorListFilter extends StatefulWidget {
ValidatorListFilter({this.onFilterChange, this.onSortChange});
Expand Down
4 changes: 2 additions & 2 deletions lib/common/consts/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ const String cross_chain_transfer_address_laminar =
'5CLaminarAUSDCrossChainTransferxxxxxxxxxxxxxwisu';

/// app versions
const String app_beta_version = 'v1.0.0-beta.2';
const int app_beta_version_code = 1002;
const String app_beta_version = 'v1.0.0-beta.3';
const int app_beta_version_code = 1003;

/// js code versions
const Map<String, int> js_code_version_map = {
Expand Down
1 change: 0 additions & 1 deletion lib/page/assets/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ class _AssetsState extends State<Assets> {
super.initState();
}

// todo: add account index display
@override
Widget build(BuildContext context) {
final Map dic = I18n.of(context).home;
Expand Down
3 changes: 2 additions & 1 deletion lib/page/staking/validators/nominatePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ class _NominatePageState extends State<NominatePage> {
retained = Fmt.filterValidatorList(
retained, _filter, store.account.addressIndexMap);
// and sort it
retained.sort((a, b) => Fmt.sortValidatorList(a, b, _sort));
retained.sort((a, b) =>
Fmt.sortValidatorList(store.account.addressIndexMap, a, b, _sort));
list.addAll(retained);

return Scaffold(
Expand Down
4 changes: 2 additions & 2 deletions lib/page/staking/validators/overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ class _StakingOverviewPageState extends State<StakingOverviewPage>
ls = Fmt.filterValidatorList(
ls, _filter, store.account.addressIndexMap);
// sort list
// todo: add sort option <known good>
ls.sort((a, b) => Fmt.sortValidatorList(a, b, _sort));
ls.sort((a, b) => Fmt.sortValidatorList(
store.account.addressIndexMap, a, b, _sort));
list.addAll(ls);
} else {
list.add(Container(
Expand Down
12 changes: 11 additions & 1 deletion lib/utils/format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ class Fmt {
return reg.hasMatch(pass);
}

static int sortValidatorList(ValidatorData a, ValidatorData b, int sortType) {
static int sortValidatorList(
Map addressIndexMap, ValidatorData a, ValidatorData b, int sortType) {
if (a.commission == null || a.commission.isEmpty) {
return 1;
}
Expand All @@ -230,6 +231,15 @@ class Fmt {
return a.points == b.points ? cmpStake : a.points < b.points ? 1 : -1;
case 2:
return comA == comB ? cmpStake : comA > comB ? 1 : -1;
case 3:
final infoA = addressIndexMap[a.accountId];
if (infoA != null && infoA['identity'] != null) {
final List judgements = infoA['identity']['judgements'];
if (judgements != null && judgements.length > 0) {
return -1;
}
}
return 1;
default:
return -1;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/i18n/staking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Map<String, String> enStaking = {
'staked': 'Staked',
'commission': 'Commission',
'points': 'Points',
'judgements': 'Judgements',
'txs': 'Staking Records',
'txs.reward': 'Reward/Slash',
'txs.reward.reward': 'Reward',
Expand Down Expand Up @@ -85,6 +86,7 @@ const Map<String, String> zhStaking = {
'staked': '总质押',
'commission': '佣金',
'points': '得分',
'judgements': '评价',
'txs': '质押记录',
'txs.reward': '收益/罚金',
'txs.reward.reward': '收益',
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: PolkaWallet made with Flutter.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1002
version: 1.0.0+1003

environment:
sdk: ">=2.1.0 <3.0.0"
Expand Down

0 comments on commit 62434ce

Please sign in to comment.