diff --git a/subgraph/abis/FundingRound.json b/subgraph/abis/FundingRound.json index 5abae313a..7a482f795 100644 --- a/subgraph/abis/FundingRound.json +++ b/subgraph/abis/FundingRound.json @@ -466,6 +466,19 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "pollId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "totalSpent", diff --git a/subgraph/generated/ClrFund/FundingRound.ts b/subgraph/generated/ClrFund/FundingRound.ts index bde4327d0..e86a75ef4 100644 --- a/subgraph/generated/ClrFund/FundingRound.ts +++ b/subgraph/generated/ClrFund/FundingRound.ts @@ -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 { + 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)", []); diff --git a/subgraph/generated/schema.ts b/subgraph/generated/schema.ts index 7a5649125..4aa73bc1b 100644 --- a/subgraph/generated/schema.ts +++ b/subgraph/generated/schema.ts @@ -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(value)); + } + } + get pollAddress(): Bytes | null { let value = this.get("pollAddress"); if (!value || value.kind == ValueKind.NULL) { diff --git a/subgraph/generated/templates/FundingRound/FundingRound.ts b/subgraph/generated/templates/FundingRound/FundingRound.ts index bde4327d0..e86a75ef4 100644 --- a/subgraph/generated/templates/FundingRound/FundingRound.ts +++ b/subgraph/generated/templates/FundingRound/FundingRound.ts @@ -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 { + 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)", []); diff --git a/subgraph/generated/templates/MACI/FundingRound.ts b/subgraph/generated/templates/MACI/FundingRound.ts index bde4327d0..e86a75ef4 100644 --- a/subgraph/generated/templates/MACI/FundingRound.ts +++ b/subgraph/generated/templates/MACI/FundingRound.ts @@ -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 { + 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)", []); diff --git a/subgraph/generated/templates/Poll/FundingRound.ts b/subgraph/generated/templates/Poll/FundingRound.ts index bde4327d0..e86a75ef4 100644 --- a/subgraph/generated/templates/Poll/FundingRound.ts +++ b/subgraph/generated/templates/Poll/FundingRound.ts @@ -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 { + 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)", []); diff --git a/subgraph/schema.graphql b/subgraph/schema.graphql index ab72afa11..1f86045f5 100644 --- a/subgraph/schema.graphql +++ b/subgraph/schema.graphql @@ -58,6 +58,7 @@ type FundingRound @entity { id: ID! clrFund: ClrFund maci: Bytes + pollId: BigInt pollAddress: Bytes messages: [Message!] @derivedFrom(field: "fundingRound") recipientRegistry: RecipientRegistry diff --git a/subgraph/src/ClrFundMapping.ts b/subgraph/src/ClrFundMapping.ts index a957a9fad..946079b6c 100644 --- a/subgraph/src/ClrFundMapping.ts +++ b/subgraph/src/ClrFundMapping.ts @@ -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 { diff --git a/vue-app/src/api/round.ts b/vue-app/src/api/round.ts index c5d9ca88b..9b492b9f8 100644 --- a/vue-app/src/api/round.ts +++ b/vue-app/src/api/round.ts @@ -17,6 +17,7 @@ export interface RoundInfo { userRegistryAddress: string recipientRegistryAddress: string maciAddress: string + pollId: bigint recipientTreeDepth: number maxContributors: number maxRecipients: number @@ -148,6 +149,7 @@ export async function getRoundInfo( } const { + pollId, pollAddress, maci: maciAddress, recipientRegistryAddress, @@ -157,9 +159,9 @@ export async function getRoundInfo( stateTreeDepth, messageTreeDepth, voteOptionTreeDepth, - startTime, - signUpDeadline, - votingDeadline, + startTime: startTimeInSeconds, + signUpDeadline: signUpDeadlineInSeconds, + votingDeadline: votingDeadlineInSeconds, coordinatorPubKeyX, coordinatorPubKeyY, } = data.fundingRound @@ -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 @@ -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, @@ -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, diff --git a/vue-app/src/components/ContributionModal.vue b/vue-app/src/components/ContributionModal.vue index b1f9ed176..478c0c434 100644 --- a/vue-app/src/components/ContributionModal.vue +++ b/vue-app/src/components/ContributionModal.vue @@ -168,7 +168,7 @@ onMounted(() => { }) async function sendVotes() { - const { coordinatorPubKey } = currentRound.value! + const { coordinatorPubKey, pollId } = currentRound.value! const contributor = appStore.contributor const messages: Message[] = [] @@ -183,6 +183,7 @@ async function sendVotes() { recipientIndex, voiceCredits, nonce, + pollId, ) messages.push(message) encPubKeys.push(encPubKey) diff --git a/vue-app/src/graphql/API.ts b/vue-app/src/graphql/API.ts index 15c5c5433..96cdd297e 100644 --- a/vue-app/src/graphql/API.ts +++ b/vue-app/src/graphql/API.ts @@ -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', @@ -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', @@ -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', @@ -1178,6 +1181,7 @@ export type FundingRound = { nativeToken: Maybe; nativeTokenInfo: Maybe; pollAddress: Maybe; + pollId: Maybe; recipientCount: Scalars['BigInt']; recipientRegistry: Maybe; recipientRegistryAddress: Maybe; @@ -1456,6 +1460,14 @@ export type FundingRound_Filter = { pollAddress_not: InputMaybe; pollAddress_not_contains: InputMaybe; pollAddress_not_in: InputMaybe>; + pollId: InputMaybe; + pollId_gt: InputMaybe; + pollId_gte: InputMaybe; + pollId_in: InputMaybe>; + pollId_lt: InputMaybe; + pollId_lte: InputMaybe; + pollId_not: InputMaybe; + pollId_not_in: InputMaybe>; recipientCount: InputMaybe; recipientCount_gt: InputMaybe; recipientCount_gte: InputMaybe; @@ -1638,6 +1650,7 @@ export enum FundingRound_OrderBy { NativeTokenInfoSymbol = 'nativeTokenInfo__symbol', NativeTokenInfoTokenAddress = 'nativeTokenInfo__tokenAddress', PollAddress = 'pollAddress', + PollId = 'pollId', RecipientCount = 'recipientCount', RecipientRegistry = 'recipientRegistry', RecipientRegistryAddress = 'recipientRegistryAddress', @@ -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', @@ -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', @@ -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', @@ -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; }>; @@ -3548,6 +3564,7 @@ export const GetRoundInfoDocument = gql` fundingRound(id: $fundingRoundAddress) { id maci + pollId pollAddress nativeTokenInfo { tokenAddress diff --git a/vue-app/src/graphql/queries/GetRoundInfo.graphql b/vue-app/src/graphql/queries/GetRoundInfo.graphql index 8dbf7db9d..d5995c8ff 100644 --- a/vue-app/src/graphql/queries/GetRoundInfo.graphql +++ b/vue-app/src/graphql/queries/GetRoundInfo.graphql @@ -2,6 +2,7 @@ query GetRoundInfo($fundingRoundAddress: ID!) { fundingRound(id: $fundingRoundAddress) { id maci + pollId pollAddress nativeTokenInfo { tokenAddress