Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ node_modules/
# Hardhat artifacts
artifacts/
cache/
**/.hardhat

# Build artifacts
dist/
pkg/balancer-js/src/typechain/*
typechain-types/

test.json

Expand Down
102 changes: 26 additions & 76 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import '@nomiclabs/hardhat-ethers';
import '@nomiclabs/hardhat-vyper';
import '@nomiclabs/hardhat-waffle';
import '@nomicfoundation/hardhat-verify';
import 'hardhat-local-networks-config-plugin';
import 'hardhat-ignore-warnings';
import hardhatEthersPlugin from '@nomicfoundation/hardhat-ethers';
import hardhatVerifyPlugin from '@nomicfoundation/hardhat-verify';
import hardhatNetworkHelpersPlugin from '@nomicfoundation/hardhat-network-helpers';
import hardhatMochaPlugin from '@nomicfoundation/hardhat-mocha';
import 'tsconfig-paths/register';

import './src/helpers/setupTests';

import { task } from 'hardhat/config';
import { TASK_TEST } from 'hardhat/builtin-tasks/task-names';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

import path from 'path';
import { existsSync, readdirSync, readFileSync, statSync } from 'fs';

import { checkArtifact, extractArtifact } from './src/artifact';
import test from './src/test';
import Task, { TaskMode, TaskStatus } from './src/task';
import Verifier from './src/verifier';
import logger, { Logger } from './src/logger';
import {
checkActionIds,
Expand All @@ -35,12 +30,13 @@ import {
saveTimelockAuthorizerConfig,
withRetries,
} from './src/network';
import { Etherscan } from '@nomicfoundation/hardhat-verify/etherscan';
import { ApiKey } from '@nomicfoundation/hardhat-verify/types';

type HardhatRuntimeEnvironment = any;

const THEGRAPHURLS: { [key: string]: string } = {};

task('deploy', 'Run deployment task')
if (process.env.ENABLE_LEGACY_TASKS === 'true') {
task('deploy', 'Run deployment task')
.addParam('id', 'Deployment task ID')
.addFlag('force', 'Ignore previous deployments')
.addOptionalParam('key', 'Etherscan API key to verify contracts')
Expand All @@ -52,33 +48,11 @@ task('deploy', 'Run deployment task')
) => {
Logger.setDefaults(false, args.verbose || false);

const network = hre.network.name;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const networkApiKey = args.key ?? (hre.config.networks[network] as any).verificationAPIKey;
// If the v1 API flag is set, we need to wrap the API key in an object with the network name as the key
// as this is how the Etherscan verification library expects it (otherwise it defaults to v2).
const apiKey: ApiKey = args.v1
? {
[network]: networkApiKey,
}
: networkApiKey;

const verifier = apiKey
? new Verifier(
hre.network,
apiKey,
await Etherscan.getCurrentChainConfig(
hre.network.name,
hre.network.provider,
hre.config.etherscan.customChains
)
)
: undefined;
await new Task(args.id, TaskMode.LIVE, hre.network.name, verifier).run(args);
await new Task(args.id, TaskMode.LIVE, hre.network.name).run(args);
}
);

task('verify-contract', `Verify a task's deployment on a block explorer`)
task('verify-contract', `Verify a task's deployment on a block explorer`)
.addParam('id', 'Deployment task ID')
.addParam('name', 'Contract name')
.addParam('address', 'Contract address')
Expand All @@ -92,35 +66,12 @@ task('verify-contract', `Verify a task's deployment on a block explorer`)
) => {
Logger.setDefaults(false, args.verbose || false);

const network = hre.network.name;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const networkApiKey = args.key ?? (hre.config.networks[network] as any).verificationAPIKey;
// If the v1 API flag is set, we need to wrap the API key in an object with the network name as the key
// as this is how the Etherscan verification library expects it (otherwise it defaults to v2).
const apiKey: ApiKey = args.v1
? {
[network]: networkApiKey,
}
: networkApiKey;

const verifier = apiKey
? new Verifier(
hre.network,
apiKey,
await Etherscan.getCurrentChainConfig(
hre.network.name,
hre.network.provider,
hre.config.etherscan.customChains
)
)
: undefined;

// Contracts can only be verified in Live mode
await new Task(args.id, TaskMode.LIVE, hre.network.name, verifier).verify(args.name, args.address, args.args);
await new Task(args.id, TaskMode.LIVE, hre.network.name).verify(args.name, args.address, args.args);
}
);

task('extract-artifacts', `Extract contract artifacts from their build-info`)
task('extract-artifacts', `Extract contract artifacts from their build-info`)
.addOptionalParam('id', 'Specific task ID')
.addOptionalParam('file', 'Target build-info file name')
.addOptionalParam('name', 'Contract name')
Expand All @@ -138,7 +89,7 @@ task('extract-artifacts', `Extract contract artifacts from their build-info`)
}
});

task('check-deployments', `Check that all tasks' deployments correspond to their build-info and inputs`)
task('check-deployments', `Check that all tasks' deployments correspond to their build-info and inputs`)
.addOptionalParam('id', 'Specific task ID')
.setAction(async (args: { id?: string; force?: boolean; verbose?: boolean }, hre: HardhatRuntimeEnvironment) => {
// The force argument above is actually not passed (and not required or used in CHECK mode), but it is the easiest
Expand Down Expand Up @@ -169,7 +120,7 @@ task('check-deployments', `Check that all tasks' deployments correspond to their
}
});

task('check-artifacts', `check that contract artifacts correspond to their build-info`)
task('check-artifacts', `check that contract artifacts correspond to their build-info`)
.addOptionalParam('id', 'Specific task ID')
.setAction(async (args: { id?: string; verbose?: boolean }) => {
Logger.setDefaults(false, args.verbose || false);
Expand All @@ -185,7 +136,7 @@ task('check-artifacts', `check that contract artifacts correspond to their build
}
});

task('save-action-ids', `Print the action IDs for a particular contract and checks their uniqueness`)
task('save-action-ids', `Print the action IDs for a particular contract and checks their uniqueness`)
.addOptionalParam('id', 'Specific task ID')
.addOptionalParam('name', 'Contract name')
.addOptionalParam('address', 'Address of Pool created from a factory')
Expand Down Expand Up @@ -257,7 +208,7 @@ task('save-action-ids', `Print the action IDs for a particular contract and chec
}
);

task('check-action-ids', `Check that contract action-ids correspond the expected values`)
task('check-action-ids', `Check that contract action-ids correspond the expected values`)
.addOptionalParam('id', 'Specific task ID')
.setAction(async (args: { id?: string; verbose?: boolean }, hre: HardhatRuntimeEnvironment) => {
Logger.setDefaults(false, args.verbose || false);
Expand All @@ -275,7 +226,7 @@ task('check-action-ids', `Check that contract action-ids correspond the expected
checkActionIdUniqueness(hre.network.name);
});

task('get-action-id-info', `Returns all the matches for the given actionId`)
task('get-action-id-info', `Returns all the matches for the given actionId`)
.addPositionalParam('id', 'ActionId to use for the lookup')
.setAction(async (args: { id: string; verbose?: boolean }, hre: HardhatRuntimeEnvironment) => {
Logger.setDefaults(false, args.verbose || false);
Expand All @@ -290,7 +241,7 @@ task('get-action-id-info', `Returns all the matches for the given actionId`)
}
});

task('get-action-ids-info', `Reconstructs all the permissions from TheGraph AP and action-ids files`).setAction(
task('get-action-ids-info', `Reconstructs all the permissions from TheGraph AP and action-ids files`).setAction(
async (args: { verbose?: boolean }, hre: HardhatRuntimeEnvironment) => {
Logger.setDefaults(false, args.verbose || false);
logger.log(`Fetching permissions using TheGraph API on ${hre.network.name}...`, '');
Expand All @@ -310,7 +261,7 @@ task('get-action-ids-info', `Reconstructs all the permissions from TheGraph AP a
}
);

task('build-address-lookup', `Build a lookup table from contract addresses to the relevant deployment`).setAction(
task('build-address-lookup', `Build a lookup table from contract addresses to the relevant deployment`).setAction(
async (args: { verbose?: boolean }, hre: HardhatRuntimeEnvironment) => {
Logger.setDefaults(false, args.verbose || false);
if (hre.network.name === 'hardhat') {
Expand All @@ -328,7 +279,7 @@ task('build-address-lookup', `Build a lookup table from contract addresses to th
}
);

task(
task(
'check-address-lookup',
`Check whether the existing lookup table from contract addresses to the relevant deployments is correct`
).setAction(async (args: { verbose?: boolean }, hre: HardhatRuntimeEnvironment) => {
Expand All @@ -353,7 +304,7 @@ task(
}
});

task('build-timelock-authorizer-config', `Builds JSON file with Timelock Authorizer configuration`).setAction(
task('build-timelock-authorizer-config', `Builds JSON file with Timelock Authorizer configuration`).setAction(
async (args: { verbose?: boolean }, hre: HardhatRuntimeEnvironment) => {
Logger.setDefaults(false, args.verbose || false);

Expand All @@ -380,7 +331,7 @@ task('build-timelock-authorizer-config', `Builds JSON file with Timelock Authori
}
);

task(
task(
'check-timelock-authorizer-config',
`Check whether the existing timelock authorizer configuration file is correct`
).setAction(async (args: { verbose?: boolean }, hre: HardhatRuntimeEnvironment) => {
Expand Down Expand Up @@ -414,7 +365,7 @@ task(
}
});

task(
task(
'verify-timelock-authorizer-config',
`Check whether the existing timelock authorizer configuration file matches the delays configured onchain`
).setAction(async (args: { verbose?: boolean }, hre: HardhatRuntimeEnvironment) => {
Expand Down Expand Up @@ -450,9 +401,11 @@ task(
}
});

task(TASK_TEST).addOptionalParam('id', 'Specific task ID of the fork test to run.').setAction(test);
task('test').addOptionalParam('id', 'Specific task ID of the fork test to run.').setAction(test);
}

export default {
plugins: [hardhatEthersPlugin, hardhatVerifyPlugin, hardhatNetworkHelpersPlugin, hardhatMochaPlugin],
mocha: {
timeout: 600000,
},
Expand All @@ -479,9 +432,6 @@ export default {
},
],
},
vyper: {
compilers: [{ version: '0.3.1' }, { version: '0.3.3' }],
},
paths: {
artifacts: './src/helpers/.hardhat/artifacts',
cache: './src/helpers/.hardhat/cache',
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function getBalancerContract(task: string, contract: string, networ
*/
export async function getBalancerContractAt(task: string, contract: string, address: string): Promise<Contract> {
const artifact = getBalancerContractArtifact(task, contract);
return new Contract(address, artifact.abi);
return new Contract(address, artifact.abi as any);
}

/**
Expand Down
26 changes: 15 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"/dist/index.*",
"/dist/{addresses,tasks}/**/*"
],
"type": "module",
"scripts": {
"networks": "cat addresses/.supported-networks.json | jq -r 'keys[]'",
"execute-for-networks": "yarn networks | xargs -I {}",
Expand All @@ -41,9 +42,9 @@
"lint:solidity": "solhint 'src/helpers/contracts/**/*.sol'",
"lint:typescript": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0",
"prepack": "yarn build",
"test": "yarn build && hardhat test v*/**/test/*.ts",
"test:v2": "yarn build && hardhat test v2/**/test/*.ts",
"test:v3": "yarn build && hardhat test v3/**/test/*.ts",
"test": "yarn build && hardhat test v*/tasks/**/test/*.ts",
"test:v2": "yarn build && hardhat test v2/tasks/**/test/*.ts",
"test:v3": "yarn build && hardhat test v3/tasks/**/test/*.ts",
"ci:prepare-config": "ts-node ci/prepare-config.ts"
},
"resolutions": {
Expand All @@ -61,13 +62,16 @@
"@ethereumjs/common": "^4.4.0",
"@ethereumjs/evm": "^3.1.1",
"@ethersproject/contracts": "^5.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.6",
"@nomicfoundation/hardhat-verify": "^2.1.1",
"@nomiclabs/hardhat-ethers": "^2.2.1",
"@nomiclabs/hardhat-vyper": "^3.0.5",
"@nomicfoundation/hardhat-ethers": "^4.0.4",
"@nomicfoundation/hardhat-mocha": "^3.0.11",
"@nomicfoundation/hardhat-network-helpers": "^3.0.3",
"@nomicfoundation/hardhat-typechain": "^3.0.2",
"@nomicfoundation/hardhat-verify": "^3.0.10",
"@nomiclabs/hardhat-vyper": "3.1.0",
"@nomiclabs/hardhat-waffle": "^2.0.6",
"@openzeppelin/contracts": "npm:@openzeppelin/contracts@^5.0.0",
"@solidity-parser/parser": "^0.18.0",
"@typechain/ethers-v6": "^0.5.1",
"@types/async-retry": "^1",
"@types/chai": "^4",
"@types/lodash": "^4.14.186",
Expand All @@ -84,13 +88,12 @@
"eslint": "^8.26.0",
"eslint-plugin-mocha-no-only": "^1.1.1",
"eslint-plugin-prettier": "^4.2.1",
"ethereum-waffle": "^4.0.10",
"ethereumjs-util": "^7.1.5",
"ethers": "^5.7.2",
"ethers": "6.16.0",
"graphql": "^16.6.0",
"graphql-request": "^5.2.0",
"hardhat": "^2.28.4",
"hardhat-ignore-warnings": "^0.2.12",
"hardhat": "^3.1.8",
"hardhat-ignore-warnings": "^0.3.0",
"hardhat-local-networks-config-plugin": "^0.0.6",
"lodash.range": "^3.2.0",
"mocha": "^10.2.0",
Expand All @@ -101,6 +104,7 @@
"solhint-plugin-prettier": "^0.0.5",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.2",
"typechain": "^8.3.2",
"typescript": "^4.9.3"
},
"packageManager": "yarn@4.12.0"
Expand Down
2 changes: 2 additions & 0 deletions src/@src/hardhatCompat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from '../hardhatCompat';
export { default } from '../hardhatCompat';
13 changes: 7 additions & 6 deletions src/actionId.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { FunctionFragment, Interface } from '@ethersproject/abi';
import { Contract } from '@ethersproject/contracts';
import fs from 'fs';
import { padEnd } from 'lodash';
import lodash from 'lodash';
import path from 'path';
import logger from './logger';
import { request, gql } from 'graphql-request';

import Task, { TaskMode } from './task';

export const ACTION_ID_DIRECTORY = path.join(__dirname, '../action-ids');
const { padEnd } = lodash;

export const ACTION_ID_DIRECTORY = path.resolve(process.cwd(), 'action-ids');

export type RoleData = {
role: string;
Expand Down Expand Up @@ -191,7 +192,7 @@ async function getActionIdSource(
contractName: string,
factoryOutput?: string,
factoryName?: string
): Promise<{ useAdaptor: boolean; actionIdSource: Contract | undefined }> {
): Promise<{ useAdaptor: boolean; actionIdSource: unknown | undefined }> {
const artifact = task.artifact(contractName);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const contractInterface = new Interface(artifact.abi as any);
Expand All @@ -200,7 +201,7 @@ async function getActionIdSource(
if (task.id === '20241204-v3-vault' && (contractName === 'Vault' || contractName === 'VaultExtension')) {
const contract = await task.deployedInstance(contractName);
const vaultAdmin = await task.deployedInstance('VaultAdmin');
const contractAsAdmin = vaultAdmin.attach(contract.address);
const contractAsAdmin = vaultAdmin.attach(contract.address as string) as any;
return { useAdaptor: false, actionIdSource: contractAsAdmin };
}

Expand All @@ -227,7 +228,7 @@ async function getActionIdSource(

async function getActionIdsFromSource(
contractFunctions: [string, FunctionFragment][],
actionIdSource: Contract
actionIdSource: any
): Promise<ActionIdData> {
const functionActionIds = await Promise.all(
contractFunctions.map(async ([signature, contractFunction]) => {
Expand Down
3 changes: 2 additions & 1 deletion src/artifact.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'fs';
import { Artifact, CompilerOutputContract } from 'hardhat/types';
import type { Artifact } from 'hardhat/types/artifacts';
import type { CompilerOutputContract } from 'hardhat/types/solidity/compiler-io';
import path from 'path';
import logger from './logger';
import Task from './task';
Expand Down
2 changes: 1 addition & 1 deletion src/buildinfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BuildInfo } from 'hardhat/types';
import type { BuildInfo } from 'hardhat/types/artifacts';

export function findContractSourceName(buildInfo: BuildInfo, contractName: string): string {
const names = getAllFullyQualifiedNames(buildInfo);
Expand Down
Loading
Loading