Skip to content

Commit

Permalink
add pollId to roundInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Dec 1, 2023
1 parent 9cbfa08 commit 5345885
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 9 deletions.
13 changes: 13 additions & 0 deletions subgraph/abis/FundingRound.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "pollId",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSpent",
Expand Down
15 changes: 15 additions & 0 deletions subgraph/generated/ClrFund/FundingRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,21 @@ export class FundingRound extends ethereum.SmartContract {
return ethereum.CallResult.fromValue(value[0].toAddress());
}

pollId(): BigInt {
let result = super.call("pollId", "pollId():(uint256)", []);

return result[0].toBigInt();
}

try_pollId(): ethereum.CallResult<BigInt> {
let result = super.tryCall("pollId", "pollId():(uint256)", []);
if (result.reverted) {
return new ethereum.CallResult();
}
let value = result.value;
return ethereum.CallResult.fromValue(value[0].toBigInt());
}

totalSpent(): BigInt {
let result = super.call("totalSpent", "totalSpent():(uint256)", []);

Expand Down
17 changes: 17 additions & 0 deletions subgraph/generated/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,23 @@ export class FundingRound extends Entity {
}
}

get pollId(): BigInt | null {
let value = this.get("pollId");
if (!value || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toBigInt();
}
}

set pollId(value: BigInt | null) {
if (!value) {
this.unset("pollId");
} else {
this.set("pollId", Value.fromBigInt(<BigInt>value));
}
}

get pollAddress(): Bytes | null {
let value = this.get("pollAddress");
if (!value || value.kind == ValueKind.NULL) {
Expand Down
15 changes: 15 additions & 0 deletions subgraph/generated/templates/FundingRound/FundingRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,21 @@ export class FundingRound extends ethereum.SmartContract {
return ethereum.CallResult.fromValue(value[0].toAddress());
}

pollId(): BigInt {
let result = super.call("pollId", "pollId():(uint256)", []);

return result[0].toBigInt();
}

try_pollId(): ethereum.CallResult<BigInt> {
let result = super.tryCall("pollId", "pollId():(uint256)", []);
if (result.reverted) {
return new ethereum.CallResult();
}
let value = result.value;
return ethereum.CallResult.fromValue(value[0].toBigInt());
}

totalSpent(): BigInt {
let result = super.call("totalSpent", "totalSpent():(uint256)", []);

Expand Down
15 changes: 15 additions & 0 deletions subgraph/generated/templates/MACI/FundingRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,21 @@ export class FundingRound extends ethereum.SmartContract {
return ethereum.CallResult.fromValue(value[0].toAddress());
}

pollId(): BigInt {
let result = super.call("pollId", "pollId():(uint256)", []);

return result[0].toBigInt();
}

try_pollId(): ethereum.CallResult<BigInt> {
let result = super.tryCall("pollId", "pollId():(uint256)", []);
if (result.reverted) {
return new ethereum.CallResult();
}
let value = result.value;
return ethereum.CallResult.fromValue(value[0].toBigInt());
}

totalSpent(): BigInt {
let result = super.call("totalSpent", "totalSpent():(uint256)", []);

Expand Down
15 changes: 15 additions & 0 deletions subgraph/generated/templates/Poll/FundingRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,21 @@ export class FundingRound extends ethereum.SmartContract {
return ethereum.CallResult.fromValue(value[0].toAddress());
}

pollId(): BigInt {
let result = super.call("pollId", "pollId():(uint256)", []);

return result[0].toBigInt();
}

try_pollId(): ethereum.CallResult<BigInt> {
let result = super.tryCall("pollId", "pollId():(uint256)", []);
if (result.reverted) {
return new ethereum.CallResult();
}
let value = result.value;
return ethereum.CallResult.fromValue(value[0].toBigInt());
}

totalSpent(): BigInt {
let result = super.call("totalSpent", "totalSpent():(uint256)", []);

Expand Down
1 change: 1 addition & 0 deletions subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type FundingRound @entity {
id: ID!
clrFund: ClrFund
maci: Bytes
pollId: BigInt
pollAddress: Bytes
messages: [Message!] @derivedFrom(field: "fundingRound")
recipientRegistry: RecipientRegistry
Expand Down
6 changes: 5 additions & 1 deletion subgraph/src/ClrFundMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,12 @@ export function handleRoundStarted(event: RoundStarted): void {
}

log.info('TRY pollAddress', [])
let pollAddressCall = fundingRoundContract.try_poll()
let pollIdCall = fundingRoundContract.try_pollId()
if (!pollIdCall.reverted) {
fundingRound.pollId = pollIdCall.value
}

let pollAddressCall = fundingRoundContract.try_poll()
if (pollAddressCall.reverted) {
log.info('TRY pollAddress Failed', [])
} else {
Expand Down
18 changes: 12 additions & 6 deletions vue-app/src/api/round.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface RoundInfo {
userRegistryAddress: string
recipientRegistryAddress: string
maciAddress: string
pollId: bigint
recipientTreeDepth: number
maxContributors: number
maxRecipients: number
Expand Down Expand Up @@ -148,6 +149,7 @@ export async function getRoundInfo(
}

const {
pollId,
pollAddress,
maci: maciAddress,
recipientRegistryAddress,
Expand All @@ -157,9 +159,9 @@ export async function getRoundInfo(
stateTreeDepth,
messageTreeDepth,
voteOptionTreeDepth,
startTime,
signUpDeadline,
votingDeadline,
startTime: startTimeInSeconds,
signUpDeadline: signUpDeadlineInSeconds,
votingDeadline: votingDeadlineInSeconds,
coordinatorPubKeyX,
coordinatorPubKeyY,
} = data.fundingRound
Expand All @@ -177,6 +179,9 @@ export async function getRoundInfo(
const maxContributors = stateTreeDepth ? 2 ** stateTreeDepth - 1 : 0
const maxMessages = messageTreeDepth ? 2 ** messageTreeDepth - 1 : 0
const now = DateTime.local()
const startTime = DateTime.fromSeconds(Number(startTimeInSeconds || 0))
const signUpDeadline = DateTime.fromSeconds(Number(signUpDeadlineInSeconds || 0))
const votingDeadline = DateTime.fromSeconds(Number(votingDeadlineInSeconds || 0))
const contributionsInfo = await getTotalContributed(fundingRoundAddress)
const contributors = contributionsInfo.count
let status: string
Expand Down Expand Up @@ -214,6 +219,7 @@ export async function getRoundInfo(
recipientRegistryAddress: utils.getAddress(recipientRegistryAddress),
userRegistryAddress: utils.getAddress(userRegistryAddress),
maciAddress: utils.getAddress(maciAddress),
pollId: BigInt(pollId || 0),
recipientTreeDepth: voteOptionTreeDepth || 1,
maxContributors,
maxRecipients: voteOptionTreeDepth ? 5 ** voteOptionTreeDepth - 1 : 0,
Expand All @@ -224,9 +230,9 @@ export async function getRoundInfo(
nativeTokenDecimals,
voiceCreditFactor,
status,
startTime: DateTime.fromSeconds(Number(startTime || 0)),
signUpDeadline: DateTime.fromSeconds(Number(signUpDeadline || 0)),
votingDeadline: DateTime.fromSeconds(Number(votingDeadline || 0)),
startTime,
signUpDeadline,
votingDeadline,
totalFunds,
matchingPool,
contributions,
Expand Down
3 changes: 2 additions & 1 deletion vue-app/src/components/ContributionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ onMounted(() => {
})
async function sendVotes() {
const { coordinatorPubKey } = currentRound.value!
const { coordinatorPubKey, pollId } = currentRound.value!
const contributor = appStore.contributor
const messages: Message[] = []
Expand All @@ -183,6 +183,7 @@ async function sendVotes() {
recipientIndex,
voiceCredits,
nonce,
pollId,
)
messages.push(message)
encPubKeys.push(encPubKey)
Expand Down
19 changes: 18 additions & 1 deletion vue-app/src/graphql/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ export enum ClrFund_OrderBy {
CurrentRoundMessageTreeDepth = 'currentRound__messageTreeDepth',
CurrentRoundNativeToken = 'currentRound__nativeToken',
CurrentRoundPollAddress = 'currentRound__pollAddress',
CurrentRoundPollId = 'currentRound__pollId',
CurrentRoundRecipientCount = 'currentRound__recipientCount',
CurrentRoundRecipientRegistryAddress = 'currentRound__recipientRegistryAddress',
CurrentRoundSignUpDeadline = 'currentRound__signUpDeadline',
Expand Down Expand Up @@ -592,6 +593,7 @@ export enum Contribution_OrderBy {
FundingRoundMessageTreeDepth = 'fundingRound__messageTreeDepth',
FundingRoundNativeToken = 'fundingRound__nativeToken',
FundingRoundPollAddress = 'fundingRound__pollAddress',
FundingRoundPollId = 'fundingRound__pollId',
FundingRoundRecipientCount = 'fundingRound__recipientCount',
FundingRoundRecipientRegistryAddress = 'fundingRound__recipientRegistryAddress',
FundingRoundSignUpDeadline = 'fundingRound__signUpDeadline',
Expand Down Expand Up @@ -1139,6 +1141,7 @@ export enum Donation_OrderBy {
FundingRoundMessageTreeDepth = 'fundingRound__messageTreeDepth',
FundingRoundNativeToken = 'fundingRound__nativeToken',
FundingRoundPollAddress = 'fundingRound__pollAddress',
FundingRoundPollId = 'fundingRound__pollId',
FundingRoundRecipientCount = 'fundingRound__recipientCount',
FundingRoundRecipientRegistryAddress = 'fundingRound__recipientRegistryAddress',
FundingRoundSignUpDeadline = 'fundingRound__signUpDeadline',
Expand Down Expand Up @@ -1178,6 +1181,7 @@ export type FundingRound = {
nativeToken: Maybe<Scalars['Bytes']>;
nativeTokenInfo: Maybe<Token>;
pollAddress: Maybe<Scalars['Bytes']>;
pollId: Maybe<Scalars['BigInt']>;
recipientCount: Scalars['BigInt'];
recipientRegistry: Maybe<RecipientRegistry>;
recipientRegistryAddress: Maybe<Scalars['Bytes']>;
Expand Down Expand Up @@ -1456,6 +1460,14 @@ export type FundingRound_Filter = {
pollAddress_not: InputMaybe<Scalars['Bytes']>;
pollAddress_not_contains: InputMaybe<Scalars['Bytes']>;
pollAddress_not_in: InputMaybe<Array<Scalars['Bytes']>>;
pollId: InputMaybe<Scalars['BigInt']>;
pollId_gt: InputMaybe<Scalars['BigInt']>;
pollId_gte: InputMaybe<Scalars['BigInt']>;
pollId_in: InputMaybe<Array<Scalars['BigInt']>>;
pollId_lt: InputMaybe<Scalars['BigInt']>;
pollId_lte: InputMaybe<Scalars['BigInt']>;
pollId_not: InputMaybe<Scalars['BigInt']>;
pollId_not_in: InputMaybe<Array<Scalars['BigInt']>>;
recipientCount: InputMaybe<Scalars['BigInt']>;
recipientCount_gt: InputMaybe<Scalars['BigInt']>;
recipientCount_gte: InputMaybe<Scalars['BigInt']>;
Expand Down Expand Up @@ -1638,6 +1650,7 @@ export enum FundingRound_OrderBy {
NativeTokenInfoSymbol = 'nativeTokenInfo__symbol',
NativeTokenInfoTokenAddress = 'nativeTokenInfo__tokenAddress',
PollAddress = 'pollAddress',
PollId = 'pollId',
RecipientCount = 'recipientCount',
RecipientRegistry = 'recipientRegistry',
RecipientRegistryAddress = 'recipientRegistryAddress',
Expand Down Expand Up @@ -1811,6 +1824,7 @@ export enum Message_OrderBy {
FundingRoundMessageTreeDepth = 'fundingRound__messageTreeDepth',
FundingRoundNativeToken = 'fundingRound__nativeToken',
FundingRoundPollAddress = 'fundingRound__pollAddress',
FundingRoundPollId = 'fundingRound__pollId',
FundingRoundRecipientCount = 'fundingRound__recipientCount',
FundingRoundRecipientRegistryAddress = 'fundingRound__recipientRegistryAddress',
FundingRoundSignUpDeadline = 'fundingRound__signUpDeadline',
Expand Down Expand Up @@ -1947,6 +1961,7 @@ export enum PublicKey_OrderBy {
FundingRoundMessageTreeDepth = 'fundingRound__messageTreeDepth',
FundingRoundNativeToken = 'fundingRound__nativeToken',
FundingRoundPollAddress = 'fundingRound__pollAddress',
FundingRoundPollId = 'fundingRound__pollId',
FundingRoundRecipientCount = 'fundingRound__recipientCount',
FundingRoundRecipientRegistryAddress = 'fundingRound__recipientRegistryAddress',
FundingRoundSignUpDeadline = 'fundingRound__signUpDeadline',
Expand Down Expand Up @@ -3185,6 +3200,7 @@ export enum Vote_OrderBy {
FundingRoundMessageTreeDepth = 'fundingRound__messageTreeDepth',
FundingRoundNativeToken = 'fundingRound__nativeToken',
FundingRoundPollAddress = 'fundingRound__pollAddress',
FundingRoundPollId = 'fundingRound__pollId',
FundingRoundRecipientCount = 'fundingRound__recipientCount',
FundingRoundRecipientRegistryAddress = 'fundingRound__recipientRegistryAddress',
FundingRoundSignUpDeadline = 'fundingRound__signUpDeadline',
Expand Down Expand Up @@ -3345,7 +3361,7 @@ export type GetRoundInfoQueryVariables = Exact<{
}>;


export type GetRoundInfoQuery = { __typename?: 'Query', fundingRound: { __typename?: 'FundingRound', id: string, maci: any | null, pollAddress: any | null, recipientRegistryAddress: any | null, contributorRegistryAddress: any | null, voiceCreditFactor: any | null, isFinalized: boolean | null, isCancelled: boolean | null, contributorCount: any, totalSpent: any | null, matchingPoolSize: any | null, startTime: any | null, signUpDeadline: any | null, votingDeadline: any | null, coordinatorPubKeyX: any | null, coordinatorPubKeyY: any | null, stateTreeDepth: number | null, messageTreeDepth: number | null, voteOptionTreeDepth: number | null, nativeTokenInfo: { __typename?: 'Token', tokenAddress: any | null, symbol: string | null, decimals: any | null } | null } | null };
export type GetRoundInfoQuery = { __typename?: 'Query', fundingRound: { __typename?: 'FundingRound', id: string, maci: any | null, pollId: any | null, pollAddress: any | null, recipientRegistryAddress: any | null, contributorRegistryAddress: any | null, voiceCreditFactor: any | null, isFinalized: boolean | null, isCancelled: boolean | null, contributorCount: any, totalSpent: any | null, matchingPoolSize: any | null, startTime: any | null, signUpDeadline: any | null, votingDeadline: any | null, coordinatorPubKeyX: any | null, coordinatorPubKeyY: any | null, stateTreeDepth: number | null, messageTreeDepth: number | null, voteOptionTreeDepth: number | null, nativeTokenInfo: { __typename?: 'Token', tokenAddress: any | null, symbol: string | null, decimals: any | null } | null } | null };

export type GetRoundsQueryVariables = Exact<{ [key: string]: never; }>;

Expand Down Expand Up @@ -3548,6 +3564,7 @@ export const GetRoundInfoDocument = gql`
fundingRound(id: $fundingRoundAddress) {
id
maci
pollId
pollAddress
nativeTokenInfo {
tokenAddress
Expand Down
1 change: 1 addition & 0 deletions vue-app/src/graphql/queries/GetRoundInfo.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ query GetRoundInfo($fundingRoundAddress: ID!) {
fundingRound(id: $fundingRoundAddress) {
id
maci
pollId
pollAddress
nativeTokenInfo {
tokenAddress
Expand Down

0 comments on commit 5345885

Please sign in to comment.