Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safe symbol #59

Merged
merged 10 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@timeswap-labs:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=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
12 changes: 12 additions & 0 deletions ErrorCodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ Cannot approve to the caller

Not safe transfer

### E609

Approve caller is not owner nor approved for all

### E610

Transfer to non ERC721Receiver implementer

### E611

Not approved to transfer

## Callback

### E701
Expand Down
3 changes: 3 additions & 0 deletions contracts/TimeswapConvenience.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ contract TimeswapConvenience is IConvenience {
/// @param _factory The address of factory contract used by this contract.
/// @param _weth The address of the Wrapped ETH contract.
constructor(IFactory _factory, IWETH _weth) {
require(address(_factory) != address(0), 'E601');
require(address(_weth) != address(0), 'E601');

factory = _factory;
weth = _weth;
}
Expand Down
19 changes: 5 additions & 14 deletions contracts/base/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ abstract contract ERC721 is IERC721Extended {
}

modifier isApproved(address owner, uint256 id) {
require(
owner == msg.sender || getApproved[id] == msg.sender || isApprovedForAll[owner][msg.sender],
'Forrbidden'
);
require(owner == msg.sender || getApproved[id] == msg.sender || isApprovedForAll[owner][msg.sender], '611');
_;
}

Expand Down Expand Up @@ -52,10 +49,7 @@ abstract contract ERC721 is IERC721Extended {

function approve(address to, uint256 id) external override {
address owner = ownerOf[id];
require(
owner == msg.sender || isApprovedForAll[owner][msg.sender],
'ERC721 :: approve : Approve caller is not owner nor approved for all'
);
require(owner == msg.sender || isApprovedForAll[owner][msg.sender], '609');
require(to != owner, 'E605');

_approve(to, id);
Expand Down Expand Up @@ -93,10 +87,7 @@ abstract contract ERC721 is IERC721Extended {
function _safeMint(address to, uint256 id) internal {
_mint(to, id);

require(
_checkOnERC721Received(address(0), to, id, ''),
'ERC721 :: _safeMint : Transfer to non ERC721Receiver implementer'
);
require(_checkOnERC721Received(address(0), to, id, ''), 'E610');
}

function _mint(address to, uint256 id) private {
Expand Down Expand Up @@ -144,13 +135,13 @@ abstract contract ERC721 is IERC721Extended {
);
if (success) {
returnData = _return;
} else if (_return.length > 0) {
} else if (_return.length != 0) {
assembly {
let returnDataSize := mload(_return)
revert(add(32, _return), returnDataSize)
}
} else {
revert('ERC721 :: _checkOnERC721Received : Transfer to non ERC721Receiver implementer');
revert('E610');
}
bytes4 retval = abi.decode(returnData, (bytes4));
return (retval == 0x150b7a02);
Expand Down
4 changes: 2 additions & 2 deletions contracts/libraries/Burn.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ library Burn {
)
);

if (tokensOut.asset > 0) {
if (tokensOut.asset != 0) {
weth.withdraw(tokensOut.asset);
ETH.transfer(params.assetTo, tokensOut.asset);
}
Expand All @@ -62,7 +62,7 @@ library Burn {
)
);

if (tokensOut.collateral > 0) {
if (tokensOut.collateral != 0) {
weth.withdraw(tokensOut.collateral);
ETH.transfer(params.collateralTo, tokensOut.collateral);
}
Expand Down
Loading