Skip to content

Commit

Permalink
fix type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Aug 21, 2024
1 parent 31ec370 commit 1335761
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/world/ts/node/findContractArtifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export type Input = {
export type Output = readonly ContractArtifact[];

const parseArtifact = type("parse.json").to(types.Artifact);
type Artifact = typeof types.Artifact.infer;

function hasMetadata(
artifact: Artifact,
): artifact is Artifact & { [k in "metadata"]-?: Exclude<Artifact["metadata"], undefined> } {
return artifact.metadata !== undefined;
}

export async function findContractArtifacts({ forgeOutDir }: Input): Promise<Output> {
const files = (await glob("**/*.sol/*.json", { ignore: "**/*.abi.json", cwd: forgeOutDir })).sort();
Expand All @@ -35,8 +42,9 @@ export async function findContractArtifacts({ forgeOutDir }: Input): Promise<Out
return artifact;
})
.filter(isDefined)
.filter(type({ metadata: "object" }).allows)
.filter(hasMetadata)
.map((artifact) => {
artifact;
const sourcePath = Object.keys(artifact.metadata.settings.compilationTarget)[0];
const name = artifact.metadata.settings.compilationTarget[sourcePath];
const deployedBytecodeSize = size(artifact.deployedBytecode.object);
Expand Down

0 comments on commit 1335761

Please sign in to comment.