diff --git a/packages/core/src/classes/WakuVoting.ts b/packages/core/src/classes/WakuVoting.ts index f0fefcd..c8fd960 100644 --- a/packages/core/src/classes/WakuVoting.ts +++ b/packages/core/src/classes/WakuVoting.ts @@ -14,7 +14,7 @@ const ABI = [ export class WakuVoting extends WakuMessaging { private votingContract: Contract - + public providerName: string constructor( appName: string, votingContract: Contract, @@ -22,6 +22,7 @@ export class WakuVoting extends WakuMessaging { provider: Web3Provider, chainId: number, multicallAddress: string, + providerName: string, waku?: Waku ) { super( @@ -39,6 +40,7 @@ export class WakuVoting extends WakuMessaging { ], waku ) + this.providerName = providerName this.votingContract = votingContract } @@ -52,7 +54,17 @@ export class WakuVoting extends WakuMessaging { const network = await provider.getNetwork() const votingContract = new Contract(contractAddress, VotingContract.abi, provider) const tokenAddress = await votingContract.token() - return new WakuVoting(appName, votingContract, tokenAddress, provider, network.chainId, multicall, waku) + const providerName = (await provider.getNetwork()).name + return new WakuVoting( + appName, + votingContract, + tokenAddress, + provider, + network.chainId, + multicall, + providerName, + waku + ) } public async createVote(question: string, descripiton: string, tokenAmount: BigNumber) { @@ -86,6 +98,16 @@ export class WakuVoting extends WakuMessaging { voteWinner: timeLeft <= 0 ? (poll[5].gt(poll[4]) ? 1 : 2) : undefined, } }) + await Promise.all( + this.lastPolls.map(async (poll) => { + if (!poll.transactionHash) { + const block = await this.provider.getBlockWithTransactions(poll.startBlock.toNumber()) + poll.transactionHash = block.transactions.find( + (transaction) => transaction.to === this.votingContract.address + )?.hash + } + }) + ) } return this.lastPolls } diff --git a/packages/core/src/types/PollType.ts b/packages/core/src/types/PollType.ts index b18389f..16afe34 100644 --- a/packages/core/src/types/PollType.ts +++ b/packages/core/src/types/PollType.ts @@ -16,4 +16,5 @@ export type VotingRoom = { id: number timeLeft: number voteWinner: number | undefined + transactionHash?: string } diff --git a/packages/proposal-components/src/components/ProposalCard.tsx b/packages/proposal-components/src/components/ProposalCard.tsx index 8adcb4e..ffcafde 100644 --- a/packages/proposal-components/src/components/ProposalCard.tsx +++ b/packages/proposal-components/src/components/ProposalCard.tsx @@ -21,7 +21,7 @@ export function ProposalCard({ theme, votingRoom, mobileVersion, availableAmount return ( mobileVersion && history.push(`/votingRoom/${votingRoom.id.toString()}`)}> - + ) diff --git a/packages/proposal-components/src/components/ProposalInfo.tsx b/packages/proposal-components/src/components/ProposalInfo.tsx index 036d89f..56ef4a6 100644 --- a/packages/proposal-components/src/components/ProposalInfo.tsx +++ b/packages/proposal-components/src/components/ProposalInfo.tsx @@ -1,3 +1,4 @@ +import { WakuVoting } from '@status-waku-voting/core' import { VotingRoom } from '@status-waku-voting/core/dist/esm/src/types/PollType' import React from 'react' import styled from 'styled-components' @@ -5,16 +6,21 @@ import { ViewLink } from './ViewLink' type ProposalInfoProps = { votingRoom: VotingRoom + providerName: string mobileMode?: boolean } -export function ProposalInfo({ votingRoom, mobileMode }: ProposalInfoProps) { +export function ProposalInfo({ votingRoom, mobileMode, providerName }: ProposalInfoProps) { return ( {votingRoom.question} {votingRoom.description} - + ) diff --git a/packages/proposal-components/src/components/mobile/ProposalVoteMobile.tsx b/packages/proposal-components/src/components/mobile/ProposalVoteMobile.tsx index 348e02d..aa459fc 100644 --- a/packages/proposal-components/src/components/mobile/ProposalVoteMobile.tsx +++ b/packages/proposal-components/src/components/mobile/ProposalVoteMobile.tsx @@ -30,7 +30,7 @@ export function ProposalVoteMobile({ wakuVoting, availableAmount }: ProposalVote return ( - +