hardhat/types#HardhatArguments TypeScript Examples
The following examples show how to use
hardhat/types#HardhatArguments.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: compile.ts From eth with GNU General Public License v3.0 | 6 votes |
async function copyAbi(
args: HardhatArguments,
hre: HardhatRuntimeEnvironment,
runSuper: RunSuperFunction<TaskArguments>
) {
const out = await runSuper(args);
const { abi } = await hre.artifacts.readArtifact(hre.config.diamondAbi.name);
const abisDir = path.join(hre.packageDirs['@darkforest_eth/contracts'], 'abis');
// workaround for: https://github.com/graphprotocol/graph-cli/issues/588
// just remove calls we cant process, note makes them unusable from within
// graph but largely dont need these
const filteredDiamondAbi = abi.filter(abiFilter);
await fs.writeFile(
path.join(abisDir, 'DarkForest_stripped.json'),
prettier.format(JSON.stringify(filteredDiamondAbi), {
semi: false,
parser: 'json',
})
);
return out;
}
Example #2
Source File: subgraph.ts From eth with GNU General Public License v3.0 | 6 votes |
async function subgraphCodegen(_args: HardhatArguments, hre: HardhatRuntimeEnvironment) {
const { CONTRACT_ADDRESS, START_BLOCK } = hre.contracts;
// hardcoded for now, will be able to set with plugin
const subgraphPath = path.join(hre.config.paths.root, 'subgraph');
const abisPath = path.join(hre.packageDirs['@darkforest_eth/contracts'], 'abis');
const warning = 'THIS FILE IS GENERATED DO NOT EDIT THIS FILE. EDIT subgraph.template.yaml\n\n';
const yaml = (await fs.readFile(path.join(subgraphPath, 'subgraph.template.yaml')))
.toString()
.replace(/{{{CONTRACT_ADDRESS}}}/g, CONTRACT_ADDRESS)
.replace(/#{{{START_BLOCK}}}/g, START_BLOCK.toString())
.replace(/{{{DARKFOREST_ABI_PATH}}}/g, path.join(abisPath, 'DarkForest_stripped.json'));
await fs.writeFile(path.join(subgraphPath, 'subgraph.yaml'), '# ' + warning + yaml);
await exec(`npx graph codegen subgraph/subgraph.yaml`, {
cwd: subgraphPath,
env: { ...process.env },
stdio: 'inherit',
});
}