Skip to content
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
5 changes: 0 additions & 5 deletions .changeset/compose-selectors.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/inspect-unknown-signatures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@perfect-abstractions/compose-cli": patch
---

Mark selectors with unknown signatures in `compose inspect` output.
8 changes: 1 addition & 7 deletions cli/src/comander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ export function buildProgram(): Command {
.argument("<address>", "Diamond contract address")
.option("--chain <chain-key>", "Chain key from compose.json", "local")

program
.command("selectors")
.description("List a deployed diamond's selectors by facet")
.argument("<address>", "Diamond contract address")
.option("--chain <chain-key>", "Chain key from compose.json", "local")

return program;
}

Expand Down Expand Up @@ -100,7 +94,7 @@ export function parseArgs(argv: string[]): { command: string; flags: Record<stri
(arg): arg is string => typeof arg === "string" && arg !== command,
);
if (positionalArgs.length > 0) {
if ((command === "inspect" || command === "selectors") && !flags.address) {
if (command === "inspect" && !flags.address) {
flags.address = positionalArgs[0];
} else if (!flags.projectName) {
flags.projectName = positionalArgs[0];
Expand Down
6 changes: 4 additions & 2 deletions cli/src/modules/inspect/output.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cyan, dim, green } from "../../utils/terminal";
import { cyan, dim, green, yellow } from "../../utils/terminal";
import type { InspectResult } from "./types";

const TREE_BRANCH = "├── ";
Expand Down Expand Up @@ -35,7 +35,9 @@ export function showInspect(result: InspectResult): void {
const isLastSelector = j === facet.selectors.length - 1;
const selectorBranch = isLastSelector ? TREE_LAST : TREE_BRANCH;

console.log(` ${dim(childPrefix + selectorBranch)}${dim(sel.selector)} ${green(sel.signature)}`);
const unknown = sel.signature.toLowerCase() === sel.selector.toLowerCase();
const signature = unknown ? yellow("Unknown signature") : green(sel.signature);
console.log(` ${dim(childPrefix + selectorBranch)}${dim(sel.selector)} ${signature}`);
}

if (!isLast) {
Expand Down
8 changes: 0 additions & 8 deletions cli/src/modules/pipelineBuilder/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { CatalogPipeline } from "../../pipelines/catalogPipeline";
import { BuildPipeline } from "../../pipelines/buildPipeline";
import { RPCPipeline } from "../../pipelines/rpcPipeline";
import { InspectPipeline } from "../../pipelines/inspectPipeline";
import { SelectorsPipeline } from "../../pipelines/selectorsPipeline";
import { ValidatePipeline } from "../../pipelines/validatePipeline";

/**
Expand Down Expand Up @@ -77,13 +76,6 @@ export const PipelineBuilderModule = {
error: null,
};
return InspectPipeline.execute(ctx);
case "selectors":
ctx.state.commandSelected = {
success: true,
result: { command: ctx.param.command, address: ctx.param.address, chain: ctx.param.chain },
error: null,
};
return SelectorsPipeline.execute(ctx);
default:
ctx.state.commandRouting = {
success: false,
Expand Down
15 changes: 0 additions & 15 deletions cli/src/modules/selectors/module.ts

This file was deleted.

23 changes: 0 additions & 23 deletions cli/src/modules/selectors/output.ts

This file was deleted.

22 changes: 0 additions & 22 deletions cli/src/pipelines/selectorsPipeline.ts

This file was deleted.

25 changes: 7 additions & 18 deletions cli/test/comander.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { parseArgs } from "../src/comander";
import { buildProgram, parseArgs } from "../src/comander";

describe("validate command arguments", () => {
it("accepts a Compose project root", () => {
Expand Down Expand Up @@ -68,6 +68,12 @@ describe("rpc command", () => {
});

describe("inspect command", () => {
it("is the only facet and selector listing command", () => {
const commands = buildProgram().commands.map((command) => command.name());
expect(commands).toContain("inspect");
expect(commands).not.toContain("selectors");
});

it("parses address positional and chain flag", () => {
const result = parseArgs([
"node",
Expand Down Expand Up @@ -103,21 +109,4 @@ describe("inspect command", () => {
},
});
});

});

describe("selectors command", () => {
it("parses address and chain", () => {
expect(parseArgs(["node", "compose", "selectors", "0x0000000000000000000000000000000000000001", "--chain", "sepolia"])).toEqual({
command: "selectors",
flags: { address: "0x0000000000000000000000000000000000000001", chain: "sepolia" },
});
});

it("defaults to local", () => {
expect(parseArgs(["node", "compose", "selectors", "0x0000000000000000000000000000000000000001"])).toEqual({
command: "selectors",
flags: { address: "0x0000000000000000000000000000000000000001", chain: "local" },
});
});
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { describe, expect, it, vi } from "vitest";
import { showSelectors } from "../../../src/modules/selectors/output";
import { showInspect } from "../../../src/modules/inspect/output";

describe("showSelectors", () => {
it("groups signatures by facet and marks unknown selectors", () => {
describe("showInspect", () => {
it("shows known signatures and marks unknown selectors", () => {
const log = vi.spyOn(console, "log").mockImplementation(() => {});
try {
showSelectors({
showInspect({
diamond: "0x0000000000000000000000000000000000000001",
chainKey: "local",
chainId: 31337,
Expand All @@ -18,10 +18,13 @@ describe("showSelectors", () => {
],
}],
});

const output = log.mock.calls.map(([line]) => line).join("\n");
expect(output).toContain("1 facets");
expect(output).toContain("2 selectors");
expect(output).toContain("facets()");
expect(output).toContain("Unknown signature");
expect(output).toContain("0xdeadbeef");
expect(output).toContain("Unknown signature");
} finally {
log.mockRestore();
}
Expand Down
16 changes: 0 additions & 16 deletions cli/test/modules/pipelineBuilder/pipelineBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { describe, expect, it, vi } from "vitest";
import { Context } from "../../../src/context/context";
import { PipelineBuilderModule } from "../../../src/modules/pipelineBuilder/module";
import { ValidatePipeline } from "../../../src/pipelines/validatePipeline";
import { SelectorsPipeline } from "../../../src/pipelines/selectorsPipeline";

describe("PipelineBuilderModule", () => {
it("routes the validate command to ValidatePipeline", async () => {
Expand All @@ -20,19 +19,4 @@ describe("PipelineBuilderModule", () => {
execute.mockRestore();
}
});

it("routes the selectors command to SelectorsPipeline", async () => {
const ctx = Context.create();
ctx.param = { command: "selectors", address: "0x0000000000000000000000000000000000000001", chain: "local" };
const execute = vi.spyOn(SelectorsPipeline, "execute").mockResolvedValue(ctx);

try {
const result = await PipelineBuilderModule.route(ctx);
expect(result).toBe(ctx);
expect(execute).toHaveBeenCalledWith(ctx);
expect(ctx.state.commandSelected).toMatchObject({ success: true, result: ctx.param });
} finally {
execute.mockRestore();
}
});
});
66 changes: 0 additions & 66 deletions cli/test/pipelines/selectorsPipeline/selectorsPipeline.test.ts

This file was deleted.

Loading