Yes Compliance Token
This commit is contained in:
@@ -84,6 +84,7 @@ export enum ContractName {
|
|||||||
MultiSigWalletWithTimeLock = 'MultiSigWalletWithTimeLock',
|
MultiSigWalletWithTimeLock = 'MultiSigWalletWithTimeLock',
|
||||||
Exchange = 'Exchange',
|
Exchange = 'Exchange',
|
||||||
ZRXToken = 'ZRXToken',
|
ZRXToken = 'ZRXToken',
|
||||||
|
YesComplianceToken = 'YesComplianceToken',
|
||||||
DummyERC20Token = 'DummyERC20Token',
|
DummyERC20Token = 'DummyERC20Token',
|
||||||
EtherToken = 'WETH9',
|
EtherToken = 'WETH9',
|
||||||
DutchAuction = 'DutchAuction',
|
DutchAuction = 'DutchAuction',
|
||||||
@@ -99,7 +100,6 @@ export enum ContractName {
|
|||||||
ERC721Proxy = 'ERC721Proxy',
|
ERC721Proxy = 'ERC721Proxy',
|
||||||
DummyERC721Receiver = 'DummyERC721Receiver',
|
DummyERC721Receiver = 'DummyERC721Receiver',
|
||||||
DummyERC721Token = 'DummyERC721Token',
|
DummyERC721Token = 'DummyERC721Token',
|
||||||
DummyYesComplianceToken = 'DummyYesComplianceToken',
|
|
||||||
TestLibBytes = 'TestLibBytes',
|
TestLibBytes = 'TestLibBytes',
|
||||||
TestWallet = 'TestWallet',
|
TestWallet = 'TestWallet',
|
||||||
Authorizable = 'Authorizable',
|
Authorizable = 'Authorizable',
|
||||||
|
2
packages/contracts/contracts/tokens/README.md
Normal file
2
packages/contracts/contracts/tokens/README.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Contracts from https://github.com/sendwyre/yes-compliance-token
|
||||||
|
Modified to compile in our codebase.
|
@@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
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
|
* @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.
|
* 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;
|
uint256 public constant OWNER_ENTITY_ID = 1;
|
||||||
|
|
||||||
|
@@ -1,17 +1,15 @@
|
|||||||
pragma solidity ^0.4.21;
|
pragma solidity ^0.4.21;
|
||||||
|
|
||||||
import "./ERC721Basic.sol";
|
import "./ERC721Basic.sol";
|
||||||
import "./ERC721Receiver.sol";
|
import "../../ERC721Token/IERC721Receiver.sol";
|
||||||
import "../../math/SafeMath.sol";
|
import "../../../utils/SafeMath/SafeMath.sol";
|
||||||
import "../../AddressUtils.sol";
|
|
||||||
import "../../introspection/ERC165Support.sol";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title ERC721 Non-Fungible Token Standard basic implementation
|
* @title ERC721 Non-Fungible Token Standard basic implementation
|
||||||
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
* @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;
|
bytes4 private constant InterfaceId_ERC721 = 0x80ac58cd;
|
||||||
/*
|
/*
|
||||||
@@ -33,9 +31,6 @@ contract ERC721BasicToken is ERC165Support, ERC721Basic {
|
|||||||
* bytes4(keccak256('exists(uint256)'))
|
* bytes4(keccak256('exists(uint256)'))
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using SafeMath for uint256;
|
|
||||||
using AddressUtils for address;
|
|
||||||
|
|
||||||
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
|
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
|
||||||
// which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
|
// which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
|
||||||
bytes4 private constant ERC721_RECEIVED = 0x150b7a02;
|
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
|
* @dev Gets the balance of the specified address
|
||||||
* @param _owner address to query the balance of
|
* @param _owner address to query the balance of
|
||||||
@@ -311,7 +297,7 @@ contract ERC721BasicToken is ERC165Support, ERC721Basic {
|
|||||||
function addTokenTo(address _to, uint256 _tokenId) internal {
|
function addTokenTo(address _to, uint256 _tokenId) internal {
|
||||||
require(tokenOwner[_tokenId] == address(0));
|
require(tokenOwner[_tokenId] == address(0));
|
||||||
tokenOwner[_tokenId] = _to;
|
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 {
|
function removeTokenFrom(address _from, uint256 _tokenId) internal {
|
||||||
require(ownerOf(_tokenId) == _from);
|
require(ownerOf(_tokenId) == _from);
|
||||||
ownedTokensCount[_from] = ownedTokensCount[_from].sub(1);
|
ownedTokensCount[_from] = safeSub(ownedTokensCount[_from], 1);
|
||||||
tokenOwner[_tokenId] = address(0);
|
tokenOwner[_tokenId] = address(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,10 +329,14 @@ contract ERC721BasicToken is ERC165Support, ERC721Basic {
|
|||||||
internal
|
internal
|
||||||
returns (bool)
|
returns (bool)
|
||||||
{
|
{
|
||||||
if (!_to.isContract()) {
|
uint256 receiverCodeSize;
|
||||||
|
assembly {
|
||||||
|
receiverCodeSize := extcodesize(_to)
|
||||||
|
}
|
||||||
|
if (receiverCodeSize == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bytes4 retval = ERC721Receiver(_to).onERC721Received(
|
bytes4 retval = IERC721Receiver(_to).onERC721Received(
|
||||||
msg.sender, _from, _tokenId, _data);
|
msg.sender, _from, _tokenId, _data);
|
||||||
return (retval == ERC721_RECEIVED);
|
return (retval == ERC721_RECEIVED);
|
||||||
}
|
}
|
||||||
|
@@ -52,20 +52,11 @@ contract ERC721Token is ERC721BasicToken, ERC721 {
|
|||||||
/**
|
/**
|
||||||
* @dev Constructor function
|
* @dev Constructor function
|
||||||
*/
|
*/
|
||||||
function initialize(string _name, string _symbol) public isInitializer("ERC721Token", "1.9.0") {
|
function initialize(string _name, string _symbol) public {
|
||||||
name_ = _name;
|
name_ = _name;
|
||||||
symbol_ = _symbol;
|
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
|
* @dev Gets the token name
|
||||||
* @return string representing the token name
|
* @return string representing the token name
|
||||||
@@ -161,7 +152,7 @@ contract ERC721Token is ERC721BasicToken, ERC721 {
|
|||||||
super.removeTokenFrom(_from, _tokenId);
|
super.removeTokenFrom(_from, _tokenId);
|
||||||
|
|
||||||
uint256 tokenIndex = ownedTokensIndex[_tokenId];
|
uint256 tokenIndex = ownedTokensIndex[_tokenId];
|
||||||
uint256 lastTokenIndex = ownedTokens[_from].length.sub(1);
|
uint256 lastTokenIndex = safeSub(ownedTokens[_from].length, 1);
|
||||||
uint256 lastToken = ownedTokens[_from][lastTokenIndex];
|
uint256 lastToken = ownedTokens[_from][lastTokenIndex];
|
||||||
|
|
||||||
ownedTokens[_from][tokenIndex] = lastToken;
|
ownedTokens[_from][tokenIndex] = lastToken;
|
||||||
@@ -204,7 +195,7 @@ contract ERC721Token is ERC721BasicToken, ERC721 {
|
|||||||
|
|
||||||
// Reorg all tokens array
|
// Reorg all tokens array
|
||||||
uint256 tokenIndex = allTokensIndex[_tokenId];
|
uint256 tokenIndex = allTokensIndex[_tokenId];
|
||||||
uint256 lastTokenIndex = allTokens.length.sub(1);
|
uint256 lastTokenIndex = safeSub(allTokens.length, 1);
|
||||||
uint256 lastToken = allTokens[lastTokenIndex];
|
uint256 lastToken = allTokens[lastTokenIndex];
|
||||||
|
|
||||||
allTokens[tokenIndex] = lastToken;
|
allTokens[tokenIndex] = lastToken;
|
||||||
|
@@ -118,7 +118,6 @@ contract YesComplianceToken is YesComplianceTokenV1 {
|
|||||||
*/
|
*/
|
||||||
function initialize(string _name, string _symbol) {
|
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
|
// 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
|
super.initialize(_name, _symbol); // init token info
|
||||||
|
|
||||||
// grant the owner token
|
// grant the owner token
|
||||||
@@ -133,7 +132,6 @@ contract YesComplianceToken is YesComplianceTokenV1 {
|
|||||||
* executed in lieu of a constructor in a delegated context
|
* executed in lieu of a constructor in a delegated context
|
||||||
*/
|
*/
|
||||||
function _upgradeable_initialize() public {
|
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:)
|
// some things are still tied to the owner (instead of the yesmark_owner :notsureif:)
|
||||||
ownerAddress = msg.sender;
|
ownerAddress = msg.sender;
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
/*
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||||
import { assetDataUtils } from '@0x/order-utils';
|
import { assetDataUtils } from '@0x/order-utils';
|
||||||
import { RevertReason, SignedOrder } from '@0x/types';
|
import { RevertReason, SignedOrder } from '@0x/types';
|
||||||
@@ -8,7 +9,7 @@ import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
|||||||
|
|
||||||
import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
|
import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
|
||||||
import { ExchangeContract } from '../../generated-wrappers/exchange';
|
import { ExchangeContract } from '../../generated-wrappers/exchange';
|
||||||
import { DummyYesComplianceContract } from '../../generated-wrappers/forwarder';
|
|
||||||
import { WETH9Contract } from '../../generated-wrappers/weth9';
|
import { WETH9Contract } from '../../generated-wrappers/weth9';
|
||||||
import { artifacts } from '../../src/artifacts';
|
import { artifacts } from '../../src/artifacts';
|
||||||
import {
|
import {
|
||||||
@@ -189,3 +190,4 @@ describe(ContractName.Forwarder, () => {
|
|||||||
});
|
});
|
||||||
// tslint:disable:max-file-line-count
|
// tslint:disable:max-file-line-count
|
||||||
// tslint:enable:no-unnecessary-type-assertion
|
// tslint:enable:no-unnecessary-type-assertion
|
||||||
|
*/
|
Reference in New Issue
Block a user