Skip to content

Commit b126460

Browse files
committed
docs(version): set 3.1 as the recommended version
1 parent f801fc3 commit b126460

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

.github/workflows/foundry-storage-check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jobs:
2525
version: nightly
2626

2727
- name: Check storage layout
28-
uses: Rubilmax/foundry-storage-check@v3.0.2
28+
uses: Rubilmax/foundry-storage-check@v3.1
2929
with:
3030
contract: contracts/Example.sol:Example

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
version: nightly
5252

5353
- name: Check storage layout
54-
uses: Rubilmax/[email protected].0
54+
uses: Rubilmax/[email protected]
5555
with:
5656
contract: src/Contract.sol:Contract
5757
# settings below are optional, but allows to check whether the added storage slots are empty on the deployed contract

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ async function run() {
140140

141141
if (diffs.length > 0) {
142142
core.info(`Parse source code`);
143-
const cmpDef = parseSource(contract);
143+
const cmpDef = parseSource(contract, workingDirectory);
144144

145145
const formattedDiffs = diffs.map((diff) => {
146146
const formattedDiff = formatDiff(cmpDef, diff);

src/input.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { execSync } from "child_process";
22
import fs from "fs";
3+
import { join } from "path";
34

45
import * as parser from "@solidity-parser/parser";
56
import { ContractDefinition } from "@solidity-parser/parser/src/ast-types";
@@ -49,8 +50,9 @@ export const parseLayout = (content: string): StorageLayoutReportExact => {
4950
}
5051
};
5152

52-
export const parseSource = (contract: string): ParsedSource => {
53-
const [path, contractName] = contract.split(":");
53+
export const parseSource = (contract: string, cwd = ""): ParsedSource => {
54+
const [relPath, contractName] = contract.split(":");
55+
const path = join(cwd, relPath);
5456

5557
const { children, tokens = [] } = parser.parse(fs.readFileSync(path, { encoding: "utf-8" }), {
5658
tolerant: true,

tests/input.test.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { expect } from "@jest/globals";
2+
3+
import { createLayout, parseLayout, parseSource } from "../src/input";
4+
5+
describe("Input checks", () => {
6+
it("should execute createLayout from a custom working directory", async () => {
7+
const layout = parseLayout(createLayout("StorageRef.sol:Storage", "tests/mocks/basic"));
8+
9+
expect(Object.keys(layout.storage)).toHaveLength(8);
10+
expect(Object.keys(layout.types)).toHaveLength(9);
11+
});
12+
13+
it("should execute parseLayout from a custom working directory", async () => {
14+
const source = parseSource("StorageRef.sol:Storage", "tests/mocks/basic");
15+
16+
expect(source.def.name).toBe("Storage");
17+
expect(source.def.baseContracts).toHaveLength(0);
18+
expect(source.def.kind).toBe("contract");
19+
expect(source.def.type).toBe("ContractDefinition");
20+
expect(source.path).toBe("tests/mocks/basic/StorageRef.sol");
21+
});
22+
});

0 commit comments

Comments
 (0)