75 lines
2.2 KiB
TypeScript
Raw Normal View History

2021-09-14 18:06:21 +02:00
import React, { useRef } from 'react'
2021-09-13 17:02:29 +02:00
import { useWakuProposal } from '@status-waku-voting/proposal-hooks'
2021-09-14 13:49:46 +02:00
import { Proposal, ProposalMobile } from '@status-waku-voting/proposal-components'
2021-09-14 18:06:21 +02:00
import { TopBar, GlobalStyle, useMobileVersion } from '@status-waku-voting/react-components'
2021-09-02 23:02:39 +02:00
import votingIcon from './assets/images/voting.svg'
import styled from 'styled-components'
2021-09-03 11:26:02 +02:00
import { blueTheme } from '@status-waku-voting/react-components/dist/esm/src/style/themes'
2021-09-15 02:16:08 +02:00
import { DAppProvider, ChainId, useEthers, useConfig } from '@usedapp/core'
2021-09-03 14:22:18 +02:00
import { DEFAULT_CONFIG } from '@usedapp/core/dist/cjs/src/model/config/default'
const config = {
readOnlyChainId: ChainId.Ropsten,
readOnlyUrls: {
[ChainId.Ropsten]: 'https://ropsten.infura.io/v3/b4451d780cc64a078ccf2181e872cfcf',
},
multicallAddresses: {
2021-09-15 02:16:08 +02:00
1: '0xeefba1e63905ef1d7acba5a8513c70307c1ce441',
3: '0x53c43764255c17bd724f74c4ef150724ac50a3ed',
2021-09-03 14:22:18 +02:00
1337: process.env.GANACHE_MULTICALL_CONTRACT ?? '0x0000000000000000000000000000000000000000',
},
supportedChains: [...DEFAULT_CONFIG.supportedChains, 1337],
notifications: {
checkInterval: 500,
expirationPeriod: 50000,
},
}
function Proposals() {
2021-09-15 02:16:08 +02:00
const { account, activateBrowserWallet, deactivate, library, chainId } = useEthers()
const config = useConfig()
const waku = useWakuProposal(
'test',
'0x5795A64A70cde4073DBa9EEBC5C6b675B15C815a',
library,
config?.multicallAddresses?.[chainId ?? 1337]
)
2021-09-14 18:06:21 +02:00
const ref = useRef<HTMLHeadingElement>(null)
const mobileVersion = useMobileVersion(ref, 600)
2021-09-13 17:02:29 +02:00
2021-09-03 14:22:18 +02:00
return (
2021-09-14 18:06:21 +02:00
<Wrapper ref={ref}>
2021-09-03 14:22:18 +02:00
<TopBar
logo={votingIcon}
title={'Proposals Dapp'}
theme={blueTheme}
activate={activateBrowserWallet}
account={account}
deactivate={deactivate}
/>
2021-09-15 00:47:14 +02:00
{waku &&
(mobileVersion ? (
<ProposalMobile wakuVoting={waku} account={account} />
) : (
<Proposal wakuVoting={waku} account={account} />
))}
2021-09-03 14:22:18 +02:00
</Wrapper>
)
}
export function ProposalPage() {
return (
2021-09-02 23:02:39 +02:00
<Wrapper>
<GlobalStyle />
2021-09-03 14:22:18 +02:00
<DAppProvider config={config}>
<Proposals />
</DAppProvider>
2021-09-02 23:02:39 +02:00
</Wrapper>
)
}
2021-09-02 23:02:39 +02:00
const Wrapper = styled.div`
height: 100%;
width: 100%;
`