Skip to content

Commit

Permalink
Remove other adaptor stored in adaptor
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjimmutable committed Nov 1, 2023
1 parent 8ad3194 commit ef30f6c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 29 deletions.
1 change: 0 additions & 1 deletion script/DeployChildContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ contract DeployChildContracts is Script {
function run() public {
uint256 deployerPrivateKey = vm.envUint("CHILD_PRIVATE_KEY");
address childGateway = vm.envAddress("CHILD_GATEWAY_ADDRESS");
address childGasService = vm.envAddress("CHILD_GAS_SERVICE_ADDRESS"); // Not yet used.
string memory childRpcUrl = vm.envString("CHILD_RPC_URL");

vm.createSelectFork(childRpcUrl);
Expand Down
13 changes: 0 additions & 13 deletions src/child/ChildAxelarBridgeAdaptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,19 @@ import {IChildAxelarBridgeAdaptorErrors} from "../interfaces/child/IChildAxelarB
contract ChildAxelarBridgeAdaptor is AxelarExecutable, Initializable, IChildAxelarBridgeAdaptorErrors {
/// @notice Address of bridge to relay messages to.
IChildERC20Bridge public childBridge;
string public rootBridgeAdaptor;

constructor(address _gateway) AxelarExecutable(_gateway) {}

/**
* @notice Initializes the contract.
* @param _childBridge Address of the child bridge contract.
* @dev Always sets the rootBridgeAdaptor to whatever the rootERC20BridgeAdaptor of the bridge contract is.
*/
function initialize(address _childBridge) external initializer {
if (_childBridge == address(0)) {
revert ZeroAddress();
}

childBridge = IChildERC20Bridge(_childBridge);
rootBridgeAdaptor = childBridge.rootERC20BridgeAdaptor();
}

// TODO tests for this
// TODO does this need to be permissioned?
/**
* @notice Sets the root bridge adaptor address.
* @dev Always sets it to whatever the rootERC20BridgeAdaptor of the bridge contract is.
*/
function setRootBridgeAdaptor() external {
rootBridgeAdaptor = childBridge.rootERC20BridgeAdaptor();
}

/**
Expand Down
19 changes: 6 additions & 13 deletions src/root/RootAxelarBridgeAdaptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {IRootERC20Bridge} from "../interfaces/root/IRootERC20Bridge.sol";

/**
* @notice RootAxelarBridgeAdaptor is a bridge adaptor that allows the RootERC20Bridge to communicate with the Axelar Gateway.
* @dev This is not an upgradeable contract, because it is trivial to deploy a new one if needed.
*/
contract RootAxelarBridgeAdaptor is
Initializable,
Expand All @@ -29,7 +28,6 @@ contract RootAxelarBridgeAdaptor is
using SafeERC20 for IERC20Metadata;

address public rootBridge;
string public childBridgeAdaptor;
/// @dev childChain could be immutable, but as of writing this Solidity does not support immutable strings.
/// see: https://ethereum.stackexchange.com/questions/127622/typeerror-immutable-variables-cannot-have-a-non-value-type
string public childChain;
Expand All @@ -38,7 +36,11 @@ contract RootAxelarBridgeAdaptor is
mapping(uint256 => string) public chainIdToChainName;

/**
* @dev Always sets it to whatever the childBridgeAdaptor of the bridge contract is.
* @notice Initilization function for RootAxelarBridgeAdaptor.
* @param _rootBridge Address of root bridge contract.
* @param _childChain Name of child chain.
* @param _axelarGateway Address of Axelar Gateway contract.
* @param _gasService Address of Axelar Gas Service contract.
*/
function initialize(address _rootBridge, string memory _childChain, address _axelarGateway, address _gasService)
public
Expand All @@ -55,15 +57,6 @@ contract RootAxelarBridgeAdaptor is
childChain = _childChain;
axelarGateway = IAxelarGateway(_axelarGateway);
gasService = IAxelarGasService(_gasService);
childBridgeAdaptor = IRootERC20Bridge(rootBridge).childBridgeAdaptor();
}

/**
* @notice Sets the child bridge adaptor address.
* @dev Always sets it to whatever the childBridgeAdaptor of the bridge contract is.
*/
function setChildBridgeAdaptor() external {
childBridgeAdaptor = IRootERC20Bridge(rootBridge).childBridgeAdaptor();
}

/**
Expand All @@ -79,7 +72,7 @@ contract RootAxelarBridgeAdaptor is
}

// Load from storage.
string memory _childBridgeAdaptor = childBridgeAdaptor;
string memory _childBridgeAdaptor = IRootERC20Bridge(rootBridge).childBridgeAdaptor();
string memory _childChain = childChain;

// TODO For `sender` (first param), should likely be refundRecipient (and in which case refundRecipient should be renamed to sender and used as refund recipient)
Expand Down
2 changes: 0 additions & 2 deletions test/unit/root/RootAxelarBridgeAdaptor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR
axelarAdaptor.initialize(
address(stubRootBridge), CHILD_CHAIN_NAME, address(mockAxelarGateway), address(axelarGasService)
);
axelarAdaptor.setChildBridgeAdaptor();
vm.deal(address(stubRootBridge), 99999999999);
}

function test_Constructor() public {
assertEq(axelarAdaptor.rootBridge(), address(stubRootBridge), "rootBridge not set");
assertEq(axelarAdaptor.childBridgeAdaptor(), childBridgeAdaptor, "childBridgeAdaptor not set");
assertEq(axelarAdaptor.childChain(), CHILD_CHAIN_NAME, "childChain not set");
assertEq(address(axelarAdaptor.axelarGateway()), address(mockAxelarGateway), "axelarGateway not set");
assertEq(address(axelarAdaptor.gasService()), address(axelarGasService), "axelarGasService not set");
Expand Down

0 comments on commit ef30f6c

Please sign in to comment.