Skip to content

Commit

Permalink
Merge pull request #141 from ivelin/dev
Browse files Browse the repository at this point in the history
fix: use kalidao-hooks useChainGuard
  • Loading branch information
ivelin authored Sep 21, 2022
2 parents 7280e48 + 8d65819 commit 144edd6
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ ports:
# https://www.gitpod.io/docs/config-ports#cors
# frontend web app service : Node.js, React
- port: 3000
onOpen: open-browser
name: SporosDAO UI
onOpen: ignore
visibility: public

- port: 3001
Expand All @@ -65,7 +66,8 @@ ports:
- port: 5900
onOpen: ignore
- port: 6080
onOpen: open-browser
name: Synpress console
onOpen: ignore
- port: 10000
onOpen: ignore

Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/tests/e2e/specs/project-tribute-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Project Management', () => {
cy.contains('#113')
cy.contains('e2e test aug 20 2022')
cy.contains('Tracking Link')
cy.contains('Budget: 2223.0')
cy.contains('Budget: 2222.0')
cy.contains('Deadline: Wed, 12 Dec 2323')
cy.contains('Manager Address: 0xf952a72F39c5Fa22a443200AbE7835128bCb7439')
cy.get('[data-testid="tribute-button"]').click({force: true})
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/tests/e2e/specs/projects-view-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Project Management', () => {
cy.contains('#113')
cy.contains('e2e test aug 20 2022')
cy.contains('Tracking Link')
cy.contains('Budget: 2223.0')
cy.contains('Budget: 2222.0')
cy.contains('Deadline: Wed, 12 Dec 2323')
cy.contains('Manager Address: 0xf952a72F39c5Fa22a443200AbE7835128bCb7439')
cy.contains('Tribute')
Expand Down
3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"react-scripts": "5.0.1",
"typescript": "^4.4.2",
"wagmi": "^0.6",
"web-vitals": "^2.1.0"
"web-vitals": "^2.1.0",
"kalidao-hooks": "^0.0.3"
},
"scripts": {
"apigen": "openapi-generator-cli generate -i http://localhost:3001/api/docs-json -g typescript-axios -o src/api/openapi",
Expand Down
16 changes: 7 additions & 9 deletions frontend/src/components/Web3SubmitDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Box } from '@mui/system'
import { Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material'
import { Button, CircularProgress, IconButton } from '@mui/material'
import { Check, Error } from '@mui/icons-material'
import { useNetwork } from 'wagmi'
import { chain } from 'wagmi'
import { useContractWrite, usePrepareContractWrite } from 'wagmi'
import { useParams } from 'react-router-dom'
import { useChainGuard } from 'kalidao-hooks'

interface Web3SubmitDialogProps {
open: boolean
Expand All @@ -18,9 +19,7 @@ export default function Web3SubmitDialog(props: Web3SubmitDialogProps) {

const { chainId: daoChainId } = useParams()

const { chain: userChain, chains } = useNetwork()

const isUserOnCorrectChain = userChain?.id && Number(daoChainId) === userChain?.id ? true : false
const { isUserOnCorrectChain, isUserConnected, userChain } = useChainGuard({ chainId: Number(daoChainId) })

// console.debug({ isUserOnCorrectChain })

Expand Down Expand Up @@ -67,11 +66,10 @@ export default function Web3SubmitDialog(props: Web3SubmitDialogProps) {
console.error({ writeError })
}
} else {
daoChainName = chains?.find((chain) => chain.id === Number(daoChainId))?.name
wrongChainWarning =
!isUserOnCorrectChain && userChain
? `Your Web3 wallet is connected to ${userChain?.name}.`
: `Your Web3 wallet is disconnected.`
daoChainName = Object.values(chain).find((chain) => chain.id === Number(daoChainId))?.name
wrongChainWarning = !isUserConnected
? `Your Web3 wallet is disconnected.`
: `Your Web3 wallet is connected to ${userChain?.name}.`
}

// console.debug({ daoChainName, wrongChainWarning })
Expand Down
5 changes: 5 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7795,6 +7795,11 @@ [email protected], jss@^10.8.2:
array-includes "^3.1.4"
object.assign "^4.1.2"

kalidao-hooks@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/kalidao-hooks/-/kalidao-hooks-0.0.3.tgz#af9e5a4439955d6ff0c311d1170fa24d214e0c1c"
integrity sha512-nHEH1mSA7o/d8Uk6+QDQaMFzWwdxTAnTknTuZ8f0nYqmtwFk1A0kCroXWrhgQBXGeDy3GAoxGNRGwTRawG+M8w==

keccak@^3.0.0, keccak@^3.0.1:
version "3.0.2"
resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.2.tgz#4c2c6e8c54e04f2670ee49fa734eb9da152206e0"
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


0 comments on commit 144edd6

Please sign in to comment.