parent
871511249b
commit
aba2e34255
|
@ -19,7 +19,9 @@ export function ConnectionNetwork({ buttonText, autoWidth = false }: ConnectionN
|
|||
<WarningWrapper>
|
||||
<Warning text="You are connected to unsupported network." icon="⚠️" />
|
||||
</WarningWrapper>
|
||||
<ProposeButton onClick={() => switchNetwork(config.daapConfig.readOnlyChainId!)}>Switch Network</ProposeButton>
|
||||
<ProposeButton onClick={() => switchNetwork(config.usedappConfig.readOnlyChainId!)}>
|
||||
Switch Network
|
||||
</ProposeButton>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
@ -54,7 +56,7 @@ export const ConnectButton = styled(ProposeButton)<{ autoWidth: boolean }>`
|
|||
`
|
||||
width: auto;
|
||||
padding: 10px 27px;
|
||||
|
||||
|
||||
@media (max-width: 600px) {
|
||||
padding: 7px 27px;
|
||||
margin-top: -9px;
|
||||
|
|
|
@ -10,8 +10,8 @@ import { RemoveModal } from './RemoveModal'
|
|||
import { CardHeading } from '../Card'
|
||||
import { useEthers, getExplorerAddressLink, ChainId } from '@usedapp/core'
|
||||
import { useHistory } from 'react-router'
|
||||
import { contracts } from '../../constants/contracts'
|
||||
import { useAccount } from '../../hooks/useAccount'
|
||||
import { config } from '../../config'
|
||||
|
||||
interface CardCommunityProps {
|
||||
community: CommunityDetail
|
||||
|
@ -118,7 +118,7 @@ export const CardCommunity = ({
|
|||
Visit community
|
||||
</LinkExternal>
|
||||
<LinkExternal
|
||||
href={getExplorerAddressLink(contracts[chainId as ChainId.Optimism]?.directoryContract, chainId!)}
|
||||
href={getExplorerAddressLink(config.contracts[chainId as ChainId]?.directoryContract, chainId!)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
|
|
|
@ -70,7 +70,7 @@ export function TopBar() {
|
|||
</Warning>
|
||||
<SubnavButton
|
||||
className={isOpened ? 'opened' : undefined}
|
||||
onClick={() => switchNetwork(config.daapConfig.readOnlyChainId!)}
|
||||
onClick={() => switchNetwork(config.usedappConfig.readOnlyChainId!)}
|
||||
>
|
||||
Switch network
|
||||
</SubnavButton>
|
||||
|
|
|
@ -39,7 +39,7 @@ export const ConnectMobile = () => {
|
|||
<Warning>⚠️ Unsupported network</Warning>
|
||||
<SubnavButton
|
||||
className={isOpened ? 'opened' : undefined}
|
||||
onClick={() => switchNetwork(config.daapConfig.readOnlyChainId!)}
|
||||
onClick={() => switchNetwork(config.usedappConfig.readOnlyChainId!)}
|
||||
>
|
||||
Switch network
|
||||
</SubnavButton>
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
// import { v4 as uuidv4 } from 'uuid'
|
||||
import { Chain, ChainId, Optimism, OptimismGoerli, Config as DAppConfig, Localhost, Hardhat } from '@usedapp/core'
|
||||
import { peers } from './constants/peers'
|
||||
|
||||
const version = '0.0.6'
|
||||
|
||||
export const OptimismSepolia: Chain = {
|
||||
const OptimismSepolia: Chain = {
|
||||
chainId: 11155420,
|
||||
chainName: 'OptimismSepolia',
|
||||
isTestChain: true,
|
||||
|
@ -23,11 +24,12 @@ export const OptimismSepolia: Chain = {
|
|||
|
||||
export interface Config {
|
||||
wakuConfig: {
|
||||
environment: 'test' | 'production'
|
||||
peers: string[]
|
||||
wakuTopic: string
|
||||
wakuFeatureTopic: string
|
||||
}
|
||||
daapConfig: DAppConfig
|
||||
usedappConfig: DAppConfig
|
||||
contracts: Record<number, Record<string, string>>
|
||||
votesLimit: number
|
||||
}
|
||||
|
||||
|
@ -40,11 +42,11 @@ const configs: Record<typeof process.env.ENV, Config> = {
|
|||
*/
|
||||
development: {
|
||||
wakuConfig: {
|
||||
environment: 'test',
|
||||
peers: peers.development,
|
||||
wakuTopic: `/communitiesCuration/localhost/${version}/directory/proto/`,
|
||||
wakuFeatureTopic: `/communitiesCuration/localhost/${version}/featured/proto/`,
|
||||
},
|
||||
daapConfig: {
|
||||
usedappConfig: {
|
||||
readOnlyChainId: ChainId.Hardhat,
|
||||
readOnlyUrls: {
|
||||
[ChainId.Hardhat]: 'http://127.0.0.1:8545',
|
||||
|
@ -61,6 +63,15 @@ const configs: Record<typeof process.env.ENV, Config> = {
|
|||
},
|
||||
},
|
||||
votesLimit: 2,
|
||||
contracts: {
|
||||
[ChainId.Hardhat]: {
|
||||
votingContract: process.env.VOTING_CONTRACT ?? '0x0000000000000000000000000000000000000000',
|
||||
directoryContract: process.env.DIRECTORY_CONTRACT ?? '0x0000000000000000000000000000000000000000',
|
||||
tokenContract: process.env.TOKEN_CONTRACT ?? '0x0000000000000000000000000000000000000000',
|
||||
multicallContract: process.env.MULTICALL_CONTRACT ?? '0x0000000000000000000000000000000000000000',
|
||||
featuredVotingContract: process.env.FEATURED_VOTING_CONTRACT ?? '0x0000000000000000000000000000000000000000',
|
||||
},
|
||||
},
|
||||
},
|
||||
/**
|
||||
* Preview.
|
||||
|
@ -69,11 +80,11 @@ const configs: Record<typeof process.env.ENV, Config> = {
|
|||
*/
|
||||
preview: {
|
||||
wakuConfig: {
|
||||
environment: 'test',
|
||||
peers: peers.preview,
|
||||
wakuTopic: `/communitiesCuration/preview/${version}/directory/proto/`,
|
||||
wakuFeatureTopic: `/communitiesCuration/preview/${version}/featured/proto/`,
|
||||
},
|
||||
daapConfig: {
|
||||
usedappConfig: {
|
||||
readOnlyChainId: OptimismSepolia.chainId,
|
||||
readOnlyUrls: {
|
||||
[OptimismSepolia.chainId]: `https://optimism-sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`,
|
||||
|
@ -86,17 +97,33 @@ const configs: Record<typeof process.env.ENV, Config> = {
|
|||
},
|
||||
},
|
||||
votesLimit: 2,
|
||||
contracts: {
|
||||
[OptimismSepolia.chainId]: {
|
||||
votingContract: '0x7Ff554af5b6624db2135E4364F416d1D397f43e6',
|
||||
featuredVotingContract: '0x336DFD512164Fe8CFA809BdE94B13E76e42edD6B',
|
||||
directoryContract: '0x6B94e21FAB8Af38E8d89dd4A0480C04e9a5c53Ab',
|
||||
tokenContract: '0x0B5DAd18B8791ddb24252B433ec4f21f9e6e5Ed0',
|
||||
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
||||
},
|
||||
[ChainId.OptimismGoerli]: {
|
||||
votingContract: '0x744Fd6e98dad09Fb8CCF530B5aBd32B56D64943b',
|
||||
featuredVotingContract: '0x898331B756EE1f29302DeF227a4471e960c50612',
|
||||
directoryContract: '0xB3Ef5B0825D5f665bE14394eea41E684CE96A4c5',
|
||||
tokenContract: '0xcAD273fA2bb77875333439FDf4417D995159c3E1',
|
||||
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
||||
},
|
||||
},
|
||||
},
|
||||
/**
|
||||
* Production.
|
||||
*/
|
||||
production: {
|
||||
wakuConfig: {
|
||||
environment: 'production',
|
||||
peers: peers.production,
|
||||
wakuTopic: `/communitiesCuration/${version}/directory/proto/`,
|
||||
wakuFeatureTopic: `/communitiesCuration/${version}/featured/proto/`,
|
||||
},
|
||||
daapConfig: {
|
||||
usedappConfig: {
|
||||
readOnlyChainId: ChainId.Optimism,
|
||||
readOnlyUrls: {
|
||||
[ChainId.Optimism]: `https://optimism-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
|
||||
|
@ -108,6 +135,15 @@ const configs: Record<typeof process.env.ENV, Config> = {
|
|||
},
|
||||
},
|
||||
votesLimit: 400,
|
||||
contracts: {
|
||||
[ChainId.Optimism]: {
|
||||
votingContract: '0x321Ba646d994200257Ce4bfe18F66C9283ad1407',
|
||||
featuredVotingContract: '0x2EA9700E7F27E09F254f2DaEc5E05015b2b961d0',
|
||||
directoryContract: '0xA8d270048a086F5807A8dc0a9ae0e96280C41e3A',
|
||||
tokenContract: '0x650AF3C15AF43dcB218406d30784416D64Cfb6B2',
|
||||
multicallContract: '0xeAa6877139d436Dc6d1f75F3aF15B74662617B2C',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
import { ChainId } from '@usedapp/core'
|
||||
import { OptimismSepolia } from '../config'
|
||||
|
||||
// todo?: move to config.ts
|
||||
export const contracts = {
|
||||
[ChainId.Optimism]: {
|
||||
votingContract: '0x321Ba646d994200257Ce4bfe18F66C9283ad1407',
|
||||
featuredVotingContract: '0x2EA9700E7F27E09F254f2DaEc5E05015b2b961d0',
|
||||
directoryContract: '0xA8d270048a086F5807A8dc0a9ae0e96280C41e3A',
|
||||
tokenContract: '0x650AF3C15AF43dcB218406d30784416D64Cfb6B2',
|
||||
multicallContract: '0xeAa6877139d436Dc6d1f75F3aF15B74662617B2C',
|
||||
},
|
||||
[ChainId.OptimismGoerli]: {
|
||||
votingContract: '0x744Fd6e98dad09Fb8CCF530B5aBd32B56D64943b',
|
||||
featuredVotingContract: '0x898331B756EE1f29302DeF227a4471e960c50612',
|
||||
directoryContract: '0xB3Ef5B0825D5f665bE14394eea41E684CE96A4c5',
|
||||
tokenContract: '0xcAD273fA2bb77875333439FDf4417D995159c3E1',
|
||||
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
||||
},
|
||||
[OptimismSepolia.chainId]: {
|
||||
votingContract: '0x7Ff554af5b6624db2135E4364F416d1D397f43e6',
|
||||
featuredVotingContract: '0x336DFD512164Fe8CFA809BdE94B13E76e42edD6B',
|
||||
directoryContract: '0x6B94e21FAB8Af38E8d89dd4A0480C04e9a5c53Ab',
|
||||
tokenContract: '0x0B5DAd18B8791ddb24252B433ec4f21f9e6e5Ed0',
|
||||
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
||||
},
|
||||
[ChainId.Hardhat]: {
|
||||
votingContract: process.env.VOTING_CONTRACT ?? '0x0000000000000000000000000000000000000000',
|
||||
directoryContract: process.env.DIRECTORY_CONTRACT ?? '0x0000000000000000000000000000000000000000',
|
||||
tokenContract: process.env.TOKEN_CONTRACT ?? '0x0000000000000000000000000000000000000000',
|
||||
multicallContract: process.env.MULTICALL_CONTRACT ?? '0x0000000000000000000000000000000000000000',
|
||||
featuredVotingContract: process.env.FEATURED_VOTING_CONTRACT ?? '0x0000000000000000000000000000000000000000',
|
||||
},
|
||||
}
|
|
@ -2,18 +2,21 @@
|
|||
* source: @see https://fleets.status.im
|
||||
*/
|
||||
|
||||
export const peers = {
|
||||
production: [],
|
||||
test: [
|
||||
'/dns4/boot-01.do-ams3.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmAR24Mbb6VuzoyUiGx42UenDkshENVDj4qnmmbabLvo31',
|
||||
'/dns4/boot-01.gc-us-central1-a.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAm8mUZ18tBWPXDQsaF7PbCKYA35z7WB2xNZH2EVq1qS8LJ',
|
||||
'/dns4/boot-01.ac-cn-hongkong-c.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmGwcE8v7gmJNEWFtZtojYpPMTHy2jBLL6xRk33qgDxFWX',
|
||||
const production = [
|
||||
'/dns4/boot-01.do-ams3.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmAR24Mbb6VuzoyUiGx42UenDkshENVDj4qnmmbabLvo31',
|
||||
'/dns4/boot-01.gc-us-central1-a.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAm8mUZ18tBWPXDQsaF7PbCKYA35z7WB2xNZH2EVq1qS8LJ',
|
||||
'/dns4/boot-01.ac-cn-hongkong-c.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmGwcE8v7gmJNEWFtZtojYpPMTHy2jBLL6xRk33qgDxFWX',
|
||||
'/dns4/store-01.do-ams3.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmAUdrQ3uwzuE4Gy4D56hX6uLKEeerJAnhKEHZ3DxF1EfT',
|
||||
'/dns4/store-02.do-ams3.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAm9aDJPkhGxc2SFcEACTFdZ91Q5TJjp76qZEhq9iF59x7R',
|
||||
'/dns4/store-01.gc-us-central1-a.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmMELCo218hncCtTvC2Dwbej3rbyHQcR8erXNnKGei7WPZ',
|
||||
'/dns4/store-02.gc-us-central1-a.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmJnVR7ZzFaYvciPVafUXuYGLHPzSUigqAmeNw9nJUVGeM',
|
||||
'/dns4/store-01.ac-cn-hongkong-c.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAm2M7xs7cLPc3jamawkEqbr7cUJX11uvY7LxQ6WFUdUKUT',
|
||||
'/dns4/store-02.ac-cn-hongkong-c.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAm9CQhsuwPR54q27kNj9iaQVfyRzTGKrhFmr94oD8ujU6P',
|
||||
]
|
||||
|
||||
'/dns4/store-01.do-ams3.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmAUdrQ3uwzuE4Gy4D56hX6uLKEeerJAnhKEHZ3DxF1EfT',
|
||||
'/dns4/store-02.do-ams3.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAm9aDJPkhGxc2SFcEACTFdZ91Q5TJjp76qZEhq9iF59x7R',
|
||||
'/dns4/store-01.gc-us-central1-a.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmMELCo218hncCtTvC2Dwbej3rbyHQcR8erXNnKGei7WPZ',
|
||||
'/dns4/store-02.gc-us-central1-a.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmJnVR7ZzFaYvciPVafUXuYGLHPzSUigqAmeNw9nJUVGeM',
|
||||
'/dns4/store-01.ac-cn-hongkong-c.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAm2M7xs7cLPc3jamawkEqbr7cUJX11uvY7LxQ6WFUdUKUT',
|
||||
'/dns4/store-02.ac-cn-hongkong-c.shards.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAm9CQhsuwPR54q27kNj9iaQVfyRzTGKrhFmr94oD8ujU6P',
|
||||
],
|
||||
// todo?: https://github.com/status-im/infra-shards/issues/29#issuecomment-1992729489 `shards.staging`; await integration in desktop and mobile
|
||||
export const peers = {
|
||||
development: production,
|
||||
preview: production,
|
||||
production,
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ export function useAccount() {
|
|||
|
||||
useEffect(() => {
|
||||
if (activateError?.name === 'ChainIdError') {
|
||||
switchNetwork(config.daapConfig.readOnlyChainId!)
|
||||
switchNetwork(config.usedappConfig.readOnlyChainId!)
|
||||
}
|
||||
}, [activateError])
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { useEthers, useTokenBalance } from '@usedapp/core'
|
||||
import { contracts } from '../constants/contracts'
|
||||
import { ChainId, useEthers, useTokenBalance } from '@usedapp/core'
|
||||
import { BigNumber } from 'ethers'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { config } from '../config'
|
||||
|
||||
export function useAvailableAmount() {
|
||||
const { account, chainId } = useEthers()
|
||||
// @ts-expect-error fixme: https://github.com/status-im/community-dapp/pull/94#discussion_r1378964354 undefined or unsupported network
|
||||
const tokenBalance = useTokenBalance(contracts[chainId as keyof typeof contracts | undefined].tokenContract, account)
|
||||
const tokenBalance = useTokenBalance(config.contracts[chainId as ChainId]?.tokenContract, account)
|
||||
|
||||
const [availableAmount, setAvailableAmount] = useState(0)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { useEthers } from '@usedapp/core'
|
||||
import { contracts } from '../constants/contracts'
|
||||
import { Contract } from 'ethers'
|
||||
import { Interface } from '@ethersproject/abi'
|
||||
import { VotingContract, Directory, FeaturedVotingContract } from '@status-community-dapp/contracts/abi'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { config } from '../config'
|
||||
|
||||
export function useContracts() {
|
||||
const { chainId } = useEthers()
|
||||
|
@ -22,7 +22,7 @@ export function useContracts() {
|
|||
|
||||
useEffect(() => {
|
||||
if (chainId) {
|
||||
const chainConfig = contracts[chainId]
|
||||
const chainConfig = config.contracts[chainId]
|
||||
if (chainConfig) {
|
||||
setVotingContract(new Contract(chainConfig.votingContract, new Interface(VotingContract.abi)))
|
||||
setDirectoryContract(new Contract(chainConfig.directoryContract, new Interface(Directory.abi)))
|
||||
|
|
|
@ -8,12 +8,11 @@ import { DAppProvider } from '@usedapp/core'
|
|||
import { WakuProvider } from './providers/waku/provider'
|
||||
import { CommunitiesProvider } from './providers/communities/provider'
|
||||
import { config } from './config'
|
||||
import { peers } from './constants/peers'
|
||||
|
||||
render(
|
||||
<React.StrictMode>
|
||||
<WakuProvider peers={peers['test']}>
|
||||
<DAppProvider config={config.daapConfig}>
|
||||
<WakuProvider peers={config.wakuConfig.peers}>
|
||||
<DAppProvider config={config.usedappConfig}>
|
||||
<CommunitiesProvider>
|
||||
<App />
|
||||
</CommunitiesProvider>
|
||||
|
|
Loading…
Reference in New Issue