// Copyright 2017-2018 @polkadot/api-observable authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. import BN from 'bn.js'; import { AccountId, Balance, BlockNumber, PropIndex, Proposal, ReferendumIndex, VoteThreshold } from '@polkadot/types/index'; import { Struct, Tuple, Vector } from '@polkadot/types/codec'; export class RxProposal extends Struct.with({ id: PropIndex, proposal: Proposal, address: AccountId }) { constructor (value: Tuple) { super({ id: value.getAtIndex(0), proposal: value.getAtIndex(1), address: value.getAtIndex(2) }); } get address (): AccountId { return this.get('address') as AccountId; } get id (): PropIndex { return this.get('id') as PropIndex; } get proposal (): Proposal { return this.get('proposal') as Proposal; } } export class RxProposalDeposits extends Struct.with({ balance: Balance, addresses: Vector.with(AccountId) }) { constructor (value: Tuple) { super({ balance: value.getAtIndex(0), addresses: value.getAtIndex(1) }); } get addresses (): Vector { return this.get('addresses') as Vector; } get balance (): Balance { return this.get('balance') as Balance; } } export class RxReferendum extends Struct.with({ blockNumber: BlockNumber, proposal: Proposal, voteThreshold: VoteThreshold, id: ReferendumIndex }) { constructor (value: Tuple, id: ReferendumIndex | BN | number) { super({ blockNumber: value.getAtIndex(0), proposal: value.getAtIndex(1), voteThreshold: value.getAtIndex(2), id }); } get blockNumber (): BlockNumber { return this.get('blockNumber') as BlockNumber; } get id (): ReferendumIndex { return this.get('id') as ReferendumIndex; } get proposal (): Proposal { return this.get('proposal') as Proposal; } get voteThreshold (): VoteThreshold { return this.get('voteThreshold') as VoteThreshold; } }