refactor/implement getId/setId

This commit is contained in:
cryptoDev222 2021-08-25 11:18:31 -05:00
parent f4b4cbfc5e
commit cc6da0c758
2 changed files with 29 additions and 11 deletions

View File

@ -4,11 +4,15 @@ contract Events {
event LogDepositERC721( event LogDepositERC721(
address indexed erc721, address indexed erc721,
address from, address from,
uint256 tokenId uint256 tokenId,
uint256 getId,
uint256 setId
); );
event LogWithdrawERC721( event LogWithdrawERC721(
address indexed erc721, address indexed erc721,
uint256 tokenId, uint256 tokenId,
address indexed to address indexed to,
uint256 getId,
uint256 setId
); );
} }

View File

@ -17,16 +17,25 @@ abstract contract BasicResolver is Events, DSMath, Basic {
* @param token The address of the token to deposit. * @param token The address of the token to deposit.
* @param tokenId The id of token to deposit. * @param tokenId The id of token to deposit.
*/ */
function depositERC721(address token, uint256 tokenId) function depositERC721(
address token,
uint256 tokenId,
uint256 getId,
uint256 setId
)
public public
payable payable
returns (string memory _eventName, bytes memory _eventParam) returns (string memory _eventName, bytes memory _eventParam)
{ {
IERC721 tokenContract = IERC721(token); uint256 _tokenId = getUint(getId, tokenId);
tokenContract.safeTransferFrom(msg.sender, address(this), tokenId);
_eventName = "LogDepositERC721(address,address,uint256)"; IERC721 tokenContract = IERC721(token);
_eventParam = abi.encode(token, msg.sender, tokenId); tokenContract.safeTransferFrom(msg.sender, address(this), _tokenId);
setUint(setId, _tokenId);
_eventName = "LogDepositERC721(address,address,uint256,uint256,uint256)";
_eventParam = abi.encode(token, msg.sender, _tokenId, getId, setId);
} }
/** /**
@ -39,17 +48,22 @@ abstract contract BasicResolver is Events, DSMath, Basic {
function withdrawERC721( function withdrawERC721(
address token, address token,
uint256 tokenId, uint256 tokenId,
address payable to address payable to,
uint256 getId,
uint256 setId
) )
public public
payable payable
returns (string memory _eventName, bytes memory _eventParam) returns (string memory _eventName, bytes memory _eventParam)
{ {
uint256 _tokenId = getUint(getId, tokenId);
IERC721 tokenContract = IERC721(token); IERC721 tokenContract = IERC721(token);
tokenContract.safeTransferFrom(address(this), to, tokenId); tokenContract.safeTransferFrom(address(this), to, _tokenId);
_eventName = "LogWithdrawERC721(address,uint256,address)"; setUint(setId, _tokenId);
_eventParam = abi.encode(token, tokenId, to);
_eventName = "LogWithdrawERC721(address,uint256,address,uint256,uint256)";
_eventParam = abi.encode(token, _tokenId, to, getId, setId);
} }
} }