Skip to content

Commit

Permalink
Optimize reading domainID
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlinaric committed Dec 4, 2023
1 parent ba3fec0 commit 3f7f8e9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/contracts/Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ contract Router is Context {

IBridge public immutable _bridge;
IAccessControlSegregator public _accessControl;
uint8 public immutable _domainID;

// destinationDomainID => number of deposits
mapping(uint8 => uint64) public _depositCounts;
Expand Down Expand Up @@ -57,6 +58,7 @@ contract Router is Context {
constructor(address bridge, address accessControl) {
_bridge = IBridge(bridge);
_accessControl = IAccessControlSegregator(accessControl);
_domainID = IBridge(_bridge)._domainID();
}

/**
Expand Down Expand Up @@ -90,8 +92,7 @@ contract Router is Context {
bytes calldata depositData,
bytes calldata feeData
) external payable whenBridgeNotPaused returns (uint64 depositNonce, bytes memory handlerResponse) {
uint8 domainID = IBridge(_bridge)._domainID();
if (destinationDomainID == domainID) revert DepositToCurrentDomain();
if (destinationDomainID == _domainID) revert DepositToCurrentDomain();

address sender = _msgSender();
IFeeHandler feeHandler = _bridge._feeHandler();
Expand All @@ -101,7 +102,7 @@ contract Router is Context {
// Reverts on failure
feeHandler.collectFee{value: msg.value}(
sender,
domainID,
_domainID,
destinationDomainID,
resourceID,
depositData,
Expand Down

0 comments on commit 3f7f8e9

Please sign in to comment.