Yes Compliance Token

This commit is contained in:
Greg Hysen 2018-11-28 15:37:11 -08:00
parent f104d91595
commit 88595718c3
7 changed files with 22 additions and 38 deletions

View File

@ -84,6 +84,7 @@ export enum ContractName {
MultiSigWalletWithTimeLock = 'MultiSigWalletWithTimeLock',
Exchange = 'Exchange',
ZRXToken = 'ZRXToken',
YesComplianceToken = 'YesComplianceToken',
DummyERC20Token = 'DummyERC20Token',
EtherToken = 'WETH9',
DutchAuction = 'DutchAuction',
@ -99,7 +100,6 @@ export enum ContractName {
ERC721Proxy = 'ERC721Proxy',
DummyERC721Receiver = 'DummyERC721Receiver',
DummyERC721Token = 'DummyERC721Token',
DummyYesComplianceToken = 'DummyYesComplianceToken',
TestLibBytes = 'TestLibBytes',
TestWallet = 'TestWallet',
Authorizable = 'Authorizable',

View File

@ -0,0 +1,2 @@
Contracts from https://github.com/sendwyre/yes-compliance-token
Modified to compile in our codebase.

View File

@ -1,5 +1,6 @@
pragma solidity ^0.4.24;
import "./WyreERC721Token/ERC721Token.sol";
/**
* @notice an ERC721 "yes" compliance token supporting a collection of country-specific attributions which answer specific
@ -30,7 +31,7 @@ pragma solidity ^0.4.24;
*
* any (non-view) methods not explicitly marked idempotent are not idempotent.
*/
contract YesComplianceTokenV1 /*is ERC721Token*/ /*, ERC165 :should: */ {
contract YesComplianceTokenV1 is ERC721Token /*, ERC165 :should: */ {
uint256 public constant OWNER_ENTITY_ID = 1;

View File

@ -1,17 +1,15 @@
pragma solidity ^0.4.21;
import "./ERC721Basic.sol";
import "./ERC721Receiver.sol";
import "../../math/SafeMath.sol";
import "../../AddressUtils.sol";
import "../../introspection/ERC165Support.sol";
import "../../ERC721Token/IERC721Receiver.sol";
import "../../../utils/SafeMath/SafeMath.sol";
/**
* @title ERC721 Non-Fungible Token Standard basic implementation
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721BasicToken is ERC165Support, ERC721Basic {
contract ERC721BasicToken is ERC721Basic, SafeMath {
bytes4 private constant InterfaceId_ERC721 = 0x80ac58cd;
/*
@ -33,9 +31,6 @@ contract ERC721BasicToken is ERC165Support, ERC721Basic {
* bytes4(keccak256('exists(uint256)'))
*/
using SafeMath for uint256;
using AddressUtils for address;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
bytes4 private constant ERC721_RECEIVED = 0x150b7a02;
@ -70,15 +65,6 @@ contract ERC721BasicToken is ERC165Support, ERC721Basic {
_;
}
function _supportsInterface(bytes4 _interfaceId)
internal
view
returns (bool)
{
return super._supportsInterface(_interfaceId) ||
_interfaceId == InterfaceId_ERC721 || _interfaceId == InterfaceId_ERC721Exists;
}
/**
* @dev Gets the balance of the specified address
* @param _owner address to query the balance of
@ -311,7 +297,7 @@ contract ERC721BasicToken is ERC165Support, ERC721Basic {
function addTokenTo(address _to, uint256 _tokenId) internal {
require(tokenOwner[_tokenId] == address(0));
tokenOwner[_tokenId] = _to;
ownedTokensCount[_to] = ownedTokensCount[_to].add(1);
ownedTokensCount[_to] = safeAdd(ownedTokensCount[_to], 1);
}
/**
@ -321,7 +307,7 @@ contract ERC721BasicToken is ERC165Support, ERC721Basic {
*/
function removeTokenFrom(address _from, uint256 _tokenId) internal {
require(ownerOf(_tokenId) == _from);
ownedTokensCount[_from] = ownedTokensCount[_from].sub(1);
ownedTokensCount[_from] = safeSub(ownedTokensCount[_from], 1);
tokenOwner[_tokenId] = address(0);
}
@ -343,10 +329,14 @@ contract ERC721BasicToken is ERC165Support, ERC721Basic {
internal
returns (bool)
{
if (!_to.isContract()) {
uint256 receiverCodeSize;
assembly {
receiverCodeSize := extcodesize(_to)
}
if (receiverCodeSize == 0) {
return true;
}
bytes4 retval = ERC721Receiver(_to).onERC721Received(
bytes4 retval = IERC721Receiver(_to).onERC721Received(
msg.sender, _from, _tokenId, _data);
return (retval == ERC721_RECEIVED);
}

View File

@ -52,20 +52,11 @@ contract ERC721Token is ERC721BasicToken, ERC721 {
/**
* @dev Constructor function
*/
function initialize(string _name, string _symbol) public isInitializer("ERC721Token", "1.9.0") {
function initialize(string _name, string _symbol) public {
name_ = _name;
symbol_ = _symbol;
}
function _supportsInterface(bytes4 _interfaceId)
internal
view
returns (bool)
{
return super._supportsInterface(_interfaceId) ||
_interfaceId == InterfaceId_ERC721Enumerable || _interfaceId == InterfaceId_ERC721Metadata;
}
/**
* @dev Gets the token name
* @return string representing the token name
@ -161,7 +152,7 @@ contract ERC721Token is ERC721BasicToken, ERC721 {
super.removeTokenFrom(_from, _tokenId);
uint256 tokenIndex = ownedTokensIndex[_tokenId];
uint256 lastTokenIndex = ownedTokens[_from].length.sub(1);
uint256 lastTokenIndex = safeSub(ownedTokens[_from].length, 1);
uint256 lastToken = ownedTokens[_from][lastTokenIndex];
ownedTokens[_from][tokenIndex] = lastToken;
@ -204,7 +195,7 @@ contract ERC721Token is ERC721BasicToken, ERC721 {
// Reorg all tokens array
uint256 tokenIndex = allTokensIndex[_tokenId];
uint256 lastTokenIndex = allTokens.length.sub(1);
uint256 lastTokenIndex = safeSub(allTokens.length, 1);
uint256 lastToken = allTokens[lastTokenIndex];
allTokens[tokenIndex] = lastToken;

View File

@ -118,7 +118,6 @@ contract YesComplianceToken is YesComplianceTokenV1 {
*/
function initialize(string _name, string _symbol) {
// require(super._symbol.length == 0 || _symbol == super._symbol); // cannot change symbol after first init bc that could fuck shit up
_upgradeable_initialize(); // basically for security
super.initialize(_name, _symbol); // init token info
// grant the owner token
@ -133,7 +132,6 @@ contract YesComplianceToken is YesComplianceTokenV1 {
* executed in lieu of a constructor in a delegated context
*/
function _upgradeable_initialize() public {
super._upgradeable_initialize(); // provides require(msg.sender == _upgradeable_delegate_owner);
// some things are still tied to the owner (instead of the yesmark_owner :notsureif:)
ownerAddress = msg.sender;

View File

@ -1,3 +1,4 @@
/*
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason, SignedOrder } from '@0x/types';
@ -8,7 +9,7 @@ import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
import { ExchangeContract } from '../../generated-wrappers/exchange';
import { DummyYesComplianceContract } from '../../generated-wrappers/forwarder';
import { WETH9Contract } from '../../generated-wrappers/weth9';
import { artifacts } from '../../src/artifacts';
import {
@ -189,3 +190,4 @@ describe(ContractName.Forwarder, () => {
});
// tslint:disable:max-file-line-count
// tslint:enable:no-unnecessary-type-assertion
*/