-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
46 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,14 +115,14 @@ contract Connected is | |
address receiver, | ||
uint256 tokenId, | ||
string memory uri, | ||
uint256 amount, | ||
uint256 gasAmount, | ||
address sender | ||
Check notice Code scanning / Slither Missing zero address validation Low
Connected.onCall(MessageContext,bytes).sender lacks a zero-check on :
- (success,None) = sender.call{value: gasAmount}() |
||
) = abi.decode(message, (address, uint256, string, uint256, address)); | ||
|
||
_safeMint(receiver, tokenId); | ||
_setTokenURI(tokenId, uri); | ||
if (amount > 0) { | ||
(bool success, ) = sender.call{value: amount}(""); | ||
if (gasAmount > 0) { | ||
(bool success, ) = sender.call{value: gasAmount}(""); | ||
if (!success) revert GasTokenTransferFailed(); | ||
} | ||
emit TokenTransferReceived(receiver, tokenId, uri); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ contract Connected is ERC20, Ownable2Step, Events { | |
error InvalidAddress(); | ||
error Unauthorized(); | ||
error InvalidGasLimit(); | ||
error GasTokenTransferFailed(); | ||
|
||
modifier onlyGateway() { | ||
if (msg.sender != address(gateway)) revert Unauthorized(); | ||
|
@@ -51,7 +52,12 @@ contract Connected is ERC20, Ownable2Step, Events { | |
if (receiver == address(0)) revert InvalidAddress(); | ||
_burn(msg.sender, amount); | ||
|
||
bytes memory message = abi.encode(destination, receiver, amount); | ||
bytes memory message = abi.encode( | ||
destination, | ||
receiver, | ||
amount, | ||
msg.sender | ||
); | ||
if (destination == address(0)) { | ||
gateway.call( | ||
counterparty, | ||
|
@@ -66,7 +72,7 @@ contract Connected is ERC20, Ownable2Step, Events { | |
address(this), | ||
true, | ||
address(0), | ||
abi.encode(receiver, amount), | ||
abi.encode(amount, msg.sender), | ||
gasLimit | ||
) | ||
); | ||
|
@@ -80,22 +86,28 @@ contract Connected is ERC20, Ownable2Step, Events { | |
bytes calldata message | ||
) external payable onlyGateway returns (bytes4) { | ||
if (context.sender != counterparty) revert Unauthorized(); | ||
(address receiver, uint256 amount) = abi.decode( | ||
message, | ||
(address, uint256) | ||
); | ||
( | ||
address receiver, | ||
uint256 amount, | ||
uint256 gasAmount, | ||
address sender | ||
Check notice Code scanning / Slither Missing zero address validation Low
Connected.onCall(MessageContext,bytes).sender lacks a zero-check on :
- (success,None) = sender.call{value: amount}() |
||
) = abi.decode(message, (address, uint256, uint256, address)); | ||
_mint(receiver, amount); | ||
if (gasAmount > 0) { | ||
(bool success, ) = sender.call{value: amount}(""); | ||
if (!success) revert GasTokenTransferFailed(); | ||
} | ||
emit TokenTransferReceived(receiver, amount); | ||
return ""; | ||
} | ||
|
||
function onRevert(RevertContext calldata context) external onlyGateway { | ||
(address sender, uint256 amount) = abi.decode( | ||
(uint256 amount, address receiver) = abi.decode( | ||
context.revertMessage, | ||
(address, uint256) | ||
(uint256, address) | ||
); | ||
_mint(sender, amount); | ||
emit TokenTransferReverted(sender, amount); | ||
_mint(receiver, amount); | ||
emit TokenTransferReverted(receiver, amount); | ||
} | ||
|
||
receive() external payable {} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters