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
10 changes: 7 additions & 3 deletions src/StdChains.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ abstract contract StdChains {

bool private fallbackToDefaultRpcUrls = true;

// The RPC URL will be fetched from config or defaultRpcUrls if possible.
/// @notice Returns chain data for the given alias, with the RPC URL resolved from config or defaults.
/// @dev Reverts if `chainAlias` is empty or has not been registered.
function getChain(string memory chainAlias) internal virtual returns (Chain memory chain) {
require(bytes(chainAlias).length != 0, "StdChains getChain(string): Chain alias cannot be the empty string.");

Expand All @@ -79,6 +80,8 @@ abstract contract StdChains {
chain = getChainWithUpdatedRpcUrl(chainAlias, chain);
}

/// @notice Returns chain data for the given chain ID, with the RPC URL resolved from config or defaults.
/// @dev Reverts if `chainId` is `0` or has not been registered.
function getChain(uint256 chainId) internal virtual returns (Chain memory chain) {
require(chainId != 0, "StdChains getChain(uint256): Chain ID cannot be 0.");
initializeStdChains();
Expand All @@ -94,7 +97,7 @@ abstract contract StdChains {
chain = getChainWithUpdatedRpcUrl(chainAlias, chain);
}

// set chain info, with priority to argument's rpcUrl field.
/// @notice Registers chain data under `chainAlias`, with priority given to the argument's `rpcUrl` field.
function setChain(string memory chainAlias, ChainData memory chain) internal virtual {
require(
bytes(chainAlias).length != 0,
Expand Down Expand Up @@ -127,7 +130,7 @@ abstract contract StdChains {
idToAlias[chain.chainId] = chainAlias;
}

// set chain info, with priority to argument's rpcUrl field.
/// @notice Registers chain data under `chainAlias`, with priority given to the argument's `rpcUrl` field.
function setChain(string memory chainAlias, Chain memory chain) internal virtual {
setChain(chainAlias, ChainData({name: chain.name, chainId: chain.chainId, rpcUrl: chain.rpcUrl}));
}
Expand Down Expand Up @@ -184,6 +187,7 @@ abstract contract StdChains {
return chain;
}

/// @notice Sets whether to fall back to default RPC URLs when no URL is configured for a chain.
function setFallbackToDefaultRpcUrls(bool useDefault) internal {
fallbackToDefaultRpcUrls = useDefault;
}
Expand Down
Loading