Skip to content

Commit

Permalink
fix abi codegen runtime validation (#1552)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiqiang90 authored Mar 8, 2023
1 parent 567ce25 commit cc841f9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/cli/src/controller/codegen-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,20 @@ interface abiInterface {
export async function generateAbis(datasources: DatasourceKind[], projectPath: string): Promise<void> {
const sortedAssets = new Map<string, string>();
datasources.map((d) => {
if (!d?.assets || !isRuntimeEthereumDs(d) || !isCustomEthereumDs(d) || !isCustomSubstrateDs(d)) {
if (!d?.assets) {
return;
}
Object.entries(d.assets).map(([name, value]) => {
const filePath = path.join(projectPath, value.file);
if (!fs.existsSync(filePath)) {
throw new Error(`Error: Asset ${name}, file ${value.file} does not exist`);
}
// We use actual abi file name instead on name provided in assets
// This is aligning with files in './ethers-contracts'
sortedAssets.set(parseContractPath(filePath).name, value.file);
});
if (isRuntimeEthereumDs(d) || isCustomEthereumDs(d) || isCustomSubstrateDs(d)) {
Object.entries(d.assets).map(([name, value]) => {
const filePath = path.join(projectPath, value.file);
if (!fs.existsSync(filePath)) {
throw new Error(`Error: Asset ${name}, file ${value.file} does not exist`);
}
// We use actual abi file name instead on name provided in assets
// This is aligning with files in './ethers-contracts'
sortedAssets.set(parseContractPath(filePath).name, value.file);
});
}
});
if (sortedAssets.size !== 0) {
await prepareDirPath(path.join(projectPath, ABI_INTERFACES_ROOT_DIR), true);
Expand Down

0 comments on commit cc841f9

Please sign in to comment.