Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

extract licenses from metadata #487

Merged
merged 2 commits into from
Jun 24, 2022
Merged
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
6 changes: 6 additions & 0 deletions src/common/feature-detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,17 @@ async function fetchContractMetadata(
details: metadata.output.devdoc.detail,
notice: metadata.output.userdoc.notice,
});
const licenses: string[] = [
...new Set(
Object.entries(metadata.sources).map(([_, src]) => (src as any).license),
),
];
return {
name,
abi,
metadata,
info,
licenses,
};
}

Expand Down
1 change: 1 addition & 0 deletions src/schema/contracts/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,5 @@ export type PublishedMetadata = {
abi: z.infer<typeof AbiSchema>;
metadata: Record<string, any>;
info: z.infer<typeof ContractInfoSchema>;
licenses: string[];
};
1 change: 1 addition & 0 deletions test/custom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ describe("Custom Contracts", async () => {
invariant(c, "Contract undefined");
const meta = await c.publishedMetadata.get();
expect(meta.name).to.eq("Greeter");
expect(meta.licenses.length).gt(0);
});

it("should extract functions", async () => {
Expand Down