Skip to content

Commit

Permalink
fix(core): update index
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Oct 23, 2024
1 parent 55299b5 commit 52a813b
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 312 deletions.
249 changes: 0 additions & 249 deletions dist/Solidity.tokens

This file was deleted.

62 changes: 31 additions & 31 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,22 +358,22 @@ const adm_zip_1 = __importDefault(__nccwpck_require__(66761));
const fs = __importStar(__nccwpck_require__(57147));
const path_1 = __nccwpck_require__(71017);
const artifact_1 = __importDefault(__nccwpck_require__(79450));
const core = __importStar(__nccwpck_require__(42186));
const core_1 = __nccwpck_require__(42186);
const github_1 = __nccwpck_require__(95438);
const providers_1 = __nccwpck_require__(40529);
const check_1 = __nccwpck_require__(57657);
const format_1 = __nccwpck_require__(84219);
const input_1 = __nccwpck_require__(98657);
const types_1 = __nccwpck_require__(88164);
const token = process.env.GITHUB_TOKEN || core.getInput("token");
const baseBranch = core.getInput("base");
const headBranch = core.getInput("head");
const contract = core.getInput("contract");
const address = core.getInput("address");
const rpcUrl = core.getInput("rpcUrl");
const failOnRemoval = core.getInput("failOnRemoval") === "true";
const workingDirectory = core.getInput("workingDirectory");
const retryDelay = parseInt(core.getInput("retryDelay"));
const token = process.env.GITHUB_TOKEN || (0, core_1.getInput)("token");
const baseBranch = (0, core_1.getInput)("base");
const headBranch = (0, core_1.getInput)("head");
const contract = (0, core_1.getInput)("contract");
const address = (0, core_1.getInput)("address");
const rpcUrl = (0, core_1.getInput)("rpcUrl");
const failOnRemoval = (0, core_1.getInput)("failOnRemoval") === "true";
const workingDirectory = (0, core_1.getInput)("workingDirectory");
const retryDelay = parseInt((0, core_1.getInput)("retryDelay"));
const contractAbs = (0, path_1.join)(workingDirectory, contract);
const contractEscaped = contractAbs.replace(/\//g, "_").replace(/:/g, "-");
const getReportPath = (branch, baseName) => `${branch.replace(/[/\\]/g, "-")}.${baseName}.json`;
Expand All @@ -386,24 +386,24 @@ const provider = rpcUrl ? (0, providers_1.getDefaultProvider)(rpcUrl) : undefine
let srcContent;
let refCommitHash = undefined;
async function _run() {
core.startGroup(`Generate storage layout of contract "${contract}" using foundry forge`);
core.info(`Start forge process`);
(0, core_1.startGroup)(`Generate storage layout of contract "${contract}" using foundry forge`);
(0, core_1.info)(`Start forge process`);
const cmpContent = (0, input_1.createLayout)(contract, workingDirectory);
core.info(`Parse generated layout`);
(0, core_1.info)(`Parse generated layout`);
const cmpLayout = (0, input_1.parseLayout)(cmpContent);
core.endGroup();
(0, core_1.endGroup)();
const localReportPath = (0, path_1.resolve)(outReport);
fs.writeFileSync(localReportPath, cmpContent);
core.startGroup(`Upload new report from "${localReportPath}" as artifact named "${outReport}"`);
(0, core_1.startGroup)(`Upload new report from "${localReportPath}" as artifact named "${outReport}"`);
const uploadResponse = await artifact_1.default.uploadArtifact(outReport, [localReportPath], (0, path_1.dirname)(localReportPath));
if (uploadResponse.id)
throw Error("Failed to upload storage layout report.");
core.info(`Artifact ${uploadResponse.id} has been successfully uploaded!`);
core.endGroup();
(0, core_1.info)(`Artifact ${uploadResponse.id} has been successfully uploaded!`);
(0, core_1.endGroup)();
if (github_1.context.eventName !== "pull_request")
return;
let artifactId = null;
core.startGroup(`Searching artifact "${baseReport}" on repository "${repository}", on branch "${baseBranch}"`);
(0, core_1.startGroup)(`Searching artifact "${baseReport}" on repository "${repository}", on branch "${baseBranch}"`);
// cannot use artifactClient because downloads are limited to uploads in the same workflow run
// cf. https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts#downloading-or-deleting-artifacts
// Note that the artifacts are returned in most recent first order.
Expand All @@ -418,12 +418,12 @@ async function _run() {
}
artifactId = artifact.id;
refCommitHash = artifact.workflow_run?.head_sha;
core.info(`Found artifact named "${baseReport}" with ID "${artifactId}" from commit "${refCommitHash}"`);
(0, core_1.info)(`Found artifact named "${baseReport}" with ID "${artifactId}" from commit "${refCommitHash}"`);
break;
}
core.endGroup();
(0, core_1.endGroup)();
if (artifactId) {
core.startGroup(`Downloading artifact "${baseReport}" of repository "${repository}" with ID "${artifactId}"`);
(0, core_1.startGroup)(`Downloading artifact "${baseReport}" of repository "${repository}" with ID "${artifactId}"`);
const res = await octokit.rest.actions.downloadArtifact({
owner,
repo,
Expand All @@ -433,30 +433,30 @@ async function _run() {
// @ts-ignore data is unknown
const zip = new adm_zip_1.default(Buffer.from(res.data));
for (const entry of zip.getEntries()) {
core.info(`Loading storage layout report from "${entry.entryName}"`);
(0, core_1.info)(`Loading storage layout report from "${entry.entryName}"`);
srcContent = zip.readAsText(entry);
}
core.endGroup();
(0, core_1.endGroup)();
}
else
throw Error(`No workflow run found with an artifact named "${baseReport}"`);
core.info(`Mapping reference storage layout report`);
(0, core_1.info)(`Mapping reference storage layout report`);
const srcLayout = (0, input_1.parseLayout)(srcContent);
core.endGroup();
core.startGroup("Check storage layout");
(0, core_1.endGroup)();
(0, core_1.startGroup)("Check storage layout");
const diffs = await (0, check_1.checkLayouts)(srcLayout, cmpLayout, {
address,
provider,
checkRemovals: failOnRemoval,
});
if (diffs.length > 0) {
core.info(`Parse source code`);
(0, core_1.info)(`Parse source code`);
const cmpDef = (0, input_1.parseSource)(contractAbs);
const formattedDiffs = diffs.map((diff) => {
const formattedDiff = (0, format_1.formatDiff)(cmpDef, diff);
const title = format_1.diffTitles[formattedDiff.type];
const level = format_1.diffLevels[formattedDiff.type] || "error";
core[level](formattedDiff.message, {
(level === "error" ? core_1.error : core_1.warning)(formattedDiff.message, {
title,
file: cmpDef.path,
startLine: formattedDiff.loc.start.line,
Expand All @@ -472,16 +472,16 @@ async function _run() {
.length > 0))
throw Error("Unsafe storage layout changes detected. Please see above for details.");
}
core.endGroup();
(0, core_1.endGroup)();
}
async function run() {
try {
await _run();
}
catch (error) {
core.setFailed(error);
(0, core_1.setFailed)(error);
if (error.stack)
core.debug(error.stack);
(0, core_1.debug)(error.stack);
}
finally {
process.exit();
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Binary file removed dist/prebuilds/linux-x64/node.napi.glibc.node
Binary file not shown.
Loading

0 comments on commit 52a813b

Please sign in to comment.