diff --git a/packages/app-democracy/src/Summary.tsx b/packages/app-democracy/src/Summary.tsx index 2521adeedb..7cb4f2bd3a 100644 --- a/packages/app-democracy/src/Summary.tsx +++ b/packages/app-democracy/src/Summary.tsx @@ -18,13 +18,12 @@ type Props = I18nProps & { democracy_nextTally?: BN, democracy_publicDelay?: BN, democracy_publicPropCount?: BN, - democracy_referendumCount?: BN, - democracy_votingPeriod?: BN + democracy_referendumCount?: BN }; class Summary extends React.PureComponent { render () { - const { chain_bestNumber = new BN(0), democracy_launchPeriod = new BN(1), democracy_nextTally = new BN(0), democracy_publicPropCount, democracy_referendumCount = new BN(0), democracy_votingPeriod = new BN(1), t } = this.props; + const { chain_bestNumber = new BN(0), democracy_launchPeriod = new BN(1), democracy_nextTally = new BN(0), democracy_publicPropCount, democracy_referendumCount = new BN(0), t } = this.props; return ( @@ -40,13 +39,6 @@ class Summary extends React.PureComponent {
- ': KeyValueArray, - 'ParaId': Amount, - 'Moment': Moment, - 'MomentOf': Moment, - 'ProposalIndex': Amount, - 'PropIndex': Amount, - 'Proposal': Proposal, - 'ReferendumIndex': Amount, - 'SeedOf': Hash, - 'SessionKey': Account, - 'Signature': Hash, - 'String': Text, - 'Text': Text, - 'Tuple': Tuple, - 'u32': Amount, - 'u64': Amount, - 'u128': Amount, - 'Vector': Vector, - 'Vote': Vote, - 'VoteIndex': Amount, - 'VoteThreshold': VoteThreshold +type TypeToComponent = { + c: React.ComponentType, + t: Array }; +const components: ComponentMap = ([ + { c: Account, t: ['AccountId', 'AccountIdOf', 'Address', 'SessionKey'] }, + { c: Amount, t: ['AccountIndex', 'BlockNumber', 'Gas', 'Index', 'ParaId', 'ProposalIndex', 'PropIndex', 'ReferendumIndex', 'u16', 'u32', 'u64', 'u128', 'u256', 'VoteIndex'] }, + { c: Balance, t: ['Amount', 'AssetOf', 'Balance', 'BalanceOf'] }, + { c: Bool, t: ['bool'] }, + { c: Bytes, t: ['Bytes'] }, + { c: Code, t: ['Code'] }, + { c: Hash, t: ['CodeHash', 'Hash', 'SeedOf', 'Signature'] }, + { c: KeyValue, t: ['KeyValue'] }, + { c: KeyValueArray, t: ['Vec'] }, + { c: Moment, t: ['Moment', 'MomentOf'] }, + { c: Proposal, t: ['Proposal'] }, + { c: Text, t: ['String', 'Text'] }, + { c: Tuple, t: ['Tuple'] }, + { c: Vector, t: ['Vector'] }, + { c: Vote, t: ['Vote'] }, + { c: VoteThreshold, t: ['VoteThreshold'] } +] as Array).reduce((components, { c, t }) => { + t.forEach((type) => { + components[type] = c; + }); + + return components; +}, {} as ComponentMap); + export default function findComponent (def: TypeDef, overrides: ComponentMap = {}): React.ComponentType { const type = (({ info, sub, type }: TypeDef) => { switch (info) {