diff --git a/group-generators/generators/tally/index.ts b/group-generators/generators/tally/index.ts index 2398d9906..f04ce1fbc 100644 --- a/group-generators/generators/tally/index.ts +++ b/group-generators/generators/tally/index.ts @@ -11,7 +11,7 @@ const generator: GroupGenerator = { const TallyProvider = new dataProviders.TallyProvider(); const input = { - name: "Aave", + governance: "Aave", // proposalId: 315, }; const tallyGetGovernanceProposers = await TallyProvider.getGovernanceProposers(input); diff --git a/group-generators/helpers/data-providers/tally/interface-schema.json b/group-generators/helpers/data-providers/tally/interface-schema.json index c4a753b90..377cc0799 100644 --- a/group-generators/helpers/data-providers/tally/interface-schema.json +++ b/group-generators/helpers/data-providers/tally/interface-schema.json @@ -13,7 +13,7 @@ "name": "DAO", "argName": "governance", "type": "string", - "example": "aave", + "example": "Aave", "description": "A specific DAO" }, { @@ -35,7 +35,7 @@ "name": "DAO", "argName": "governance", "type": "string", - "example": "aave", + "example": "Aave", "description": "A specific DAO" } ] @@ -50,7 +50,7 @@ "name": "DAO", "argName": "governance", "type": "string", - "example": "aave", + "example": "Aave", "description": "A specific DAO" } ] diff --git a/group-generators/helpers/data-providers/tally/provider.ts b/group-generators/helpers/data-providers/tally/provider.ts index 1425f2e04..fd2dab272 100644 --- a/group-generators/helpers/data-providers/tally/provider.ts +++ b/group-generators/helpers/data-providers/tally/provider.ts @@ -51,7 +51,7 @@ export default class TallyProvider extends GraphQLProvider implements ITallyProv } public async getProposalVoters({ - name, + governance, proposalId, }: inputGetProposalVoters): Promise { const data = await this._queryNameToGovernorAddress(); @@ -60,17 +60,16 @@ export default class TallyProvider extends GraphQLProvider implements ITallyProv if (data && Array.isArray(data.governors)) { const matchingGovernors = data.governors.filter( - (governor: { name: string }) => governor.name === name + (governor: { name: string }) => governor.name === governance ); for (const governor of matchingGovernors) { for (const proposals of governor.proposals) { const propId = proposals.id; - - if (parseInt(propId) === proposalId) { + if (propId === proposalId.toString()) { const allVotes = proposals.votes; - allVotes.forEach((voteItem: { id: string; voter: any }) => { + allVotes.forEach((voteItem: { id: string; voter: { address: string } }) => { const { voter } = voteItem; const { address } = voter; if (fetchedData[address]) { @@ -90,22 +89,24 @@ export default class TallyProvider extends GraphQLProvider implements ITallyProv } public async getProposalVotersCount({ - name, + governance, proposalId, }: inputGetProposalVoters): Promise { - const ProposalVoterData = await this.getProposalVoters({ name, proposalId }); + const ProposalVoterData = await this.getProposalVoters({ governance, proposalId }); const ProposalVoterCount = Object.keys(ProposalVoterData).length; return ProposalVoterCount; } - public async getGovernanceVoters({ name }: inputGetGovernanceProposers): Promise { + public async getGovernanceVoters({ + governance, + }: inputGetGovernanceProposers): Promise { const data: queryData = await this._queryNameToGovernorAddress(); const fetchedData: { [address: string]: number } = {}; if (data && Array.isArray(data.governors)) { const matchingGovernors = data.governors.filter( - (governor: { name: string }) => governor.name === name + (governor: { name: string }) => governor.name === governance ); for (const governor of matchingGovernors) { @@ -130,20 +131,24 @@ export default class TallyProvider extends GraphQLProvider implements ITallyProv return fetchedData; } - public async getGovernanceVotersCount({ name }: inputGetGovernanceProposers): Promise { - const VoterData = await this.getGovernanceVoters({ name }); + public async getGovernanceVotersCount({ + governance, + }: inputGetGovernanceProposers): Promise { + const VoterData = await this.getGovernanceVoters({ governance }); const VoterCount = Object.keys(VoterData).length; return VoterCount; } - public async getGovernanceProposers({ name }: inputGetGovernanceProposers): Promise { + public async getGovernanceProposers({ + governance, + }: inputGetGovernanceProposers): Promise { const data: queryData = await this._queryNameToGovernorAddress(); const fetchedData: { [address: string]: number } = {}; if (data && Array.isArray(data.governors)) { const matchingGovernors = data.governors.filter( - (governor: { name: string }) => governor.name === name + (governor: { name: string }) => governor.name === governance ); for (const governor of matchingGovernors) { @@ -163,8 +168,10 @@ export default class TallyProvider extends GraphQLProvider implements ITallyProv return fetchedData; } - public async getGovernanceProposersCount({ name }: inputGetGovernanceProposers): Promise { - const proposersData = await this.getGovernanceProposers({ name }); + public async getGovernanceProposersCount({ + governance, + }: inputGetGovernanceProposers): Promise { + const proposersData = await this.getGovernanceProposers({ governance }); const proposerCount = Object.keys(proposersData).length; return proposerCount; diff --git a/group-generators/helpers/data-providers/tally/types.ts b/group-generators/helpers/data-providers/tally/types.ts index 67e5f5abe..bcd9686fe 100644 --- a/group-generators/helpers/data-providers/tally/types.ts +++ b/group-generators/helpers/data-providers/tally/types.ts @@ -3,11 +3,11 @@ import { IGraphQLProvider } from "@group-generators/helpers/data-providers/graph export type ITallyProvider = IGraphQLProvider; export interface inputGetGovernanceProposers { - name: string; + governance: string; } export interface inputGetProposalVoters { - name: string; + governance: string; proposalId: number; } @@ -23,7 +23,11 @@ export interface govArray { id: string; type: string; name: string; - proposals: any[]; + proposals: { + id: string; + votes: { id: string; voter: { address: string } }[]; + proposer: { address: string }; + }[]; delegates: Delegate[]; }