Skip to content

Commit

Permalink
fix parsing council proposal tx data (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardo Vieira authored Mar 23, 2023
1 parent 349f806 commit 6be212b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impact-market/utils",
"version": "3.3.3",
"version": "3.3.4",
"description": "impactMarket utils",
"repository": {
"type": "git",
Expand Down
46 changes: 32 additions & 14 deletions src/useImpactMarketCouncil.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { BigNumber } from 'bignumber.js';
import { ImpactProviderContext } from './ImpactProvider';
import { Interface, defaultAbiCoder } from '@ethersproject/abi';
import { defaultAbiCoder } from '@ethersproject/abi';
import { filterEvent } from './filterEvent';
import { getContracts } from './contracts';
import { internalUseTransaction } from './internalUseTransaction';
import ImpactMarketCouncilABI from './abi/ImpactMarketCouncil.json';
import React, { useEffect, useState } from 'react';

type BaseProposalArgs = {
Expand Down Expand Up @@ -142,10 +142,13 @@ export const useImpactMarketCouncil = () => {
})
);
const response = await executeTransaction(tx);
const ifaceCouncil = new Interface(ImpactMarketCouncilABI);
const received = filterEvent(
'event ProposalCreated(uint256 id, address proposer, address[] targets, string[] signatures, bytes[] calldatas, uint256 endBlock, string description)',
'ProposalCreated',
response
);

// TODO: filter out events
return parseInt(ifaceCouncil.parseLog(response.logs[0]).args![0].toString(), 10);
return parseInt(received.args![0].toString(), 10);
};

/**
Expand Down Expand Up @@ -173,9 +176,13 @@ export const useImpactMarketCouncil = () => {
})
);
const response = await executeTransaction(tx);
const ifaceCouncil = new Interface(ImpactMarketCouncilABI);
const received = filterEvent(
'event ProposalCreated(uint256 id, address proposer, address[] targets, string[] signatures, bytes[] calldatas, uint256 endBlock, string description)',
'ProposalCreated',
response
);

return parseInt(ifaceCouncil.parseLog(response.logs[0]).args![0].toString(), 10);
return parseInt(received.args![0].toString(), 10);
};

/**
Expand Down Expand Up @@ -204,9 +211,13 @@ export const useImpactMarketCouncil = () => {
})
);
const response = await executeTransaction(tx);
const ifaceCouncil = new Interface(ImpactMarketCouncilABI);
const received = filterEvent(
'event ProposalCreated(uint256 id, address proposer, address[] targets, string[] signatures, bytes[] calldatas, uint256 endBlock, string description)',
'ProposalCreated',
response
);

return parseInt(ifaceCouncil.parseLog(response.logs[0]).args![0].toString(), 10);
return parseInt(received.args![0].toString(), 10);
};

/**
Expand Down Expand Up @@ -257,9 +268,13 @@ export const useImpactMarketCouncil = () => {
})
);
const response = await executeTransaction(tx);
const ifaceCouncil = new Interface(ImpactMarketCouncilABI);
const received = filterEvent(
'event ProposalCreated(uint256 id, address proposer, address[] targets, string[] signatures, bytes[] calldatas, uint256 endBlock, string description)',
'ProposalCreated',
response
);

return parseInt(ifaceCouncil.parseLog(response.logs[0]).args![0].toString(), 10);
return parseInt(received.args![0].toString(), 10);
};

/**
Expand Down Expand Up @@ -392,10 +407,13 @@ export const useImpactMarketCouncil = () => {
})
);
const response = await executeTransaction(tx);
const ifaceCouncil = new Interface(ImpactMarketCouncilABI);
const received = filterEvent(
'event ProposalCreated(uint256 id, address proposer, address[] targets, string[] signatures, bytes[] calldatas, uint256 endBlock, string description)',
'ProposalCreated',
response
);

// TODO: filter out events
return parseInt(ifaceCouncil.parseLog(response.logs[0]).args![0].toString(), 10);
return parseInt(received.args![0].toString(), 10);
};

return {
Expand Down

0 comments on commit 6be212b

Please sign in to comment.