Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

[contracts] Refactor token implementations #933

Merged
merged 19 commits into from
Aug 17, 2018

Conversation

abandeali1
Copy link
Member

@abandeali1 abandeali1 commented Jul 31, 2018

Description

  • Refactors and optimizes token implementations (mostly ERC721)
  • Adds tests for ERC20 tokens that don't return a value
  • Adds tests for ERC721 tokens

Testing instructions

Types of changes

Checklist:

  • Prefixed the title of this PR with [WIP] if it is a work in progress.
  • Prefixed the title of this PR with bracketed package name(s) corresponding to the changed package(s). For example: [sol-cov] Fixed bug.
  • Added tests to cover my changes, or decided that tests would be too impractical.
  • Updated documentation, or decided that no doc change is needed.
  • Added new entries to the relevant CHANGELOG.jsons.

@abandeali1 abandeali1 force-pushed the refactor/contracts/tokens branch 2 times, most recently from 4356b9b to f343c3f Compare July 31, 2018 20:25
@coveralls
Copy link

coveralls commented Jul 31, 2018

Coverage Status

Coverage increased (+0.01%) to 85.449% when pulling e35788e on refactor/contracts/tokens into 8131a87 on development.

@abandeali1 abandeali1 force-pushed the refactor/contracts/tokens branch 3 times, most recently from 7de76ae to 428c8a4 Compare August 10, 2018 00:26
@abandeali1 abandeali1 requested a review from dekz August 13, 2018 19:28
@abandeali1 abandeali1 force-pushed the refactor/contracts/tokens branch 2 times, most recently from 76f6e1e to 649b16c Compare August 15, 2018 04:14
expect(log.args._to).to.be.equal(to);
expect(log.args._tokenId).to.be.bignumber.equal(tokenId);
});
it('should transfer the token is spender is individually approved', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if

const newOwner = await token.ownerOf.callAsync(tokenId);
expect(newOwner).to.be.equal(to);
const transferLog = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>;
const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs<InvalidERC721ReceiverTokenReceivedEventArgs>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be DummyERC721Receiver.... Guessing their Events are the same but since this is a valid test might make sense to use that type.

/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
/// @return Always true if enough call has enough gas to complete execution
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always true if the call has enough gas to complete execution

/// @dev `msg.sender` approves `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Always true if enough call has enough gas to complete execution
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enough enough

external
{
require(
_value <= 10000000000000000000000,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe expose this so it's readable programatically (if it does change)

_;
/// @notice Transfers the ownership of an NFT from one address to another address
/// @dev Throws unless `msg.sender` is the current owner, an authorized
/// perator, or the approved address for this NFT. Throws if `_from` is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operator

/// Reverts if the given token ID already exists
/// @param _to Address of the beneficiary that will own the minted token
/// @param _tokenId ID of the token to be minted by the msg.sender
function _mint(address _to, uint256 _tokenId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we expose a public mintable function for testnets?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have DummyERC721Token. Maybe I should just drop the onlyOwner modifiers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to remove onlyOwner from mint but leave it on burn.

@abandeali1 abandeali1 force-pushed the refactor/contracts/tokens branch from 5e9dd81 to aa5a97e Compare August 16, 2018 19:04
@abandeali1 abandeali1 force-pushed the refactor/contracts/tokens branch from aa5a97e to 87689f6 Compare August 17, 2018 00:31
@abandeali1 abandeali1 force-pushed the refactor/contracts/tokens branch from 87689f6 to e35788e Compare August 17, 2018 00:32
@abandeali1 abandeali1 merged commit ddf8511 into development Aug 17, 2018
@abandeali1 abandeali1 deleted the refactor/contracts/tokens branch August 28, 2018 05:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants