Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lenient Read Mastercopy #9

Merged
merged 2 commits into from
Aug 23, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gnosis-guild/zodiac-core",
"version": "1.1.0",
"version": "1.1.1",
"description": "Zodiac is a composable design philosophy and collection of standards for building DAO ecosystem tooling.",
"author": "Auryn Macmillan <[email protected]>",
"license": "LGPL-3.0+",
Expand Down
17 changes: 3 additions & 14 deletions src/artifact/readMastercopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { MastercopyArtifact } from "../types";
* @param {string} [params.contractVersion] - The version of the contract. If not provided, the latest version will be used.
* @param {string} [params.mastercopyArtifactsFile=defaultMastercopyArtifactsFile()] - The path to the mastercopy artifacts file. Optional.
* @returns {MastercopyArtifact} The Mastercopy artifact information.
* @throws {Error} If the artifacts file does not exist, the contract name is not found, or the contract version is invalid.
*/
export default function readMastercopy({
contractName,
Expand All @@ -26,7 +25,7 @@ export default function readMastercopy({
contractName: string;
contractVersion?: string;
mastercopyArtifactsFile?: string;
}): MastercopyArtifact {
}): MastercopyArtifact | null {
if (!existsSync(mastercopyArtifactsFile)) {
throw new Error(
`MastercopyArtifacts file not found at ${mastercopyArtifactsFile}`
Expand All @@ -38,24 +37,14 @@ export default function readMastercopy({
);

if (!mastercopies[contractName]) {
throw new Error(
`MastercopyArtifacts file does not contain any entries for ${contractName}`
);
return null;
}

if (!contractVersion) {
contractVersion = findLatestVersion(mastercopies[contractName]);
}

const artifact = mastercopies[contractName][contractVersion];

if (!artifact) {
throw new Error(
`MastercopyArtifacts file: no artifact ${contractName}@${contractVersion}`
);
}

return artifact;
return mastercopies[contractName][contractVersion] || null;
}

function findLatestVersion(mastercopies: JSON) {
Expand Down
Loading