Skip to content

Commit 725b09d

Browse files
authored
Merge branch 'master' into ab/remarks
2 parents e4c7b27 + 0d032ac commit 725b09d

File tree

67 files changed

+2410
-763
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2410
-763
lines changed

app/lib/l10n/arb/app_de.arb

+30
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,36 @@
395395
}
396396
}
397397
},
398+
"proposalPetition": "{cid} Petition: {value}",
399+
"@proposalPetition": {
400+
"placeholders": {
401+
"cid": {
402+
"type": "String",
403+
"example": "global"
404+
},
405+
"value": {
406+
"type": "String",
407+
"example": "Peace to the World"
408+
}
409+
}
410+
},
411+
"proposalSpendNative": "{cid} Kasse soll {amount} KSM an {beneficiary} senden",
412+
"@proposalSpendNative": {
413+
"placeholders": {
414+
"cid": {
415+
"type": "String",
416+
"example": "global"
417+
},
418+
"amount": {
419+
"type": "String",
420+
"example": "0.00"
421+
},
422+
"beneficiary": {
423+
"type": "String",
424+
"example": "HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F"
425+
}
426+
}
427+
},
398428
"proposalSupersededBy": "Verdrängt durch: {id}",
399429
"@proposalSupersededBy": {
400430
"placeholders": {

app/lib/l10n/arb/app_en.arb

+30
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,36 @@
554554
}
555555
}
556556
},
557+
"proposalPetition": "{cid} petition: {value}",
558+
"@proposalPetition": {
559+
"placeholders": {
560+
"cid": {
561+
"type": "String",
562+
"example": "global"
563+
},
564+
"value": {
565+
"type": "String",
566+
"example": "Peace to the World"
567+
}
568+
}
569+
},
570+
"proposalSpendNative": "{cid} treasury shall spend {amount} KSM to {beneficiary}",
571+
"@proposalSpendNative": {
572+
"placeholders": {
573+
"cid": {
574+
"type": "String",
575+
"example": "global"
576+
},
577+
"amount": {
578+
"type": "String",
579+
"example": "0.00"
580+
},
581+
"beneficiary": {
582+
"type": "String",
583+
"example": "HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F"
584+
}
585+
}
586+
},
557587
"proposalSupersededBy": "Superseded by: {id}",
558588
"@proposalSupersededBy": {
559589
"placeholders": {

app/lib/l10n/arb/app_fr.arb

+30
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,36 @@
395395
}
396396
}
397397
},
398+
"proposalPetition": "{cid} petition: {value}",
399+
"@proposalPetition": {
400+
"placeholders": {
401+
"cid": {
402+
"type": "String",
403+
"example": "global"
404+
},
405+
"value": {
406+
"type": "String",
407+
"example": "Peace to the World"
408+
}
409+
}
410+
},
411+
"proposalSpendNative": "{cid} trèsor enverra {amount} KSM à {beneficiary}",
412+
"@proposalSpendNative": {
413+
"placeholders": {
414+
"cid": {
415+
"type": "String",
416+
"example": "global"
417+
},
418+
"amount": {
419+
"type": "String",
420+
"example": "0.00"
421+
},
422+
"beneficiary": {
423+
"type": "String",
424+
"example": "HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F"
425+
}
426+
}
427+
},
398428
"proposalSupersededBy": "Epargné par: {id}",
399429
"@proposalSupersededBy": {
400430
"placeholders": {

app/lib/l10n/arb/app_ru.arb

+30
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,36 @@
395395
}
396396
}
397397
},
398+
"proposalPetition": "{cid} петиция: {value}",
399+
"@proposalPetition": {
400+
"placeholders": {
401+
"cid": {
402+
"type": "String",
403+
"example": "global"
404+
},
405+
"value": {
406+
"type": "String",
407+
"example": "Peace to the World"
408+
}
409+
}
410+
},
411+
"proposalSpendNative": "{cid} Казначейство отправит {amount} KSM {beneficiary}",
412+
"@proposalSpendNative": {
413+
"placeholders": {
414+
"cid": {
415+
"type": "String",
416+
"example": "global"
417+
},
418+
"amount": {
419+
"type": "String",
420+
"example": "0.00"
421+
},
422+
"beneficiary": {
423+
"type": "String",
424+
"example": "HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F"
425+
}
426+
}
427+
},
398428
"proposalSupersededBy": "заменен на: {id}",
399429
"@proposalSupersededBy": {
400430
"placeholders": {

app/lib/l10n/arb/app_sw.arb

+30
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,36 @@
548548
}
549549
}
550550
},
551+
"proposalPetition": "{cid} petitioni: {value}",
552+
"@proposalPetition": {
553+
"placeholders": {
554+
"cid": {
555+
"type": "String",
556+
"example": "global"
557+
},
558+
"value": {
559+
"type": "String",
560+
"example": "Peace to the World"
561+
}
562+
}
563+
},
564+
"proposalSpendNative": "{cid} hazina itatuma {amount} KSM kwa {beneficiary}",
565+
"@proposalSpendNative": {
566+
"placeholders": {
567+
"cid": {
568+
"type": "String",
569+
"example": "global"
570+
},
571+
"amount": {
572+
"type": "String",
573+
"example": "0.00"
574+
},
575+
"beneficiary": {
576+
"type": "String",
577+
"example": "HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F"
578+
}
579+
}
580+
},
551581
"proposalSupersededBy": "Imetanguliwa na: {id}",
552582
"@proposalSupersededBy": {
553583
"placeholders": {

app/lib/page-encointer/democracy/democracy_page.dart

+6-3
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ class _DemocracyPageState extends State<DemocracyPage> {
4141
}
4242

4343
Future<void> _init() async {
44-
final proposalIds = await webApi.encointer.getHistoricProposalIds(count: BigInt.from(50));
44+
final maybeProposalIds = await webApi.encointer.getHistoricProposalIds(count: BigInt.from(50));
4545

46-
final allProposals = await webApi.encointer.getProposals(proposalIds);
46+
final allProposals = await webApi.encointer.getProposals(maybeProposalIds);
47+
// Reduce proposalIds to the entries which also exist in allProposals
48+
// this is necessary, because migrations may purge incompatible (non-decodable) proposals,
49+
// but never the index
50+
final proposalIds = maybeProposalIds.where(allProposals.containsKey).toList();
4751
final allTallies = await webApi.encointer.getTallies(proposalIds);
4852
final allPurposeIds = await webApi.encointer.getProposalPurposeIds(proposalIds);
49-
5053
democracyParams = webApi.encointer.democracyParams();
5154

5255
proposals = allProposals;

app/lib/page-encointer/democracy/helpers.dart

+33
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import 'dart:math';
22

3+
import 'package:encointer_wallet/config/consts.dart';
34
import 'package:encointer_wallet/l10n/l10.dart';
45
import 'package:encointer_wallet/models/communities/community_identifier.dart';
56
import 'package:encointer_wallet/service/service.dart';
67
import 'package:encointer_wallet/service/substrate_api/encointer/encointer_api.dart';
78
import 'package:encointer_wallet/store/app.dart';
9+
import 'package:encointer_wallet/utils/format.dart';
10+
import 'package:ew_keyring/ew_keyring.dart';
811
import 'package:ew_substrate_fixed/substrate_fixed.dart';
912
import 'package:flutter/material.dart';
1013
import 'package:provider/provider.dart';
@@ -14,10 +17,12 @@ import 'package:ew_polkadart/encointer_types.dart' as et;
1417
import 'package:ew_polkadart/ew_polkadart.dart'
1518
show
1619
AddLocation,
20+
Petition,
1721
Proposal,
1822
ProposalAction,
1923
RemoveLocation,
2024
SetInactivityTimeout,
25+
SpendNative,
2126
Tally,
2227
UpdateDemurrage,
2328
UpdateNominalIncome;
@@ -27,6 +32,7 @@ import 'package:ew_polkadart/ew_polkadart.dart'
2732
/// Todo: add localization for all variants.
2833
String getProposalActionTitle(BuildContext context, ProposalAction action) {
2934
final l10n = context.l10n;
35+
final store = context.read<AppStore>();
3036

3137
switch (action.runtimeType) {
3238
case UpdateNominalIncome:
@@ -52,11 +58,32 @@ String getProposalActionTitle(BuildContext context, ProposalAction action) {
5258
return 'Remove Location (unsupported)';
5359
case SetInactivityTimeout:
5460
return 'SetInactivity Timeout (unsupported)';
61+
case Petition:
62+
final cidPolkadart = getCommunityIdentifierFromProposal(action);
63+
final cidStr = cidOrGlobal(cidPolkadart, store);
64+
final demand = String.fromCharCodes((action as Petition).value1);
65+
return l10n.proposalPetition(cidStr, demand);
66+
case SpendNative:
67+
final cidPolkadart = getCommunityIdentifierFromProposal(action);
68+
final cidStr = cidOrGlobal(cidPolkadart, store);
69+
final beneficiary = Fmt.address(
70+
AddressUtils.pubKeyToAddress((action as SpendNative).value1, prefix: store.settings.currentNetwork.ss58()))!;
71+
final amount = Fmt.token(action.value2, ertDecimals);
72+
return l10n.proposalSpendNative(cidStr, amount, beneficiary);
5573
default:
5674
throw Exception('ProposalAction: Invalid Type: "${action.runtimeType}"');
5775
}
5876
}
5977

78+
String cidOrGlobal(et.CommunityIdentifier? cidPolkadart, AppStore store) {
79+
final cidStr = cidPolkadart == null
80+
? 'global'
81+
: (store.encointer.communityStores![CommunityIdentifier(cidPolkadart.geohash, cidPolkadart.digest).toFmtString()]
82+
?.symbol ??
83+
CommunityIdentifier(cidPolkadart.geohash, cidPolkadart.digest).toFmtString());
84+
return cidStr;
85+
}
86+
6087
double demurragePerMonth(double demurrage, BigInt blockProductionTime) {
6188
return (1 - exp(-1 * demurrage * blocksPerMonth(blockProductionTime))) * 100;
6289
}
@@ -81,6 +108,12 @@ et.CommunityIdentifier? getCommunityIdentifierFromProposal(ProposalAction action
81108
case SetInactivityTimeout:
82109
// This is a global action hence all communities can vote for it.
83110
return null;
111+
case Petition:
112+
// can be global or local
113+
return (action as Petition).value0;
114+
case SpendNative:
115+
// can be global or local
116+
return (action as SpendNative).value0;
84117
default:
85118
throw Exception('ProposalAction: Invalid Type: "${action.runtimeType}"');
86119
}

app/lib/service/substrate_api/encointer/encointer_api.dart

+13-9
Original file line numberDiff line numberDiff line change
@@ -734,21 +734,25 @@ class EncointerApi {
734734

735735
Future<Map<BigInt, Proposal>> getProposals(List<BigInt> proposalIds, {BlockHash? at}) async {
736736
try {
737-
// Keys including storage prefix.
738-
Log.d("[getProposals] ProposalIds: $proposalIds')}");
737+
Log.d('[getProposals] ProposalIds: $proposalIds');
739738

740739
final proposals = await Future.wait(proposalIds.map(
741-
(key) => encointerKusama.query.encointerDemocracy
742-
.proposals(key, at: at ?? store.chain.latestHash)
743-
.then((maybeProposal) => maybeProposal!),
740+
(key) => encointerKusama.query.encointerDemocracy.proposals(key, at: at ?? store.chain.latestHash),
744741
));
745742

746-
final proposalMap = Map.fromIterables(proposalIds, proposals);
747-
Log.d('[getProposals] proposals: $proposalMap');
748-
return proposalMap;
743+
// We need to assume that old proposals have been purged from the state. So we need to filter out null values.
744+
final validProposals = <BigInt, Proposal>{};
745+
for (var i = 0; i < proposalIds.length; i++) {
746+
if (proposals[i] != null) {
747+
validProposals[proposalIds[i]] = proposals[i]!;
748+
}
749+
}
750+
751+
Log.d('[getProposals] valid proposals: $validProposals');
752+
return validProposals;
749753
} catch (e, s) {
750754
Log.e('[getProposals]', '$e', s);
751-
return Map.of({});
755+
return {};
752756
}
753757
}
754758

packages/ew_polkadart/lib/ew_polkadart.dart

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ export 'package:polkadart/polkadart.dart';
88
// encointer democracy exports
99
export 'generated/encointer_kusama/types/encointer_primitives/democracy/proposal.dart' show Proposal;
1010
export 'generated/encointer_kusama/types/encointer_primitives/democracy/proposal_action.dart'
11-
show ProposalAction, AddLocation, RemoveLocation, UpdateDemurrage, UpdateNominalIncome, SetInactivityTimeout;
11+
show
12+
ProposalAction,
13+
AddLocation,
14+
RemoveLocation,
15+
UpdateDemurrage,
16+
UpdateNominalIncome,
17+
SetInactivityTimeout,
18+
Petition,
19+
SpendNative;
1220
export 'generated/encointer_kusama/types/encointer_primitives/democracy/proposal_action_identifier.dart'
1321
show ProposalActionIdentifier;
1422
export 'generated/encointer_kusama/types/encointer_primitives/democracy/proposal_state.dart'

packages/ew_polkadart/lib/generated/encointer_kusama/encointer_kusama.dart

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// ignore_for_file: no_leading_underscores_for_library_prefixes
2-
import 'dart:async' as _i21;
2+
import 'dart:async' as _i23;
33

44
import 'package:polkadart/polkadart.dart' as _i1;
55

6+
import 'pallets/aura.dart' as _i21;
67
import 'pallets/balances.dart' as _i6;
78
import 'pallets/encointer_balances.dart' as _i15;
89
import 'pallets/encointer_bazaar.dart' as _i16;
@@ -12,6 +13,7 @@ import 'pallets/encointer_democracy.dart' as _i19;
1213
import 'pallets/encointer_faucet.dart' as _i18;
1314
import 'pallets/encointer_reputation_commitments.dart' as _i17;
1415
import 'pallets/encointer_scheduler.dart' as _i12;
16+
import 'pallets/encointer_treasuries.dart' as _i22;
1517
import 'pallets/grandpa.dart' as _i8;
1618
import 'pallets/proxy.dart' as _i9;
1719
import 'pallets/randomness_collective_flip.dart' as _i3;
@@ -130,6 +132,8 @@ class Constants {
130132

131133
final _i7.Constants transactionPayment = _i7.Constants();
132134

135+
final _i21.Constants aura = _i21.Constants();
136+
133137
final _i8.Constants grandpa = _i8.Constants();
134138

135139
final _i20.Constants utility = _i20.Constants();
@@ -151,6 +155,8 @@ class Constants {
151155
final _i18.Constants encointerFaucet = _i18.Constants();
152156

153157
final _i19.Constants encointerDemocracy = _i19.Constants();
158+
159+
final _i22.Constants encointerTreasuries = _i22.Constants();
154160
}
155161

156162
class Rpc {
@@ -215,11 +221,11 @@ class EncointerKusama {
215221

216222
final Registry registry;
217223

218-
_i21.Future connect() async {
224+
_i23.Future connect() async {
219225
return await _provider.connect();
220226
}
221227

222-
_i21.Future disconnect() async {
228+
_i23.Future disconnect() async {
223229
return await _provider.disconnect();
224230
}
225231
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Constants {
2+
Constants();
3+
4+
/// The slot duration Aura should run with, expressed in milliseconds.
5+
/// The effective value of this type should not change while the chain is running.
6+
///
7+
/// For backwards compatibility either use [`MinimumPeriodTimesTwo`] or a const.
8+
final BigInt slotDuration = BigInt.from(6000);
9+
}

0 commit comments

Comments
 (0)