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

feat(wip): move to pnpm, install missing deps, update ci, remove oz test-helpers #337

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js 16
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
cache: 'yarn'
cache: 'pnpm'

- run: yarn install --frozen-lockfile
- run: pnpm install

- name: Run test
run: yarn test
run: pnpm test

deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js 16
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
cache: 'yarn'
cache: 'pnpm'

- run: yarn install --frozen-lockfile
- run: pnpm install

- name: Run deploy
run: yarn test:deploy
run: pnpm test:deploy
env:
BATCH_GATEWAY_URLS: '["https://universal-offchain-unwrapper.ens-cf.workers.dev/"]'
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn format && git add .
pnpm format && git add .
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,19 @@ This repo runs a husky precommit to prettify all contract files to keep them con
```
git clone https://github.com/ensdomains/ens-contracts
cd ens-contracts
yarn
pnpm i
```

### How to run tests

```
yarn test
pnpm test
```

### How to publish

```
yarn pub
pnpm pub
```

### Release flow
Expand Down
12 changes: 6 additions & 6 deletions contracts/wrapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,13 @@ RESOLVER_ADDRESS=

### Run deploy script

`yarn deploy:rinkeby` will deploy to rinkeby and verify its source code
`pnpm deploy:rinkeby` will deploy to rinkeby and verify its source code

NOTE: If you want to override the default metadata url, set `METADATA_HOST=` to `.env`

```
$yarn deploy:rinkeby
yarn run v1.22.10
$ pnpm deploy:rinkeby
pnpm run v1.22.10
$ npx hardhat run --network rinkeby scripts/deploy.js
Deploying contracts to rinkeby with the account:0x97bA55F61345665cF08c4233b9D6E61051A43B18
Account balance: 1934772596667918724 true
Expand All @@ -472,11 +472,11 @@ After running the script it sets addresses to `.env`. If you want to redeploy so

1. Register a name using the account you used to deploy the contract
2. Set the label (`matoken` for `matoken.eth`) to `SEED_NAME=` on `.env`
3. Run `yarn seed:rinkeby`
3. Run `pnpm seed:rinkeby`

```
~/.../ens/name-wrapper (seed)$yarn seed:rinkeby
yarn run v1.22.10
~/.../ens/name-wrapper (seed)$pnpm seed:rinkeby
pnpm run v1.22.10
$ npx hardhat run --network rinkeby scripts/seed.js
Account balance: 1925134991223891632
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import namehash from 'eth-ens-namehash'
import namehash from '@ensdomains/eth-ens-namehash'
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { keccak256 } from 'js-sha3'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments, network } = hre
Expand Down
1 change: 0 additions & 1 deletion deploy/ethregistrar/00_setup_base_registrar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import namehash from 'eth-ens-namehash'
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
Expand Down
5 changes: 2 additions & 3 deletions deploy/ethregistrar/03_deploy_eth_registrar_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { Interface } from 'ethers/lib/utils'
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

const { makeInterfaceId } = require('@openzeppelin/test-helpers')
import { makeInterfaceId } from '../utils/solidity'

function computeInterfaceId(iface: Interface) {
return makeInterfaceId.ERC165(
return makeInterfaceId(
Object.values(iface.functions).map((frag) => frag.format('sighash')),
)
}
Expand Down
5 changes: 2 additions & 3 deletions deploy/ethregistrar/04_deploy_bulk_renewal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { Interface } from 'ethers/lib/utils'
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

const { makeInterfaceId } = require('@openzeppelin/test-helpers')
import { makeInterfaceId } from '../utils/solidity'

function computeInterfaceId(iface: Interface) {
return makeInterfaceId.ERC165(
return makeInterfaceId(
Object.values(iface.functions).map((frag) => frag.format('sighash')),
)
}
Expand Down
19 changes: 19 additions & 0 deletions deploy/utils/solidity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { utils } from 'ethers'

export function makeInterfaceId(functionSignatures: string[] = []) {
const INTERFACE_ID_LENGTH = 4

const interfaceIdBuffer = functionSignatures
.map((signature) => utils.keccak256(signature)) // keccak256
.map(
(h) => Buffer.from(h.substring(2), 'hex').subarray(0, 4), // bytes4()
)
.reduce((memo, bytes) => {
for (let i = 0; i < INTERFACE_ID_LENGTH; i++) {
memo[i] = memo[i] ^ bytes[i] // xor
}
return memo
}, Buffer.alloc(INTERFACE_ID_LENGTH))

return `0x${interfaceIdBuffer.toString('hex')}`
}
5 changes: 2 additions & 3 deletions deploy/wrapper/01_deploy_name_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { Interface } from 'ethers/lib/utils'
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

const { makeInterfaceId } = require('@openzeppelin/test-helpers')
import { makeInterfaceId } from '../utils/solidity'

function computeInterfaceId(iface: Interface) {
return makeInterfaceId.ERC165(
return makeInterfaceId(
Object.values(iface.functions).map((frag) => frag.format('sighash')),
)
}
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"lint": "hardhat check",
"build": "rm -rf ./build/deploy ./build/hardhat.config.js && hardhat compile && tsc",
"format": "prettier --write .",
"prepublishOnly": "yarn build",
"pub": "yarn publish --access public",
"prepublishOnly": "pnpm build",
"pub": "pnpm publish --access public",
"prepare": "husky install"
},
"files": [
Expand All @@ -29,33 +29,34 @@
"@nomiclabs/hardhat-truffle5": "^2.0.0",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@nomiclabs/hardhat-web3": "^2.0.0",
"@openzeppelin/test-helpers": "^0.5.11",
"@types/mocha": "^9.1.1",
"@types/node": "^18.0.0",
"chai": "^4.3.4",
"dotenv": "^10.0.0",
"elliptic-solidity": "^1.0.0",
"envfile": "^6.17.0",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.6.1",
"ethers": "^5.7.2",
"hardhat": "^2.9.9",
"hardhat-abi-exporter": "^2.9.0",
"hardhat-contract-sizer": "^2.6.1",
"hardhat-deploy": "^0.11.10",
"hardhat-deploy": "^0.12.1",
"hardhat-gas-reporter": "^1.0.4",
"husky": "^8.0.0",
"prettier": "^2.6.2",
"prettier-plugin-solidity": "^1.0.0-beta.24",
"rfc4648": "^1.5.0",
"ts-node": "^10.8.1",
"typescript": "^4.7.3"
"typescript": "^4.7.3",
"web3": "^1.2.11"
},
"resolutions": {
"ethereum-ens": "0.8.0",
"js-sha3": "0.8.0"
},
"dependencies": {
"@ensdomains/buffer": "^0.1.1",
"@ensdomains/eth-ens-namehash": "^2.0.15",
"@ensdomains/solsha1": "0.0.3",
"@openzeppelin/contracts": "^4.1.0",
"dns-packet": "^5.3.0"
Expand Down
Loading
Loading