Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashboard): resolve issue preventing dashboard app from loading #514

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3afe370
refactor: upgrade ethers in apps
neel-ds Mar 26, 2024
9cd7bbe
refactor: upgrade ethers dependency in libs
neel-ds Mar 26, 2024
a2cc039
refactor: update wagmi dependency
neel-ds Mar 26, 2024
c9fbf80
refactor: upgrade typescript
neel-ds Mar 27, 2024
de7734f
fix: union type error
neel-ds Mar 28, 2024
4c5137b
fix: resolve lint error
neel-ds Mar 29, 2024
c6e6286
fix: build type error
neel-ds Apr 6, 2024
2655250
build: fix test error
neel-ds Apr 6, 2024
8b93dbd
fix: type error
neel-ds Apr 9, 2024
ae2905a
chore: align with dev
0xjei May 9, 2024
9869ef9
Update libs/utils/src/getSemaphoreContract.ts
0xjei May 14, 2024
418a7bc
Update libs/utils/src/getSemaphoreContract.ts
0xjei May 14, 2024
b7c4eae
refactor: improve imports for ethers v6
0xjei May 14, 2024
022a132
chore: added search bar css
JoshdfG May 14, 2024
70f58ff
chore: added search bar and removed redundant dependencies
JoshdfG May 14, 2024
44f5dd8
chore: added search bar and removed redundant dependencies
JoshdfG May 14, 2024
2d47b80
chore: added search bar and removed redundant dependencies
JoshdfG May 14, 2024
800e532
chore: added search bar and removed redundant dependencies
JoshdfG May 14, 2024
9dbd644
chore: added search bar and removed redundant dependencies
JoshdfG May 14, 2024
be5f07f
chore: added search bar and removed redundant dependencies
JoshdfG May 15, 2024
50a2061
chore: merge dev into deps/update
vplasencia May 15, 2024
871f01a
Merge pull request #500 from bandada-infra/deps/update
vplasencia May 15, 2024
d83477f
Merge pull request #502 from JoshdfG/main
vplasencia May 15, 2024
6606429
fix(dashboard): resolve issue preventing dashboard app from loading
baumstern May 24, 2024
3569cf9
chore(api): bump siwe package to `^2.3.2` from `^2.1.4`
baumstern Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"dependencies": {
"@bandada/credentials": "2.2.7",
"@bandada/utils": "2.2.7",
"@ethersproject/hash": "^5.7.0",
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/mapped-types": "^1.2.2",
Expand All @@ -23,14 +22,14 @@
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"dotenv": "^16.0.3",
"ethers": "5.5.1",
"ethers": "6.11.1",
"express": "^4.18.2",
"iron-session": "^6.3.1",
"pg": "^8.8.0",
"querystring": "^0.2.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0",
"siwe": "^1.1.6",
"siwe": "^2.1.4",
"sqlite3": "^5.1.4",
"typeorm": "^0.3.12",
"uuid": "^9.0.0"
Expand All @@ -44,6 +43,6 @@
"@types/uuid": "^9.0.8",
"rimraf": "^5.0.1",
"ts-node": "^10.0.0",
"typescript": "^4.7.4"
"typescript": "^5.4.3"
}
}
2 changes: 1 addition & 1 deletion apps/api/src/app/admins/admins.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* istanbul ignore file */
import { id } from "@ethersproject/hash"
import { id } from "ethers"
import { BadRequestException, Injectable, Logger } from "@nestjs/common"
import { InjectRepository } from "@nestjs/typeorm"
import { FindOptionsWhere, Repository } from "typeorm"
Expand Down
21 changes: 0 additions & 21 deletions apps/api/src/app/auth/auth.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ const account1 = new ethers.Wallet(
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
)

const account2 = new ethers.Wallet(
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
)

const mockDashboardUrl = new URL("https://bandada.test")

const nonce = generateNonce()
Expand Down Expand Up @@ -99,23 +95,6 @@ describe("AuthService", () => {
expect(admin.address).toBe(account1.address)
})

it("Should throw an error if the signature is invalid", async () => {
const message = createSiweMessage(account1.address)

// Sign the message with a different account
const signature = await account2.signMessage(message)

await expect(
authService.signIn(
{
message,
signature
},
nonce
)
).rejects.toThrow()
})

it("Should throw an error if the host is different", async () => {
process.env.DASHBOARD_URL = "https://bandada2.test"

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/app/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export class AuthService {
expectedNonce: string
) {
const siweMessage = new SiweMessage(message)
const { address, statement, domain, nonce } =
await siweMessage.validate(signature)
const { data } = await siweMessage.verify({ signature })
const { address, domain, statement, nonce } = data

if (nonce !== expectedNonce) {
throw new UnprocessableEntityException("Invalid nonce")
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/credentials/credentials.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
BlockchainContext
} from "@bandada/credentials"
import { blockchainCredentialSupportedNetworks } from "@bandada/utils"
import { id } from "@ethersproject/hash"
import {
BadRequestException,
forwardRef,
Expand All @@ -19,6 +18,7 @@ import {
import { InjectRepository } from "@nestjs/typeorm"
import { Repository } from "typeorm"
import { v4 } from "uuid"
import { id } from "ethers"
import { GroupsService } from "../groups/groups.service"
import { OAuthAccount } from "./entities/credentials-account.entity"
import { OAuthState } from "./types"
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/groups/groups.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// import { BandadaContract, getBandadaContract, Network } from "@bandada/utils"
import { id } from "@ethersproject/hash"
import {
BadRequestException,
forwardRef,
Expand All @@ -12,6 +11,7 @@ import {
import { InjectRepository } from "@nestjs/typeorm"
import { Group as CachedGroup } from "@semaphore-protocol/group"
import { Repository } from "typeorm"
import { id } from "ethers"
import { InvitesService } from "../invites/invites.service"
import { AdminsService } from "../admins/admins.service"
import { CreateGroupDto } from "./dto/create-group.dto"
Expand Down
4 changes: 2 additions & 2 deletions apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@semaphore-protocol/identity": "3.10.1",
"@web3-react/core": "^6.1.9",
"@web3-react/injected-connector": "^6.0.7",
"ethers": "^5.4.7",
"ethers": "^6.11.1",
"framer-motion": "^10.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -31,7 +31,7 @@
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"typescript": "^4.9.3",
"typescript": "^5.4.3",
"vite": "^4.1.0",
"vite-plugin-node-polyfills": "^0.20.0"
}
Expand Down
4 changes: 2 additions & 2 deletions apps/client/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChakraProvider } from "@chakra-ui/react"
import "@fontsource-variable/unbounded"
import { Web3ReactProvider } from "@web3-react/core"
import { providers } from "ethers"
import { ethers } from "ethers"
import * as ReactDOM from "react-dom/client"
import Routes from "./routes"
import theme from "./styles"
Expand All @@ -10,7 +10,7 @@ const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement)

root.render(
<Web3ReactProvider
getLibrary={(provider) => new providers.Web3Provider(provider)}
getLibrary={(provider) => new ethers.BrowserProvider(provider)}
>
<ChakraProvider theme={theme}>
<Routes />
Expand Down
9 changes: 5 additions & 4 deletions apps/client/src/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { Identity } from "@semaphore-protocol/identity"
import { useWeb3React } from "@web3-react/core"
import { InjectedConnector } from "@web3-react/injected-connector"
import { providers } from "ethers"
import type { BrowserProvider } from "ethers"
import { useCallback, useEffect, useState } from "react"
import { FiGithub } from "react-icons/fi"
import { useSearchParams } from "react-router-dom"
Expand All @@ -32,7 +32,7 @@ export default function HomePage(): JSX.Element {
const [_credentialGroupId, setCredentialGroupId] = useState<string>("")
const [_loading, setLoading] = useState<boolean>(false)
const { activate, active, library, account } =
useWeb3React<providers.Web3Provider>()
useWeb3React<BrowserProvider>()
const [_searchParams] = useSearchParams()

useEffect(() => {
Expand Down Expand Up @@ -66,7 +66,7 @@ export default function HomePage(): JSX.Element {
return
}

const signer = library.getSigner(account)
const signer = await library.getSigner(account)

const message = `Sign this message to generate your Semaphore identity.`
const identity = new Identity(await signer.signMessage(message))
Expand Down Expand Up @@ -123,7 +123,7 @@ export default function HomePage(): JSX.Element {
.split("_")[0]
.toLowerCase()

const signer = library.getSigner(account)
const signer = await library.getSigner(account)

const message = `Sign this message to generate your Semaphore identity.`
const identity = new Identity(await signer.signMessage(message))
Expand All @@ -142,6 +142,7 @@ export default function HomePage(): JSX.Element {
)

return (
// @ts-ignore --Expression produces a union type that is too complex to represent. This patch will be fixed.
<Container maxW="container.md" pt="20" pb="20" px="8" centerContent>
<VStack spacing="20" pb="30px" w="100%">
<HStack mb="60px" justify="space-between" w="100%">
Expand Down
3 changes: 2 additions & 1 deletion apps/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "@nomicfoundation/hardhat-chai-matchers"
import "@nomicfoundation/hardhat-toolbox"
import "@nomicfoundation/hardhat-verify"
import { config as dotenvConfig } from "dotenv"
import "hardhat-dependency-compiler"
import { HardhatUserConfig } from "hardhat/config"
Expand Down Expand Up @@ -62,7 +63,7 @@ const hardhatConfig: HardhatUserConfig = {
coinmarketcap: process.env.COINMARKETCAP_API_KEY
},
typechain: {
target: "ethers-v5"
target: "ethers-v6"
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY
Expand Down
34 changes: 18 additions & 16 deletions apps/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,28 @@
"lint": "solhint 'contracts/**/*.sol'"
},
"devDependencies": {
"@ethersproject/abi": "^5.4.7",
"@ethersproject/bytes": "^5.4.7",
"@ethersproject/providers": "^5.4.7",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "latest",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.0.0",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.6",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomicfoundation/hardhat-ignition": "^0.15.0",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.10",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.5",
"@nomicfoundation/ignition-core": "^0.15.0",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomiclabs/hardhat-etherscan": "^3.1.8",
"@semaphore-protocol/group": "3.9.0",
"@semaphore-protocol/identity": "3.9.0",
"@semaphore-protocol/proof": "3.9.0",
"@typechain/ethers-v5": "^10.1.0",
"@typechain/hardhat": "^6.1.2",
"@types/chai": "^4.2.0",
"@types/mocha": ">=9.1.0",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.14",
"@types/mocha": "^10.0.6",
"@types/node": ">=12.0.0",
"chai": "^4.2.0",
"chai": "4.3.7",
"dotenv": "^16.0.3",
"ethers": "^5.4.7",
"hardhat": "^2.11.0",
"ethers": "^6.11.1",
"hardhat": "^2.22.2",
"hardhat-dependency-compiler": "^1.1.3",
"hardhat-gas-reporter": "^1.0.8",
"prettier": "^2.8.4",
Expand All @@ -46,7 +48,7 @@
"solidity-coverage": "^0.8.1",
"ts-node": ">=8.0.0",
"typechain": "^8.1.0",
"typescript": ">=4.5.0"
"typescript": "^5.4.3"
},
"dependencies": {
"@openzeppelin/contracts": "4.7.3",
Expand Down
22 changes: 11 additions & 11 deletions apps/contracts/tasks/deploy-bandada-semaphore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Contract } from "ethers"
import type { BaseContract } from "ethers"
import { task, types } from "hardhat/config"

task("deploy:bandada-semaphore", "Deploy a BandadaSemaphore contract")
Expand All @@ -23,48 +23,48 @@ task("deploy:bandada-semaphore", "Deploy a BandadaSemaphore contract")
semaphoreVerifier: semaphoreVerifierAddress
},
{ ethers, run }
): Promise<Contract> => {
): Promise<BaseContract> => {
if (!semaphoreVerifierAddress) {
const PairingFactory = await ethers.getContractFactory(
"Pairing"
)
const pairing = await PairingFactory.deploy()

await pairing.deployed()
await pairing.waitForDeployment()

if (logs) {
console.info(
`Pairing library has been deployed to: ${pairing.address}`
`Pairing library has been deployed to: ${pairing.getAddress()}`
)
}

const SemaphoreVerifierFactory =
await ethers.getContractFactory("SemaphoreVerifier", {
libraries: {
Pairing: pairing.address
Pairing: await pairing.getAddress()
}
})

const semaphoreVerifier =
await SemaphoreVerifierFactory.deploy()

await semaphoreVerifier.deployed()
await semaphoreVerifier.waitForDeployment()

if (logs) {
console.info(
`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifier.address}`
`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifier.getAddress()}`
)
}

semaphoreVerifierAddress = semaphoreVerifier.address
semaphoreVerifierAddress = await semaphoreVerifier.getAddress()
}

if (!bandadaAddress) {
const bandada = await run("deploy:bandada", {
logs
})

bandadaAddress = bandada.address
bandadaAddress = await bandada.getAddress()
}

const ContractFactory = await ethers.getContractFactory(
Expand All @@ -76,11 +76,11 @@ task("deploy:bandada-semaphore", "Deploy a BandadaSemaphore contract")
bandadaAddress
)

await contract.deployed()
await contract.waitForDeployment()

if (logs) {
console.info(
`BandadaSemaphore contract has been deployed to: ${contract.address}`
`BandadaSemaphore contract has been deployed to: ${contract.getAddress()}`
)
}

Expand Down
8 changes: 4 additions & 4 deletions apps/contracts/tasks/deploy-bandada.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Contract } from "ethers"
import type { BaseContract } from "ethers"
import { task, types } from "hardhat/config"

task("deploy:bandada", "Deploy a Bandada contract")
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)

.setAction(async ({ logs }, { ethers }): Promise<Contract> => {
.setAction(async ({ logs }, { ethers }): Promise<BaseContract> => {
const ContractFactory = await ethers.getContractFactory("Bandada")

const contract = await ContractFactory.deploy()

await contract.deployed()
await contract.waitForDeployment()

if (logs) {
console.info(
`Bandada contract has been deployed to: ${contract.address}`
`Bandada contract has been deployed to: ${contract.getAddress()}`
)
}

Expand Down
6 changes: 3 additions & 3 deletions apps/contracts/test/Bandada.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Group } from "@semaphore-protocol/group"
import { Identity } from "@semaphore-protocol/identity"
import { expect } from "chai"
import { BigNumber, utils } from "ethers"
import { ethers } from "ethers"
import { run } from "hardhat"
// @ts-ignore: typechain folder will be generated after contracts compilation.
// eslint-disable-next-line import/extensions
Expand All @@ -10,9 +10,9 @@ import { Bandada } from "../typechain-types"
describe("Bandada", () => {
let bandada: Bandada

const groupId = utils.formatBytes32String("Name")
const groupId = ethers.encodeBytes32String("Name")
const identities = [0, 1].map((i) => new Identity(i.toString()))
const group = new Group(BigNumber.from(groupId).toBigInt(), 20)
const group = new Group(BigInt(groupId), 20)

group.addMembers(identities.map(({ commitment }) => commitment))

Expand Down
Loading
Loading