Skip to content

Commit

Permalink
fix: add more required ABI exports to subgraph task
Browse files Browse the repository at this point in the history
  • Loading branch information
panukettu committed Apr 12, 2023
1 parent e92fe03 commit fcf2be4
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions src/tasks/utility/write-subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ const logger = getLogger(TASK_WRITE_SUBGRAPH_JSON);

const deploymentNames: (keyof TC | "krCUBE")[] = [
"Kresko",
"UniswapV2Factory",
"KISS",
"krCUBE",
"KrStaking",
"KrStakingHelper",
"FluxPriceFeedFactory",
"FluxPriceFeed",
"KreskoAsset",
"ERC20Upgradeable",
"UniswapV2Factory",
"UniswapV2Router02",
"UniswapV2Oracle",
"UniswapV2Pair",
];

task(TASK_WRITE_SUBGRAPH_JSON).setAction(async function (_taskArgs: TaskArguments, hre) {
Expand All @@ -30,24 +35,31 @@ task(TASK_WRITE_SUBGRAPH_JSON).setAction(async function (_taskArgs: TaskArgument

for (const deploymentName of deploymentNames) {
const deployment = await hre.getDeploymentOrFork(deploymentName);
if (!deployment) continue;

results.push({
[deploymentName]: {
address: deployment.address,
startBlock: deployment.receipt?.blockNumber || 0,
},
});
if (deployment) {
results.push({
[deploymentName]: {
address: deployment.address,
startBlock: deployment.receipt?.blockNumber || 0,
},
});
} else {
logger.warn(`deployment not found for: ${deploymentName} - ABI will be exported`);
}

let ABI: any[];
let ABI: any[] | undefined;
try {
ABI = hre.artifacts.readArtifactSync(deploymentName).abi;
} catch {
logger.warn(`hardhat artifact not found for: ${deploymentName} - saving ABI from the deployment`);
ABI = deployment.abi;
logger.warn(`hardhat artifact not found for: ${deploymentName} - saving ABI from deployment`);
if (deployment) {
ABI = deployment.abi;
}
}
if (ABI) {
writeFileSync(`${abiDir}/${deploymentName}.json`, JSON.stringify(ABI, null, 2));
} else {
logger.error(`ABI not found for: ${deploymentName}`);
}

writeFileSync(`${abiDir}/${deploymentName}.json`, JSON.stringify(ABI, null, 2));
}
const output = {
[hre.network.name === "opgoerli" ? "optimism-goerli" : hre.network.name]: results,
Expand Down

0 comments on commit fcf2be4

Please sign in to comment.