Call return is CallBase (w/ method, section) (#2996)

* Call return is CallBase (w/ method, section)

* Remove {section, method}Name

* mthod/section

* compare via .is
This commit is contained in:
Jaco Greeff
2020-12-28 15:02:27 +01:00
committed by GitHub
parent a806e4a2ee
commit b5e37c020d
4 changed files with 15 additions and 33 deletions
@@ -20,20 +20,20 @@ interface Result {
proposalCount: ProposalIndex;
}
function parseResult (_api: ApiInterfaceRx, { allIds, allProposals, approvalIds, councilProposals, proposalCount }: Result): DeriveTreasuryProposals {
function parseResult (api: ApiInterfaceRx, { allIds, allProposals, approvalIds, councilProposals, proposalCount }: Result): DeriveTreasuryProposals {
const approvals: DeriveTreasuryProposal[] = [];
const proposals: DeriveTreasuryProposal[] = [];
const councilTreasury = councilProposals.filter(({ proposal: { methodName, sectionName } }): boolean =>
sectionName === 'treasury' &&
['approveProposal', 'rejectProposal'].includes(methodName)
const councilTreasury = councilProposals.filter(({ proposal }) =>
api.tx.treasury.approveProposal.is(proposal) ||
api.tx.treasury.rejectProposal.is(proposal)
);
allIds.forEach((id, index): void => {
if (allProposals[index].isSome) {
const council = councilTreasury
.filter(({ proposal }): boolean => id.eq(proposal.args[0]))
.sort((a, b): number => a.proposal.methodName.localeCompare(b.proposal.methodName));
const isApproval = approvalIds.some((approvalId): boolean => approvalId.eq(id));
.filter(({ proposal }) => id.eq(proposal.args[0]))
.sort((a, b) => a.proposal.method.localeCompare(b.proposal.method));
const isApproval = approvalIds.some((approvalId) => approvalId.eq(id));
const derived = { council, id, proposal: allProposals[index].unwrap() };
if (isApproval) {