Skip to content

Commit

Permalink
chore: remove prefix from superchainerc20 crosschain functions (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xng authored Oct 11, 2024
1 parent 78c0cdd commit b1de5f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions specs/interop/predeploys.md
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,9 @@ It SHOULD burn `_amount` tokens with address `_tokenAddress` and initialize a me
in the target address `_to` at `_chainId` and emit the `SentERC20` event including the `msg.sender` as parameter.

To burn the token, the `sendERC20` function
calls `__crosschainBurn` in the token contract,
calls `crosschainBurn` in the token contract,
which is included as part of the the `ICrosschainERC20`
[interface](./token-bridging.md#__crosschainburn)
[interface](./token-bridging.md#crosschainburn)
implemented by the `SuperchainERC20` standard.

Returns the `msgHash_` crafted by the `L2ToL2CrossChainMessenger`.
Expand All @@ -906,9 +906,9 @@ and emit an event including the `_tokenAddress`, the `_from` and chain id from t
`source` chain, where `_from` is the `msg.sender` of `sendERC20`.

To mint the token, the `relayERC20` function
calls `__crosschainMint` in the token contract,
calls `crosschainMint` in the token contract,
which is included as part of the the `ICrosschainERC20`
[interface](./token-bridging.md#__crosschainmint)
[interface](./token-bridging.md#crosschainmint)
implemented by the `SuperchainERC20` standard.

```solidity
Expand Down Expand Up @@ -949,15 +949,15 @@ sequenceDiagram
participant SuperERC20_B as SuperchainERC20 (Chain B)
from->>L2SBA: sendERC20(tokenAddr, to, amount, chainID)
L2SBA->>SuperERC20_A: __crosschainBurn(from, amount)
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)
L2SBB->>SuperERC20_B: crosschainMint(to, amount)
SuperERC20_B-->SuperERC20_B: emit SuperchainMinted(to, amount)
L2SBB-->L2SBB: emit RelayedERC20(tokenAddr, from, to, amount, source)
```
Expand Down
30 changes: 15 additions & 15 deletions specs/interop/token-bridging.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
- [`SuperchainERC20` standard](#superchainerc20-standard)
- [Properties](#properties)
- [`ICrosschainERC20`](#icrosschainerc20)
- [`__crosschainMint`](#__crosschainmint)
- [`__crosschainBurn`](#__crosschainburn)
- [`crosschainMint`](#crosschainmint)
- [`crosschainBurn`](#crosschainburn)
- [`CrosschainMinted`](#crosschainminted)
- [`CrosschainBurnt`](#crosschainburnt)
- [`SuperchainERC20Bridge`](#superchainerc20bridge)
Expand All @@ -36,7 +36,7 @@ The standard will build on top of ERC20, implement the [`ICrosschainERC20`](#icr
interface and include the following properties:

1. Only allow `SuperchainERC20Bridge` to call
[`__crosschainMint`](#__crosschainmint) and [`__crosschainBurn`](#__crosschainburn).
[`crosschainMint`](#crosschainmint) and [`crosschainBurn`](#crosschainburn).
2. Be deployed at the same address on every chain in the Superchain.

The first property will allow the `SuperchainERC20Bridge` to have a liquidity guarantee,
Expand All @@ -63,33 +63,33 @@ using a custom bridge or implementing `sendERC20` and `relayERC20` on their own
Implementations of the `SuperchainERC20` standard will need to implement the `ICrosschainERC20`
token standard, that includes two external functions and two events:

#### `__crosschainMint`
#### `crosschainMint`

Mints `_amount` of token to address `_account`.

```solidity
__crosschainMint(address _account, uint256 _amount)
crosschainMint(address _account, uint256 _amount)
```

#### `__crosschainBurn`
#### `crosschainBurn`

Burns `_amount` of token from address `_account`.

```solidity
__crosschainBurn(address _account, uint256 _amount)
crosschainBurn(address _account, uint256 _amount)
```

#### `CrosschainMinted`

MUST trigger when `__crosschainMint` is called
MUST trigger when `crosschainMint` is called

```solidity
event CrosschainMinted(address indexed _to, uint256 _amount)
```

#### `CrosschainBurnt`

MUST trigger when `__crosschainBurn` is called
MUST trigger when `crosschainBurn` is called

```solidity
event CrosschainBurnt(address indexed _from, uint256 _amount)
Expand Down Expand Up @@ -132,15 +132,15 @@ sequenceDiagram
participant SuperERC20_B as SuperchainERC20 (Chain B)
from->>L2SBA: sendERC20(tokenAddr, to, amount, chainID)
L2SBA->>SuperERC20_A: __crosschainBurn(from, amount)
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)
L2SBB->>SuperERC20_B: crosschainMint(to, amount)
SuperERC20_B-->SuperERC20_B: emit CrosschainMinted(to, amount)
L2SBB-->L2SBB: emit RelayedERC20(tokenAddr, from, to, amount, source)
```
Expand All @@ -151,7 +151,7 @@ An example implementation for the `sendERC20` and `relayERC20` functions is prov

```solidity
function sendERC20(SuperchainERC20 _token, address _to, uint256 _amount, uint256 _chainId) external returns (bytes32 msgHash_) {
_token.__crosschainBurn(msg.sender, _amount);
_token.crosschainBurn(msg.sender, _amount);
bytes memory _message = abi.encodeCall(this.relayERC20, (_token, msg.sender, _to, _amount));
Expand All @@ -166,7 +166,7 @@ function relayERC20(SuperchainERC20 _token, address _from, address _to, uint256
uint256 _source = L2ToL2CrossChainMessenger.crossDomainMessageSource();
_token.__crosschainMint(_to, _amount);
_token.crosschainMint(_to, _amount);
emit RelayedERC20(address(_token), _from, _to, _amount, _source);
}
Expand Down Expand Up @@ -229,14 +229,14 @@ sequenceDiagram
from->>Intermediate_A: sendWithData(data)
Intermediate_A->>L2SBA: sendERC20To(tokenAddr, to, amount, chainID)
L2SBA->>SuperERC20_A: __crosschainBurn(from, amount)
L2SBA->>SuperERC20_A: crosschainBurn(from, amount)
SuperERC20_A-->SuperERC20_A: emit CrosschainBurnt(from, amount)
L2SBA->>Messenger_A: sendMessage(chainId, message)
L2SBA-->L2SBA: emit SentERC20(tokenAddr, from, to, amount, destination)
Intermediate_A->>Messenger_A: sendMessage(chainId, to, data)
Inbox->>Messenger_B: relayMessage()
Messenger_B->>L2SBB: relayERC20(tokenAddr, from, to, amount)
L2SBB->>SuperERC20_B: __crosschainMint(to, amount)
L2SBB->>SuperERC20_B: crosschainMint(to, amount)
SuperERC20_B-->SuperERC20_B: emit CrosschainMinted(to, amount)
Inbox->>Messenger_B: relayMessage(): call
L2SBB-->L2SBB: emit RelayedERC20(tokenAddr, from, to, amount, source)
Expand Down

0 comments on commit b1de5f6

Please sign in to comment.