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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ report/
lcov.info*

broadcast/
.DS_Store
5 changes: 4 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ optimizer = true
optimizer_runs = 200

# The test suite reads its chain id / CCIP selector table from JSON. Read-only,
# and scoped to that one directory.
# and scoped to that one directory. `./artifacts` is writable so `CreateRepo`
# can drop its per-deployment envelope (`artifacts-<network>-<timestamp>.json`)
# for later ingestion into artifacts-hub.
fs_permissions = [
{ access = "read", path = "./test/fixtures" },
{ access = "write", path = "./artifacts" },
]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
Expand Down
2 changes: 1 addition & 1 deletion lib/just-foundry
78 changes: 78 additions & 0 deletions script/CreateRepo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import { CrossChainController } from "@src/CrossChainController.sol";
/// @title CreateRepo
/// @notice Deploys `CrossChainControllerSetup` inside PluginRepoFactory
contract CreateRepo is Script {
/// @dev Slug this plugin is registered under in artifacts-hub
/// (`plugins.<slug>` in `addresses/<chainId>.json`). Must match the
/// catalog entry in
/// `artifacts-hub/scripts/lib/plugin-catalog.ts`.
string internal constant PLUGIN_SLUG = "crosschain";

/// @dev Pinned metadata for the initial build; update whenever a new
/// metadata JSON is re-pinned. Sources live in
/// `src/{release,build}-metadata.json`; pin them with `just ipfs-pin`.
Expand Down Expand Up @@ -86,5 +92,77 @@ contract CreateRepo is Script {
console.log(
"- ENS subdomain: ", bytes(pluginEnsSubdomain).length == 0 ? "(none)" : pluginEnsSubdomain
);

// Emit the artifacts-hub envelope for later ingestion. Skipped in
// simulations (no NETWORK_NAME wired in and no artifact to keep).
if (!vm.envOr("SIMULATION", false)) {
writeArtifact();
}
}

/// @notice Writes `artifacts/artifacts-<network>-<timestamp>.json` in the
/// shape defined by `PluginArtifact` in
/// `artifacts-hub/scripts/schema.ts`. The `plugin` subtree matches
/// the AddressBook `Plugin` schema verbatim, so an artifacts-hub
/// ingest step can merge it into `addresses/<chainId>.json` under
/// `plugins.<slug>` without any per-plugin adapter code.
function writeArtifact() internal {
string memory networkName = vm.envString("NETWORK_NAME");
string memory timestampStr = vm.toString(block.timestamp);
address implementation = IPluginSetup(pluginSetup).implementation();

// Skip the `ens` field entirely when the repo was deployed without an
// ENS subdomain, matching the schema's `optional` treatment.
string memory ensLine = bytes(pluginEnsSubdomain).length == 0
? ""
: string.concat(" \"ens\": \"", pluginEnsSubdomain, ".plugin.dao.eth\",\n");

string memory header = string.concat(
"{\n",
" \"chainId\": ",
vm.toString(block.chainid),
",\n",
" \"network\": \"",
networkName,
"\",\n",
" \"timestamp\": ",
timestampStr,
",\n",
" \"slug\": \"",
PLUGIN_SLUG,
"\",\n"
);
string memory pluginBody = string.concat(
" \"plugin\": {\n",
" \"repo\": \"",
vm.toString(address(myPluginRepo)),
"\",\n",
ensLine,
" \"maintainer\": \"",
vm.toString(managementDao),
"\",\n"
);
string memory versionsBlock = string.concat(
" \"versions\": [\n",
" {\n",
" \"release\": 1,\n",
" \"build\": 1,\n",
" \"setup\": \"",
vm.toString(pluginSetup),
"\",\n",
" \"implementation\": \"",
vm.toString(implementation),
"\",\n",
" \"current\": true\n",
" }\n",
" ]\n",
" }\n",
"}\n"
);

string memory outPath =
string.concat(vm.projectRoot(), "/artifacts/artifacts-", networkName, "-", timestampStr, ".json");
vm.writeFile(outPath, string.concat(header, pluginBody, versionsBlock));
console.log("Artifact written to", outPath);
}
}