Skip to content

Commit

Permalink
Merge pull request #500 from bandada-infra/deps/update
Browse files Browse the repository at this point in the history
Upgrade `ethers` and related dependencies to latest version
  • Loading branch information
vplasencia authored May 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 3354c1f + 50a2061 commit 871f01a
Showing 51 changed files with 3,622 additions and 2,087 deletions.
7 changes: 3 additions & 4 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -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",
@@ -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"
@@ -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"
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
@@ -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()
@@ -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"

4 changes: 2 additions & 2 deletions apps/api/src/app/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion apps/api/src/app/credentials/credentials.service.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import {
BlockchainContext
} from "@bandada/credentials"
import { blockchainCredentialSupportedNetworks } from "@bandada/utils"
import { id } from "@ethersproject/hash"
import {
BadRequestException,
forwardRef,
@@ -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"
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,
@@ -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"
4 changes: 2 additions & 2 deletions apps/client/package.json
Original file line number Diff line number Diff line change
@@ -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",
@@ -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"
}
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"
@@ -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 />
9 changes: 5 additions & 4 deletions apps/client/src/pages/home.tsx
Original file line number Diff line number Diff line change
@@ -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"
@@ -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(() => {
@@ -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))
@@ -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))
@@ -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%">
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"
@@ -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
34 changes: 18 additions & 16 deletions apps/contracts/package.json
Original file line number Diff line number Diff line change
@@ -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",
@@ -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",
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")
@@ -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(
@@ -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()}`
)
}

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()}`
)
}

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
@@ -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))

Loading

0 comments on commit 871f01a

Please sign in to comment.