Skip to content

Commit

Permalink
experimental changes for better tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed May 22, 2024
1 parent 8e8cf71 commit 2b7bae3
Show file tree
Hide file tree
Showing 21 changed files with 2,315 additions and 10,896 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: CI

on:
push:
branches: [staging, mainnet]
pull_request:
# TODO: reenable
on: []

jobs:
wiki_address_check:
Expand Down
Binary file added bun.lockb
Binary file not shown.
16 changes: 3 additions & 13 deletions hardhat.config.ts → hardhat.config.cts
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import { exec as _exec } from 'child_process'

import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-solhint'
import '@nomiclabs/hardhat-truffle5'
import '@nomiclabs/hardhat-waffle'
import '@nomicfoundation/hardhat-toolbox-viem'
import dotenv from 'dotenv'
import 'hardhat-abi-exporter'
import 'hardhat-contract-sizer'
import 'hardhat-deploy'
import 'hardhat-gas-reporter'
import { HardhatUserConfig } from 'hardhat/config'
import { promisify } from 'util'

const exec = promisify(_exec)
import('@ensdomains/hardhat-chai-matchers-viem')

// hardhat actions
import './tasks/accounts'
import './tasks/archive_scan'
import './tasks/save'
import './tasks/seed'
import './tasks/esm_fix.cjs'

// Load environment variables from .env file. Suppress warnings using silent
// if this file is missing. dotenv will never modify any environment variables
Expand Down
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
"name": "@ensdomains/ens-contracts",
"version": "1.0.0",
"description": "ENS contracts",
"type": "module",
"scripts": {
"test": "hardhat test",
"compile": "NODE_OPTIONS=\"--experimental-loader ts-node/esm/transpile-only\" hardhat compile",
"test": "NODE_OPTIONS=\"--experimental-loader ts-node/esm/transpile-only\" TS_NODE_PREFER_TS_EXTS=true hardhat test ./test/ethregistrar/TestStablePriceOracle.ts",
"test:parallel": "NODE_OPTIONS=\"--experimental-loader ts-node/esm/transpile-only\" TS_NODE_PREFER_TS_EXTS=true hardhat test ./test/**/Test*.ts --parallel",
"test:local": "hardhat --network localhost test",
"test:deploy": "hardhat --network hardhat deploy",
"lint": "hardhat check",
Expand All @@ -12,7 +15,8 @@
"prepublishOnly": "yarn build",
"pub": "yarn publish --access public",
"prepare": "husky install",
"wikiCheck": "node wikiCheck.js "
"wikiCheck": "node wikiCheck.js ",
"postinstall": "bunx patch-package"
},
"files": [
"build",
Expand All @@ -24,22 +28,20 @@
"main": "index.js",
"devDependencies": {
"@ensdomains/dnsprovejs": "^0.3.7",
"@ensdomains/hardhat-chai-matchers-viem": "^0.0.1",
"@ensdomains/test-utils": "^1.3.0",
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13",
"@nomiclabs/hardhat-solhint": "^2.0.0",
"@nomiclabs/hardhat-truffle5": "^2.0.0",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@nomiclabs/hardhat-web3": "^2.0.0",
"@nomicfoundation/hardhat-toolbox-viem": "^3.0.0",
"@openzeppelin/test-helpers": "^0.5.11",
"@types/mocha": "^9.1.1",
"@types/node": "^18.0.0",
"@vitest/expect": "^1.6.0",
"chai": "^4.3.4",
"dotenv": "^10.0.0",
"dotenv": "^16.4.5",
"elliptic-solidity": "^1.0.0",
"envfile": "^6.17.0",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.6.1",
"hardhat": "^2.9.9",
"hardhat": "^2.22.2",
"hardhat-abi-exporter": "^2.9.0",
"hardhat-contract-sizer": "^2.6.1",
"hardhat-deploy": "^0.11.10",
Expand All @@ -48,8 +50,9 @@
"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"
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"viem": "^2.10.2"
},
"resolutions": {
"ethereum-ens": "0.8.0",
Expand Down
31 changes: 31 additions & 0 deletions patches/@nomicfoundation+hardhat-viem+2.0.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/node_modules/@nomicfoundation/hardhat-viem/internal/clients.js b/node_modules/@nomicfoundation/hardhat-viem/internal/clients.js
index 9466df2..b3d2fd5 100644
--- a/node_modules/@nomicfoundation/hardhat-viem/internal/clients.js
+++ b/node_modules/@nomicfoundation/hardhat-viem/internal/clients.js
@@ -47,7 +47,7 @@ async function innerGetPublicClient(provider, chain, publicClientConfig) {
const parameters = { ...defaultParameters, ...publicClientConfig };
const publicClient = viem.createPublicClient({
chain,
- transport: viem.custom(provider),
+ transport: viem.custom(provider, { retryCount: 0 }),
...parameters,
});
return publicClient;
@@ -80,7 +80,7 @@ async function innerGetWalletClients(provider, chain, accounts, walletClientConf
const walletClients = accounts.map((account) => viem.createWalletClient({
chain,
account,
- transport: viem.custom(provider),
+ transport: viem.custom(provider, { retryCount: 0 }),
...parameters,
}));
return walletClients;
@@ -123,7 +123,7 @@ async function innerGetTestClient(provider, chain, mode, testClientConfig) {
const testClient = viem.createTestClient({
mode,
chain,
- transport: viem.custom(provider),
+ transport: viem.custom(provider, { retryCount: 0 }),
...parameters,
});
return testClient;
4 changes: 2 additions & 2 deletions tasks/accounts.ts → tasks/accounts.cts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { task } from 'hardhat/config'
import config = require('hardhat/config')

task('accounts', 'Prints the list of accounts', async (_, hre) => {
config.task('accounts', 'Prints the list of accounts', async (_, hre) => {
const accounts = await hre.ethers.getSigners()

for (const account of accounts) {
Expand Down
46 changes: 46 additions & 0 deletions tasks/archive_scan.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// import { existsSync } from 'fs'
import fs = require('fs')

// import { task } from 'hardhat/config.js'
import config = require('hardhat/config')

// import { archivedDeploymentPath } from '../hardhat.config.cjs'
import ic = require('../hardhat.config.cjs')

config
.task('archive-scan', 'Scans the deployments for unarchived deployments')
.setAction(async (_, hre) => {
const network = hre.network.name

const deployments = await hre.deployments.all()

for (const deploymentName in deployments) {
const deployment = deployments[deploymentName]
if (!deployment.receipt || !deployment.bytecode) continue

const archiveName = `${deploymentName}_${network}_${deployment.receipt.blockNumber}`
const archivePath = `${ic.archivedDeploymentPath}/${archiveName}.sol`

if (fs.existsSync(archivePath)) {
continue
}

let fullName: string
try {
await hre.deployments.getArtifact(deploymentName)
fullName = `${deploymentName}.sol:${deploymentName}`
} catch (e: any) {
if (e._isHardhatError && e.number === 701) {
fullName = e.messageArguments.candidates.split('\n')[1]
} else {
throw e
}
}

await hre.run('save', {
contract: deploymentName,
block: String(deployment.receipt.blockNumber),
fullName,
})
}
})
44 changes: 0 additions & 44 deletions tasks/archive_scan.ts

This file was deleted.

21 changes: 21 additions & 0 deletions tasks/esm_fix.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import fs = require('fs/promises')
import task_names = require('hardhat/builtin-tasks/task-names')
import config = require('hardhat/config')
import path = require('path')

config
.subtask(task_names.TASK_COMPILE_SOLIDITY)
.setAction(async (_, { config }, runSuper) => {
const superRes = await runSuper()

try {
await fs.writeFile(
path.join(config.paths.artifacts, 'package.json'),
'{ "type": "commonjs" }',
)
} catch (error) {
console.error('Error writing package.json: ', error)
}

return superRes
})
2 changes: 1 addition & 1 deletion tasks/save.ts → tasks/save.cts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { promisify } from 'util'
import { task } from 'hardhat/config'
import { Artifact } from 'hardhat/types'

import { archivedDeploymentPath } from '../hardhat.config'
import { archivedDeploymentPath } from '../hardhat.config.cts'

const exec = promisify(_exec)

Expand Down

0 comments on commit 2b7bae3

Please sign in to comment.