Skip to content

Commit

Permalink
AxelarMessageSent
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjimmutable committed Nov 6, 2023
1 parent b68158f commit 7da7c83
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/child/ChildAxelarBridgeAdaptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ contract ChildAxelarBridgeAdaptor is
);

gateway.callContract(_rootChain, _rootBridgeAdaptor, payload);
emit AxelarMessage(_rootChain, _rootBridgeAdaptor, payload);
emit AxelarMessageSent(_rootChain, _rootBridgeAdaptor, payload);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/child/IChildAxelarBridgeAdaptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface IChildAxelarBridgeAdaptorErrors {

interface IChildAxelarBridgeAdaptorEvents {
/// @notice Emitted when an Axelar message is sent to the root chain.
event AxelarMessage(string indexed rootChain, string indexed rootBridgeAdaptor, bytes indexed payload);
event AxelarMessageSent(string indexed rootChain, string indexed rootBridgeAdaptor, bytes indexed payload);
/// @notice Emitted when an Axelar message is received from the root chain.
event AdaptorExecute(string sourceChain, string sourceAddress_, bytes payload_);
}
2 changes: 1 addition & 1 deletion src/interfaces/root/IRootAxelarBridgeAdaptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface IRootAxelarBridgeAdaptorErrors {

interface IRootAxelarBridgeAdaptorEvents {
/// @notice Emitted when an Axelar message is sent to the child chain.
event AxelarMessage(string indexed childChain, string indexed childBridgeAdaptor, bytes indexed payload);
event AxelarMessageSent(string indexed childChain, string indexed childBridgeAdaptor, bytes indexed payload);
/// @notice Emitted when an Axelar message is received from the child chain.
event AdaptorExecute(string sourceChain, string sourceAddress_, bytes payload_);
}
2 changes: 1 addition & 1 deletion src/root/RootAxelarBridgeAdaptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ contract RootAxelarBridgeAdaptor is
);

gateway.callContract(_childChain, _childBridgeAdaptor, payload);
emit AxelarMessage(_childChain, _childBridgeAdaptor, payload);
emit AxelarMessageSent(_childChain, _childBridgeAdaptor, payload);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ contract ChildERC20BridgeWithdrawIntegrationTest is
childBridge.withdraw{value: withdrawFee}(childToken, withdrawAmount);
}

function test_withdraw_emits_AxelarMessageEvent() public {
function test_withdraw_emits_AxelarMessageSentEvent() public {
ChildERC20 childToken = ChildERC20(childBridge.rootTokenToChildToken(rootToken));

bytes memory predictedPayload =
abi.encode(WITHDRAW_SIG, rootToken, address(this), address(this), withdrawAmount);

vm.expectEmit(address(axelarAdaptor));
emit AxelarMessage(childBridge.rootChain(), childBridge.rootERC20BridgeAdaptor(), predictedPayload);
emit AxelarMessageSent(childBridge.rootChain(), childBridge.rootERC20BridgeAdaptor(), predictedPayload);
childBridge.withdraw{value: withdrawFee}(childToken, withdrawAmount);
}

Expand Down
12 changes: 6 additions & 6 deletions test/integration/root/RootERC20Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx

bytes memory payload = abi.encode(MAP_TOKEN_SIG, address(token), token.name(), token.symbol(), token.decimals());
vm.expectEmit(true, true, true, false, address(axelarAdaptor));
emit AxelarMessage(CHILD_CHAIN_NAME, Strings.toHexString(CHILD_BRIDGE_ADAPTOR), payload);
emit AxelarMessageSent(CHILD_CHAIN_NAME, Strings.toHexString(CHILD_BRIDGE_ADAPTOR), payload);

vm.expectEmit(true, true, false, false, address(rootBridge));
emit L1TokenMapped(address(token), childToken);
Expand Down Expand Up @@ -113,7 +113,7 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx
console2.logBytes(predictedPayload);

vm.expectEmit(address(axelarAdaptor));
emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
emit AxelarMessageSent(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
vm.expectEmit(address(rootBridge));
emit NativeEthDeposit(
address(NATIVE_ETH), rootBridge.childETHToken(), address(this), address(this), tokenAmount
Expand Down Expand Up @@ -169,7 +169,7 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx
setupDeposit(IMX_TOKEN_ADDRESS, rootBridge, mapTokenFee, depositFee, tokenAmount, false);

vm.expectEmit(address(axelarAdaptor));
emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
emit AxelarMessageSent(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
vm.expectEmit(address(rootBridge));
emit IMXDeposit(address(IMX_TOKEN_ADDRESS), address(this), address(this), tokenAmount);

Expand Down Expand Up @@ -226,7 +226,7 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx
setupDeposit(WRAPPED_ETH, rootBridge, mapTokenFee, depositFee, tokenAmount, false);

vm.expectEmit(address(axelarAdaptor));
emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
emit AxelarMessageSent(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
vm.expectEmit(address(rootBridge));
emit WETHDeposit(address(WRAPPED_ETH), rootBridge.childETHToken(), address(this), address(this), tokenAmount);
vm.expectCall(
Expand Down Expand Up @@ -284,7 +284,7 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx
setupDeposit(address(token), rootBridge, mapTokenFee, depositFee, tokenAmount, true);

vm.expectEmit(address(axelarAdaptor));
emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
emit AxelarMessageSent(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
vm.expectEmit(address(rootBridge));
emit ChildChainERC20Deposit(address(token), childToken, address(this), address(this), tokenAmount);

Expand Down Expand Up @@ -340,7 +340,7 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx
setupDepositTo(address(token), rootBridge, mapTokenFee, depositFee, tokenAmount, recipient, true);

vm.expectEmit(address(axelarAdaptor));
emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
emit AxelarMessageSent(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
vm.expectEmit(address(rootBridge));
emit ChildChainERC20Deposit(address(token), childToken, address(this), recipient, tokenAmount);

Expand Down
4 changes: 2 additions & 2 deletions test/unit/child/ChildAxelarBridgeAdaptor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro
axelarAdaptor.sendMessage{value: callValue}(payload, address(123));
}

function test_sendMessage_EmitsAxelarMessageEvent() public {
function test_sendMessage_EmitsAxelarMessageSentEvent() public {
bytes memory payload = abi.encode(WITHDRAW_SIG, address(token), address(this), address(999), 11111);
uint256 callValue = 300;

vm.expectEmit();
emit AxelarMessage(ROOT_CHAIN_NAME, mockChildERC20Bridge.rootERC20BridgeAdaptor(), payload);
emit AxelarMessageSent(ROOT_CHAIN_NAME, mockChildERC20Bridge.rootERC20BridgeAdaptor(), payload);

vm.deal(address(mockChildERC20Bridge), callValue);
vm.prank(address(mockChildERC20Bridge));
Expand Down
4 changes: 2 additions & 2 deletions test/unit/root/RootAxelarBridgeAdaptor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR
axelarAdaptor.sendMessage{value: callValue}(payload, address(123));
}

function test_sendMessage_EmitsAxelarMessageEvent() public {
function test_sendMessage_EmitsAxelarMessageSentEvent() public {
bytes memory payload = abi.encode(MAP_TOKEN_SIG, address(token), token.name(), token.symbol(), token.decimals());
uint256 callValue = 300;

vm.expectEmit(true, true, true, false, address(axelarAdaptor));
emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptor, payload);
emit AxelarMessageSent(CHILD_CHAIN_NAME, childBridgeAdaptor, payload);
vm.prank(address(stubRootBridge));
axelarAdaptor.sendMessage{value: callValue}(payload, address(123));
}
Expand Down

0 comments on commit 7da7c83

Please sign in to comment.