Skip to content

Commit

Permalink
Include initial sketch for the atrifact entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
cristovaoth committed Aug 2, 2024
1 parent cd9e9bc commit 7d62208
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 49 deletions.
48 changes: 0 additions & 48 deletions src/README.md

This file was deleted.

13 changes: 12 additions & 1 deletion src/artifact/deployMastercopies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import deployMastercopy from "../deploy/deployMastercopy";

import { EIP1193Provider, MastercopyArtifact } from "../types";

/**
* Deploys all mastercopy contracts and versions specified in the artifacts file.
*
* @param {Object} params - The function parameters.
* @param mastercopyArtifactsFile - The path to the mastercopy artifacts file.
* @param provider - EIP1193 compliant provider
*
* @throws {Error} If the mastercopy artifacts file does not exist at the specified path.
*/
export default async function ({
mastercopyArtifactsFile = defaultMastercopyArtifactsFile(),
provider,
Expand All @@ -13,7 +22,9 @@ export default async function ({
provider: EIP1193Provider;
}) {
if (!existsSync(mastercopyArtifactsFile)) {
throw new Error(`MastercopyArtifacts file not found at ${mastercopyArtifactsFile}`);
throw new Error(
`MastercopyArtifacts file not found at ${mastercopyArtifactsFile}`
);
}

const allArtifacts = JSON.parse(
Expand Down
19 changes: 19 additions & 0 deletions src/artifact/storeMastercopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ import getBuildArtifact from "./internal/getBuildArtifact";

import { MastercopyArtifact } from "../types";

/**
* Extracts and stores mastercopy contract information in the artifacts file.
*
* For optional fields like `compilerInput` and `bytecode`, these can either be provided externally or extracted internally from build artifacts.
* The `compilerInput` is expected to be provided, since the internal code will include every generated source in the verification, instead of only including sources reached by the current contract through graph traversal.
*
* @param {Object} params - The function parameters.
* @param {string} params.contractVersion - The version of the contract.
* @param {string} params.contractName - The name of the contract.
* @param {Object} params.constructorArgs - The constructor arguments.
* @param {any[]} params.constructorArgs.types - The types of the constructor arguments.
* @param {any[]} params.constructorArgs.values - The values of the constructor arguments.
* @param {string} params.salt - A 32-byte value used for mastercopy deployment.
* @param {string} [params.factory=erc2470FactoryAddress] - The address of the factory contract used to deploy the mastercopy. Optional.
* @param {string} [params.bytecode] - The bytecode of the contract. Optional.
* @param {any} [params.compilerInput] - The minimal compiler input. Optional.
* @param {string} [params.buildDirPath=defaultBuildDir()] - The path to the build directory. Optional.
* @param {string} [params.mastercopyArtifactsFile=defaultMastercopyArtifactsFile()] - The path to the mastercopy artifacts file. Optional.
*/
export default function extractMastercopy({
contractVersion,
contractName,
Expand Down
10 changes: 10 additions & 0 deletions src/artifact/verifyMastercopies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ import verify from "./internal/verify";

import { MastercopyArtifact } from "../types";

/**
* Verifies mastercopy contracts specified in the artifacts file using the provided API url and key.
*
* @param {Object} params - The function parameters.
* @param {string} params.apiUrl - The API URL used for verification. If a chainId if provided, we will try to resolve to a valid explorer URL.
* @param {string} params.apiKey - The API key used for verification.
* @param {string} [params.mastercopyArtifactsFile=defaultMastercopyArtifactsFile()] - The path to the mastercopy artifacts file. Optional.
*
* @throws {Error} If the mastercopy artifacts file does not exist at the specified path.
*/
export default async function ({
apiUrl,
apiKey,
Expand Down

0 comments on commit 7d62208

Please sign in to comment.