Skip to content

Add Deployments to Solidity#16

Closed
jtriley2p wants to merge 5 commits into
Uniswap:mainfrom
jtriley2p:jtriley2p/add-solc-const
Closed

Add Deployments to Solidity#16
jtriley2p wants to merge 5 commits into
Uniswap:mainfrom
jtriley2p:jtriley2p/add-solc-const

Conversation

@jtriley2p

Copy link
Copy Markdown

What

Adds a script sync_deployments.py (no external dependencies) which parses the deployments/*.json files and writes respective solidity libraries to src/depoyments/*.sol.

Each file contains a library named after the network with constants declared internally to be accessed in cleaner, namespaced way.

Why

This is useful for governance scripting where currently address constants are duplicated in each script which opens us up to errors.

Governance Script Example

Current way:

contract ProposalM {
    address constant MAINNET_TOKEN_JAR = address(/*...*/);
    address constant ARB_TOKEN_JAR = address(/*...*/);

    function run() public {
        // accessible as:
        //
        // MAINNET_TOKEN_JAR
        // ARB_TOKEN_JAR
    }
}

contract ProposalN {
    address constant MAINNET_TOKEN_JAR = address(/*...*/);
    address constant ARB_TOKEN_JAR = address(/*...*/);

    function run() public {
        // accessible as:
        //
        // MAINNET_TOKEN_JAR
        // ARB_TOKEN_JAR
    }
}

Briefcase Deployment way:

import {Ethereum, Arbitrum} from "briefcase/deployments/Latest.sol";


contract ProposalM {
    function run() public {
        // accessible as:
        //
        // Ethereum.TokenJar
        // Arbitrum.TokenJar
    }
}

contract ProposalN {
    function run() public {
        // accessible as:
        //
        // Ethereum.TokenJar
        // Arbitrum.TokenJar
    }
}

@jtriley2p

Copy link
Copy Markdown
Author

Also, for development and testing purposes, if any contract is hard-coding their address constants, they can use these directly.

import {IPoolManager} from "briefcase/protocols/v4-core/interfaces/IPoolManager.sol";
import {Ethereum} from "briefcase/deployments/Latest.sol";

contract PoolCaller {
    IPoolManager pool = IPoolManager(Ethereum.PoolManager);

    function run() public {
        pool.unlock();
    }

    // ..
}

@jtriley2p

Copy link
Copy Markdown
Author

closing to potentially add to contracts repo scripts

@jtriley2p jtriley2p closed this May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant