Skip to content
Closed
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
36 changes: 27 additions & 9 deletions dincli/cli/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,20 +872,28 @@ def din_info(ctx: typer.Context,
def import_deployments(ctx: typer.Context,
file: Optional[Path] = typer.Option(
None, "--file", "-f",
help="Deployments JSON written by deploy-platform.ts (default: hardhat/deployments/<network>.json under the current directory, with dincli network 'local' mapped to hardhat's 'localhost')",
help="Explicit deployments JSON path. Mutually exclusive with --foundry.",
),
foundry: bool = typer.Option(
False, "--foundry",
help="Load from foundry/deployments/<network>.json (dincli 'local' maps to 'localhost'). Mutually exclusive with --file.",
),
):
"""
Import platform proxy addresses from a hardhat deployments file into din_info.json.
Import platform proxy addresses from a deployments JSON into din_info.json.

Deploy the platform first with the canonical proxy-aware script:
Hardhat flow (default):

cd hardhat && npx hardhat run scripts/deploy-platform.ts --network localhost
dincli system import-deployments

Foundry flow:

then run this command to point dincli at the deployed proxies:
forge script foundry/script/DeployPlatform.s.sol --rpc-url http://127.0.0.1:8545 --broadcast ...
dincli system import-deployments --foundry

dincli system import-deployments # default file location
dincli system import-deployments --file hardhat/deployments/localhost.json
Both flows write the same address schema; this command reads either.
Pass --file to supply an explicit path (mutually exclusive with --foundry).

Only the platform address keys of the active network's din_info entry are
updated (coordinator, token, stake, registry, proxy_admin); everything
Expand All @@ -894,14 +902,24 @@ def import_deployments(ctx: typer.Context,
console = ctx.obj.console
effective_network = ctx.obj.network

if file is not None and foundry:
console.print("[red]❌ --file and --foundry are mutually exclusive.[/red]")
raise typer.Exit(1)

if file is None:
hardhat_network = _HARDHAT_NETWORK_FOR.get(effective_network, effective_network)
file = Path("hardhat") / "deployments" / f"{hardhat_network}.json"
network_key = _HARDHAT_NETWORK_FOR.get(effective_network, effective_network)
if foundry:
file = Path("foundry") / "deployments" / f"{network_key}.json"
else:
file = Path("hardhat") / "deployments" / f"{network_key}.json"

file = file.expanduser()
if not file.exists():
console.print(f"[red]❌ Deployments file not found: {file}[/red]")
console.print("[yellow]Run the platform deploy script first:[/yellow] cd hardhat && npx hardhat run scripts/deploy-platform.ts --network <net>")
if foundry:
console.print("[yellow]Run the Foundry deploy script first:[/yellow] forge script foundry/script/DeployPlatform.s.sol --rpc-url http://127.0.0.1:8545 --broadcast ...")
else:
console.print("[yellow]Run the platform deploy script first:[/yellow] cd hardhat && npx hardhat run scripts/deploy-platform.ts --network <net>")
raise typer.Exit(1)

try:
Expand Down
5 changes: 5 additions & 0 deletions foundry/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ out/
# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/*/1337/
/broadcast/**/dry-run/

# Local deployment artifacts (generated by forge script DeployPlatform.s.sol)
deployments/localhost.json

# Docs
docs/

Expand All @@ -17,3 +21,4 @@ docs/
lib/*
node_modules/*
script/*
!script/*.sol
4 changes: 4 additions & 0 deletions foundry/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ ffi = true
ast = true
build_info = true
extra_output = ["storageLayout"]
fs_permissions = [
{access = "read", path = "out/"},
{access = "read-write", path = "deployments/"}
]

# The "Magic" fix for Stack too Deep
via_ir = true
Expand Down
Loading