ChainAwareness
Inherits: PathFinder
State Variables
activeChain
Name of the active chain, should match the name of the directory in deployments
string public activeChain
chainIdsLoaded
Whether chainIds and chainNames have been loaded
bool private chainIdsLoaded
chainIds
Map from chain name to chainId
mapping(string => uint256) public chainIds
chainNames
Map from chainId to chain name
mapping(uint256 => string) public chainNames
Functions
getFreshDeploymentFN
Returns the path to the FRESH contract deployment JSON for a contract on the active chain. Example: ".deployments/mainnet/SynapseRouter.json"
function getFreshDeploymentFN(string memory contractName) internal view returns (string memory);
getDeploymentFN
Returns the path to the contract deployment JSON for a contract on the active chain. Example: "deployments/mainnet/SynapseRouter.json"
function getDeploymentFN(string memory contractName) internal view returns (string memory);
getChainGenericFN
Returns the path to the generic file on the active chain.
Useful for the files that are not specific to a contract, but are specific to a chain.
function getChainGenericFN(string memory fileName) internal view returns (string memory);
getDeployConfigFN
Returns the path to the contract deployment configuration JSON for a contract on the active chain. Example: "script/configs/mainnet/SynapseRouter.json"
function getDeployConfigFN(string memory contractName) internal view returns (string memory);
getChainId
Returns the chain ID for a given chain by reading the chain ID file in the deployments directory.
Returns 0 or reverts if the chain ID is not found based on the flag.
function getChainId(string memory chain, bool revertIfNotFound) internal returns (uint256);
loadActiveChain
Sets active chain to the one matching block.chainid value. Reverts if the chain is not supported.
function loadActiveChain() internal;
loadChainIds
Reads all chain:chainId pairs from the deployments directory,
and saves them in chainIds and chainNames mappings.
Will do this lazily, only once per the script run.
function loadChainIds() internal;
blockChainId
Wrapper for block.chainid, which only exists in Solidity 0.8+
function blockChainId() internal view returns (uint256 chainId);