From 90851b0c3de7ee2e501ea50067efa91c2c38d378 Mon Sep 17 00:00:00 2001 From: 0xng <87835144+0xng@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:14:54 -0300 Subject: [PATCH] fix: adding return hash and fixing event tenses (#417) * fix: adding return hash and fixing event tenses * fix: msgHash underscore --- specs/interop/predeploys.md | 8 ++++++-- specs/interop/token-bridging.md | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/specs/interop/predeploys.md b/specs/interop/predeploys.md index 7f34224cc..a17b492a6 100644 --- a/specs/interop/predeploys.md +++ b/specs/interop/predeploys.md @@ -860,8 +860,10 @@ which is included as part of the the `ICrosschainERC20` [interface](./token-bridging.md#__crosschainburn) implemented by the `SuperchainERC20` standard. +Returns the `msgHash_` crafted by the `L2ToL2CrossChainMessenger`. + ```solidity -sendERC20(address _tokenAddress, address _to, uint256 _amount, uint256 _chainId) +sendERC20(address _tokenAddress, address _to, uint256 _amount, uint256 _chainId) returns (bytes32 msgHash_) ``` #### `relayERC20` @@ -916,11 +918,13 @@ sequenceDiagram participant L2SBB as SuperchainERC20Bridge (Chain B) participant SuperERC20_B as SuperchainERC20 (Chain B) - from->>L2SBA: sendERC20To(tokenAddr, to, amount, chainID) + from->>L2SBA: sendERC20(tokenAddr, to, amount, chainID) L2SBA->>SuperERC20_A: __crosschainBurn(from, amount) SuperERC20_A-->SuperERC20_A: emit SuperchainBurn(from, amount) L2SBA->>Messenger_A: sendMessage(chainId, message) + Messenger_A->>L2SBA: return msgHash_ L2SBA-->L2SBA: emit SentERC20(tokenAddr, from, to, amount, destination) + L2SBA->>from: return msgHash_ Inbox->>Messenger_B: relayMessage() Messenger_B->>L2SBB: relayERC20(tokenAddr, from, to, amount) L2SBB->>SuperERC20_B: __crosschainMint(to, amount) diff --git a/specs/interop/token-bridging.md b/specs/interop/token-bridging.md index 83f8b2c50..d0372b5f8 100644 --- a/specs/interop/token-bridging.md +++ b/specs/interop/token-bridging.md @@ -107,6 +107,7 @@ The `SuperchainERC20Bridge` includes two functions for bridging: - `sendERC20`: initializes a cross-chain transfer of a `SuperchainERC20` by burning the tokens locally and sending a message to the `SuperchainERC20Bridge` on the target chain using the `L2toL2CrossDomainMessenger`. +Additionaly, it returns the `msgHash_` crafted by the `L2toL2CrossDomainMessenger`. - `relayERC20`: process incoming messages from the `L2toL2CrossDomainMessenger` and mints the corresponding amount of the `SuperchainERC20` @@ -130,11 +131,13 @@ sequenceDiagram participant L2SBB as SuperchainERC20Bridge (Chain B) participant SuperERC20_B as SuperchainERC20 (Chain B) - from->>L2SBA: sendERC20To(tokenAddr, to, amount, chainID) + from->>L2SBA: sendERC20(tokenAddr, to, amount, chainID) L2SBA->>SuperERC20_A: __crosschainBurn(from, amount) SuperERC20_A-->SuperERC20_A: emit CrosschainBurnt(from, amount) L2SBA->>Messenger_A: sendMessage(chainId, message) + Messenger_A->>L2SBA: return msgHash_ L2SBA-->L2SBA: emit SentERC20(tokenAddr, from, to, amount, destination) + L2SBA->>from: return msgHash_ Inbox->>Messenger_B: relayMessage() Messenger_B->>L2SBB: relayERC20(tokenAddr, from, to, amount) L2SBB->>SuperERC20_B: __crosschainMint(to, amount) @@ -147,13 +150,14 @@ sequenceDiagram An example implementation for the `sendERC20` and `relayERC20` functions is provided. ```solidity -function sendERC20(SuperchainERC20 _token, address _to, uint256 _amount, uint256 _chainId) external { +function sendERC20(SuperchainERC20 _token, address _to, uint256 _amount, uint256 _chainId) external returns (bytes32 msgHash_) { _token.__crosschainBurn(msg.sender, _amount); bytes memory _message = abi.encodeCall(this.relayERC20, (_token, msg.sender, _to, _amount)); - L2ToL2CrossDomainMessenger.sendMessage(_chainId, address(this), _message); + + msgHash_ = L2ToL2CrossDomainMessenger.sendMessage(_chainId, address(this), _message); - emit SendERC20(address(_token), msg.sender, _to, _amount, _chainId); + emit SentERC20(address(_token), msg.sender, _to, _amount, _chainId); } function relayERC20(SuperchainERC20 _token, address _from, address _to, uint256 _amount) external { @@ -164,7 +168,7 @@ function relayERC20(SuperchainERC20 _token, address _from, address _to, uint256 _token.__crosschainMint(_to, _amount); - emit RelayERC20(address(_token), _from, _to, _amount, _source); + emit RelayedERC20(address(_token), _from, _to, _amount, _source); } ```