|
@@ -118,14 +118,14 @@ export const getFinalizedSpendingProposals = async (
|
|
api: ApiPromise,
|
|
api: ApiPromise,
|
|
blocks: [number, CacheEvent[]][]
|
|
blocks: [number, CacheEvent[]][]
|
|
): Promise<SpendingProposal[]> => {
|
|
): Promise<SpendingProposal[]> => {
|
|
- let spendingProposals: SpendingProposal[] = [];
|
|
|
|
- await blocks.forEach(([key, proposals]) =>
|
|
|
|
- proposals.forEach(async (proposalEvent) => {
|
|
|
|
- let statusUpdateData = proposalEvent.data[1] as any;
|
|
|
|
|
|
+ const spendingProposals: SpendingProposal[] = [];
|
|
|
|
+ for (const [key, events] of blocks) {
|
|
|
|
+ for (const event of events) {
|
|
|
|
+ let statusUpdateData = event.data[1] as any;
|
|
const finalizedAt = statusUpdateData.finalized.finalizedAt;
|
|
const finalizedAt = statusUpdateData.finalized.finalizedAt;
|
|
- if (!(statusUpdateData.finalized && finalizedAt)) return;
|
|
|
|
|
|
+ if (!(statusUpdateData.finalized && finalizedAt)) continue;
|
|
|
|
|
|
- const proposalId = proposalEvent.data[0] as ProposalId;
|
|
|
|
|
|
+ const proposalId = event.data[0] as ProposalId;
|
|
const id = +proposalId;
|
|
const id = +proposalId;
|
|
const proposalInfo: ProposalOf = await getProposalInfo(api, proposalId);
|
|
const proposalInfo: ProposalOf = await getProposalInfo(api, proposalId);
|
|
const finalizedData = proposalInfo.status.asFinalized;
|
|
const finalizedData = proposalInfo.status.asFinalized;
|
|
@@ -134,16 +134,17 @@ export const getFinalizedSpendingProposals = async (
|
|
proposalId
|
|
proposalId
|
|
);
|
|
);
|
|
if (!finalizedData.proposalStatus.isApproved || !details.isSpending)
|
|
if (!finalizedData.proposalStatus.isApproved || !details.isSpending)
|
|
- return;
|
|
|
|
|
|
+ continue;
|
|
let approvedData = finalizedData.proposalStatus.asApproved;
|
|
let approvedData = finalizedData.proposalStatus.asApproved;
|
|
- if (!approvedData.isExecuted) return;
|
|
|
|
- if (!spendingProposals.some((proposal) => proposal.id === id)) {
|
|
|
|
- const title = proposalInfo.title.toString();
|
|
|
|
- const amount = +details.asSpending[0];
|
|
|
|
- spendingProposals.push({ id, title, amount });
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- );
|
|
|
|
|
|
+ if (!approvedData.isExecuted) continue;
|
|
|
|
+ if (spendingProposals.some((proposal) => +proposal.id === +id)) continue;
|
|
|
|
+ const title = String(proposalInfo.title.toHuman());
|
|
|
|
+ const amount = +details.asSpending[0];
|
|
|
|
+
|
|
|
|
+ console.log(`Spent ${amount.toFixed().padStart(8)} on ${id} ${title}`);
|
|
|
|
+ spendingProposals.push({ id, title, amount });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return spendingProposals;
|
|
return spendingProposals;
|
|
};
|
|
};
|
|
|
|
|