Add etherscan links (#79)
This commit is contained in:
parent
e1a1203a58
commit
1374663cac
|
@ -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
|
||||
}
|
||||
|
|
|
@ -16,4 +16,5 @@ export type VotingRoom = {
|
|||
id: number
|
||||
timeLeft: number
|
||||
voteWinner: number | undefined
|
||||
transactionHash?: string
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export function ProposalCard({ theme, votingRoom, mobileVersion, availableAmount
|
|||
|
||||
return (
|
||||
<Card onClick={() => mobileVersion && history.push(`/votingRoom/${votingRoom.id.toString()}`)}>
|
||||
<ProposalInfo votingRoom={votingRoom} />
|
||||
<ProposalInfo votingRoom={votingRoom} providerName={wakuVoting.providerName} />
|
||||
<ProposalVote votingRoom={votingRoom} theme={theme} availableAmount={availableAmount} wakuVoting={wakuVoting} />
|
||||
</Card>
|
||||
)
|
||||
|
|
|
@ -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 (
|
||||
<Card>
|
||||
<CardHeading>{votingRoom.question}</CardHeading>
|
||||
<CardText className={mobileMode ? 'mobile' : ''}>{votingRoom.description}</CardText>
|
||||
<CardViewLink className={mobileMode ? 'mobile' : ''}>
|
||||
<ViewLink address={'#'} />
|
||||
<ViewLink
|
||||
address={
|
||||
votingRoom.transactionHash ? `https://${providerName}.etherscan.io/tx/${votingRoom.transactionHash}` : '#'
|
||||
}
|
||||
/>
|
||||
</CardViewLink>
|
||||
</Card>
|
||||
)
|
||||
|
|
|
@ -30,7 +30,7 @@ export function ProposalVoteMobile({ wakuVoting, availableAmount }: ProposalVote
|
|||
|
||||
return (
|
||||
<Card>
|
||||
<ProposalInfo votingRoom={votingRoom} mobileMode={true} />
|
||||
<ProposalInfo votingRoom={votingRoom} mobileMode={true} providerName={wakuVoting.providerName} />
|
||||
<VoteChartWrap>
|
||||
<VoteChart votingRoom={votingRoom} selectedVote={selectedVoted} />
|
||||
</VoteChartWrap>
|
||||
|
|
Loading…
Reference in New Issue