-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nft: return extra tokens to sender, handle a case where receiver is n…
…ot the same as sender
- Loading branch information
Showing
2 changed files
with
19 additions
and
10 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 |
---|---|---|
|
@@ -75,7 +75,13 @@ contract Connected is | |
|
||
string memory uri = tokenURI(tokenId); | ||
_burn(tokenId); | ||
bytes memory message = abi.encode(destination, receiver, tokenId, uri); | ||
bytes memory message = abi.encode( | ||
destination, | ||
receiver, | ||
tokenId, | ||
uri, | ||
msg.sender | ||
); | ||
if (destination == address(0)) { | ||
gateway.call( | ||
counterparty, | ||
|
@@ -90,7 +96,7 @@ contract Connected is | |
address(this), | ||
true, | ||
address(0), | ||
abi.encode(receiver, tokenId, uri), | ||
abi.encode(receiver, tokenId, uri, msg.sender), | ||
gasLimit | ||
) | ||
); | ||
|
@@ -109,23 +115,24 @@ contract Connected is | |
address receiver, | ||
uint256 tokenId, | ||
string memory uri, | ||
uint256 amount | ||
) = abi.decode(message, (address, uint256, string, uint256)); | ||
uint256 amount, | ||
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, ) = receiver.call{value: amount}(""); | ||
(bool success, ) = sender.call{value: amount}(""); | ||
if (!success) revert GasTokenTransferFailed(); | ||
} | ||
emit TokenTransferReceived(receiver, tokenId, uri); | ||
return ""; | ||
} | ||
|
||
function onRevert(RevertContext calldata context) external onlyGateway { | ||
(address sender, uint256 tokenId, string memory uri) = abi.decode( | ||
(, uint256 tokenId, string memory uri, address sender) = abi.decode( | ||
context.revertMessage, | ||
(address, uint256, string) | ||
(address, uint256, string, address) | ||
); | ||
|
||
_safeMint(sender, tokenId); | ||
|
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