Skip to content

Commit ca9d111

Browse files
committed
apply Solidity style guide conventions
1 parent 4f14167 commit ca9d111

File tree

4 files changed

+63
-62
lines changed

4 files changed

+63
-62
lines changed

base/src/Bridge.sol

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,19 @@ contract Bridge is Initializable {
122122
}
123123

124124
/// @notice Sends ERC20 tokens to the sender's address on the other chain.
125-
/// @param _localToken Address of the ERC20 on this chain.
126-
/// @param _remoteToken Address of the corresponding token on the remote chain.
127-
/// @param _to Solana pubkey to send tokens to
128-
/// @param _amount Amount of local tokens to deposit.
129-
/// @param _extraData Extra data to be sent with the transaction. Note that the recipient will
125+
/// @param localToken Address of the ERC20 on this chain.
126+
/// @param remoteToken Address of the corresponding token on the remote chain.
127+
/// @param to Solana pubkey to send tokens to
128+
/// @param amount Amount of local tokens to deposit.
129+
/// @param extraData Extra data to be sent with the transaction. Note that the recipient will
130130
/// not be triggered with this data, but it will be emitted and can be used
131131
/// to identify the transaction.
132-
function bridgeToken(
133-
address _localToken,
134-
bytes32 _remoteToken,
135-
bytes32 _to,
136-
uint64 _amount,
137-
bytes calldata _extraData
138-
) public virtual onlyEOA {
139-
_initiateBridgeERC20(_localToken, _remoteToken, msg.sender, _to, _amount, _extraData);
132+
function bridgeToken(address localToken, bytes32 remoteToken, bytes32 to, uint64 amount, bytes calldata extraData)
133+
public
134+
virtual
135+
onlyEOA
136+
{
137+
_initiateBridgeERC20(localToken, remoteToken, msg.sender, to, amount, extraData);
140138
}
141139

142140
/// @notice Finalizes a token bridge on this chain. Can only be triggered by the Bridge contract on the remote
@@ -186,49 +184,49 @@ contract Bridge is Initializable {
186184
//////////////////////////////////////////////////////////////
187185

188186
/// @notice Sends ERC20 tokens to a receiver's address on the other chain.
189-
/// @param _localToken Address of the ERC20 on this chain.
190-
/// @param _remoteToken Address of the corresponding token on the remote chain.
191-
/// @param _to Address of the receiver.
192-
/// @param _amount Amount of local tokens to deposit.
193-
/// @param _extraData Extra data to be sent with the transaction. Note that the recipient will
187+
/// @param localToken Address of the ERC20 on this chain.
188+
/// @param remoteToken Address of the corresponding token on the remote chain.
189+
/// @param to Address of the receiver.
190+
/// @param amount Amount of local tokens to deposit.
191+
/// @param extraData Extra data to be sent with the transaction. Note that the recipient will
194192
/// not be triggered with this data, but it will be emitted and can be used
195193
/// to identify the transaction.
196194
function _initiateBridgeERC20(
197-
address _localToken,
198-
bytes32 _remoteToken,
199-
address _from,
200-
bytes32 _to,
201-
uint64 _amount,
202-
bytes memory _extraData
195+
address localToken,
196+
bytes32 remoteToken,
197+
address from,
198+
bytes32 to,
199+
uint64 amount,
200+
bytes memory extraData
203201
) internal {
204202
require(msg.value == 0, "StandardBridge: cannot send value");
205203

206-
if (_isCrossChainERC20(_localToken)) {
204+
if (_isCrossChainERC20(localToken)) {
207205
require(
208-
_isCorrectTokenPair(CrossChainERC20(_localToken), _remoteToken),
206+
_isCorrectTokenPair(CrossChainERC20(localToken), remoteToken),
209207
"StandardBridge: wrong remote token for Optimism Mintable ERC20 local token"
210208
);
211209

212-
CrossChainERC20(_localToken).burn(_from, _amount);
210+
CrossChainERC20(localToken).burn(from, amount);
213211
} else {
214-
SafeTransferLib.safeTransferFrom({token: _localToken, from: _from, to: address(this), amount: _amount});
215-
deposits[_localToken][_remoteToken] = deposits[_localToken][_remoteToken] + _amount;
212+
SafeTransferLib.safeTransferFrom({token: localToken, from: from, to: address(this), amount: amount});
213+
deposits[localToken][remoteToken] = deposits[localToken][remoteToken] + amount;
216214
}
217215

218-
emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
216+
emit ERC20BridgeInitiated(localToken, remoteToken, from, to, amount, extraData);
219217

220218
MessagePasser.Instruction[] memory messageIxs = new MessagePasser.Instruction[](1);
221219
messageIxs[0] = MessagePasser.Instruction({
222220
programId: remoteBridge,
223221
accounts: new MessagePasser.AccountMeta[](0),
224222
data: Encoder.encodeBridgePayload(
225223
BridgePayload({
226-
localToken: _remoteToken,
227-
remoteToken: _localToken,
228-
from: _from,
229-
to: _to,
230-
amount: _amount,
231-
extraData: _extraData
224+
localToken: remoteToken,
225+
remoteToken: localToken,
226+
from: from,
227+
to: to,
228+
amount: amount,
229+
extraData: extraData
232230
})
233231
)
234232
});

base/src/CrossChainERC20.sol

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ contract CrossChainERC20 is ERC20 {
2121
/// @param from Address of the account tokens are being burned from.
2222
/// @param amount Amount of tokens burned.
2323
event Burn(address indexed from, uint256 amount);
24+
2425
//////////////////////////////////////////////////////////////
2526
/// Constants ///
2627
//////////////////////////////////////////////////////////////
@@ -72,32 +73,33 @@ contract CrossChainERC20 is ERC20 {
7273
return "1.0.1";
7374
}
7475

75-
/// @dev Returns the bridge address.
76+
/// @notice Returns the bridge address.
7677
function bridge() public view returns (address) {
7778
return _bridge;
7879
}
7980

80-
/// @dev Returns the remote token address.
81+
/// @notice Returns the remote token address.
8182
function remoteToken() public view returns (bytes32) {
8283
return _remoteToken;
8384
}
8485

85-
/// @dev Returns the name of the token.
86+
/// @notice Returns the name of the token.
8687
function name() public view override returns (string memory) {
8788
return _name;
8889
}
8990

90-
/// @dev Returns the symbol of the token.
91+
/// @notice Returns the symbol of the token.
9192
function symbol() public view override returns (string memory) {
9293
return _symbol;
9394
}
9495

95-
/// @dev Returns the decimals places of the token.
96+
/// @notice Returns the decimals places of the token.
9697
function decimals() public view override returns (uint8) {
9798
return _decimals;
9899
}
99100

100101
/// @notice Allows the Bridge to mint tokens.
102+
///
101103
/// @param to Address to mint tokens to.
102104
/// @param amount Amount of tokens to mint.
103105
function mint(address to, uint256 amount) external onlyBridge {
@@ -108,6 +110,7 @@ contract CrossChainERC20 is ERC20 {
108110
}
109111

110112
/// @notice Allows the Bridge to burn tokens.
113+
///
111114
/// @param from Address to burn tokens from.
112115
/// @param amount Amount of tokens to burn.
113116
function burn(address from, uint256 amount) external onlyBridge {

base/src/CrossChainMessenger.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ contract CrossChainMessenger is Initializable {
124124
return _xChainMsgSender;
125125
}
126126

127+
/// @notice Retrieves the next message nonce. Message version will be added to the upper two
128+
/// bytes of the message nonce. Message version allows us to treat messages as having
129+
/// different structures.
130+
///
131+
/// @return Nonce of the next message to be sent, with added message version.
132+
function messageNonce() public view returns (uint256) {
133+
return Encoding.encodeVersionedNonce(_msgNonce, MESSAGE_VERSION);
134+
}
135+
127136
/// @notice Initializer.
128137
///
129138
/// @param remoteMessenger_ Address of the messenger on the remote chain.
@@ -247,15 +256,6 @@ contract CrossChainMessenger is Initializable {
247256
}
248257
}
249258

250-
/// @notice Retrieves the next message nonce. Message version will be added to the upper two
251-
/// bytes of the message nonce. Message version allows us to treat messages as having
252-
/// different structures.
253-
///
254-
/// @return Nonce of the next message to be sent, with added message version.
255-
function messageNonce() public view returns (uint256) {
256-
return Encoding.encodeVersionedNonce(_msgNonce, MESSAGE_VERSION);
257-
}
258-
259259
//////////////////////////////////////////////////////////////
260260
/// Internal Functions ///
261261
//////////////////////////////////////////////////////////////

base/src/MessagePasser.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ contract MessagePasser {
8888
return "1.1.2";
8989
}
9090

91+
/// @notice Retrieves the next message nonce. Message version will be added to the upper two
92+
/// bytes of the message nonce. Message version allows us to treat messages as having
93+
/// different structures.
94+
///
95+
/// @return Nonce of the next message to be sent, with added message version.
96+
function messageNonce() public view returns (uint256) {
97+
return Encoding.encodeVersionedNonce(_msgNonce, MESSAGE_VERSION);
98+
}
99+
91100
/// @notice Sends a message from L2 to L1.
92101
///
93102
/// @param ixs Instructions to execute.
@@ -104,25 +113,16 @@ contract MessagePasser {
104113
}
105114
}
106115

107-
/// @notice Retrieves the next message nonce. Message version will be added to the upper two
108-
/// bytes of the message nonce. Message version allows us to treat messages as having
109-
/// different structures.
110-
///
111-
/// @return Nonce of the next message to be sent, with added message version.
112-
function messageNonce() public view returns (uint256) {
113-
return Encoding.encodeVersionedNonce(_msgNonce, MESSAGE_VERSION);
114-
}
115-
116116
//////////////////////////////////////////////////////////////
117117
/// Internal Functions ///
118118
//////////////////////////////////////////////////////////////
119119

120120
/// @notice Derives the withdrawal hash according to the encoding in the L2 Withdrawer contract
121121
///
122-
/// @param _tx Withdrawal transaction to hash.
122+
/// @param withdrawal Withdrawal transaction to hash.
123123
///
124124
/// @return Hashed withdrawal transaction.
125-
function _hashWithdrawal(WithdrawalTransaction memory _tx) internal pure returns (bytes32) {
126-
return keccak256(Encoder.encodeMessage(_tx.nonce, _tx.sender, _tx.ixs));
125+
function _hashWithdrawal(WithdrawalTransaction memory withdrawal) internal pure returns (bytes32) {
126+
return keccak256(Encoder.encodeMessage(withdrawal.nonce, withdrawal.sender, withdrawal.ixs));
127127
}
128128
}

0 commit comments

Comments
 (0)