From 97c54f357a7beb9df30431b46bffa36841131e02 Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 10 Dec 2020 12:07:07 +0800 Subject: [PATCH 01/64] upgrade ObjectOwnershipAuthority to V3 --- .gitignore | 1 + contracts/MintAndBurnAuthorityV2.sol | 2 +- contracts/ObjectOwnershipAuthorityV3.sol | 34 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 contracts/ObjectOwnershipAuthorityV3.sol diff --git a/.gitignore b/.gitignore index af374d3..9949076 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ package-lock.json .idea contracts-flattener truffle.js +truffle.config.js scripts diff --git a/contracts/MintAndBurnAuthorityV2.sol b/contracts/MintAndBurnAuthorityV2.sol index c34c2ba..f894e56 100644 --- a/contracts/MintAndBurnAuthorityV2.sol +++ b/contracts/MintAndBurnAuthorityV2.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.24; -contract MintAndBurnAuthority { +contract MintAndBurnAuthorityV2 { mapping (address => bool) public allowList; diff --git a/contracts/ObjectOwnershipAuthorityV3.sol b/contracts/ObjectOwnershipAuthorityV3.sol new file mode 100644 index 0000000..fe9ded0 --- /dev/null +++ b/contracts/ObjectOwnershipAuthorityV3.sol @@ -0,0 +1,34 @@ +pragma solidity ^0.4.24; + +/** + * @title ObjectOwnershipAuthority + * @dev ObjectOwnershipAuthority is authority that manage ObjectOwnership. + * difference between ObjectOwnershipAuthority whiteList: +[$LANDBASE_PROXY,$APOSTLEBASE_PROXY,$ERC721BRIDGE_PROXY] ==> [$LANDBASE_PROXY,$APOSTLEBASE_PROXY,$ERC721BRIDGE_PROXY,$DRILLBASE_PROXY] + */ + +contract ObjectOwnershipAuthorityV3 { + mapping(address => bool) public whiteList; + + constructor(address[] memory _whitelists) public { + for (uint256 i = 0; i < _whitelists.length; i++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, + address, /* _dst */ + bytes4 _sig + ) public view returns (bool) { + return + (whiteList[_src] && + _sig == bytes4(keccak256("mintObject(address,uint128)"))) || + (whiteList[_src] && + _sig == bytes4(keccak256("burnObject(address,uint128)"))) || + (whiteList[_src] && + _sig == bytes4(keccak256("mint(address,uint256)"))) || + (whiteList[_src] && + _sig == bytes4(keccak256("burn(address,uint256)"))); + } +} From bfa0aefebd761016a7e312bf9a8e6ccce08d980d Mon Sep 17 00:00:00 2001 From: echo Date: Mon, 4 Jan 2021 11:20:45 +0800 Subject: [PATCH 02/64] flat code --- .gitignore | 2 + flat/ApproveAndCallFallBack.sol | 7 + flat/DSAuth.sol | 71 + flat/DeployAndTest.sol | 905 ++++++++++++ flat/ERC20Container.sol | 429 ++++++ flat/ERC223.sol | 11 + flat/ERC223ReceivingContract.sol | 19 + flat/ERC721Adaptor.sol | 564 ++++++++ flat/ERC721AdaptorAuthority.sol | 20 + flat/ERC721Bridge.sol | 654 +++++++++ flat/ERC721Container.sol | 522 +++++++ flat/IActivity.sol | 39 + flat/IActivityObject.sol | 42 + flat/IAuthority.sol | 9 + flat/IBurnableERC20.sol | 7 + flat/IContainer.sol | 8 + flat/IInterstellarEncoder.sol | 35 + flat/IInterstellarEncoderV3.sol | 41 + flat/IMinerObject.sol | 41 + flat/IMintableERC20.sol | 8 + flat/INFTAdaptor.sol | 16 + flat/IObjectOwnership.sol | 9 + flat/ISettingsRegistry.sol | 35 + flat/ISmartToken.sol | 15 + flat/ITokenLocation.sol | 16 + flat/ITokenUse.sol | 23 + flat/ITokenVendor.sol | 32 + flat/IUserPoints.sol | 16 + flat/InterstellarEncoder.sol | 157 ++ flat/InterstellarEncoderV2.sol | 170 +++ flat/InterstellarEncoderV3.sol | 202 +++ flat/Issuing.sol | 326 +++++ flat/KtonVoter.sol | 143 ++ flat/LocationCoder.sol | 82 ++ flat/Migrations.sol | 213 +++ flat/MintAndBurnAuthority.sol | 21 + flat/MintAndBurnAuthorityV2.sol | 21 + flat/MintAndBurnMutableAuthority.sol | 104 ++ flat/MultiSigWallet.sol | 368 +++++ flat/ObjectOwnership.sol | 1269 ++++++++++++++++ flat/ObjectOwnershipAuthority.sol | 21 + flat/ObjectOwnershipAuthorityV2.sol | 23 + flat/ObjectOwnershipAuthorityV3.sol | 36 + flat/ObjectOwnershipV2.sol | 1998 ++++++++++++++++++++++++++ flat/PausableDSAuth.sol | 123 ++ flat/Proposal.sol | 32 + flat/ProposalRegistry.sol | 215 +++ flat/RBACWithAdmin.sol | 238 +++ flat/RBACWithAuth.sol | 317 ++++ flat/SettingIds.sol | 88 ++ flat/SettingsRegistry.sol | 224 +++ flat/StandardERC20Base.sol | 153 ++ flat/StandardERC223.sol | 521 +++++++ flat/StringUtil.sol | 706 +++++++++ flat/TokenBuildInGenesis.sol | 359 +++++ flat/TokenBurnDrop.sol | 331 +++++ flat/TokenController.sol | 28 + flat/TokenLocation.sol | 226 +++ flat/TokenLocationAuthority.sol | 20 + flat/TokenUse.sol | 913 ++++++++++++ flat/TokenUseAuthority.sol | 21 + flat/TokenVestingFactory.sol | 400 ++++++ flat/UserPoints.sol | 265 ++++ flat/UserPointsAuthority.sol | 20 + package.json | 9 +- 65 files changed, 13957 insertions(+), 2 deletions(-) create mode 100644 flat/ApproveAndCallFallBack.sol create mode 100644 flat/DSAuth.sol create mode 100644 flat/DeployAndTest.sol create mode 100644 flat/ERC20Container.sol create mode 100644 flat/ERC223.sol create mode 100644 flat/ERC223ReceivingContract.sol create mode 100644 flat/ERC721Adaptor.sol create mode 100644 flat/ERC721AdaptorAuthority.sol create mode 100644 flat/ERC721Bridge.sol create mode 100644 flat/ERC721Container.sol create mode 100644 flat/IActivity.sol create mode 100644 flat/IActivityObject.sol create mode 100644 flat/IAuthority.sol create mode 100644 flat/IBurnableERC20.sol create mode 100644 flat/IContainer.sol create mode 100644 flat/IInterstellarEncoder.sol create mode 100644 flat/IInterstellarEncoderV3.sol create mode 100644 flat/IMinerObject.sol create mode 100644 flat/IMintableERC20.sol create mode 100644 flat/INFTAdaptor.sol create mode 100644 flat/IObjectOwnership.sol create mode 100644 flat/ISettingsRegistry.sol create mode 100644 flat/ISmartToken.sol create mode 100644 flat/ITokenLocation.sol create mode 100644 flat/ITokenUse.sol create mode 100644 flat/ITokenVendor.sol create mode 100644 flat/IUserPoints.sol create mode 100644 flat/InterstellarEncoder.sol create mode 100644 flat/InterstellarEncoderV2.sol create mode 100644 flat/InterstellarEncoderV3.sol create mode 100644 flat/Issuing.sol create mode 100644 flat/KtonVoter.sol create mode 100644 flat/LocationCoder.sol create mode 100644 flat/Migrations.sol create mode 100644 flat/MintAndBurnAuthority.sol create mode 100644 flat/MintAndBurnAuthorityV2.sol create mode 100644 flat/MintAndBurnMutableAuthority.sol create mode 100644 flat/MultiSigWallet.sol create mode 100644 flat/ObjectOwnership.sol create mode 100644 flat/ObjectOwnershipAuthority.sol create mode 100644 flat/ObjectOwnershipAuthorityV2.sol create mode 100644 flat/ObjectOwnershipAuthorityV3.sol create mode 100644 flat/ObjectOwnershipV2.sol create mode 100644 flat/PausableDSAuth.sol create mode 100644 flat/Proposal.sol create mode 100644 flat/ProposalRegistry.sol create mode 100644 flat/RBACWithAdmin.sol create mode 100644 flat/RBACWithAuth.sol create mode 100644 flat/SettingIds.sol create mode 100644 flat/SettingsRegistry.sol create mode 100644 flat/StandardERC20Base.sol create mode 100644 flat/StandardERC223.sol create mode 100644 flat/StringUtil.sol create mode 100644 flat/TokenBuildInGenesis.sol create mode 100644 flat/TokenBurnDrop.sol create mode 100644 flat/TokenController.sol create mode 100644 flat/TokenLocation.sol create mode 100644 flat/TokenLocationAuthority.sol create mode 100644 flat/TokenUse.sol create mode 100644 flat/TokenUseAuthority.sol create mode 100644 flat/TokenVestingFactory.sol create mode 100644 flat/UserPoints.sol create mode 100644 flat/UserPointsAuthority.sol diff --git a/.gitignore b/.gitignore index 9949076..cb0164f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ contracts-flattener truffle.js truffle.config.js scripts +waffle.json +cache diff --git a/flat/ApproveAndCallFallBack.sol b/flat/ApproveAndCallFallBack.sol new file mode 100644 index 0000000..14af094 --- /dev/null +++ b/flat/ApproveAndCallFallBack.sol @@ -0,0 +1,7 @@ +// Root file: contracts/interfaces/ApproveAndCallFallBack.sol + +pragma solidity ^0.4.23; + +contract ApproveAndCallFallBack { + function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public; +} \ No newline at end of file diff --git a/flat/DSAuth.sol b/flat/DSAuth.sol new file mode 100644 index 0000000..fe663b9 --- /dev/null +++ b/flat/DSAuth.sol @@ -0,0 +1,71 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Root file: contracts/DSAuth.sol + +pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} diff --git a/flat/DeployAndTest.sol b/flat/DeployAndTest.sol new file mode 100644 index 0000000..472c18d --- /dev/null +++ b/flat/DeployAndTest.sol @@ -0,0 +1,905 @@ +// Dependency file: contracts/interfaces/ERC223ReceivingContract.sol + +// pragma solidity ^0.4.23; + + /* + * Contract that is working with ERC223 tokens + * https://github.com/ethereum/EIPs/issues/223 + */ + +/// @title ERC223ReceivingContract - Standard contract implementation for compatibility with ERC223 tokens. +contract ERC223ReceivingContract { + + /// @dev Function that is called when a user or another contract wants to transfer funds. + /// @param _from Transaction initiator, analogue of msg.sender + /// @param _value Number of tokens to transfer. + /// @param _data Data containig a function signature and/or parameters + function tokenFallback(address _from, uint256 _value, bytes _data) public; + +} + + +// Dependency file: contracts/interfaces/TokenController.sol + +// pragma solidity ^0.4.23; + + +/// @dev The token controller contract must implement these functions +contract TokenController { + /// @notice Called when `_owner` sends ether to the MiniMe Token contract + /// @param _owner The address that sent the ether to create tokens + /// @return True if the ether is accepted, false if it throws + function proxyPayment(address _owner, bytes4 sig, bytes data) payable public returns (bool); + + /// @notice Notifies the controller about a token transfer allowing the + /// controller to react if desired + /// @param _from The origin of the transfer + /// @param _to The destination of the transfer + /// @param _amount The amount of the transfer + /// @return False if the controller does not authorize the transfer + function onTransfer(address _from, address _to, uint _amount) public returns (bool); + + /// @notice Notifies the controller about an approval allowing the + /// controller to react if desired + /// @param _owner The address that calls `approve()` + /// @param _spender The spender in the `approve()` call + /// @param _amount The amount in the `approve()` call + /// @return False if the controller does not authorize the approval + function onApprove(address _owner, address _spender, uint _amount) public returns (bool); +} + + +// Dependency file: contracts/interfaces/ApproveAndCallFallBack.sol + +// pragma solidity ^0.4.23; + +contract ApproveAndCallFallBack { + function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public; +} + +// Dependency file: contracts/interfaces/ERC223.sol + +// pragma solidity ^0.4.23; + +contract ERC223 { + function transfer(address to, uint amount, bytes data) public returns (bool ok); + + function transferFrom(address from, address to, uint256 amount, bytes data) public returns (bool ok); + + event ERC223Transfer(address indexed from, address indexed to, uint amount, bytes data); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol + +// pragma solidity ^0.4.24; + + +/** + * @title SafeMath + * @dev Math operations with safety checks that throw on error + */ +library SafeMath { + + /** + * @dev Multiplies two numbers, throws on overflow. + */ + function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + // Gas optimization: this is cheaper than asserting 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 + if (_a == 0) { + return 0; + } + + c = _a * _b; + assert(c / _a == _b); + return c; + } + + /** + * @dev Integer division of two numbers, truncating the quotient. + */ + function div(uint256 _a, uint256 _b) internal pure returns (uint256) { + // assert(_b > 0); // Solidity automatically throws when dividing by 0 + // uint256 c = _a / _b; + // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold + return _a / _b; + } + + /** + * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). + */ + function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { + assert(_b <= _a); + return _a - _b; + } + + /** + * @dev Adds two numbers, throws on overflow. + */ + function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + c = _a + _b; + assert(c >= _a); + return c; + } +} + + +// Dependency file: contracts/StandardERC20Base.sol + +// pragma solidity ^0.4.23; + +// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol'; +// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; + +contract StandardERC20Base is ERC20 { + using SafeMath for uint256; + + uint256 _supply; + mapping (address => uint256) _balances; + mapping (address => mapping (address => uint256)) _approvals; + + function totalSupply() public view returns (uint) { + return _supply; + } + function balanceOf(address src) public view returns (uint) { + return _balances[src]; + } + function allowance(address src, address guy) public view returns (uint) { + return _approvals[src][guy]; + } + + function transfer(address dst, uint wad) public returns (bool) { + return transferFrom(msg.sender, dst, wad); + } + + function transferFrom(address src, address dst, uint wad) + public + returns (bool) + { + if (src != msg.sender) { + _approvals[src][msg.sender] = _approvals[src][msg.sender].sub(wad); + } + + _balances[src] = _balances[src].sub(wad); + _balances[dst] = _balances[dst].add(wad); + + emit Transfer(src, dst, wad); + + return true; + } + + function approve(address guy, uint wad) public returns (bool) { + _approvals[msg.sender][guy] = wad; + + emit Approval(msg.sender, guy, wad); + + return true; + } +} + + +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: contracts/StandardERC223.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/ERC223ReceivingContract.sol'; +// import 'contracts/interfaces/TokenController.sol'; +// import 'contracts/interfaces/ApproveAndCallFallBack.sol'; +// import 'contracts/interfaces/ERC223.sol'; +// import 'contracts/StandardERC20Base.sol'; +// import 'contracts/DSAuth.sol'; + +// This is a contract for demo and test. +contract StandardERC223 is StandardERC20Base, DSAuth, ERC223 { + event Burn(address indexed burner, uint256 value); + event Mint(address indexed to, uint256 amount); + + bytes32 public symbol; + uint256 public decimals = 18; // standard token precision. override to customize + // Optional token name + bytes32 public name = ""; + + address public controller; + + constructor(bytes32 _symbol) public { + symbol = _symbol; + controller = msg.sender; + } + + function setName(bytes32 name_) public auth { + name = name_; + } + +////////// +// Controller Methods +////////// + /// @notice Changes the controller of the contract + /// @param _newController The new controller of the contract + function changeController(address _newController) public auth { + controller = _newController; + } + + /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it + /// is approved by `_from` + /// @param _from The address holding the tokens being transferred + /// @param _to The address of the recipient + /// @param _amount The amount of tokens to be transferred + /// @return True if the transfer was successful + function transferFrom(address _from, address _to, uint256 _amount + ) public returns (bool success) { + // Alerts the token controller of the transfer + if (isContract(controller)) { + if (!TokenController(controller).onTransfer(_from, _to, _amount)) + revert(); + } + + success = super.transferFrom(_from, _to, _amount); + } + + /* + * ERC 223 + * Added support for the ERC 223 "tokenFallback" method in a "transfer" function with a payload. + */ + function transferFrom(address _from, address _to, uint256 _amount, bytes _data) + public + returns (bool success) + { + // Alerts the token controller of the transfer + if (isContract(controller)) { + if (!TokenController(controller).onTransfer(_from, _to, _amount)) + revert(); + } + + require(super.transferFrom(_from, _to, _amount)); + + if (isContract(_to)) { + ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); + receiver.tokenFallback(_from, _amount, _data); + } + + emit ERC223Transfer(_from, _to, _amount, _data); + + return true; + } + + function issue(address _to, uint256 _amount) public auth { + mint(_to, _amount); + } + + function destroy(address _from, uint256 _amount) public auth { + burn(_from, _amount); + } + + function mint(address _to, uint _amount) public auth { + _supply = _supply.add(_amount); + _balances[_to] = _balances[_to].add(_amount); + emit Mint(_to, _amount); + emit Transfer(address(0), _to, _amount); + } + + function burn(address _who, uint _value) public auth { + require(_value <= _balances[_who]); + // no need to require value <= totalSupply, since that would imply the + // sender's balance is greater than the totalSupply, which *should* be an assertion failure + + _balances[_who] = _balances[_who].sub(_value); + _supply = _supply.sub(_value); + emit Burn(_who, _value); + emit Transfer(_who, address(0), _value); + } + + /* + * ERC 223 + * Added support for the ERC 223 "tokenFallback" method in a "transfer" function with a payload. + * https://github.com/ethereum/EIPs/issues/223 + * function transfer(address _to, uint256 _value, bytes _data) public returns (bool success); + */ + /// @notice Send `_value` tokens to `_to` from `msg.sender` and trigger + /// tokenFallback if sender is a contract. + /// @dev Function that is called when a user or another contract wants to transfer funds. + /// @param _to Address of token receiver. + /// @param _amount Number of tokens to transfer. + /// @param _data Data to be sent to tokenFallback + /// @return Returns success of function call. + function transfer( + address _to, + uint256 _amount, + bytes _data) + public + returns (bool success) + { + return transferFrom(msg.sender, _to, _amount, _data); + } + + /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on + /// its behalf. This is a modified version of the ERC20 approve function + /// to be a little bit safer + /// @param _spender The address of the account able to transfer the tokens + /// @param _amount The amount of tokens to be approved for transfer + /// @return True if the approval was successful + function approve(address _spender, uint256 _amount) public returns (bool success) { + // Alerts the token controller of the approve function call + if (isContract(controller)) { + if (!TokenController(controller).onApprove(msg.sender, _spender, _amount)) + revert(); + } + + return super.approve(_spender, _amount); + } + + /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on + /// its behalf, and then a function is triggered in the contract that is + /// being approved, `_spender`. This allows users to use their tokens to + /// interact with contracts in one function call instead of two + /// @param _spender The address of the contract able to transfer the tokens + /// @param _amount The amount of tokens to be approved for transfer + /// @return True if the function call was successful + function approveAndCall(address _spender, uint256 _amount, bytes _extraData + ) public returns (bool success) { + if (!approve(_spender, _amount)) revert(); + + ApproveAndCallFallBack(_spender).receiveApproval( + msg.sender, + _amount, + this, + _extraData + ); + + return true; + } + + /// @dev Internal function to determine if an address is a contract + /// @param _addr The address being queried + /// @return True if `_addr` is a contract + function isContract(address _addr) constant internal returns(bool) { + uint size; + if (_addr == 0) return false; + assembly { + size := extcodesize(_addr) + } + return size>0; + } + + /// @notice The fallback function: If the contract's controller has not been + /// set to 0, then the `proxyPayment` method is called which relays the + /// ether and creates tokens as described in the token controller contract + function () public payable { + if (isContract(controller)) { + if (! TokenController(controller).proxyPayment.value(msg.value)(msg.sender, msg.sig, msg.data)) + revert(); + } else { + revert(); + } + } + +////////// +// Safety Methods +////////// + + /// @notice This method can be used by the owner to extract mistakenly + /// sent tokens to this contract. + /// @param _token The address of the token contract that you want to recover + /// set to 0 in case you want to extract ether. + function claimTokens(address _token) public auth { + if (_token == 0x0) { + address(msg.sender).transfer(address(this).balance); + return; + } + + ERC20 token = ERC20(_token); + uint balance = token.balanceOf(this); + token.transfer(address(msg.sender), balance); + + emit ClaimedTokens(_token, address(msg.sender), balance); + } + +//////////////// +// Events +//////////////// + + event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/SettingsRegistry.sol + +// pragma solidity ^0.4.24; + +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/DSAuth.sol"; + +/** + * @title SettingsRegistry + * @dev This contract holds all the settings for updating and querying. + */ +contract SettingsRegistry is ISettingsRegistry, DSAuth { + + mapping(bytes32 => uint256) public uintProperties; + mapping(bytes32 => string) public stringProperties; + mapping(bytes32 => address) public addressProperties; + mapping(bytes32 => bytes) public bytesProperties; + mapping(bytes32 => bool) public boolProperties; + mapping(bytes32 => int256) public intProperties; + + mapping(bytes32 => SettingsValueTypes) public valueTypes; + + function uintOf(bytes32 _propertyName) public view returns (uint256) { + require(valueTypes[_propertyName] == SettingsValueTypes.UINT, "Property type does not match."); + return uintProperties[_propertyName]; + } + + function stringOf(bytes32 _propertyName) public view returns (string) { + require(valueTypes[_propertyName] == SettingsValueTypes.STRING, "Property type does not match."); + return stringProperties[_propertyName]; + } + + function addressOf(bytes32 _propertyName) public view returns (address) { + require(valueTypes[_propertyName] == SettingsValueTypes.ADDRESS, "Property type does not match."); + return addressProperties[_propertyName]; + } + + function bytesOf(bytes32 _propertyName) public view returns (bytes) { + require(valueTypes[_propertyName] == SettingsValueTypes.BYTES, "Property type does not match."); + return bytesProperties[_propertyName]; + } + + function boolOf(bytes32 _propertyName) public view returns (bool) { + require(valueTypes[_propertyName] == SettingsValueTypes.BOOL, "Property type does not match."); + return boolProperties[_propertyName]; + } + + function intOf(bytes32 _propertyName) public view returns (int) { + require(valueTypes[_propertyName] == SettingsValueTypes.INT, "Property type does not match."); + return intProperties[_propertyName]; + } + + function setUintProperty(bytes32 _propertyName, uint _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.UINT, "Property type does not match."); + uintProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.UINT; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.UINT)); + } + + function setStringProperty(bytes32 _propertyName, string _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.STRING, "Property type does not match."); + stringProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.STRING; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.STRING)); + } + + function setAddressProperty(bytes32 _propertyName, address _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.ADDRESS, "Property type does not match."); + + addressProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.ADDRESS; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.ADDRESS)); + } + + function setBytesProperty(bytes32 _propertyName, bytes _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.BYTES, "Property type does not match."); + + bytesProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.BYTES; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.BYTES)); + } + + function setBoolProperty(bytes32 _propertyName, bool _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.BOOL, "Property type does not match."); + + boolProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.BOOL; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.BOOL)); + } + + function setIntProperty(bytes32 _propertyName, int _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.INT, "Property type does not match."); + + intProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.INT; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.INT)); + } + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint256 /* SettingsValueTypes */ ) { + return uint256(valueTypes[_propertyName]); + } + +} + +// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/Proxy.sol + +// pragma solidity ^0.4.21; + +/** + * @title Proxy + * @dev Gives the possibility to delegate any call to a foreign implementation. + */ +contract Proxy { + /** + * @dev Tells the address of the implementation where every call will be delegated. + * @return address of the implementation to which it will be delegated + */ + function implementation() public view returns (address); + + /** + * @dev Fallback function allowing to perform a delegatecall to the given implementation. + * This function will return whatever the implementation call returns + */ + function () payable public { + address _impl = implementation(); + require(_impl != address(0)); + + assembly { + let ptr := mload(0x40) + calldatacopy(ptr, 0, calldatasize) + let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0) + let size := returndatasize + returndatacopy(ptr, 0, size) + + switch result + case 0 { revert(ptr, size) } + default { return(ptr, size) } + } + } +} + + +// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/UpgradeabilityProxy.sol + +// pragma solidity ^0.4.21; + +// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/@evolutionland/upgraeability-using-unstructured-storage/contracts/Proxy.sol'; + +/** + * @title UpgradeabilityProxy + * @dev This contract represents a proxy where the implementation address to which it will delegate can be upgraded + */ +contract UpgradeabilityProxy is Proxy { + /** + * @dev This event will be emitted every time the implementation gets upgraded + * @param implementation representing the address of the upgraded implementation + */ + event Upgraded(address indexed implementation); + + // Storage position of the address of the current implementation + bytes32 private constant implementationPosition = keccak256("org.zeppelinos.proxy.implementation"); + + /** + * @dev Constructor function + */ + function UpgradeabilityProxy() public {} + + /** + * @dev Tells the address of the current implementation + * @return address of the current implementation + */ + function implementation() public view returns (address impl) { + bytes32 position = implementationPosition; + assembly { + impl := sload(position) + } + } + + /** + * @dev Sets the address of the current implementation + * @param newImplementation address representing the new implementation to be set + */ + function setImplementation(address newImplementation) internal { + bytes32 position = implementationPosition; + assembly { + sstore(position, newImplementation) + } + } + + /** + * @dev Upgrades the implementation address + * @param newImplementation representing the address of the new implementation to be set + */ + function _upgradeTo(address newImplementation) internal { + address currentImplementation = implementation(); + require(currentImplementation != newImplementation); + setImplementation(newImplementation); + emit Upgraded(newImplementation); + } +} + + +// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol + +// pragma solidity ^0.4.21; + +// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/@evolutionland/upgraeability-using-unstructured-storage/contracts/UpgradeabilityProxy.sol'; + +/** + * @title OwnedUpgradeabilityProxy + * @dev This contract combines an upgradeability proxy with basic authorization control functionalities + */ +contract OwnedUpgradeabilityProxy is UpgradeabilityProxy { + /** + * @dev Event to show ownership has been transferred + * @param previousOwner representing the address of the previous owner + * @param newOwner representing the address of the new owner + */ + event ProxyOwnershipTransferred(address previousOwner, address newOwner); + + // Storage position of the owner of the contract + bytes32 private constant proxyOwnerPosition = keccak256("org.zeppelinos.proxy.owner"); + + /** + * @dev the constructor sets the original owner of the contract to the sender account. + */ + function OwnedUpgradeabilityProxy() public { + setUpgradeabilityOwner(msg.sender); + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyProxyOwner() { + require(msg.sender == proxyOwner()); + _; + } + + /** + * @dev Tells the address of the owner + * @return the address of the owner + */ + function proxyOwner() public view returns (address owner) { + bytes32 position = proxyOwnerPosition; + assembly { + owner := sload(position) + } + } + + /** + * @dev Sets the address of the owner + */ + function setUpgradeabilityOwner(address newProxyOwner) internal { + bytes32 position = proxyOwnerPosition; + assembly { + sstore(position, newProxyOwner) + } + } + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param newOwner The address to transfer ownership to. + */ + function transferProxyOwnership(address newOwner) public onlyProxyOwner { + require(newOwner != address(0)); + emit ProxyOwnershipTransferred(proxyOwner(), newOwner); + setUpgradeabilityOwner(newOwner); + } + + /** + * @dev Allows the proxy owner to upgrade the current version of the proxy. + * @param implementation representing the address of the new implementation to be set. + */ + function upgradeTo(address implementation) public onlyProxyOwner { + _upgradeTo(implementation); + } + + /** + * @dev Allows the proxy owner to upgrade the current version of the proxy and call the new implementation + * to initialize whatever is needed through a low level call. + * @param implementation representing the address of the new implementation to be set. + * @param data represents the msg.data to bet sent in the low level call. This parameter may include the function + * signature of the implementation to be called with the needed payload + */ + function upgradeToAndCall(address implementation, bytes data) payable public onlyProxyOwner { + upgradeTo(implementation); + require(this.call.value(msg.value)(data)); + } +} + + +// Dependency file: contracts/MintAndBurnAuthority.sol + +// pragma solidity ^0.4.24; + +contract MintAndBurnAuthority { + + mapping (address => bool) public whiteList; + + constructor(address[] _whitelists) public { + for (uint i = 0; i < _whitelists.length; i ++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, address _dst, bytes4 _sig + ) public view returns (bool) { + return ( whiteList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || + ( whiteList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); + } +} + + +// Root file: contracts/DeployAndTest.sol + +pragma solidity ^0.4.23; + +// import "contracts/StandardERC223.sol"; +// import "contracts/SettingsRegistry.sol"; +// import "@evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol"; +// import "contracts/MintAndBurnAuthority.sol"; + +contract DeployAndTest { + address public testRING = new StandardERC223("RING"); + address public testKTON = new StandardERC223("KTON"); + + constructor() public { + StandardERC223(testRING).changeController(msg.sender); + StandardERC223(testKTON).changeController(msg.sender); + StandardERC223(testRING).setOwner(msg.sender); + StandardERC223(testKTON).setOwner(msg.sender); + } + +} diff --git a/flat/ERC20Container.sol b/flat/ERC20Container.sol new file mode 100644 index 0000000..e1d3e45 --- /dev/null +++ b/flat/ERC20Container.sol @@ -0,0 +1,429 @@ +// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol + +// pragma solidity ^0.4.24; + + +/** + * @title Ownable + * @dev The Ownable contract has an owner address, and provides basic authorization control + * functions, this simplifies the implementation of "user permissions". + */ +contract Ownable { + address public owner; + + + event OwnershipRenounced(address indexed previousOwner); + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + + /** + * @dev The Ownable constructor sets the original `owner` of the contract to the sender + * account. + */ + constructor() public { + owner = msg.sender; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + /** + * @dev Allows the current owner to relinquish control of the contract. + * @notice Renouncing to ownership will leave the contract without an owner. + * It will not be possible to call the functions with the `onlyOwner` + * modifier anymore. + */ + function renounceOwnership() public onlyOwner { + emit OwnershipRenounced(owner); + owner = address(0); + } + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function transferOwnership(address _newOwner) public onlyOwner { + _transferOwnership(_newOwner); + } + + /** + * @dev Transfers control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function _transferOwnership(address _newOwner) internal { + require(_newOwner != address(0)); + emit OwnershipTransferred(owner, _newOwner); + owner = _newOwner; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + + +/** + * @title ERC721 Non-Fungible Token Standard basic interface + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Basic is ERC165 { + + bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; + /* + * 0x80ac58cd === + * bytes4(keccak256('balanceOf(address)')) ^ + * bytes4(keccak256('ownerOf(uint256)')) ^ + * bytes4(keccak256('approve(address,uint256)')) ^ + * bytes4(keccak256('getApproved(uint256)')) ^ + * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ + * bytes4(keccak256('isApprovedForAll(address,address)')) ^ + * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) + */ + + bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; + /* + * 0x4f558e79 === + * bytes4(keccak256('exists(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; + /** + * 0x780e9d63 === + * bytes4(keccak256('totalSupply()')) ^ + * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ + * bytes4(keccak256('tokenByIndex(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; + /** + * 0x5b5e139f === + * bytes4(keccak256('name()')) ^ + * bytes4(keccak256('symbol()')) ^ + * bytes4(keccak256('tokenURI(uint256)')) + */ + + event Transfer( + address indexed _from, + address indexed _to, + uint256 indexed _tokenId + ); + event Approval( + address indexed _owner, + address indexed _approved, + uint256 indexed _tokenId + ); + event ApprovalForAll( + address indexed _owner, + address indexed _operator, + bool _approved + ); + + function balanceOf(address _owner) public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view returns (bool _exists); + + function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) + public view returns (address _operator); + + function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) + public view returns (bool); + + function transferFrom(address _from, address _to, uint256 _tokenId) public; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) + public; + + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public; +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Enumerable is ERC721Basic { + function totalSupply() public view returns (uint256); + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256 _tokenId); + + function tokenByIndex(uint256 _index) public view returns (uint256); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional metadata extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Metadata is ERC721Basic { + function name() external view returns (string _name); + function symbol() external view returns (string _symbol); + function tokenURI(uint256 _tokenId) public view returns (string); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, full implementation interface + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { +} + + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/interfaces/IInterstellarEncoder.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoder { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function registerNewTokenContract(address _tokenAddress) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); +} + +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Root file: contracts/ERC20Container.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/interfaces/IInterstellarEncoder.sol"; +// import "contracts/SettingIds.sol"; + +contract ERC20Container is Ownable, SettingIds { + ISettingsRegistry public registry; + + // token ids must follow the standard of interstellar encoding + mapping(uint256 => mapping(address=>uint256)) public fungibleTokensInContainer; + + bool private singletonLock = false; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + constructor () public { + // initializeContract(); + } + + /** + * @dev Same with constructor, but is used and called by storage proxy as logic contract. + */ + function initializeContract(address _registry) public singletonLockCall { + // Ownable constructor + owner = msg.sender; + + registry = ISettingsRegistry(_registry); + } +} \ No newline at end of file diff --git a/flat/ERC223.sol b/flat/ERC223.sol new file mode 100644 index 0000000..03d02f9 --- /dev/null +++ b/flat/ERC223.sol @@ -0,0 +1,11 @@ +// Root file: contracts/interfaces/ERC223.sol + +pragma solidity ^0.4.23; + +contract ERC223 { + function transfer(address to, uint amount, bytes data) public returns (bool ok); + + function transferFrom(address from, address to, uint256 amount, bytes data) public returns (bool ok); + + event ERC223Transfer(address indexed from, address indexed to, uint amount, bytes data); +} diff --git a/flat/ERC223ReceivingContract.sol b/flat/ERC223ReceivingContract.sol new file mode 100644 index 0000000..9d20bf0 --- /dev/null +++ b/flat/ERC223ReceivingContract.sol @@ -0,0 +1,19 @@ +// Root file: contracts/interfaces/ERC223ReceivingContract.sol + +pragma solidity ^0.4.23; + + /* + * Contract that is working with ERC223 tokens + * https://github.com/ethereum/EIPs/issues/223 + */ + +/// @title ERC223ReceivingContract - Standard contract implementation for compatibility with ERC223 tokens. +contract ERC223ReceivingContract { + + /// @dev Function that is called when a user or another contract wants to transfer funds. + /// @param _from Transaction initiator, analogue of msg.sender + /// @param _value Number of tokens to transfer. + /// @param _data Data containig a function signature and/or parameters + function tokenFallback(address _from, uint256 _value, bytes _data) public; + +} diff --git a/flat/ERC721Adaptor.sol b/flat/ERC721Adaptor.sol new file mode 100644 index 0000000..c00d406 --- /dev/null +++ b/flat/ERC721Adaptor.sol @@ -0,0 +1,564 @@ +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: contracts/PausableDSAuth.sol + +// pragma solidity ^0.4.24; + +// import "contracts/DSAuth.sol"; + + +/** + * @title Pausable + * @dev Base contract which allows children to implement an emergency stop mechanism. + */ +contract PausableDSAuth is DSAuth { + event Pause(); + event Unpause(); + + bool public paused = false; + + + /** + * @dev Modifier to make a function callable only when the contract is not paused. + */ + modifier whenNotPaused() { + require(!paused); + _; + } + + /** + * @dev Modifier to make a function callable only when the contract is paused. + */ + modifier whenPaused() { + require(paused); + _; + } + + /** + * @dev called by the owner to pause, triggers stopped state + */ + function pause() public onlyOwner whenNotPaused { + paused = true; + emit Pause(); + } + + /** + * @dev called by the owner to unpause, returns to normal state + */ + function unpause() public onlyOwner whenPaused { + paused = false; + emit Unpause(); + } +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/interfaces/INFTAdaptor.sol + +// pragma solidity ^0.4.24; + + +contract INFTAdaptor { + function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); + + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); + + function approveOriginToken(address _bridge, uint256 _originTokenId) public; + + function ownerInOrigin(uint256 _originTokenId) public view returns (address); + + function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public; +} + + +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + + +/** + * @title ERC721 Non-Fungible Token Standard basic interface + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Basic is ERC165 { + + bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; + /* + * 0x80ac58cd === + * bytes4(keccak256('balanceOf(address)')) ^ + * bytes4(keccak256('ownerOf(uint256)')) ^ + * bytes4(keccak256('approve(address,uint256)')) ^ + * bytes4(keccak256('getApproved(uint256)')) ^ + * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ + * bytes4(keccak256('isApprovedForAll(address,address)')) ^ + * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) + */ + + bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; + /* + * 0x4f558e79 === + * bytes4(keccak256('exists(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; + /** + * 0x780e9d63 === + * bytes4(keccak256('totalSupply()')) ^ + * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ + * bytes4(keccak256('tokenByIndex(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; + /** + * 0x5b5e139f === + * bytes4(keccak256('name()')) ^ + * bytes4(keccak256('symbol()')) ^ + * bytes4(keccak256('tokenURI(uint256)')) + */ + + event Transfer( + address indexed _from, + address indexed _to, + uint256 indexed _tokenId + ); + event Approval( + address indexed _owner, + address indexed _approved, + uint256 indexed _tokenId + ); + event ApprovalForAll( + address indexed _owner, + address indexed _operator, + bool _approved + ); + + function balanceOf(address _owner) public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view returns (bool _exists); + + function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) + public view returns (address _operator); + + function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) + public view returns (bool); + + function transferFrom(address _from, address _to, uint256 _tokenId) public; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) + public; + + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public; +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Enumerable is ERC721Basic { + function totalSupply() public view returns (uint256); + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256 _tokenId); + + function tokenByIndex(uint256 _index) public view returns (uint256); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional metadata extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Metadata is ERC721Basic { + function name() external view returns (string _name); + function symbol() external view returns (string _symbol); + function tokenURI(uint256 _tokenId) public view returns (string); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, full implementation interface + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { +} + + +// Dependency file: contracts/interfaces/IInterstellarEncoderV3.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoderV3 { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function encodeTokenIdForOuterObjectContract( + address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); + + function getProducerId(uint256 _tokenId) public view returns (uint16); + + function getOriginAddress(uint256 _tokenId) public view returns (address); + +} + +// Root file: contracts/ERC721Adaptor.sol + +pragma solidity ^0.4.24; + +// import "contracts/SettingIds.sol"; +// import "contracts/PausableDSAuth.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/interfaces/INFTAdaptor.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +// import "contracts/interfaces/IInterstellarEncoderV3.sol"; + + +contract ERC721Adaptor is PausableDSAuth, SettingIds { + + /* + * Storage + */ + bool private singletonLock = false; + + uint16 public producerId; + + uint8 public convertType; + + ISettingsRegistry public registry; + + ERC721 public originNft; + + // tokenId_outside_evolutionLand => tokenId_inside + mapping(uint256 => uint256) public cachedOriginId2MirrorId; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract(ISettingsRegistry _registry, ERC721 _originNft, uint16 _producerId) public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + registry = _registry; + originNft = _originNft; + producerId = _producerId; + + convertType = 128; // f(x) = x,fullfill with zero at left side. + } + + + function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256) { + if (cachedOriginId2MirrorId[_originTokenId] > 0) { + return cachedOriginId2MirrorId[_originTokenId]; + } + + uint128 mirrorObjectId = uint128(_originTokenId & 0xffffffffffffffffffffffffffffffff); + + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + uint256 mirrorTokenId = interstellarEncoder.encodeTokenIdForOuterObjectContract( + petBase, objectOwnership, address(originNft), mirrorObjectId, producerId, convertType); + + return mirrorTokenId; + } + + function ownerInOrigin(uint256 _originTokenId) public view returns (address) { + return ERC721(originNft).ownerOf(_originTokenId); + } + + // if the convertion is not calculatable, and need to use cache mapping in Bridge. + // then .. + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256) { + return (_mirrorTokenId & 0xffffffffffffffffffffffffffffffff); + } + + function approveToBridge(address _bridge) public onlyOwner { + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + ERC721(objectOwnership).setApprovalForAll(_bridge, true); + } + + function cancelApprove(address _bridge) public onlyOwner { + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + ERC721(objectOwnership).setApprovalForAll(_bridge, false); + } + + function getObjectClass(uint256 _originTokenId) public view returns (uint8) { + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + uint256 mirrorTokenId = toMirrorTokenId(_originTokenId); + return interstellarEncoder.getObjectClass(mirrorTokenId); + } + + function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public auth { + cachedOriginId2MirrorId[_originTokenId] = _mirrorTokenId; + } +} diff --git a/flat/ERC721AdaptorAuthority.sol b/flat/ERC721AdaptorAuthority.sol new file mode 100644 index 0000000..be8e0f6 --- /dev/null +++ b/flat/ERC721AdaptorAuthority.sol @@ -0,0 +1,20 @@ +// Root file: contracts/ERC721AdaptorAuthority.sol + +pragma solidity ^0.4.24; + +contract ERC721AdaptorAuthority { + mapping (address => bool) public whiteList; + + constructor(address[] _whitelists) public { + for (uint i = 0; i < _whitelists.length; i++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, address _dst, bytes4 _sig + ) public view returns (bool) { + return ( whiteList[_src] && _sig == bytes4(keccak256("approveOriginToken(address,uint256)")) ) + || ( whiteList[_src] && _sig == bytes4(keccak256("cacheMirrorTokenId(uint256,uint256)")) ); + } +} \ No newline at end of file diff --git a/flat/ERC721Bridge.sol b/flat/ERC721Bridge.sol new file mode 100644 index 0000000..5072107 --- /dev/null +++ b/flat/ERC721Bridge.sol @@ -0,0 +1,654 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: contracts/PausableDSAuth.sol + +// pragma solidity ^0.4.24; + +// import "contracts/DSAuth.sol"; + + +/** + * @title Pausable + * @dev Base contract which allows children to implement an emergency stop mechanism. + */ +contract PausableDSAuth is DSAuth { + event Pause(); + event Unpause(); + + bool public paused = false; + + + /** + * @dev Modifier to make a function callable only when the contract is not paused. + */ + modifier whenNotPaused() { + require(!paused); + _; + } + + /** + * @dev Modifier to make a function callable only when the contract is paused. + */ + modifier whenPaused() { + require(paused); + _; + } + + /** + * @dev called by the owner to pause, triggers stopped state + */ + function pause() public onlyOwner whenNotPaused { + paused = true; + emit Pause(); + } + + /** + * @dev called by the owner to unpause, returns to normal state + */ + function unpause() public onlyOwner whenPaused { + paused = false; + emit Unpause(); + } +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Dependency file: contracts/interfaces/IInterstellarEncoderV3.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoderV3 { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function encodeTokenIdForOuterObjectContract( + address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); + + function getProducerId(uint256 _tokenId) public view returns (uint16); + + function getOriginAddress(uint256 _tokenId) public view returns (address); + +} + +// Dependency file: contracts/interfaces/IMintableERC20.sol + +// pragma solidity ^0.4.23; + +contract IMintableERC20 { + + function mint(address _to, uint256 _value) public; +} + +// Dependency file: contracts/interfaces/INFTAdaptor.sol + +// pragma solidity ^0.4.24; + + +contract INFTAdaptor { + function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); + + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); + + function approveOriginToken(address _bridge, uint256 _originTokenId) public; + + function ownerInOrigin(uint256 _originTokenId) public view returns (address); + + function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public; +} + + +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + + +/** + * @title ERC721 Non-Fungible Token Standard basic interface + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Basic is ERC165 { + + bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; + /* + * 0x80ac58cd === + * bytes4(keccak256('balanceOf(address)')) ^ + * bytes4(keccak256('ownerOf(uint256)')) ^ + * bytes4(keccak256('approve(address,uint256)')) ^ + * bytes4(keccak256('getApproved(uint256)')) ^ + * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ + * bytes4(keccak256('isApprovedForAll(address,address)')) ^ + * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) + */ + + bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; + /* + * 0x4f558e79 === + * bytes4(keccak256('exists(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; + /** + * 0x780e9d63 === + * bytes4(keccak256('totalSupply()')) ^ + * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ + * bytes4(keccak256('tokenByIndex(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; + /** + * 0x5b5e139f === + * bytes4(keccak256('name()')) ^ + * bytes4(keccak256('symbol()')) ^ + * bytes4(keccak256('tokenURI(uint256)')) + */ + + event Transfer( + address indexed _from, + address indexed _to, + uint256 indexed _tokenId + ); + event Approval( + address indexed _owner, + address indexed _approved, + uint256 indexed _tokenId + ); + event ApprovalForAll( + address indexed _owner, + address indexed _operator, + bool _approved + ); + + function balanceOf(address _owner) public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view returns (bool _exists); + + function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) + public view returns (address _operator); + + function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) + public view returns (bool); + + function transferFrom(address _from, address _to, uint256 _tokenId) public; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) + public; + + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public; +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Enumerable is ERC721Basic { + function totalSupply() public view returns (uint256); + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256 _tokenId); + + function tokenByIndex(uint256 _index) public view returns (uint256); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional metadata extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Metadata is ERC721Basic { + function name() external view returns (string _name); + function symbol() external view returns (string _symbol); + function tokenURI(uint256 _tokenId) public view returns (string); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, full implementation interface + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { +} + + +// Root file: contracts/ERC721Bridge.sol + +pragma solidity ^0.4.23; + +// import "contracts/PausableDSAuth.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/SettingIds.sol"; +// import "contracts/interfaces/IInterstellarEncoderV3.sol"; +// import "contracts/interfaces/IMintableERC20.sol"; +// import "contracts/interfaces/INFTAdaptor.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; + + +/* + * naming convention: + * originTokenId - token outside evolutionLand + * mirrorTokenId - mirror token + */ +contract ERC721Bridge is SettingIds, PausableDSAuth { + + /* + * Storage + */ + bool private singletonLock = false; + + ISettingsRegistry public registry; + + + // originNFTContract => its adator + // for instance, CryptoKitties => CryptoKittiesAdaptor + // this need to be registered by owner + mapping(address => address) public originNFT2Adaptor; + + // tokenId_inside => tokenId_outside + mapping(uint256 => uint256) public mirrorId2OriginId; + + /* + * Event + */ + event BridgeIn(uint256 originTokenId, uint256 mirrorTokenId, address originContract, address adaptorAddress, address owner); + + event SwapIn(uint256 originTokenId, uint256 mirrorTokenId, address owner); + event SwapOut(uint256 originTokenId, uint256 mirrorTokenId, address owner); + + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract(ISettingsRegistry _registry) public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + registry = _registry; + } + + function registerAdaptor(address _originNftAddress, address _erc721Adaptor) public whenNotPaused onlyOwner { + originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; + } + + // used by PetBase + function bridgeInAuth(address _originNftAddress, uint256 _originTokenId, address _owner) public auth returns (uint256) { + return _bridgeIn(_originNftAddress, _originTokenId, _owner); + } + + + // generate new mirror token without origin token frozen + function bridgeIn(address _originNftAddress, uint256 _originTokenId) public returns (uint256) { + _bridgeIn(_originNftAddress, _originTokenId, msg.sender); + } + + function _bridgeIn(address _originNftAddress, uint256 _originTokenId, address _owner) internal returns (uint256) { + address adaptor = originNFT2Adaptor[_originNftAddress]; + require(adaptor != address(0), "Not registered!"); + + require(INFTAdaptor(adaptor).ownerInOrigin(_originTokenId) == _owner, "Invalid owner!"); + + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); + + // if it is the first time to bridge in + if (!isBridged(mirrorTokenId)) { + // keep new mirror object in this contract + // before the owner has transferred his/her outerObject into this contract + // mirror object can not be transferred + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); + + // link objects_in and objects_out + INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); + } + + return mirrorTokenId; + } + + // freeze origin token to free mirror token + function swapIn(address _originNftAddress, uint256 _originTokenId) public { + require(ERC721(_originNftAddress).ownerOf(_originTokenId) == msg.sender, "Invalid owner!"); + + address adaptor = originNFT2Adaptor[_originNftAddress]; + require(adaptor != address(0), "Not registered!"); + + // all specific originTokens are kept in bridge + ERC721(_originNftAddress).transferFrom(msg.sender, address(this), _originTokenId); + + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + ERC721(objectOwnership).transferFrom(address(this), msg.sender, mirrorTokenId); + + emit SwapIn(_originTokenId, mirrorTokenId, msg.sender); + } + + function bridgeAndSwapIn(address _originNftAddress, uint256 _originTokenId) public { + bridgeIn(_originNftAddress, _originTokenId); + swapIn(_originNftAddress, _originTokenId); + } + + function swapOut(uint256 _mirrorTokenId) public { + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); + require(nftContract != address(0), "No such NFT contract"); + address adaptor = originNFT2Adaptor[nftContract]; + require(adaptor != address(0), "not registered!"); + require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); + + // TODO: if it is needed to check its current status + uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); + ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); + + emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); + } + + function approveOriginToken(address _originNFT, address _approved, uint256 _originTokenId) public auth { + ERC721(_originNFT).approve(_approved, _originTokenId); + } + + function ownerOf(uint256 _mirrorTokenId) public view returns (address) { + return ownerOfMirror(_mirrorTokenId); + } + + // return human owner of the token + function mirrorOfOrigin(address _originNFT, uint256 _originTokenId) public view returns (uint256) { + INFTAdaptor adapter = INFTAdaptor(originNFT2Adaptor[_originNFT]); + + return adapter.toMirrorTokenId(_originTokenId); + } + + // return human owner of the token + function ownerOfMirror(uint256 _mirrorTokenId) public view returns (address) { + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + address owner = ERC721(objectOwnership).ownerOf(_mirrorTokenId); + if(owner != address(this)) { + return owner; + } else { + uint originTokenId = mirrorId2OriginId[_mirrorTokenId]; + return INFTAdaptor(originNFT2Adaptor[originOwnershipAddress(_mirrorTokenId)]).ownerInOrigin(originTokenId); + } + } + + function originOwnershipAddress(uint256 _mirrorTokenId) public view returns (address) { + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + + return interstellarEncoder.getOriginAddress(_mirrorTokenId); + } + + function isBridged(uint256 _mirrorTokenId) public view returns (bool) { + return (mirrorId2OriginId[_mirrorTokenId] != 0); + } +} diff --git a/flat/ERC721Container.sol b/flat/ERC721Container.sol new file mode 100644 index 0000000..2e9c802 --- /dev/null +++ b/flat/ERC721Container.sol @@ -0,0 +1,522 @@ +// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol + +// pragma solidity ^0.4.24; + + +/** + * @title Ownable + * @dev The Ownable contract has an owner address, and provides basic authorization control + * functions, this simplifies the implementation of "user permissions". + */ +contract Ownable { + address public owner; + + + event OwnershipRenounced(address indexed previousOwner); + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + + /** + * @dev The Ownable constructor sets the original `owner` of the contract to the sender + * account. + */ + constructor() public { + owner = msg.sender; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + /** + * @dev Allows the current owner to relinquish control of the contract. + * @notice Renouncing to ownership will leave the contract without an owner. + * It will not be possible to call the functions with the `onlyOwner` + * modifier anymore. + */ + function renounceOwnership() public onlyOwner { + emit OwnershipRenounced(owner); + owner = address(0); + } + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function transferOwnership(address _newOwner) public onlyOwner { + _transferOwnership(_newOwner); + } + + /** + * @dev Transfers control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function _transferOwnership(address _newOwner) internal { + require(_newOwner != address(0)); + emit OwnershipTransferred(owner, _newOwner); + owner = _newOwner; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + + +/** + * @title ERC721 Non-Fungible Token Standard basic interface + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Basic is ERC165 { + + bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; + /* + * 0x80ac58cd === + * bytes4(keccak256('balanceOf(address)')) ^ + * bytes4(keccak256('ownerOf(uint256)')) ^ + * bytes4(keccak256('approve(address,uint256)')) ^ + * bytes4(keccak256('getApproved(uint256)')) ^ + * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ + * bytes4(keccak256('isApprovedForAll(address,address)')) ^ + * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) + */ + + bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; + /* + * 0x4f558e79 === + * bytes4(keccak256('exists(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; + /** + * 0x780e9d63 === + * bytes4(keccak256('totalSupply()')) ^ + * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ + * bytes4(keccak256('tokenByIndex(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; + /** + * 0x5b5e139f === + * bytes4(keccak256('name()')) ^ + * bytes4(keccak256('symbol()')) ^ + * bytes4(keccak256('tokenURI(uint256)')) + */ + + event Transfer( + address indexed _from, + address indexed _to, + uint256 indexed _tokenId + ); + event Approval( + address indexed _owner, + address indexed _approved, + uint256 indexed _tokenId + ); + event ApprovalForAll( + address indexed _owner, + address indexed _operator, + bool _approved + ); + + function balanceOf(address _owner) public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view returns (bool _exists); + + function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) + public view returns (address _operator); + + function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) + public view returns (bool); + + function transferFrom(address _from, address _to, uint256 _tokenId) public; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) + public; + + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public; +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Enumerable is ERC721Basic { + function totalSupply() public view returns (uint256); + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256 _tokenId); + + function tokenByIndex(uint256 _index) public view returns (uint256); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional metadata extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Metadata is ERC721Basic { + function name() external view returns (string _name); + function symbol() external view returns (string _symbol); + function tokenURI(uint256 _tokenId) public view returns (string); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, full implementation interface + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { +} + + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/interfaces/IInterstellarEncoder.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoder { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function registerNewTokenContract(address _tokenAddress) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); +} + +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Root file: contracts/ERC721Container.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/interfaces/IInterstellarEncoder.sol"; +// import "contracts/SettingIds.sol"; + +contract ERC721Container is Ownable, SettingIds { + ISettingsRegistry public registry; + + // token ids must follow the standard of interstellar encoding + mapping(uint256 => uint256[]) public objectsInContainer; + + mapping(uint256 => uint256) public object2Container; + + mapping(uint256 => uint256) public object2IndexInContainer; + + bool private singletonLock = false; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + constructor () public { + // initializeContract(); + } + + /** + * @dev Same with constructor, but is used and called by storage proxy as logic contract. + */ + function initializeContract(address _registry) public singletonLockCall { + // Ownable constructor + owner = msg.sender; + + registry = ISettingsRegistry(_registry); + } + + function contains(uint256 _containerTokenId, uint256 _objectTokenId) public view returns (bool) { + require(_containerTokenId > 0, "Token Id should large than zero."); + + return object2Container[_objectTokenId] == _containerTokenId; + } + + + // TODO: does the add operation require the container's owner agree to? + function addToContainer(uint256 _containerTokenId, uint256 _objectTokenId) public { + // make sure this object is not already in container. + require(object2Container[_objectTokenId] == 0, "Object Token can not be in container."); + require(_containerTokenId > 0, "Token Id should large than zero."); + + address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); + require(interstellarEncoder != address(0), "Contract Interstellar Encoder does not exist."); + + address containerTokenAddress = IInterstellarEncoder(interstellarEncoder).getContractAddress(_containerTokenId); + require(containerTokenAddress != address(0), "Container token contract is not registered."); + address objectTokenAddress = IInterstellarEncoder(interstellarEncoder).getContractAddress(_objectTokenId); + require(objectTokenAddress != address(0), "Object token contract is not registered."); + + address objectOwner = ERC721(objectTokenAddress).ownerOf(_objectTokenId); + // requires approve first. + ERC721(objectTokenAddress).transferFrom(objectOwner, address(this), _objectTokenId); + + // update belongs mappings. + + objectsInContainer[_containerTokenId].push(_objectTokenId); + + object2Container[_objectTokenId] = _containerTokenId; + object2IndexInContainer[_objectTokenId] = objectsInContainer[_containerTokenId].length - 1; + + } + + function transferToOtherContainer(uint256 _objectTokenId, uint256 _toContainer) public { + + } + + function transferToAddress(uint256 _objectTokenId, address _receiver) public { + (address _topOwner, address _topApproved) = getTopContainerOwnerAndApproved(_objectTokenId); + + address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); + require(interstellarEncoder != address(0), "Contract Interstellar Encoder does not exist."); + + address objectTokenAddress = IInterstellarEncoder(interstellarEncoder).getContractAddress(_objectTokenId); + require(objectTokenAddress != address(0), "Object token contract is not registered."); + + if(_topOwner == msg.sender || _topApproved == msg.sender) { + ERC721(objectTokenAddress).transferFrom(address(this), _receiver, _objectTokenId); + } + + // Reorg index array in objectsInContainer + uint256 objectIndex = object2IndexInContainer[_objectTokenId]; + uint256 lastObjectIndex = objectsInContainer[object2Container[_objectTokenId]].length - 1; + uint256 lastObjectId = objectsInContainer[object2Container[_objectTokenId]][lastObjectIndex]; + + objectsInContainer[object2Container[_objectTokenId]][objectIndex] = lastObjectId; + objectsInContainer[object2Container[_objectTokenId]][lastObjectIndex] = 0; + + objectsInContainer[object2Container[_objectTokenId]].length --; + object2IndexInContainer[lastObjectId] = objectIndex; + + delete object2Container[_objectTokenId]; + delete object2IndexInContainer[_objectTokenId]; + } + + function getTopContainerOwnerAndApproved(uint256 _objectTokenId) public view returns (address _owner, address _approved) { + // make sure this object is already in container. + require(object2Container[_objectTokenId] > 0, "Object Token can not be in container."); + // recursive check to get authorized addresses to transfer. + uint256 _topContainerTokenId = object2Container[_objectTokenId]; + while(object2Container[_topContainerTokenId] > 0) { + _topContainerTokenId = object2Container[_topContainerTokenId]; + } + + address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); + require(interstellarEncoder != address(0), "Contract Interstellar Encoder does not exist."); + + _owner = ERC721(IInterstellarEncoder(interstellarEncoder).getContractAddress(_topContainerTokenId)).ownerOf(_topContainerTokenId); + _approved = ERC721(IInterstellarEncoder(interstellarEncoder).getContractAddress(_topContainerTokenId)) + .getApproved(_topContainerTokenId); + } + + function isContainer(uint256 _containerTokenId) public view returns (bool) { + require(_containerTokenId > 0, "Token Id should large than zero."); + + return objectsInContainer[_containerTokenId].length > 0; + } +} diff --git a/flat/IActivity.sol b/flat/IActivity.sol new file mode 100644 index 0000000..856ae03 --- /dev/null +++ b/flat/IActivity.sol @@ -0,0 +1,39 @@ +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Root file: contracts/interfaces/IActivity.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + +contract IActivity is ERC165 { + bytes4 internal constant InterfaceId_IActivity = 0x6086e7f8; + /* + * 0x6086e7f8 === + * bytes4(keccak256('activityStopped(uint256)')) + */ + + function activityStopped(uint256 _tokenId) public; +} \ No newline at end of file diff --git a/flat/IActivityObject.sol b/flat/IActivityObject.sol new file mode 100644 index 0000000..236047b --- /dev/null +++ b/flat/IActivityObject.sol @@ -0,0 +1,42 @@ +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Root file: contracts/interfaces/IActivityObject.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + +contract IActivityObject is ERC165 { + bytes4 internal constant InterfaceId_IActivityObject = 0x2b9eccc6; + /* + * 0x2b9eccc6 === + * bytes4(keccak256('activityAdded(uint256,address,address)')) ^ + * bytes4(keccak256('activityRemoved(uint256,address,address)')) + */ + + function activityAdded(uint256 _tokenId, address _activity, address _user) public; + + function activityRemoved(uint256 _tokenId, address _activity, address _user) public; +} \ No newline at end of file diff --git a/flat/IAuthority.sol b/flat/IAuthority.sol new file mode 100644 index 0000000..111fe9f --- /dev/null +++ b/flat/IAuthority.sol @@ -0,0 +1,9 @@ +// Root file: contracts/interfaces/IAuthority.sol + +pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} \ No newline at end of file diff --git a/flat/IBurnableERC20.sol b/flat/IBurnableERC20.sol new file mode 100644 index 0000000..c7a38e0 --- /dev/null +++ b/flat/IBurnableERC20.sol @@ -0,0 +1,7 @@ +// Root file: contracts/interfaces/IBurnableERC20.sol + +pragma solidity ^0.4.23; + +contract IBurnableERC20 { + function burn(address _from, uint _value) public; +} \ No newline at end of file diff --git a/flat/IContainer.sol b/flat/IContainer.sol new file mode 100644 index 0000000..22f47b9 --- /dev/null +++ b/flat/IContainer.sol @@ -0,0 +1,8 @@ +// Root file: contracts/interfaces/IContainer.sol + +pragma solidity ^0.4.23; + +contract IContainer { + // TODO, using the iter-stella objects encoding ids. + +} \ No newline at end of file diff --git a/flat/IInterstellarEncoder.sol b/flat/IInterstellarEncoder.sol new file mode 100644 index 0000000..c785c2d --- /dev/null +++ b/flat/IInterstellarEncoder.sol @@ -0,0 +1,35 @@ +// Root file: contracts/interfaces/IInterstellarEncoder.sol + +pragma solidity ^0.4.24; + +contract IInterstellarEncoder { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function registerNewTokenContract(address _tokenAddress) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); +} \ No newline at end of file diff --git a/flat/IInterstellarEncoderV3.sol b/flat/IInterstellarEncoderV3.sol new file mode 100644 index 0000000..39af983 --- /dev/null +++ b/flat/IInterstellarEncoderV3.sol @@ -0,0 +1,41 @@ +// Root file: contracts/interfaces/IInterstellarEncoderV3.sol + +pragma solidity ^0.4.24; + +contract IInterstellarEncoderV3 { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function encodeTokenIdForOuterObjectContract( + address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); + + function getProducerId(uint256 _tokenId) public view returns (uint16); + + function getOriginAddress(uint256 _tokenId) public view returns (address); + +} \ No newline at end of file diff --git a/flat/IMinerObject.sol b/flat/IMinerObject.sol new file mode 100644 index 0000000..2ef5f9d --- /dev/null +++ b/flat/IMinerObject.sol @@ -0,0 +1,41 @@ +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Root file: contracts/interfaces/IMinerObject.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + +contract IMinerObject is ERC165 { + bytes4 internal constant InterfaceId_IMinerObject = 0x64272b75; + + /* + * 0x64272b752 === + * bytes4(keccak256('strengthOf(uint256,address)')) + */ + + function strengthOf(uint256 _tokenId, address _resourceToken, uint256 _landTokenId) public view returns (uint256); + +} \ No newline at end of file diff --git a/flat/IMintableERC20.sol b/flat/IMintableERC20.sol new file mode 100644 index 0000000..da28029 --- /dev/null +++ b/flat/IMintableERC20.sol @@ -0,0 +1,8 @@ +// Root file: contracts/interfaces/IMintableERC20.sol + +pragma solidity ^0.4.23; + +contract IMintableERC20 { + + function mint(address _to, uint256 _value) public; +} \ No newline at end of file diff --git a/flat/INFTAdaptor.sol b/flat/INFTAdaptor.sol new file mode 100644 index 0000000..3ad3ae5 --- /dev/null +++ b/flat/INFTAdaptor.sol @@ -0,0 +1,16 @@ +// Root file: contracts/interfaces/INFTAdaptor.sol + +pragma solidity ^0.4.24; + + +contract INFTAdaptor { + function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); + + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); + + function approveOriginToken(address _bridge, uint256 _originTokenId) public; + + function ownerInOrigin(uint256 _originTokenId) public view returns (address); + + function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public; +} diff --git a/flat/IObjectOwnership.sol b/flat/IObjectOwnership.sol new file mode 100644 index 0000000..a8bc07e --- /dev/null +++ b/flat/IObjectOwnership.sol @@ -0,0 +1,9 @@ +// Root file: contracts/interfaces/IObjectOwnership.sol + +pragma solidity ^0.4.24; + +contract IObjectOwnership { + function mintObject(address _to, uint128 _objectId) public returns (uint256 _tokenId); + + function burnObject(address _to, uint128 _objectId) public returns (uint256 _tokenId); +} \ No newline at end of file diff --git a/flat/ISettingsRegistry.sol b/flat/ISettingsRegistry.sol new file mode 100644 index 0000000..a778a98 --- /dev/null +++ b/flat/ISettingsRegistry.sol @@ -0,0 +1,35 @@ +// Root file: contracts/interfaces/ISettingsRegistry.sol + +pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} \ No newline at end of file diff --git a/flat/ISmartToken.sol b/flat/ISmartToken.sol new file mode 100644 index 0000000..315dc5e --- /dev/null +++ b/flat/ISmartToken.sol @@ -0,0 +1,15 @@ +// Root file: contracts/interfaces/ISmartToken.sol + +pragma solidity ^0.4.23; + +/* + Smart Token interface +*/ +contract ISmartToken { + function transferOwnership(address _newOwner) public; + function acceptOwnership() public; + + function disableTransfers(bool _disable) public; + function issue(address _to, uint256 _amount) public; + function destroy(address _from, uint256 _amount) public; +} \ No newline at end of file diff --git a/flat/ITokenLocation.sol b/flat/ITokenLocation.sol new file mode 100644 index 0000000..89b6547 --- /dev/null +++ b/flat/ITokenLocation.sol @@ -0,0 +1,16 @@ +// Root file: contracts/interfaces/ITokenLocation.sol + +pragma solidity ^0.4.24; + +contract ITokenLocation { + + function hasLocation(uint256 _tokenId) public view returns (bool); + + function getTokenLocation(uint256 _tokenId) public view returns (int, int); + + function setTokenLocation(uint256 _tokenId, int _x, int _y) public; + + function getTokenLocationHM(uint256 _tokenId) public view returns (int, int); + + function setTokenLocationHM(uint256 _tokenId, int _x, int _y) public; +} \ No newline at end of file diff --git a/flat/ITokenUse.sol b/flat/ITokenUse.sol new file mode 100644 index 0000000..95e47bc --- /dev/null +++ b/flat/ITokenUse.sol @@ -0,0 +1,23 @@ +// Root file: contracts/interfaces/ITokenUse.sol + +pragma solidity ^0.4.24; + +contract ITokenUse { + uint48 public constant MAX_UINT48_TIME = 281474976710655; + + function isObjectInHireStage(uint256 _tokenId) public view returns (bool); + + function isObjectReadyToUse(uint256 _tokenId) public view returns (bool); + + function getTokenUser(uint256 _tokenId) public view returns (address); + + function createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public; + + function cancelTokenUseOffer(uint256 _tokenId) public; + + function takeTokenUseOffer(uint256 _tokenId) public; + + function addActivity(uint256 _tokenId, address _user, uint256 _endTime) public; + + function removeActivity(uint256 _tokenId, address _user) public; +} \ No newline at end of file diff --git a/flat/ITokenVendor.sol b/flat/ITokenVendor.sol new file mode 100644 index 0000000..1652029 --- /dev/null +++ b/flat/ITokenVendor.sol @@ -0,0 +1,32 @@ +// Root file: contracts/interfaces/ITokenVendor.sol + +pragma solidity ^0.4.23; + +contract ITokenVendor { + + + function buyTokenRate() public view returns (uint256); + + function sellTokenRate() public returns (uint256); + + function totalBuyTokenTransfered() public returns (uint256); + + function totalBuyEtherCollected() public returns (uint256); + + function totalSellEthTransfered() public returns (uint256); + + function totalSellTokenCollected() public returns (uint256); + + function tokenFallback(address _from, uint256 _value, bytes _data) public; + + function buyToken(address _th) public payable returns (bool); + + function sellToken(address _th, uint256 _value) public returns (bool); + + function changeBuyTokenRate(uint256 _newBuyTokenRate) public; + + function changeSellTokenRate(uint256 _newSellTokenRate) public; + + function claimTokens(address _token) public; + +} \ No newline at end of file diff --git a/flat/IUserPoints.sol b/flat/IUserPoints.sol new file mode 100644 index 0000000..e70491f --- /dev/null +++ b/flat/IUserPoints.sol @@ -0,0 +1,16 @@ +// Root file: contracts/interfaces/IUserPoints.sol + +pragma solidity ^0.4.24; + +contract IUserPoints { + event AddedPoints(address indexed user, uint256 pointAmount); + event SubedPoints(address indexed user, uint256 pointAmount); + + function addPoints(address _user, uint256 _pointAmount) public; + + function subPoints(address _user, uint256 _pointAmount) public; + + function pointsSupply() public view returns (uint256); + + function pointsBalanceOf(address _user) public view returns (uint256); +} diff --git a/flat/InterstellarEncoder.sol b/flat/InterstellarEncoder.sol new file mode 100644 index 0000000..1a4600b --- /dev/null +++ b/flat/InterstellarEncoder.sol @@ -0,0 +1,157 @@ +// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol + +// pragma solidity ^0.4.24; + + +/** + * @title Ownable + * @dev The Ownable contract has an owner address, and provides basic authorization control + * functions, this simplifies the implementation of "user permissions". + */ +contract Ownable { + address public owner; + + + event OwnershipRenounced(address indexed previousOwner); + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + + /** + * @dev The Ownable constructor sets the original `owner` of the contract to the sender + * account. + */ + constructor() public { + owner = msg.sender; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + /** + * @dev Allows the current owner to relinquish control of the contract. + * @notice Renouncing to ownership will leave the contract without an owner. + * It will not be possible to call the functions with the `onlyOwner` + * modifier anymore. + */ + function renounceOwnership() public onlyOwner { + emit OwnershipRenounced(owner); + owner = address(0); + } + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function transferOwnership(address _newOwner) public onlyOwner { + _transferOwnership(_newOwner); + } + + /** + * @dev Transfers control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function _transferOwnership(address _newOwner) internal { + require(_newOwner != address(0)); + emit OwnershipTransferred(owner, _newOwner); + owner = _newOwner; + } +} + + +// Dependency file: contracts/interfaces/IInterstellarEncoder.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoder { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function registerNewTokenContract(address _tokenAddress) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); +} + +// Root file: contracts/InterstellarEncoder.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +// import "contracts/interfaces/IInterstellarEncoder.sol"; + +contract InterstellarEncoder is IInterstellarEncoder, Ownable { + // [magic_number, chain_id, contract_id <2>, origin_chain_id, origin_contract_id<2>, object_class, convert_type, <6>, land, <128>] + mapping(uint16 => address) public contractId2Address; + mapping(address => uint16) public contractAddress2Id; + + mapping(address => uint8) public objectContract2ObjectClass; + + uint16 public lastContractId = 0; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectId) public view returns (uint256 _tokenId) { + uint16 contractId = contractAddress2Id[_tokenAddress]; + require(contractAddress2Id[_tokenAddress] > 0, "Contract address does not exist"); + + _tokenId = (MAGIC_NUMBER << 248) + (CHAIN_ID << 240) + (uint256(contractId) << 224) + + (CHAIN_ID << 216) + (uint256(contractId) << 200) + (uint256(_objectClass) << 192) + (CURRENT_LAND << 128) + uint256(_objectId); + } + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId) { + require (objectContract2ObjectClass[_objectContract] > 0, "Object class for this object contract does not exist."); + + _tokenId = encodeTokenId(_tokenAddress, objectContract2ObjectClass[_objectContract], _objectId); + } + + function registerNewTokenContract(address _tokenAddress) public onlyOwner { + require(contractAddress2Id[_tokenAddress] == 0, "Contract address already exist"); + require(lastContractId < 65535, "Contract Id already reach maximum."); + + lastContractId += 1; + + contractAddress2Id[_tokenAddress] = lastContractId; + contractId2Address[lastContractId] = _tokenAddress; + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public onlyOwner { + objectContract2ObjectClass[_objectContract] = objectClass; + } + + function getContractAddress(uint256 _tokenId) public view returns (address) { + return contractId2Address[uint16((_tokenId << 16) >> 240)]; + } + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId) { + return uint128(_tokenId & CLEAR_HIGH); + } +} \ No newline at end of file diff --git a/flat/InterstellarEncoderV2.sol b/flat/InterstellarEncoderV2.sol new file mode 100644 index 0000000..178b79c --- /dev/null +++ b/flat/InterstellarEncoderV2.sol @@ -0,0 +1,170 @@ +// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol + +// pragma solidity ^0.4.24; + + +/** + * @title Ownable + * @dev The Ownable contract has an owner address, and provides basic authorization control + * functions, this simplifies the implementation of "user permissions". + */ +contract Ownable { + address public owner; + + + event OwnershipRenounced(address indexed previousOwner); + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + + /** + * @dev The Ownable constructor sets the original `owner` of the contract to the sender + * account. + */ + constructor() public { + owner = msg.sender; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + /** + * @dev Allows the current owner to relinquish control of the contract. + * @notice Renouncing to ownership will leave the contract without an owner. + * It will not be possible to call the functions with the `onlyOwner` + * modifier anymore. + */ + function renounceOwnership() public onlyOwner { + emit OwnershipRenounced(owner); + owner = address(0); + } + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function transferOwnership(address _newOwner) public onlyOwner { + _transferOwnership(_newOwner); + } + + /** + * @dev Transfers control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function _transferOwnership(address _newOwner) internal { + require(_newOwner != address(0)); + emit OwnershipTransferred(owner, _newOwner); + owner = _newOwner; + } +} + + +// Dependency file: contracts/interfaces/IInterstellarEncoder.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoder { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function registerNewTokenContract(address _tokenAddress) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); +} + +// Root file: contracts/InterstellarEncoderV2.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +// import "contracts/interfaces/IInterstellarEncoder.sol"; + +// TODO: upgrade. +contract InterstellarEncoderV2 is IInterstellarEncoder, Ownable { + // [magic_number, chain_id, contract_id <2>, origin_chain_id, origin_contract_id<2>, object_class, convert_type, <6>, land, <128>] + mapping(uint16 => address) public contractId2Address; + mapping(address => uint16) public contractAddress2Id; + + mapping(address => uint8) public objectContract2ObjectClass; + + uint16 public lastContractId = 0; + + // extended since V2 + mapping(uint8 => address) public objectClass2ObjectContract; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectId) public view returns (uint256 _tokenId) { + uint16 contractId = contractAddress2Id[_tokenAddress]; + require(contractAddress2Id[_tokenAddress] > 0, "Contract address does not exist"); + + _tokenId = (MAGIC_NUMBER << 248) + (CHAIN_ID << 240) + (uint256(contractId) << 224) + + (CHAIN_ID << 216) + (uint256(contractId) << 200) + (uint256(_objectClass) << 192) + (CURRENT_LAND << 128) + uint256(_objectId); + } + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId) { + require (objectContract2ObjectClass[_objectContract] > 0, "Object class for this object contract does not exist."); + + _tokenId = encodeTokenId(_tokenAddress, objectContract2ObjectClass[_objectContract], _objectId); + } + + function registerNewTokenContract(address _tokenAddress) public onlyOwner { + require(contractAddress2Id[_tokenAddress] == 0, "Contract address already exist"); + require(lastContractId < 65535, "Contract Id already reach maximum."); + + lastContractId += 1; + + contractAddress2Id[_tokenAddress] = lastContractId; + contractId2Address[lastContractId] = _tokenAddress; + } + + function registerNewObjectClass(address _objectContract, uint8 _objectClass) public onlyOwner { + objectContract2ObjectClass[_objectContract] = _objectClass; + objectClass2ObjectContract[_objectClass] = _objectContract; + } + + function getContractAddress(uint256 _tokenId) public view returns (address) { + return contractId2Address[uint16((_tokenId << 16) >> 240)]; + } + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId) { + return uint128(_tokenId & CLEAR_HIGH); + } + + function getObjectClass(uint256 _tokenId) public view returns (uint8) { + return uint8((_tokenId << 56) >> 248); + } + + function getObjectAddress(uint256 _tokenId) public view returns (address) { + return objectClass2ObjectContract[uint8((_tokenId << 56) >> 248)]; + } +} \ No newline at end of file diff --git a/flat/InterstellarEncoderV3.sol b/flat/InterstellarEncoderV3.sol new file mode 100644 index 0000000..25d9182 --- /dev/null +++ b/flat/InterstellarEncoderV3.sol @@ -0,0 +1,202 @@ +// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol + +// pragma solidity ^0.4.24; + + +/** + * @title Ownable + * @dev The Ownable contract has an owner address, and provides basic authorization control + * functions, this simplifies the implementation of "user permissions". + */ +contract Ownable { + address public owner; + + + event OwnershipRenounced(address indexed previousOwner); + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + + /** + * @dev The Ownable constructor sets the original `owner` of the contract to the sender + * account. + */ + constructor() public { + owner = msg.sender; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + /** + * @dev Allows the current owner to relinquish control of the contract. + * @notice Renouncing to ownership will leave the contract without an owner. + * It will not be possible to call the functions with the `onlyOwner` + * modifier anymore. + */ + function renounceOwnership() public onlyOwner { + emit OwnershipRenounced(owner); + owner = address(0); + } + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function transferOwnership(address _newOwner) public onlyOwner { + _transferOwnership(_newOwner); + } + + /** + * @dev Transfers control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function _transferOwnership(address _newOwner) internal { + require(_newOwner != address(0)); + emit OwnershipTransferred(owner, _newOwner); + owner = _newOwner; + } +} + + +// Dependency file: contracts/interfaces/IInterstellarEncoderV3.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoderV3 { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function encodeTokenIdForOuterObjectContract( + address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); + + function getProducerId(uint256 _tokenId) public view returns (uint16); + + function getOriginAddress(uint256 _tokenId) public view returns (address); + +} + +// Root file: contracts/InterstellarEncoderV3.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +// import "contracts/interfaces/IInterstellarEncoderV3.sol"; + +// TODO: upgrade. +contract InterstellarEncoderV3 is IInterstellarEncoderV3, Ownable { + // [magic_number, chain_id, contract_id <2>, origin_chain_id, origin_contract_id<2>, object_class, convert_type, <6>, land, <128>] + mapping(uint8 => address) public ownershipId2Address; + mapping(address => uint8) public ownershipAddress2Id; + + mapping(address => uint8) public classAddress2Id; // class + // extended since V2 + mapping(uint8 => address) public classId2Address; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectId) public view returns (uint256 _tokenId) { + uint16 contractId = ownershipAddress2Id[_tokenAddress]; + require(ownershipAddress2Id[_tokenAddress] > 0, "Contract address does not exist"); + + _tokenId = (MAGIC_NUMBER << 248) + (CHAIN_ID << 240) + (uint256(contractId) << 224) + + (CHAIN_ID << 216) + (uint256(contractId) << 200) + (uint256(_objectClass) << 192) + (CURRENT_LAND << 128) + uint256(_objectId); + } + + function encodeTokenIdForOuter( + address _nftAddress, address _originNftAddress, uint8 _objectClass, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256) { + uint16 contractId = ownershipAddress2Id[_nftAddress]; + uint16 originContractId = ownershipAddress2Id[_originNftAddress]; + require(contractId > 0 && originContractId > 0 && _producerId > 0, "Contract address does not exist"); + + uint256 tokenId = (MAGIC_NUMBER << 248) + (CHAIN_ID << 240) + (uint256(contractId) << 224) + + (CHAIN_ID << 216) + (uint256(originContractId) << 200) + (uint256(_objectClass) << 192) + (uint256(_convertType) << 184)+ (uint256(_producerId) << 128) + uint256(_objectId); + + return tokenId; + } + + // TODO; newly added + // @param _tokenAddress - objectOwnership + // @param _objectContract - xxxBase contract + function encodeTokenIdForOuterObjectContract( + address _objectContract, address _nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256) { + require (classAddress2Id[_objectContract] > 0, "Object class for this object contract does not exist."); + + return encodeTokenIdForOuter(_nftAddress, _originNftAddress, classAddress2Id[_objectContract], _objectId, _producerId, _convertType); + + } + // TODO; newly added + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId) { + require (classAddress2Id[_objectContract] > 0, "Object class for this object contract does not exist."); + + _tokenId = encodeTokenId(_tokenAddress, classAddress2Id[_objectContract], _objectId); + } + + function registerNewOwnershipContract(address _nftAddress, uint8 _nftId) public onlyOwner { + ownershipAddress2Id[_nftAddress] = _nftId; + ownershipId2Address[_nftId] = _nftAddress; + } + + function registerNewObjectClass(address _objectContract, uint8 _objectClass) public onlyOwner { + classAddress2Id[_objectContract] = _objectClass; + classId2Address[_objectClass] = _objectContract; + } + + function getProducerId(uint256 _tokenId) public view returns (uint16) { + return uint16((_tokenId >> 128) & 0xff); + } + + function getContractAddress(uint256 _tokenId) public view returns (address) { + return ownershipId2Address[uint8((_tokenId >> 240) & 0xff)]; + } + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId) { + return uint128(_tokenId & CLEAR_HIGH); + } + + function getObjectClass(uint256 _tokenId) public view returns (uint8) { + return uint8((_tokenId << 56) >> 248); + } + + function getObjectAddress(uint256 _tokenId) public view returns (address) { + return classId2Address[uint8((_tokenId << 56) >> 248)]; + } + + // TODO; newly added + function getOriginAddress(uint256 _tokenId) public view returns (address) { + uint8 originContractId = uint8((_tokenId >> 200) & 0xff); + return ownershipId2Address[originContractId]; + + } +} \ No newline at end of file diff --git a/flat/Issuing.sol b/flat/Issuing.sol new file mode 100644 index 0000000..1661a45 --- /dev/null +++ b/flat/Issuing.sol @@ -0,0 +1,326 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: contracts/PausableDSAuth.sol + +// pragma solidity ^0.4.24; + +// import "contracts/DSAuth.sol"; + + +/** + * @title Pausable + * @dev Base contract which allows children to implement an emergency stop mechanism. + */ +contract PausableDSAuth is DSAuth { + event Pause(); + event Unpause(); + + bool public paused = false; + + + /** + * @dev Modifier to make a function callable only when the contract is not paused. + */ + modifier whenNotPaused() { + require(!paused); + _; + } + + /** + * @dev Modifier to make a function callable only when the contract is paused. + */ + modifier whenPaused() { + require(paused); + _; + } + + /** + * @dev called by the owner to pause, triggers stopped state + */ + function pause() public onlyOwner whenNotPaused { + paused = true; + emit Pause(); + } + + /** + * @dev called by the owner to unpause, returns to normal state + */ + function unpause() public onlyOwner whenPaused { + paused = false; + emit Unpause(); + } +} + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Dependency file: contracts/interfaces/IBurnableERC20.sol + +// pragma solidity ^0.4.23; + +contract IBurnableERC20 { + function burn(address _from, uint _value) public; +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Root file: contracts/Issuing.sol + +pragma solidity ^0.4.24; + +// import "contracts/PausableDSAuth.sol"; +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; +// import "contracts/interfaces/IBurnableERC20.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; + +contract Issuing is PausableDSAuth { + // claimedToken event + event ClaimedTokens( + address indexed token, + address indexed owner, + uint256 amount + ); + + event BurnAndRedeem( + address indexed token, + address indexed from, + uint256 amount, + bytes receiver + ); + + ISettingsRegistry public registry; + + mapping(address => bool) public supportedTokens; + + constructor(address _registry) { + registry = ISettingsRegistry(_registry); + } + + /** + * @dev ERC223 fallback function, make sure to check the msg.sender is from target token contracts + * @param _from - person who transfer token in for deposits or claim deposit with penalty KTON. + * @param _amount - amount of token. + * @param _data - data which indicate the operations. + */ + function tokenFallback( + address _from, + uint256 _amount, + bytes _data + ) public whenNotPaused { + bytes32 darwiniaAddress; + + assembly { + let ptr := mload(0x40) + calldatacopy(ptr, 0, calldatasize) + darwiniaAddress := mload(add(ptr, 132)) + } + + // Only supported tokens can be called + require(supportedTokens[msg.sender], "Permission denied"); + require( + _data.length == 32, + "The address (Darwinia Network) must be in a 32 bytes hexadecimal format" + ); + require( + darwiniaAddress != bytes32(0), + "Darwinia Network Address can't be empty" + ); + + // SettingIds.UINT_BRIDGE_FEE + uint256 bridgeFee = registry.uintOf( + 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + ); + + // SettingIds.CONTRACT_BRIDGE_POOL + address bridgePool = registry.addressOf( + 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + ); + + // SettingIds.CONTRACT_RING_ERC20_TOKEN + address ring = registry.addressOf( + 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + ); + + // BridgeFee will be paid to the relayer + if (bridgeFee > 0) { + require( + ERC20(ring).transferFrom(_from, bridgePool, bridgeFee), + "Error when paying transaction fees" + ); + } + + IBurnableERC20(msg.sender).burn(address(this), _amount); + emit BurnAndRedeem(msg.sender, _from, _amount, _data); + } + + function addSupportedTokens(address _token) public auth { + supportedTokens[_token] = true; + } + + function removeSupportedTokens(address _token) public auth { + supportedTokens[_token] = false; + } + + /// @notice This method can be used by the owner to extract mistakenly + /// sent tokens to this contract. + /// @param _token The address of the token contract that you want to recover + /// set to 0 in case you want to extract ether. + function claimTokens(address _token) public auth { + if (_token == 0x0) { + owner.transfer(address(this).balance); + return; + } + ERC20 token = ERC20(_token); + uint256 balance = token.balanceOf(address(this)); + token.transfer(owner, balance); + + emit ClaimedTokens(_token, owner, balance); + } +} diff --git a/flat/KtonVoter.sol b/flat/KtonVoter.sol new file mode 100644 index 0000000..4c596db --- /dev/null +++ b/flat/KtonVoter.sol @@ -0,0 +1,143 @@ +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Root file: contracts/KtonVoter.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; + +/// @title KtonVoter +/// @dev Voting and support specific proposal validator by deposit KTON +/// Vote will be cancel after KTON get withdrawd +/// 1 KTON means one vote +contract KtonVoter { + address public KTON; + + struct VoterItem { + // mapping (address => mapping (address => uint256)) public votes; + mapping (address => uint256) votes; + // mapping (address => uint256) public depositBalances; + uint256 balance; + // TODO: address[] candidates; + } + + struct CandidateItem { + uint256 voteCount; // contract address + uint256 sortedIndex; // index of the item in the list of sortedCandidate + bool isRegistered; // used to tell if the mapping element is defined + // TODO: address[] voters; + } + + mapping (address => VoterItem) public voterItems; + + mapping (address => CandidateItem) public cadidateItems; + + // descending + address[] public sortedCandidates; + + function vote(address _candidate, uint _amount) public { + require(cadidateItems[_candidate].isRegistered); + require(ERC20(KTON).transferFrom(msg.sender, address(this), _amount)); + + voterItems[msg.sender].votes[_candidate] += _amount; + voterItems[msg.sender].balance += _amount; + + cadidateItems[_candidate].voteCount += _amount; + + // TODO: update sortedIndex + quickSort(0, cadidateItems[_candidate].sortedIndex); + } + + function withdrawFrom(address _candidate, uint _amount) public { + require(voterItems[msg.sender].votes[_candidate] >= _amount); + + voterItems[msg.sender].votes[_candidate] -= _amount; + voterItems[msg.sender].balance -= _amount; + cadidateItems[_candidate].voteCount -= _amount; + + require(ERC20(KTON).transfer(msg.sender, _amount)); + + // TODO: update sortedIndex + quickSort(cadidateItems[_candidate].sortedIndex, sortedCandidates.length - 1); + } + + function getCandidate(uint _num) public view returns (address candidate){ + require(_num < sortedCandidates.length); + candidate = sortedCandidates[_num]; + } + + function registerCandidate() public { + // require(ERC20(KTON).transferFrom(msg.sender, address(this), 1000000000000000000000)); + require(!cadidateItems[msg.sender].isRegistered); + + cadidateItems[msg.sender].isRegistered = true; + sortedCandidates.push(msg.sender); + cadidateItems[msg.sender].sortedIndex = sortedCandidates.length - 1; + } + + // http://www.etherdevops.com/content/sorting-array-integer-ethereum + function quickSort(uint left, uint right) internal { + uint i = left; + uint j = right; + uint pivot = cadidateItems[sortedCandidates[left + (right - left) / 2]].voteCount; + while (i <= j) { + while (cadidateItems[sortedCandidates[i]].voteCount < pivot) i++; + while (pivot < cadidateItems[sortedCandidates[j]].voteCount) j--; + if (i <= j) { + (sortedCandidates[i], sortedCandidates[j]) = (sortedCandidates[j], sortedCandidates[i]); + cadidateItems[sortedCandidates[i]].sortedIndex = i; + cadidateItems[sortedCandidates[j]].sortedIndex = j; + + i++; + j--; + } + } + if (left < j) + quickSort(left, j); + if (i < right) + quickSort(i, right); + } +} \ No newline at end of file diff --git a/flat/LocationCoder.sol b/flat/LocationCoder.sol new file mode 100644 index 0000000..cc843dc --- /dev/null +++ b/flat/LocationCoder.sol @@ -0,0 +1,82 @@ +// Root file: contracts/LocationCoder.sol + +pragma solidity ^0.4.24; + +library LocationCoder { + // the allocation of the [x, y, z] is [0<1>, x<21>, y<21>, z<21>] + uint256 constant CLEAR_YZ = 0x0fffffffffffffffffffff000000000000000000000000000000000000000000; + uint256 constant CLEAR_XZ = 0x0000000000000000000000fffffffffffffffffffff000000000000000000000; + uint256 constant CLEAR_XY = 0x0000000000000000000000000000000000000000000fffffffffffffffffffff; + + uint256 constant NOT_ZERO = 0x1000000000000000000000000000000000000000000000000000000000000000; + uint256 constant APPEND_HIGH = 0xfffffffffffffffffffffffffffffffffffffffffff000000000000000000000; + + uint256 constant MAX_LOCATION_ID = 0x2000000000000000000000000000000000000000000000000000000000000000; + + int256 constant HMETER_DECIMAL = 10 ** 8; + + // x, y, z should between -2^83 (-9671406556917033397649408) and 2^83 - 1 (9671406556917033397649407). + int256 constant MIN_Location_XYZ = -9671406556917033397649408; + int256 constant MAX_Location_XYZ = 9671406556917033397649407; + // 96714065569170334.50000000 + int256 constant MAX_HM_DECIMAL = 9671406556917033450000000; + int256 constant MAX_HM = 96714065569170334; + + function encodeLocationIdXY(int _x, int _y) internal pure returns (uint result) { + return encodeLocationId3D(_x, _y, 0); + } + + function decodeLocationIdXY(uint _positionId) internal pure returns (int _x, int _y) { + (_x, _y, ) = decodeLocationId3D(_positionId); + } + + function encodeLocationId3D(int _x, int _y, int _z) internal pure returns (uint result) { + return _unsafeEncodeLocationId3D(_x, _y, _z); + } + + function _unsafeEncodeLocationId3D(int _x, int _y, int _z) internal pure returns (uint) { + require(_x >= MIN_Location_XYZ && _x <= MAX_Location_XYZ, "Invalid value."); + require(_y >= MIN_Location_XYZ && _y <= MAX_Location_XYZ, "Invalid value."); + require(_z >= MIN_Location_XYZ && _z <= MAX_Location_XYZ, "Invalid value."); + + // uint256 constant FACTOR_2 = 0x1000000000000000000000000000000000000000000; // <16 ** 42> or <2 ** 168> + // uint256 constant FACTOR = 0x1000000000000000000000; // <16 ** 21> or <2 ** 84> + return ((uint(_x) << 168) & CLEAR_YZ) | (uint(_y << 84) & CLEAR_XZ) | (uint(_z) & CLEAR_XY) | NOT_ZERO; + } + + function decodeLocationId3D(uint _positionId) internal pure returns (int, int, int) { + return _unsafeDecodeLocationId3D(_positionId); + } + + function _unsafeDecodeLocationId3D(uint _value) internal pure returns (int x, int y, int z) { + require(_value >= NOT_ZERO && _value < MAX_LOCATION_ID, "Invalid Location Id"); + + x = expandNegative84BitCast((_value & CLEAR_YZ) >> 168); + y = expandNegative84BitCast((_value & CLEAR_XZ) >> 84); + z = expandNegative84BitCast(_value & CLEAR_XY); + } + + function toHM(int _x) internal pure returns (int) { + return (_x + MAX_HM_DECIMAL)/HMETER_DECIMAL - MAX_HM; + } + + function toUM(int _x) internal pure returns (int) { + return _x * LocationCoder.HMETER_DECIMAL; + } + + function expandNegative84BitCast(uint _value) internal pure returns (int) { + if (_value & (1<<83) != 0) { + return int(_value | APPEND_HIGH); + } + return int(_value); + } + + function encodeLocationIdHM(int _x, int _y) internal pure returns (uint result) { + return encodeLocationIdXY(toUM(_x), toUM(_y)); + } + + function decodeLocationIdHM(uint _positionId) internal pure returns (int, int) { + (int _x, int _y) = decodeLocationIdXY(_positionId); + return (toHM(_x), toHM(_y)); + } +} \ No newline at end of file diff --git a/flat/Migrations.sol b/flat/Migrations.sol new file mode 100644 index 0000000..c82b119 --- /dev/null +++ b/flat/Migrations.sol @@ -0,0 +1,213 @@ +// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/Proxy.sol + +// pragma solidity ^0.4.21; + +/** + * @title Proxy + * @dev Gives the possibility to delegate any call to a foreign implementation. + */ +contract Proxy { + /** + * @dev Tells the address of the implementation where every call will be delegated. + * @return address of the implementation to which it will be delegated + */ + function implementation() public view returns (address); + + /** + * @dev Fallback function allowing to perform a delegatecall to the given implementation. + * This function will return whatever the implementation call returns + */ + function () payable public { + address _impl = implementation(); + require(_impl != address(0)); + + assembly { + let ptr := mload(0x40) + calldatacopy(ptr, 0, calldatasize) + let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0) + let size := returndatasize + returndatacopy(ptr, 0, size) + + switch result + case 0 { revert(ptr, size) } + default { return(ptr, size) } + } + } +} + + +// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/UpgradeabilityProxy.sol + +// pragma solidity ^0.4.21; + +// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/@evolutionland/upgraeability-using-unstructured-storage/contracts/Proxy.sol'; + +/** + * @title UpgradeabilityProxy + * @dev This contract represents a proxy where the implementation address to which it will delegate can be upgraded + */ +contract UpgradeabilityProxy is Proxy { + /** + * @dev This event will be emitted every time the implementation gets upgraded + * @param implementation representing the address of the upgraded implementation + */ + event Upgraded(address indexed implementation); + + // Storage position of the address of the current implementation + bytes32 private constant implementationPosition = keccak256("org.zeppelinos.proxy.implementation"); + + /** + * @dev Constructor function + */ + function UpgradeabilityProxy() public {} + + /** + * @dev Tells the address of the current implementation + * @return address of the current implementation + */ + function implementation() public view returns (address impl) { + bytes32 position = implementationPosition; + assembly { + impl := sload(position) + } + } + + /** + * @dev Sets the address of the current implementation + * @param newImplementation address representing the new implementation to be set + */ + function setImplementation(address newImplementation) internal { + bytes32 position = implementationPosition; + assembly { + sstore(position, newImplementation) + } + } + + /** + * @dev Upgrades the implementation address + * @param newImplementation representing the address of the new implementation to be set + */ + function _upgradeTo(address newImplementation) internal { + address currentImplementation = implementation(); + require(currentImplementation != newImplementation); + setImplementation(newImplementation); + emit Upgraded(newImplementation); + } +} + + +// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol + +// pragma solidity ^0.4.21; + +// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/@evolutionland/upgraeability-using-unstructured-storage/contracts/UpgradeabilityProxy.sol'; + +/** + * @title OwnedUpgradeabilityProxy + * @dev This contract combines an upgradeability proxy with basic authorization control functionalities + */ +contract OwnedUpgradeabilityProxy is UpgradeabilityProxy { + /** + * @dev Event to show ownership has been transferred + * @param previousOwner representing the address of the previous owner + * @param newOwner representing the address of the new owner + */ + event ProxyOwnershipTransferred(address previousOwner, address newOwner); + + // Storage position of the owner of the contract + bytes32 private constant proxyOwnerPosition = keccak256("org.zeppelinos.proxy.owner"); + + /** + * @dev the constructor sets the original owner of the contract to the sender account. + */ + function OwnedUpgradeabilityProxy() public { + setUpgradeabilityOwner(msg.sender); + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyProxyOwner() { + require(msg.sender == proxyOwner()); + _; + } + + /** + * @dev Tells the address of the owner + * @return the address of the owner + */ + function proxyOwner() public view returns (address owner) { + bytes32 position = proxyOwnerPosition; + assembly { + owner := sload(position) + } + } + + /** + * @dev Sets the address of the owner + */ + function setUpgradeabilityOwner(address newProxyOwner) internal { + bytes32 position = proxyOwnerPosition; + assembly { + sstore(position, newProxyOwner) + } + } + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param newOwner The address to transfer ownership to. + */ + function transferProxyOwnership(address newOwner) public onlyProxyOwner { + require(newOwner != address(0)); + emit ProxyOwnershipTransferred(proxyOwner(), newOwner); + setUpgradeabilityOwner(newOwner); + } + + /** + * @dev Allows the proxy owner to upgrade the current version of the proxy. + * @param implementation representing the address of the new implementation to be set. + */ + function upgradeTo(address implementation) public onlyProxyOwner { + _upgradeTo(implementation); + } + + /** + * @dev Allows the proxy owner to upgrade the current version of the proxy and call the new implementation + * to initialize whatever is needed through a low level call. + * @param implementation representing the address of the new implementation to be set. + * @param data represents the msg.data to bet sent in the low level call. This parameter may include the function + * signature of the implementation to be called with the needed payload + */ + function upgradeToAndCall(address implementation, bytes data) payable public onlyProxyOwner { + upgradeTo(implementation); + require(this.call.value(msg.value)(data)); + } +} + + +// Root file: contracts/Migrations.sol + +pragma solidity ^0.4.23; +// import "@evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol"; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + constructor() public { + owner = msg.sender; + } + + modifier restricted() { + if (msg.sender == owner) _; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } + + function upgrade(address new_address) public restricted { + Migrations upgraded = Migrations(new_address); + upgraded.setCompleted(last_completed_migration); + } +} diff --git a/flat/MintAndBurnAuthority.sol b/flat/MintAndBurnAuthority.sol new file mode 100644 index 0000000..ec892ee --- /dev/null +++ b/flat/MintAndBurnAuthority.sol @@ -0,0 +1,21 @@ +// Root file: contracts/MintAndBurnAuthority.sol + +pragma solidity ^0.4.24; + +contract MintAndBurnAuthority { + + mapping (address => bool) public whiteList; + + constructor(address[] _whitelists) public { + for (uint i = 0; i < _whitelists.length; i ++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, address _dst, bytes4 _sig + ) public view returns (bool) { + return ( whiteList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || + ( whiteList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); + } +} diff --git a/flat/MintAndBurnAuthorityV2.sol b/flat/MintAndBurnAuthorityV2.sol new file mode 100644 index 0000000..5cec0bf --- /dev/null +++ b/flat/MintAndBurnAuthorityV2.sol @@ -0,0 +1,21 @@ +// Root file: contracts/MintAndBurnAuthorityV2.sol + +pragma solidity ^0.4.24; + +contract MintAndBurnAuthorityV2 { + + mapping (address => bool) public allowList; + + constructor(address[] _allowlists) public { + for (uint i = 0; i < _allowlists.length; i ++) { + allowList[_allowlists[i]] = true; + } + } + + function canCall( + address _src, address _dst, bytes4 _sig + ) public view returns (bool) { + return ( allowList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || + ( allowList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); + } +} diff --git a/flat/MintAndBurnMutableAuthority.sol b/flat/MintAndBurnMutableAuthority.sol new file mode 100644 index 0000000..6dadc65 --- /dev/null +++ b/flat/MintAndBurnMutableAuthority.sol @@ -0,0 +1,104 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Root file: contracts/MintAndBurnMutableAuthority.sol + +pragma solidity ^0.4.24; + +// import "contracts/DSAuth.sol"; + +contract MintAndBurnAuthority is DSAuth { + + mapping (address => bool) public allowList; + + constructor(address[] _allowlists) public { + for (uint i = 0; i < _allowlists.length; i ++) { + allowList[_allowlists[i]] = true; + } + } + + function canCall( + address _src, address _dst, bytes4 _sig + ) public view returns (bool) { + return ( allowList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || + ( allowList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); + } + + function addAllowAddress(address allowAddress) public onlyOwner{ + allowList[allowAddress] = true; + } + + function removeAllowAddress(address allowAddress) public onlyOwner{ + allowList[allowAddress] = false; + } +} diff --git a/flat/MultiSigWallet.sol b/flat/MultiSigWallet.sol new file mode 100644 index 0000000..7f66af4 --- /dev/null +++ b/flat/MultiSigWallet.sol @@ -0,0 +1,368 @@ +// Root file: contracts/MultiSigWallet.sol + +pragma solidity ^0.4.17; + + +/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. +/// @author Stefan George - +contract MultiSigWallet { + + uint constant public MAX_OWNER_COUNT = 50; + + event Confirmation(address indexed _sender, uint indexed _transactionId); + event Revocation(address indexed _sender, uint indexed _transactionId); + event Submission(uint indexed _transactionId); + event Execution(uint indexed _transactionId); + event ExecutionFailure(uint indexed _transactionId); + event Deposit(address indexed _sender, uint _value); + event OwnerAddition(address indexed _owner); + event OwnerRemoval(address indexed _owner); + event RequirementChange(uint _required); + + mapping (uint => Transaction) public transactions; + mapping (uint => mapping (address => bool)) public confirmations; + mapping (address => bool) public isOwner; + address[] public owners; + uint public required; + uint public transactionCount; + + struct Transaction { + address destination; + uint value; + bytes data; + bool executed; + } + + modifier onlyWallet() { + if (msg.sender != address(this)) + throw; + _; + } + + modifier ownerDoesNotExist(address owner) { + if (isOwner[owner]) + throw; + _; + } + + modifier ownerExists(address owner) { + if (!isOwner[owner]) + throw; + _; + } + + modifier transactionExists(uint transactionId) { + if (transactions[transactionId].destination == 0) + throw; + _; + } + + modifier confirmed(uint transactionId, address owner) { + if (!confirmations[transactionId][owner]) + throw; + _; + } + + modifier notConfirmed(uint transactionId, address owner) { + if (confirmations[transactionId][owner]) + throw; + _; + } + + modifier notExecuted(uint transactionId) { + if (transactions[transactionId].executed) + throw; + _; + } + + modifier notNull(address _address) { + if (_address == 0) + throw; + _; + } + + modifier validRequirement(uint ownerCount, uint _required) { + if ( ownerCount > MAX_OWNER_COUNT + || _required > ownerCount + || _required == 0 + || ownerCount == 0) + throw; + _; + } + + /// @dev Fallback function allows to deposit ether. + function() + payable + { + if (msg.value > 0) + Deposit(msg.sender, msg.value); + } + + /* + * Public functions + */ + /// @dev Contract constructor sets initial owners and required number of confirmations. + /// @param _owners List of initial owners. + /// @param _required Number of required confirmations. + function MultiSigWallet(address[] _owners, uint _required) + public + validRequirement(_owners.length, _required) + { + for (uint i=0; i<_owners.length; i++) { + if (isOwner[_owners[i]] || _owners[i] == 0) + throw; + isOwner[_owners[i]] = true; + } + owners = _owners; + required = _required; + } + + /// @dev Allows to add a new owner. Transaction has to be sent by wallet. + /// @param owner Address of new owner. + function addOwner(address owner) + public + onlyWallet + ownerDoesNotExist(owner) + notNull(owner) + validRequirement(owners.length + 1, required) + { + isOwner[owner] = true; + owners.push(owner); + OwnerAddition(owner); + } + + /// @dev Allows to remove an owner. Transaction has to be sent by wallet. + /// @param owner Address of owner. + function removeOwner(address owner) + public + onlyWallet + ownerExists(owner) + { + isOwner[owner] = false; + for (uint i=0; i owners.length) + changeRequirement(owners.length); + OwnerRemoval(owner); + } + + /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. + /// @param owner Address of owner to be replaced. + /// @param owner Address of new owner. + function replaceOwner(address owner, address newOwner) + public + onlyWallet + ownerExists(owner) + ownerDoesNotExist(newOwner) + { + for (uint i=0; i 0); // Solidity automatically throws when dividing by 0 + // uint256 c = _a / _b; + // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold + return _a / _b; + } + + /** + * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). + */ + function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { + assert(_b <= _a); + return _a - _b; + } + + /** + * @dev Adds two numbers, throws on overflow. + */ + function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + c = _a + _b; + assert(c >= _a); + return c; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/AddressUtils.sol + +// pragma solidity ^0.4.24; + + +/** + * Utility library of inline functions on addresses + */ +library AddressUtils { + + /** + * Returns whether the target address is a contract + * @dev This function will return false if invoked during the constructor of a contract, + * as the code is not actually created until after the constructor finishes. + * @param _addr address to check + * @return whether the target address is a contract + */ + function isContract(address _addr) internal view returns (bool) { + uint256 size; + // XXX Currently there is no better way to check if there is a contract in an address + // than to check the size of the code at that address. + // See https://ethereum.stackexchange.com/a/14016/36603 + // for more details about how this works. + // TODO Check this again before the Serenity release, because all addresses will be + // contracts then. + // solium-disable-next-line security/no-inline-assembly + assembly { size := extcodesize(_addr) } + return size > 0; + } + +} + + +// Dependency file: openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + + +/** + * @title SupportsInterfaceWithLookup + * @author Matt Condon (@shrugs) + * @dev Implements ERC165 using a lookup table. + */ +contract SupportsInterfaceWithLookup is ERC165 { + + bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; + /** + * 0x01ffc9a7 === + * bytes4(keccak256('supportsInterface(bytes4)')) + */ + + /** + * @dev a mapping of interface id to whether or not it's supported + */ + mapping(bytes4 => bool) internal supportedInterfaces; + + /** + * @dev A contract implementing SupportsInterfaceWithLookup + * implement ERC165 itself + */ + constructor() + public + { + _registerInterface(InterfaceId_ERC165); + } + + /** + * @dev implement supportsInterface(bytes4) using a lookup table + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool) + { + return supportedInterfaces[_interfaceId]; + } + + /** + * @dev private method for registering an interface + */ + function _registerInterface(bytes4 _interfaceId) + internal + { + require(_interfaceId != 0xffffffff); + supportedInterfaces[_interfaceId] = true; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721BasicToken.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol"; +// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +// import "openzeppelin-solidity/contracts/AddressUtils.sol"; +// import "openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.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 SupportsInterfaceWithLookup, ERC721Basic { + + 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; + + // Mapping from token ID to owner + mapping (uint256 => address) internal tokenOwner; + + // Mapping from token ID to approved address + mapping (uint256 => address) internal tokenApprovals; + + // Mapping from owner to number of owned token + mapping (address => uint256) internal ownedTokensCount; + + // Mapping from owner to operator approvals + mapping (address => mapping (address => bool)) internal operatorApprovals; + + constructor() + public + { + // register the supported interfaces to conform to ERC721 via ERC165 + _registerInterface(InterfaceId_ERC721); + _registerInterface(InterfaceId_ERC721Exists); + } + + /** + * @dev Gets the balance of the specified address + * @param _owner address to query the balance of + * @return uint256 representing the amount owned by the passed address + */ + function balanceOf(address _owner) public view returns (uint256) { + require(_owner != address(0)); + return ownedTokensCount[_owner]; + } + + /** + * @dev Gets the owner of the specified token ID + * @param _tokenId uint256 ID of the token to query the owner of + * @return owner address currently marked as the owner of the given token ID + */ + function ownerOf(uint256 _tokenId) public view returns (address) { + address owner = tokenOwner[_tokenId]; + require(owner != address(0)); + return owner; + } + + /** + * @dev Returns whether the specified token exists + * @param _tokenId uint256 ID of the token to query the existence of + * @return whether the token exists + */ + function exists(uint256 _tokenId) public view returns (bool) { + address owner = tokenOwner[_tokenId]; + return owner != address(0); + } + + /** + * @dev Approves another address to transfer the given token ID + * The zero address indicates there is no approved address. + * There can only be one approved address per token at a given time. + * Can only be called by the token owner or an approved operator. + * @param _to address to be approved for the given token ID + * @param _tokenId uint256 ID of the token to be approved + */ + function approve(address _to, uint256 _tokenId) public { + address owner = ownerOf(_tokenId); + require(_to != owner); + require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); + + tokenApprovals[_tokenId] = _to; + emit Approval(owner, _to, _tokenId); + } + + /** + * @dev Gets the approved address for a token ID, or zero if no address set + * @param _tokenId uint256 ID of the token to query the approval of + * @return address currently approved for the given token ID + */ + function getApproved(uint256 _tokenId) public view returns (address) { + return tokenApprovals[_tokenId]; + } + + /** + * @dev Sets or unsets the approval of a given operator + * An operator is allowed to transfer all tokens of the sender on their behalf + * @param _to operator address to set the approval + * @param _approved representing the status of the approval to be set + */ + function setApprovalForAll(address _to, bool _approved) public { + require(_to != msg.sender); + operatorApprovals[msg.sender][_to] = _approved; + emit ApprovalForAll(msg.sender, _to, _approved); + } + + /** + * @dev Tells whether an operator is approved by a given owner + * @param _owner owner address which you want to query the approval of + * @param _operator operator address which you want to query the approval of + * @return bool whether the given operator is approved by the given owner + */ + function isApprovedForAll( + address _owner, + address _operator + ) + public + view + returns (bool) + { + return operatorApprovals[_owner][_operator]; + } + + /** + * @dev Transfers the ownership of a given token ID to another address + * Usage of this method is discouraged, use `safeTransferFrom` whenever possible + * Requires the msg sender to be the owner, approved, or operator + * @param _from current owner of the token + * @param _to address to receive the ownership of the given token ID + * @param _tokenId uint256 ID of the token to be transferred + */ + function transferFrom( + address _from, + address _to, + uint256 _tokenId + ) + public + { + require(isApprovedOrOwner(msg.sender, _tokenId)); + require(_from != address(0)); + require(_to != address(0)); + + clearApproval(_from, _tokenId); + removeTokenFrom(_from, _tokenId); + addTokenTo(_to, _tokenId); + + emit Transfer(_from, _to, _tokenId); + } + + /** + * @dev Safely transfers the ownership of a given token ID to another address + * If the target address is a contract, it must implement `onERC721Received`, + * which is called upon a safe transfer, and return the magic value + * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, + * the transfer is reverted. + * + * Requires the msg sender to be the owner, approved, or operator + * @param _from current owner of the token + * @param _to address to receive the ownership of the given token ID + * @param _tokenId uint256 ID of the token to be transferred + */ + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId + ) + public + { + // solium-disable-next-line arg-overflow + safeTransferFrom(_from, _to, _tokenId, ""); + } + + /** + * @dev Safely transfers the ownership of a given token ID to another address + * If the target address is a contract, it must implement `onERC721Received`, + * which is called upon a safe transfer, and return the magic value + * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, + * the transfer is reverted. + * Requires the msg sender to be the owner, approved, or operator + * @param _from current owner of the token + * @param _to address to receive the ownership of the given token ID + * @param _tokenId uint256 ID of the token to be transferred + * @param _data bytes data to send along with a safe transfer check + */ + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public + { + transferFrom(_from, _to, _tokenId); + // solium-disable-next-line arg-overflow + require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); + } + + /** + * @dev Returns whether the given spender can transfer a given token ID + * @param _spender address of the spender to query + * @param _tokenId uint256 ID of the token to be transferred + * @return bool whether the msg.sender is approved for the given token ID, + * is an operator of the owner, or is the owner of the token + */ + function isApprovedOrOwner( + address _spender, + uint256 _tokenId + ) + internal + view + returns (bool) + { + address owner = ownerOf(_tokenId); + // Disable solium check because of + // https://github.com/duaraghav8/Solium/issues/175 + // solium-disable-next-line operator-whitespace + return ( + _spender == owner || + getApproved(_tokenId) == _spender || + isApprovedForAll(owner, _spender) + ); + } + + /** + * @dev Internal function to mint a new token + * Reverts if the given token ID already exists + * @param _to The address that will own the minted token + * @param _tokenId uint256 ID of the token to be minted by the msg.sender + */ + function _mint(address _to, uint256 _tokenId) internal { + require(_to != address(0)); + addTokenTo(_to, _tokenId); + emit Transfer(address(0), _to, _tokenId); + } + + /** + * @dev Internal function to burn a specific token + * Reverts if the token does not exist + * @param _tokenId uint256 ID of the token being burned by the msg.sender + */ + function _burn(address _owner, uint256 _tokenId) internal { + clearApproval(_owner, _tokenId); + removeTokenFrom(_owner, _tokenId); + emit Transfer(_owner, address(0), _tokenId); + } + + /** + * @dev Internal function to clear current approval of a given token ID + * Reverts if the given address is not indeed the owner of the token + * @param _owner owner of the token + * @param _tokenId uint256 ID of the token to be transferred + */ + function clearApproval(address _owner, uint256 _tokenId) internal { + require(ownerOf(_tokenId) == _owner); + if (tokenApprovals[_tokenId] != address(0)) { + tokenApprovals[_tokenId] = address(0); + } + } + + /** + * @dev Internal function to add a token ID to the list of a given address + * @param _to address representing the new owner of the given token ID + * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address + */ + function addTokenTo(address _to, uint256 _tokenId) internal { + require(tokenOwner[_tokenId] == address(0)); + tokenOwner[_tokenId] = _to; + ownedTokensCount[_to] = ownedTokensCount[_to].add(1); + } + + /** + * @dev Internal function to remove a token ID from the list of a given address + * @param _from address representing the previous owner of the given token ID + * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address + */ + function removeTokenFrom(address _from, uint256 _tokenId) internal { + require(ownerOf(_tokenId) == _from); + ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); + tokenOwner[_tokenId] = address(0); + } + + /** + * @dev Internal function to invoke `onERC721Received` on a target address + * The call is not executed if the target address is not a contract + * @param _from address representing the previous owner of the given token ID + * @param _to target address that will receive the tokens + * @param _tokenId uint256 ID of the token to be transferred + * @param _data bytes optional data to send along with the call + * @return whether the call correctly returned the expected magic value + */ + function checkAndCallSafeTransfer( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + internal + returns (bool) + { + if (!_to.isContract()) { + return true; + } + bytes4 retval = ERC721Receiver(_to).onERC721Received( + msg.sender, _from, _tokenId, _data); + return (retval == ERC721_RECEIVED); + } +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721BasicToken.sol"; +// import "openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.sol"; + + +/** + * @title Full ERC721 Token + * This implementation includes all the required and some optional functionality of the ERC721 standard + * Moreover, it includes approve all functionality using operator terminology + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 { + + // Token name + string internal name_; + + // Token symbol + string internal symbol_; + + // Mapping from owner to list of owned token IDs + mapping(address => uint256[]) internal ownedTokens; + + // Mapping from token ID to index of the owner tokens list + mapping(uint256 => uint256) internal ownedTokensIndex; + + // Array with all token ids, used for enumeration + uint256[] internal allTokens; + + // Mapping from token id to position in the allTokens array + mapping(uint256 => uint256) internal allTokensIndex; + + // Optional mapping for token URIs + mapping(uint256 => string) internal tokenURIs; + + /** + * @dev Constructor function + */ + constructor(string _name, string _symbol) public { + name_ = _name; + symbol_ = _symbol; + + // register the supported interfaces to conform to ERC721 via ERC165 + _registerInterface(InterfaceId_ERC721Enumerable); + _registerInterface(InterfaceId_ERC721Metadata); + } + + /** + * @dev Gets the token name + * @return string representing the token name + */ + function name() external view returns (string) { + return name_; + } + + /** + * @dev Gets the token symbol + * @return string representing the token symbol + */ + function symbol() external view returns (string) { + return symbol_; + } + + /** + * @dev Returns an URI for a given token ID + * Throws if the token ID does not exist. May return an empty string. + * @param _tokenId uint256 ID of the token to query + */ + function tokenURI(uint256 _tokenId) public view returns (string) { + require(exists(_tokenId)); + return tokenURIs[_tokenId]; + } + + /** + * @dev Gets the token ID at a given index of the tokens list of the requested owner + * @param _owner address owning the tokens list to be accessed + * @param _index uint256 representing the index to be accessed of the requested tokens list + * @return uint256 token ID at the given index of the tokens list owned by the requested address + */ + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256) + { + require(_index < balanceOf(_owner)); + return ownedTokens[_owner][_index]; + } + + /** + * @dev Gets the total amount of tokens stored by the contract + * @return uint256 representing the total amount of tokens + */ + function totalSupply() public view returns (uint256) { + return allTokens.length; + } + + /** + * @dev Gets the token ID at a given index of all the tokens in this contract + * Reverts if the index is greater or equal to the total number of tokens + * @param _index uint256 representing the index to be accessed of the tokens list + * @return uint256 token ID at the given index of the tokens list + */ + function tokenByIndex(uint256 _index) public view returns (uint256) { + require(_index < totalSupply()); + return allTokens[_index]; + } + + /** + * @dev Internal function to set the token URI for a given token + * Reverts if the token ID does not exist + * @param _tokenId uint256 ID of the token to set its URI + * @param _uri string URI to assign + */ + function _setTokenURI(uint256 _tokenId, string _uri) internal { + require(exists(_tokenId)); + tokenURIs[_tokenId] = _uri; + } + + /** + * @dev Internal function to add a token ID to the list of a given address + * @param _to address representing the new owner of the given token ID + * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address + */ + function addTokenTo(address _to, uint256 _tokenId) internal { + super.addTokenTo(_to, _tokenId); + uint256 length = ownedTokens[_to].length; + ownedTokens[_to].push(_tokenId); + ownedTokensIndex[_tokenId] = length; + } + + /** + * @dev Internal function to remove a token ID from the list of a given address + * @param _from address representing the previous owner of the given token ID + * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address + */ + function removeTokenFrom(address _from, uint256 _tokenId) internal { + super.removeTokenFrom(_from, _tokenId); + + // To prevent a gap in the array, we store the last token in the index of the token to delete, and + // then delete the last slot. + uint256 tokenIndex = ownedTokensIndex[_tokenId]; + uint256 lastTokenIndex = ownedTokens[_from].length.sub(1); + uint256 lastToken = ownedTokens[_from][lastTokenIndex]; + + ownedTokens[_from][tokenIndex] = lastToken; + // This also deletes the contents at the last position of the array + ownedTokens[_from].length--; + + // Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to + // be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping + // the lastToken to the first position, and then dropping the element placed in the last position of the list + + ownedTokensIndex[_tokenId] = 0; + ownedTokensIndex[lastToken] = tokenIndex; + } + + /** + * @dev Internal function to mint a new token + * Reverts if the given token ID already exists + * @param _to address the beneficiary that will own the minted token + * @param _tokenId uint256 ID of the token to be minted by the msg.sender + */ + function _mint(address _to, uint256 _tokenId) internal { + super._mint(_to, _tokenId); + + allTokensIndex[_tokenId] = allTokens.length; + allTokens.push(_tokenId); + } + + /** + * @dev Internal function to burn a specific token + * Reverts if the token does not exist + * @param _owner owner of the token to burn + * @param _tokenId uint256 ID of the token being burned by the msg.sender + */ + function _burn(address _owner, uint256 _tokenId) internal { + super._burn(_owner, _tokenId); + + // Clear metadata (if any) + if (bytes(tokenURIs[_tokenId]).length != 0) { + delete tokenURIs[_tokenId]; + } + + // Reorg all tokens array + uint256 tokenIndex = allTokensIndex[_tokenId]; + uint256 lastTokenIndex = allTokens.length.sub(1); + uint256 lastToken = allTokens[lastTokenIndex]; + + allTokens[tokenIndex] = lastToken; + allTokens[lastTokenIndex] = 0; + + allTokens.length--; + allTokensIndex[_tokenId] = 0; + allTokensIndex[lastToken] = tokenIndex; + } + +} + + +// Dependency file: contracts/interfaces/IInterstellarEncoder.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoder { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function registerNewTokenContract(address _tokenAddress) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Root file: contracts/ObjectOwnership.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol"; +// import "contracts/interfaces/IInterstellarEncoder.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/DSAuth.sol"; +// import "contracts/SettingIds.sol"; + +contract ObjectOwnership is ERC721Token("Evolution Land Objects","EVO"), DSAuth, SettingIds { + ISettingsRegistry public registry; + + bool private singletonLock = false; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + /** + * @dev Atlantis's constructor + */ + constructor () public { + // initializeContract(); + } + + /** + * @dev Same with constructor, but is used and called by storage proxy as logic contract. + */ + function initializeContract(address _registry) public singletonLockCall { + // Ownable constructor + owner = msg.sender; + emit LogSetOwner(msg.sender); + + // SupportsInterfaceWithLookup constructor + _registerInterface(InterfaceId_ERC165); + + // ERC721BasicToken constructor + _registerInterface(InterfaceId_ERC721); + _registerInterface(InterfaceId_ERC721Exists); + + // ERC721Token constructor + name_ = "Evolution Land Objects"; + symbol_ = "EVO"; // Evolution Land Objects + // register the supported interfaces to conform to ERC721 via ERC165 + _registerInterface(InterfaceId_ERC721Enumerable); + _registerInterface(InterfaceId_ERC721Metadata); + + registry = ISettingsRegistry(_registry); + } + + function mintObject(address _to, uint128 _objectId) public auth returns (uint256 _tokenId) { + address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); + + _tokenId = IInterstellarEncoder(interstellarEncoder).encodeTokenIdForObjectContract( + address(this), msg.sender, _objectId); + super._mint(_to, _tokenId); + } + + function burnObject(address _to, uint128 _objectId) public auth returns (uint256 _tokenId) { + address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); + + _tokenId = IInterstellarEncoder(interstellarEncoder).encodeTokenIdForObjectContract( + address(this), msg.sender, _objectId); + super._burn(_to, _tokenId); + } + + function mint(address _to, uint256 _tokenId) public auth { + super._mint(_to, _tokenId); + } + + function burn(address _to, uint256 _tokenId) public auth { + super._burn(_to, _tokenId); + } + + //@dev user invoke approveAndCall to create auction + //@param _to - address of auction contractß + function approveAndCall( + address _to, + uint _tokenId, + bytes _extraData + ) public { + // set _to to the auction contract + approve(_to, _tokenId); + + if(!_to.call( + bytes4(keccak256("receiveApproval(address,uint256,bytes)")), abi.encode(msg.sender, _tokenId, _extraData) + )) { + revert(); + } + } +} diff --git a/flat/ObjectOwnershipAuthority.sol b/flat/ObjectOwnershipAuthority.sol new file mode 100644 index 0000000..347dbb0 --- /dev/null +++ b/flat/ObjectOwnershipAuthority.sol @@ -0,0 +1,21 @@ +// Root file: contracts/ObjectOwnershipAuthority.sol + +pragma solidity ^0.4.24; + +contract ObjectOwnershipAuthority { + + mapping (address => bool) public whiteList; + + constructor(address[] _whitelists) public { + for (uint i = 0; i < _whitelists.length; i ++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, address _dst, bytes4 _sig + ) public view returns (bool) { + return ( whiteList[_src] && _sig == bytes4(keccak256("mintObject(address,uint128)")) ) || + ( whiteList[_src] && _sig == bytes4(keccak256("burnObject(address,uint128)")) ); + } +} \ No newline at end of file diff --git a/flat/ObjectOwnershipAuthorityV2.sol b/flat/ObjectOwnershipAuthorityV2.sol new file mode 100644 index 0000000..2f7a597 --- /dev/null +++ b/flat/ObjectOwnershipAuthorityV2.sol @@ -0,0 +1,23 @@ +// Root file: contracts/ObjectOwnershipAuthorityV2.sol + +pragma solidity ^0.4.24; + +contract ObjectOwnershipAuthorityV2 { + + mapping (address => bool) public whiteList; + + constructor(address[] _whitelists) public { + for (uint i = 0; i < _whitelists.length; i ++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, address _dst, bytes4 _sig + ) public view returns (bool) { + return ( whiteList[_src] && _sig == bytes4(keccak256("mintObject(address,uint128)")) ) || + ( whiteList[_src] && _sig == bytes4(keccak256("burnObject(address,uint128)")) ) || + ( whiteList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || + ( whiteList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); + } +} \ No newline at end of file diff --git a/flat/ObjectOwnershipAuthorityV3.sol b/flat/ObjectOwnershipAuthorityV3.sol new file mode 100644 index 0000000..1ba81e2 --- /dev/null +++ b/flat/ObjectOwnershipAuthorityV3.sol @@ -0,0 +1,36 @@ +// Root file: contracts/ObjectOwnershipAuthorityV3.sol + +pragma solidity ^0.4.24; + +/** + * @title ObjectOwnershipAuthority + * @dev ObjectOwnershipAuthority is authority that manage ObjectOwnership. + * difference between ObjectOwnershipAuthority whiteList: +[$LANDBASE_PROXY,$APOSTLEBASE_PROXY,$ERC721BRIDGE_PROXY] ==> [$LANDBASE_PROXY,$APOSTLEBASE_PROXY,$ERC721BRIDGE_PROXY,$DRILLBASE_PROXY] + */ + +contract ObjectOwnershipAuthorityV3 { + mapping(address => bool) public whiteList; + + constructor(address[] memory _whitelists) public { + for (uint256 i = 0; i < _whitelists.length; i++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, + address, /* _dst */ + bytes4 _sig + ) public view returns (bool) { + return + (whiteList[_src] && + _sig == bytes4(keccak256("mintObject(address,uint128)"))) || + (whiteList[_src] && + _sig == bytes4(keccak256("burnObject(address,uint128)"))) || + (whiteList[_src] && + _sig == bytes4(keccak256("mint(address,uint256)"))) || + (whiteList[_src] && + _sig == bytes4(keccak256("burn(address,uint256)"))); + } +} diff --git a/flat/ObjectOwnershipV2.sol b/flat/ObjectOwnershipV2.sol new file mode 100644 index 0000000..38a56b4 --- /dev/null +++ b/flat/ObjectOwnershipV2.sol @@ -0,0 +1,1998 @@ +// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol + +// pragma solidity ^0.4.24; + + +/** + * @title Ownable + * @dev The Ownable contract has an owner address, and provides basic authorization control + * functions, this simplifies the implementation of "user permissions". + */ +contract Ownable { + address public owner; + + + event OwnershipRenounced(address indexed previousOwner); + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + + /** + * @dev The Ownable constructor sets the original `owner` of the contract to the sender + * account. + */ + constructor() public { + owner = msg.sender; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + /** + * @dev Allows the current owner to relinquish control of the contract. + * @notice Renouncing to ownership will leave the contract without an owner. + * It will not be possible to call the functions with the `onlyOwner` + * modifier anymore. + */ + function renounceOwnership() public onlyOwner { + emit OwnershipRenounced(owner); + owner = address(0); + } + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function transferOwnership(address _newOwner) public onlyOwner { + _transferOwnership(_newOwner); + } + + /** + * @dev Transfers control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function _transferOwnership(address _newOwner) internal { + require(_newOwner != address(0)); + emit OwnershipTransferred(owner, _newOwner); + owner = _newOwner; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + + +/** + * @title ERC721 Non-Fungible Token Standard basic interface + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Basic is ERC165 { + + bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; + /* + * 0x80ac58cd === + * bytes4(keccak256('balanceOf(address)')) ^ + * bytes4(keccak256('ownerOf(uint256)')) ^ + * bytes4(keccak256('approve(address,uint256)')) ^ + * bytes4(keccak256('getApproved(uint256)')) ^ + * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ + * bytes4(keccak256('isApprovedForAll(address,address)')) ^ + * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) + */ + + bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; + /* + * 0x4f558e79 === + * bytes4(keccak256('exists(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; + /** + * 0x780e9d63 === + * bytes4(keccak256('totalSupply()')) ^ + * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ + * bytes4(keccak256('tokenByIndex(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; + /** + * 0x5b5e139f === + * bytes4(keccak256('name()')) ^ + * bytes4(keccak256('symbol()')) ^ + * bytes4(keccak256('tokenURI(uint256)')) + */ + + event Transfer( + address indexed _from, + address indexed _to, + uint256 indexed _tokenId + ); + event Approval( + address indexed _owner, + address indexed _approved, + uint256 indexed _tokenId + ); + event ApprovalForAll( + address indexed _owner, + address indexed _operator, + bool _approved + ); + + function balanceOf(address _owner) public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view returns (bool _exists); + + function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) + public view returns (address _operator); + + function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) + public view returns (bool); + + function transferFrom(address _from, address _to, uint256 _tokenId) public; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) + public; + + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public; +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Enumerable is ERC721Basic { + function totalSupply() public view returns (uint256); + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256 _tokenId); + + function tokenByIndex(uint256 _index) public view returns (uint256); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional metadata extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Metadata is ERC721Basic { + function name() external view returns (string _name); + function symbol() external view returns (string _symbol); + function tokenURI(uint256 _tokenId) public view returns (string); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, full implementation interface + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC721 token receiver interface + * @dev Interface for any contract that wants to support safeTransfers + * from ERC721 asset contracts. + */ +contract ERC721Receiver { + /** + * @dev Magic value to be returned upon successful reception of an NFT + * Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`, + * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` + */ + bytes4 internal constant ERC721_RECEIVED = 0x150b7a02; + + /** + * @notice Handle the receipt of an NFT + * @dev The ERC721 smart contract calls this function on the recipient + * after a `safetransfer`. This function MAY throw to revert and reject the + * transfer. Return of other than the magic value MUST result in the + * transaction being reverted. + * Note: the contract address is always the message sender. + * @param _operator The address which called `safeTransferFrom` function + * @param _from The address which previously owned the token + * @param _tokenId The NFT identifier which is being transferred + * @param _data Additional data with no specified format + * @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` + */ + function onERC721Received( + address _operator, + address _from, + uint256 _tokenId, + bytes _data + ) + public + returns(bytes4); +} + + +// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol + +// pragma solidity ^0.4.24; + + +/** + * @title SafeMath + * @dev Math operations with safety checks that throw on error + */ +library SafeMath { + + /** + * @dev Multiplies two numbers, throws on overflow. + */ + function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + // Gas optimization: this is cheaper than asserting 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 + if (_a == 0) { + return 0; + } + + c = _a * _b; + assert(c / _a == _b); + return c; + } + + /** + * @dev Integer division of two numbers, truncating the quotient. + */ + function div(uint256 _a, uint256 _b) internal pure returns (uint256) { + // assert(_b > 0); // Solidity automatically throws when dividing by 0 + // uint256 c = _a / _b; + // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold + return _a / _b; + } + + /** + * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). + */ + function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { + assert(_b <= _a); + return _a - _b; + } + + /** + * @dev Adds two numbers, throws on overflow. + */ + function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + c = _a + _b; + assert(c >= _a); + return c; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/AddressUtils.sol + +// pragma solidity ^0.4.24; + + +/** + * Utility library of inline functions on addresses + */ +library AddressUtils { + + /** + * Returns whether the target address is a contract + * @dev This function will return false if invoked during the constructor of a contract, + * as the code is not actually created until after the constructor finishes. + * @param _addr address to check + * @return whether the target address is a contract + */ + function isContract(address _addr) internal view returns (bool) { + uint256 size; + // XXX Currently there is no better way to check if there is a contract in an address + // than to check the size of the code at that address. + // See https://ethereum.stackexchange.com/a/14016/36603 + // for more details about how this works. + // TODO Check this again before the Serenity release, because all addresses will be + // contracts then. + // solium-disable-next-line security/no-inline-assembly + assembly { size := extcodesize(_addr) } + return size > 0; + } + +} + + +// Dependency file: openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + + +/** + * @title SupportsInterfaceWithLookup + * @author Matt Condon (@shrugs) + * @dev Implements ERC165 using a lookup table. + */ +contract SupportsInterfaceWithLookup is ERC165 { + + bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; + /** + * 0x01ffc9a7 === + * bytes4(keccak256('supportsInterface(bytes4)')) + */ + + /** + * @dev a mapping of interface id to whether or not it's supported + */ + mapping(bytes4 => bool) internal supportedInterfaces; + + /** + * @dev A contract implementing SupportsInterfaceWithLookup + * implement ERC165 itself + */ + constructor() + public + { + _registerInterface(InterfaceId_ERC165); + } + + /** + * @dev implement supportsInterface(bytes4) using a lookup table + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool) + { + return supportedInterfaces[_interfaceId]; + } + + /** + * @dev private method for registering an interface + */ + function _registerInterface(bytes4 _interfaceId) + internal + { + require(_interfaceId != 0xffffffff); + supportedInterfaces[_interfaceId] = true; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721BasicToken.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol"; +// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +// import "openzeppelin-solidity/contracts/AddressUtils.sol"; +// import "openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.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 SupportsInterfaceWithLookup, ERC721Basic { + + 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; + + // Mapping from token ID to owner + mapping (uint256 => address) internal tokenOwner; + + // Mapping from token ID to approved address + mapping (uint256 => address) internal tokenApprovals; + + // Mapping from owner to number of owned token + mapping (address => uint256) internal ownedTokensCount; + + // Mapping from owner to operator approvals + mapping (address => mapping (address => bool)) internal operatorApprovals; + + constructor() + public + { + // register the supported interfaces to conform to ERC721 via ERC165 + _registerInterface(InterfaceId_ERC721); + _registerInterface(InterfaceId_ERC721Exists); + } + + /** + * @dev Gets the balance of the specified address + * @param _owner address to query the balance of + * @return uint256 representing the amount owned by the passed address + */ + function balanceOf(address _owner) public view returns (uint256) { + require(_owner != address(0)); + return ownedTokensCount[_owner]; + } + + /** + * @dev Gets the owner of the specified token ID + * @param _tokenId uint256 ID of the token to query the owner of + * @return owner address currently marked as the owner of the given token ID + */ + function ownerOf(uint256 _tokenId) public view returns (address) { + address owner = tokenOwner[_tokenId]; + require(owner != address(0)); + return owner; + } + + /** + * @dev Returns whether the specified token exists + * @param _tokenId uint256 ID of the token to query the existence of + * @return whether the token exists + */ + function exists(uint256 _tokenId) public view returns (bool) { + address owner = tokenOwner[_tokenId]; + return owner != address(0); + } + + /** + * @dev Approves another address to transfer the given token ID + * The zero address indicates there is no approved address. + * There can only be one approved address per token at a given time. + * Can only be called by the token owner or an approved operator. + * @param _to address to be approved for the given token ID + * @param _tokenId uint256 ID of the token to be approved + */ + function approve(address _to, uint256 _tokenId) public { + address owner = ownerOf(_tokenId); + require(_to != owner); + require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); + + tokenApprovals[_tokenId] = _to; + emit Approval(owner, _to, _tokenId); + } + + /** + * @dev Gets the approved address for a token ID, or zero if no address set + * @param _tokenId uint256 ID of the token to query the approval of + * @return address currently approved for the given token ID + */ + function getApproved(uint256 _tokenId) public view returns (address) { + return tokenApprovals[_tokenId]; + } + + /** + * @dev Sets or unsets the approval of a given operator + * An operator is allowed to transfer all tokens of the sender on their behalf + * @param _to operator address to set the approval + * @param _approved representing the status of the approval to be set + */ + function setApprovalForAll(address _to, bool _approved) public { + require(_to != msg.sender); + operatorApprovals[msg.sender][_to] = _approved; + emit ApprovalForAll(msg.sender, _to, _approved); + } + + /** + * @dev Tells whether an operator is approved by a given owner + * @param _owner owner address which you want to query the approval of + * @param _operator operator address which you want to query the approval of + * @return bool whether the given operator is approved by the given owner + */ + function isApprovedForAll( + address _owner, + address _operator + ) + public + view + returns (bool) + { + return operatorApprovals[_owner][_operator]; + } + + /** + * @dev Transfers the ownership of a given token ID to another address + * Usage of this method is discouraged, use `safeTransferFrom` whenever possible + * Requires the msg sender to be the owner, approved, or operator + * @param _from current owner of the token + * @param _to address to receive the ownership of the given token ID + * @param _tokenId uint256 ID of the token to be transferred + */ + function transferFrom( + address _from, + address _to, + uint256 _tokenId + ) + public + { + require(isApprovedOrOwner(msg.sender, _tokenId)); + require(_from != address(0)); + require(_to != address(0)); + + clearApproval(_from, _tokenId); + removeTokenFrom(_from, _tokenId); + addTokenTo(_to, _tokenId); + + emit Transfer(_from, _to, _tokenId); + } + + /** + * @dev Safely transfers the ownership of a given token ID to another address + * If the target address is a contract, it must implement `onERC721Received`, + * which is called upon a safe transfer, and return the magic value + * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, + * the transfer is reverted. + * + * Requires the msg sender to be the owner, approved, or operator + * @param _from current owner of the token + * @param _to address to receive the ownership of the given token ID + * @param _tokenId uint256 ID of the token to be transferred + */ + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId + ) + public + { + // solium-disable-next-line arg-overflow + safeTransferFrom(_from, _to, _tokenId, ""); + } + + /** + * @dev Safely transfers the ownership of a given token ID to another address + * If the target address is a contract, it must implement `onERC721Received`, + * which is called upon a safe transfer, and return the magic value + * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, + * the transfer is reverted. + * Requires the msg sender to be the owner, approved, or operator + * @param _from current owner of the token + * @param _to address to receive the ownership of the given token ID + * @param _tokenId uint256 ID of the token to be transferred + * @param _data bytes data to send along with a safe transfer check + */ + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public + { + transferFrom(_from, _to, _tokenId); + // solium-disable-next-line arg-overflow + require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); + } + + /** + * @dev Returns whether the given spender can transfer a given token ID + * @param _spender address of the spender to query + * @param _tokenId uint256 ID of the token to be transferred + * @return bool whether the msg.sender is approved for the given token ID, + * is an operator of the owner, or is the owner of the token + */ + function isApprovedOrOwner( + address _spender, + uint256 _tokenId + ) + internal + view + returns (bool) + { + address owner = ownerOf(_tokenId); + // Disable solium check because of + // https://github.com/duaraghav8/Solium/issues/175 + // solium-disable-next-line operator-whitespace + return ( + _spender == owner || + getApproved(_tokenId) == _spender || + isApprovedForAll(owner, _spender) + ); + } + + /** + * @dev Internal function to mint a new token + * Reverts if the given token ID already exists + * @param _to The address that will own the minted token + * @param _tokenId uint256 ID of the token to be minted by the msg.sender + */ + function _mint(address _to, uint256 _tokenId) internal { + require(_to != address(0)); + addTokenTo(_to, _tokenId); + emit Transfer(address(0), _to, _tokenId); + } + + /** + * @dev Internal function to burn a specific token + * Reverts if the token does not exist + * @param _tokenId uint256 ID of the token being burned by the msg.sender + */ + function _burn(address _owner, uint256 _tokenId) internal { + clearApproval(_owner, _tokenId); + removeTokenFrom(_owner, _tokenId); + emit Transfer(_owner, address(0), _tokenId); + } + + /** + * @dev Internal function to clear current approval of a given token ID + * Reverts if the given address is not indeed the owner of the token + * @param _owner owner of the token + * @param _tokenId uint256 ID of the token to be transferred + */ + function clearApproval(address _owner, uint256 _tokenId) internal { + require(ownerOf(_tokenId) == _owner); + if (tokenApprovals[_tokenId] != address(0)) { + tokenApprovals[_tokenId] = address(0); + } + } + + /** + * @dev Internal function to add a token ID to the list of a given address + * @param _to address representing the new owner of the given token ID + * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address + */ + function addTokenTo(address _to, uint256 _tokenId) internal { + require(tokenOwner[_tokenId] == address(0)); + tokenOwner[_tokenId] = _to; + ownedTokensCount[_to] = ownedTokensCount[_to].add(1); + } + + /** + * @dev Internal function to remove a token ID from the list of a given address + * @param _from address representing the previous owner of the given token ID + * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address + */ + function removeTokenFrom(address _from, uint256 _tokenId) internal { + require(ownerOf(_tokenId) == _from); + ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); + tokenOwner[_tokenId] = address(0); + } + + /** + * @dev Internal function to invoke `onERC721Received` on a target address + * The call is not executed if the target address is not a contract + * @param _from address representing the previous owner of the given token ID + * @param _to target address that will receive the tokens + * @param _tokenId uint256 ID of the token to be transferred + * @param _data bytes optional data to send along with the call + * @return whether the call correctly returned the expected magic value + */ + function checkAndCallSafeTransfer( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + internal + returns (bool) + { + if (!_to.isContract()) { + return true; + } + bytes4 retval = ERC721Receiver(_to).onERC721Received( + msg.sender, _from, _tokenId, _data); + return (retval == ERC721_RECEIVED); + } +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721BasicToken.sol"; +// import "openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.sol"; + + +/** + * @title Full ERC721 Token + * This implementation includes all the required and some optional functionality of the ERC721 standard + * Moreover, it includes approve all functionality using operator terminology + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 { + + // Token name + string internal name_; + + // Token symbol + string internal symbol_; + + // Mapping from owner to list of owned token IDs + mapping(address => uint256[]) internal ownedTokens; + + // Mapping from token ID to index of the owner tokens list + mapping(uint256 => uint256) internal ownedTokensIndex; + + // Array with all token ids, used for enumeration + uint256[] internal allTokens; + + // Mapping from token id to position in the allTokens array + mapping(uint256 => uint256) internal allTokensIndex; + + // Optional mapping for token URIs + mapping(uint256 => string) internal tokenURIs; + + /** + * @dev Constructor function + */ + constructor(string _name, string _symbol) public { + name_ = _name; + symbol_ = _symbol; + + // register the supported interfaces to conform to ERC721 via ERC165 + _registerInterface(InterfaceId_ERC721Enumerable); + _registerInterface(InterfaceId_ERC721Metadata); + } + + /** + * @dev Gets the token name + * @return string representing the token name + */ + function name() external view returns (string) { + return name_; + } + + /** + * @dev Gets the token symbol + * @return string representing the token symbol + */ + function symbol() external view returns (string) { + return symbol_; + } + + /** + * @dev Returns an URI for a given token ID + * Throws if the token ID does not exist. May return an empty string. + * @param _tokenId uint256 ID of the token to query + */ + function tokenURI(uint256 _tokenId) public view returns (string) { + require(exists(_tokenId)); + return tokenURIs[_tokenId]; + } + + /** + * @dev Gets the token ID at a given index of the tokens list of the requested owner + * @param _owner address owning the tokens list to be accessed + * @param _index uint256 representing the index to be accessed of the requested tokens list + * @return uint256 token ID at the given index of the tokens list owned by the requested address + */ + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256) + { + require(_index < balanceOf(_owner)); + return ownedTokens[_owner][_index]; + } + + /** + * @dev Gets the total amount of tokens stored by the contract + * @return uint256 representing the total amount of tokens + */ + function totalSupply() public view returns (uint256) { + return allTokens.length; + } + + /** + * @dev Gets the token ID at a given index of all the tokens in this contract + * Reverts if the index is greater or equal to the total number of tokens + * @param _index uint256 representing the index to be accessed of the tokens list + * @return uint256 token ID at the given index of the tokens list + */ + function tokenByIndex(uint256 _index) public view returns (uint256) { + require(_index < totalSupply()); + return allTokens[_index]; + } + + /** + * @dev Internal function to set the token URI for a given token + * Reverts if the token ID does not exist + * @param _tokenId uint256 ID of the token to set its URI + * @param _uri string URI to assign + */ + function _setTokenURI(uint256 _tokenId, string _uri) internal { + require(exists(_tokenId)); + tokenURIs[_tokenId] = _uri; + } + + /** + * @dev Internal function to add a token ID to the list of a given address + * @param _to address representing the new owner of the given token ID + * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address + */ + function addTokenTo(address _to, uint256 _tokenId) internal { + super.addTokenTo(_to, _tokenId); + uint256 length = ownedTokens[_to].length; + ownedTokens[_to].push(_tokenId); + ownedTokensIndex[_tokenId] = length; + } + + /** + * @dev Internal function to remove a token ID from the list of a given address + * @param _from address representing the previous owner of the given token ID + * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address + */ + function removeTokenFrom(address _from, uint256 _tokenId) internal { + super.removeTokenFrom(_from, _tokenId); + + // To prevent a gap in the array, we store the last token in the index of the token to delete, and + // then delete the last slot. + uint256 tokenIndex = ownedTokensIndex[_tokenId]; + uint256 lastTokenIndex = ownedTokens[_from].length.sub(1); + uint256 lastToken = ownedTokens[_from][lastTokenIndex]; + + ownedTokens[_from][tokenIndex] = lastToken; + // This also deletes the contents at the last position of the array + ownedTokens[_from].length--; + + // Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to + // be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping + // the lastToken to the first position, and then dropping the element placed in the last position of the list + + ownedTokensIndex[_tokenId] = 0; + ownedTokensIndex[lastToken] = tokenIndex; + } + + /** + * @dev Internal function to mint a new token + * Reverts if the given token ID already exists + * @param _to address the beneficiary that will own the minted token + * @param _tokenId uint256 ID of the token to be minted by the msg.sender + */ + function _mint(address _to, uint256 _tokenId) internal { + super._mint(_to, _tokenId); + + allTokensIndex[_tokenId] = allTokens.length; + allTokens.push(_tokenId); + } + + /** + * @dev Internal function to burn a specific token + * Reverts if the token does not exist + * @param _owner owner of the token to burn + * @param _tokenId uint256 ID of the token being burned by the msg.sender + */ + function _burn(address _owner, uint256 _tokenId) internal { + super._burn(_owner, _tokenId); + + // Clear metadata (if any) + if (bytes(tokenURIs[_tokenId]).length != 0) { + delete tokenURIs[_tokenId]; + } + + // Reorg all tokens array + uint256 tokenIndex = allTokensIndex[_tokenId]; + uint256 lastTokenIndex = allTokens.length.sub(1); + uint256 lastToken = allTokens[lastTokenIndex]; + + allTokens[tokenIndex] = lastToken; + allTokens[lastTokenIndex] = 0; + + allTokens.length--; + allTokensIndex[_tokenId] = 0; + allTokensIndex[lastToken] = tokenIndex; + } + +} + + +// Dependency file: contracts/interfaces/IInterstellarEncoder.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoder { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function registerNewTokenContract(address _tokenAddress) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Dependency file: contracts/StringUtil.sol + +// https://github.com/Arachnid/solidity-stringutils/tree/master/src + +// https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol#L1036 + +// pragma solidity ^0.4.14; + +library StringUtil { + struct slice { + uint _len; + uint _ptr; + } + + function memcpy(uint dest, uint src, uint len) private pure { + // Copy word-length chunks while possible + for(; len >= 32; len -= 32) { + assembly { + mstore(dest, mload(src)) + } + dest += 32; + src += 32; + } + + // Copy remaining bytes + uint mask = 256 ** (32 - len) - 1; + assembly { + let srcpart := and(mload(src), not(mask)) + let destpart := and(mload(dest), mask) + mstore(dest, or(destpart, srcpart)) + } + } + + /* + * @dev Returns a slice containing the entire string. + * @param self The string to make a slice from. + * @return A newly allocated slice containing the entire string. + */ + function toSlice(string memory self) internal pure returns (slice memory) { + uint ptr; + assembly { + ptr := add(self, 0x20) + } + return slice(bytes(self).length, ptr); + } + + /* + * @dev Returns the length of a null-terminated bytes32 string. + * @param self The value to find the length of. + * @return The length of the string, from 0 to 32. + */ + function len(bytes32 self) internal pure returns (uint) { + uint ret; + if (self == 0) + return 0; + if (self & 0xffffffffffffffffffffffffffffffff == 0) { + ret += 16; + self = bytes32(uint(self) / 0x100000000000000000000000000000000); + } + if (self & 0xffffffffffffffff == 0) { + ret += 8; + self = bytes32(uint(self) / 0x10000000000000000); + } + if (self & 0xffffffff == 0) { + ret += 4; + self = bytes32(uint(self) / 0x100000000); + } + if (self & 0xffff == 0) { + ret += 2; + self = bytes32(uint(self) / 0x10000); + } + if (self & 0xff == 0) { + ret += 1; + } + return 32 - ret; + } + + /* + * @dev Returns a slice containing the entire bytes32, interpreted as a + * null-terminated utf-8 string. + * @param self The bytes32 value to convert to a slice. + * @return A new slice containing the value of the input argument up to the + * first null. + */ + function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { + // Allocate space for `self` in memory, copy it there, and point ret at it + assembly { + let ptr := mload(0x40) + mstore(0x40, add(ptr, 0x20)) + mstore(ptr, self) + mstore(add(ret, 0x20), ptr) + } + ret._len = len(self); + } + + /* + * @dev Returns a new slice containing the same data as the current slice. + * @param self The slice to copy. + * @return A new slice containing the same data as `self`. + */ + function copy(slice memory self) internal pure returns (slice memory) { + return slice(self._len, self._ptr); + } + + /* + * @dev Copies a slice to a new string. + * @param self The slice to copy. + * @return A newly allocated string containing the slice's text. + */ + function toString(slice memory self) internal pure returns (string memory) { + string memory ret = new string(self._len); + uint retptr; + assembly { retptr := add(ret, 32) } + + memcpy(retptr, self._ptr, self._len); + return ret; + } + + /* + * @dev Returns the length in runes of the slice. Note that this operation + * takes time proportional to the length of the slice; avoid using it + * in loops, and call `slice.empty()` if you only need to know whether + * the slice is empty or not. + * @param self The slice to operate on. + * @return The length of the slice in runes. + */ + function len(slice memory self) internal pure returns (uint l) { + // Starting at ptr-31 means the LSB will be the byte we care about + uint ptr = self._ptr - 31; + uint end = ptr + self._len; + for (l = 0; ptr < end; l++) { + uint8 b; + assembly { b := and(mload(ptr), 0xFF) } + if (b < 0x80) { + ptr += 1; + } else if(b < 0xE0) { + ptr += 2; + } else if(b < 0xF0) { + ptr += 3; + } else if(b < 0xF8) { + ptr += 4; + } else if(b < 0xFC) { + ptr += 5; + } else { + ptr += 6; + } + } + } + + /* + * @dev Returns true if the slice is empty (has a length of 0). + * @param self The slice to operate on. + * @return True if the slice is empty, False otherwise. + */ + function empty(slice memory self) internal pure returns (bool) { + return self._len == 0; + } + + /* + * @dev Returns a positive number if `other` comes lexicographically after + * `self`, a negative number if it comes before, or zero if the + * contents of the two slices are equal. Comparison is done per-rune, + * on unicode codepoints. + * @param self The first slice to compare. + * @param other The second slice to compare. + * @return The result of the comparison. + */ + function compare(slice memory self, slice memory other) internal pure returns (int) { + uint shortest = self._len; + if (other._len < self._len) + shortest = other._len; + + uint selfptr = self._ptr; + uint otherptr = other._ptr; + for (uint idx = 0; idx < shortest; idx += 32) { + uint a; + uint b; + assembly { + a := mload(selfptr) + b := mload(otherptr) + } + if (a != b) { + // Mask out irrelevant bytes and check again + uint256 mask = uint256(-1); // 0xffff... + if(shortest < 32) { + mask = ~(2 ** (8 * (32 - shortest + idx)) - 1); + } + uint256 diff = (a & mask) - (b & mask); + if (diff != 0) + return int(diff); + } + selfptr += 32; + otherptr += 32; + } + return int(self._len) - int(other._len); + } + + /* + * @dev Returns true if the two slices contain the same text. + * @param self The first slice to compare. + * @param self The second slice to compare. + * @return True if the slices are equal, false otherwise. + */ + function equals(slice memory self, slice memory other) internal pure returns (bool) { + return compare(self, other) == 0; + } + + /* + * @dev Extracts the first rune in the slice into `rune`, advancing the + * slice to point to the next rune and returning `self`. + * @param self The slice to operate on. + * @param rune The slice that will contain the first rune. + * @return `rune`. + */ + function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) { + rune._ptr = self._ptr; + + if (self._len == 0) { + rune._len = 0; + return rune; + } + + uint l; + uint b; + // Load the first byte of the rune into the LSBs of b + assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) } + if (b < 0x80) { + l = 1; + } else if(b < 0xE0) { + l = 2; + } else if(b < 0xF0) { + l = 3; + } else { + l = 4; + } + + // Check for truncated codepoints + if (l > self._len) { + rune._len = self._len; + self._ptr += self._len; + self._len = 0; + return rune; + } + + self._ptr += l; + self._len -= l; + rune._len = l; + return rune; + } + + /* + * @dev Returns the first rune in the slice, advancing the slice to point + * to the next rune. + * @param self The slice to operate on. + * @return A slice containing only the first rune from `self`. + */ + function nextRune(slice memory self) internal pure returns (slice memory ret) { + nextRune(self, ret); + } + + /* + * @dev Returns the number of the first codepoint in the slice. + * @param self The slice to operate on. + * @return The number of the first codepoint in the slice. + */ + function ord(slice memory self) internal pure returns (uint ret) { + if (self._len == 0) { + return 0; + } + + uint word; + uint length; + uint divisor = 2 ** 248; + + // Load the rune into the MSBs of b + assembly { word:= mload(mload(add(self, 32))) } + uint b = word / divisor; + if (b < 0x80) { + ret = b; + length = 1; + } else if(b < 0xE0) { + ret = b & 0x1F; + length = 2; + } else if(b < 0xF0) { + ret = b & 0x0F; + length = 3; + } else { + ret = b & 0x07; + length = 4; + } + + // Check for truncated codepoints + if (length > self._len) { + return 0; + } + + for (uint i = 1; i < length; i++) { + divisor = divisor / 256; + b = (word / divisor) & 0xFF; + if (b & 0xC0 != 0x80) { + // Invalid UTF-8 sequence + return 0; + } + ret = (ret * 64) | (b & 0x3F); + } + + return ret; + } + + /* + * @dev Returns the keccak-256 hash of the slice. + * @param self The slice to hash. + * @return The hash of the slice. + */ + function keccak(slice memory self) internal pure returns (bytes32 ret) { + assembly { + ret := keccak256(mload(add(self, 32)), mload(self)) + } + } + + /* + * @dev Returns true if `self` starts with `needle`. + * @param self The slice to operate on. + * @param needle The slice to search for. + * @return True if the slice starts with the provided text, false otherwise. + */ + function startsWith(slice memory self, slice memory needle) internal pure returns (bool) { + if (self._len < needle._len) { + return false; + } + + if (self._ptr == needle._ptr) { + return true; + } + + bool equal; + assembly { + let length := mload(needle) + let selfptr := mload(add(self, 0x20)) + let needleptr := mload(add(needle, 0x20)) + equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) + } + return equal; + } + + /* + * @dev If `self` starts with `needle`, `needle` is removed from the + * beginning of `self`. Otherwise, `self` is unmodified. + * @param self The slice to operate on. + * @param needle The slice to search for. + * @return `self` + */ + function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) { + if (self._len < needle._len) { + return self; + } + + bool equal = true; + if (self._ptr != needle._ptr) { + assembly { + let length := mload(needle) + let selfptr := mload(add(self, 0x20)) + let needleptr := mload(add(needle, 0x20)) + equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) + } + } + + if (equal) { + self._len -= needle._len; + self._ptr += needle._len; + } + + return self; + } + + /* + * @dev Returns true if the slice ends with `needle`. + * @param self The slice to operate on. + * @param needle The slice to search for. + * @return True if the slice starts with the provided text, false otherwise. + */ + function endsWith(slice memory self, slice memory needle) internal pure returns (bool) { + if (self._len < needle._len) { + return false; + } + + uint selfptr = self._ptr + self._len - needle._len; + + if (selfptr == needle._ptr) { + return true; + } + + bool equal; + assembly { + let length := mload(needle) + let needleptr := mload(add(needle, 0x20)) + equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) + } + + return equal; + } + + /* + * @dev If `self` ends with `needle`, `needle` is removed from the + * end of `self`. Otherwise, `self` is unmodified. + * @param self The slice to operate on. + * @param needle The slice to search for. + * @return `self` + */ + function until(slice memory self, slice memory needle) internal pure returns (slice memory) { + if (self._len < needle._len) { + return self; + } + + uint selfptr = self._ptr + self._len - needle._len; + bool equal = true; + if (selfptr != needle._ptr) { + assembly { + let length := mload(needle) + let needleptr := mload(add(needle, 0x20)) + equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) + } + } + + if (equal) { + self._len -= needle._len; + } + + return self; + } + + // Returns the memory address of the first byte of the first occurrence of + // `needle` in `self`, or the first byte after `self` if not found. + function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { + uint ptr = selfptr; + uint idx; + + if (needlelen <= selflen) { + if (needlelen <= 32) { + bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); + + bytes32 needledata; + assembly { needledata := and(mload(needleptr), mask) } + + uint end = selfptr + selflen - needlelen; + bytes32 ptrdata; + assembly { ptrdata := and(mload(ptr), mask) } + + while (ptrdata != needledata) { + if (ptr >= end) + return selfptr + selflen; + ptr++; + assembly { ptrdata := and(mload(ptr), mask) } + } + return ptr; + } else { + // For long needles, use hashing + bytes32 hash; + assembly { hash := keccak256(needleptr, needlelen) } + + for (idx = 0; idx <= selflen - needlelen; idx++) { + bytes32 testHash; + assembly { testHash := keccak256(ptr, needlelen) } + if (hash == testHash) + return ptr; + ptr += 1; + } + } + } + return selfptr + selflen; + } + + // Returns the memory address of the first byte after the last occurrence of + // `needle` in `self`, or the address of `self` if not found. + function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { + uint ptr; + + if (needlelen <= selflen) { + if (needlelen <= 32) { + bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); + + bytes32 needledata; + assembly { needledata := and(mload(needleptr), mask) } + + ptr = selfptr + selflen - needlelen; + bytes32 ptrdata; + assembly { ptrdata := and(mload(ptr), mask) } + + while (ptrdata != needledata) { + if (ptr <= selfptr) + return selfptr; + ptr--; + assembly { ptrdata := and(mload(ptr), mask) } + } + return ptr + needlelen; + } else { + // For long needles, use hashing + bytes32 hash; + assembly { hash := keccak256(needleptr, needlelen) } + ptr = selfptr + (selflen - needlelen); + while (ptr >= selfptr) { + bytes32 testHash; + assembly { testHash := keccak256(ptr, needlelen) } + if (hash == testHash) + return ptr + needlelen; + ptr -= 1; + } + } + } + return selfptr; + } + + /* + * @dev Modifies `self` to contain everything from the first occurrence of + * `needle` to the end of the slice. `self` is set to the empty slice + * if `needle` is not found. + * @param self The slice to search and modify. + * @param needle The text to search for. + * @return `self`. + */ + function find(slice memory self, slice memory needle) internal pure returns (slice memory) { + uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); + self._len -= ptr - self._ptr; + self._ptr = ptr; + return self; + } + + /* + * @dev Modifies `self` to contain the part of the string from the start of + * `self` to the end of the first occurrence of `needle`. If `needle` + * is not found, `self` is set to the empty slice. + * @param self The slice to search and modify. + * @param needle The text to search for. + * @return `self`. + */ + function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) { + uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); + self._len = ptr - self._ptr; + return self; + } + + /* + * @dev Splits the slice, setting `self` to everything after the first + * occurrence of `needle`, and `token` to everything before it. If + * `needle` does not occur in `self`, `self` is set to the empty slice, + * and `token` is set to the entirety of `self`. + * @param self The slice to split. + * @param needle The text to search for in `self`. + * @param token An output parameter to which the first token is written. + * @return `token`. + */ + function split(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { + uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); + token._ptr = self._ptr; + token._len = ptr - self._ptr; + if (ptr == self._ptr + self._len) { + // Not found + self._len = 0; + } else { + self._len -= token._len + needle._len; + self._ptr = ptr + needle._len; + } + return token; + } + + /* + * @dev Splits the slice, setting `self` to everything after the first + * occurrence of `needle`, and returning everything before it. If + * `needle` does not occur in `self`, `self` is set to the empty slice, + * and the entirety of `self` is returned. + * @param self The slice to split. + * @param needle The text to search for in `self`. + * @return The part of `self` up to the first occurrence of `delim`. + */ + function split(slice memory self, slice memory needle) internal pure returns (slice memory token) { + split(self, needle, token); + } + + /* + * @dev Splits the slice, setting `self` to everything before the last + * occurrence of `needle`, and `token` to everything after it. If + * `needle` does not occur in `self`, `self` is set to the empty slice, + * and `token` is set to the entirety of `self`. + * @param self The slice to split. + * @param needle The text to search for in `self`. + * @param token An output parameter to which the first token is written. + * @return `token`. + */ + function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { + uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); + token._ptr = ptr; + token._len = self._len - (ptr - self._ptr); + if (ptr == self._ptr) { + // Not found + self._len = 0; + } else { + self._len -= token._len + needle._len; + } + return token; + } + + /* + * @dev Splits the slice, setting `self` to everything before the last + * occurrence of `needle`, and returning everything after it. If + * `needle` does not occur in `self`, `self` is set to the empty slice, + * and the entirety of `self` is returned. + * @param self The slice to split. + * @param needle The text to search for in `self`. + * @return The part of `self` after the last occurrence of `delim`. + */ + function rsplit(slice memory self, slice memory needle) internal pure returns (slice memory token) { + rsplit(self, needle, token); + } + + /* + * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`. + * @param self The slice to search. + * @param needle The text to search for in `self`. + * @return The number of occurrences of `needle` found in `self`. + */ + function count(slice memory self, slice memory needle) internal pure returns (uint cnt) { + uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; + while (ptr <= self._ptr + self._len) { + cnt++; + ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; + } + } + + /* + * @dev Returns True if `self` contains `needle`. + * @param self The slice to search. + * @param needle The text to search for in `self`. + * @return True if `needle` is found in `self`, false otherwise. + */ + function contains(slice memory self, slice memory needle) internal pure returns (bool) { + return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; + } + + /* + * @dev Returns a newly allocated string containing the concatenation of + * `self` and `other`. + * @param self The first slice to concatenate. + * @param other The second slice to concatenate. + * @return The concatenation of the two strings. + */ + function concat(slice memory self, slice memory other) internal pure returns (string memory) { + string memory ret = new string(self._len + other._len); + uint retptr; + assembly { retptr := add(ret, 32) } + memcpy(retptr, self._ptr, self._len); + memcpy(retptr + self._len, other._ptr, other._len); + return ret; + } + + /* + * @dev Joins an array of slices, using `self` as a delimiter, returning a + * newly allocated string. + * @param self The delimiter to use. + * @param parts A list of slices to join. + * @return A newly allocated string containing all the slices in `parts`, + * joined with `self`. + */ + function join(slice memory self, slice[] memory parts) internal pure returns (string memory) { + if (parts.length == 0) + return ""; + + uint length = self._len * (parts.length - 1); + for(uint i = 0; i < parts.length; i++) + length += parts[i]._len; + + string memory ret = new string(length); + uint retptr; + assembly { retptr := add(ret, 32) } + + for(i = 0; i < parts.length; i++) { + memcpy(retptr, parts[i]._ptr, parts[i]._len); + retptr += parts[i]._len; + if (i < parts.length - 1) { + memcpy(retptr, self._ptr, self._len); + retptr += self._len; + } + } + + return ret; + } + + function uint2str(uint _int) internal pure returns (string memory _uintAsString) { + uint _i = _int; + if (_i == 0) { + return "0"; + } + uint j = _i; + uint length; + while (j != 0) { + length++; + j /= 10; + } + bytes memory bstr = new bytes(length); + uint k = length - 1; + while (_i != 0) { + bstr[k--] = byte(uint8(48 + _i % 10)); + _i /= 10; + } + return string(bstr); + } +} + +// Root file: contracts/ObjectOwnershipV2.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol"; +// import "contracts/interfaces/IInterstellarEncoder.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/DSAuth.sol"; +// import "contracts/SettingIds.sol"; +// import "contracts/StringUtil.sol"; + +contract ObjectOwnershipV2 is ERC721Token("Evolution Land Objects","EVO"), DSAuth, SettingIds { + using StringUtil for *; + + ISettingsRegistry public registry; + + bool private singletonLock = false; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + // https://docs.opensea.io/docs/2-adding-metadata + string public baseTokenURI; + + /** + * @dev Atlantis's constructor + */ + constructor () public { + // initializeContract(); + } + + /** + * @dev Same with constructor, but is used and called by storage proxy as logic contract. + */ + function initializeContract(address _registry) public singletonLockCall { + // Ownable constructor + owner = msg.sender; + emit LogSetOwner(msg.sender); + + // SupportsInterfaceWithLookup constructor + _registerInterface(InterfaceId_ERC165); + + // ERC721BasicToken constructor + _registerInterface(InterfaceId_ERC721); + _registerInterface(InterfaceId_ERC721Exists); + + // ERC721Token constructor + name_ = "Evolution Land Objects"; + symbol_ = "EVO"; // Evolution Land Objects + // register the supported interfaces to conform to ERC721 via ERC165 + _registerInterface(InterfaceId_ERC721Enumerable); + _registerInterface(InterfaceId_ERC721Metadata); + + registry = ISettingsRegistry(_registry); + } + + function tokenURI(uint256 _tokenId) public view returns (string) { + if (super.tokenURI(_tokenId).toSlice().empty()) { + return baseTokenURI.toSlice().concat(StringUtil.uint2str(_tokenId).toSlice()); + } + + return super.tokenURI(_tokenId); + } + + function setTokenURI(uint256 _tokenId, string _uri) public auth { + _setTokenURI(_tokenId, _uri); + } + + function setBaseTokenURI(string _newBaseTokenURI) public auth { + baseTokenURI = _newBaseTokenURI; + } + + function mintObject(address _to, uint128 _objectId) public auth returns (uint256 _tokenId) { + address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); + + _tokenId = IInterstellarEncoder(interstellarEncoder).encodeTokenIdForObjectContract( + address(this), msg.sender, _objectId); + super._mint(_to, _tokenId); + } + + function burnObject(address _to, uint128 _objectId) public auth returns (uint256 _tokenId) { + address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); + + _tokenId = IInterstellarEncoder(interstellarEncoder).encodeTokenIdForObjectContract( + address(this), msg.sender, _objectId); + super._burn(_to, _tokenId); + } + + function mint(address _to, uint256 _tokenId) public auth { + super._mint(_to, _tokenId); + } + + function burn(address _to, uint256 _tokenId) public auth { + super._burn(_to, _tokenId); + } + + //@dev user invoke approveAndCall to create auction + //@param _to - address of auction contractß + function approveAndCall( + address _to, + uint _tokenId, + bytes _extraData + ) public { + // set _to to the auction contract + approve(_to, _tokenId); + + if(!_to.call( + bytes4(keccak256("receiveApproval(address,uint256,bytes)")), abi.encode(msg.sender, _tokenId, _extraData) + )) { + revert(); + } + } +} diff --git a/flat/PausableDSAuth.sol b/flat/PausableDSAuth.sol new file mode 100644 index 0000000..ad09228 --- /dev/null +++ b/flat/PausableDSAuth.sol @@ -0,0 +1,123 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Root file: contracts/PausableDSAuth.sol + +pragma solidity ^0.4.24; + +// import "contracts/DSAuth.sol"; + + +/** + * @title Pausable + * @dev Base contract which allows children to implement an emergency stop mechanism. + */ +contract PausableDSAuth is DSAuth { + event Pause(); + event Unpause(); + + bool public paused = false; + + + /** + * @dev Modifier to make a function callable only when the contract is not paused. + */ + modifier whenNotPaused() { + require(!paused); + _; + } + + /** + * @dev Modifier to make a function callable only when the contract is paused. + */ + modifier whenPaused() { + require(paused); + _; + } + + /** + * @dev called by the owner to pause, triggers stopped state + */ + function pause() public onlyOwner whenNotPaused { + paused = true; + emit Pause(); + } + + /** + * @dev called by the owner to unpause, returns to normal state + */ + function unpause() public onlyOwner whenPaused { + paused = false; + emit Unpause(); + } +} \ No newline at end of file diff --git a/flat/Proposal.sol b/flat/Proposal.sol new file mode 100644 index 0000000..2b9cf00 --- /dev/null +++ b/flat/Proposal.sol @@ -0,0 +1,32 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Root file: contracts/Proposal.sol + +pragma solidity ^0.4.24; + +// import "contracts/interfaces/IAuthority.sol"; + +contract Proposal is IAuthority { + + function doSomething() public { + // do changes to destiantion + } + + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool) + { + if (src == address(this)) + { + return true; + } + } +} \ No newline at end of file diff --git a/flat/ProposalRegistry.sol b/flat/ProposalRegistry.sol new file mode 100644 index 0000000..d9f5efd --- /dev/null +++ b/flat/ProposalRegistry.sol @@ -0,0 +1,215 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/Proposal.sol + +// pragma solidity ^0.4.24; + +// import "contracts/interfaces/IAuthority.sol"; + +contract Proposal is IAuthority { + + function doSomething() public { + // do changes to destiantion + } + + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool) + { + if (src == address(this)) + { + return true; + } + } +} + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Dependency file: contracts/KtonVoter.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; + +/// @title KtonVoter +/// @dev Voting and support specific proposal validator by deposit KTON +/// Vote will be cancel after KTON get withdrawd +/// 1 KTON means one vote +contract KtonVoter { + address public KTON; + + struct VoterItem { + // mapping (address => mapping (address => uint256)) public votes; + mapping (address => uint256) votes; + // mapping (address => uint256) public depositBalances; + uint256 balance; + // TODO: address[] candidates; + } + + struct CandidateItem { + uint256 voteCount; // contract address + uint256 sortedIndex; // index of the item in the list of sortedCandidate + bool isRegistered; // used to tell if the mapping element is defined + // TODO: address[] voters; + } + + mapping (address => VoterItem) public voterItems; + + mapping (address => CandidateItem) public cadidateItems; + + // descending + address[] public sortedCandidates; + + function vote(address _candidate, uint _amount) public { + require(cadidateItems[_candidate].isRegistered); + require(ERC20(KTON).transferFrom(msg.sender, address(this), _amount)); + + voterItems[msg.sender].votes[_candidate] += _amount; + voterItems[msg.sender].balance += _amount; + + cadidateItems[_candidate].voteCount += _amount; + + // TODO: update sortedIndex + quickSort(0, cadidateItems[_candidate].sortedIndex); + } + + function withdrawFrom(address _candidate, uint _amount) public { + require(voterItems[msg.sender].votes[_candidate] >= _amount); + + voterItems[msg.sender].votes[_candidate] -= _amount; + voterItems[msg.sender].balance -= _amount; + cadidateItems[_candidate].voteCount -= _amount; + + require(ERC20(KTON).transfer(msg.sender, _amount)); + + // TODO: update sortedIndex + quickSort(cadidateItems[_candidate].sortedIndex, sortedCandidates.length - 1); + } + + function getCandidate(uint _num) public view returns (address candidate){ + require(_num < sortedCandidates.length); + candidate = sortedCandidates[_num]; + } + + function registerCandidate() public { + // require(ERC20(KTON).transferFrom(msg.sender, address(this), 1000000000000000000000)); + require(!cadidateItems[msg.sender].isRegistered); + + cadidateItems[msg.sender].isRegistered = true; + sortedCandidates.push(msg.sender); + cadidateItems[msg.sender].sortedIndex = sortedCandidates.length - 1; + } + + // http://www.etherdevops.com/content/sorting-array-integer-ethereum + function quickSort(uint left, uint right) internal { + uint i = left; + uint j = right; + uint pivot = cadidateItems[sortedCandidates[left + (right - left) / 2]].voteCount; + while (i <= j) { + while (cadidateItems[sortedCandidates[i]].voteCount < pivot) i++; + while (pivot < cadidateItems[sortedCandidates[j]].voteCount) j--; + if (i <= j) { + (sortedCandidates[i], sortedCandidates[j]) = (sortedCandidates[j], sortedCandidates[i]); + cadidateItems[sortedCandidates[i]].sortedIndex = i; + cadidateItems[sortedCandidates[j]].sortedIndex = j; + + i++; + j--; + } + } + if (left < j) + quickSort(left, j); + if (i < right) + quickSort(i, right); + } +} + +// Root file: contracts/ProposalRegistry.sol + +pragma solidity ^0.4.24; + +// import "contracts/interfaces/IAuthority.sol"; +// import "contracts/Proposal.sol"; +// import "contracts/KtonVoter.sol"; + +contract ProposalRegistry is IAuthority { + + // refer https://github.com/gnosis/MultiSigWallet/blob/master/contracts/MultiSigWallet.sol + // TODO: We can create a similar VoterWallet.sol + mapping (uint => Proposal) public proposals; + mapping (uint => mapping (address => bool)) public confirmations; + + mapping (address => bool) public proposalsApproved; + + KtonVoter public voter; + + uint public required; + + uint public transactionCount; + + function executeProposal(uint proposalId) public { + // TODO + proposals[proposalId].doSomething(); + } + + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool) + { + if (proposalsApproved[src]) + { + return Proposal(src).canCall(src, dst, sig); + } + } +} \ No newline at end of file diff --git a/flat/RBACWithAdmin.sol b/flat/RBACWithAdmin.sol new file mode 100644 index 0000000..ee3f162 --- /dev/null +++ b/flat/RBACWithAdmin.sol @@ -0,0 +1,238 @@ +// Dependency file: openzeppelin-solidity/contracts/access/rbac/Roles.sol + +// pragma solidity ^0.4.24; + + +/** + * @title Roles + * @author Francisco Giordano (@frangio) + * @dev Library for managing addresses assigned to a Role. + * See RBAC.sol for example usage. + */ +library Roles { + struct Role { + mapping (address => bool) bearer; + } + + /** + * @dev give an address access to this role + */ + function add(Role storage _role, address _addr) + internal + { + _role.bearer[_addr] = true; + } + + /** + * @dev remove an address' access to this role + */ + function remove(Role storage _role, address _addr) + internal + { + _role.bearer[_addr] = false; + } + + /** + * @dev check if an address has this role + * // reverts + */ + function check(Role storage _role, address _addr) + internal + view + { + require(has(_role, _addr)); + } + + /** + * @dev check if an address has this role + * @return bool + */ + function has(Role storage _role, address _addr) + internal + view + returns (bool) + { + return _role.bearer[_addr]; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/access/rbac/RBAC.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/access/rbac/Roles.sol"; + + +/** + * @title RBAC (Role-Based Access Control) + * @author Matt Condon (@Shrugs) + * @dev Stores and provides setters and getters for roles and addresses. + * Supports unlimited numbers of roles and addresses. + * See //contracts/mocks/RBACMock.sol for an example of usage. + * This RBAC method uses strings to key roles. It may be beneficial + * for you to write your own implementation of this interface using Enums or similar. + */ +contract RBAC { + using Roles for Roles.Role; + + mapping (string => Roles.Role) private roles; + + event RoleAdded(address indexed operator, string role); + event RoleRemoved(address indexed operator, string role); + + /** + * @dev reverts if addr does not have role + * @param _operator address + * @param _role the name of the role + * // reverts + */ + function checkRole(address _operator, string _role) + public + view + { + roles[_role].check(_operator); + } + + /** + * @dev determine if addr has role + * @param _operator address + * @param _role the name of the role + * @return bool + */ + function hasRole(address _operator, string _role) + public + view + returns (bool) + { + return roles[_role].has(_operator); + } + + /** + * @dev add a role to an address + * @param _operator address + * @param _role the name of the role + */ + function addRole(address _operator, string _role) + internal + { + roles[_role].add(_operator); + emit RoleAdded(_operator, _role); + } + + /** + * @dev remove a role from an address + * @param _operator address + * @param _role the name of the role + */ + function removeRole(address _operator, string _role) + internal + { + roles[_role].remove(_operator); + emit RoleRemoved(_operator, _role); + } + + /** + * @dev modifier to scope access to a single role (uses msg.sender as addr) + * @param _role the name of the role + * // reverts + */ + modifier onlyRole(string _role) + { + checkRole(msg.sender, _role); + _; + } + + /** + * @dev modifier to scope access to a set of roles (uses msg.sender as addr) + * @param _roles the names of the roles to scope access to + * // reverts + * + * @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this + * see: https://github.com/ethereum/solidity/issues/2467 + */ + // modifier onlyRoles(string[] _roles) { + // bool hasAnyRole = false; + // for (uint8 i = 0; i < _roles.length; i++) { + // if (hasRole(msg.sender, _roles[i])) { + // hasAnyRole = true; + // break; + // } + // } + + // require(hasAnyRole); + + // _; + // } +} + + +// Root file: contracts/RBACWithAdmin.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/access/rbac/RBAC.sol"; + +// https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/examples/RBACWithAdmin.sol + +/** + * @title RBACWithAdmin + * @author Matt Condon (@Shrugs) + * @dev It's recommended that you define constants in the contract, + * like ROLE_ADMIN below, to avoid typos. + * @notice RBACWithAdmin is probably too expansive and powerful for your + * application; an admin is actually able to change any address to any role + * which is a very large API surface. It's recommended that you follow a strategy + * of strictly defining the abilities of your roles + * and the API-surface of your contract. + * This is just an example for example's sake. + */ +contract RBACWithAdmin is RBAC { + /** + * A constant role name for indicating admins. + */ + string public constant ROLE_ADMIN = "admin"; + + /** + * @dev modifier to scope access to admins + * // reverts + */ + modifier onlyAdmin() + { + checkRole(msg.sender, ROLE_ADMIN); + _; + } + + /** + * @dev constructor. Sets msg.sender as admin by default + */ + constructor() + public + { + addRole(msg.sender, ROLE_ADMIN); + } + + /** + * @dev add a role to an account + * @param _account the account that will have the role + * @param _roleName the name of the role + */ + function adminAddRole(address _account, string _roleName) + public + onlyAdmin + { + addRole(_account, _roleName); + } + + /** + * @dev remove a role from an account + * @param _account the account that will no longer have the role + * @param _roleName the name of the role + */ + function adminRemoveRole(address _account, string _roleName) + public + onlyAdmin + { + removeRole(_account, _roleName); + } +} \ No newline at end of file diff --git a/flat/RBACWithAuth.sol b/flat/RBACWithAuth.sol new file mode 100644 index 0000000..e0e69e5 --- /dev/null +++ b/flat/RBACWithAuth.sol @@ -0,0 +1,317 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: openzeppelin-solidity/contracts/access/rbac/Roles.sol + +// pragma solidity ^0.4.24; + + +/** + * @title Roles + * @author Francisco Giordano (@frangio) + * @dev Library for managing addresses assigned to a Role. + * See RBAC.sol for example usage. + */ +library Roles { + struct Role { + mapping (address => bool) bearer; + } + + /** + * @dev give an address access to this role + */ + function add(Role storage _role, address _addr) + internal + { + _role.bearer[_addr] = true; + } + + /** + * @dev remove an address' access to this role + */ + function remove(Role storage _role, address _addr) + internal + { + _role.bearer[_addr] = false; + } + + /** + * @dev check if an address has this role + * // reverts + */ + function check(Role storage _role, address _addr) + internal + view + { + require(has(_role, _addr)); + } + + /** + * @dev check if an address has this role + * @return bool + */ + function has(Role storage _role, address _addr) + internal + view + returns (bool) + { + return _role.bearer[_addr]; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/access/rbac/RBAC.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/access/rbac/Roles.sol"; + + +/** + * @title RBAC (Role-Based Access Control) + * @author Matt Condon (@Shrugs) + * @dev Stores and provides setters and getters for roles and addresses. + * Supports unlimited numbers of roles and addresses. + * See //contracts/mocks/RBACMock.sol for an example of usage. + * This RBAC method uses strings to key roles. It may be beneficial + * for you to write your own implementation of this interface using Enums or similar. + */ +contract RBAC { + using Roles for Roles.Role; + + mapping (string => Roles.Role) private roles; + + event RoleAdded(address indexed operator, string role); + event RoleRemoved(address indexed operator, string role); + + /** + * @dev reverts if addr does not have role + * @param _operator address + * @param _role the name of the role + * // reverts + */ + function checkRole(address _operator, string _role) + public + view + { + roles[_role].check(_operator); + } + + /** + * @dev determine if addr has role + * @param _operator address + * @param _role the name of the role + * @return bool + */ + function hasRole(address _operator, string _role) + public + view + returns (bool) + { + return roles[_role].has(_operator); + } + + /** + * @dev add a role to an address + * @param _operator address + * @param _role the name of the role + */ + function addRole(address _operator, string _role) + internal + { + roles[_role].add(_operator); + emit RoleAdded(_operator, _role); + } + + /** + * @dev remove a role from an address + * @param _operator address + * @param _role the name of the role + */ + function removeRole(address _operator, string _role) + internal + { + roles[_role].remove(_operator); + emit RoleRemoved(_operator, _role); + } + + /** + * @dev modifier to scope access to a single role (uses msg.sender as addr) + * @param _role the name of the role + * // reverts + */ + modifier onlyRole(string _role) + { + checkRole(msg.sender, _role); + _; + } + + /** + * @dev modifier to scope access to a set of roles (uses msg.sender as addr) + * @param _roles the names of the roles to scope access to + * // reverts + * + * @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this + * see: https://github.com/ethereum/solidity/issues/2467 + */ + // modifier onlyRoles(string[] _roles) { + // bool hasAnyRole = false; + // for (uint8 i = 0; i < _roles.length; i++) { + // if (hasRole(msg.sender, _roles[i])) { + // hasAnyRole = true; + // break; + // } + // } + + // require(hasAnyRole); + + // _; + // } +} + + +// Dependency file: contracts/RBACWithAdmin.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/access/rbac/RBAC.sol"; + +// https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/examples/RBACWithAdmin.sol + +/** + * @title RBACWithAdmin + * @author Matt Condon (@Shrugs) + * @dev It's recommended that you define constants in the contract, + * like ROLE_ADMIN below, to avoid typos. + * @notice RBACWithAdmin is probably too expansive and powerful for your + * application; an admin is actually able to change any address to any role + * which is a very large API surface. It's recommended that you follow a strategy + * of strictly defining the abilities of your roles + * and the API-surface of your contract. + * This is just an example for example's sake. + */ +contract RBACWithAdmin is RBAC { + /** + * A constant role name for indicating admins. + */ + string public constant ROLE_ADMIN = "admin"; + + /** + * @dev modifier to scope access to admins + * // reverts + */ + modifier onlyAdmin() + { + checkRole(msg.sender, ROLE_ADMIN); + _; + } + + /** + * @dev constructor. Sets msg.sender as admin by default + */ + constructor() + public + { + addRole(msg.sender, ROLE_ADMIN); + } + + /** + * @dev add a role to an account + * @param _account the account that will have the role + * @param _roleName the name of the role + */ + function adminAddRole(address _account, string _roleName) + public + onlyAdmin + { + addRole(_account, _roleName); + } + + /** + * @dev remove a role from an account + * @param _account the account that will no longer have the role + * @param _roleName the name of the role + */ + function adminRemoveRole(address _account, string _roleName) + public + onlyAdmin + { + removeRole(_account, _roleName); + } +} + +// Root file: contracts/RBACWithAuth.sol + +pragma solidity ^0.4.24; + +// import "contracts/interfaces/IAuthority.sol"; +// import "contracts/RBACWithAdmin.sol"; + +/** + * @title RBACWithAuth + * @dev It's recommended that you define constants in the contract, + * like ROLE_AUTH_CONTROLLER below, to avoid typos. + * This introduce the auth features from ds-auth, an advanced feature added to RBACWithAdmin. + * It's recommended that you follow a strategy + * of strictly defining the abilities of your roles + * and the API-surface of your contract. + */ +contract RBACWithAuth is RBACWithAdmin { + /** + * A constant role name for indicating auth controllers. + */ + string public constant ROLE_AUTH_CONTROLLER = "auth_controller"; + + IAuthority public authority; + + event LogSetAuthority (address indexed authority); + + /** + * @dev modifier to scope access to auth controllers + * // reverts + */ + modifier onlyAuthController() + { + checkRole(msg.sender, ROLE_AUTH_CONTROLLER); + _; + } + + modifier isAuth { + require( isAuthorized(msg.sender, msg.sig) ); + _; + } + + /** + * @dev constructor. Sets msg.sender as auth controllers by default + */ + constructor() public + { + addRole(msg.sender, ROLE_AUTH_CONTROLLER); + } + + function setAuthority(IAuthority _authority) + public + onlyAuthController + { + authority = _authority; + emit LogSetAuthority(authority); + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if ( hasRole(msg.sender, ROLE_AUTH_CONTROLLER) ) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } + +} \ No newline at end of file diff --git a/flat/SettingIds.sol b/flat/SettingIds.sol new file mode 100644 index 0000000..bd1ccd4 --- /dev/null +++ b/flat/SettingIds.sol @@ -0,0 +1,88 @@ +// Root file: contracts/SettingIds.sol + +pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} \ No newline at end of file diff --git a/flat/SettingsRegistry.sol b/flat/SettingsRegistry.sol new file mode 100644 index 0000000..5abb2b6 --- /dev/null +++ b/flat/SettingsRegistry.sol @@ -0,0 +1,224 @@ +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Root file: contracts/SettingsRegistry.sol + +pragma solidity ^0.4.24; + +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/DSAuth.sol"; + +/** + * @title SettingsRegistry + * @dev This contract holds all the settings for updating and querying. + */ +contract SettingsRegistry is ISettingsRegistry, DSAuth { + + mapping(bytes32 => uint256) public uintProperties; + mapping(bytes32 => string) public stringProperties; + mapping(bytes32 => address) public addressProperties; + mapping(bytes32 => bytes) public bytesProperties; + mapping(bytes32 => bool) public boolProperties; + mapping(bytes32 => int256) public intProperties; + + mapping(bytes32 => SettingsValueTypes) public valueTypes; + + function uintOf(bytes32 _propertyName) public view returns (uint256) { + require(valueTypes[_propertyName] == SettingsValueTypes.UINT, "Property type does not match."); + return uintProperties[_propertyName]; + } + + function stringOf(bytes32 _propertyName) public view returns (string) { + require(valueTypes[_propertyName] == SettingsValueTypes.STRING, "Property type does not match."); + return stringProperties[_propertyName]; + } + + function addressOf(bytes32 _propertyName) public view returns (address) { + require(valueTypes[_propertyName] == SettingsValueTypes.ADDRESS, "Property type does not match."); + return addressProperties[_propertyName]; + } + + function bytesOf(bytes32 _propertyName) public view returns (bytes) { + require(valueTypes[_propertyName] == SettingsValueTypes.BYTES, "Property type does not match."); + return bytesProperties[_propertyName]; + } + + function boolOf(bytes32 _propertyName) public view returns (bool) { + require(valueTypes[_propertyName] == SettingsValueTypes.BOOL, "Property type does not match."); + return boolProperties[_propertyName]; + } + + function intOf(bytes32 _propertyName) public view returns (int) { + require(valueTypes[_propertyName] == SettingsValueTypes.INT, "Property type does not match."); + return intProperties[_propertyName]; + } + + function setUintProperty(bytes32 _propertyName, uint _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.UINT, "Property type does not match."); + uintProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.UINT; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.UINT)); + } + + function setStringProperty(bytes32 _propertyName, string _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.STRING, "Property type does not match."); + stringProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.STRING; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.STRING)); + } + + function setAddressProperty(bytes32 _propertyName, address _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.ADDRESS, "Property type does not match."); + + addressProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.ADDRESS; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.ADDRESS)); + } + + function setBytesProperty(bytes32 _propertyName, bytes _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.BYTES, "Property type does not match."); + + bytesProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.BYTES; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.BYTES)); + } + + function setBoolProperty(bytes32 _propertyName, bool _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.BOOL, "Property type does not match."); + + boolProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.BOOL; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.BOOL)); + } + + function setIntProperty(bytes32 _propertyName, int _value) public auth { + require( + valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.INT, "Property type does not match."); + + intProperties[_propertyName] = _value; + valueTypes[_propertyName] = SettingsValueTypes.INT; + + emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.INT)); + } + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint256 /* SettingsValueTypes */ ) { + return uint256(valueTypes[_propertyName]); + } + +} \ No newline at end of file diff --git a/flat/StandardERC20Base.sol b/flat/StandardERC20Base.sol new file mode 100644 index 0000000..21763b7 --- /dev/null +++ b/flat/StandardERC20Base.sol @@ -0,0 +1,153 @@ +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol + +// pragma solidity ^0.4.24; + + +/** + * @title SafeMath + * @dev Math operations with safety checks that throw on error + */ +library SafeMath { + + /** + * @dev Multiplies two numbers, throws on overflow. + */ + function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + // Gas optimization: this is cheaper than asserting 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 + if (_a == 0) { + return 0; + } + + c = _a * _b; + assert(c / _a == _b); + return c; + } + + /** + * @dev Integer division of two numbers, truncating the quotient. + */ + function div(uint256 _a, uint256 _b) internal pure returns (uint256) { + // assert(_b > 0); // Solidity automatically throws when dividing by 0 + // uint256 c = _a / _b; + // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold + return _a / _b; + } + + /** + * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). + */ + function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { + assert(_b <= _a); + return _a - _b; + } + + /** + * @dev Adds two numbers, throws on overflow. + */ + function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + c = _a + _b; + assert(c >= _a); + return c; + } +} + + +// Root file: contracts/StandardERC20Base.sol + +pragma solidity ^0.4.23; + +// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol'; +// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; + +contract StandardERC20Base is ERC20 { + using SafeMath for uint256; + + uint256 _supply; + mapping (address => uint256) _balances; + mapping (address => mapping (address => uint256)) _approvals; + + function totalSupply() public view returns (uint) { + return _supply; + } + function balanceOf(address src) public view returns (uint) { + return _balances[src]; + } + function allowance(address src, address guy) public view returns (uint) { + return _approvals[src][guy]; + } + + function transfer(address dst, uint wad) public returns (bool) { + return transferFrom(msg.sender, dst, wad); + } + + function transferFrom(address src, address dst, uint wad) + public + returns (bool) + { + if (src != msg.sender) { + _approvals[src][msg.sender] = _approvals[src][msg.sender].sub(wad); + } + + _balances[src] = _balances[src].sub(wad); + _balances[dst] = _balances[dst].add(wad); + + emit Transfer(src, dst, wad); + + return true; + } + + function approve(address guy, uint wad) public returns (bool) { + _approvals[msg.sender][guy] = wad; + + emit Approval(msg.sender, guy, wad); + + return true; + } +} diff --git a/flat/StandardERC223.sol b/flat/StandardERC223.sol new file mode 100644 index 0000000..c67f119 --- /dev/null +++ b/flat/StandardERC223.sol @@ -0,0 +1,521 @@ +// Dependency file: contracts/interfaces/ERC223ReceivingContract.sol + +// pragma solidity ^0.4.23; + + /* + * Contract that is working with ERC223 tokens + * https://github.com/ethereum/EIPs/issues/223 + */ + +/// @title ERC223ReceivingContract - Standard contract implementation for compatibility with ERC223 tokens. +contract ERC223ReceivingContract { + + /// @dev Function that is called when a user or another contract wants to transfer funds. + /// @param _from Transaction initiator, analogue of msg.sender + /// @param _value Number of tokens to transfer. + /// @param _data Data containig a function signature and/or parameters + function tokenFallback(address _from, uint256 _value, bytes _data) public; + +} + + +// Dependency file: contracts/interfaces/TokenController.sol + +// pragma solidity ^0.4.23; + + +/// @dev The token controller contract must implement these functions +contract TokenController { + /// @notice Called when `_owner` sends ether to the MiniMe Token contract + /// @param _owner The address that sent the ether to create tokens + /// @return True if the ether is accepted, false if it throws + function proxyPayment(address _owner, bytes4 sig, bytes data) payable public returns (bool); + + /// @notice Notifies the controller about a token transfer allowing the + /// controller to react if desired + /// @param _from The origin of the transfer + /// @param _to The destination of the transfer + /// @param _amount The amount of the transfer + /// @return False if the controller does not authorize the transfer + function onTransfer(address _from, address _to, uint _amount) public returns (bool); + + /// @notice Notifies the controller about an approval allowing the + /// controller to react if desired + /// @param _owner The address that calls `approve()` + /// @param _spender The spender in the `approve()` call + /// @param _amount The amount in the `approve()` call + /// @return False if the controller does not authorize the approval + function onApprove(address _owner, address _spender, uint _amount) public returns (bool); +} + + +// Dependency file: contracts/interfaces/ApproveAndCallFallBack.sol + +// pragma solidity ^0.4.23; + +contract ApproveAndCallFallBack { + function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public; +} + +// Dependency file: contracts/interfaces/ERC223.sol + +// pragma solidity ^0.4.23; + +contract ERC223 { + function transfer(address to, uint amount, bytes data) public returns (bool ok); + + function transferFrom(address from, address to, uint256 amount, bytes data) public returns (bool ok); + + event ERC223Transfer(address indexed from, address indexed to, uint amount, bytes data); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol + +// pragma solidity ^0.4.24; + + +/** + * @title SafeMath + * @dev Math operations with safety checks that throw on error + */ +library SafeMath { + + /** + * @dev Multiplies two numbers, throws on overflow. + */ + function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + // Gas optimization: this is cheaper than asserting 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 + if (_a == 0) { + return 0; + } + + c = _a * _b; + assert(c / _a == _b); + return c; + } + + /** + * @dev Integer division of two numbers, truncating the quotient. + */ + function div(uint256 _a, uint256 _b) internal pure returns (uint256) { + // assert(_b > 0); // Solidity automatically throws when dividing by 0 + // uint256 c = _a / _b; + // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold + return _a / _b; + } + + /** + * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). + */ + function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { + assert(_b <= _a); + return _a - _b; + } + + /** + * @dev Adds two numbers, throws on overflow. + */ + function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + c = _a + _b; + assert(c >= _a); + return c; + } +} + + +// Dependency file: contracts/StandardERC20Base.sol + +// pragma solidity ^0.4.23; + +// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol'; +// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; + +contract StandardERC20Base is ERC20 { + using SafeMath for uint256; + + uint256 _supply; + mapping (address => uint256) _balances; + mapping (address => mapping (address => uint256)) _approvals; + + function totalSupply() public view returns (uint) { + return _supply; + } + function balanceOf(address src) public view returns (uint) { + return _balances[src]; + } + function allowance(address src, address guy) public view returns (uint) { + return _approvals[src][guy]; + } + + function transfer(address dst, uint wad) public returns (bool) { + return transferFrom(msg.sender, dst, wad); + } + + function transferFrom(address src, address dst, uint wad) + public + returns (bool) + { + if (src != msg.sender) { + _approvals[src][msg.sender] = _approvals[src][msg.sender].sub(wad); + } + + _balances[src] = _balances[src].sub(wad); + _balances[dst] = _balances[dst].add(wad); + + emit Transfer(src, dst, wad); + + return true; + } + + function approve(address guy, uint wad) public returns (bool) { + _approvals[msg.sender][guy] = wad; + + emit Approval(msg.sender, guy, wad); + + return true; + } +} + + +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Root file: contracts/StandardERC223.sol + +pragma solidity ^0.4.24; + +// import 'contracts/interfaces/ERC223ReceivingContract.sol'; +// import 'contracts/interfaces/TokenController.sol'; +// import 'contracts/interfaces/ApproveAndCallFallBack.sol'; +// import 'contracts/interfaces/ERC223.sol'; +// import 'contracts/StandardERC20Base.sol'; +// import 'contracts/DSAuth.sol'; + +// This is a contract for demo and test. +contract StandardERC223 is StandardERC20Base, DSAuth, ERC223 { + event Burn(address indexed burner, uint256 value); + event Mint(address indexed to, uint256 amount); + + bytes32 public symbol; + uint256 public decimals = 18; // standard token precision. override to customize + // Optional token name + bytes32 public name = ""; + + address public controller; + + constructor(bytes32 _symbol) public { + symbol = _symbol; + controller = msg.sender; + } + + function setName(bytes32 name_) public auth { + name = name_; + } + +////////// +// Controller Methods +////////// + /// @notice Changes the controller of the contract + /// @param _newController The new controller of the contract + function changeController(address _newController) public auth { + controller = _newController; + } + + /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it + /// is approved by `_from` + /// @param _from The address holding the tokens being transferred + /// @param _to The address of the recipient + /// @param _amount The amount of tokens to be transferred + /// @return True if the transfer was successful + function transferFrom(address _from, address _to, uint256 _amount + ) public returns (bool success) { + // Alerts the token controller of the transfer + if (isContract(controller)) { + if (!TokenController(controller).onTransfer(_from, _to, _amount)) + revert(); + } + + success = super.transferFrom(_from, _to, _amount); + } + + /* + * ERC 223 + * Added support for the ERC 223 "tokenFallback" method in a "transfer" function with a payload. + */ + function transferFrom(address _from, address _to, uint256 _amount, bytes _data) + public + returns (bool success) + { + // Alerts the token controller of the transfer + if (isContract(controller)) { + if (!TokenController(controller).onTransfer(_from, _to, _amount)) + revert(); + } + + require(super.transferFrom(_from, _to, _amount)); + + if (isContract(_to)) { + ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); + receiver.tokenFallback(_from, _amount, _data); + } + + emit ERC223Transfer(_from, _to, _amount, _data); + + return true; + } + + function issue(address _to, uint256 _amount) public auth { + mint(_to, _amount); + } + + function destroy(address _from, uint256 _amount) public auth { + burn(_from, _amount); + } + + function mint(address _to, uint _amount) public auth { + _supply = _supply.add(_amount); + _balances[_to] = _balances[_to].add(_amount); + emit Mint(_to, _amount); + emit Transfer(address(0), _to, _amount); + } + + function burn(address _who, uint _value) public auth { + require(_value <= _balances[_who]); + // no need to require value <= totalSupply, since that would imply the + // sender's balance is greater than the totalSupply, which *should* be an assertion failure + + _balances[_who] = _balances[_who].sub(_value); + _supply = _supply.sub(_value); + emit Burn(_who, _value); + emit Transfer(_who, address(0), _value); + } + + /* + * ERC 223 + * Added support for the ERC 223 "tokenFallback" method in a "transfer" function with a payload. + * https://github.com/ethereum/EIPs/issues/223 + * function transfer(address _to, uint256 _value, bytes _data) public returns (bool success); + */ + /// @notice Send `_value` tokens to `_to` from `msg.sender` and trigger + /// tokenFallback if sender is a contract. + /// @dev Function that is called when a user or another contract wants to transfer funds. + /// @param _to Address of token receiver. + /// @param _amount Number of tokens to transfer. + /// @param _data Data to be sent to tokenFallback + /// @return Returns success of function call. + function transfer( + address _to, + uint256 _amount, + bytes _data) + public + returns (bool success) + { + return transferFrom(msg.sender, _to, _amount, _data); + } + + /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on + /// its behalf. This is a modified version of the ERC20 approve function + /// to be a little bit safer + /// @param _spender The address of the account able to transfer the tokens + /// @param _amount The amount of tokens to be approved for transfer + /// @return True if the approval was successful + function approve(address _spender, uint256 _amount) public returns (bool success) { + // Alerts the token controller of the approve function call + if (isContract(controller)) { + if (!TokenController(controller).onApprove(msg.sender, _spender, _amount)) + revert(); + } + + return super.approve(_spender, _amount); + } + + /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on + /// its behalf, and then a function is triggered in the contract that is + /// being approved, `_spender`. This allows users to use their tokens to + /// interact with contracts in one function call instead of two + /// @param _spender The address of the contract able to transfer the tokens + /// @param _amount The amount of tokens to be approved for transfer + /// @return True if the function call was successful + function approveAndCall(address _spender, uint256 _amount, bytes _extraData + ) public returns (bool success) { + if (!approve(_spender, _amount)) revert(); + + ApproveAndCallFallBack(_spender).receiveApproval( + msg.sender, + _amount, + this, + _extraData + ); + + return true; + } + + /// @dev Internal function to determine if an address is a contract + /// @param _addr The address being queried + /// @return True if `_addr` is a contract + function isContract(address _addr) constant internal returns(bool) { + uint size; + if (_addr == 0) return false; + assembly { + size := extcodesize(_addr) + } + return size>0; + } + + /// @notice The fallback function: If the contract's controller has not been + /// set to 0, then the `proxyPayment` method is called which relays the + /// ether and creates tokens as described in the token controller contract + function () public payable { + if (isContract(controller)) { + if (! TokenController(controller).proxyPayment.value(msg.value)(msg.sender, msg.sig, msg.data)) + revert(); + } else { + revert(); + } + } + +////////// +// Safety Methods +////////// + + /// @notice This method can be used by the owner to extract mistakenly + /// sent tokens to this contract. + /// @param _token The address of the token contract that you want to recover + /// set to 0 in case you want to extract ether. + function claimTokens(address _token) public auth { + if (_token == 0x0) { + address(msg.sender).transfer(address(this).balance); + return; + } + + ERC20 token = ERC20(_token); + uint balance = token.balanceOf(this); + token.transfer(address(msg.sender), balance); + + emit ClaimedTokens(_token, address(msg.sender), balance); + } + +//////////////// +// Events +//////////////// + + event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); +} \ No newline at end of file diff --git a/flat/StringUtil.sol b/flat/StringUtil.sol new file mode 100644 index 0000000..4db925d --- /dev/null +++ b/flat/StringUtil.sol @@ -0,0 +1,706 @@ +// Root file: contracts/StringUtil.sol + +// https://github.com/Arachnid/solidity-stringutils/tree/master/src + +// https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol#L1036 + +pragma solidity ^0.4.14; + +library StringUtil { + struct slice { + uint _len; + uint _ptr; + } + + function memcpy(uint dest, uint src, uint len) private pure { + // Copy word-length chunks while possible + for(; len >= 32; len -= 32) { + assembly { + mstore(dest, mload(src)) + } + dest += 32; + src += 32; + } + + // Copy remaining bytes + uint mask = 256 ** (32 - len) - 1; + assembly { + let srcpart := and(mload(src), not(mask)) + let destpart := and(mload(dest), mask) + mstore(dest, or(destpart, srcpart)) + } + } + + /* + * @dev Returns a slice containing the entire string. + * @param self The string to make a slice from. + * @return A newly allocated slice containing the entire string. + */ + function toSlice(string memory self) internal pure returns (slice memory) { + uint ptr; + assembly { + ptr := add(self, 0x20) + } + return slice(bytes(self).length, ptr); + } + + /* + * @dev Returns the length of a null-terminated bytes32 string. + * @param self The value to find the length of. + * @return The length of the string, from 0 to 32. + */ + function len(bytes32 self) internal pure returns (uint) { + uint ret; + if (self == 0) + return 0; + if (self & 0xffffffffffffffffffffffffffffffff == 0) { + ret += 16; + self = bytes32(uint(self) / 0x100000000000000000000000000000000); + } + if (self & 0xffffffffffffffff == 0) { + ret += 8; + self = bytes32(uint(self) / 0x10000000000000000); + } + if (self & 0xffffffff == 0) { + ret += 4; + self = bytes32(uint(self) / 0x100000000); + } + if (self & 0xffff == 0) { + ret += 2; + self = bytes32(uint(self) / 0x10000); + } + if (self & 0xff == 0) { + ret += 1; + } + return 32 - ret; + } + + /* + * @dev Returns a slice containing the entire bytes32, interpreted as a + * null-terminated utf-8 string. + * @param self The bytes32 value to convert to a slice. + * @return A new slice containing the value of the input argument up to the + * first null. + */ + function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { + // Allocate space for `self` in memory, copy it there, and point ret at it + assembly { + let ptr := mload(0x40) + mstore(0x40, add(ptr, 0x20)) + mstore(ptr, self) + mstore(add(ret, 0x20), ptr) + } + ret._len = len(self); + } + + /* + * @dev Returns a new slice containing the same data as the current slice. + * @param self The slice to copy. + * @return A new slice containing the same data as `self`. + */ + function copy(slice memory self) internal pure returns (slice memory) { + return slice(self._len, self._ptr); + } + + /* + * @dev Copies a slice to a new string. + * @param self The slice to copy. + * @return A newly allocated string containing the slice's text. + */ + function toString(slice memory self) internal pure returns (string memory) { + string memory ret = new string(self._len); + uint retptr; + assembly { retptr := add(ret, 32) } + + memcpy(retptr, self._ptr, self._len); + return ret; + } + + /* + * @dev Returns the length in runes of the slice. Note that this operation + * takes time proportional to the length of the slice; avoid using it + * in loops, and call `slice.empty()` if you only need to know whether + * the slice is empty or not. + * @param self The slice to operate on. + * @return The length of the slice in runes. + */ + function len(slice memory self) internal pure returns (uint l) { + // Starting at ptr-31 means the LSB will be the byte we care about + uint ptr = self._ptr - 31; + uint end = ptr + self._len; + for (l = 0; ptr < end; l++) { + uint8 b; + assembly { b := and(mload(ptr), 0xFF) } + if (b < 0x80) { + ptr += 1; + } else if(b < 0xE0) { + ptr += 2; + } else if(b < 0xF0) { + ptr += 3; + } else if(b < 0xF8) { + ptr += 4; + } else if(b < 0xFC) { + ptr += 5; + } else { + ptr += 6; + } + } + } + + /* + * @dev Returns true if the slice is empty (has a length of 0). + * @param self The slice to operate on. + * @return True if the slice is empty, False otherwise. + */ + function empty(slice memory self) internal pure returns (bool) { + return self._len == 0; + } + + /* + * @dev Returns a positive number if `other` comes lexicographically after + * `self`, a negative number if it comes before, or zero if the + * contents of the two slices are equal. Comparison is done per-rune, + * on unicode codepoints. + * @param self The first slice to compare. + * @param other The second slice to compare. + * @return The result of the comparison. + */ + function compare(slice memory self, slice memory other) internal pure returns (int) { + uint shortest = self._len; + if (other._len < self._len) + shortest = other._len; + + uint selfptr = self._ptr; + uint otherptr = other._ptr; + for (uint idx = 0; idx < shortest; idx += 32) { + uint a; + uint b; + assembly { + a := mload(selfptr) + b := mload(otherptr) + } + if (a != b) { + // Mask out irrelevant bytes and check again + uint256 mask = uint256(-1); // 0xffff... + if(shortest < 32) { + mask = ~(2 ** (8 * (32 - shortest + idx)) - 1); + } + uint256 diff = (a & mask) - (b & mask); + if (diff != 0) + return int(diff); + } + selfptr += 32; + otherptr += 32; + } + return int(self._len) - int(other._len); + } + + /* + * @dev Returns true if the two slices contain the same text. + * @param self The first slice to compare. + * @param self The second slice to compare. + * @return True if the slices are equal, false otherwise. + */ + function equals(slice memory self, slice memory other) internal pure returns (bool) { + return compare(self, other) == 0; + } + + /* + * @dev Extracts the first rune in the slice into `rune`, advancing the + * slice to point to the next rune and returning `self`. + * @param self The slice to operate on. + * @param rune The slice that will contain the first rune. + * @return `rune`. + */ + function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) { + rune._ptr = self._ptr; + + if (self._len == 0) { + rune._len = 0; + return rune; + } + + uint l; + uint b; + // Load the first byte of the rune into the LSBs of b + assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) } + if (b < 0x80) { + l = 1; + } else if(b < 0xE0) { + l = 2; + } else if(b < 0xF0) { + l = 3; + } else { + l = 4; + } + + // Check for truncated codepoints + if (l > self._len) { + rune._len = self._len; + self._ptr += self._len; + self._len = 0; + return rune; + } + + self._ptr += l; + self._len -= l; + rune._len = l; + return rune; + } + + /* + * @dev Returns the first rune in the slice, advancing the slice to point + * to the next rune. + * @param self The slice to operate on. + * @return A slice containing only the first rune from `self`. + */ + function nextRune(slice memory self) internal pure returns (slice memory ret) { + nextRune(self, ret); + } + + /* + * @dev Returns the number of the first codepoint in the slice. + * @param self The slice to operate on. + * @return The number of the first codepoint in the slice. + */ + function ord(slice memory self) internal pure returns (uint ret) { + if (self._len == 0) { + return 0; + } + + uint word; + uint length; + uint divisor = 2 ** 248; + + // Load the rune into the MSBs of b + assembly { word:= mload(mload(add(self, 32))) } + uint b = word / divisor; + if (b < 0x80) { + ret = b; + length = 1; + } else if(b < 0xE0) { + ret = b & 0x1F; + length = 2; + } else if(b < 0xF0) { + ret = b & 0x0F; + length = 3; + } else { + ret = b & 0x07; + length = 4; + } + + // Check for truncated codepoints + if (length > self._len) { + return 0; + } + + for (uint i = 1; i < length; i++) { + divisor = divisor / 256; + b = (word / divisor) & 0xFF; + if (b & 0xC0 != 0x80) { + // Invalid UTF-8 sequence + return 0; + } + ret = (ret * 64) | (b & 0x3F); + } + + return ret; + } + + /* + * @dev Returns the keccak-256 hash of the slice. + * @param self The slice to hash. + * @return The hash of the slice. + */ + function keccak(slice memory self) internal pure returns (bytes32 ret) { + assembly { + ret := keccak256(mload(add(self, 32)), mload(self)) + } + } + + /* + * @dev Returns true if `self` starts with `needle`. + * @param self The slice to operate on. + * @param needle The slice to search for. + * @return True if the slice starts with the provided text, false otherwise. + */ + function startsWith(slice memory self, slice memory needle) internal pure returns (bool) { + if (self._len < needle._len) { + return false; + } + + if (self._ptr == needle._ptr) { + return true; + } + + bool equal; + assembly { + let length := mload(needle) + let selfptr := mload(add(self, 0x20)) + let needleptr := mload(add(needle, 0x20)) + equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) + } + return equal; + } + + /* + * @dev If `self` starts with `needle`, `needle` is removed from the + * beginning of `self`. Otherwise, `self` is unmodified. + * @param self The slice to operate on. + * @param needle The slice to search for. + * @return `self` + */ + function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) { + if (self._len < needle._len) { + return self; + } + + bool equal = true; + if (self._ptr != needle._ptr) { + assembly { + let length := mload(needle) + let selfptr := mload(add(self, 0x20)) + let needleptr := mload(add(needle, 0x20)) + equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) + } + } + + if (equal) { + self._len -= needle._len; + self._ptr += needle._len; + } + + return self; + } + + /* + * @dev Returns true if the slice ends with `needle`. + * @param self The slice to operate on. + * @param needle The slice to search for. + * @return True if the slice starts with the provided text, false otherwise. + */ + function endsWith(slice memory self, slice memory needle) internal pure returns (bool) { + if (self._len < needle._len) { + return false; + } + + uint selfptr = self._ptr + self._len - needle._len; + + if (selfptr == needle._ptr) { + return true; + } + + bool equal; + assembly { + let length := mload(needle) + let needleptr := mload(add(needle, 0x20)) + equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) + } + + return equal; + } + + /* + * @dev If `self` ends with `needle`, `needle` is removed from the + * end of `self`. Otherwise, `self` is unmodified. + * @param self The slice to operate on. + * @param needle The slice to search for. + * @return `self` + */ + function until(slice memory self, slice memory needle) internal pure returns (slice memory) { + if (self._len < needle._len) { + return self; + } + + uint selfptr = self._ptr + self._len - needle._len; + bool equal = true; + if (selfptr != needle._ptr) { + assembly { + let length := mload(needle) + let needleptr := mload(add(needle, 0x20)) + equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) + } + } + + if (equal) { + self._len -= needle._len; + } + + return self; + } + + // Returns the memory address of the first byte of the first occurrence of + // `needle` in `self`, or the first byte after `self` if not found. + function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { + uint ptr = selfptr; + uint idx; + + if (needlelen <= selflen) { + if (needlelen <= 32) { + bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); + + bytes32 needledata; + assembly { needledata := and(mload(needleptr), mask) } + + uint end = selfptr + selflen - needlelen; + bytes32 ptrdata; + assembly { ptrdata := and(mload(ptr), mask) } + + while (ptrdata != needledata) { + if (ptr >= end) + return selfptr + selflen; + ptr++; + assembly { ptrdata := and(mload(ptr), mask) } + } + return ptr; + } else { + // For long needles, use hashing + bytes32 hash; + assembly { hash := keccak256(needleptr, needlelen) } + + for (idx = 0; idx <= selflen - needlelen; idx++) { + bytes32 testHash; + assembly { testHash := keccak256(ptr, needlelen) } + if (hash == testHash) + return ptr; + ptr += 1; + } + } + } + return selfptr + selflen; + } + + // Returns the memory address of the first byte after the last occurrence of + // `needle` in `self`, or the address of `self` if not found. + function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { + uint ptr; + + if (needlelen <= selflen) { + if (needlelen <= 32) { + bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); + + bytes32 needledata; + assembly { needledata := and(mload(needleptr), mask) } + + ptr = selfptr + selflen - needlelen; + bytes32 ptrdata; + assembly { ptrdata := and(mload(ptr), mask) } + + while (ptrdata != needledata) { + if (ptr <= selfptr) + return selfptr; + ptr--; + assembly { ptrdata := and(mload(ptr), mask) } + } + return ptr + needlelen; + } else { + // For long needles, use hashing + bytes32 hash; + assembly { hash := keccak256(needleptr, needlelen) } + ptr = selfptr + (selflen - needlelen); + while (ptr >= selfptr) { + bytes32 testHash; + assembly { testHash := keccak256(ptr, needlelen) } + if (hash == testHash) + return ptr + needlelen; + ptr -= 1; + } + } + } + return selfptr; + } + + /* + * @dev Modifies `self` to contain everything from the first occurrence of + * `needle` to the end of the slice. `self` is set to the empty slice + * if `needle` is not found. + * @param self The slice to search and modify. + * @param needle The text to search for. + * @return `self`. + */ + function find(slice memory self, slice memory needle) internal pure returns (slice memory) { + uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); + self._len -= ptr - self._ptr; + self._ptr = ptr; + return self; + } + + /* + * @dev Modifies `self` to contain the part of the string from the start of + * `self` to the end of the first occurrence of `needle`. If `needle` + * is not found, `self` is set to the empty slice. + * @param self The slice to search and modify. + * @param needle The text to search for. + * @return `self`. + */ + function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) { + uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); + self._len = ptr - self._ptr; + return self; + } + + /* + * @dev Splits the slice, setting `self` to everything after the first + * occurrence of `needle`, and `token` to everything before it. If + * `needle` does not occur in `self`, `self` is set to the empty slice, + * and `token` is set to the entirety of `self`. + * @param self The slice to split. + * @param needle The text to search for in `self`. + * @param token An output parameter to which the first token is written. + * @return `token`. + */ + function split(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { + uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); + token._ptr = self._ptr; + token._len = ptr - self._ptr; + if (ptr == self._ptr + self._len) { + // Not found + self._len = 0; + } else { + self._len -= token._len + needle._len; + self._ptr = ptr + needle._len; + } + return token; + } + + /* + * @dev Splits the slice, setting `self` to everything after the first + * occurrence of `needle`, and returning everything before it. If + * `needle` does not occur in `self`, `self` is set to the empty slice, + * and the entirety of `self` is returned. + * @param self The slice to split. + * @param needle The text to search for in `self`. + * @return The part of `self` up to the first occurrence of `delim`. + */ + function split(slice memory self, slice memory needle) internal pure returns (slice memory token) { + split(self, needle, token); + } + + /* + * @dev Splits the slice, setting `self` to everything before the last + * occurrence of `needle`, and `token` to everything after it. If + * `needle` does not occur in `self`, `self` is set to the empty slice, + * and `token` is set to the entirety of `self`. + * @param self The slice to split. + * @param needle The text to search for in `self`. + * @param token An output parameter to which the first token is written. + * @return `token`. + */ + function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { + uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); + token._ptr = ptr; + token._len = self._len - (ptr - self._ptr); + if (ptr == self._ptr) { + // Not found + self._len = 0; + } else { + self._len -= token._len + needle._len; + } + return token; + } + + /* + * @dev Splits the slice, setting `self` to everything before the last + * occurrence of `needle`, and returning everything after it. If + * `needle` does not occur in `self`, `self` is set to the empty slice, + * and the entirety of `self` is returned. + * @param self The slice to split. + * @param needle The text to search for in `self`. + * @return The part of `self` after the last occurrence of `delim`. + */ + function rsplit(slice memory self, slice memory needle) internal pure returns (slice memory token) { + rsplit(self, needle, token); + } + + /* + * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`. + * @param self The slice to search. + * @param needle The text to search for in `self`. + * @return The number of occurrences of `needle` found in `self`. + */ + function count(slice memory self, slice memory needle) internal pure returns (uint cnt) { + uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; + while (ptr <= self._ptr + self._len) { + cnt++; + ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; + } + } + + /* + * @dev Returns True if `self` contains `needle`. + * @param self The slice to search. + * @param needle The text to search for in `self`. + * @return True if `needle` is found in `self`, false otherwise. + */ + function contains(slice memory self, slice memory needle) internal pure returns (bool) { + return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; + } + + /* + * @dev Returns a newly allocated string containing the concatenation of + * `self` and `other`. + * @param self The first slice to concatenate. + * @param other The second slice to concatenate. + * @return The concatenation of the two strings. + */ + function concat(slice memory self, slice memory other) internal pure returns (string memory) { + string memory ret = new string(self._len + other._len); + uint retptr; + assembly { retptr := add(ret, 32) } + memcpy(retptr, self._ptr, self._len); + memcpy(retptr + self._len, other._ptr, other._len); + return ret; + } + + /* + * @dev Joins an array of slices, using `self` as a delimiter, returning a + * newly allocated string. + * @param self The delimiter to use. + * @param parts A list of slices to join. + * @return A newly allocated string containing all the slices in `parts`, + * joined with `self`. + */ + function join(slice memory self, slice[] memory parts) internal pure returns (string memory) { + if (parts.length == 0) + return ""; + + uint length = self._len * (parts.length - 1); + for(uint i = 0; i < parts.length; i++) + length += parts[i]._len; + + string memory ret = new string(length); + uint retptr; + assembly { retptr := add(ret, 32) } + + for(i = 0; i < parts.length; i++) { + memcpy(retptr, parts[i]._ptr, parts[i]._len); + retptr += parts[i]._len; + if (i < parts.length - 1) { + memcpy(retptr, self._ptr, self._len); + retptr += self._len; + } + } + + return ret; + } + + function uint2str(uint _int) internal pure returns (string memory _uintAsString) { + uint _i = _int; + if (_i == 0) { + return "0"; + } + uint j = _i; + uint length; + while (j != 0) { + length++; + j /= 10; + } + bytes memory bstr = new bytes(length); + uint k = length - 1; + while (_i != 0) { + bstr[k--] = byte(uint8(48 + _i % 10)); + _i /= 10; + } + return string(bstr); + } +} \ No newline at end of file diff --git a/flat/TokenBuildInGenesis.sol b/flat/TokenBuildInGenesis.sol new file mode 100644 index 0000000..feb221a --- /dev/null +++ b/flat/TokenBuildInGenesis.sol @@ -0,0 +1,359 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Dependency file: contracts/interfaces/IBurnableERC20.sol + +// pragma solidity ^0.4.23; + +contract IBurnableERC20 { + function burn(address _from, uint _value) public; +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Root file: contracts/TokenBuildInGenesis.sol + +pragma solidity ^0.4.24; + +// import "contracts/DSAuth.sol"; +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; +// import "contracts/interfaces/IBurnableERC20.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/SettingIds.sol"; + +contract TokenBuildInGenesis is DSAuth, SettingIds { + // claimedToken event + event ClaimedTokens(address indexed token, address indexed owner, uint amount); + + // burndropTokens event + event RingBuildInEvent(address indexed token, address indexed owner, uint amount, bytes data); + + event KtonBuildInEvent(address indexed token, address indexed owner, uint amount, bytes data); + + event SetStatus(bool status); + + ISettingsRegistry public registry; + + bool public paused = false; + + bool private singletonLock = false; + + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + modifier isWork() { + require(!paused, "Not started"); + _; + } + + function initializeContract(address _registry, bool _status) public singletonLockCall{ + registry = ISettingsRegistry(_registry); + paused = _status; + owner = msg.sender; + } + + /** + * @dev ERC223 fallback function, make sure to check the msg.sender is from target token contracts + * @param _from - person who transfer token in for deposits or claim deposit with penalty KTON. + * @param _amount - amount of token. + * @param _data - data which indicate the operations. + */ + function tokenFallback(address _from, uint256 _amount, bytes _data) public isWork{ + bytes32 darwiniaAddress; + + assembly { + let ptr := mload(0x40) + calldatacopy(ptr, 0, calldatasize) + darwiniaAddress := mload(add(ptr, 132)) + } + + address ring = registry.addressOf(SettingIds.CONTRACT_RING_ERC20_TOKEN); + address kryptonite = registry.addressOf(SettingIds.CONTRACT_KTON_ERC20_TOKEN); + + require((msg.sender == ring) || (msg.sender == kryptonite), "Permission denied"); + + require(_data.length == 32, "The address (Darwinia Network) must be in a 32 bytes hexadecimal format"); + require(darwiniaAddress != bytes32(0x0), "Darwinia Network Address can't be empty"); + + // burndrop ring + if(ring == msg.sender) { + IBurnableERC20(ring).burn(address(this), _amount); + emit RingBuildInEvent(msg.sender, _from, _amount, _data); + } + + // burndrop kton + if (kryptonite == msg.sender) { + IBurnableERC20(kryptonite).burn(address(this), _amount); + emit KtonBuildInEvent(msg.sender, _from, _amount, _data); + } + } + + /// @notice This method can be used by the owner to extract mistakenly + /// sent tokens to this contract. + /// @param _token The address of the token contract that you want to recover + /// set to 0 in case you want to extract ether. + function claimTokens(address _token) public auth { + if (_token == 0x0) { + owner.transfer(address(this).balance); + return; + } + ERC20 token = ERC20(_token); + uint balance = token.balanceOf(address(this)); + token.transfer(owner, balance); + + emit ClaimedTokens(_token, owner, balance); + } + + function setPaused(bool _status) public auth { + paused = _status; + } + + function togglePaused() public auth { + paused = !paused; + } + + function setRegistry(address _registry) public auth { + registry = ISettingsRegistry(_registry); + } +} diff --git a/flat/TokenBurnDrop.sol b/flat/TokenBurnDrop.sol new file mode 100644 index 0000000..64cc79b --- /dev/null +++ b/flat/TokenBurnDrop.sol @@ -0,0 +1,331 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Dependency file: contracts/interfaces/IBurnableERC20.sol + +// pragma solidity ^0.4.23; + +contract IBurnableERC20 { + function burn(address _from, uint _value) public; +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Root file: contracts/TokenBurnDrop.sol + +pragma solidity ^0.4.24; + +// import "contracts/DSAuth.sol"; +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; +// import "contracts/interfaces/IBurnableERC20.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/SettingIds.sol"; + +contract TokenBurnDrop is DSAuth, SettingIds { + // claimedToken event + event ClaimedTokens(address indexed token, address indexed owner, uint amount); + + // burndropTokens event + event RingBurndropTokens(address indexed token, address indexed owner, uint amount, bytes data); + + event KtonBurndropTokens(address indexed token, address indexed owner, uint amount, bytes data); + + ISettingsRegistry public registry; + + byte public SS58_PREFIX_DARWINIA = 0x2a; + + function initializeContract(address _registry) public onlyOwner{ + registry = ISettingsRegistry(_registry); + } + + /** + * @dev ERC223 fallback function, make sure to check the msg.sender is from target token contracts + * @param _from - person who transfer token in for deposits or claim deposit with penalty KTON. + * @param _amount - amount of token. + * @param _data - data which indicate the operations. + */ + function tokenFallback(address _from, uint256 _amount, bytes _data) public { + bytes32 darwiniaAddress; + + assembly { + let ptr := mload(0x40) + calldatacopy(ptr, 0, calldatasize) + darwiniaAddress := mload(add(ptr, 133)) + } + + address ring = registry.addressOf(SettingIds.CONTRACT_RING_ERC20_TOKEN); + address kryptonite = registry.addressOf(SettingIds.CONTRACT_KTON_ERC20_TOKEN); + + require((msg.sender == ring) || (msg.sender == kryptonite), "Permission denied"); + + require(_data.length == 33, "The address (Darwinia Network) must be in a 33 bytes hexadecimal format"); + require(byte(_data[0]) == SS58_PREFIX_DARWINIA, "Darwinia Network Address ss58 prefix is 42"); + require(darwiniaAddress != bytes32(0x0), "Darwinia Network Address can't be empty"); + + // burndrop ring + if(ring == msg.sender) { + IBurnableERC20(ring).burn(address(this), _amount); + emit RingBurndropTokens(msg.sender, _from, _amount, _data); + } + + // burndrop kton + if (kryptonite == msg.sender) { + IBurnableERC20(kryptonite).burn(address(this), _amount); + emit KtonBurndropTokens(msg.sender, _from, _amount, _data); + } + } + + /// @notice This method can be used by the owner to extract mistakenly + /// sent tokens to this contract. + /// @param _token The address of the token contract that you want to recover + /// set to 0 in case you want to extract ether. + function claimTokens(address _token) public auth { + if (_token == 0x0) { + owner.transfer(address(this).balance); + return; + } + ERC20 token = ERC20(_token); + uint balance = token.balanceOf(address(this)); + token.transfer(owner, balance); + + emit ClaimedTokens(_token, owner, balance); + } +} diff --git a/flat/TokenController.sol b/flat/TokenController.sol new file mode 100644 index 0000000..e9c3857 --- /dev/null +++ b/flat/TokenController.sol @@ -0,0 +1,28 @@ +// Root file: contracts/interfaces/TokenController.sol + +pragma solidity ^0.4.23; + + +/// @dev The token controller contract must implement these functions +contract TokenController { + /// @notice Called when `_owner` sends ether to the MiniMe Token contract + /// @param _owner The address that sent the ether to create tokens + /// @return True if the ether is accepted, false if it throws + function proxyPayment(address _owner, bytes4 sig, bytes data) payable public returns (bool); + + /// @notice Notifies the controller about a token transfer allowing the + /// controller to react if desired + /// @param _from The origin of the transfer + /// @param _to The destination of the transfer + /// @param _amount The amount of the transfer + /// @return False if the controller does not authorize the transfer + function onTransfer(address _from, address _to, uint _amount) public returns (bool); + + /// @notice Notifies the controller about an approval allowing the + /// controller to react if desired + /// @param _owner The address that calls `approve()` + /// @param _spender The spender in the `approve()` call + /// @param _amount The amount in the `approve()` call + /// @return False if the controller does not authorize the approval + function onApprove(address _owner, address _spender, uint _amount) public returns (bool); +} diff --git a/flat/TokenLocation.sol b/flat/TokenLocation.sol new file mode 100644 index 0000000..a4780fb --- /dev/null +++ b/flat/TokenLocation.sol @@ -0,0 +1,226 @@ +// Dependency file: contracts/interfaces/ITokenLocation.sol + +// pragma solidity ^0.4.24; + +contract ITokenLocation { + + function hasLocation(uint256 _tokenId) public view returns (bool); + + function getTokenLocation(uint256 _tokenId) public view returns (int, int); + + function setTokenLocation(uint256 _tokenId, int _x, int _y) public; + + function getTokenLocationHM(uint256 _tokenId) public view returns (int, int); + + function setTokenLocationHM(uint256 _tokenId, int _x, int _y) public; +} + +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: contracts/LocationCoder.sol + +// pragma solidity ^0.4.24; + +library LocationCoder { + // the allocation of the [x, y, z] is [0<1>, x<21>, y<21>, z<21>] + uint256 constant CLEAR_YZ = 0x0fffffffffffffffffffff000000000000000000000000000000000000000000; + uint256 constant CLEAR_XZ = 0x0000000000000000000000fffffffffffffffffffff000000000000000000000; + uint256 constant CLEAR_XY = 0x0000000000000000000000000000000000000000000fffffffffffffffffffff; + + uint256 constant NOT_ZERO = 0x1000000000000000000000000000000000000000000000000000000000000000; + uint256 constant APPEND_HIGH = 0xfffffffffffffffffffffffffffffffffffffffffff000000000000000000000; + + uint256 constant MAX_LOCATION_ID = 0x2000000000000000000000000000000000000000000000000000000000000000; + + int256 constant HMETER_DECIMAL = 10 ** 8; + + // x, y, z should between -2^83 (-9671406556917033397649408) and 2^83 - 1 (9671406556917033397649407). + int256 constant MIN_Location_XYZ = -9671406556917033397649408; + int256 constant MAX_Location_XYZ = 9671406556917033397649407; + // 96714065569170334.50000000 + int256 constant MAX_HM_DECIMAL = 9671406556917033450000000; + int256 constant MAX_HM = 96714065569170334; + + function encodeLocationIdXY(int _x, int _y) internal pure returns (uint result) { + return encodeLocationId3D(_x, _y, 0); + } + + function decodeLocationIdXY(uint _positionId) internal pure returns (int _x, int _y) { + (_x, _y, ) = decodeLocationId3D(_positionId); + } + + function encodeLocationId3D(int _x, int _y, int _z) internal pure returns (uint result) { + return _unsafeEncodeLocationId3D(_x, _y, _z); + } + + function _unsafeEncodeLocationId3D(int _x, int _y, int _z) internal pure returns (uint) { + require(_x >= MIN_Location_XYZ && _x <= MAX_Location_XYZ, "Invalid value."); + require(_y >= MIN_Location_XYZ && _y <= MAX_Location_XYZ, "Invalid value."); + require(_z >= MIN_Location_XYZ && _z <= MAX_Location_XYZ, "Invalid value."); + + // uint256 constant FACTOR_2 = 0x1000000000000000000000000000000000000000000; // <16 ** 42> or <2 ** 168> + // uint256 constant FACTOR = 0x1000000000000000000000; // <16 ** 21> or <2 ** 84> + return ((uint(_x) << 168) & CLEAR_YZ) | (uint(_y << 84) & CLEAR_XZ) | (uint(_z) & CLEAR_XY) | NOT_ZERO; + } + + function decodeLocationId3D(uint _positionId) internal pure returns (int, int, int) { + return _unsafeDecodeLocationId3D(_positionId); + } + + function _unsafeDecodeLocationId3D(uint _value) internal pure returns (int x, int y, int z) { + require(_value >= NOT_ZERO && _value < MAX_LOCATION_ID, "Invalid Location Id"); + + x = expandNegative84BitCast((_value & CLEAR_YZ) >> 168); + y = expandNegative84BitCast((_value & CLEAR_XZ) >> 84); + z = expandNegative84BitCast(_value & CLEAR_XY); + } + + function toHM(int _x) internal pure returns (int) { + return (_x + MAX_HM_DECIMAL)/HMETER_DECIMAL - MAX_HM; + } + + function toUM(int _x) internal pure returns (int) { + return _x * LocationCoder.HMETER_DECIMAL; + } + + function expandNegative84BitCast(uint _value) internal pure returns (int) { + if (_value & (1<<83) != 0) { + return int(_value | APPEND_HIGH); + } + return int(_value); + } + + function encodeLocationIdHM(int _x, int _y) internal pure returns (uint result) { + return encodeLocationIdXY(toUM(_x), toUM(_y)); + } + + function decodeLocationIdHM(uint _positionId) internal pure returns (int, int) { + (int _x, int _y) = decodeLocationIdXY(_positionId); + return (toHM(_x), toHM(_y)); + } +} + +// Root file: contracts/TokenLocation.sol + +pragma solidity ^0.4.24; + +// import "contracts/interfaces/ITokenLocation.sol"; +// import "contracts/DSAuth.sol"; +// import "contracts/LocationCoder.sol"; + +contract TokenLocation is DSAuth, ITokenLocation { + using LocationCoder for *; + + bool private singletonLock = false; + + // token id => encode(x,y) postiion in map, the location is in micron. + mapping (uint256 => uint256) public tokenId2LocationId; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract() public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function hasLocation(uint256 _tokenId) public view returns (bool) { + return tokenId2LocationId[_tokenId] != 0; + } + + function getTokenLocationHM(uint256 _tokenId) public view returns (int, int){ + (int _x, int _y) = getTokenLocation(_tokenId); + return (LocationCoder.toHM(_x), LocationCoder.toHM(_y)); + } + + function setTokenLocationHM(uint256 _tokenId, int _x, int _y) public auth { + setTokenLocation(_tokenId, LocationCoder.toUM(_x), LocationCoder.toUM(_y)); + } + + // decode tokenId to get (x,y) + function getTokenLocation(uint256 _tokenId) public view returns (int, int) { + uint locationId = tokenId2LocationId[_tokenId]; + return LocationCoder.decodeLocationIdXY(locationId); + } + + function setTokenLocation(uint256 _tokenId, int _x, int _y) public auth { + tokenId2LocationId[_tokenId] = LocationCoder.encodeLocationIdXY(_x, _y); + } +} \ No newline at end of file diff --git a/flat/TokenLocationAuthority.sol b/flat/TokenLocationAuthority.sol new file mode 100644 index 0000000..7925b6d --- /dev/null +++ b/flat/TokenLocationAuthority.sol @@ -0,0 +1,20 @@ +// Root file: contracts/TokenLocationAuthority.sol + +pragma solidity ^0.4.24; + +contract TokenLocationAuthority { + + mapping (address => bool) public whiteList; + + constructor(address[] _whitelists) public { + for (uint i = 0; i < _whitelists.length; i ++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, address _dst, bytes4 _sig + ) public view returns (bool) { + return ( whiteList[_src] && _sig == bytes4(keccak256("setTokenLocationHM(uint256,int256,int256)"))) ; + } +} \ No newline at end of file diff --git a/flat/TokenUse.sol b/flat/TokenUse.sol new file mode 100644 index 0000000..5ec5fdf --- /dev/null +++ b/flat/TokenUse.sol @@ -0,0 +1,913 @@ +// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol + +// pragma solidity ^0.4.24; + + +/** + * @title SafeMath + * @dev Math operations with safety checks that throw on error + */ +library SafeMath { + + /** + * @dev Multiplies two numbers, throws on overflow. + */ + function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + // Gas optimization: this is cheaper than asserting 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 + if (_a == 0) { + return 0; + } + + c = _a * _b; + assert(c / _a == _b); + return c; + } + + /** + * @dev Integer division of two numbers, truncating the quotient. + */ + function div(uint256 _a, uint256 _b) internal pure returns (uint256) { + // assert(_b > 0); // Solidity automatically throws when dividing by 0 + // uint256 c = _a / _b; + // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold + return _a / _b; + } + + /** + * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). + */ + function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { + assert(_b <= _a); + return _a - _b; + } + + /** + * @dev Adds two numbers, throws on overflow. + */ + function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + c = _a + _b; + assert(c >= _a); + return c; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + + +/** + * @title ERC721 Non-Fungible Token Standard basic interface + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Basic is ERC165 { + + bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; + /* + * 0x80ac58cd === + * bytes4(keccak256('balanceOf(address)')) ^ + * bytes4(keccak256('ownerOf(uint256)')) ^ + * bytes4(keccak256('approve(address,uint256)')) ^ + * bytes4(keccak256('getApproved(uint256)')) ^ + * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ + * bytes4(keccak256('isApprovedForAll(address,address)')) ^ + * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) + */ + + bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; + /* + * 0x4f558e79 === + * bytes4(keccak256('exists(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; + /** + * 0x780e9d63 === + * bytes4(keccak256('totalSupply()')) ^ + * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ + * bytes4(keccak256('tokenByIndex(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; + /** + * 0x5b5e139f === + * bytes4(keccak256('name()')) ^ + * bytes4(keccak256('symbol()')) ^ + * bytes4(keccak256('tokenURI(uint256)')) + */ + + event Transfer( + address indexed _from, + address indexed _to, + uint256 indexed _tokenId + ); + event Approval( + address indexed _owner, + address indexed _approved, + uint256 indexed _tokenId + ); + event ApprovalForAll( + address indexed _owner, + address indexed _operator, + bool _approved + ); + + function balanceOf(address _owner) public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view returns (bool _exists); + + function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) + public view returns (address _operator); + + function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) + public view returns (bool); + + function transferFrom(address _from, address _to, uint256 _tokenId) public; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) + public; + + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public; +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Enumerable is ERC721Basic { + function totalSupply() public view returns (uint256); + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256 _tokenId); + + function tokenByIndex(uint256 _index) public view returns (uint256); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional metadata extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Metadata is ERC721Basic { + function name() external view returns (string _name); + function symbol() external view returns (string _symbol); + function tokenURI(uint256 _tokenId) public view returns (string); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, full implementation interface + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { +} + + +// Dependency file: contracts/interfaces/ERC223.sol + +// pragma solidity ^0.4.23; + +contract ERC223 { + function transfer(address to, uint amount, bytes data) public returns (bool ok); + + function transferFrom(address from, address to, uint256 amount, bytes data) public returns (bool ok); + + event ERC223Transfer(address indexed from, address indexed to, uint amount, bytes data); +} + + +// Dependency file: contracts/interfaces/ITokenUse.sol + +// pragma solidity ^0.4.24; + +contract ITokenUse { + uint48 public constant MAX_UINT48_TIME = 281474976710655; + + function isObjectInHireStage(uint256 _tokenId) public view returns (bool); + + function isObjectReadyToUse(uint256 _tokenId) public view returns (bool); + + function getTokenUser(uint256 _tokenId) public view returns (address); + + function createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public; + + function cancelTokenUseOffer(uint256 _tokenId) public; + + function takeTokenUseOffer(uint256 _tokenId) public; + + function addActivity(uint256 _tokenId, address _user, uint256 _endTime) public; + + function removeActivity(uint256 _tokenId, address _user) public; +} + +// Dependency file: contracts/interfaces/IActivity.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + +contract IActivity is ERC165 { + bytes4 internal constant InterfaceId_IActivity = 0x6086e7f8; + /* + * 0x6086e7f8 === + * bytes4(keccak256('activityStopped(uint256)')) + */ + + function activityStopped(uint256 _tokenId) public; +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/interfaces/IInterstellarEncoder.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoder { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function registerNewTokenContract(address _tokenAddress) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); +} + +// Dependency file: contracts/interfaces/IActivityObject.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + +contract IActivityObject is ERC165 { + bytes4 internal constant InterfaceId_IActivityObject = 0x2b9eccc6; + /* + * 0x2b9eccc6 === + * bytes4(keccak256('activityAdded(uint256,address,address)')) ^ + * bytes4(keccak256('activityRemoved(uint256,address,address)')) + */ + + function activityAdded(uint256 _tokenId, address _activity, address _user) public; + + function activityRemoved(uint256 _tokenId, address _activity, address _user) public; +} + +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Root file: contracts/TokenUse.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +// import "contracts/interfaces/ERC223.sol"; +// import "contracts/interfaces/ITokenUse.sol"; +// import "contracts/interfaces/IActivity.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/interfaces/IInterstellarEncoder.sol"; +// import "contracts/interfaces/IActivityObject.sol"; +// import "contracts/SettingIds.sol"; +// import "contracts/DSAuth.sol"; + +contract TokenUse is DSAuth, ITokenUse, SettingIds { + using SafeMath for *; + + // claimedToken event + event ClaimedTokens(address indexed token, address indexed owner, uint amount); + + event OfferCreated(uint256 indexed tokenId, uint256 duration, uint256 price, address acceptedActivity, address owner); + event OfferCancelled(uint256 tokenId); + event OfferTaken(uint256 indexed tokenId, address from, address owner, uint256 now, uint256 endTime); + event ActivityAdded(uint256 indexed tokenId, address activity, uint256 endTime); + event ActivityRemoved(uint256 indexed tokenId, address activity); + event TokenUseRemoved(uint256 indexed tokenId, address owner, address user, address activity); + + struct UseStatus { + address user; + address owner; + uint48 startTime; + uint48 endTime; + uint256 price; // RING per second. + address acceptedActivity; // can only be used in this activity. + } + + struct UseOffer { + address owner; + uint48 duration; + // total price of hiring mft for full duration + uint256 price; + address acceptedActivity; // If 0, then accept any activity + } + + struct CurrentActivity { + address activity; + uint48 endTime; + } + + bool private singletonLock = false; + + ISettingsRegistry public registry; + mapping (uint256 => UseStatus) public tokenId2UseStatus; + mapping (uint256 => UseOffer) public tokenId2UseOffer; + + mapping (uint256 => CurrentActivity ) public tokenId2CurrentActivity; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract(ISettingsRegistry _registry) public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + + registry = _registry; + } + + // false if it is not in useStage + // based on data in TokenUseStatus + function isObjectInHireStage(uint256 _tokenId) public view returns (bool) { + if (tokenId2UseStatus[_tokenId].user == address(0)) { + return false; + } + + return tokenId2UseStatus[_tokenId].startTime <= now && now <= tokenId2UseStatus[_tokenId].endTime; + } + + // by check this function + // you can know if an nft is ok to addActivity + // based on data in CurrentActivity + function isObjectReadyToUse(uint256 _tokenId) public view returns (bool) { + + if(tokenId2CurrentActivity[_tokenId].endTime == 0) { + return tokenId2CurrentActivity[_tokenId].activity == address(0); + } else { + return now > tokenId2CurrentActivity[_tokenId].endTime; + } + } + + + function getTokenUser(uint256 _tokenId) public view returns (address) { + return tokenId2UseStatus[_tokenId].user; + } + + function receiveApproval(address _from, uint _tokenId, bytes _data) public { + if(msg.sender == registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)) { + uint256 duration; + uint256 price; + address acceptedActivity; + assembly { + let ptr := mload(0x40) + calldatacopy(ptr, 0, calldatasize) + duration := mload(add(ptr, 132)) + price := mload(add(ptr, 164)) + acceptedActivity := mload(add(ptr, 196)) + } + + // already approve that msg.sender == ownerOf(_tokenId) + + _createTokenUseOffer(_tokenId, duration, price, acceptedActivity, _from); + } + } + + + // need approval from msg.sender + function createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public { + require(ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == msg.sender, "Only can call by the token owner."); + + _createTokenUseOffer(_tokenId, _duration, _price, _acceptedActivity, msg.sender); + } + + // TODO: be careful with unit of duration and price + // remember to deal with unit off chain + function _createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity, address _owner) internal { + require(isObjectReadyToUse(_tokenId), "No, it is still in use."); + require(tokenId2UseOffer[_tokenId].owner == 0, "Token already in another offer."); + require(_price >= 1 ether, "price must larger than 1 ring."); + require(_duration >= 7 days); + + ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom(_owner, address(this), _tokenId); + + tokenId2UseOffer[_tokenId] = UseOffer({ + owner: _owner, + duration: uint48(_duration), + price : _price, + acceptedActivity: _acceptedActivity + }); + + emit OfferCreated(_tokenId,_duration, _price, _acceptedActivity, _owner); + } + + function cancelTokenUseOffer(uint256 _tokenId) public { + require(tokenId2UseOffer[_tokenId].owner == msg.sender, "Only token owner can cancel the offer."); + + ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom(address(this), msg.sender, _tokenId); + + delete tokenId2UseOffer[_tokenId]; + + emit OfferCancelled(_tokenId); + } + + function takeTokenUseOffer(uint256 _tokenId) public { + uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); + + uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); + + address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); + + ERC20(ring).transferFrom( + msg.sender, tokenId2UseOffer[_tokenId].owner, expense.sub(cut)); + + ERC223(ring).transferFrom( + msg.sender, registry.addressOf(CONTRACT_REVENUE_POOL), cut, toBytes(msg.sender)); + + _takeTokenUseOffer(_tokenId, msg.sender); + } + + function _takeTokenUseOffer(uint256 _tokenId, address _from) internal { + require(tokenId2UseOffer[_tokenId].owner != address(0), "Offer does not exist for this token."); + require(isObjectReadyToUse(_tokenId), "Token already in another activity."); + + tokenId2UseStatus[_tokenId] = UseStatus({ + user: _from, + owner: tokenId2UseOffer[_tokenId].owner, + startTime: uint48(now), + endTime : uint48(now) + tokenId2UseOffer[_tokenId].duration, + price : tokenId2UseOffer[_tokenId].price, + acceptedActivity : tokenId2UseOffer[_tokenId].acceptedActivity + }); + + delete tokenId2UseOffer[_tokenId]; + + emit OfferTaken(_tokenId, _from, tokenId2UseStatus[_tokenId].owner, now, uint256(tokenId2UseStatus[_tokenId].endTime)); + + } + + //TODO: allow batch operation + function tokenFallback(address _from, uint256 _value, bytes _data) public { + address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); + if(ring == msg.sender) { + uint256 tokenId; + + assembly { + let ptr := mload(0x40) + calldatacopy(ptr, 0, calldatasize) + tokenId := mload(add(ptr, 132)) + } + + uint256 expense = uint256(tokenId2UseOffer[tokenId].price); + require(_value >= expense); + + uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); + + ERC20(ring).transfer(tokenId2UseOffer[tokenId].owner, expense.sub(cut)); + + ERC223(ring).transfer( + registry.addressOf(CONTRACT_REVENUE_POOL), cut, toBytes(_from)); + + _takeTokenUseOffer(tokenId, _from); + } + } + + // start activity when token has no user at all + function addActivity( + uint256 _tokenId, address _user, uint256 _endTime + ) public auth { + // require the token user to verify even if it is from business logic. + // if it is rent by others, can not addActivity by default. + if(tokenId2UseStatus[_tokenId].user != address(0)) { + require(_user == tokenId2UseStatus[_tokenId].user); + require( + tokenId2UseStatus[_tokenId].acceptedActivity == address(0) || + tokenId2UseStatus[_tokenId].acceptedActivity == msg.sender, "Token accepted activity is not accepted."); + } else { + require( + address(0) == _user || ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == _user, "you can not use this token."); + } + + require(tokenId2UseOffer[_tokenId].owner == address(0), "Can not start activity when offering."); + + require(IActivity(msg.sender).supportsInterface(0x6086e7f8), "Msg sender must be activity"); + + require(isObjectReadyToUse(_tokenId), "Token should be available."); + + address activityObject = IInterstellarEncoder(registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER)).getObjectAddress(_tokenId); + IActivityObject(activityObject).activityAdded(_tokenId, msg.sender, _user); + + tokenId2CurrentActivity[_tokenId].activity = msg.sender; + + if(tokenId2UseStatus[_tokenId].endTime != 0) { + tokenId2CurrentActivity[_tokenId].endTime = tokenId2UseStatus[_tokenId].endTime; + } else { + tokenId2CurrentActivity[_tokenId].endTime = uint48(_endTime); + } + + + emit ActivityAdded(_tokenId, msg.sender, uint48(tokenId2CurrentActivity[_tokenId].endTime)); + } + + function removeActivity(uint256 _tokenId, address _user) public auth { + // require the token user to verify even if it is from business logic. + // if it is rent by others, can not addActivity by default. + if(tokenId2UseStatus[_tokenId].user != address(0)) { + require(_user == tokenId2UseStatus[_tokenId].user); + } else { + require( + address(0) == _user || ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == _user, "you can not use this token."); + } + + require(tokenId2CurrentActivity[_tokenId].activity == msg.sender || msg.sender == address(this), "Must stop from current activity"); + + address activityObject = IInterstellarEncoder(registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER)).getObjectAddress(_tokenId); + IActivityObject(activityObject).activityRemoved(_tokenId, msg.sender, _user); + + IActivity(tokenId2CurrentActivity[_tokenId].activity).activityStopped(_tokenId); + + delete tokenId2CurrentActivity[_tokenId]; + + emit ActivityRemoved(_tokenId, msg.sender); + } + + function removeTokenUseAndActivity(uint256 _tokenId) public { + require(tokenId2UseStatus[_tokenId].user != address(0), "Object does not exist."); + + // when in activity, only user can stop + if(isObjectInHireStage(_tokenId)) { + require(tokenId2UseStatus[_tokenId].user == msg.sender); + } + + _removeTokenUse(_tokenId); + + if (tokenId2CurrentActivity[_tokenId].activity != address(0)) { + this.removeActivity(_tokenId, address(0)); + } + } + + + function _removeTokenUse(uint256 _tokenId) public { + + address owner = tokenId2UseStatus[_tokenId].owner; + address user = tokenId2UseStatus[_tokenId].user; + address activity = tokenId2CurrentActivity[_tokenId].activity; + ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom( + address(this), owner, _tokenId); + + delete tokenId2UseStatus[_tokenId]; +// delete tokenId2CurrentActivity[_tokenId]; + + emit TokenUseRemoved(_tokenId, owner, user, activity); + } + + // for user-friendly + function removeUseAndCreateOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public { + + require(msg.sender == tokenId2UseStatus[_tokenId].owner); + removeTokenUseAndActivity(_tokenId); + + tokenId2UseOffer[_tokenId] = UseOffer({ + owner: msg.sender, + duration: uint48(_duration), + price : _price, + acceptedActivity: _acceptedActivity + }); + + emit OfferCreated(_tokenId, _duration, _price, _acceptedActivity, msg.sender); + } + + /// @notice This method can be used by the owner to extract mistakenly + /// sent tokens to this contract. + /// @param _token The address of the token contract that you want to recover + /// set to 0 in case you want to extract ether. + function claimTokens(address _token) public auth { + if (_token == 0x0) { + owner.transfer(address(this).balance); + return; + } + ERC20 token = ERC20(_token); + uint balance = token.balanceOf(address(this)); + token.transfer(owner, balance); + + emit ClaimedTokens(_token, owner, balance); + } + + function toBytes(address x) public pure returns (bytes b) { + b = new bytes(32); + assembly { mstore(add(b, 32), x) } + } + +} \ No newline at end of file diff --git a/flat/TokenUseAuthority.sol b/flat/TokenUseAuthority.sol new file mode 100644 index 0000000..93acc1a --- /dev/null +++ b/flat/TokenUseAuthority.sol @@ -0,0 +1,21 @@ +// Root file: contracts/TokenUseAuthority.sol + +pragma solidity ^0.4.24; + +contract TokenUseAuthority { + + mapping (address => bool) public whiteList; + + constructor(address[] _whitelists) public { + for (uint i = 0; i < _whitelists.length; i ++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, address _dst, bytes4 _sig + ) public view returns (bool) { + return (whiteList[_src] && _sig == bytes4(keccak256("addActivity(uint256,address,uint256)"))) || + ( whiteList[_src] && _sig == bytes4(keccak256("removeActivity(uint256,address)"))); + } +} \ No newline at end of file diff --git a/flat/TokenVestingFactory.sol b/flat/TokenVestingFactory.sol new file mode 100644 index 0000000..04015ec --- /dev/null +++ b/flat/TokenVestingFactory.sol @@ -0,0 +1,400 @@ +// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol + +// pragma solidity ^0.4.24; + + +/** + * @title Ownable + * @dev The Ownable contract has an owner address, and provides basic authorization control + * functions, this simplifies the implementation of "user permissions". + */ +contract Ownable { + address public owner; + + + event OwnershipRenounced(address indexed previousOwner); + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + + /** + * @dev The Ownable constructor sets the original `owner` of the contract to the sender + * account. + */ + constructor() public { + owner = msg.sender; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + /** + * @dev Allows the current owner to relinquish control of the contract. + * @notice Renouncing to ownership will leave the contract without an owner. + * It will not be possible to call the functions with the `onlyOwner` + * modifier anymore. + */ + function renounceOwnership() public onlyOwner { + emit OwnershipRenounced(owner); + owner = address(0); + } + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function transferOwnership(address _newOwner) public onlyOwner { + _transferOwnership(_newOwner); + } + + /** + * @dev Transfers control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function _transferOwnership(address _newOwner) internal { + require(_newOwner != address(0)); + emit OwnershipTransferred(owner, _newOwner); + owner = _newOwner; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; + + +/** + * @title SafeERC20 + * @dev Wrappers around ERC20 operations that throw on failure. + * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, + * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. + */ +library SafeERC20 { + function safeTransfer( + ERC20Basic _token, + address _to, + uint256 _value + ) + internal + { + require(_token.transfer(_to, _value)); + } + + function safeTransferFrom( + ERC20 _token, + address _from, + address _to, + uint256 _value + ) + internal + { + require(_token.transferFrom(_from, _to, _value)); + } + + function safeApprove( + ERC20 _token, + address _spender, + uint256 _value + ) + internal + { + require(_token.approve(_spender, _value)); + } +} + + +// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol + +// pragma solidity ^0.4.24; + + +/** + * @title SafeMath + * @dev Math operations with safety checks that throw on error + */ +library SafeMath { + + /** + * @dev Multiplies two numbers, throws on overflow. + */ + function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + // Gas optimization: this is cheaper than asserting 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 + if (_a == 0) { + return 0; + } + + c = _a * _b; + assert(c / _a == _b); + return c; + } + + /** + * @dev Integer division of two numbers, truncating the quotient. + */ + function div(uint256 _a, uint256 _b) internal pure returns (uint256) { + // assert(_b > 0); // Solidity automatically throws when dividing by 0 + // uint256 c = _a / _b; + // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold + return _a / _b; + } + + /** + * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). + */ + function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { + assert(_b <= _a); + return _a - _b; + } + + /** + * @dev Adds two numbers, throws on overflow. + */ + function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + c = _a + _b; + assert(c >= _a); + return c; + } +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/TokenVesting.sol + +/* solium-disable security/no-block-members */ + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; +// import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; +// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; + + +/** + * @title TokenVesting + * @dev A token holder contract that can release its token balance gradually like a + * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the + * owner. + */ +contract TokenVesting is Ownable { + using SafeMath for uint256; + using SafeERC20 for ERC20Basic; + + event Released(uint256 amount); + event Revoked(); + + // beneficiary of tokens after they are released + address public beneficiary; + + uint256 public cliff; + uint256 public start; + uint256 public duration; + + bool public revocable; + + mapping (address => uint256) public released; + mapping (address => bool) public revoked; + + /** + * @dev Creates a vesting contract that vests its balance of any ERC20 token to the + * _beneficiary, gradually in a linear fashion until _start + _duration. By then all + * of the balance will have vested. + * @param _beneficiary address of the beneficiary to whom vested tokens are transferred + * @param _cliff duration in seconds of the cliff in which tokens will begin to vest + * @param _start the time (as Unix time) at which point vesting starts + * @param _duration duration in seconds of the period in which the tokens will vest + * @param _revocable whether the vesting is revocable or not + */ + constructor( + address _beneficiary, + uint256 _start, + uint256 _cliff, + uint256 _duration, + bool _revocable + ) + public + { + require(_beneficiary != address(0)); + require(_cliff <= _duration); + + beneficiary = _beneficiary; + revocable = _revocable; + duration = _duration; + cliff = _start.add(_cliff); + start = _start; + } + + /** + * @notice Transfers vested tokens to beneficiary. + * @param _token ERC20 token which is being vested + */ + function release(ERC20Basic _token) public { + uint256 unreleased = releasableAmount(_token); + + require(unreleased > 0); + + released[_token] = released[_token].add(unreleased); + + _token.safeTransfer(beneficiary, unreleased); + + emit Released(unreleased); + } + + /** + * @notice Allows the owner to revoke the vesting. Tokens already vested + * remain in the contract, the rest are returned to the owner. + * @param _token ERC20 token which is being vested + */ + function revoke(ERC20Basic _token) public onlyOwner { + require(revocable); + require(!revoked[_token]); + + uint256 balance = _token.balanceOf(address(this)); + + uint256 unreleased = releasableAmount(_token); + uint256 refund = balance.sub(unreleased); + + revoked[_token] = true; + + _token.safeTransfer(owner, refund); + + emit Revoked(); + } + + /** + * @dev Calculates the amount that has already vested but hasn't been released yet. + * @param _token ERC20 token which is being vested + */ + function releasableAmount(ERC20Basic _token) public view returns (uint256) { + return vestedAmount(_token).sub(released[_token]); + } + + /** + * @dev Calculates the amount that has already vested. + * @param _token ERC20 token which is being vested + */ + function vestedAmount(ERC20Basic _token) public view returns (uint256) { + uint256 currentBalance = _token.balanceOf(address(this)); + uint256 totalBalance = currentBalance.add(released[_token]); + + if (block.timestamp < cliff) { + return 0; + } else if (block.timestamp >= start.add(duration) || revoked[_token]) { + return totalBalance; + } else { + return totalBalance.mul(block.timestamp.sub(start)).div(duration); + } + } +} + + +// Root file: contracts/TokenVestingFactory.sol + +pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +// import "openzeppelin-solidity/contracts/token/ERC20/TokenVesting.sol"; + +contract TokenVestingFactory is Ownable { + // claimedToken event + event ClaimedTokens(address indexed token, address indexed owner, uint amount); + + // index of created contracts + address[] public contracts; + + // useful to know the row count in contracts index + function getContractCount() public constant returns(uint contractCount) + { + return contracts.length; + } + + // deploy a new contract + function newTokenVesting( + address _beneficiary, + uint256 _start, + uint256 _cliff, + uint256 _duration, + bool _revocable) public returns(address newContract) + { + TokenVesting tv = new TokenVesting(_beneficiary, _start, _cliff, _duration, _revocable); + contracts.push(tv); + return tv; + } + + function revokeVesting(uint256 _contractIndex, ERC20Basic _token) public onlyOwner { + TokenVesting(contracts[_contractIndex]).revoke(_token); + } + + /// @notice This method can be used by the owner to extract mistakenly + /// sent tokens to this contract. + /// @param _token The address of the token contract that you want to recover + /// set to 0 in case you want to extract ether. + function claimTokens(address _token) public onlyOwner { + if (_token == 0x0) { + owner.transfer(address(this).balance); + return; + } + ERC20 token = ERC20(_token); + uint balance = token.balanceOf(address(this)); + token.transfer(owner, balance); + + emit ClaimedTokens(_token, owner, balance); + } +} \ No newline at end of file diff --git a/flat/UserPoints.sol b/flat/UserPoints.sol new file mode 100644 index 0000000..98388ac --- /dev/null +++ b/flat/UserPoints.sol @@ -0,0 +1,265 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * See https://github.com/ethereum/EIPs/issues/179 + */ +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address _who) public view returns (uint256); + function transfer(address _to, uint256 _value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; + + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +contract ERC20 is ERC20Basic { + function allowance(address _owner, address _spender) + public view returns (uint256); + + function transferFrom(address _from, address _to, uint256 _value) + public returns (bool); + + function approve(address _spender, uint256 _value) public returns (bool); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + + +// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol + +// pragma solidity ^0.4.24; + + +/** + * @title SafeMath + * @dev Math operations with safety checks that throw on error + */ +library SafeMath { + + /** + * @dev Multiplies two numbers, throws on overflow. + */ + function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + // Gas optimization: this is cheaper than asserting 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 + if (_a == 0) { + return 0; + } + + c = _a * _b; + assert(c / _a == _b); + return c; + } + + /** + * @dev Integer division of two numbers, truncating the quotient. + */ + function div(uint256 _a, uint256 _b) internal pure returns (uint256) { + // assert(_b > 0); // Solidity automatically throws when dividing by 0 + // uint256 c = _a / _b; + // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold + return _a / _b; + } + + /** + * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). + */ + function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { + assert(_b <= _a); + return _a - _b; + } + + /** + * @dev Adds two numbers, throws on overflow. + */ + function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { + c = _a + _b; + assert(c >= _a); + return c; + } +} + + +// Dependency file: contracts/interfaces/IUserPoints.sol + +// pragma solidity ^0.4.24; + +contract IUserPoints { + event AddedPoints(address indexed user, uint256 pointAmount); + event SubedPoints(address indexed user, uint256 pointAmount); + + function addPoints(address _user, uint256 _pointAmount) public; + + function subPoints(address _user, uint256 _pointAmount) public; + + function pointsSupply() public view returns (uint256); + + function pointsBalanceOf(address _user) public view returns (uint256); +} + + +// Root file: contracts/UserPoints.sol + +pragma solidity ^0.4.24; + +// import "contracts/DSAuth.sol"; +// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; +// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +// import "contracts/interfaces/IUserPoints.sol"; + +contract UserPoints is DSAuth, IUserPoints { + using SafeMath for *; + + // claimedToken event + event ClaimedTokens(address indexed token, address indexed owner, uint amount); + + bool private singletonLock = false; + + // points + mapping (address => uint256) public points; + + uint256 public allUserPoints; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract() public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function pointsSupply() public view returns (uint256) { + return allUserPoints; + } + + function pointsBalanceOf(address _user) public view returns (uint256) { + return points[_user]; + } + + function addPoints(address _user, uint256 _pointAmount) public auth { + points[_user] = points[_user].add(_pointAmount); + allUserPoints = allUserPoints.add(_pointAmount); + + emit AddedPoints(_user, _pointAmount); + } + + function subPoints(address _user, uint256 _pointAmount) public auth { + points[_user] = points[_user].sub(_pointAmount); + allUserPoints = allUserPoints.sub(_pointAmount); + emit SubedPoints(_user, _pointAmount); + } + + /// @notice This method can be used by the owner to extract mistakenly + /// sent tokens to this contract. + /// @param _token The address of the token contract that you want to recover + /// set to 0 in case you want to extract ether. + function claimTokens(address _token) public auth { + if (_token == 0x0) { + owner.transfer(address(this).balance); + return; + } + ERC20 token = ERC20(_token); + uint balance = token.balanceOf(address(this)); + token.transfer(owner, balance); + + emit ClaimedTokens(_token, owner, balance); + } +} \ No newline at end of file diff --git a/flat/UserPointsAuthority.sol b/flat/UserPointsAuthority.sol new file mode 100644 index 0000000..ece830f --- /dev/null +++ b/flat/UserPointsAuthority.sol @@ -0,0 +1,20 @@ +// Root file: contracts/UserPointsAuthority.sol + +pragma solidity ^0.4.24; + +contract UserPointsAuthority { + mapping (address => bool) public whiteList; + + constructor(address[] _whitelists) public { + for (uint i = 0; i < _whitelists.length; i ++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, address _dst, bytes4 _sig + ) public view returns (bool) { + return ( whiteList[_src] && _sig == bytes4(keccak256("addPoints(address,uint256)"))) || + ( whiteList[_src] && _sig == bytes4(keccak256("subPoints(address,uint256)"))); + } +} diff --git a/package.json b/package.json index 9d9c508..2a2a166 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,8 @@ "test": "test" }, "scripts": { + "build": "npx waffle", + "flatten": "npx waffle flatten", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -21,9 +23,12 @@ }, "homepage": "https://github.com/evolutionlandorg/common-contracts#readme", "dependencies": { - "openzeppelin-solidity": "1.12.0", - "@truffle/hdwallet-provider": "^1.0.23", "@evolutionland/upgraeability-using-unstructured-storage": "^0.1.1", + "@truffle/hdwallet-provider": "^1.0.23", + "openzeppelin-solidity": "1.12.0", "web3": "^1.2.11" + }, + "devDependencies": { + "ethereum-waffle": "^3.2.1" } } From caf1fdb7e3d895fd2977e99e4ed238dca06f1ba1 Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 23 Feb 2021 14:56:47 +0800 Subject: [PATCH 03/64] dev: support PolkPet --- contracts/ERC721BridgeV2.sol | 199 +++++++ contracts/PolkaPetAdaptor.sol | 99 ++++ contracts/interfaces/IERC1155.sol | 103 ++++ contracts/interfaces/IERC165.sol | 24 + contracts/interfaces/INFTAdaptor.sol | 2 + flat/ERC721Adaptor.sol | 2 + flat/ERC721Bridge.sol | 2 + flat/ERC721BridgeV2.sol | 822 +++++++++++++++++++++++++++ flat/IERC1155.sol | 132 +++++ flat/IERC165.sol | 26 + flat/INFTAdaptor.sol | 2 + flat/PolkaPetAdaptor.sol | 705 +++++++++++++++++++++++ 12 files changed, 2118 insertions(+) create mode 100644 contracts/ERC721BridgeV2.sol create mode 100644 contracts/PolkaPetAdaptor.sol create mode 100644 contracts/interfaces/IERC1155.sol create mode 100644 contracts/interfaces/IERC165.sol create mode 100644 flat/ERC721BridgeV2.sol create mode 100644 flat/IERC1155.sol create mode 100644 flat/IERC165.sol create mode 100644 flat/PolkaPetAdaptor.sol diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol new file mode 100644 index 0000000..0d95281 --- /dev/null +++ b/contracts/ERC721BridgeV2.sol @@ -0,0 +1,199 @@ +pragma solidity ^0.4.23; + +import "./PausableDSAuth.sol"; +import "./interfaces/ISettingsRegistry.sol"; +import "./SettingIds.sol"; +import "./interfaces/IInterstellarEncoderV3.sol"; +import "./interfaces/IMintableERC20.sol"; +import "./interfaces/IBurnableERC20.sol"; +import "./interfaces/INFTAdaptor.sol"; +import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +import "./interfaces/IERC1155.sol"; + + +/* + * naming convention: + * originTokenId - token outside evolutionLand + * mirrorTokenId - mirror token + */ +contract ERC721BridgeV2 is SettingIds, PausableDSAuth { + + /* + * Storage + */ + bool private singletonLock = false; + + ISettingsRegistry public registry; + + + // originNFTContract => its adator + // for instance, CryptoKitties => CryptoKittiesAdaptor + // this need to be registered by owner + mapping(address => address) public originNFT2Adaptor; + + // tokenId_inside => tokenId_outside + mapping(uint256 => uint256) public mirrorId2OriginId; + + /* + * Event + */ + event BridgeIn(uint256 originTokenId, uint256 mirrorTokenId, address originContract, address adaptorAddress, address owner); + + event SwapIn(uint256 originTokenId, uint256 mirrorTokenId, address owner); + event SwapOut(uint256 originTokenId, uint256 mirrorTokenId, address owner); + + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract(ISettingsRegistry _registry) public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + registry = _registry; + } + + function registerAdaptor(address _originNftAddress, address _erc721Adaptor) public whenNotPaused onlyOwner { + originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; + } + + // used by PetBase + function bridgeInAuth(address _originNftAddress, uint256 _originTokenId, address _owner) public auth returns (uint256) { + return _bridgeIn(_originNftAddress, _originTokenId, _owner); + } + + + // generate new mirror token without origin token frozen + function bridgeIn(address _originNftAddress, uint256 _originTokenId) public returns (uint256) { + _bridgeIn(_originNftAddress, _originTokenId, msg.sender); + } + + function _bridgeIn(address _originNftAddress, uint256 _originTokenId, address _owner) internal returns (uint256) { + address adaptor = originNFT2Adaptor[_originNftAddress]; + require(adaptor != address(0), "Not registered!"); + + require(INFTAdaptor(adaptor).ownerInOrigin(_originTokenId) == _owner, "Invalid owner!"); + + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); + + // if it is the first time to bridge in + if (!isBridged(mirrorTokenId)) { + // keep new mirror object in this contract + // before the owner has transferred his/her outerObject into this contract + // mirror object can not be transferred + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); + + // link objects_in and objects_out + INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); + } + + return mirrorTokenId; + } + + // freeze origin token to free mirror token + function swapIn(address _originNftAddress, uint256 _originTokenId) public { + require(ERC721(_originNftAddress).ownerOf(_originTokenId) == msg.sender, "Invalid owner!"); + + address adaptor = originNFT2Adaptor[_originNftAddress]; + require(adaptor != address(0), "Not registered!"); + + // all specific originTokens are kept in bridge + ERC721(_originNftAddress).transferFrom(msg.sender, address(this), _originTokenId); + + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + ERC721(objectOwnership).transferFrom(address(this), msg.sender, mirrorTokenId); + + emit SwapIn(_originTokenId, mirrorTokenId, msg.sender); + } + + function bridgeAndSwapIn(address _originNftAddress, uint256 _originTokenId) public { + bridgeIn(_originNftAddress, _originTokenId); + swapIn(_originNftAddress, _originTokenId); + } + + // V2 add - Support PolkaPet + function bridgeAndSwapIn1155(address _originNftAddress, uint256 _originTokenId) public { + address adaptor = originNFT2Adaptor[_originNftAddress]; + require(adaptor != address(0), "Not registered!"); + + IERC1155(_originNftAddress).safeTransferFrom(msg.sender, address(this), _originTokenId, 1, ""); + + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); + IMintableERC20(objectOwnership).mint(msg.sender, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, msg.sender); + emit SwapIn(_originTokenId, mirrorTokenId, msg.sender); + } + + function swapOut(uint256 _mirrorTokenId) public { + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); + require(nftContract != address(0), "No such NFT contract"); + address adaptor = originNFT2Adaptor[nftContract]; + require(adaptor != address(0), "not registered!"); + require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); + + // TODO: if it is needed to check its current status + uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + + // V2 add - Support PolkaPet + if (IERC1155(nftContract).supportsInterface(bytes4(keccak256("safeTransferFrom(address,address,uint256,uint256,bytes)")))) { + IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); + IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); + } else { + ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); + ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); + } + + emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); + } + + function approveOriginToken(address _originNFT, address _approved, uint256 _originTokenId) public auth { + ERC721(_originNFT).approve(_approved, _originTokenId); + } + + function ownerOf(uint256 _mirrorTokenId) public view returns (address) { + return ownerOfMirror(_mirrorTokenId); + } + + // return human owner of the token + function mirrorOfOrigin(address _originNFT, uint256 _originTokenId) public view returns (uint256) { + INFTAdaptor adapter = INFTAdaptor(originNFT2Adaptor[_originNFT]); + + return adapter.toMirrorTokenId(_originTokenId); + } + + // return human owner of the token + function ownerOfMirror(uint256 _mirrorTokenId) public view returns (address) { + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + address owner = ERC721(objectOwnership).ownerOf(_mirrorTokenId); + if(owner != address(this)) { + return owner; + } else { + uint originTokenId = mirrorId2OriginId[_mirrorTokenId]; + return INFTAdaptor(originNFT2Adaptor[originOwnershipAddress(_mirrorTokenId)]).ownerInOrigin(originTokenId); + } + } + + function originOwnershipAddress(uint256 _mirrorTokenId) public view returns (address) { + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + + return interstellarEncoder.getOriginAddress(_mirrorTokenId); + } + + function isBridged(uint256 _mirrorTokenId) public view returns (bool) { + return (mirrorId2OriginId[_mirrorTokenId] != 0); + } +} diff --git a/contracts/PolkaPetAdaptor.sol b/contracts/PolkaPetAdaptor.sol new file mode 100644 index 0000000..ec128de --- /dev/null +++ b/contracts/PolkaPetAdaptor.sol @@ -0,0 +1,99 @@ +pragma solidity ^0.4.24; + +import "./SettingIds.sol"; +import "./PausableDSAuth.sol"; +import "./interfaces/ISettingsRegistry.sol"; +import "./interfaces/INFTAdaptor.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +import "./interfaces/IInterstellarEncoderV3.sol"; +import "./interfaces/IERC1155.sol"; + + +contract PolkaPetAdaptor is PausableDSAuth, SettingIds { + + event SetTokenIDAuth(uint256 indexed tokenId, bool status); + + /* + * Storage + */ + bool private singletonLock = false; + + uint16 public producerId; + + uint8 public convertType; + + ISettingsRegistry public registry; + + IERC1155 public originNft; + + uint128 public lastObjectId; + + // tokenID => bool allowList + mapping (uint256 => bool) public allowList; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + registry = _registry; + originNft = _originNft; + producerId = _producerId; + + convertType = 128; // f(x) = x,fullfill with zero at left side. + } + + function setTokenIDAuth(uint256 _tokenId, bool _status) public auth { + allowList[_tokenId] = _status; + emit SetTokenIDAuth(_tokenId, _status); + } + + function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256) { + require(allowList[_originTokenId], "POLKPET: PERMISSION"); + lastObjectId += 1; + uint128 mirrorObjectId = uint128(lastObjectId & 0xffffffffffffffffffffffffffffffff); + require(lastObjectId <= uint128(-1), "POLKPET: OBJECTID_OVERFLOW"); + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + uint256 mirrorTokenId = interstellarEncoder.encodeTokenIdForOuterObjectContract( + petBase, objectOwnership, address(originNft), mirrorObjectId, producerId, convertType); + + return mirrorTokenId; + } + + function ownerInOrigin(uint256 _originTokenId) public view returns (address) { + revert("NOT_SUPPORT"); + } + + // if the convertion is not calculatable, and need to use cache mapping in Bridge. + // then .. + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256) { + revert("NOT_SUPPORT"); + } + + function approveToBridge(address _bridge) public onlyOwner { + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + IERC1155(objectOwnership).setApprovalForAll(_bridge, true); + } + + function cancelApprove(address _bridge) public onlyOwner { + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + IERC1155(objectOwnership).setApprovalForAll(_bridge, false); + } + + function getObjectClass(uint256 _originTokenId) public view returns (uint8) { + revert("NOT_SUPPORT"); + } + + function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public auth { + revert("NOT_SUPPORT"); + } +} diff --git a/contracts/interfaces/IERC1155.sol b/contracts/interfaces/IERC1155.sol new file mode 100644 index 0000000..ad0dbc7 --- /dev/null +++ b/contracts/interfaces/IERC1155.sol @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.4.24; + +import "./IERC165.sol"; + +/** + * @dev Required interface of an ERC1155 compliant contract, as defined in the + * https://eips.ethereum.org/EIPS/eip-1155[EIP]. + * + * _Available since v3.1._ + */ +contract IERC1155 is IERC165 { + /** + * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. + */ + event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); + + /** + * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all + * transfers. + */ + event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); + + /** + * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to + * `approved`. + */ + event ApprovalForAll(address indexed account, address indexed operator, bool approved); + + /** + * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. + * + * If an {URI} event was emitted for `id`, the standard + * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value + * returned by {IERC1155MetadataURI-uri}. + */ + event URI(string value, uint256 indexed id); + + /** + * @dev Returns the amount of tokens of token type `id` owned by `account`. + * + * Requirements: + * + * - `account` cannot be the zero address. + */ + function balanceOf(address account, uint256 id) external view returns (uint256); + + /** + * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. + * + * Requirements: + * + * - `accounts` and `ids` must have the same length. + */ + function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[] memory); + + /** + * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, + * + * Emits an {ApprovalForAll} event. + * + * Requirements: + * + * - `operator` cannot be the caller. + */ + function setApprovalForAll(address operator, bool approved) external; + + /** + * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. + * + * See {setApprovalForAll}. + */ + function isApprovedForAll(address account, address operator) external view returns (bool); + + /** + * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. + * + * Emits a {TransferSingle} event. + * + * Requirements: + * + * - `to` cannot be the zero address. + * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. + * - `from` must have a balance of tokens of type `id` of at least `amount`. + * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the + * acceptance magic value. + */ + function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external; + + /** + * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. + * + * Emits a {TransferBatch} event. + * + * Requirements: + * + * - `ids` and `amounts` must have the same length. + * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the + * acceptance magic value. + */ + function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external; +} diff --git a/contracts/interfaces/IERC165.sol b/contracts/interfaces/IERC165.sol new file mode 100644 index 0000000..953c61a --- /dev/null +++ b/contracts/interfaces/IERC165.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.4.24; + +/** + * @dev Interface of the ERC165 standard, as defined in the + * https://eips.ethereum.org/EIPS/eip-165[EIP]. + * + * Implementers can declare support of contract interfaces, which can then be + * queried by others ({ERC165Checker}). + * + * For an implementation, see {ERC165}. + */ +contract IERC165 { + /** + * @dev Returns true if this contract implements the interface defined by + * `interfaceId`. See the corresponding + * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] + * to learn more about how these ids are created. + * + * This function call must use less than 30 000 gas. + */ + function supportsInterface(bytes4 interfaceId) external view returns (bool); +} diff --git a/contracts/interfaces/INFTAdaptor.sol b/contracts/interfaces/INFTAdaptor.sol index 8314c00..7638a4b 100644 --- a/contracts/interfaces/INFTAdaptor.sol +++ b/contracts/interfaces/INFTAdaptor.sol @@ -4,6 +4,8 @@ pragma solidity ^0.4.24; contract INFTAdaptor { function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); + function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); function approveOriginToken(address _bridge, uint256 _originTokenId) public; diff --git a/flat/ERC721Adaptor.sol b/flat/ERC721Adaptor.sol index c00d406..ab1c40f 100644 --- a/flat/ERC721Adaptor.sol +++ b/flat/ERC721Adaptor.sol @@ -255,6 +255,8 @@ contract ISettingsRegistry { contract INFTAdaptor { function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); + function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); function approveOriginToken(address _bridge, uint256 _originTokenId) public; diff --git a/flat/ERC721Bridge.sol b/flat/ERC721Bridge.sol index 5072107..862cf8d 100644 --- a/flat/ERC721Bridge.sol +++ b/flat/ERC721Bridge.sol @@ -306,6 +306,8 @@ contract IMintableERC20 { contract INFTAdaptor { function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); + function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); function approveOriginToken(address _bridge, uint256 _originTokenId) public; diff --git a/flat/ERC721BridgeV2.sol b/flat/ERC721BridgeV2.sol new file mode 100644 index 0000000..0ab7506 --- /dev/null +++ b/flat/ERC721BridgeV2.sol @@ -0,0 +1,822 @@ +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: contracts/PausableDSAuth.sol + +// pragma solidity ^0.4.24; + +// import "contracts/DSAuth.sol"; + + +/** + * @title Pausable + * @dev Base contract which allows children to implement an emergency stop mechanism. + */ +contract PausableDSAuth is DSAuth { + event Pause(); + event Unpause(); + + bool public paused = false; + + + /** + * @dev Modifier to make a function callable only when the contract is not paused. + */ + modifier whenNotPaused() { + require(!paused); + _; + } + + /** + * @dev Modifier to make a function callable only when the contract is paused. + */ + modifier whenPaused() { + require(paused); + _; + } + + /** + * @dev called by the owner to pause, triggers stopped state + */ + function pause() public onlyOwner whenNotPaused { + paused = true; + emit Pause(); + } + + /** + * @dev called by the owner to unpause, returns to normal state + */ + function unpause() public onlyOwner whenPaused { + paused = false; + emit Unpause(); + } +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Dependency file: contracts/interfaces/IInterstellarEncoderV3.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoderV3 { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function encodeTokenIdForOuterObjectContract( + address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); + + function getProducerId(uint256 _tokenId) public view returns (uint16); + + function getOriginAddress(uint256 _tokenId) public view returns (address); + +} + +// Dependency file: contracts/interfaces/IMintableERC20.sol + +// pragma solidity ^0.4.23; + +contract IMintableERC20 { + + function mint(address _to, uint256 _value) public; +} + +// Dependency file: contracts/interfaces/IBurnableERC20.sol + +// pragma solidity ^0.4.23; + +contract IBurnableERC20 { + function burn(address _from, uint _value) public; +} + +// Dependency file: contracts/interfaces/INFTAdaptor.sol + +// pragma solidity ^0.4.24; + + +contract INFTAdaptor { + function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); + + function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); + + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); + + function approveOriginToken(address _bridge, uint256 _originTokenId) public; + + function ownerInOrigin(uint256 _originTokenId) public view returns (address); + + function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public; +} + + +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + + +/** + * @title ERC721 Non-Fungible Token Standard basic interface + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Basic is ERC165 { + + bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; + /* + * 0x80ac58cd === + * bytes4(keccak256('balanceOf(address)')) ^ + * bytes4(keccak256('ownerOf(uint256)')) ^ + * bytes4(keccak256('approve(address,uint256)')) ^ + * bytes4(keccak256('getApproved(uint256)')) ^ + * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ + * bytes4(keccak256('isApprovedForAll(address,address)')) ^ + * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) + */ + + bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; + /* + * 0x4f558e79 === + * bytes4(keccak256('exists(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; + /** + * 0x780e9d63 === + * bytes4(keccak256('totalSupply()')) ^ + * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ + * bytes4(keccak256('tokenByIndex(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; + /** + * 0x5b5e139f === + * bytes4(keccak256('name()')) ^ + * bytes4(keccak256('symbol()')) ^ + * bytes4(keccak256('tokenURI(uint256)')) + */ + + event Transfer( + address indexed _from, + address indexed _to, + uint256 indexed _tokenId + ); + event Approval( + address indexed _owner, + address indexed _approved, + uint256 indexed _tokenId + ); + event ApprovalForAll( + address indexed _owner, + address indexed _operator, + bool _approved + ); + + function balanceOf(address _owner) public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view returns (bool _exists); + + function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) + public view returns (address _operator); + + function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) + public view returns (bool); + + function transferFrom(address _from, address _to, uint256 _tokenId) public; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) + public; + + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public; +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Enumerable is ERC721Basic { + function totalSupply() public view returns (uint256); + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256 _tokenId); + + function tokenByIndex(uint256 _index) public view returns (uint256); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional metadata extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Metadata is ERC721Basic { + function name() external view returns (string _name); + function symbol() external view returns (string _symbol); + function tokenURI(uint256 _tokenId) public view returns (string); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, full implementation interface + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { +} + + +// Dependency file: contracts/interfaces/IERC165.sol + +// SPDX-License-Identifier: MIT + +// pragma solidity ^0.4.24; + +/** + * @dev Interface of the ERC165 standard, as defined in the + * https://eips.ethereum.org/EIPS/eip-165[EIP]. + * + * Implementers can declare support of contract interfaces, which can then be + * queried by others ({ERC165Checker}). + * + * For an implementation, see {ERC165}. + */ +contract IERC165 { + /** + * @dev Returns true if this contract implements the interface defined by + * `interfaceId`. See the corresponding + * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] + * to learn more about how these ids are created. + * + * This function call must use less than 30 000 gas. + */ + function supportsInterface(bytes4 interfaceId) external view returns (bool); +} + + +// Dependency file: contracts/interfaces/IERC1155.sol + + +// pragma solidity ^0.4.24; + +// import "contracts/interfaces/IERC165.sol"; + +/** + * @dev Required interface of an ERC1155 compliant contract, as defined in the + * https://eips.ethereum.org/EIPS/eip-1155[EIP]. + * + * _Available since v3.1._ + */ +contract IERC1155 is IERC165 { + /** + * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. + */ + event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); + + /** + * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all + * transfers. + */ + event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); + + /** + * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to + * `approved`. + */ + event ApprovalForAll(address indexed account, address indexed operator, bool approved); + + /** + * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. + * + * If an {URI} event was emitted for `id`, the standard + * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value + * returned by {IERC1155MetadataURI-uri}. + */ + event URI(string value, uint256 indexed id); + + /** + * @dev Returns the amount of tokens of token type `id` owned by `account`. + * + * Requirements: + * + * - `account` cannot be the zero address. + */ + function balanceOf(address account, uint256 id) external view returns (uint256); + + /** + * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. + * + * Requirements: + * + * - `accounts` and `ids` must have the same length. + */ + function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[] memory); + + /** + * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, + * + * Emits an {ApprovalForAll} event. + * + * Requirements: + * + * - `operator` cannot be the caller. + */ + function setApprovalForAll(address operator, bool approved) external; + + /** + * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. + * + * See {setApprovalForAll}. + */ + function isApprovedForAll(address account, address operator) external view returns (bool); + + /** + * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. + * + * Emits a {TransferSingle} event. + * + * Requirements: + * + * - `to` cannot be the zero address. + * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. + * - `from` must have a balance of tokens of type `id` of at least `amount`. + * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the + * acceptance magic value. + */ + function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external; + + /** + * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. + * + * Emits a {TransferBatch} event. + * + * Requirements: + * + * - `ids` and `amounts` must have the same length. + * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the + * acceptance magic value. + */ + function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external; +} + + +// Root file: contracts/ERC721BridgeV2.sol + +pragma solidity ^0.4.23; + +// import "contracts/PausableDSAuth.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/SettingIds.sol"; +// import "contracts/interfaces/IInterstellarEncoderV3.sol"; +// import "contracts/interfaces/IMintableERC20.sol"; +// import "contracts/interfaces/IBurnableERC20.sol"; +// import "contracts/interfaces/INFTAdaptor.sol"; +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +// import "contracts/interfaces/IERC1155.sol"; + + +/* + * naming convention: + * originTokenId - token outside evolutionLand + * mirrorTokenId - mirror token + */ +contract ERC721BridgeV2 is SettingIds, PausableDSAuth { + + /* + * Storage + */ + bool private singletonLock = false; + + ISettingsRegistry public registry; + + + // originNFTContract => its adator + // for instance, CryptoKitties => CryptoKittiesAdaptor + // this need to be registered by owner + mapping(address => address) public originNFT2Adaptor; + + // tokenId_inside => tokenId_outside + mapping(uint256 => uint256) public mirrorId2OriginId; + + /* + * Event + */ + event BridgeIn(uint256 originTokenId, uint256 mirrorTokenId, address originContract, address adaptorAddress, address owner); + + event SwapIn(uint256 originTokenId, uint256 mirrorTokenId, address owner); + event SwapOut(uint256 originTokenId, uint256 mirrorTokenId, address owner); + + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract(ISettingsRegistry _registry) public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + registry = _registry; + } + + function registerAdaptor(address _originNftAddress, address _erc721Adaptor) public whenNotPaused onlyOwner { + originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; + } + + // used by PetBase + function bridgeInAuth(address _originNftAddress, uint256 _originTokenId, address _owner) public auth returns (uint256) { + return _bridgeIn(_originNftAddress, _originTokenId, _owner); + } + + + // generate new mirror token without origin token frozen + function bridgeIn(address _originNftAddress, uint256 _originTokenId) public returns (uint256) { + _bridgeIn(_originNftAddress, _originTokenId, msg.sender); + } + + function _bridgeIn(address _originNftAddress, uint256 _originTokenId, address _owner) internal returns (uint256) { + address adaptor = originNFT2Adaptor[_originNftAddress]; + require(adaptor != address(0), "Not registered!"); + + require(INFTAdaptor(adaptor).ownerInOrigin(_originTokenId) == _owner, "Invalid owner!"); + + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); + + // if it is the first time to bridge in + if (!isBridged(mirrorTokenId)) { + // keep new mirror object in this contract + // before the owner has transferred his/her outerObject into this contract + // mirror object can not be transferred + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); + + // link objects_in and objects_out + INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); + } + + return mirrorTokenId; + } + + // freeze origin token to free mirror token + function swapIn(address _originNftAddress, uint256 _originTokenId) public { + require(ERC721(_originNftAddress).ownerOf(_originTokenId) == msg.sender, "Invalid owner!"); + + address adaptor = originNFT2Adaptor[_originNftAddress]; + require(adaptor != address(0), "Not registered!"); + + // all specific originTokens are kept in bridge + ERC721(_originNftAddress).transferFrom(msg.sender, address(this), _originTokenId); + + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + ERC721(objectOwnership).transferFrom(address(this), msg.sender, mirrorTokenId); + + emit SwapIn(_originTokenId, mirrorTokenId, msg.sender); + } + + function bridgeAndSwapIn(address _originNftAddress, uint256 _originTokenId) public { + bridgeIn(_originNftAddress, _originTokenId); + swapIn(_originNftAddress, _originTokenId); + } + + // V2 add - Support PolkaPet + function bridgeAndSwapIn1155(address _originNftAddress, uint256 _originTokenId) public { + address adaptor = originNFT2Adaptor[_originNftAddress]; + require(adaptor != address(0), "Not registered!"); + + IERC1155(_originNftAddress).safeTransferFrom(msg.sender, address(this), _originTokenId, 1, ""); + + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); + IMintableERC20(objectOwnership).mint(msg.sender, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, msg.sender); + emit SwapIn(_originTokenId, mirrorTokenId, msg.sender); + } + + function swapOut(uint256 _mirrorTokenId) public { + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); + require(nftContract != address(0), "No such NFT contract"); + address adaptor = originNFT2Adaptor[nftContract]; + require(adaptor != address(0), "not registered!"); + require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); + + // TODO: if it is needed to check its current status + uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + + // V2 add - Support PolkaPet + if (IERC1155(nftContract).supportsInterface(bytes4(keccak256("safeTransferFrom(address,address,uint256,uint256,bytes)")))) { + IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); + IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); + } else { + ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); + ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); + } + + emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); + } + + function approveOriginToken(address _originNFT, address _approved, uint256 _originTokenId) public auth { + ERC721(_originNFT).approve(_approved, _originTokenId); + } + + function ownerOf(uint256 _mirrorTokenId) public view returns (address) { + return ownerOfMirror(_mirrorTokenId); + } + + // return human owner of the token + function mirrorOfOrigin(address _originNFT, uint256 _originTokenId) public view returns (uint256) { + INFTAdaptor adapter = INFTAdaptor(originNFT2Adaptor[_originNFT]); + + return adapter.toMirrorTokenId(_originTokenId); + } + + // return human owner of the token + function ownerOfMirror(uint256 _mirrorTokenId) public view returns (address) { + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + address owner = ERC721(objectOwnership).ownerOf(_mirrorTokenId); + if(owner != address(this)) { + return owner; + } else { + uint originTokenId = mirrorId2OriginId[_mirrorTokenId]; + return INFTAdaptor(originNFT2Adaptor[originOwnershipAddress(_mirrorTokenId)]).ownerInOrigin(originTokenId); + } + } + + function originOwnershipAddress(uint256 _mirrorTokenId) public view returns (address) { + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + + return interstellarEncoder.getOriginAddress(_mirrorTokenId); + } + + function isBridged(uint256 _mirrorTokenId) public view returns (bool) { + return (mirrorId2OriginId[_mirrorTokenId] != 0); + } +} diff --git a/flat/IERC1155.sol b/flat/IERC1155.sol new file mode 100644 index 0000000..cd7e8db --- /dev/null +++ b/flat/IERC1155.sol @@ -0,0 +1,132 @@ +// Dependency file: contracts/interfaces/IERC165.sol + +// SPDX-License-Identifier: MIT + +// pragma solidity ^0.4.24; + +/** + * @dev Interface of the ERC165 standard, as defined in the + * https://eips.ethereum.org/EIPS/eip-165[EIP]. + * + * Implementers can declare support of contract interfaces, which can then be + * queried by others ({ERC165Checker}). + * + * For an implementation, see {ERC165}. + */ +contract IERC165 { + /** + * @dev Returns true if this contract implements the interface defined by + * `interfaceId`. See the corresponding + * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] + * to learn more about how these ids are created. + * + * This function call must use less than 30 000 gas. + */ + function supportsInterface(bytes4 interfaceId) external view returns (bool); +} + + +// Root file: contracts/interfaces/IERC1155.sol + + +pragma solidity ^0.4.24; + +// import "contracts/interfaces/IERC165.sol"; + +/** + * @dev Required interface of an ERC1155 compliant contract, as defined in the + * https://eips.ethereum.org/EIPS/eip-1155[EIP]. + * + * _Available since v3.1._ + */ +contract IERC1155 is IERC165 { + /** + * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. + */ + event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); + + /** + * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all + * transfers. + */ + event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); + + /** + * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to + * `approved`. + */ + event ApprovalForAll(address indexed account, address indexed operator, bool approved); + + /** + * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. + * + * If an {URI} event was emitted for `id`, the standard + * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value + * returned by {IERC1155MetadataURI-uri}. + */ + event URI(string value, uint256 indexed id); + + /** + * @dev Returns the amount of tokens of token type `id` owned by `account`. + * + * Requirements: + * + * - `account` cannot be the zero address. + */ + function balanceOf(address account, uint256 id) external view returns (uint256); + + /** + * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. + * + * Requirements: + * + * - `accounts` and `ids` must have the same length. + */ + function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[] memory); + + /** + * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, + * + * Emits an {ApprovalForAll} event. + * + * Requirements: + * + * - `operator` cannot be the caller. + */ + function setApprovalForAll(address operator, bool approved) external; + + /** + * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. + * + * See {setApprovalForAll}. + */ + function isApprovedForAll(address account, address operator) external view returns (bool); + + /** + * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. + * + * Emits a {TransferSingle} event. + * + * Requirements: + * + * - `to` cannot be the zero address. + * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. + * - `from` must have a balance of tokens of type `id` of at least `amount`. + * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the + * acceptance magic value. + */ + function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external; + + /** + * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. + * + * Emits a {TransferBatch} event. + * + * Requirements: + * + * - `ids` and `amounts` must have the same length. + * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the + * acceptance magic value. + */ + function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external; +} diff --git a/flat/IERC165.sol b/flat/IERC165.sol new file mode 100644 index 0000000..98379ca --- /dev/null +++ b/flat/IERC165.sol @@ -0,0 +1,26 @@ +// Root file: contracts/interfaces/IERC165.sol + +// SPDX-License-Identifier: MIT + +pragma solidity ^0.4.24; + +/** + * @dev Interface of the ERC165 standard, as defined in the + * https://eips.ethereum.org/EIPS/eip-165[EIP]. + * + * Implementers can declare support of contract interfaces, which can then be + * queried by others ({ERC165Checker}). + * + * For an implementation, see {ERC165}. + */ +contract IERC165 { + /** + * @dev Returns true if this contract implements the interface defined by + * `interfaceId`. See the corresponding + * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] + * to learn more about how these ids are created. + * + * This function call must use less than 30 000 gas. + */ + function supportsInterface(bytes4 interfaceId) external view returns (bool); +} diff --git a/flat/INFTAdaptor.sol b/flat/INFTAdaptor.sol index 3ad3ae5..ad7faf3 100644 --- a/flat/INFTAdaptor.sol +++ b/flat/INFTAdaptor.sol @@ -6,6 +6,8 @@ pragma solidity ^0.4.24; contract INFTAdaptor { function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); + function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); function approveOriginToken(address _bridge, uint256 _originTokenId) public; diff --git a/flat/PolkaPetAdaptor.sol b/flat/PolkaPetAdaptor.sol new file mode 100644 index 0000000..cb65da7 --- /dev/null +++ b/flat/PolkaPetAdaptor.sol @@ -0,0 +1,705 @@ +// Dependency file: contracts/SettingIds.sol + +// pragma solidity ^0.4.24; + +/** + Id definitions for SettingsRegistry.sol + Can be used in conjunction with the settings registry to get properties +*/ +contract SettingIds { + // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; + + // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; + + // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; + + // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; + + // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 + bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; + + // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; + + // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 + bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; + + // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 + bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; + + // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 + bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; + + // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 + bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; + + // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 + bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; + + // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 + bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; + + // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 + bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; + + // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 + bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; + + // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 + bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; + + // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 + bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; + + // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 + bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; + + // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 + bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; + + // Cut owner takes on each auction, measured in basis points (1/100 of a percent). + // this can be considered as transaction fee. + // Values 0-10,000 map to 0%-100% + // set ownerCut to 4% + // ownerCut = 400; + // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 + bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 + + // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 + bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 + + // Cut referer takes on each auction, measured in basis points (1/100 of a percent). + // which cut from transaction fee. + // Values 0-10,000 map to 0%-100% + // set refererCut to 4% + // refererCut = 400; + // 0x55494e545f524546455245525f43555400000000000000000000000000000000 + bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; + + // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 + bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; + + // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 + bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; +} + +// Dependency file: contracts/interfaces/IAuthority.sol + +// pragma solidity ^0.4.24; + +contract IAuthority { + function canCall( + address src, address dst, bytes4 sig + ) public view returns (bool); +} + +// Dependency file: contracts/DSAuth.sol + +// pragma solidity ^0.4.24; + +// import 'contracts/interfaces/IAuthority.sol'; + +contract DSAuthEvents { + event LogSetAuthority (address indexed authority); + event LogSetOwner (address indexed owner); +} + +/** + * @title DSAuth + * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth + * But in the isAuthorized method, the src from address(this) is remove for safty concern. + */ +contract DSAuth is DSAuthEvents { + IAuthority public authority; + address public owner; + + constructor() public { + owner = msg.sender; + emit LogSetOwner(msg.sender); + } + + function setOwner(address owner_) + public + auth + { + owner = owner_; + emit LogSetOwner(owner); + } + + function setAuthority(IAuthority authority_) + public + auth + { + authority = authority_; + emit LogSetAuthority(authority); + } + + modifier auth { + require(isAuthorized(msg.sender, msg.sig)); + _; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + function isAuthorized(address src, bytes4 sig) internal view returns (bool) { + if (src == owner) { + return true; + } else if (authority == IAuthority(0)) { + return false; + } else { + return authority.canCall(src, this, sig); + } + } +} + + +// Dependency file: contracts/PausableDSAuth.sol + +// pragma solidity ^0.4.24; + +// import "contracts/DSAuth.sol"; + + +/** + * @title Pausable + * @dev Base contract which allows children to implement an emergency stop mechanism. + */ +contract PausableDSAuth is DSAuth { + event Pause(); + event Unpause(); + + bool public paused = false; + + + /** + * @dev Modifier to make a function callable only when the contract is not paused. + */ + modifier whenNotPaused() { + require(!paused); + _; + } + + /** + * @dev Modifier to make a function callable only when the contract is paused. + */ + modifier whenPaused() { + require(paused); + _; + } + + /** + * @dev called by the owner to pause, triggers stopped state + */ + function pause() public onlyOwner whenNotPaused { + paused = true; + emit Pause(); + } + + /** + * @dev called by the owner to unpause, returns to normal state + */ + function unpause() public onlyOwner whenPaused { + paused = false; + emit Unpause(); + } +} + +// Dependency file: contracts/interfaces/ISettingsRegistry.sol + +// pragma solidity ^0.4.24; + +contract ISettingsRegistry { + enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } + + function uintOf(bytes32 _propertyName) public view returns (uint256); + + function stringOf(bytes32 _propertyName) public view returns (string); + + function addressOf(bytes32 _propertyName) public view returns (address); + + function bytesOf(bytes32 _propertyName) public view returns (bytes); + + function boolOf(bytes32 _propertyName) public view returns (bool); + + function intOf(bytes32 _propertyName) public view returns (int); + + function setUintProperty(bytes32 _propertyName, uint _value) public; + + function setStringProperty(bytes32 _propertyName, string _value) public; + + function setAddressProperty(bytes32 _propertyName, address _value) public; + + function setBytesProperty(bytes32 _propertyName, bytes _value) public; + + function setBoolProperty(bytes32 _propertyName, bool _value) public; + + function setIntProperty(bytes32 _propertyName, int _value) public; + + function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); + + event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); +} + +// Dependency file: contracts/interfaces/INFTAdaptor.sol + +// pragma solidity ^0.4.24; + + +contract INFTAdaptor { + function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); + + function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); + + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); + + function approveOriginToken(address _bridge, uint256 _originTokenId) public; + + function ownerInOrigin(uint256 _originTokenId) public view returns (address); + + function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public; +} + + +// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol + +// pragma solidity ^0.4.24; + + +/** + * @title ERC165 + * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md + */ +interface ERC165 { + + /** + * @notice Query if a contract implements an interface + * @param _interfaceId The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + */ + function supportsInterface(bytes4 _interfaceId) + external + view + returns (bool); +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; + + +/** + * @title ERC721 Non-Fungible Token Standard basic interface + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Basic is ERC165 { + + bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; + /* + * 0x80ac58cd === + * bytes4(keccak256('balanceOf(address)')) ^ + * bytes4(keccak256('ownerOf(uint256)')) ^ + * bytes4(keccak256('approve(address,uint256)')) ^ + * bytes4(keccak256('getApproved(uint256)')) ^ + * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ + * bytes4(keccak256('isApprovedForAll(address,address)')) ^ + * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) + */ + + bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; + /* + * 0x4f558e79 === + * bytes4(keccak256('exists(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; + /** + * 0x780e9d63 === + * bytes4(keccak256('totalSupply()')) ^ + * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ + * bytes4(keccak256('tokenByIndex(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; + /** + * 0x5b5e139f === + * bytes4(keccak256('name()')) ^ + * bytes4(keccak256('symbol()')) ^ + * bytes4(keccak256('tokenURI(uint256)')) + */ + + event Transfer( + address indexed _from, + address indexed _to, + uint256 indexed _tokenId + ); + event Approval( + address indexed _owner, + address indexed _approved, + uint256 indexed _tokenId + ); + event ApprovalForAll( + address indexed _owner, + address indexed _operator, + bool _approved + ); + + function balanceOf(address _owner) public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view returns (bool _exists); + + function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) + public view returns (address _operator); + + function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) + public view returns (bool); + + function transferFrom(address _from, address _to, uint256 _tokenId) public; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) + public; + + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public; +} + + +// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol + +// pragma solidity ^0.4.24; + +// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Enumerable is ERC721Basic { + function totalSupply() public view returns (uint256); + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256 _tokenId); + + function tokenByIndex(uint256 _index) public view returns (uint256); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, optional metadata extension + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721Metadata is ERC721Basic { + function name() external view returns (string _name); + function symbol() external view returns (string _symbol); + function tokenURI(uint256 _tokenId) public view returns (string); +} + + +/** + * @title ERC-721 Non-Fungible Token Standard, full implementation interface + * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { +} + + +// Dependency file: contracts/interfaces/IInterstellarEncoderV3.sol + +// pragma solidity ^0.4.24; + +contract IInterstellarEncoderV3 { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + uint256 public constant CHAIN_ID = 1; // Ethereum mainet. + uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function encodeTokenIdForOuterObjectContract( + address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); + + function getProducerId(uint256 _tokenId) public view returns (uint16); + + function getOriginAddress(uint256 _tokenId) public view returns (address); + +} + +// Dependency file: contracts/interfaces/IERC165.sol + +// SPDX-License-Identifier: MIT + +// pragma solidity ^0.4.24; + +/** + * @dev Interface of the ERC165 standard, as defined in the + * https://eips.ethereum.org/EIPS/eip-165[EIP]. + * + * Implementers can declare support of contract interfaces, which can then be + * queried by others ({ERC165Checker}). + * + * For an implementation, see {ERC165}. + */ +contract IERC165 { + /** + * @dev Returns true if this contract implements the interface defined by + * `interfaceId`. See the corresponding + * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] + * to learn more about how these ids are created. + * + * This function call must use less than 30 000 gas. + */ + function supportsInterface(bytes4 interfaceId) external view returns (bool); +} + + +// Dependency file: contracts/interfaces/IERC1155.sol + + +// pragma solidity ^0.4.24; + +// import "contracts/interfaces/IERC165.sol"; + +/** + * @dev Required interface of an ERC1155 compliant contract, as defined in the + * https://eips.ethereum.org/EIPS/eip-1155[EIP]. + * + * _Available since v3.1._ + */ +contract IERC1155 is IERC165 { + /** + * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. + */ + event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); + + /** + * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all + * transfers. + */ + event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); + + /** + * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to + * `approved`. + */ + event ApprovalForAll(address indexed account, address indexed operator, bool approved); + + /** + * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. + * + * If an {URI} event was emitted for `id`, the standard + * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value + * returned by {IERC1155MetadataURI-uri}. + */ + event URI(string value, uint256 indexed id); + + /** + * @dev Returns the amount of tokens of token type `id` owned by `account`. + * + * Requirements: + * + * - `account` cannot be the zero address. + */ + function balanceOf(address account, uint256 id) external view returns (uint256); + + /** + * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. + * + * Requirements: + * + * - `accounts` and `ids` must have the same length. + */ + function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[] memory); + + /** + * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, + * + * Emits an {ApprovalForAll} event. + * + * Requirements: + * + * - `operator` cannot be the caller. + */ + function setApprovalForAll(address operator, bool approved) external; + + /** + * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. + * + * See {setApprovalForAll}. + */ + function isApprovedForAll(address account, address operator) external view returns (bool); + + /** + * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. + * + * Emits a {TransferSingle} event. + * + * Requirements: + * + * - `to` cannot be the zero address. + * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. + * - `from` must have a balance of tokens of type `id` of at least `amount`. + * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the + * acceptance magic value. + */ + function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external; + + /** + * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. + * + * Emits a {TransferBatch} event. + * + * Requirements: + * + * - `ids` and `amounts` must have the same length. + * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the + * acceptance magic value. + */ + function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external; +} + + +// Root file: contracts/PolkaPetAdaptor.sol + +pragma solidity ^0.4.24; + +// import "contracts/SettingIds.sol"; +// import "contracts/PausableDSAuth.sol"; +// import "contracts/interfaces/ISettingsRegistry.sol"; +// import "contracts/interfaces/INFTAdaptor.sol"; +// // import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +// import "contracts/interfaces/IInterstellarEncoderV3.sol"; +// import "contracts/interfaces/IERC1155.sol"; + + +contract PolkaPetAdaptor is PausableDSAuth, SettingIds { + + event SetTokenIDAuth(uint256 indexed tokenId, bool status); + + /* + * Storage + */ + bool private singletonLock = false; + + uint16 public producerId; + + uint8 public convertType; + + ISettingsRegistry public registry; + + IERC1155 public originNft; + + uint128 public lastObjectId; + + // tokenID => bool allowList + mapping (uint256 => bool) public allowList; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + registry = _registry; + originNft = _originNft; + producerId = _producerId; + + convertType = 128; // f(x) = x,fullfill with zero at left side. + } + + function setTokenIDAuth(uint256 _tokenId, bool _status) public auth { + allowList[_tokenId] = _status; + emit SetTokenIDAuth(_tokenId, _status); + } + + function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256) { + require(allowList[_originTokenId], "POLKPET: PERMISSION"); + lastObjectId += 1; + uint128 mirrorObjectId = uint128(lastObjectId & 0xffffffffffffffffffffffffffffffff); + require(lastObjectId <= uint128(-1), "POLKPET: OBJECTID_OVERFLOW"); + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + uint256 mirrorTokenId = interstellarEncoder.encodeTokenIdForOuterObjectContract( + petBase, objectOwnership, address(originNft), mirrorObjectId, producerId, convertType); + + return mirrorTokenId; + } + + function ownerInOrigin(uint256 _originTokenId) public view returns (address) { + revert("NOT_SUPPORT"); + } + + // if the convertion is not calculatable, and need to use cache mapping in Bridge. + // then .. + function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256) { + revert("NOT_SUPPORT"); + } + + function approveToBridge(address _bridge) public onlyOwner { + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + IERC1155(objectOwnership).setApprovalForAll(_bridge, true); + } + + function cancelApprove(address _bridge) public onlyOwner { + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + IERC1155(objectOwnership).setApprovalForAll(_bridge, false); + } + + function getObjectClass(uint256 _originTokenId) public view returns (uint8) { + revert("NOT_SUPPORT"); + } + + function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public auth { + revert("NOT_SUPPORT"); + } +} From e20fc6ddad807bbcfa0d0b087938a29413ed61eb Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 23 Feb 2021 15:08:37 +0800 Subject: [PATCH 04/64] dev: add 2 & 11 token id to support polkpet --- contracts/PolkaPetAdaptor.sol | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/contracts/PolkaPetAdaptor.sol b/contracts/PolkaPetAdaptor.sol index ec128de..04cce0f 100644 --- a/contracts/PolkaPetAdaptor.sol +++ b/contracts/PolkaPetAdaptor.sol @@ -31,23 +31,14 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { // tokenID => bool allowList mapping (uint256 => bool) public allowList; - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - function initializeContract(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public singletonLockCall { - owner = msg.sender; - emit LogSetOwner(msg.sender); + function constructor(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public { registry = _registry; originNft = _originNft; producerId = _producerId; - convertType = 128; // f(x) = x,fullfill with zero at left side. + + allowList[2] = true; + allowList[11] = true; } function setTokenIDAuth(uint256 _tokenId, bool _status) public auth { From 253a44bea917941ebcef122b483bc855e07d6b18 Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 23 Feb 2021 15:42:28 +0800 Subject: [PATCH 05/64] dev: add 2 & 11 token id to support polkpet --- contracts/ERC721BridgeV2.sol | 16 ---------------- flat/ERC721BridgeV2.sol | 16 ---------------- flat/PolkaPetAdaptor.sol | 17 ++++------------- 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 0d95281..857cbe8 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -42,22 +42,6 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth { event SwapIn(uint256 originTokenId, uint256 mirrorTokenId, address owner); event SwapOut(uint256 originTokenId, uint256 mirrorTokenId, address owner); - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - function initializeContract(ISettingsRegistry _registry) public singletonLockCall { - owner = msg.sender; - emit LogSetOwner(msg.sender); - registry = _registry; - } - function registerAdaptor(address _originNftAddress, address _erc721Adaptor) public whenNotPaused onlyOwner { originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; } diff --git a/flat/ERC721BridgeV2.sol b/flat/ERC721BridgeV2.sol index 0ab7506..04e8e1d 100644 --- a/flat/ERC721BridgeV2.sol +++ b/flat/ERC721BridgeV2.sol @@ -665,22 +665,6 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth { event SwapIn(uint256 originTokenId, uint256 mirrorTokenId, address owner); event SwapOut(uint256 originTokenId, uint256 mirrorTokenId, address owner); - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - function initializeContract(ISettingsRegistry _registry) public singletonLockCall { - owner = msg.sender; - emit LogSetOwner(msg.sender); - registry = _registry; - } - function registerAdaptor(address _originNftAddress, address _erc721Adaptor) public whenNotPaused onlyOwner { originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; } diff --git a/flat/PolkaPetAdaptor.sol b/flat/PolkaPetAdaptor.sol index cb65da7..c05e110 100644 --- a/flat/PolkaPetAdaptor.sol +++ b/flat/PolkaPetAdaptor.sol @@ -637,23 +637,14 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { // tokenID => bool allowList mapping (uint256 => bool) public allowList; - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - function initializeContract(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public singletonLockCall { - owner = msg.sender; - emit LogSetOwner(msg.sender); + function constructor(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public { registry = _registry; originNft = _originNft; producerId = _producerId; - convertType = 128; // f(x) = x,fullfill with zero at left side. + + allowList[2] = true; + allowList[11] = true; } function setTokenIDAuth(uint256 _tokenId, bool _status) public auth { From dc6338e279c23301b79cd56aee3664477e533130 Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 23 Feb 2021 16:39:25 +0800 Subject: [PATCH 06/64] dev: fix typo --- contracts/PolkaPetAdaptor.sol | 2 +- flat/PolkaPetAdaptor.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/PolkaPetAdaptor.sol b/contracts/PolkaPetAdaptor.sol index 04cce0f..5d26968 100644 --- a/contracts/PolkaPetAdaptor.sol +++ b/contracts/PolkaPetAdaptor.sol @@ -31,7 +31,7 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { // tokenID => bool allowList mapping (uint256 => bool) public allowList; - function constructor(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public { + constructor(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public { registry = _registry; originNft = _originNft; producerId = _producerId; diff --git a/flat/PolkaPetAdaptor.sol b/flat/PolkaPetAdaptor.sol index c05e110..5d7198e 100644 --- a/flat/PolkaPetAdaptor.sol +++ b/flat/PolkaPetAdaptor.sol @@ -637,7 +637,7 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { // tokenID => bool allowList mapping (uint256 => bool) public allowList; - function constructor(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public { + constructor(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public { registry = _registry; originNft = _originNft; producerId = _producerId; From de1fb678c659837c850d575c943a61845f9fb07c Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 23 Feb 2021 17:51:35 +0800 Subject: [PATCH 07/64] dev: support batch 1155 transfer --- contracts/ERC721BridgeV2.sol | 66 ++++++++--- contracts/interfaces/IERC1155Receiver.sol | 58 ++++++++++ flat/ERC721BridgeV2.sol | 127 +++++++++++++++++++--- flat/IERC1155Receiver.sol | 60 ++++++++++ 4 files changed, 279 insertions(+), 32 deletions(-) create mode 100644 contracts/interfaces/IERC1155Receiver.sol create mode 100644 flat/IERC1155Receiver.sol diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 857cbe8..9c0be25 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -9,6 +9,7 @@ import "./interfaces/IBurnableERC20.sol"; import "./interfaces/INFTAdaptor.sol"; import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; import "./interfaces/IERC1155.sol"; +import "./interfaces/IERC1155Receiver.sol"; /* @@ -16,7 +17,7 @@ import "./interfaces/IERC1155.sol"; * originTokenId - token outside evolutionLand * mirrorTokenId - mirror token */ -contract ERC721BridgeV2 is SettingIds, PausableDSAuth { +contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { /* * Storage @@ -105,21 +106,6 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth { swapIn(_originNftAddress, _originTokenId); } - // V2 add - Support PolkaPet - function bridgeAndSwapIn1155(address _originNftAddress, uint256 _originTokenId) public { - address adaptor = originNFT2Adaptor[_originNftAddress]; - require(adaptor != address(0), "Not registered!"); - - IERC1155(_originNftAddress).safeTransferFrom(msg.sender, address(this), _originTokenId, 1, ""); - - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); - IMintableERC20(objectOwnership).mint(msg.sender, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, msg.sender); - emit SwapIn(_originTokenId, mirrorTokenId, msg.sender); - } - function swapOut(uint256 _mirrorTokenId) public { IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); @@ -180,4 +166,52 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth { function isBridged(uint256 _mirrorTokenId) public view returns (bool) { return (mirrorId2OriginId[_mirrorTokenId] != 0); } + + + // V2 add - Support PolkaPet + function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from, uint256 _value) private { + address adaptor = originNFT2Adaptor[msg.sender]; + require(adaptor != address(0), "Not registered!"); + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + for (uint256 i = 0; i < _value; i++) { + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); + IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); + emit SwapIn(_originTokenId, mirrorTokenId, _from); + } + } + + function onERC1155Received( + address operator, + address from, + uint256 id, + uint256 value, + bytes data + ) + whenNotPaused() + external + returns(bytes4) + { + _bridgeIn1155(msg.sender, id, from, value); + return ERC1155_RECEIVED_VALUE; + } + + function onERC1155BatchReceived( + address operator, + address from, + uint256[] ids, + uint256[] values, + bytes data + ) + whenNotPaused() + external + returns(bytes4) + { + require(ids.length == values.length, "INVALID_ARRAYS_LENGTH"); + for (uint256 i = 0; i < ids.length; i++) { + _bridgeIn1155(msg.sender, ids[i], from, values[i]); + } + return ERC1155_BATCH_RECEIVED_VALUE; + } } diff --git a/contracts/interfaces/IERC1155Receiver.sol b/contracts/interfaces/IERC1155Receiver.sol new file mode 100644 index 0000000..906acd4 --- /dev/null +++ b/contracts/interfaces/IERC1155Receiver.sol @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.4.24; + +/** + * _Available since v3.1._ + */ +contract IERC1155Receiver { + + bytes4 internal constant ERC1155_RECEIVED_VALUE = 0xf23a6e61; + bytes4 internal constant ERC1155_BATCH_RECEIVED_VALUE = 0xbc197c81; + + /** + @dev Handles the receipt of a single ERC1155 token type. This function is + called at the end of a `safeTransferFrom` after the balance has been updated. + To accept the transfer, this must return + `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` + (i.e. 0xf23a6e61, or its own function selector). + @param operator The address which initiated the transfer (i.e. msg.sender) + @param from The address which previously owned the token + @param id The ID of the token being transferred + @param value The amount of tokens being transferred + @param data Additional data with no specified format + @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed + */ + function onERC1155Received( + address operator, + address from, + uint256 id, + uint256 value, + bytes data + ) + external + returns(bytes4); + + /** + @dev Handles the receipt of a multiple ERC1155 token types. This function + is called at the end of a `safeBatchTransferFrom` after the balances have + been updated. To accept the transfer(s), this must return + `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` + (i.e. 0xbc197c81, or its own function selector). + @param operator The address which initiated the batch transfer (i.e. msg.sender) + @param from The address which previously owned the token + @param ids An array containing ids of each token being transferred (order and length must match values array) + @param values An array containing amounts of each token being transferred (order and length must match ids array) + @param data Additional data with no specified format + @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed + */ + function onERC1155BatchReceived( + address operator, + address from, + uint256[] ids, + uint256[] values, + bytes data + ) + external + returns(bytes4); +} diff --git a/flat/ERC721BridgeV2.sol b/flat/ERC721BridgeV2.sol index 04e8e1d..7ae0714 100644 --- a/flat/ERC721BridgeV2.sol +++ b/flat/ERC721BridgeV2.sol @@ -619,6 +619,67 @@ contract IERC1155 is IERC165 { } +// Dependency file: contracts/interfaces/IERC1155Receiver.sol + + +// pragma solidity ^0.4.24; + +/** + * _Available since v3.1._ + */ +contract IERC1155Receiver { + + bytes4 internal constant ERC1155_RECEIVED_VALUE = 0xf23a6e61; + bytes4 internal constant ERC1155_BATCH_RECEIVED_VALUE = 0xbc197c81; + + /** + @dev Handles the receipt of a single ERC1155 token type. This function is + called at the end of a `safeTransferFrom` after the balance has been updated. + To accept the transfer, this must return + `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` + (i.e. 0xf23a6e61, or its own function selector). + @param operator The address which initiated the transfer (i.e. msg.sender) + @param from The address which previously owned the token + @param id The ID of the token being transferred + @param value The amount of tokens being transferred + @param data Additional data with no specified format + @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed + */ + function onERC1155Received( + address operator, + address from, + uint256 id, + uint256 value, + bytes data + ) + external + returns(bytes4); + + /** + @dev Handles the receipt of a multiple ERC1155 token types. This function + is called at the end of a `safeBatchTransferFrom` after the balances have + been updated. To accept the transfer(s), this must return + `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` + (i.e. 0xbc197c81, or its own function selector). + @param operator The address which initiated the batch transfer (i.e. msg.sender) + @param from The address which previously owned the token + @param ids An array containing ids of each token being transferred (order and length must match values array) + @param values An array containing amounts of each token being transferred (order and length must match ids array) + @param data Additional data with no specified format + @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed + */ + function onERC1155BatchReceived( + address operator, + address from, + uint256[] ids, + uint256[] values, + bytes data + ) + external + returns(bytes4); +} + + // Root file: contracts/ERC721BridgeV2.sol pragma solidity ^0.4.23; @@ -632,6 +693,7 @@ pragma solidity ^0.4.23; // import "contracts/interfaces/INFTAdaptor.sol"; // import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; // import "contracts/interfaces/IERC1155.sol"; +// import "contracts/interfaces/IERC1155Receiver.sol"; /* @@ -639,7 +701,7 @@ pragma solidity ^0.4.23; * originTokenId - token outside evolutionLand * mirrorTokenId - mirror token */ -contract ERC721BridgeV2 is SettingIds, PausableDSAuth { +contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { /* * Storage @@ -728,21 +790,6 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth { swapIn(_originNftAddress, _originTokenId); } - // V2 add - Support PolkaPet - function bridgeAndSwapIn1155(address _originNftAddress, uint256 _originTokenId) public { - address adaptor = originNFT2Adaptor[_originNftAddress]; - require(adaptor != address(0), "Not registered!"); - - IERC1155(_originNftAddress).safeTransferFrom(msg.sender, address(this), _originTokenId, 1, ""); - - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); - IMintableERC20(objectOwnership).mint(msg.sender, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, msg.sender); - emit SwapIn(_originTokenId, mirrorTokenId, msg.sender); - } - function swapOut(uint256 _mirrorTokenId) public { IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); @@ -803,4 +850,52 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth { function isBridged(uint256 _mirrorTokenId) public view returns (bool) { return (mirrorId2OriginId[_mirrorTokenId] != 0); } + + + // V2 add - Support PolkaPet + function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from, uint256 _value) private { + address adaptor = originNFT2Adaptor[msg.sender]; + require(adaptor != address(0), "Not registered!"); + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + for (uint256 i = 0; i < _value; i++) { + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); + IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); + emit SwapIn(_originTokenId, mirrorTokenId, _from); + } + } + + function onERC1155Received( + address operator, + address from, + uint256 id, + uint256 value, + bytes data + ) + whenNotPaused() + external + returns(bytes4) + { + _bridgeIn1155(msg.sender, id, from, value); + return ERC1155_RECEIVED_VALUE; + } + + function onERC1155BatchReceived( + address operator, + address from, + uint256[] ids, + uint256[] values, + bytes data + ) + whenNotPaused() + external + returns(bytes4) + { + require(ids.length == values.length, "INVALID_ARRAYS_LENGTH"); + for (uint256 i = 0; i < ids.length; i++) { + _bridgeIn1155(msg.sender, ids[i], from, values[i]); + } + return ERC1155_BATCH_RECEIVED_VALUE; + } } diff --git a/flat/IERC1155Receiver.sol b/flat/IERC1155Receiver.sol new file mode 100644 index 0000000..a0cba5c --- /dev/null +++ b/flat/IERC1155Receiver.sol @@ -0,0 +1,60 @@ +// Root file: contracts/interfaces/IERC1155Receiver.sol + +// SPDX-License-Identifier: MIT + +pragma solidity ^0.4.24; + +/** + * _Available since v3.1._ + */ +contract IERC1155Receiver { + + bytes4 internal constant ERC1155_RECEIVED_VALUE = 0xf23a6e61; + bytes4 internal constant ERC1155_BATCH_RECEIVED_VALUE = 0xbc197c81; + + /** + @dev Handles the receipt of a single ERC1155 token type. This function is + called at the end of a `safeTransferFrom` after the balance has been updated. + To accept the transfer, this must return + `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` + (i.e. 0xf23a6e61, or its own function selector). + @param operator The address which initiated the transfer (i.e. msg.sender) + @param from The address which previously owned the token + @param id The ID of the token being transferred + @param value The amount of tokens being transferred + @param data Additional data with no specified format + @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed + */ + function onERC1155Received( + address operator, + address from, + uint256 id, + uint256 value, + bytes data + ) + external + returns(bytes4); + + /** + @dev Handles the receipt of a multiple ERC1155 token types. This function + is called at the end of a `safeBatchTransferFrom` after the balances have + been updated. To accept the transfer(s), this must return + `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` + (i.e. 0xbc197c81, or its own function selector). + @param operator The address which initiated the batch transfer (i.e. msg.sender) + @param from The address which previously owned the token + @param ids An array containing ids of each token being transferred (order and length must match values array) + @param values An array containing amounts of each token being transferred (order and length must match ids array) + @param data Additional data with no specified format + @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed + */ + function onERC1155BatchReceived( + address operator, + address from, + uint256[] ids, + uint256[] values, + bytes data + ) + external + returns(bytes4); +} From f25e940ae0ab6c4da2bba5ee13a4433ad33159c5 Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 23 Feb 2021 21:00:47 +0800 Subject: [PATCH 08/64] dev: swapout1155 --- contracts/ERC721BridgeV2.sol | 26 ++++++++++++++++++-------- flat/ERC721BridgeV2.sol | 26 ++++++++++++++++++-------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 9c0be25..7f6efc2 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -117,16 +117,26 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { // TODO: if it is needed to check its current status uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); + ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); - // V2 add - Support PolkaPet - if (IERC1155(nftContract).supportsInterface(bytes4(keccak256("safeTransferFrom(address,address,uint256,uint256,bytes)")))) { - IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); - IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); - } else { - ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); - ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); - } + emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); + } + // V2 add - Support PolkaPet + function swapOut1155(uint256 _mirrorTokenId) public { + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + address nftContract = interstellarEncoder.getOriginAddress(_mirrorTokenId); + require(nftContract != address(0), "No such NFT contract"); + address adaptor = originNFT2Adaptor[nftContract]; + require(adaptor != address(0), "not registered!"); + require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); + + // TODO: if it is needed to check its current status + uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); + IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); } diff --git a/flat/ERC721BridgeV2.sol b/flat/ERC721BridgeV2.sol index 7ae0714..a2034a6 100644 --- a/flat/ERC721BridgeV2.sol +++ b/flat/ERC721BridgeV2.sol @@ -801,16 +801,26 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { // TODO: if it is needed to check its current status uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); + ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); - // V2 add - Support PolkaPet - if (IERC1155(nftContract).supportsInterface(bytes4(keccak256("safeTransferFrom(address,address,uint256,uint256,bytes)")))) { - IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); - IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); - } else { - ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); - ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); - } + emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); + } + // V2 add - Support PolkaPet + function swapOut1155(uint256 _mirrorTokenId) public { + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + address nftContract = interstellarEncoder.getOriginAddress(_mirrorTokenId); + require(nftContract != address(0), "No such NFT contract"); + address adaptor = originNFT2Adaptor[nftContract]; + require(adaptor != address(0), "not registered!"); + require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); + + // TODO: if it is needed to check its current status + uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); + IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); } From 41adc34ef30c8a3cc5f0a77b44db1b17af75104b Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 22 Apr 2021 20:10:48 +0800 Subject: [PATCH 09/64] dapp compatible --- .env | 6 ++++++ .gitignore | 1 + Makefile | 1 + 3 files changed, 8 insertions(+) create mode 100644 .env create mode 100644 Makefile diff --git a/.env b/.env new file mode 100644 index 0000000..66f4d27 --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +export DAPP_SRC=contracts +export DAPP_LIB=lib +export DAPP_REMAPPINGS="openzeppelin-solidity/=lib/zeppelin-solidity/ +@evolutionland/upgraeability-using-unstructured-storage/=lib/upgradeability-using-unstructured-storage/" +export DAPP_BUILD_OPTIMIZE=1 +unset SOLC_FLAGS DAPP_BUILD_LEGACY DAPP_BUILD_EXTRACT diff --git a/.gitignore b/.gitignore index cb0164f..9e5592a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ truffle.config.js scripts waffle.json cache +/out diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8b2a92c --- /dev/null +++ b/Makefile @@ -0,0 +1 @@ +all :; source .env && dapp --use solc:0.4.24 build From 0148f903d200081a83a03e211c2cf57a26c12294 Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 22 Apr 2021 20:11:08 +0800 Subject: [PATCH 10/64] dapp install evolutionlandorg/upgradeability-using-unstructured-storage --- .gitmodules | 3 +++ lib/upgradeability-using-unstructured-storage | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 lib/upgradeability-using-unstructured-storage diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7846f0c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/upgradeability-using-unstructured-storage"] + path = lib/upgradeability-using-unstructured-storage + url = https://github.com/evolutionlandorg/upgradeability-using-unstructured-storage diff --git a/lib/upgradeability-using-unstructured-storage b/lib/upgradeability-using-unstructured-storage new file mode 160000 index 0000000..5d89ae1 --- /dev/null +++ b/lib/upgradeability-using-unstructured-storage @@ -0,0 +1 @@ +Subproject commit 5d89ae1a00943cbe06d2fb97ad8ade0f9a7f8f08 From 58fe38b105a82935d31b1fe61412f5c5a6fe620d Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 22 Apr 2021 20:11:55 +0800 Subject: [PATCH 11/64] dapp install OpenZeppelin/zeppelin-solidity --- .gitmodules | 3 +++ lib/zeppelin-solidity | 1 + 2 files changed, 4 insertions(+) create mode 160000 lib/zeppelin-solidity diff --git a/.gitmodules b/.gitmodules index 7846f0c..f7dc7ed 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "lib/upgradeability-using-unstructured-storage"] path = lib/upgradeability-using-unstructured-storage url = https://github.com/evolutionlandorg/upgradeability-using-unstructured-storage +[submodule "lib/zeppelin-solidity"] + path = lib/zeppelin-solidity + url = https://github.com/OpenZeppelin/zeppelin-solidity diff --git a/lib/zeppelin-solidity b/lib/zeppelin-solidity new file mode 160000 index 0000000..165e6f1 --- /dev/null +++ b/lib/zeppelin-solidity @@ -0,0 +1 @@ +Subproject commit 165e6f19489786c9c6abfcc9bdc8f2815d807935 From ff9f4bf849b05b0f112c8c24ffdf70b7770e228c Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 22 Apr 2021 20:13:16 +0800 Subject: [PATCH 12/64] zepplin v1.12.0 --- lib/zeppelin-solidity | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zeppelin-solidity b/lib/zeppelin-solidity index 165e6f1..0e65947 160000 --- a/lib/zeppelin-solidity +++ b/lib/zeppelin-solidity @@ -1 +1 @@ -Subproject commit 165e6f19489786c9c6abfcc9bdc8f2815d807935 +Subproject commit 0e65947efbffc592cffea8c2ae9d3b8e11659854 From 474dd87109e2c31aefce5287ce4cb181ee37ed37 Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 22 Apr 2021 20:14:37 +0800 Subject: [PATCH 13/64] rm flat --- flat/ApproveAndCallFallBack.sol | 7 - flat/DSAuth.sol | 71 - flat/DeployAndTest.sol | 905 ------------ flat/ERC20Container.sol | 429 ------ flat/ERC223.sol | 11 - flat/ERC223ReceivingContract.sol | 19 - flat/ERC721Adaptor.sol | 566 -------- flat/ERC721AdaptorAuthority.sol | 20 - flat/ERC721Bridge.sol | 656 --------- flat/ERC721BridgeV2.sol | 911 ------------ flat/ERC721Container.sol | 522 ------- flat/IActivity.sol | 39 - flat/IActivityObject.sol | 42 - flat/IAuthority.sol | 9 - flat/IBurnableERC20.sol | 7 - flat/IContainer.sol | 8 - flat/IERC1155.sol | 132 -- flat/IERC1155Receiver.sol | 60 - flat/IERC165.sol | 26 - flat/IInterstellarEncoder.sol | 35 - flat/IInterstellarEncoderV3.sol | 41 - flat/IMinerObject.sol | 41 - flat/IMintableERC20.sol | 8 - flat/INFTAdaptor.sol | 18 - flat/IObjectOwnership.sol | 9 - flat/ISettingsRegistry.sol | 35 - flat/ISmartToken.sol | 15 - flat/ITokenLocation.sol | 16 - flat/ITokenUse.sol | 23 - flat/ITokenVendor.sol | 32 - flat/IUserPoints.sol | 16 - flat/InterstellarEncoder.sol | 157 -- flat/InterstellarEncoderV2.sol | 170 --- flat/InterstellarEncoderV3.sol | 202 --- flat/Issuing.sol | 326 ----- flat/KtonVoter.sol | 143 -- flat/LocationCoder.sol | 82 -- flat/Migrations.sol | 213 --- flat/MintAndBurnAuthority.sol | 21 - flat/MintAndBurnAuthorityV2.sol | 21 - flat/MintAndBurnMutableAuthority.sol | 104 -- flat/MultiSigWallet.sol | 368 ----- flat/ObjectOwnership.sol | 1269 ---------------- flat/ObjectOwnershipAuthority.sol | 21 - flat/ObjectOwnershipAuthorityV2.sol | 23 - flat/ObjectOwnershipAuthorityV3.sol | 36 - flat/ObjectOwnershipV2.sol | 1998 -------------------------- flat/PausableDSAuth.sol | 123 -- flat/PolkaPetAdaptor.sol | 696 --------- flat/Proposal.sol | 32 - flat/ProposalRegistry.sol | 215 --- flat/RBACWithAdmin.sol | 238 --- flat/RBACWithAuth.sol | 317 ---- flat/SettingIds.sol | 88 -- flat/SettingsRegistry.sol | 224 --- flat/StandardERC20Base.sol | 153 -- flat/StandardERC223.sol | 521 ------- flat/StringUtil.sol | 706 --------- flat/TokenBuildInGenesis.sol | 359 ----- flat/TokenBurnDrop.sol | 331 ----- flat/TokenController.sol | 28 - flat/TokenLocation.sol | 226 --- flat/TokenLocationAuthority.sol | 20 - flat/TokenUse.sol | 913 ------------ flat/TokenUseAuthority.sol | 21 - flat/TokenVestingFactory.sol | 400 ------ flat/UserPoints.sol | 265 ---- flat/UserPointsAuthority.sol | 20 - 68 files changed, 15779 deletions(-) delete mode 100644 flat/ApproveAndCallFallBack.sol delete mode 100644 flat/DSAuth.sol delete mode 100644 flat/DeployAndTest.sol delete mode 100644 flat/ERC20Container.sol delete mode 100644 flat/ERC223.sol delete mode 100644 flat/ERC223ReceivingContract.sol delete mode 100644 flat/ERC721Adaptor.sol delete mode 100644 flat/ERC721AdaptorAuthority.sol delete mode 100644 flat/ERC721Bridge.sol delete mode 100644 flat/ERC721BridgeV2.sol delete mode 100644 flat/ERC721Container.sol delete mode 100644 flat/IActivity.sol delete mode 100644 flat/IActivityObject.sol delete mode 100644 flat/IAuthority.sol delete mode 100644 flat/IBurnableERC20.sol delete mode 100644 flat/IContainer.sol delete mode 100644 flat/IERC1155.sol delete mode 100644 flat/IERC1155Receiver.sol delete mode 100644 flat/IERC165.sol delete mode 100644 flat/IInterstellarEncoder.sol delete mode 100644 flat/IInterstellarEncoderV3.sol delete mode 100644 flat/IMinerObject.sol delete mode 100644 flat/IMintableERC20.sol delete mode 100644 flat/INFTAdaptor.sol delete mode 100644 flat/IObjectOwnership.sol delete mode 100644 flat/ISettingsRegistry.sol delete mode 100644 flat/ISmartToken.sol delete mode 100644 flat/ITokenLocation.sol delete mode 100644 flat/ITokenUse.sol delete mode 100644 flat/ITokenVendor.sol delete mode 100644 flat/IUserPoints.sol delete mode 100644 flat/InterstellarEncoder.sol delete mode 100644 flat/InterstellarEncoderV2.sol delete mode 100644 flat/InterstellarEncoderV3.sol delete mode 100644 flat/Issuing.sol delete mode 100644 flat/KtonVoter.sol delete mode 100644 flat/LocationCoder.sol delete mode 100644 flat/Migrations.sol delete mode 100644 flat/MintAndBurnAuthority.sol delete mode 100644 flat/MintAndBurnAuthorityV2.sol delete mode 100644 flat/MintAndBurnMutableAuthority.sol delete mode 100644 flat/MultiSigWallet.sol delete mode 100644 flat/ObjectOwnership.sol delete mode 100644 flat/ObjectOwnershipAuthority.sol delete mode 100644 flat/ObjectOwnershipAuthorityV2.sol delete mode 100644 flat/ObjectOwnershipAuthorityV3.sol delete mode 100644 flat/ObjectOwnershipV2.sol delete mode 100644 flat/PausableDSAuth.sol delete mode 100644 flat/PolkaPetAdaptor.sol delete mode 100644 flat/Proposal.sol delete mode 100644 flat/ProposalRegistry.sol delete mode 100644 flat/RBACWithAdmin.sol delete mode 100644 flat/RBACWithAuth.sol delete mode 100644 flat/SettingIds.sol delete mode 100644 flat/SettingsRegistry.sol delete mode 100644 flat/StandardERC20Base.sol delete mode 100644 flat/StandardERC223.sol delete mode 100644 flat/StringUtil.sol delete mode 100644 flat/TokenBuildInGenesis.sol delete mode 100644 flat/TokenBurnDrop.sol delete mode 100644 flat/TokenController.sol delete mode 100644 flat/TokenLocation.sol delete mode 100644 flat/TokenLocationAuthority.sol delete mode 100644 flat/TokenUse.sol delete mode 100644 flat/TokenUseAuthority.sol delete mode 100644 flat/TokenVestingFactory.sol delete mode 100644 flat/UserPoints.sol delete mode 100644 flat/UserPointsAuthority.sol diff --git a/flat/ApproveAndCallFallBack.sol b/flat/ApproveAndCallFallBack.sol deleted file mode 100644 index 14af094..0000000 --- a/flat/ApproveAndCallFallBack.sol +++ /dev/null @@ -1,7 +0,0 @@ -// Root file: contracts/interfaces/ApproveAndCallFallBack.sol - -pragma solidity ^0.4.23; - -contract ApproveAndCallFallBack { - function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public; -} \ No newline at end of file diff --git a/flat/DSAuth.sol b/flat/DSAuth.sol deleted file mode 100644 index fe663b9..0000000 --- a/flat/DSAuth.sol +++ /dev/null @@ -1,71 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Root file: contracts/DSAuth.sol - -pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} diff --git a/flat/DeployAndTest.sol b/flat/DeployAndTest.sol deleted file mode 100644 index 472c18d..0000000 --- a/flat/DeployAndTest.sol +++ /dev/null @@ -1,905 +0,0 @@ -// Dependency file: contracts/interfaces/ERC223ReceivingContract.sol - -// pragma solidity ^0.4.23; - - /* - * Contract that is working with ERC223 tokens - * https://github.com/ethereum/EIPs/issues/223 - */ - -/// @title ERC223ReceivingContract - Standard contract implementation for compatibility with ERC223 tokens. -contract ERC223ReceivingContract { - - /// @dev Function that is called when a user or another contract wants to transfer funds. - /// @param _from Transaction initiator, analogue of msg.sender - /// @param _value Number of tokens to transfer. - /// @param _data Data containig a function signature and/or parameters - function tokenFallback(address _from, uint256 _value, bytes _data) public; - -} - - -// Dependency file: contracts/interfaces/TokenController.sol - -// pragma solidity ^0.4.23; - - -/// @dev The token controller contract must implement these functions -contract TokenController { - /// @notice Called when `_owner` sends ether to the MiniMe Token contract - /// @param _owner The address that sent the ether to create tokens - /// @return True if the ether is accepted, false if it throws - function proxyPayment(address _owner, bytes4 sig, bytes data) payable public returns (bool); - - /// @notice Notifies the controller about a token transfer allowing the - /// controller to react if desired - /// @param _from The origin of the transfer - /// @param _to The destination of the transfer - /// @param _amount The amount of the transfer - /// @return False if the controller does not authorize the transfer - function onTransfer(address _from, address _to, uint _amount) public returns (bool); - - /// @notice Notifies the controller about an approval allowing the - /// controller to react if desired - /// @param _owner The address that calls `approve()` - /// @param _spender The spender in the `approve()` call - /// @param _amount The amount in the `approve()` call - /// @return False if the controller does not authorize the approval - function onApprove(address _owner, address _spender, uint _amount) public returns (bool); -} - - -// Dependency file: contracts/interfaces/ApproveAndCallFallBack.sol - -// pragma solidity ^0.4.23; - -contract ApproveAndCallFallBack { - function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public; -} - -// Dependency file: contracts/interfaces/ERC223.sol - -// pragma solidity ^0.4.23; - -contract ERC223 { - function transfer(address to, uint amount, bytes data) public returns (bool ok); - - function transferFrom(address from, address to, uint256 amount, bytes data) public returns (bool ok); - - event ERC223Transfer(address indexed from, address indexed to, uint amount, bytes data); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol - -// pragma solidity ^0.4.24; - - -/** - * @title SafeMath - * @dev Math operations with safety checks that throw on error - */ -library SafeMath { - - /** - * @dev Multiplies two numbers, throws on overflow. - */ - function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - // Gas optimization: this is cheaper than asserting 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - c = _a * _b; - assert(c / _a == _b); - return c; - } - - /** - * @dev Integer division of two numbers, truncating the quotient. - */ - function div(uint256 _a, uint256 _b) internal pure returns (uint256) { - // assert(_b > 0); // Solidity automatically throws when dividing by 0 - // uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - return _a / _b; - } - - /** - * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - assert(_b <= _a); - return _a - _b; - } - - /** - * @dev Adds two numbers, throws on overflow. - */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - c = _a + _b; - assert(c >= _a); - return c; - } -} - - -// Dependency file: contracts/StandardERC20Base.sol - -// pragma solidity ^0.4.23; - -// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol'; -// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; - -contract StandardERC20Base is ERC20 { - using SafeMath for uint256; - - uint256 _supply; - mapping (address => uint256) _balances; - mapping (address => mapping (address => uint256)) _approvals; - - function totalSupply() public view returns (uint) { - return _supply; - } - function balanceOf(address src) public view returns (uint) { - return _balances[src]; - } - function allowance(address src, address guy) public view returns (uint) { - return _approvals[src][guy]; - } - - function transfer(address dst, uint wad) public returns (bool) { - return transferFrom(msg.sender, dst, wad); - } - - function transferFrom(address src, address dst, uint wad) - public - returns (bool) - { - if (src != msg.sender) { - _approvals[src][msg.sender] = _approvals[src][msg.sender].sub(wad); - } - - _balances[src] = _balances[src].sub(wad); - _balances[dst] = _balances[dst].add(wad); - - emit Transfer(src, dst, wad); - - return true; - } - - function approve(address guy, uint wad) public returns (bool) { - _approvals[msg.sender][guy] = wad; - - emit Approval(msg.sender, guy, wad); - - return true; - } -} - - -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: contracts/StandardERC223.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/ERC223ReceivingContract.sol'; -// import 'contracts/interfaces/TokenController.sol'; -// import 'contracts/interfaces/ApproveAndCallFallBack.sol'; -// import 'contracts/interfaces/ERC223.sol'; -// import 'contracts/StandardERC20Base.sol'; -// import 'contracts/DSAuth.sol'; - -// This is a contract for demo and test. -contract StandardERC223 is StandardERC20Base, DSAuth, ERC223 { - event Burn(address indexed burner, uint256 value); - event Mint(address indexed to, uint256 amount); - - bytes32 public symbol; - uint256 public decimals = 18; // standard token precision. override to customize - // Optional token name - bytes32 public name = ""; - - address public controller; - - constructor(bytes32 _symbol) public { - symbol = _symbol; - controller = msg.sender; - } - - function setName(bytes32 name_) public auth { - name = name_; - } - -////////// -// Controller Methods -////////// - /// @notice Changes the controller of the contract - /// @param _newController The new controller of the contract - function changeController(address _newController) public auth { - controller = _newController; - } - - /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it - /// is approved by `_from` - /// @param _from The address holding the tokens being transferred - /// @param _to The address of the recipient - /// @param _amount The amount of tokens to be transferred - /// @return True if the transfer was successful - function transferFrom(address _from, address _to, uint256 _amount - ) public returns (bool success) { - // Alerts the token controller of the transfer - if (isContract(controller)) { - if (!TokenController(controller).onTransfer(_from, _to, _amount)) - revert(); - } - - success = super.transferFrom(_from, _to, _amount); - } - - /* - * ERC 223 - * Added support for the ERC 223 "tokenFallback" method in a "transfer" function with a payload. - */ - function transferFrom(address _from, address _to, uint256 _amount, bytes _data) - public - returns (bool success) - { - // Alerts the token controller of the transfer - if (isContract(controller)) { - if (!TokenController(controller).onTransfer(_from, _to, _amount)) - revert(); - } - - require(super.transferFrom(_from, _to, _amount)); - - if (isContract(_to)) { - ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); - receiver.tokenFallback(_from, _amount, _data); - } - - emit ERC223Transfer(_from, _to, _amount, _data); - - return true; - } - - function issue(address _to, uint256 _amount) public auth { - mint(_to, _amount); - } - - function destroy(address _from, uint256 _amount) public auth { - burn(_from, _amount); - } - - function mint(address _to, uint _amount) public auth { - _supply = _supply.add(_amount); - _balances[_to] = _balances[_to].add(_amount); - emit Mint(_to, _amount); - emit Transfer(address(0), _to, _amount); - } - - function burn(address _who, uint _value) public auth { - require(_value <= _balances[_who]); - // no need to require value <= totalSupply, since that would imply the - // sender's balance is greater than the totalSupply, which *should* be an assertion failure - - _balances[_who] = _balances[_who].sub(_value); - _supply = _supply.sub(_value); - emit Burn(_who, _value); - emit Transfer(_who, address(0), _value); - } - - /* - * ERC 223 - * Added support for the ERC 223 "tokenFallback" method in a "transfer" function with a payload. - * https://github.com/ethereum/EIPs/issues/223 - * function transfer(address _to, uint256 _value, bytes _data) public returns (bool success); - */ - /// @notice Send `_value` tokens to `_to` from `msg.sender` and trigger - /// tokenFallback if sender is a contract. - /// @dev Function that is called when a user or another contract wants to transfer funds. - /// @param _to Address of token receiver. - /// @param _amount Number of tokens to transfer. - /// @param _data Data to be sent to tokenFallback - /// @return Returns success of function call. - function transfer( - address _to, - uint256 _amount, - bytes _data) - public - returns (bool success) - { - return transferFrom(msg.sender, _to, _amount, _data); - } - - /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on - /// its behalf. This is a modified version of the ERC20 approve function - /// to be a little bit safer - /// @param _spender The address of the account able to transfer the tokens - /// @param _amount The amount of tokens to be approved for transfer - /// @return True if the approval was successful - function approve(address _spender, uint256 _amount) public returns (bool success) { - // Alerts the token controller of the approve function call - if (isContract(controller)) { - if (!TokenController(controller).onApprove(msg.sender, _spender, _amount)) - revert(); - } - - return super.approve(_spender, _amount); - } - - /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on - /// its behalf, and then a function is triggered in the contract that is - /// being approved, `_spender`. This allows users to use their tokens to - /// interact with contracts in one function call instead of two - /// @param _spender The address of the contract able to transfer the tokens - /// @param _amount The amount of tokens to be approved for transfer - /// @return True if the function call was successful - function approveAndCall(address _spender, uint256 _amount, bytes _extraData - ) public returns (bool success) { - if (!approve(_spender, _amount)) revert(); - - ApproveAndCallFallBack(_spender).receiveApproval( - msg.sender, - _amount, - this, - _extraData - ); - - return true; - } - - /// @dev Internal function to determine if an address is a contract - /// @param _addr The address being queried - /// @return True if `_addr` is a contract - function isContract(address _addr) constant internal returns(bool) { - uint size; - if (_addr == 0) return false; - assembly { - size := extcodesize(_addr) - } - return size>0; - } - - /// @notice The fallback function: If the contract's controller has not been - /// set to 0, then the `proxyPayment` method is called which relays the - /// ether and creates tokens as described in the token controller contract - function () public payable { - if (isContract(controller)) { - if (! TokenController(controller).proxyPayment.value(msg.value)(msg.sender, msg.sig, msg.data)) - revert(); - } else { - revert(); - } - } - -////////// -// Safety Methods -////////// - - /// @notice This method can be used by the owner to extract mistakenly - /// sent tokens to this contract. - /// @param _token The address of the token contract that you want to recover - /// set to 0 in case you want to extract ether. - function claimTokens(address _token) public auth { - if (_token == 0x0) { - address(msg.sender).transfer(address(this).balance); - return; - } - - ERC20 token = ERC20(_token); - uint balance = token.balanceOf(this); - token.transfer(address(msg.sender), balance); - - emit ClaimedTokens(_token, address(msg.sender), balance); - } - -//////////////// -// Events -//////////////// - - event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/SettingsRegistry.sol - -// pragma solidity ^0.4.24; - -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/DSAuth.sol"; - -/** - * @title SettingsRegistry - * @dev This contract holds all the settings for updating and querying. - */ -contract SettingsRegistry is ISettingsRegistry, DSAuth { - - mapping(bytes32 => uint256) public uintProperties; - mapping(bytes32 => string) public stringProperties; - mapping(bytes32 => address) public addressProperties; - mapping(bytes32 => bytes) public bytesProperties; - mapping(bytes32 => bool) public boolProperties; - mapping(bytes32 => int256) public intProperties; - - mapping(bytes32 => SettingsValueTypes) public valueTypes; - - function uintOf(bytes32 _propertyName) public view returns (uint256) { - require(valueTypes[_propertyName] == SettingsValueTypes.UINT, "Property type does not match."); - return uintProperties[_propertyName]; - } - - function stringOf(bytes32 _propertyName) public view returns (string) { - require(valueTypes[_propertyName] == SettingsValueTypes.STRING, "Property type does not match."); - return stringProperties[_propertyName]; - } - - function addressOf(bytes32 _propertyName) public view returns (address) { - require(valueTypes[_propertyName] == SettingsValueTypes.ADDRESS, "Property type does not match."); - return addressProperties[_propertyName]; - } - - function bytesOf(bytes32 _propertyName) public view returns (bytes) { - require(valueTypes[_propertyName] == SettingsValueTypes.BYTES, "Property type does not match."); - return bytesProperties[_propertyName]; - } - - function boolOf(bytes32 _propertyName) public view returns (bool) { - require(valueTypes[_propertyName] == SettingsValueTypes.BOOL, "Property type does not match."); - return boolProperties[_propertyName]; - } - - function intOf(bytes32 _propertyName) public view returns (int) { - require(valueTypes[_propertyName] == SettingsValueTypes.INT, "Property type does not match."); - return intProperties[_propertyName]; - } - - function setUintProperty(bytes32 _propertyName, uint _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.UINT, "Property type does not match."); - uintProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.UINT; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.UINT)); - } - - function setStringProperty(bytes32 _propertyName, string _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.STRING, "Property type does not match."); - stringProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.STRING; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.STRING)); - } - - function setAddressProperty(bytes32 _propertyName, address _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.ADDRESS, "Property type does not match."); - - addressProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.ADDRESS; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.ADDRESS)); - } - - function setBytesProperty(bytes32 _propertyName, bytes _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.BYTES, "Property type does not match."); - - bytesProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.BYTES; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.BYTES)); - } - - function setBoolProperty(bytes32 _propertyName, bool _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.BOOL, "Property type does not match."); - - boolProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.BOOL; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.BOOL)); - } - - function setIntProperty(bytes32 _propertyName, int _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.INT, "Property type does not match."); - - intProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.INT; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.INT)); - } - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint256 /* SettingsValueTypes */ ) { - return uint256(valueTypes[_propertyName]); - } - -} - -// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/Proxy.sol - -// pragma solidity ^0.4.21; - -/** - * @title Proxy - * @dev Gives the possibility to delegate any call to a foreign implementation. - */ -contract Proxy { - /** - * @dev Tells the address of the implementation where every call will be delegated. - * @return address of the implementation to which it will be delegated - */ - function implementation() public view returns (address); - - /** - * @dev Fallback function allowing to perform a delegatecall to the given implementation. - * This function will return whatever the implementation call returns - */ - function () payable public { - address _impl = implementation(); - require(_impl != address(0)); - - assembly { - let ptr := mload(0x40) - calldatacopy(ptr, 0, calldatasize) - let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0) - let size := returndatasize - returndatacopy(ptr, 0, size) - - switch result - case 0 { revert(ptr, size) } - default { return(ptr, size) } - } - } -} - - -// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/UpgradeabilityProxy.sol - -// pragma solidity ^0.4.21; - -// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/@evolutionland/upgraeability-using-unstructured-storage/contracts/Proxy.sol'; - -/** - * @title UpgradeabilityProxy - * @dev This contract represents a proxy where the implementation address to which it will delegate can be upgraded - */ -contract UpgradeabilityProxy is Proxy { - /** - * @dev This event will be emitted every time the implementation gets upgraded - * @param implementation representing the address of the upgraded implementation - */ - event Upgraded(address indexed implementation); - - // Storage position of the address of the current implementation - bytes32 private constant implementationPosition = keccak256("org.zeppelinos.proxy.implementation"); - - /** - * @dev Constructor function - */ - function UpgradeabilityProxy() public {} - - /** - * @dev Tells the address of the current implementation - * @return address of the current implementation - */ - function implementation() public view returns (address impl) { - bytes32 position = implementationPosition; - assembly { - impl := sload(position) - } - } - - /** - * @dev Sets the address of the current implementation - * @param newImplementation address representing the new implementation to be set - */ - function setImplementation(address newImplementation) internal { - bytes32 position = implementationPosition; - assembly { - sstore(position, newImplementation) - } - } - - /** - * @dev Upgrades the implementation address - * @param newImplementation representing the address of the new implementation to be set - */ - function _upgradeTo(address newImplementation) internal { - address currentImplementation = implementation(); - require(currentImplementation != newImplementation); - setImplementation(newImplementation); - emit Upgraded(newImplementation); - } -} - - -// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol - -// pragma solidity ^0.4.21; - -// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/@evolutionland/upgraeability-using-unstructured-storage/contracts/UpgradeabilityProxy.sol'; - -/** - * @title OwnedUpgradeabilityProxy - * @dev This contract combines an upgradeability proxy with basic authorization control functionalities - */ -contract OwnedUpgradeabilityProxy is UpgradeabilityProxy { - /** - * @dev Event to show ownership has been transferred - * @param previousOwner representing the address of the previous owner - * @param newOwner representing the address of the new owner - */ - event ProxyOwnershipTransferred(address previousOwner, address newOwner); - - // Storage position of the owner of the contract - bytes32 private constant proxyOwnerPosition = keccak256("org.zeppelinos.proxy.owner"); - - /** - * @dev the constructor sets the original owner of the contract to the sender account. - */ - function OwnedUpgradeabilityProxy() public { - setUpgradeabilityOwner(msg.sender); - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyProxyOwner() { - require(msg.sender == proxyOwner()); - _; - } - - /** - * @dev Tells the address of the owner - * @return the address of the owner - */ - function proxyOwner() public view returns (address owner) { - bytes32 position = proxyOwnerPosition; - assembly { - owner := sload(position) - } - } - - /** - * @dev Sets the address of the owner - */ - function setUpgradeabilityOwner(address newProxyOwner) internal { - bytes32 position = proxyOwnerPosition; - assembly { - sstore(position, newProxyOwner) - } - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param newOwner The address to transfer ownership to. - */ - function transferProxyOwnership(address newOwner) public onlyProxyOwner { - require(newOwner != address(0)); - emit ProxyOwnershipTransferred(proxyOwner(), newOwner); - setUpgradeabilityOwner(newOwner); - } - - /** - * @dev Allows the proxy owner to upgrade the current version of the proxy. - * @param implementation representing the address of the new implementation to be set. - */ - function upgradeTo(address implementation) public onlyProxyOwner { - _upgradeTo(implementation); - } - - /** - * @dev Allows the proxy owner to upgrade the current version of the proxy and call the new implementation - * to initialize whatever is needed through a low level call. - * @param implementation representing the address of the new implementation to be set. - * @param data represents the msg.data to bet sent in the low level call. This parameter may include the function - * signature of the implementation to be called with the needed payload - */ - function upgradeToAndCall(address implementation, bytes data) payable public onlyProxyOwner { - upgradeTo(implementation); - require(this.call.value(msg.value)(data)); - } -} - - -// Dependency file: contracts/MintAndBurnAuthority.sol - -// pragma solidity ^0.4.24; - -contract MintAndBurnAuthority { - - mapping (address => bool) public whiteList; - - constructor(address[] _whitelists) public { - for (uint i = 0; i < _whitelists.length; i ++) { - whiteList[_whitelists[i]] = true; - } - } - - function canCall( - address _src, address _dst, bytes4 _sig - ) public view returns (bool) { - return ( whiteList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || - ( whiteList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); - } -} - - -// Root file: contracts/DeployAndTest.sol - -pragma solidity ^0.4.23; - -// import "contracts/StandardERC223.sol"; -// import "contracts/SettingsRegistry.sol"; -// import "@evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol"; -// import "contracts/MintAndBurnAuthority.sol"; - -contract DeployAndTest { - address public testRING = new StandardERC223("RING"); - address public testKTON = new StandardERC223("KTON"); - - constructor() public { - StandardERC223(testRING).changeController(msg.sender); - StandardERC223(testKTON).changeController(msg.sender); - StandardERC223(testRING).setOwner(msg.sender); - StandardERC223(testKTON).setOwner(msg.sender); - } - -} diff --git a/flat/ERC20Container.sol b/flat/ERC20Container.sol deleted file mode 100644 index e1d3e45..0000000 --- a/flat/ERC20Container.sol +++ /dev/null @@ -1,429 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol - -// pragma solidity ^0.4.24; - - -/** - * @title Ownable - * @dev The Ownable contract has an owner address, and provides basic authorization control - * functions, this simplifies the implementation of "user permissions". - */ -contract Ownable { - address public owner; - - - event OwnershipRenounced(address indexed previousOwner); - event OwnershipTransferred( - address indexed previousOwner, - address indexed newOwner - ); - - - /** - * @dev The Ownable constructor sets the original `owner` of the contract to the sender - * account. - */ - constructor() public { - owner = msg.sender; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - /** - * @dev Allows the current owner to relinquish control of the contract. - * @notice Renouncing to ownership will leave the contract without an owner. - * It will not be possible to call the functions with the `onlyOwner` - * modifier anymore. - */ - function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner); - owner = address(0); - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function transferOwnership(address _newOwner) public onlyOwner { - _transferOwnership(_newOwner); - } - - /** - * @dev Transfers control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function _transferOwnership(address _newOwner) internal { - require(_newOwner != address(0)); - emit OwnershipTransferred(owner, _newOwner); - owner = _newOwner; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - - -/** - * @title ERC721 Non-Fungible Token Standard basic interface - * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Basic is ERC165 { - - bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; - /* - * 0x80ac58cd === - * bytes4(keccak256('balanceOf(address)')) ^ - * bytes4(keccak256('ownerOf(uint256)')) ^ - * bytes4(keccak256('approve(address,uint256)')) ^ - * bytes4(keccak256('getApproved(uint256)')) ^ - * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ - * bytes4(keccak256('isApprovedForAll(address,address)')) ^ - * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) - */ - - bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; - /* - * 0x4f558e79 === - * bytes4(keccak256('exists(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; - /** - * 0x780e9d63 === - * bytes4(keccak256('totalSupply()')) ^ - * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ - * bytes4(keccak256('tokenByIndex(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; - /** - * 0x5b5e139f === - * bytes4(keccak256('name()')) ^ - * bytes4(keccak256('symbol()')) ^ - * bytes4(keccak256('tokenURI(uint256)')) - */ - - event Transfer( - address indexed _from, - address indexed _to, - uint256 indexed _tokenId - ); - event Approval( - address indexed _owner, - address indexed _approved, - uint256 indexed _tokenId - ); - event ApprovalForAll( - address indexed _owner, - address indexed _operator, - bool _approved - ); - - function balanceOf(address _owner) public view returns (uint256 _balance); - function ownerOf(uint256 _tokenId) public view returns (address _owner); - function exists(uint256 _tokenId) public view returns (bool _exists); - - function approve(address _to, uint256 _tokenId) public; - function getApproved(uint256 _tokenId) - public view returns (address _operator); - - function setApprovalForAll(address _operator, bool _approved) public; - function isApprovedForAll(address _owner, address _operator) - public view returns (bool); - - function transferFrom(address _from, address _to, uint256 _tokenId) public; - function safeTransferFrom(address _from, address _to, uint256 _tokenId) - public; - - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - public; -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Enumerable is ERC721Basic { - function totalSupply() public view returns (uint256); - function tokenOfOwnerByIndex( - address _owner, - uint256 _index - ) - public - view - returns (uint256 _tokenId); - - function tokenByIndex(uint256 _index) public view returns (uint256); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional metadata extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Metadata is ERC721Basic { - function name() external view returns (string _name); - function symbol() external view returns (string _symbol); - function tokenURI(uint256 _tokenId) public view returns (string); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, full implementation interface - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { -} - - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/interfaces/IInterstellarEncoder.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoder { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function registerNewTokenContract(address _tokenAddress) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); -} - -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Root file: contracts/ERC20Container.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/interfaces/IInterstellarEncoder.sol"; -// import "contracts/SettingIds.sol"; - -contract ERC20Container is Ownable, SettingIds { - ISettingsRegistry public registry; - - // token ids must follow the standard of interstellar encoding - mapping(uint256 => mapping(address=>uint256)) public fungibleTokensInContainer; - - bool private singletonLock = false; - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - constructor () public { - // initializeContract(); - } - - /** - * @dev Same with constructor, but is used and called by storage proxy as logic contract. - */ - function initializeContract(address _registry) public singletonLockCall { - // Ownable constructor - owner = msg.sender; - - registry = ISettingsRegistry(_registry); - } -} \ No newline at end of file diff --git a/flat/ERC223.sol b/flat/ERC223.sol deleted file mode 100644 index 03d02f9..0000000 --- a/flat/ERC223.sol +++ /dev/null @@ -1,11 +0,0 @@ -// Root file: contracts/interfaces/ERC223.sol - -pragma solidity ^0.4.23; - -contract ERC223 { - function transfer(address to, uint amount, bytes data) public returns (bool ok); - - function transferFrom(address from, address to, uint256 amount, bytes data) public returns (bool ok); - - event ERC223Transfer(address indexed from, address indexed to, uint amount, bytes data); -} diff --git a/flat/ERC223ReceivingContract.sol b/flat/ERC223ReceivingContract.sol deleted file mode 100644 index 9d20bf0..0000000 --- a/flat/ERC223ReceivingContract.sol +++ /dev/null @@ -1,19 +0,0 @@ -// Root file: contracts/interfaces/ERC223ReceivingContract.sol - -pragma solidity ^0.4.23; - - /* - * Contract that is working with ERC223 tokens - * https://github.com/ethereum/EIPs/issues/223 - */ - -/// @title ERC223ReceivingContract - Standard contract implementation for compatibility with ERC223 tokens. -contract ERC223ReceivingContract { - - /// @dev Function that is called when a user or another contract wants to transfer funds. - /// @param _from Transaction initiator, analogue of msg.sender - /// @param _value Number of tokens to transfer. - /// @param _data Data containig a function signature and/or parameters - function tokenFallback(address _from, uint256 _value, bytes _data) public; - -} diff --git a/flat/ERC721Adaptor.sol b/flat/ERC721Adaptor.sol deleted file mode 100644 index ab1c40f..0000000 --- a/flat/ERC721Adaptor.sol +++ /dev/null @@ -1,566 +0,0 @@ -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: contracts/PausableDSAuth.sol - -// pragma solidity ^0.4.24; - -// import "contracts/DSAuth.sol"; - - -/** - * @title Pausable - * @dev Base contract which allows children to implement an emergency stop mechanism. - */ -contract PausableDSAuth is DSAuth { - event Pause(); - event Unpause(); - - bool public paused = false; - - - /** - * @dev Modifier to make a function callable only when the contract is not paused. - */ - modifier whenNotPaused() { - require(!paused); - _; - } - - /** - * @dev Modifier to make a function callable only when the contract is paused. - */ - modifier whenPaused() { - require(paused); - _; - } - - /** - * @dev called by the owner to pause, triggers stopped state - */ - function pause() public onlyOwner whenNotPaused { - paused = true; - emit Pause(); - } - - /** - * @dev called by the owner to unpause, returns to normal state - */ - function unpause() public onlyOwner whenPaused { - paused = false; - emit Unpause(); - } -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/interfaces/INFTAdaptor.sol - -// pragma solidity ^0.4.24; - - -contract INFTAdaptor { - function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); - - function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); - - function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); - - function approveOriginToken(address _bridge, uint256 _originTokenId) public; - - function ownerInOrigin(uint256 _originTokenId) public view returns (address); - - function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public; -} - - -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - - -/** - * @title ERC721 Non-Fungible Token Standard basic interface - * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Basic is ERC165 { - - bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; - /* - * 0x80ac58cd === - * bytes4(keccak256('balanceOf(address)')) ^ - * bytes4(keccak256('ownerOf(uint256)')) ^ - * bytes4(keccak256('approve(address,uint256)')) ^ - * bytes4(keccak256('getApproved(uint256)')) ^ - * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ - * bytes4(keccak256('isApprovedForAll(address,address)')) ^ - * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) - */ - - bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; - /* - * 0x4f558e79 === - * bytes4(keccak256('exists(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; - /** - * 0x780e9d63 === - * bytes4(keccak256('totalSupply()')) ^ - * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ - * bytes4(keccak256('tokenByIndex(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; - /** - * 0x5b5e139f === - * bytes4(keccak256('name()')) ^ - * bytes4(keccak256('symbol()')) ^ - * bytes4(keccak256('tokenURI(uint256)')) - */ - - event Transfer( - address indexed _from, - address indexed _to, - uint256 indexed _tokenId - ); - event Approval( - address indexed _owner, - address indexed _approved, - uint256 indexed _tokenId - ); - event ApprovalForAll( - address indexed _owner, - address indexed _operator, - bool _approved - ); - - function balanceOf(address _owner) public view returns (uint256 _balance); - function ownerOf(uint256 _tokenId) public view returns (address _owner); - function exists(uint256 _tokenId) public view returns (bool _exists); - - function approve(address _to, uint256 _tokenId) public; - function getApproved(uint256 _tokenId) - public view returns (address _operator); - - function setApprovalForAll(address _operator, bool _approved) public; - function isApprovedForAll(address _owner, address _operator) - public view returns (bool); - - function transferFrom(address _from, address _to, uint256 _tokenId) public; - function safeTransferFrom(address _from, address _to, uint256 _tokenId) - public; - - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - public; -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Enumerable is ERC721Basic { - function totalSupply() public view returns (uint256); - function tokenOfOwnerByIndex( - address _owner, - uint256 _index - ) - public - view - returns (uint256 _tokenId); - - function tokenByIndex(uint256 _index) public view returns (uint256); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional metadata extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Metadata is ERC721Basic { - function name() external view returns (string _name); - function symbol() external view returns (string _symbol); - function tokenURI(uint256 _tokenId) public view returns (string); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, full implementation interface - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { -} - - -// Dependency file: contracts/interfaces/IInterstellarEncoderV3.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoderV3 { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function encodeTokenIdForOuterObjectContract( - address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); - - function getProducerId(uint256 _tokenId) public view returns (uint16); - - function getOriginAddress(uint256 _tokenId) public view returns (address); - -} - -// Root file: contracts/ERC721Adaptor.sol - -pragma solidity ^0.4.24; - -// import "contracts/SettingIds.sol"; -// import "contracts/PausableDSAuth.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/interfaces/INFTAdaptor.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -// import "contracts/interfaces/IInterstellarEncoderV3.sol"; - - -contract ERC721Adaptor is PausableDSAuth, SettingIds { - - /* - * Storage - */ - bool private singletonLock = false; - - uint16 public producerId; - - uint8 public convertType; - - ISettingsRegistry public registry; - - ERC721 public originNft; - - // tokenId_outside_evolutionLand => tokenId_inside - mapping(uint256 => uint256) public cachedOriginId2MirrorId; - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - function initializeContract(ISettingsRegistry _registry, ERC721 _originNft, uint16 _producerId) public singletonLockCall { - owner = msg.sender; - emit LogSetOwner(msg.sender); - registry = _registry; - originNft = _originNft; - producerId = _producerId; - - convertType = 128; // f(x) = x,fullfill with zero at left side. - } - - - function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256) { - if (cachedOriginId2MirrorId[_originTokenId] > 0) { - return cachedOriginId2MirrorId[_originTokenId]; - } - - uint128 mirrorObjectId = uint128(_originTokenId & 0xffffffffffffffffffffffffffffffff); - - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); - IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - uint256 mirrorTokenId = interstellarEncoder.encodeTokenIdForOuterObjectContract( - petBase, objectOwnership, address(originNft), mirrorObjectId, producerId, convertType); - - return mirrorTokenId; - } - - function ownerInOrigin(uint256 _originTokenId) public view returns (address) { - return ERC721(originNft).ownerOf(_originTokenId); - } - - // if the convertion is not calculatable, and need to use cache mapping in Bridge. - // then .. - function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256) { - return (_mirrorTokenId & 0xffffffffffffffffffffffffffffffff); - } - - function approveToBridge(address _bridge) public onlyOwner { - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - ERC721(objectOwnership).setApprovalForAll(_bridge, true); - } - - function cancelApprove(address _bridge) public onlyOwner { - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - ERC721(objectOwnership).setApprovalForAll(_bridge, false); - } - - function getObjectClass(uint256 _originTokenId) public view returns (uint8) { - IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - uint256 mirrorTokenId = toMirrorTokenId(_originTokenId); - return interstellarEncoder.getObjectClass(mirrorTokenId); - } - - function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public auth { - cachedOriginId2MirrorId[_originTokenId] = _mirrorTokenId; - } -} diff --git a/flat/ERC721AdaptorAuthority.sol b/flat/ERC721AdaptorAuthority.sol deleted file mode 100644 index be8e0f6..0000000 --- a/flat/ERC721AdaptorAuthority.sol +++ /dev/null @@ -1,20 +0,0 @@ -// Root file: contracts/ERC721AdaptorAuthority.sol - -pragma solidity ^0.4.24; - -contract ERC721AdaptorAuthority { - mapping (address => bool) public whiteList; - - constructor(address[] _whitelists) public { - for (uint i = 0; i < _whitelists.length; i++) { - whiteList[_whitelists[i]] = true; - } - } - - function canCall( - address _src, address _dst, bytes4 _sig - ) public view returns (bool) { - return ( whiteList[_src] && _sig == bytes4(keccak256("approveOriginToken(address,uint256)")) ) - || ( whiteList[_src] && _sig == bytes4(keccak256("cacheMirrorTokenId(uint256,uint256)")) ); - } -} \ No newline at end of file diff --git a/flat/ERC721Bridge.sol b/flat/ERC721Bridge.sol deleted file mode 100644 index 862cf8d..0000000 --- a/flat/ERC721Bridge.sol +++ /dev/null @@ -1,656 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: contracts/PausableDSAuth.sol - -// pragma solidity ^0.4.24; - -// import "contracts/DSAuth.sol"; - - -/** - * @title Pausable - * @dev Base contract which allows children to implement an emergency stop mechanism. - */ -contract PausableDSAuth is DSAuth { - event Pause(); - event Unpause(); - - bool public paused = false; - - - /** - * @dev Modifier to make a function callable only when the contract is not paused. - */ - modifier whenNotPaused() { - require(!paused); - _; - } - - /** - * @dev Modifier to make a function callable only when the contract is paused. - */ - modifier whenPaused() { - require(paused); - _; - } - - /** - * @dev called by the owner to pause, triggers stopped state - */ - function pause() public onlyOwner whenNotPaused { - paused = true; - emit Pause(); - } - - /** - * @dev called by the owner to unpause, returns to normal state - */ - function unpause() public onlyOwner whenPaused { - paused = false; - emit Unpause(); - } -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Dependency file: contracts/interfaces/IInterstellarEncoderV3.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoderV3 { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function encodeTokenIdForOuterObjectContract( - address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); - - function getProducerId(uint256 _tokenId) public view returns (uint16); - - function getOriginAddress(uint256 _tokenId) public view returns (address); - -} - -// Dependency file: contracts/interfaces/IMintableERC20.sol - -// pragma solidity ^0.4.23; - -contract IMintableERC20 { - - function mint(address _to, uint256 _value) public; -} - -// Dependency file: contracts/interfaces/INFTAdaptor.sol - -// pragma solidity ^0.4.24; - - -contract INFTAdaptor { - function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); - - function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); - - function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); - - function approveOriginToken(address _bridge, uint256 _originTokenId) public; - - function ownerInOrigin(uint256 _originTokenId) public view returns (address); - - function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public; -} - - -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - - -/** - * @title ERC721 Non-Fungible Token Standard basic interface - * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Basic is ERC165 { - - bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; - /* - * 0x80ac58cd === - * bytes4(keccak256('balanceOf(address)')) ^ - * bytes4(keccak256('ownerOf(uint256)')) ^ - * bytes4(keccak256('approve(address,uint256)')) ^ - * bytes4(keccak256('getApproved(uint256)')) ^ - * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ - * bytes4(keccak256('isApprovedForAll(address,address)')) ^ - * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) - */ - - bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; - /* - * 0x4f558e79 === - * bytes4(keccak256('exists(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; - /** - * 0x780e9d63 === - * bytes4(keccak256('totalSupply()')) ^ - * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ - * bytes4(keccak256('tokenByIndex(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; - /** - * 0x5b5e139f === - * bytes4(keccak256('name()')) ^ - * bytes4(keccak256('symbol()')) ^ - * bytes4(keccak256('tokenURI(uint256)')) - */ - - event Transfer( - address indexed _from, - address indexed _to, - uint256 indexed _tokenId - ); - event Approval( - address indexed _owner, - address indexed _approved, - uint256 indexed _tokenId - ); - event ApprovalForAll( - address indexed _owner, - address indexed _operator, - bool _approved - ); - - function balanceOf(address _owner) public view returns (uint256 _balance); - function ownerOf(uint256 _tokenId) public view returns (address _owner); - function exists(uint256 _tokenId) public view returns (bool _exists); - - function approve(address _to, uint256 _tokenId) public; - function getApproved(uint256 _tokenId) - public view returns (address _operator); - - function setApprovalForAll(address _operator, bool _approved) public; - function isApprovedForAll(address _owner, address _operator) - public view returns (bool); - - function transferFrom(address _from, address _to, uint256 _tokenId) public; - function safeTransferFrom(address _from, address _to, uint256 _tokenId) - public; - - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - public; -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Enumerable is ERC721Basic { - function totalSupply() public view returns (uint256); - function tokenOfOwnerByIndex( - address _owner, - uint256 _index - ) - public - view - returns (uint256 _tokenId); - - function tokenByIndex(uint256 _index) public view returns (uint256); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional metadata extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Metadata is ERC721Basic { - function name() external view returns (string _name); - function symbol() external view returns (string _symbol); - function tokenURI(uint256 _tokenId) public view returns (string); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, full implementation interface - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { -} - - -// Root file: contracts/ERC721Bridge.sol - -pragma solidity ^0.4.23; - -// import "contracts/PausableDSAuth.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/SettingIds.sol"; -// import "contracts/interfaces/IInterstellarEncoderV3.sol"; -// import "contracts/interfaces/IMintableERC20.sol"; -// import "contracts/interfaces/INFTAdaptor.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; - - -/* - * naming convention: - * originTokenId - token outside evolutionLand - * mirrorTokenId - mirror token - */ -contract ERC721Bridge is SettingIds, PausableDSAuth { - - /* - * Storage - */ - bool private singletonLock = false; - - ISettingsRegistry public registry; - - - // originNFTContract => its adator - // for instance, CryptoKitties => CryptoKittiesAdaptor - // this need to be registered by owner - mapping(address => address) public originNFT2Adaptor; - - // tokenId_inside => tokenId_outside - mapping(uint256 => uint256) public mirrorId2OriginId; - - /* - * Event - */ - event BridgeIn(uint256 originTokenId, uint256 mirrorTokenId, address originContract, address adaptorAddress, address owner); - - event SwapIn(uint256 originTokenId, uint256 mirrorTokenId, address owner); - event SwapOut(uint256 originTokenId, uint256 mirrorTokenId, address owner); - - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - function initializeContract(ISettingsRegistry _registry) public singletonLockCall { - owner = msg.sender; - emit LogSetOwner(msg.sender); - registry = _registry; - } - - function registerAdaptor(address _originNftAddress, address _erc721Adaptor) public whenNotPaused onlyOwner { - originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; - } - - // used by PetBase - function bridgeInAuth(address _originNftAddress, uint256 _originTokenId, address _owner) public auth returns (uint256) { - return _bridgeIn(_originNftAddress, _originTokenId, _owner); - } - - - // generate new mirror token without origin token frozen - function bridgeIn(address _originNftAddress, uint256 _originTokenId) public returns (uint256) { - _bridgeIn(_originNftAddress, _originTokenId, msg.sender); - } - - function _bridgeIn(address _originNftAddress, uint256 _originTokenId, address _owner) internal returns (uint256) { - address adaptor = originNFT2Adaptor[_originNftAddress]; - require(adaptor != address(0), "Not registered!"); - - require(INFTAdaptor(adaptor).ownerInOrigin(_originTokenId) == _owner, "Invalid owner!"); - - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); - - // if it is the first time to bridge in - if (!isBridged(mirrorTokenId)) { - // keep new mirror object in this contract - // before the owner has transferred his/her outerObject into this contract - // mirror object can not be transferred - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); - - // link objects_in and objects_out - INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; - - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); - } - - return mirrorTokenId; - } - - // freeze origin token to free mirror token - function swapIn(address _originNftAddress, uint256 _originTokenId) public { - require(ERC721(_originNftAddress).ownerOf(_originTokenId) == msg.sender, "Invalid owner!"); - - address adaptor = originNFT2Adaptor[_originNftAddress]; - require(adaptor != address(0), "Not registered!"); - - // all specific originTokens are kept in bridge - ERC721(_originNftAddress).transferFrom(msg.sender, address(this), _originTokenId); - - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - ERC721(objectOwnership).transferFrom(address(this), msg.sender, mirrorTokenId); - - emit SwapIn(_originTokenId, mirrorTokenId, msg.sender); - } - - function bridgeAndSwapIn(address _originNftAddress, uint256 _originTokenId) public { - bridgeIn(_originNftAddress, _originTokenId); - swapIn(_originNftAddress, _originTokenId); - } - - function swapOut(uint256 _mirrorTokenId) public { - IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); - require(nftContract != address(0), "No such NFT contract"); - address adaptor = originNFT2Adaptor[nftContract]; - require(adaptor != address(0), "not registered!"); - require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); - - // TODO: if it is needed to check its current status - uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); - ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); - - emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); - } - - function approveOriginToken(address _originNFT, address _approved, uint256 _originTokenId) public auth { - ERC721(_originNFT).approve(_approved, _originTokenId); - } - - function ownerOf(uint256 _mirrorTokenId) public view returns (address) { - return ownerOfMirror(_mirrorTokenId); - } - - // return human owner of the token - function mirrorOfOrigin(address _originNFT, uint256 _originTokenId) public view returns (uint256) { - INFTAdaptor adapter = INFTAdaptor(originNFT2Adaptor[_originNFT]); - - return adapter.toMirrorTokenId(_originTokenId); - } - - // return human owner of the token - function ownerOfMirror(uint256 _mirrorTokenId) public view returns (address) { - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - address owner = ERC721(objectOwnership).ownerOf(_mirrorTokenId); - if(owner != address(this)) { - return owner; - } else { - uint originTokenId = mirrorId2OriginId[_mirrorTokenId]; - return INFTAdaptor(originNFT2Adaptor[originOwnershipAddress(_mirrorTokenId)]).ownerInOrigin(originTokenId); - } - } - - function originOwnershipAddress(uint256 _mirrorTokenId) public view returns (address) { - IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - - return interstellarEncoder.getOriginAddress(_mirrorTokenId); - } - - function isBridged(uint256 _mirrorTokenId) public view returns (bool) { - return (mirrorId2OriginId[_mirrorTokenId] != 0); - } -} diff --git a/flat/ERC721BridgeV2.sol b/flat/ERC721BridgeV2.sol deleted file mode 100644 index a2034a6..0000000 --- a/flat/ERC721BridgeV2.sol +++ /dev/null @@ -1,911 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: contracts/PausableDSAuth.sol - -// pragma solidity ^0.4.24; - -// import "contracts/DSAuth.sol"; - - -/** - * @title Pausable - * @dev Base contract which allows children to implement an emergency stop mechanism. - */ -contract PausableDSAuth is DSAuth { - event Pause(); - event Unpause(); - - bool public paused = false; - - - /** - * @dev Modifier to make a function callable only when the contract is not paused. - */ - modifier whenNotPaused() { - require(!paused); - _; - } - - /** - * @dev Modifier to make a function callable only when the contract is paused. - */ - modifier whenPaused() { - require(paused); - _; - } - - /** - * @dev called by the owner to pause, triggers stopped state - */ - function pause() public onlyOwner whenNotPaused { - paused = true; - emit Pause(); - } - - /** - * @dev called by the owner to unpause, returns to normal state - */ - function unpause() public onlyOwner whenPaused { - paused = false; - emit Unpause(); - } -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Dependency file: contracts/interfaces/IInterstellarEncoderV3.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoderV3 { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function encodeTokenIdForOuterObjectContract( - address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); - - function getProducerId(uint256 _tokenId) public view returns (uint16); - - function getOriginAddress(uint256 _tokenId) public view returns (address); - -} - -// Dependency file: contracts/interfaces/IMintableERC20.sol - -// pragma solidity ^0.4.23; - -contract IMintableERC20 { - - function mint(address _to, uint256 _value) public; -} - -// Dependency file: contracts/interfaces/IBurnableERC20.sol - -// pragma solidity ^0.4.23; - -contract IBurnableERC20 { - function burn(address _from, uint _value) public; -} - -// Dependency file: contracts/interfaces/INFTAdaptor.sol - -// pragma solidity ^0.4.24; - - -contract INFTAdaptor { - function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); - - function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); - - function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); - - function approveOriginToken(address _bridge, uint256 _originTokenId) public; - - function ownerInOrigin(uint256 _originTokenId) public view returns (address); - - function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public; -} - - -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - - -/** - * @title ERC721 Non-Fungible Token Standard basic interface - * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Basic is ERC165 { - - bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; - /* - * 0x80ac58cd === - * bytes4(keccak256('balanceOf(address)')) ^ - * bytes4(keccak256('ownerOf(uint256)')) ^ - * bytes4(keccak256('approve(address,uint256)')) ^ - * bytes4(keccak256('getApproved(uint256)')) ^ - * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ - * bytes4(keccak256('isApprovedForAll(address,address)')) ^ - * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) - */ - - bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; - /* - * 0x4f558e79 === - * bytes4(keccak256('exists(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; - /** - * 0x780e9d63 === - * bytes4(keccak256('totalSupply()')) ^ - * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ - * bytes4(keccak256('tokenByIndex(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; - /** - * 0x5b5e139f === - * bytes4(keccak256('name()')) ^ - * bytes4(keccak256('symbol()')) ^ - * bytes4(keccak256('tokenURI(uint256)')) - */ - - event Transfer( - address indexed _from, - address indexed _to, - uint256 indexed _tokenId - ); - event Approval( - address indexed _owner, - address indexed _approved, - uint256 indexed _tokenId - ); - event ApprovalForAll( - address indexed _owner, - address indexed _operator, - bool _approved - ); - - function balanceOf(address _owner) public view returns (uint256 _balance); - function ownerOf(uint256 _tokenId) public view returns (address _owner); - function exists(uint256 _tokenId) public view returns (bool _exists); - - function approve(address _to, uint256 _tokenId) public; - function getApproved(uint256 _tokenId) - public view returns (address _operator); - - function setApprovalForAll(address _operator, bool _approved) public; - function isApprovedForAll(address _owner, address _operator) - public view returns (bool); - - function transferFrom(address _from, address _to, uint256 _tokenId) public; - function safeTransferFrom(address _from, address _to, uint256 _tokenId) - public; - - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - public; -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Enumerable is ERC721Basic { - function totalSupply() public view returns (uint256); - function tokenOfOwnerByIndex( - address _owner, - uint256 _index - ) - public - view - returns (uint256 _tokenId); - - function tokenByIndex(uint256 _index) public view returns (uint256); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional metadata extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Metadata is ERC721Basic { - function name() external view returns (string _name); - function symbol() external view returns (string _symbol); - function tokenURI(uint256 _tokenId) public view returns (string); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, full implementation interface - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { -} - - -// Dependency file: contracts/interfaces/IERC165.sol - -// SPDX-License-Identifier: MIT - -// pragma solidity ^0.4.24; - -/** - * @dev Interface of the ERC165 standard, as defined in the - * https://eips.ethereum.org/EIPS/eip-165[EIP]. - * - * Implementers can declare support of contract interfaces, which can then be - * queried by others ({ERC165Checker}). - * - * For an implementation, see {ERC165}. - */ -contract IERC165 { - /** - * @dev Returns true if this contract implements the interface defined by - * `interfaceId`. See the corresponding - * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] - * to learn more about how these ids are created. - * - * This function call must use less than 30 000 gas. - */ - function supportsInterface(bytes4 interfaceId) external view returns (bool); -} - - -// Dependency file: contracts/interfaces/IERC1155.sol - - -// pragma solidity ^0.4.24; - -// import "contracts/interfaces/IERC165.sol"; - -/** - * @dev Required interface of an ERC1155 compliant contract, as defined in the - * https://eips.ethereum.org/EIPS/eip-1155[EIP]. - * - * _Available since v3.1._ - */ -contract IERC1155 is IERC165 { - /** - * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. - */ - event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); - - /** - * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all - * transfers. - */ - event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); - - /** - * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to - * `approved`. - */ - event ApprovalForAll(address indexed account, address indexed operator, bool approved); - - /** - * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. - * - * If an {URI} event was emitted for `id`, the standard - * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value - * returned by {IERC1155MetadataURI-uri}. - */ - event URI(string value, uint256 indexed id); - - /** - * @dev Returns the amount of tokens of token type `id` owned by `account`. - * - * Requirements: - * - * - `account` cannot be the zero address. - */ - function balanceOf(address account, uint256 id) external view returns (uint256); - - /** - * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. - * - * Requirements: - * - * - `accounts` and `ids` must have the same length. - */ - function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[] memory); - - /** - * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, - * - * Emits an {ApprovalForAll} event. - * - * Requirements: - * - * - `operator` cannot be the caller. - */ - function setApprovalForAll(address operator, bool approved) external; - - /** - * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. - * - * See {setApprovalForAll}. - */ - function isApprovedForAll(address account, address operator) external view returns (bool); - - /** - * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. - * - * Emits a {TransferSingle} event. - * - * Requirements: - * - * - `to` cannot be the zero address. - * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. - * - `from` must have a balance of tokens of type `id` of at least `amount`. - * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the - * acceptance magic value. - */ - function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external; - - /** - * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. - * - * Emits a {TransferBatch} event. - * - * Requirements: - * - * - `ids` and `amounts` must have the same length. - * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the - * acceptance magic value. - */ - function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external; -} - - -// Dependency file: contracts/interfaces/IERC1155Receiver.sol - - -// pragma solidity ^0.4.24; - -/** - * _Available since v3.1._ - */ -contract IERC1155Receiver { - - bytes4 internal constant ERC1155_RECEIVED_VALUE = 0xf23a6e61; - bytes4 internal constant ERC1155_BATCH_RECEIVED_VALUE = 0xbc197c81; - - /** - @dev Handles the receipt of a single ERC1155 token type. This function is - called at the end of a `safeTransferFrom` after the balance has been updated. - To accept the transfer, this must return - `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` - (i.e. 0xf23a6e61, or its own function selector). - @param operator The address which initiated the transfer (i.e. msg.sender) - @param from The address which previously owned the token - @param id The ID of the token being transferred - @param value The amount of tokens being transferred - @param data Additional data with no specified format - @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed - */ - function onERC1155Received( - address operator, - address from, - uint256 id, - uint256 value, - bytes data - ) - external - returns(bytes4); - - /** - @dev Handles the receipt of a multiple ERC1155 token types. This function - is called at the end of a `safeBatchTransferFrom` after the balances have - been updated. To accept the transfer(s), this must return - `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` - (i.e. 0xbc197c81, or its own function selector). - @param operator The address which initiated the batch transfer (i.e. msg.sender) - @param from The address which previously owned the token - @param ids An array containing ids of each token being transferred (order and length must match values array) - @param values An array containing amounts of each token being transferred (order and length must match ids array) - @param data Additional data with no specified format - @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed - */ - function onERC1155BatchReceived( - address operator, - address from, - uint256[] ids, - uint256[] values, - bytes data - ) - external - returns(bytes4); -} - - -// Root file: contracts/ERC721BridgeV2.sol - -pragma solidity ^0.4.23; - -// import "contracts/PausableDSAuth.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/SettingIds.sol"; -// import "contracts/interfaces/IInterstellarEncoderV3.sol"; -// import "contracts/interfaces/IMintableERC20.sol"; -// import "contracts/interfaces/IBurnableERC20.sol"; -// import "contracts/interfaces/INFTAdaptor.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -// import "contracts/interfaces/IERC1155.sol"; -// import "contracts/interfaces/IERC1155Receiver.sol"; - - -/* - * naming convention: - * originTokenId - token outside evolutionLand - * mirrorTokenId - mirror token - */ -contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { - - /* - * Storage - */ - bool private singletonLock = false; - - ISettingsRegistry public registry; - - - // originNFTContract => its adator - // for instance, CryptoKitties => CryptoKittiesAdaptor - // this need to be registered by owner - mapping(address => address) public originNFT2Adaptor; - - // tokenId_inside => tokenId_outside - mapping(uint256 => uint256) public mirrorId2OriginId; - - /* - * Event - */ - event BridgeIn(uint256 originTokenId, uint256 mirrorTokenId, address originContract, address adaptorAddress, address owner); - - event SwapIn(uint256 originTokenId, uint256 mirrorTokenId, address owner); - event SwapOut(uint256 originTokenId, uint256 mirrorTokenId, address owner); - - function registerAdaptor(address _originNftAddress, address _erc721Adaptor) public whenNotPaused onlyOwner { - originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; - } - - // used by PetBase - function bridgeInAuth(address _originNftAddress, uint256 _originTokenId, address _owner) public auth returns (uint256) { - return _bridgeIn(_originNftAddress, _originTokenId, _owner); - } - - - // generate new mirror token without origin token frozen - function bridgeIn(address _originNftAddress, uint256 _originTokenId) public returns (uint256) { - _bridgeIn(_originNftAddress, _originTokenId, msg.sender); - } - - function _bridgeIn(address _originNftAddress, uint256 _originTokenId, address _owner) internal returns (uint256) { - address adaptor = originNFT2Adaptor[_originNftAddress]; - require(adaptor != address(0), "Not registered!"); - - require(INFTAdaptor(adaptor).ownerInOrigin(_originTokenId) == _owner, "Invalid owner!"); - - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); - - // if it is the first time to bridge in - if (!isBridged(mirrorTokenId)) { - // keep new mirror object in this contract - // before the owner has transferred his/her outerObject into this contract - // mirror object can not be transferred - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); - - // link objects_in and objects_out - INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; - - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); - } - - return mirrorTokenId; - } - - // freeze origin token to free mirror token - function swapIn(address _originNftAddress, uint256 _originTokenId) public { - require(ERC721(_originNftAddress).ownerOf(_originTokenId) == msg.sender, "Invalid owner!"); - - address adaptor = originNFT2Adaptor[_originNftAddress]; - require(adaptor != address(0), "Not registered!"); - - // all specific originTokens are kept in bridge - ERC721(_originNftAddress).transferFrom(msg.sender, address(this), _originTokenId); - - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - ERC721(objectOwnership).transferFrom(address(this), msg.sender, mirrorTokenId); - - emit SwapIn(_originTokenId, mirrorTokenId, msg.sender); - } - - function bridgeAndSwapIn(address _originNftAddress, uint256 _originTokenId) public { - bridgeIn(_originNftAddress, _originTokenId); - swapIn(_originNftAddress, _originTokenId); - } - - function swapOut(uint256 _mirrorTokenId) public { - IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); - require(nftContract != address(0), "No such NFT contract"); - address adaptor = originNFT2Adaptor[nftContract]; - require(adaptor != address(0), "not registered!"); - require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); - - // TODO: if it is needed to check its current status - uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); - ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); - - emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); - } - - // V2 add - Support PolkaPet - function swapOut1155(uint256 _mirrorTokenId) public { - IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - address nftContract = interstellarEncoder.getOriginAddress(_mirrorTokenId); - require(nftContract != address(0), "No such NFT contract"); - address adaptor = originNFT2Adaptor[nftContract]; - require(adaptor != address(0), "not registered!"); - require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); - - // TODO: if it is needed to check its current status - uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); - IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); - emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); - } - - function approveOriginToken(address _originNFT, address _approved, uint256 _originTokenId) public auth { - ERC721(_originNFT).approve(_approved, _originTokenId); - } - - function ownerOf(uint256 _mirrorTokenId) public view returns (address) { - return ownerOfMirror(_mirrorTokenId); - } - - // return human owner of the token - function mirrorOfOrigin(address _originNFT, uint256 _originTokenId) public view returns (uint256) { - INFTAdaptor adapter = INFTAdaptor(originNFT2Adaptor[_originNFT]); - - return adapter.toMirrorTokenId(_originTokenId); - } - - // return human owner of the token - function ownerOfMirror(uint256 _mirrorTokenId) public view returns (address) { - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - address owner = ERC721(objectOwnership).ownerOf(_mirrorTokenId); - if(owner != address(this)) { - return owner; - } else { - uint originTokenId = mirrorId2OriginId[_mirrorTokenId]; - return INFTAdaptor(originNFT2Adaptor[originOwnershipAddress(_mirrorTokenId)]).ownerInOrigin(originTokenId); - } - } - - function originOwnershipAddress(uint256 _mirrorTokenId) public view returns (address) { - IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - - return interstellarEncoder.getOriginAddress(_mirrorTokenId); - } - - function isBridged(uint256 _mirrorTokenId) public view returns (bool) { - return (mirrorId2OriginId[_mirrorTokenId] != 0); - } - - - // V2 add - Support PolkaPet - function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from, uint256 _value) private { - address adaptor = originNFT2Adaptor[msg.sender]; - require(adaptor != address(0), "Not registered!"); - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - for (uint256 i = 0; i < _value; i++) { - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); - IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); - emit SwapIn(_originTokenId, mirrorTokenId, _from); - } - } - - function onERC1155Received( - address operator, - address from, - uint256 id, - uint256 value, - bytes data - ) - whenNotPaused() - external - returns(bytes4) - { - _bridgeIn1155(msg.sender, id, from, value); - return ERC1155_RECEIVED_VALUE; - } - - function onERC1155BatchReceived( - address operator, - address from, - uint256[] ids, - uint256[] values, - bytes data - ) - whenNotPaused() - external - returns(bytes4) - { - require(ids.length == values.length, "INVALID_ARRAYS_LENGTH"); - for (uint256 i = 0; i < ids.length; i++) { - _bridgeIn1155(msg.sender, ids[i], from, values[i]); - } - return ERC1155_BATCH_RECEIVED_VALUE; - } -} diff --git a/flat/ERC721Container.sol b/flat/ERC721Container.sol deleted file mode 100644 index 2e9c802..0000000 --- a/flat/ERC721Container.sol +++ /dev/null @@ -1,522 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol - -// pragma solidity ^0.4.24; - - -/** - * @title Ownable - * @dev The Ownable contract has an owner address, and provides basic authorization control - * functions, this simplifies the implementation of "user permissions". - */ -contract Ownable { - address public owner; - - - event OwnershipRenounced(address indexed previousOwner); - event OwnershipTransferred( - address indexed previousOwner, - address indexed newOwner - ); - - - /** - * @dev The Ownable constructor sets the original `owner` of the contract to the sender - * account. - */ - constructor() public { - owner = msg.sender; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - /** - * @dev Allows the current owner to relinquish control of the contract. - * @notice Renouncing to ownership will leave the contract without an owner. - * It will not be possible to call the functions with the `onlyOwner` - * modifier anymore. - */ - function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner); - owner = address(0); - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function transferOwnership(address _newOwner) public onlyOwner { - _transferOwnership(_newOwner); - } - - /** - * @dev Transfers control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function _transferOwnership(address _newOwner) internal { - require(_newOwner != address(0)); - emit OwnershipTransferred(owner, _newOwner); - owner = _newOwner; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - - -/** - * @title ERC721 Non-Fungible Token Standard basic interface - * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Basic is ERC165 { - - bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; - /* - * 0x80ac58cd === - * bytes4(keccak256('balanceOf(address)')) ^ - * bytes4(keccak256('ownerOf(uint256)')) ^ - * bytes4(keccak256('approve(address,uint256)')) ^ - * bytes4(keccak256('getApproved(uint256)')) ^ - * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ - * bytes4(keccak256('isApprovedForAll(address,address)')) ^ - * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) - */ - - bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; - /* - * 0x4f558e79 === - * bytes4(keccak256('exists(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; - /** - * 0x780e9d63 === - * bytes4(keccak256('totalSupply()')) ^ - * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ - * bytes4(keccak256('tokenByIndex(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; - /** - * 0x5b5e139f === - * bytes4(keccak256('name()')) ^ - * bytes4(keccak256('symbol()')) ^ - * bytes4(keccak256('tokenURI(uint256)')) - */ - - event Transfer( - address indexed _from, - address indexed _to, - uint256 indexed _tokenId - ); - event Approval( - address indexed _owner, - address indexed _approved, - uint256 indexed _tokenId - ); - event ApprovalForAll( - address indexed _owner, - address indexed _operator, - bool _approved - ); - - function balanceOf(address _owner) public view returns (uint256 _balance); - function ownerOf(uint256 _tokenId) public view returns (address _owner); - function exists(uint256 _tokenId) public view returns (bool _exists); - - function approve(address _to, uint256 _tokenId) public; - function getApproved(uint256 _tokenId) - public view returns (address _operator); - - function setApprovalForAll(address _operator, bool _approved) public; - function isApprovedForAll(address _owner, address _operator) - public view returns (bool); - - function transferFrom(address _from, address _to, uint256 _tokenId) public; - function safeTransferFrom(address _from, address _to, uint256 _tokenId) - public; - - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - public; -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Enumerable is ERC721Basic { - function totalSupply() public view returns (uint256); - function tokenOfOwnerByIndex( - address _owner, - uint256 _index - ) - public - view - returns (uint256 _tokenId); - - function tokenByIndex(uint256 _index) public view returns (uint256); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional metadata extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Metadata is ERC721Basic { - function name() external view returns (string _name); - function symbol() external view returns (string _symbol); - function tokenURI(uint256 _tokenId) public view returns (string); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, full implementation interface - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { -} - - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/interfaces/IInterstellarEncoder.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoder { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function registerNewTokenContract(address _tokenAddress) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); -} - -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Root file: contracts/ERC721Container.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/interfaces/IInterstellarEncoder.sol"; -// import "contracts/SettingIds.sol"; - -contract ERC721Container is Ownable, SettingIds { - ISettingsRegistry public registry; - - // token ids must follow the standard of interstellar encoding - mapping(uint256 => uint256[]) public objectsInContainer; - - mapping(uint256 => uint256) public object2Container; - - mapping(uint256 => uint256) public object2IndexInContainer; - - bool private singletonLock = false; - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - constructor () public { - // initializeContract(); - } - - /** - * @dev Same with constructor, but is used and called by storage proxy as logic contract. - */ - function initializeContract(address _registry) public singletonLockCall { - // Ownable constructor - owner = msg.sender; - - registry = ISettingsRegistry(_registry); - } - - function contains(uint256 _containerTokenId, uint256 _objectTokenId) public view returns (bool) { - require(_containerTokenId > 0, "Token Id should large than zero."); - - return object2Container[_objectTokenId] == _containerTokenId; - } - - - // TODO: does the add operation require the container's owner agree to? - function addToContainer(uint256 _containerTokenId, uint256 _objectTokenId) public { - // make sure this object is not already in container. - require(object2Container[_objectTokenId] == 0, "Object Token can not be in container."); - require(_containerTokenId > 0, "Token Id should large than zero."); - - address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); - require(interstellarEncoder != address(0), "Contract Interstellar Encoder does not exist."); - - address containerTokenAddress = IInterstellarEncoder(interstellarEncoder).getContractAddress(_containerTokenId); - require(containerTokenAddress != address(0), "Container token contract is not registered."); - address objectTokenAddress = IInterstellarEncoder(interstellarEncoder).getContractAddress(_objectTokenId); - require(objectTokenAddress != address(0), "Object token contract is not registered."); - - address objectOwner = ERC721(objectTokenAddress).ownerOf(_objectTokenId); - // requires approve first. - ERC721(objectTokenAddress).transferFrom(objectOwner, address(this), _objectTokenId); - - // update belongs mappings. - - objectsInContainer[_containerTokenId].push(_objectTokenId); - - object2Container[_objectTokenId] = _containerTokenId; - object2IndexInContainer[_objectTokenId] = objectsInContainer[_containerTokenId].length - 1; - - } - - function transferToOtherContainer(uint256 _objectTokenId, uint256 _toContainer) public { - - } - - function transferToAddress(uint256 _objectTokenId, address _receiver) public { - (address _topOwner, address _topApproved) = getTopContainerOwnerAndApproved(_objectTokenId); - - address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); - require(interstellarEncoder != address(0), "Contract Interstellar Encoder does not exist."); - - address objectTokenAddress = IInterstellarEncoder(interstellarEncoder).getContractAddress(_objectTokenId); - require(objectTokenAddress != address(0), "Object token contract is not registered."); - - if(_topOwner == msg.sender || _topApproved == msg.sender) { - ERC721(objectTokenAddress).transferFrom(address(this), _receiver, _objectTokenId); - } - - // Reorg index array in objectsInContainer - uint256 objectIndex = object2IndexInContainer[_objectTokenId]; - uint256 lastObjectIndex = objectsInContainer[object2Container[_objectTokenId]].length - 1; - uint256 lastObjectId = objectsInContainer[object2Container[_objectTokenId]][lastObjectIndex]; - - objectsInContainer[object2Container[_objectTokenId]][objectIndex] = lastObjectId; - objectsInContainer[object2Container[_objectTokenId]][lastObjectIndex] = 0; - - objectsInContainer[object2Container[_objectTokenId]].length --; - object2IndexInContainer[lastObjectId] = objectIndex; - - delete object2Container[_objectTokenId]; - delete object2IndexInContainer[_objectTokenId]; - } - - function getTopContainerOwnerAndApproved(uint256 _objectTokenId) public view returns (address _owner, address _approved) { - // make sure this object is already in container. - require(object2Container[_objectTokenId] > 0, "Object Token can not be in container."); - // recursive check to get authorized addresses to transfer. - uint256 _topContainerTokenId = object2Container[_objectTokenId]; - while(object2Container[_topContainerTokenId] > 0) { - _topContainerTokenId = object2Container[_topContainerTokenId]; - } - - address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); - require(interstellarEncoder != address(0), "Contract Interstellar Encoder does not exist."); - - _owner = ERC721(IInterstellarEncoder(interstellarEncoder).getContractAddress(_topContainerTokenId)).ownerOf(_topContainerTokenId); - _approved = ERC721(IInterstellarEncoder(interstellarEncoder).getContractAddress(_topContainerTokenId)) - .getApproved(_topContainerTokenId); - } - - function isContainer(uint256 _containerTokenId) public view returns (bool) { - require(_containerTokenId > 0, "Token Id should large than zero."); - - return objectsInContainer[_containerTokenId].length > 0; - } -} diff --git a/flat/IActivity.sol b/flat/IActivity.sol deleted file mode 100644 index 856ae03..0000000 --- a/flat/IActivity.sol +++ /dev/null @@ -1,39 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Root file: contracts/interfaces/IActivity.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - -contract IActivity is ERC165 { - bytes4 internal constant InterfaceId_IActivity = 0x6086e7f8; - /* - * 0x6086e7f8 === - * bytes4(keccak256('activityStopped(uint256)')) - */ - - function activityStopped(uint256 _tokenId) public; -} \ No newline at end of file diff --git a/flat/IActivityObject.sol b/flat/IActivityObject.sol deleted file mode 100644 index 236047b..0000000 --- a/flat/IActivityObject.sol +++ /dev/null @@ -1,42 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Root file: contracts/interfaces/IActivityObject.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - -contract IActivityObject is ERC165 { - bytes4 internal constant InterfaceId_IActivityObject = 0x2b9eccc6; - /* - * 0x2b9eccc6 === - * bytes4(keccak256('activityAdded(uint256,address,address)')) ^ - * bytes4(keccak256('activityRemoved(uint256,address,address)')) - */ - - function activityAdded(uint256 _tokenId, address _activity, address _user) public; - - function activityRemoved(uint256 _tokenId, address _activity, address _user) public; -} \ No newline at end of file diff --git a/flat/IAuthority.sol b/flat/IAuthority.sol deleted file mode 100644 index 111fe9f..0000000 --- a/flat/IAuthority.sol +++ /dev/null @@ -1,9 +0,0 @@ -// Root file: contracts/interfaces/IAuthority.sol - -pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} \ No newline at end of file diff --git a/flat/IBurnableERC20.sol b/flat/IBurnableERC20.sol deleted file mode 100644 index c7a38e0..0000000 --- a/flat/IBurnableERC20.sol +++ /dev/null @@ -1,7 +0,0 @@ -// Root file: contracts/interfaces/IBurnableERC20.sol - -pragma solidity ^0.4.23; - -contract IBurnableERC20 { - function burn(address _from, uint _value) public; -} \ No newline at end of file diff --git a/flat/IContainer.sol b/flat/IContainer.sol deleted file mode 100644 index 22f47b9..0000000 --- a/flat/IContainer.sol +++ /dev/null @@ -1,8 +0,0 @@ -// Root file: contracts/interfaces/IContainer.sol - -pragma solidity ^0.4.23; - -contract IContainer { - // TODO, using the iter-stella objects encoding ids. - -} \ No newline at end of file diff --git a/flat/IERC1155.sol b/flat/IERC1155.sol deleted file mode 100644 index cd7e8db..0000000 --- a/flat/IERC1155.sol +++ /dev/null @@ -1,132 +0,0 @@ -// Dependency file: contracts/interfaces/IERC165.sol - -// SPDX-License-Identifier: MIT - -// pragma solidity ^0.4.24; - -/** - * @dev Interface of the ERC165 standard, as defined in the - * https://eips.ethereum.org/EIPS/eip-165[EIP]. - * - * Implementers can declare support of contract interfaces, which can then be - * queried by others ({ERC165Checker}). - * - * For an implementation, see {ERC165}. - */ -contract IERC165 { - /** - * @dev Returns true if this contract implements the interface defined by - * `interfaceId`. See the corresponding - * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] - * to learn more about how these ids are created. - * - * This function call must use less than 30 000 gas. - */ - function supportsInterface(bytes4 interfaceId) external view returns (bool); -} - - -// Root file: contracts/interfaces/IERC1155.sol - - -pragma solidity ^0.4.24; - -// import "contracts/interfaces/IERC165.sol"; - -/** - * @dev Required interface of an ERC1155 compliant contract, as defined in the - * https://eips.ethereum.org/EIPS/eip-1155[EIP]. - * - * _Available since v3.1._ - */ -contract IERC1155 is IERC165 { - /** - * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. - */ - event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); - - /** - * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all - * transfers. - */ - event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); - - /** - * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to - * `approved`. - */ - event ApprovalForAll(address indexed account, address indexed operator, bool approved); - - /** - * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. - * - * If an {URI} event was emitted for `id`, the standard - * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value - * returned by {IERC1155MetadataURI-uri}. - */ - event URI(string value, uint256 indexed id); - - /** - * @dev Returns the amount of tokens of token type `id` owned by `account`. - * - * Requirements: - * - * - `account` cannot be the zero address. - */ - function balanceOf(address account, uint256 id) external view returns (uint256); - - /** - * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. - * - * Requirements: - * - * - `accounts` and `ids` must have the same length. - */ - function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[] memory); - - /** - * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, - * - * Emits an {ApprovalForAll} event. - * - * Requirements: - * - * - `operator` cannot be the caller. - */ - function setApprovalForAll(address operator, bool approved) external; - - /** - * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. - * - * See {setApprovalForAll}. - */ - function isApprovedForAll(address account, address operator) external view returns (bool); - - /** - * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. - * - * Emits a {TransferSingle} event. - * - * Requirements: - * - * - `to` cannot be the zero address. - * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. - * - `from` must have a balance of tokens of type `id` of at least `amount`. - * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the - * acceptance magic value. - */ - function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external; - - /** - * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. - * - * Emits a {TransferBatch} event. - * - * Requirements: - * - * - `ids` and `amounts` must have the same length. - * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the - * acceptance magic value. - */ - function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external; -} diff --git a/flat/IERC1155Receiver.sol b/flat/IERC1155Receiver.sol deleted file mode 100644 index a0cba5c..0000000 --- a/flat/IERC1155Receiver.sol +++ /dev/null @@ -1,60 +0,0 @@ -// Root file: contracts/interfaces/IERC1155Receiver.sol - -// SPDX-License-Identifier: MIT - -pragma solidity ^0.4.24; - -/** - * _Available since v3.1._ - */ -contract IERC1155Receiver { - - bytes4 internal constant ERC1155_RECEIVED_VALUE = 0xf23a6e61; - bytes4 internal constant ERC1155_BATCH_RECEIVED_VALUE = 0xbc197c81; - - /** - @dev Handles the receipt of a single ERC1155 token type. This function is - called at the end of a `safeTransferFrom` after the balance has been updated. - To accept the transfer, this must return - `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` - (i.e. 0xf23a6e61, or its own function selector). - @param operator The address which initiated the transfer (i.e. msg.sender) - @param from The address which previously owned the token - @param id The ID of the token being transferred - @param value The amount of tokens being transferred - @param data Additional data with no specified format - @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed - */ - function onERC1155Received( - address operator, - address from, - uint256 id, - uint256 value, - bytes data - ) - external - returns(bytes4); - - /** - @dev Handles the receipt of a multiple ERC1155 token types. This function - is called at the end of a `safeBatchTransferFrom` after the balances have - been updated. To accept the transfer(s), this must return - `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` - (i.e. 0xbc197c81, or its own function selector). - @param operator The address which initiated the batch transfer (i.e. msg.sender) - @param from The address which previously owned the token - @param ids An array containing ids of each token being transferred (order and length must match values array) - @param values An array containing amounts of each token being transferred (order and length must match ids array) - @param data Additional data with no specified format - @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed - */ - function onERC1155BatchReceived( - address operator, - address from, - uint256[] ids, - uint256[] values, - bytes data - ) - external - returns(bytes4); -} diff --git a/flat/IERC165.sol b/flat/IERC165.sol deleted file mode 100644 index 98379ca..0000000 --- a/flat/IERC165.sol +++ /dev/null @@ -1,26 +0,0 @@ -// Root file: contracts/interfaces/IERC165.sol - -// SPDX-License-Identifier: MIT - -pragma solidity ^0.4.24; - -/** - * @dev Interface of the ERC165 standard, as defined in the - * https://eips.ethereum.org/EIPS/eip-165[EIP]. - * - * Implementers can declare support of contract interfaces, which can then be - * queried by others ({ERC165Checker}). - * - * For an implementation, see {ERC165}. - */ -contract IERC165 { - /** - * @dev Returns true if this contract implements the interface defined by - * `interfaceId`. See the corresponding - * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] - * to learn more about how these ids are created. - * - * This function call must use less than 30 000 gas. - */ - function supportsInterface(bytes4 interfaceId) external view returns (bool); -} diff --git a/flat/IInterstellarEncoder.sol b/flat/IInterstellarEncoder.sol deleted file mode 100644 index c785c2d..0000000 --- a/flat/IInterstellarEncoder.sol +++ /dev/null @@ -1,35 +0,0 @@ -// Root file: contracts/interfaces/IInterstellarEncoder.sol - -pragma solidity ^0.4.24; - -contract IInterstellarEncoder { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function registerNewTokenContract(address _tokenAddress) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); -} \ No newline at end of file diff --git a/flat/IInterstellarEncoderV3.sol b/flat/IInterstellarEncoderV3.sol deleted file mode 100644 index 39af983..0000000 --- a/flat/IInterstellarEncoderV3.sol +++ /dev/null @@ -1,41 +0,0 @@ -// Root file: contracts/interfaces/IInterstellarEncoderV3.sol - -pragma solidity ^0.4.24; - -contract IInterstellarEncoderV3 { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function encodeTokenIdForOuterObjectContract( - address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); - - function getProducerId(uint256 _tokenId) public view returns (uint16); - - function getOriginAddress(uint256 _tokenId) public view returns (address); - -} \ No newline at end of file diff --git a/flat/IMinerObject.sol b/flat/IMinerObject.sol deleted file mode 100644 index 2ef5f9d..0000000 --- a/flat/IMinerObject.sol +++ /dev/null @@ -1,41 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Root file: contracts/interfaces/IMinerObject.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - -contract IMinerObject is ERC165 { - bytes4 internal constant InterfaceId_IMinerObject = 0x64272b75; - - /* - * 0x64272b752 === - * bytes4(keccak256('strengthOf(uint256,address)')) - */ - - function strengthOf(uint256 _tokenId, address _resourceToken, uint256 _landTokenId) public view returns (uint256); - -} \ No newline at end of file diff --git a/flat/IMintableERC20.sol b/flat/IMintableERC20.sol deleted file mode 100644 index da28029..0000000 --- a/flat/IMintableERC20.sol +++ /dev/null @@ -1,8 +0,0 @@ -// Root file: contracts/interfaces/IMintableERC20.sol - -pragma solidity ^0.4.23; - -contract IMintableERC20 { - - function mint(address _to, uint256 _value) public; -} \ No newline at end of file diff --git a/flat/INFTAdaptor.sol b/flat/INFTAdaptor.sol deleted file mode 100644 index ad7faf3..0000000 --- a/flat/INFTAdaptor.sol +++ /dev/null @@ -1,18 +0,0 @@ -// Root file: contracts/interfaces/INFTAdaptor.sol - -pragma solidity ^0.4.24; - - -contract INFTAdaptor { - function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); - - function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); - - function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); - - function approveOriginToken(address _bridge, uint256 _originTokenId) public; - - function ownerInOrigin(uint256 _originTokenId) public view returns (address); - - function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public; -} diff --git a/flat/IObjectOwnership.sol b/flat/IObjectOwnership.sol deleted file mode 100644 index a8bc07e..0000000 --- a/flat/IObjectOwnership.sol +++ /dev/null @@ -1,9 +0,0 @@ -// Root file: contracts/interfaces/IObjectOwnership.sol - -pragma solidity ^0.4.24; - -contract IObjectOwnership { - function mintObject(address _to, uint128 _objectId) public returns (uint256 _tokenId); - - function burnObject(address _to, uint128 _objectId) public returns (uint256 _tokenId); -} \ No newline at end of file diff --git a/flat/ISettingsRegistry.sol b/flat/ISettingsRegistry.sol deleted file mode 100644 index a778a98..0000000 --- a/flat/ISettingsRegistry.sol +++ /dev/null @@ -1,35 +0,0 @@ -// Root file: contracts/interfaces/ISettingsRegistry.sol - -pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} \ No newline at end of file diff --git a/flat/ISmartToken.sol b/flat/ISmartToken.sol deleted file mode 100644 index 315dc5e..0000000 --- a/flat/ISmartToken.sol +++ /dev/null @@ -1,15 +0,0 @@ -// Root file: contracts/interfaces/ISmartToken.sol - -pragma solidity ^0.4.23; - -/* - Smart Token interface -*/ -contract ISmartToken { - function transferOwnership(address _newOwner) public; - function acceptOwnership() public; - - function disableTransfers(bool _disable) public; - function issue(address _to, uint256 _amount) public; - function destroy(address _from, uint256 _amount) public; -} \ No newline at end of file diff --git a/flat/ITokenLocation.sol b/flat/ITokenLocation.sol deleted file mode 100644 index 89b6547..0000000 --- a/flat/ITokenLocation.sol +++ /dev/null @@ -1,16 +0,0 @@ -// Root file: contracts/interfaces/ITokenLocation.sol - -pragma solidity ^0.4.24; - -contract ITokenLocation { - - function hasLocation(uint256 _tokenId) public view returns (bool); - - function getTokenLocation(uint256 _tokenId) public view returns (int, int); - - function setTokenLocation(uint256 _tokenId, int _x, int _y) public; - - function getTokenLocationHM(uint256 _tokenId) public view returns (int, int); - - function setTokenLocationHM(uint256 _tokenId, int _x, int _y) public; -} \ No newline at end of file diff --git a/flat/ITokenUse.sol b/flat/ITokenUse.sol deleted file mode 100644 index 95e47bc..0000000 --- a/flat/ITokenUse.sol +++ /dev/null @@ -1,23 +0,0 @@ -// Root file: contracts/interfaces/ITokenUse.sol - -pragma solidity ^0.4.24; - -contract ITokenUse { - uint48 public constant MAX_UINT48_TIME = 281474976710655; - - function isObjectInHireStage(uint256 _tokenId) public view returns (bool); - - function isObjectReadyToUse(uint256 _tokenId) public view returns (bool); - - function getTokenUser(uint256 _tokenId) public view returns (address); - - function createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public; - - function cancelTokenUseOffer(uint256 _tokenId) public; - - function takeTokenUseOffer(uint256 _tokenId) public; - - function addActivity(uint256 _tokenId, address _user, uint256 _endTime) public; - - function removeActivity(uint256 _tokenId, address _user) public; -} \ No newline at end of file diff --git a/flat/ITokenVendor.sol b/flat/ITokenVendor.sol deleted file mode 100644 index 1652029..0000000 --- a/flat/ITokenVendor.sol +++ /dev/null @@ -1,32 +0,0 @@ -// Root file: contracts/interfaces/ITokenVendor.sol - -pragma solidity ^0.4.23; - -contract ITokenVendor { - - - function buyTokenRate() public view returns (uint256); - - function sellTokenRate() public returns (uint256); - - function totalBuyTokenTransfered() public returns (uint256); - - function totalBuyEtherCollected() public returns (uint256); - - function totalSellEthTransfered() public returns (uint256); - - function totalSellTokenCollected() public returns (uint256); - - function tokenFallback(address _from, uint256 _value, bytes _data) public; - - function buyToken(address _th) public payable returns (bool); - - function sellToken(address _th, uint256 _value) public returns (bool); - - function changeBuyTokenRate(uint256 _newBuyTokenRate) public; - - function changeSellTokenRate(uint256 _newSellTokenRate) public; - - function claimTokens(address _token) public; - -} \ No newline at end of file diff --git a/flat/IUserPoints.sol b/flat/IUserPoints.sol deleted file mode 100644 index e70491f..0000000 --- a/flat/IUserPoints.sol +++ /dev/null @@ -1,16 +0,0 @@ -// Root file: contracts/interfaces/IUserPoints.sol - -pragma solidity ^0.4.24; - -contract IUserPoints { - event AddedPoints(address indexed user, uint256 pointAmount); - event SubedPoints(address indexed user, uint256 pointAmount); - - function addPoints(address _user, uint256 _pointAmount) public; - - function subPoints(address _user, uint256 _pointAmount) public; - - function pointsSupply() public view returns (uint256); - - function pointsBalanceOf(address _user) public view returns (uint256); -} diff --git a/flat/InterstellarEncoder.sol b/flat/InterstellarEncoder.sol deleted file mode 100644 index 1a4600b..0000000 --- a/flat/InterstellarEncoder.sol +++ /dev/null @@ -1,157 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol - -// pragma solidity ^0.4.24; - - -/** - * @title Ownable - * @dev The Ownable contract has an owner address, and provides basic authorization control - * functions, this simplifies the implementation of "user permissions". - */ -contract Ownable { - address public owner; - - - event OwnershipRenounced(address indexed previousOwner); - event OwnershipTransferred( - address indexed previousOwner, - address indexed newOwner - ); - - - /** - * @dev The Ownable constructor sets the original `owner` of the contract to the sender - * account. - */ - constructor() public { - owner = msg.sender; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - /** - * @dev Allows the current owner to relinquish control of the contract. - * @notice Renouncing to ownership will leave the contract without an owner. - * It will not be possible to call the functions with the `onlyOwner` - * modifier anymore. - */ - function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner); - owner = address(0); - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function transferOwnership(address _newOwner) public onlyOwner { - _transferOwnership(_newOwner); - } - - /** - * @dev Transfers control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function _transferOwnership(address _newOwner) internal { - require(_newOwner != address(0)); - emit OwnershipTransferred(owner, _newOwner); - owner = _newOwner; - } -} - - -// Dependency file: contracts/interfaces/IInterstellarEncoder.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoder { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function registerNewTokenContract(address _tokenAddress) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); -} - -// Root file: contracts/InterstellarEncoder.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -// import "contracts/interfaces/IInterstellarEncoder.sol"; - -contract InterstellarEncoder is IInterstellarEncoder, Ownable { - // [magic_number, chain_id, contract_id <2>, origin_chain_id, origin_contract_id<2>, object_class, convert_type, <6>, land, <128>] - mapping(uint16 => address) public contractId2Address; - mapping(address => uint16) public contractAddress2Id; - - mapping(address => uint8) public objectContract2ObjectClass; - - uint16 public lastContractId = 0; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectId) public view returns (uint256 _tokenId) { - uint16 contractId = contractAddress2Id[_tokenAddress]; - require(contractAddress2Id[_tokenAddress] > 0, "Contract address does not exist"); - - _tokenId = (MAGIC_NUMBER << 248) + (CHAIN_ID << 240) + (uint256(contractId) << 224) - + (CHAIN_ID << 216) + (uint256(contractId) << 200) + (uint256(_objectClass) << 192) + (CURRENT_LAND << 128) + uint256(_objectId); - } - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId) { - require (objectContract2ObjectClass[_objectContract] > 0, "Object class for this object contract does not exist."); - - _tokenId = encodeTokenId(_tokenAddress, objectContract2ObjectClass[_objectContract], _objectId); - } - - function registerNewTokenContract(address _tokenAddress) public onlyOwner { - require(contractAddress2Id[_tokenAddress] == 0, "Contract address already exist"); - require(lastContractId < 65535, "Contract Id already reach maximum."); - - lastContractId += 1; - - contractAddress2Id[_tokenAddress] = lastContractId; - contractId2Address[lastContractId] = _tokenAddress; - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public onlyOwner { - objectContract2ObjectClass[_objectContract] = objectClass; - } - - function getContractAddress(uint256 _tokenId) public view returns (address) { - return contractId2Address[uint16((_tokenId << 16) >> 240)]; - } - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId) { - return uint128(_tokenId & CLEAR_HIGH); - } -} \ No newline at end of file diff --git a/flat/InterstellarEncoderV2.sol b/flat/InterstellarEncoderV2.sol deleted file mode 100644 index 178b79c..0000000 --- a/flat/InterstellarEncoderV2.sol +++ /dev/null @@ -1,170 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol - -// pragma solidity ^0.4.24; - - -/** - * @title Ownable - * @dev The Ownable contract has an owner address, and provides basic authorization control - * functions, this simplifies the implementation of "user permissions". - */ -contract Ownable { - address public owner; - - - event OwnershipRenounced(address indexed previousOwner); - event OwnershipTransferred( - address indexed previousOwner, - address indexed newOwner - ); - - - /** - * @dev The Ownable constructor sets the original `owner` of the contract to the sender - * account. - */ - constructor() public { - owner = msg.sender; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - /** - * @dev Allows the current owner to relinquish control of the contract. - * @notice Renouncing to ownership will leave the contract without an owner. - * It will not be possible to call the functions with the `onlyOwner` - * modifier anymore. - */ - function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner); - owner = address(0); - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function transferOwnership(address _newOwner) public onlyOwner { - _transferOwnership(_newOwner); - } - - /** - * @dev Transfers control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function _transferOwnership(address _newOwner) internal { - require(_newOwner != address(0)); - emit OwnershipTransferred(owner, _newOwner); - owner = _newOwner; - } -} - - -// Dependency file: contracts/interfaces/IInterstellarEncoder.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoder { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function registerNewTokenContract(address _tokenAddress) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); -} - -// Root file: contracts/InterstellarEncoderV2.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -// import "contracts/interfaces/IInterstellarEncoder.sol"; - -// TODO: upgrade. -contract InterstellarEncoderV2 is IInterstellarEncoder, Ownable { - // [magic_number, chain_id, contract_id <2>, origin_chain_id, origin_contract_id<2>, object_class, convert_type, <6>, land, <128>] - mapping(uint16 => address) public contractId2Address; - mapping(address => uint16) public contractAddress2Id; - - mapping(address => uint8) public objectContract2ObjectClass; - - uint16 public lastContractId = 0; - - // extended since V2 - mapping(uint8 => address) public objectClass2ObjectContract; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectId) public view returns (uint256 _tokenId) { - uint16 contractId = contractAddress2Id[_tokenAddress]; - require(contractAddress2Id[_tokenAddress] > 0, "Contract address does not exist"); - - _tokenId = (MAGIC_NUMBER << 248) + (CHAIN_ID << 240) + (uint256(contractId) << 224) - + (CHAIN_ID << 216) + (uint256(contractId) << 200) + (uint256(_objectClass) << 192) + (CURRENT_LAND << 128) + uint256(_objectId); - } - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId) { - require (objectContract2ObjectClass[_objectContract] > 0, "Object class for this object contract does not exist."); - - _tokenId = encodeTokenId(_tokenAddress, objectContract2ObjectClass[_objectContract], _objectId); - } - - function registerNewTokenContract(address _tokenAddress) public onlyOwner { - require(contractAddress2Id[_tokenAddress] == 0, "Contract address already exist"); - require(lastContractId < 65535, "Contract Id already reach maximum."); - - lastContractId += 1; - - contractAddress2Id[_tokenAddress] = lastContractId; - contractId2Address[lastContractId] = _tokenAddress; - } - - function registerNewObjectClass(address _objectContract, uint8 _objectClass) public onlyOwner { - objectContract2ObjectClass[_objectContract] = _objectClass; - objectClass2ObjectContract[_objectClass] = _objectContract; - } - - function getContractAddress(uint256 _tokenId) public view returns (address) { - return contractId2Address[uint16((_tokenId << 16) >> 240)]; - } - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId) { - return uint128(_tokenId & CLEAR_HIGH); - } - - function getObjectClass(uint256 _tokenId) public view returns (uint8) { - return uint8((_tokenId << 56) >> 248); - } - - function getObjectAddress(uint256 _tokenId) public view returns (address) { - return objectClass2ObjectContract[uint8((_tokenId << 56) >> 248)]; - } -} \ No newline at end of file diff --git a/flat/InterstellarEncoderV3.sol b/flat/InterstellarEncoderV3.sol deleted file mode 100644 index 25d9182..0000000 --- a/flat/InterstellarEncoderV3.sol +++ /dev/null @@ -1,202 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol - -// pragma solidity ^0.4.24; - - -/** - * @title Ownable - * @dev The Ownable contract has an owner address, and provides basic authorization control - * functions, this simplifies the implementation of "user permissions". - */ -contract Ownable { - address public owner; - - - event OwnershipRenounced(address indexed previousOwner); - event OwnershipTransferred( - address indexed previousOwner, - address indexed newOwner - ); - - - /** - * @dev The Ownable constructor sets the original `owner` of the contract to the sender - * account. - */ - constructor() public { - owner = msg.sender; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - /** - * @dev Allows the current owner to relinquish control of the contract. - * @notice Renouncing to ownership will leave the contract without an owner. - * It will not be possible to call the functions with the `onlyOwner` - * modifier anymore. - */ - function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner); - owner = address(0); - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function transferOwnership(address _newOwner) public onlyOwner { - _transferOwnership(_newOwner); - } - - /** - * @dev Transfers control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function _transferOwnership(address _newOwner) internal { - require(_newOwner != address(0)); - emit OwnershipTransferred(owner, _newOwner); - owner = _newOwner; - } -} - - -// Dependency file: contracts/interfaces/IInterstellarEncoderV3.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoderV3 { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function encodeTokenIdForOuterObjectContract( - address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); - - function getProducerId(uint256 _tokenId) public view returns (uint16); - - function getOriginAddress(uint256 _tokenId) public view returns (address); - -} - -// Root file: contracts/InterstellarEncoderV3.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -// import "contracts/interfaces/IInterstellarEncoderV3.sol"; - -// TODO: upgrade. -contract InterstellarEncoderV3 is IInterstellarEncoderV3, Ownable { - // [magic_number, chain_id, contract_id <2>, origin_chain_id, origin_contract_id<2>, object_class, convert_type, <6>, land, <128>] - mapping(uint8 => address) public ownershipId2Address; - mapping(address => uint8) public ownershipAddress2Id; - - mapping(address => uint8) public classAddress2Id; // class - // extended since V2 - mapping(uint8 => address) public classId2Address; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectId) public view returns (uint256 _tokenId) { - uint16 contractId = ownershipAddress2Id[_tokenAddress]; - require(ownershipAddress2Id[_tokenAddress] > 0, "Contract address does not exist"); - - _tokenId = (MAGIC_NUMBER << 248) + (CHAIN_ID << 240) + (uint256(contractId) << 224) - + (CHAIN_ID << 216) + (uint256(contractId) << 200) + (uint256(_objectClass) << 192) + (CURRENT_LAND << 128) + uint256(_objectId); - } - - function encodeTokenIdForOuter( - address _nftAddress, address _originNftAddress, uint8 _objectClass, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256) { - uint16 contractId = ownershipAddress2Id[_nftAddress]; - uint16 originContractId = ownershipAddress2Id[_originNftAddress]; - require(contractId > 0 && originContractId > 0 && _producerId > 0, "Contract address does not exist"); - - uint256 tokenId = (MAGIC_NUMBER << 248) + (CHAIN_ID << 240) + (uint256(contractId) << 224) - + (CHAIN_ID << 216) + (uint256(originContractId) << 200) + (uint256(_objectClass) << 192) + (uint256(_convertType) << 184)+ (uint256(_producerId) << 128) + uint256(_objectId); - - return tokenId; - } - - // TODO; newly added - // @param _tokenAddress - objectOwnership - // @param _objectContract - xxxBase contract - function encodeTokenIdForOuterObjectContract( - address _objectContract, address _nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256) { - require (classAddress2Id[_objectContract] > 0, "Object class for this object contract does not exist."); - - return encodeTokenIdForOuter(_nftAddress, _originNftAddress, classAddress2Id[_objectContract], _objectId, _producerId, _convertType); - - } - // TODO; newly added - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId) { - require (classAddress2Id[_objectContract] > 0, "Object class for this object contract does not exist."); - - _tokenId = encodeTokenId(_tokenAddress, classAddress2Id[_objectContract], _objectId); - } - - function registerNewOwnershipContract(address _nftAddress, uint8 _nftId) public onlyOwner { - ownershipAddress2Id[_nftAddress] = _nftId; - ownershipId2Address[_nftId] = _nftAddress; - } - - function registerNewObjectClass(address _objectContract, uint8 _objectClass) public onlyOwner { - classAddress2Id[_objectContract] = _objectClass; - classId2Address[_objectClass] = _objectContract; - } - - function getProducerId(uint256 _tokenId) public view returns (uint16) { - return uint16((_tokenId >> 128) & 0xff); - } - - function getContractAddress(uint256 _tokenId) public view returns (address) { - return ownershipId2Address[uint8((_tokenId >> 240) & 0xff)]; - } - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId) { - return uint128(_tokenId & CLEAR_HIGH); - } - - function getObjectClass(uint256 _tokenId) public view returns (uint8) { - return uint8((_tokenId << 56) >> 248); - } - - function getObjectAddress(uint256 _tokenId) public view returns (address) { - return classId2Address[uint8((_tokenId << 56) >> 248)]; - } - - // TODO; newly added - function getOriginAddress(uint256 _tokenId) public view returns (address) { - uint8 originContractId = uint8((_tokenId >> 200) & 0xff); - return ownershipId2Address[originContractId]; - - } -} \ No newline at end of file diff --git a/flat/Issuing.sol b/flat/Issuing.sol deleted file mode 100644 index 1661a45..0000000 --- a/flat/Issuing.sol +++ /dev/null @@ -1,326 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: contracts/PausableDSAuth.sol - -// pragma solidity ^0.4.24; - -// import "contracts/DSAuth.sol"; - - -/** - * @title Pausable - * @dev Base contract which allows children to implement an emergency stop mechanism. - */ -contract PausableDSAuth is DSAuth { - event Pause(); - event Unpause(); - - bool public paused = false; - - - /** - * @dev Modifier to make a function callable only when the contract is not paused. - */ - modifier whenNotPaused() { - require(!paused); - _; - } - - /** - * @dev Modifier to make a function callable only when the contract is paused. - */ - modifier whenPaused() { - require(paused); - _; - } - - /** - * @dev called by the owner to pause, triggers stopped state - */ - function pause() public onlyOwner whenNotPaused { - paused = true; - emit Pause(); - } - - /** - * @dev called by the owner to unpause, returns to normal state - */ - function unpause() public onlyOwner whenPaused { - paused = false; - emit Unpause(); - } -} - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Dependency file: contracts/interfaces/IBurnableERC20.sol - -// pragma solidity ^0.4.23; - -contract IBurnableERC20 { - function burn(address _from, uint _value) public; -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Root file: contracts/Issuing.sol - -pragma solidity ^0.4.24; - -// import "contracts/PausableDSAuth.sol"; -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; -// import "contracts/interfaces/IBurnableERC20.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; - -contract Issuing is PausableDSAuth { - // claimedToken event - event ClaimedTokens( - address indexed token, - address indexed owner, - uint256 amount - ); - - event BurnAndRedeem( - address indexed token, - address indexed from, - uint256 amount, - bytes receiver - ); - - ISettingsRegistry public registry; - - mapping(address => bool) public supportedTokens; - - constructor(address _registry) { - registry = ISettingsRegistry(_registry); - } - - /** - * @dev ERC223 fallback function, make sure to check the msg.sender is from target token contracts - * @param _from - person who transfer token in for deposits or claim deposit with penalty KTON. - * @param _amount - amount of token. - * @param _data - data which indicate the operations. - */ - function tokenFallback( - address _from, - uint256 _amount, - bytes _data - ) public whenNotPaused { - bytes32 darwiniaAddress; - - assembly { - let ptr := mload(0x40) - calldatacopy(ptr, 0, calldatasize) - darwiniaAddress := mload(add(ptr, 132)) - } - - // Only supported tokens can be called - require(supportedTokens[msg.sender], "Permission denied"); - require( - _data.length == 32, - "The address (Darwinia Network) must be in a 32 bytes hexadecimal format" - ); - require( - darwiniaAddress != bytes32(0), - "Darwinia Network Address can't be empty" - ); - - // SettingIds.UINT_BRIDGE_FEE - uint256 bridgeFee = registry.uintOf( - 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - ); - - // SettingIds.CONTRACT_BRIDGE_POOL - address bridgePool = registry.addressOf( - 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - ); - - // SettingIds.CONTRACT_RING_ERC20_TOKEN - address ring = registry.addressOf( - 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - ); - - // BridgeFee will be paid to the relayer - if (bridgeFee > 0) { - require( - ERC20(ring).transferFrom(_from, bridgePool, bridgeFee), - "Error when paying transaction fees" - ); - } - - IBurnableERC20(msg.sender).burn(address(this), _amount); - emit BurnAndRedeem(msg.sender, _from, _amount, _data); - } - - function addSupportedTokens(address _token) public auth { - supportedTokens[_token] = true; - } - - function removeSupportedTokens(address _token) public auth { - supportedTokens[_token] = false; - } - - /// @notice This method can be used by the owner to extract mistakenly - /// sent tokens to this contract. - /// @param _token The address of the token contract that you want to recover - /// set to 0 in case you want to extract ether. - function claimTokens(address _token) public auth { - if (_token == 0x0) { - owner.transfer(address(this).balance); - return; - } - ERC20 token = ERC20(_token); - uint256 balance = token.balanceOf(address(this)); - token.transfer(owner, balance); - - emit ClaimedTokens(_token, owner, balance); - } -} diff --git a/flat/KtonVoter.sol b/flat/KtonVoter.sol deleted file mode 100644 index 4c596db..0000000 --- a/flat/KtonVoter.sol +++ /dev/null @@ -1,143 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Root file: contracts/KtonVoter.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; - -/// @title KtonVoter -/// @dev Voting and support specific proposal validator by deposit KTON -/// Vote will be cancel after KTON get withdrawd -/// 1 KTON means one vote -contract KtonVoter { - address public KTON; - - struct VoterItem { - // mapping (address => mapping (address => uint256)) public votes; - mapping (address => uint256) votes; - // mapping (address => uint256) public depositBalances; - uint256 balance; - // TODO: address[] candidates; - } - - struct CandidateItem { - uint256 voteCount; // contract address - uint256 sortedIndex; // index of the item in the list of sortedCandidate - bool isRegistered; // used to tell if the mapping element is defined - // TODO: address[] voters; - } - - mapping (address => VoterItem) public voterItems; - - mapping (address => CandidateItem) public cadidateItems; - - // descending - address[] public sortedCandidates; - - function vote(address _candidate, uint _amount) public { - require(cadidateItems[_candidate].isRegistered); - require(ERC20(KTON).transferFrom(msg.sender, address(this), _amount)); - - voterItems[msg.sender].votes[_candidate] += _amount; - voterItems[msg.sender].balance += _amount; - - cadidateItems[_candidate].voteCount += _amount; - - // TODO: update sortedIndex - quickSort(0, cadidateItems[_candidate].sortedIndex); - } - - function withdrawFrom(address _candidate, uint _amount) public { - require(voterItems[msg.sender].votes[_candidate] >= _amount); - - voterItems[msg.sender].votes[_candidate] -= _amount; - voterItems[msg.sender].balance -= _amount; - cadidateItems[_candidate].voteCount -= _amount; - - require(ERC20(KTON).transfer(msg.sender, _amount)); - - // TODO: update sortedIndex - quickSort(cadidateItems[_candidate].sortedIndex, sortedCandidates.length - 1); - } - - function getCandidate(uint _num) public view returns (address candidate){ - require(_num < sortedCandidates.length); - candidate = sortedCandidates[_num]; - } - - function registerCandidate() public { - // require(ERC20(KTON).transferFrom(msg.sender, address(this), 1000000000000000000000)); - require(!cadidateItems[msg.sender].isRegistered); - - cadidateItems[msg.sender].isRegistered = true; - sortedCandidates.push(msg.sender); - cadidateItems[msg.sender].sortedIndex = sortedCandidates.length - 1; - } - - // http://www.etherdevops.com/content/sorting-array-integer-ethereum - function quickSort(uint left, uint right) internal { - uint i = left; - uint j = right; - uint pivot = cadidateItems[sortedCandidates[left + (right - left) / 2]].voteCount; - while (i <= j) { - while (cadidateItems[sortedCandidates[i]].voteCount < pivot) i++; - while (pivot < cadidateItems[sortedCandidates[j]].voteCount) j--; - if (i <= j) { - (sortedCandidates[i], sortedCandidates[j]) = (sortedCandidates[j], sortedCandidates[i]); - cadidateItems[sortedCandidates[i]].sortedIndex = i; - cadidateItems[sortedCandidates[j]].sortedIndex = j; - - i++; - j--; - } - } - if (left < j) - quickSort(left, j); - if (i < right) - quickSort(i, right); - } -} \ No newline at end of file diff --git a/flat/LocationCoder.sol b/flat/LocationCoder.sol deleted file mode 100644 index cc843dc..0000000 --- a/flat/LocationCoder.sol +++ /dev/null @@ -1,82 +0,0 @@ -// Root file: contracts/LocationCoder.sol - -pragma solidity ^0.4.24; - -library LocationCoder { - // the allocation of the [x, y, z] is [0<1>, x<21>, y<21>, z<21>] - uint256 constant CLEAR_YZ = 0x0fffffffffffffffffffff000000000000000000000000000000000000000000; - uint256 constant CLEAR_XZ = 0x0000000000000000000000fffffffffffffffffffff000000000000000000000; - uint256 constant CLEAR_XY = 0x0000000000000000000000000000000000000000000fffffffffffffffffffff; - - uint256 constant NOT_ZERO = 0x1000000000000000000000000000000000000000000000000000000000000000; - uint256 constant APPEND_HIGH = 0xfffffffffffffffffffffffffffffffffffffffffff000000000000000000000; - - uint256 constant MAX_LOCATION_ID = 0x2000000000000000000000000000000000000000000000000000000000000000; - - int256 constant HMETER_DECIMAL = 10 ** 8; - - // x, y, z should between -2^83 (-9671406556917033397649408) and 2^83 - 1 (9671406556917033397649407). - int256 constant MIN_Location_XYZ = -9671406556917033397649408; - int256 constant MAX_Location_XYZ = 9671406556917033397649407; - // 96714065569170334.50000000 - int256 constant MAX_HM_DECIMAL = 9671406556917033450000000; - int256 constant MAX_HM = 96714065569170334; - - function encodeLocationIdXY(int _x, int _y) internal pure returns (uint result) { - return encodeLocationId3D(_x, _y, 0); - } - - function decodeLocationIdXY(uint _positionId) internal pure returns (int _x, int _y) { - (_x, _y, ) = decodeLocationId3D(_positionId); - } - - function encodeLocationId3D(int _x, int _y, int _z) internal pure returns (uint result) { - return _unsafeEncodeLocationId3D(_x, _y, _z); - } - - function _unsafeEncodeLocationId3D(int _x, int _y, int _z) internal pure returns (uint) { - require(_x >= MIN_Location_XYZ && _x <= MAX_Location_XYZ, "Invalid value."); - require(_y >= MIN_Location_XYZ && _y <= MAX_Location_XYZ, "Invalid value."); - require(_z >= MIN_Location_XYZ && _z <= MAX_Location_XYZ, "Invalid value."); - - // uint256 constant FACTOR_2 = 0x1000000000000000000000000000000000000000000; // <16 ** 42> or <2 ** 168> - // uint256 constant FACTOR = 0x1000000000000000000000; // <16 ** 21> or <2 ** 84> - return ((uint(_x) << 168) & CLEAR_YZ) | (uint(_y << 84) & CLEAR_XZ) | (uint(_z) & CLEAR_XY) | NOT_ZERO; - } - - function decodeLocationId3D(uint _positionId) internal pure returns (int, int, int) { - return _unsafeDecodeLocationId3D(_positionId); - } - - function _unsafeDecodeLocationId3D(uint _value) internal pure returns (int x, int y, int z) { - require(_value >= NOT_ZERO && _value < MAX_LOCATION_ID, "Invalid Location Id"); - - x = expandNegative84BitCast((_value & CLEAR_YZ) >> 168); - y = expandNegative84BitCast((_value & CLEAR_XZ) >> 84); - z = expandNegative84BitCast(_value & CLEAR_XY); - } - - function toHM(int _x) internal pure returns (int) { - return (_x + MAX_HM_DECIMAL)/HMETER_DECIMAL - MAX_HM; - } - - function toUM(int _x) internal pure returns (int) { - return _x * LocationCoder.HMETER_DECIMAL; - } - - function expandNegative84BitCast(uint _value) internal pure returns (int) { - if (_value & (1<<83) != 0) { - return int(_value | APPEND_HIGH); - } - return int(_value); - } - - function encodeLocationIdHM(int _x, int _y) internal pure returns (uint result) { - return encodeLocationIdXY(toUM(_x), toUM(_y)); - } - - function decodeLocationIdHM(uint _positionId) internal pure returns (int, int) { - (int _x, int _y) = decodeLocationIdXY(_positionId); - return (toHM(_x), toHM(_y)); - } -} \ No newline at end of file diff --git a/flat/Migrations.sol b/flat/Migrations.sol deleted file mode 100644 index c82b119..0000000 --- a/flat/Migrations.sol +++ /dev/null @@ -1,213 +0,0 @@ -// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/Proxy.sol - -// pragma solidity ^0.4.21; - -/** - * @title Proxy - * @dev Gives the possibility to delegate any call to a foreign implementation. - */ -contract Proxy { - /** - * @dev Tells the address of the implementation where every call will be delegated. - * @return address of the implementation to which it will be delegated - */ - function implementation() public view returns (address); - - /** - * @dev Fallback function allowing to perform a delegatecall to the given implementation. - * This function will return whatever the implementation call returns - */ - function () payable public { - address _impl = implementation(); - require(_impl != address(0)); - - assembly { - let ptr := mload(0x40) - calldatacopy(ptr, 0, calldatasize) - let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0) - let size := returndatasize - returndatacopy(ptr, 0, size) - - switch result - case 0 { revert(ptr, size) } - default { return(ptr, size) } - } - } -} - - -// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/UpgradeabilityProxy.sol - -// pragma solidity ^0.4.21; - -// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/@evolutionland/upgraeability-using-unstructured-storage/contracts/Proxy.sol'; - -/** - * @title UpgradeabilityProxy - * @dev This contract represents a proxy where the implementation address to which it will delegate can be upgraded - */ -contract UpgradeabilityProxy is Proxy { - /** - * @dev This event will be emitted every time the implementation gets upgraded - * @param implementation representing the address of the upgraded implementation - */ - event Upgraded(address indexed implementation); - - // Storage position of the address of the current implementation - bytes32 private constant implementationPosition = keccak256("org.zeppelinos.proxy.implementation"); - - /** - * @dev Constructor function - */ - function UpgradeabilityProxy() public {} - - /** - * @dev Tells the address of the current implementation - * @return address of the current implementation - */ - function implementation() public view returns (address impl) { - bytes32 position = implementationPosition; - assembly { - impl := sload(position) - } - } - - /** - * @dev Sets the address of the current implementation - * @param newImplementation address representing the new implementation to be set - */ - function setImplementation(address newImplementation) internal { - bytes32 position = implementationPosition; - assembly { - sstore(position, newImplementation) - } - } - - /** - * @dev Upgrades the implementation address - * @param newImplementation representing the address of the new implementation to be set - */ - function _upgradeTo(address newImplementation) internal { - address currentImplementation = implementation(); - require(currentImplementation != newImplementation); - setImplementation(newImplementation); - emit Upgraded(newImplementation); - } -} - - -// Dependency file: @evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol - -// pragma solidity ^0.4.21; - -// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/@evolutionland/upgraeability-using-unstructured-storage/contracts/UpgradeabilityProxy.sol'; - -/** - * @title OwnedUpgradeabilityProxy - * @dev This contract combines an upgradeability proxy with basic authorization control functionalities - */ -contract OwnedUpgradeabilityProxy is UpgradeabilityProxy { - /** - * @dev Event to show ownership has been transferred - * @param previousOwner representing the address of the previous owner - * @param newOwner representing the address of the new owner - */ - event ProxyOwnershipTransferred(address previousOwner, address newOwner); - - // Storage position of the owner of the contract - bytes32 private constant proxyOwnerPosition = keccak256("org.zeppelinos.proxy.owner"); - - /** - * @dev the constructor sets the original owner of the contract to the sender account. - */ - function OwnedUpgradeabilityProxy() public { - setUpgradeabilityOwner(msg.sender); - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyProxyOwner() { - require(msg.sender == proxyOwner()); - _; - } - - /** - * @dev Tells the address of the owner - * @return the address of the owner - */ - function proxyOwner() public view returns (address owner) { - bytes32 position = proxyOwnerPosition; - assembly { - owner := sload(position) - } - } - - /** - * @dev Sets the address of the owner - */ - function setUpgradeabilityOwner(address newProxyOwner) internal { - bytes32 position = proxyOwnerPosition; - assembly { - sstore(position, newProxyOwner) - } - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param newOwner The address to transfer ownership to. - */ - function transferProxyOwnership(address newOwner) public onlyProxyOwner { - require(newOwner != address(0)); - emit ProxyOwnershipTransferred(proxyOwner(), newOwner); - setUpgradeabilityOwner(newOwner); - } - - /** - * @dev Allows the proxy owner to upgrade the current version of the proxy. - * @param implementation representing the address of the new implementation to be set. - */ - function upgradeTo(address implementation) public onlyProxyOwner { - _upgradeTo(implementation); - } - - /** - * @dev Allows the proxy owner to upgrade the current version of the proxy and call the new implementation - * to initialize whatever is needed through a low level call. - * @param implementation representing the address of the new implementation to be set. - * @param data represents the msg.data to bet sent in the low level call. This parameter may include the function - * signature of the implementation to be called with the needed payload - */ - function upgradeToAndCall(address implementation, bytes data) payable public onlyProxyOwner { - upgradeTo(implementation); - require(this.call.value(msg.value)(data)); - } -} - - -// Root file: contracts/Migrations.sol - -pragma solidity ^0.4.23; -// import "@evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol"; - -contract Migrations { - address public owner; - uint public last_completed_migration; - - constructor() public { - owner = msg.sender; - } - - modifier restricted() { - if (msg.sender == owner) _; - } - - function setCompleted(uint completed) public restricted { - last_completed_migration = completed; - } - - function upgrade(address new_address) public restricted { - Migrations upgraded = Migrations(new_address); - upgraded.setCompleted(last_completed_migration); - } -} diff --git a/flat/MintAndBurnAuthority.sol b/flat/MintAndBurnAuthority.sol deleted file mode 100644 index ec892ee..0000000 --- a/flat/MintAndBurnAuthority.sol +++ /dev/null @@ -1,21 +0,0 @@ -// Root file: contracts/MintAndBurnAuthority.sol - -pragma solidity ^0.4.24; - -contract MintAndBurnAuthority { - - mapping (address => bool) public whiteList; - - constructor(address[] _whitelists) public { - for (uint i = 0; i < _whitelists.length; i ++) { - whiteList[_whitelists[i]] = true; - } - } - - function canCall( - address _src, address _dst, bytes4 _sig - ) public view returns (bool) { - return ( whiteList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || - ( whiteList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); - } -} diff --git a/flat/MintAndBurnAuthorityV2.sol b/flat/MintAndBurnAuthorityV2.sol deleted file mode 100644 index 5cec0bf..0000000 --- a/flat/MintAndBurnAuthorityV2.sol +++ /dev/null @@ -1,21 +0,0 @@ -// Root file: contracts/MintAndBurnAuthorityV2.sol - -pragma solidity ^0.4.24; - -contract MintAndBurnAuthorityV2 { - - mapping (address => bool) public allowList; - - constructor(address[] _allowlists) public { - for (uint i = 0; i < _allowlists.length; i ++) { - allowList[_allowlists[i]] = true; - } - } - - function canCall( - address _src, address _dst, bytes4 _sig - ) public view returns (bool) { - return ( allowList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || - ( allowList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); - } -} diff --git a/flat/MintAndBurnMutableAuthority.sol b/flat/MintAndBurnMutableAuthority.sol deleted file mode 100644 index 6dadc65..0000000 --- a/flat/MintAndBurnMutableAuthority.sol +++ /dev/null @@ -1,104 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Root file: contracts/MintAndBurnMutableAuthority.sol - -pragma solidity ^0.4.24; - -// import "contracts/DSAuth.sol"; - -contract MintAndBurnAuthority is DSAuth { - - mapping (address => bool) public allowList; - - constructor(address[] _allowlists) public { - for (uint i = 0; i < _allowlists.length; i ++) { - allowList[_allowlists[i]] = true; - } - } - - function canCall( - address _src, address _dst, bytes4 _sig - ) public view returns (bool) { - return ( allowList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || - ( allowList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); - } - - function addAllowAddress(address allowAddress) public onlyOwner{ - allowList[allowAddress] = true; - } - - function removeAllowAddress(address allowAddress) public onlyOwner{ - allowList[allowAddress] = false; - } -} diff --git a/flat/MultiSigWallet.sol b/flat/MultiSigWallet.sol deleted file mode 100644 index 7f66af4..0000000 --- a/flat/MultiSigWallet.sol +++ /dev/null @@ -1,368 +0,0 @@ -// Root file: contracts/MultiSigWallet.sol - -pragma solidity ^0.4.17; - - -/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. -/// @author Stefan George - -contract MultiSigWallet { - - uint constant public MAX_OWNER_COUNT = 50; - - event Confirmation(address indexed _sender, uint indexed _transactionId); - event Revocation(address indexed _sender, uint indexed _transactionId); - event Submission(uint indexed _transactionId); - event Execution(uint indexed _transactionId); - event ExecutionFailure(uint indexed _transactionId); - event Deposit(address indexed _sender, uint _value); - event OwnerAddition(address indexed _owner); - event OwnerRemoval(address indexed _owner); - event RequirementChange(uint _required); - - mapping (uint => Transaction) public transactions; - mapping (uint => mapping (address => bool)) public confirmations; - mapping (address => bool) public isOwner; - address[] public owners; - uint public required; - uint public transactionCount; - - struct Transaction { - address destination; - uint value; - bytes data; - bool executed; - } - - modifier onlyWallet() { - if (msg.sender != address(this)) - throw; - _; - } - - modifier ownerDoesNotExist(address owner) { - if (isOwner[owner]) - throw; - _; - } - - modifier ownerExists(address owner) { - if (!isOwner[owner]) - throw; - _; - } - - modifier transactionExists(uint transactionId) { - if (transactions[transactionId].destination == 0) - throw; - _; - } - - modifier confirmed(uint transactionId, address owner) { - if (!confirmations[transactionId][owner]) - throw; - _; - } - - modifier notConfirmed(uint transactionId, address owner) { - if (confirmations[transactionId][owner]) - throw; - _; - } - - modifier notExecuted(uint transactionId) { - if (transactions[transactionId].executed) - throw; - _; - } - - modifier notNull(address _address) { - if (_address == 0) - throw; - _; - } - - modifier validRequirement(uint ownerCount, uint _required) { - if ( ownerCount > MAX_OWNER_COUNT - || _required > ownerCount - || _required == 0 - || ownerCount == 0) - throw; - _; - } - - /// @dev Fallback function allows to deposit ether. - function() - payable - { - if (msg.value > 0) - Deposit(msg.sender, msg.value); - } - - /* - * Public functions - */ - /// @dev Contract constructor sets initial owners and required number of confirmations. - /// @param _owners List of initial owners. - /// @param _required Number of required confirmations. - function MultiSigWallet(address[] _owners, uint _required) - public - validRequirement(_owners.length, _required) - { - for (uint i=0; i<_owners.length; i++) { - if (isOwner[_owners[i]] || _owners[i] == 0) - throw; - isOwner[_owners[i]] = true; - } - owners = _owners; - required = _required; - } - - /// @dev Allows to add a new owner. Transaction has to be sent by wallet. - /// @param owner Address of new owner. - function addOwner(address owner) - public - onlyWallet - ownerDoesNotExist(owner) - notNull(owner) - validRequirement(owners.length + 1, required) - { - isOwner[owner] = true; - owners.push(owner); - OwnerAddition(owner); - } - - /// @dev Allows to remove an owner. Transaction has to be sent by wallet. - /// @param owner Address of owner. - function removeOwner(address owner) - public - onlyWallet - ownerExists(owner) - { - isOwner[owner] = false; - for (uint i=0; i owners.length) - changeRequirement(owners.length); - OwnerRemoval(owner); - } - - /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. - /// @param owner Address of owner to be replaced. - /// @param owner Address of new owner. - function replaceOwner(address owner, address newOwner) - public - onlyWallet - ownerExists(owner) - ownerDoesNotExist(newOwner) - { - for (uint i=0; i 0); // Solidity automatically throws when dividing by 0 - // uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - return _a / _b; - } - - /** - * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - assert(_b <= _a); - return _a - _b; - } - - /** - * @dev Adds two numbers, throws on overflow. - */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - c = _a + _b; - assert(c >= _a); - return c; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/AddressUtils.sol - -// pragma solidity ^0.4.24; - - -/** - * Utility library of inline functions on addresses - */ -library AddressUtils { - - /** - * Returns whether the target address is a contract - * @dev This function will return false if invoked during the constructor of a contract, - * as the code is not actually created until after the constructor finishes. - * @param _addr address to check - * @return whether the target address is a contract - */ - function isContract(address _addr) internal view returns (bool) { - uint256 size; - // XXX Currently there is no better way to check if there is a contract in an address - // than to check the size of the code at that address. - // See https://ethereum.stackexchange.com/a/14016/36603 - // for more details about how this works. - // TODO Check this again before the Serenity release, because all addresses will be - // contracts then. - // solium-disable-next-line security/no-inline-assembly - assembly { size := extcodesize(_addr) } - return size > 0; - } - -} - - -// Dependency file: openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - - -/** - * @title SupportsInterfaceWithLookup - * @author Matt Condon (@shrugs) - * @dev Implements ERC165 using a lookup table. - */ -contract SupportsInterfaceWithLookup is ERC165 { - - bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; - /** - * 0x01ffc9a7 === - * bytes4(keccak256('supportsInterface(bytes4)')) - */ - - /** - * @dev a mapping of interface id to whether or not it's supported - */ - mapping(bytes4 => bool) internal supportedInterfaces; - - /** - * @dev A contract implementing SupportsInterfaceWithLookup - * implement ERC165 itself - */ - constructor() - public - { - _registerInterface(InterfaceId_ERC165); - } - - /** - * @dev implement supportsInterface(bytes4) using a lookup table - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool) - { - return supportedInterfaces[_interfaceId]; - } - - /** - * @dev private method for registering an interface - */ - function _registerInterface(bytes4 _interfaceId) - internal - { - require(_interfaceId != 0xffffffff); - supportedInterfaces[_interfaceId] = true; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721BasicToken.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol"; -// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -// import "openzeppelin-solidity/contracts/AddressUtils.sol"; -// import "openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.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 SupportsInterfaceWithLookup, ERC721Basic { - - 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; - - // Mapping from token ID to owner - mapping (uint256 => address) internal tokenOwner; - - // Mapping from token ID to approved address - mapping (uint256 => address) internal tokenApprovals; - - // Mapping from owner to number of owned token - mapping (address => uint256) internal ownedTokensCount; - - // Mapping from owner to operator approvals - mapping (address => mapping (address => bool)) internal operatorApprovals; - - constructor() - public - { - // register the supported interfaces to conform to ERC721 via ERC165 - _registerInterface(InterfaceId_ERC721); - _registerInterface(InterfaceId_ERC721Exists); - } - - /** - * @dev Gets the balance of the specified address - * @param _owner address to query the balance of - * @return uint256 representing the amount owned by the passed address - */ - function balanceOf(address _owner) public view returns (uint256) { - require(_owner != address(0)); - return ownedTokensCount[_owner]; - } - - /** - * @dev Gets the owner of the specified token ID - * @param _tokenId uint256 ID of the token to query the owner of - * @return owner address currently marked as the owner of the given token ID - */ - function ownerOf(uint256 _tokenId) public view returns (address) { - address owner = tokenOwner[_tokenId]; - require(owner != address(0)); - return owner; - } - - /** - * @dev Returns whether the specified token exists - * @param _tokenId uint256 ID of the token to query the existence of - * @return whether the token exists - */ - function exists(uint256 _tokenId) public view returns (bool) { - address owner = tokenOwner[_tokenId]; - return owner != address(0); - } - - /** - * @dev Approves another address to transfer the given token ID - * The zero address indicates there is no approved address. - * There can only be one approved address per token at a given time. - * Can only be called by the token owner or an approved operator. - * @param _to address to be approved for the given token ID - * @param _tokenId uint256 ID of the token to be approved - */ - function approve(address _to, uint256 _tokenId) public { - address owner = ownerOf(_tokenId); - require(_to != owner); - require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); - - tokenApprovals[_tokenId] = _to; - emit Approval(owner, _to, _tokenId); - } - - /** - * @dev Gets the approved address for a token ID, or zero if no address set - * @param _tokenId uint256 ID of the token to query the approval of - * @return address currently approved for the given token ID - */ - function getApproved(uint256 _tokenId) public view returns (address) { - return tokenApprovals[_tokenId]; - } - - /** - * @dev Sets or unsets the approval of a given operator - * An operator is allowed to transfer all tokens of the sender on their behalf - * @param _to operator address to set the approval - * @param _approved representing the status of the approval to be set - */ - function setApprovalForAll(address _to, bool _approved) public { - require(_to != msg.sender); - operatorApprovals[msg.sender][_to] = _approved; - emit ApprovalForAll(msg.sender, _to, _approved); - } - - /** - * @dev Tells whether an operator is approved by a given owner - * @param _owner owner address which you want to query the approval of - * @param _operator operator address which you want to query the approval of - * @return bool whether the given operator is approved by the given owner - */ - function isApprovedForAll( - address _owner, - address _operator - ) - public - view - returns (bool) - { - return operatorApprovals[_owner][_operator]; - } - - /** - * @dev Transfers the ownership of a given token ID to another address - * Usage of this method is discouraged, use `safeTransferFrom` whenever possible - * Requires the msg sender to be the owner, approved, or operator - * @param _from current owner of the token - * @param _to address to receive the ownership of the given token ID - * @param _tokenId uint256 ID of the token to be transferred - */ - function transferFrom( - address _from, - address _to, - uint256 _tokenId - ) - public - { - require(isApprovedOrOwner(msg.sender, _tokenId)); - require(_from != address(0)); - require(_to != address(0)); - - clearApproval(_from, _tokenId); - removeTokenFrom(_from, _tokenId); - addTokenTo(_to, _tokenId); - - emit Transfer(_from, _to, _tokenId); - } - - /** - * @dev Safely transfers the ownership of a given token ID to another address - * If the target address is a contract, it must implement `onERC721Received`, - * which is called upon a safe transfer, and return the magic value - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, - * the transfer is reverted. - * - * Requires the msg sender to be the owner, approved, or operator - * @param _from current owner of the token - * @param _to address to receive the ownership of the given token ID - * @param _tokenId uint256 ID of the token to be transferred - */ - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId - ) - public - { - // solium-disable-next-line arg-overflow - safeTransferFrom(_from, _to, _tokenId, ""); - } - - /** - * @dev Safely transfers the ownership of a given token ID to another address - * If the target address is a contract, it must implement `onERC721Received`, - * which is called upon a safe transfer, and return the magic value - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, - * the transfer is reverted. - * Requires the msg sender to be the owner, approved, or operator - * @param _from current owner of the token - * @param _to address to receive the ownership of the given token ID - * @param _tokenId uint256 ID of the token to be transferred - * @param _data bytes data to send along with a safe transfer check - */ - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - public - { - transferFrom(_from, _to, _tokenId); - // solium-disable-next-line arg-overflow - require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); - } - - /** - * @dev Returns whether the given spender can transfer a given token ID - * @param _spender address of the spender to query - * @param _tokenId uint256 ID of the token to be transferred - * @return bool whether the msg.sender is approved for the given token ID, - * is an operator of the owner, or is the owner of the token - */ - function isApprovedOrOwner( - address _spender, - uint256 _tokenId - ) - internal - view - returns (bool) - { - address owner = ownerOf(_tokenId); - // Disable solium check because of - // https://github.com/duaraghav8/Solium/issues/175 - // solium-disable-next-line operator-whitespace - return ( - _spender == owner || - getApproved(_tokenId) == _spender || - isApprovedForAll(owner, _spender) - ); - } - - /** - * @dev Internal function to mint a new token - * Reverts if the given token ID already exists - * @param _to The address that will own the minted token - * @param _tokenId uint256 ID of the token to be minted by the msg.sender - */ - function _mint(address _to, uint256 _tokenId) internal { - require(_to != address(0)); - addTokenTo(_to, _tokenId); - emit Transfer(address(0), _to, _tokenId); - } - - /** - * @dev Internal function to burn a specific token - * Reverts if the token does not exist - * @param _tokenId uint256 ID of the token being burned by the msg.sender - */ - function _burn(address _owner, uint256 _tokenId) internal { - clearApproval(_owner, _tokenId); - removeTokenFrom(_owner, _tokenId); - emit Transfer(_owner, address(0), _tokenId); - } - - /** - * @dev Internal function to clear current approval of a given token ID - * Reverts if the given address is not indeed the owner of the token - * @param _owner owner of the token - * @param _tokenId uint256 ID of the token to be transferred - */ - function clearApproval(address _owner, uint256 _tokenId) internal { - require(ownerOf(_tokenId) == _owner); - if (tokenApprovals[_tokenId] != address(0)) { - tokenApprovals[_tokenId] = address(0); - } - } - - /** - * @dev Internal function to add a token ID to the list of a given address - * @param _to address representing the new owner of the given token ID - * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address - */ - function addTokenTo(address _to, uint256 _tokenId) internal { - require(tokenOwner[_tokenId] == address(0)); - tokenOwner[_tokenId] = _to; - ownedTokensCount[_to] = ownedTokensCount[_to].add(1); - } - - /** - * @dev Internal function to remove a token ID from the list of a given address - * @param _from address representing the previous owner of the given token ID - * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address - */ - function removeTokenFrom(address _from, uint256 _tokenId) internal { - require(ownerOf(_tokenId) == _from); - ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); - tokenOwner[_tokenId] = address(0); - } - - /** - * @dev Internal function to invoke `onERC721Received` on a target address - * The call is not executed if the target address is not a contract - * @param _from address representing the previous owner of the given token ID - * @param _to target address that will receive the tokens - * @param _tokenId uint256 ID of the token to be transferred - * @param _data bytes optional data to send along with the call - * @return whether the call correctly returned the expected magic value - */ - function checkAndCallSafeTransfer( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - internal - returns (bool) - { - if (!_to.isContract()) { - return true; - } - bytes4 retval = ERC721Receiver(_to).onERC721Received( - msg.sender, _from, _tokenId, _data); - return (retval == ERC721_RECEIVED); - } -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721BasicToken.sol"; -// import "openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.sol"; - - -/** - * @title Full ERC721 Token - * This implementation includes all the required and some optional functionality of the ERC721 standard - * Moreover, it includes approve all functionality using operator terminology - * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 { - - // Token name - string internal name_; - - // Token symbol - string internal symbol_; - - // Mapping from owner to list of owned token IDs - mapping(address => uint256[]) internal ownedTokens; - - // Mapping from token ID to index of the owner tokens list - mapping(uint256 => uint256) internal ownedTokensIndex; - - // Array with all token ids, used for enumeration - uint256[] internal allTokens; - - // Mapping from token id to position in the allTokens array - mapping(uint256 => uint256) internal allTokensIndex; - - // Optional mapping for token URIs - mapping(uint256 => string) internal tokenURIs; - - /** - * @dev Constructor function - */ - constructor(string _name, string _symbol) public { - name_ = _name; - symbol_ = _symbol; - - // register the supported interfaces to conform to ERC721 via ERC165 - _registerInterface(InterfaceId_ERC721Enumerable); - _registerInterface(InterfaceId_ERC721Metadata); - } - - /** - * @dev Gets the token name - * @return string representing the token name - */ - function name() external view returns (string) { - return name_; - } - - /** - * @dev Gets the token symbol - * @return string representing the token symbol - */ - function symbol() external view returns (string) { - return symbol_; - } - - /** - * @dev Returns an URI for a given token ID - * Throws if the token ID does not exist. May return an empty string. - * @param _tokenId uint256 ID of the token to query - */ - function tokenURI(uint256 _tokenId) public view returns (string) { - require(exists(_tokenId)); - return tokenURIs[_tokenId]; - } - - /** - * @dev Gets the token ID at a given index of the tokens list of the requested owner - * @param _owner address owning the tokens list to be accessed - * @param _index uint256 representing the index to be accessed of the requested tokens list - * @return uint256 token ID at the given index of the tokens list owned by the requested address - */ - function tokenOfOwnerByIndex( - address _owner, - uint256 _index - ) - public - view - returns (uint256) - { - require(_index < balanceOf(_owner)); - return ownedTokens[_owner][_index]; - } - - /** - * @dev Gets the total amount of tokens stored by the contract - * @return uint256 representing the total amount of tokens - */ - function totalSupply() public view returns (uint256) { - return allTokens.length; - } - - /** - * @dev Gets the token ID at a given index of all the tokens in this contract - * Reverts if the index is greater or equal to the total number of tokens - * @param _index uint256 representing the index to be accessed of the tokens list - * @return uint256 token ID at the given index of the tokens list - */ - function tokenByIndex(uint256 _index) public view returns (uint256) { - require(_index < totalSupply()); - return allTokens[_index]; - } - - /** - * @dev Internal function to set the token URI for a given token - * Reverts if the token ID does not exist - * @param _tokenId uint256 ID of the token to set its URI - * @param _uri string URI to assign - */ - function _setTokenURI(uint256 _tokenId, string _uri) internal { - require(exists(_tokenId)); - tokenURIs[_tokenId] = _uri; - } - - /** - * @dev Internal function to add a token ID to the list of a given address - * @param _to address representing the new owner of the given token ID - * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address - */ - function addTokenTo(address _to, uint256 _tokenId) internal { - super.addTokenTo(_to, _tokenId); - uint256 length = ownedTokens[_to].length; - ownedTokens[_to].push(_tokenId); - ownedTokensIndex[_tokenId] = length; - } - - /** - * @dev Internal function to remove a token ID from the list of a given address - * @param _from address representing the previous owner of the given token ID - * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address - */ - function removeTokenFrom(address _from, uint256 _tokenId) internal { - super.removeTokenFrom(_from, _tokenId); - - // To prevent a gap in the array, we store the last token in the index of the token to delete, and - // then delete the last slot. - uint256 tokenIndex = ownedTokensIndex[_tokenId]; - uint256 lastTokenIndex = ownedTokens[_from].length.sub(1); - uint256 lastToken = ownedTokens[_from][lastTokenIndex]; - - ownedTokens[_from][tokenIndex] = lastToken; - // This also deletes the contents at the last position of the array - ownedTokens[_from].length--; - - // Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to - // be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping - // the lastToken to the first position, and then dropping the element placed in the last position of the list - - ownedTokensIndex[_tokenId] = 0; - ownedTokensIndex[lastToken] = tokenIndex; - } - - /** - * @dev Internal function to mint a new token - * Reverts if the given token ID already exists - * @param _to address the beneficiary that will own the minted token - * @param _tokenId uint256 ID of the token to be minted by the msg.sender - */ - function _mint(address _to, uint256 _tokenId) internal { - super._mint(_to, _tokenId); - - allTokensIndex[_tokenId] = allTokens.length; - allTokens.push(_tokenId); - } - - /** - * @dev Internal function to burn a specific token - * Reverts if the token does not exist - * @param _owner owner of the token to burn - * @param _tokenId uint256 ID of the token being burned by the msg.sender - */ - function _burn(address _owner, uint256 _tokenId) internal { - super._burn(_owner, _tokenId); - - // Clear metadata (if any) - if (bytes(tokenURIs[_tokenId]).length != 0) { - delete tokenURIs[_tokenId]; - } - - // Reorg all tokens array - uint256 tokenIndex = allTokensIndex[_tokenId]; - uint256 lastTokenIndex = allTokens.length.sub(1); - uint256 lastToken = allTokens[lastTokenIndex]; - - allTokens[tokenIndex] = lastToken; - allTokens[lastTokenIndex] = 0; - - allTokens.length--; - allTokensIndex[_tokenId] = 0; - allTokensIndex[lastToken] = tokenIndex; - } - -} - - -// Dependency file: contracts/interfaces/IInterstellarEncoder.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoder { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function registerNewTokenContract(address _tokenAddress) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Root file: contracts/ObjectOwnership.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol"; -// import "contracts/interfaces/IInterstellarEncoder.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/DSAuth.sol"; -// import "contracts/SettingIds.sol"; - -contract ObjectOwnership is ERC721Token("Evolution Land Objects","EVO"), DSAuth, SettingIds { - ISettingsRegistry public registry; - - bool private singletonLock = false; - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - /** - * @dev Atlantis's constructor - */ - constructor () public { - // initializeContract(); - } - - /** - * @dev Same with constructor, but is used and called by storage proxy as logic contract. - */ - function initializeContract(address _registry) public singletonLockCall { - // Ownable constructor - owner = msg.sender; - emit LogSetOwner(msg.sender); - - // SupportsInterfaceWithLookup constructor - _registerInterface(InterfaceId_ERC165); - - // ERC721BasicToken constructor - _registerInterface(InterfaceId_ERC721); - _registerInterface(InterfaceId_ERC721Exists); - - // ERC721Token constructor - name_ = "Evolution Land Objects"; - symbol_ = "EVO"; // Evolution Land Objects - // register the supported interfaces to conform to ERC721 via ERC165 - _registerInterface(InterfaceId_ERC721Enumerable); - _registerInterface(InterfaceId_ERC721Metadata); - - registry = ISettingsRegistry(_registry); - } - - function mintObject(address _to, uint128 _objectId) public auth returns (uint256 _tokenId) { - address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); - - _tokenId = IInterstellarEncoder(interstellarEncoder).encodeTokenIdForObjectContract( - address(this), msg.sender, _objectId); - super._mint(_to, _tokenId); - } - - function burnObject(address _to, uint128 _objectId) public auth returns (uint256 _tokenId) { - address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); - - _tokenId = IInterstellarEncoder(interstellarEncoder).encodeTokenIdForObjectContract( - address(this), msg.sender, _objectId); - super._burn(_to, _tokenId); - } - - function mint(address _to, uint256 _tokenId) public auth { - super._mint(_to, _tokenId); - } - - function burn(address _to, uint256 _tokenId) public auth { - super._burn(_to, _tokenId); - } - - //@dev user invoke approveAndCall to create auction - //@param _to - address of auction contractß - function approveAndCall( - address _to, - uint _tokenId, - bytes _extraData - ) public { - // set _to to the auction contract - approve(_to, _tokenId); - - if(!_to.call( - bytes4(keccak256("receiveApproval(address,uint256,bytes)")), abi.encode(msg.sender, _tokenId, _extraData) - )) { - revert(); - } - } -} diff --git a/flat/ObjectOwnershipAuthority.sol b/flat/ObjectOwnershipAuthority.sol deleted file mode 100644 index 347dbb0..0000000 --- a/flat/ObjectOwnershipAuthority.sol +++ /dev/null @@ -1,21 +0,0 @@ -// Root file: contracts/ObjectOwnershipAuthority.sol - -pragma solidity ^0.4.24; - -contract ObjectOwnershipAuthority { - - mapping (address => bool) public whiteList; - - constructor(address[] _whitelists) public { - for (uint i = 0; i < _whitelists.length; i ++) { - whiteList[_whitelists[i]] = true; - } - } - - function canCall( - address _src, address _dst, bytes4 _sig - ) public view returns (bool) { - return ( whiteList[_src] && _sig == bytes4(keccak256("mintObject(address,uint128)")) ) || - ( whiteList[_src] && _sig == bytes4(keccak256("burnObject(address,uint128)")) ); - } -} \ No newline at end of file diff --git a/flat/ObjectOwnershipAuthorityV2.sol b/flat/ObjectOwnershipAuthorityV2.sol deleted file mode 100644 index 2f7a597..0000000 --- a/flat/ObjectOwnershipAuthorityV2.sol +++ /dev/null @@ -1,23 +0,0 @@ -// Root file: contracts/ObjectOwnershipAuthorityV2.sol - -pragma solidity ^0.4.24; - -contract ObjectOwnershipAuthorityV2 { - - mapping (address => bool) public whiteList; - - constructor(address[] _whitelists) public { - for (uint i = 0; i < _whitelists.length; i ++) { - whiteList[_whitelists[i]] = true; - } - } - - function canCall( - address _src, address _dst, bytes4 _sig - ) public view returns (bool) { - return ( whiteList[_src] && _sig == bytes4(keccak256("mintObject(address,uint128)")) ) || - ( whiteList[_src] && _sig == bytes4(keccak256("burnObject(address,uint128)")) ) || - ( whiteList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || - ( whiteList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); - } -} \ No newline at end of file diff --git a/flat/ObjectOwnershipAuthorityV3.sol b/flat/ObjectOwnershipAuthorityV3.sol deleted file mode 100644 index 1ba81e2..0000000 --- a/flat/ObjectOwnershipAuthorityV3.sol +++ /dev/null @@ -1,36 +0,0 @@ -// Root file: contracts/ObjectOwnershipAuthorityV3.sol - -pragma solidity ^0.4.24; - -/** - * @title ObjectOwnershipAuthority - * @dev ObjectOwnershipAuthority is authority that manage ObjectOwnership. - * difference between ObjectOwnershipAuthority whiteList: -[$LANDBASE_PROXY,$APOSTLEBASE_PROXY,$ERC721BRIDGE_PROXY] ==> [$LANDBASE_PROXY,$APOSTLEBASE_PROXY,$ERC721BRIDGE_PROXY,$DRILLBASE_PROXY] - */ - -contract ObjectOwnershipAuthorityV3 { - mapping(address => bool) public whiteList; - - constructor(address[] memory _whitelists) public { - for (uint256 i = 0; i < _whitelists.length; i++) { - whiteList[_whitelists[i]] = true; - } - } - - function canCall( - address _src, - address, /* _dst */ - bytes4 _sig - ) public view returns (bool) { - return - (whiteList[_src] && - _sig == bytes4(keccak256("mintObject(address,uint128)"))) || - (whiteList[_src] && - _sig == bytes4(keccak256("burnObject(address,uint128)"))) || - (whiteList[_src] && - _sig == bytes4(keccak256("mint(address,uint256)"))) || - (whiteList[_src] && - _sig == bytes4(keccak256("burn(address,uint256)"))); - } -} diff --git a/flat/ObjectOwnershipV2.sol b/flat/ObjectOwnershipV2.sol deleted file mode 100644 index 38a56b4..0000000 --- a/flat/ObjectOwnershipV2.sol +++ /dev/null @@ -1,1998 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol - -// pragma solidity ^0.4.24; - - -/** - * @title Ownable - * @dev The Ownable contract has an owner address, and provides basic authorization control - * functions, this simplifies the implementation of "user permissions". - */ -contract Ownable { - address public owner; - - - event OwnershipRenounced(address indexed previousOwner); - event OwnershipTransferred( - address indexed previousOwner, - address indexed newOwner - ); - - - /** - * @dev The Ownable constructor sets the original `owner` of the contract to the sender - * account. - */ - constructor() public { - owner = msg.sender; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - /** - * @dev Allows the current owner to relinquish control of the contract. - * @notice Renouncing to ownership will leave the contract without an owner. - * It will not be possible to call the functions with the `onlyOwner` - * modifier anymore. - */ - function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner); - owner = address(0); - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function transferOwnership(address _newOwner) public onlyOwner { - _transferOwnership(_newOwner); - } - - /** - * @dev Transfers control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function _transferOwnership(address _newOwner) internal { - require(_newOwner != address(0)); - emit OwnershipTransferred(owner, _newOwner); - owner = _newOwner; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - - -/** - * @title ERC721 Non-Fungible Token Standard basic interface - * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Basic is ERC165 { - - bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; - /* - * 0x80ac58cd === - * bytes4(keccak256('balanceOf(address)')) ^ - * bytes4(keccak256('ownerOf(uint256)')) ^ - * bytes4(keccak256('approve(address,uint256)')) ^ - * bytes4(keccak256('getApproved(uint256)')) ^ - * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ - * bytes4(keccak256('isApprovedForAll(address,address)')) ^ - * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) - */ - - bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; - /* - * 0x4f558e79 === - * bytes4(keccak256('exists(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; - /** - * 0x780e9d63 === - * bytes4(keccak256('totalSupply()')) ^ - * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ - * bytes4(keccak256('tokenByIndex(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; - /** - * 0x5b5e139f === - * bytes4(keccak256('name()')) ^ - * bytes4(keccak256('symbol()')) ^ - * bytes4(keccak256('tokenURI(uint256)')) - */ - - event Transfer( - address indexed _from, - address indexed _to, - uint256 indexed _tokenId - ); - event Approval( - address indexed _owner, - address indexed _approved, - uint256 indexed _tokenId - ); - event ApprovalForAll( - address indexed _owner, - address indexed _operator, - bool _approved - ); - - function balanceOf(address _owner) public view returns (uint256 _balance); - function ownerOf(uint256 _tokenId) public view returns (address _owner); - function exists(uint256 _tokenId) public view returns (bool _exists); - - function approve(address _to, uint256 _tokenId) public; - function getApproved(uint256 _tokenId) - public view returns (address _operator); - - function setApprovalForAll(address _operator, bool _approved) public; - function isApprovedForAll(address _owner, address _operator) - public view returns (bool); - - function transferFrom(address _from, address _to, uint256 _tokenId) public; - function safeTransferFrom(address _from, address _to, uint256 _tokenId) - public; - - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - public; -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Enumerable is ERC721Basic { - function totalSupply() public view returns (uint256); - function tokenOfOwnerByIndex( - address _owner, - uint256 _index - ) - public - view - returns (uint256 _tokenId); - - function tokenByIndex(uint256 _index) public view returns (uint256); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional metadata extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Metadata is ERC721Basic { - function name() external view returns (string _name); - function symbol() external view returns (string _symbol); - function tokenURI(uint256 _tokenId) public view returns (string); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, full implementation interface - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC721 token receiver interface - * @dev Interface for any contract that wants to support safeTransfers - * from ERC721 asset contracts. - */ -contract ERC721Receiver { - /** - * @dev Magic value to be returned upon successful reception of an NFT - * Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`, - * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` - */ - bytes4 internal constant ERC721_RECEIVED = 0x150b7a02; - - /** - * @notice Handle the receipt of an NFT - * @dev The ERC721 smart contract calls this function on the recipient - * after a `safetransfer`. This function MAY throw to revert and reject the - * transfer. Return of other than the magic value MUST result in the - * transaction being reverted. - * Note: the contract address is always the message sender. - * @param _operator The address which called `safeTransferFrom` function - * @param _from The address which previously owned the token - * @param _tokenId The NFT identifier which is being transferred - * @param _data Additional data with no specified format - * @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` - */ - function onERC721Received( - address _operator, - address _from, - uint256 _tokenId, - bytes _data - ) - public - returns(bytes4); -} - - -// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol - -// pragma solidity ^0.4.24; - - -/** - * @title SafeMath - * @dev Math operations with safety checks that throw on error - */ -library SafeMath { - - /** - * @dev Multiplies two numbers, throws on overflow. - */ - function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - // Gas optimization: this is cheaper than asserting 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - c = _a * _b; - assert(c / _a == _b); - return c; - } - - /** - * @dev Integer division of two numbers, truncating the quotient. - */ - function div(uint256 _a, uint256 _b) internal pure returns (uint256) { - // assert(_b > 0); // Solidity automatically throws when dividing by 0 - // uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - return _a / _b; - } - - /** - * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - assert(_b <= _a); - return _a - _b; - } - - /** - * @dev Adds two numbers, throws on overflow. - */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - c = _a + _b; - assert(c >= _a); - return c; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/AddressUtils.sol - -// pragma solidity ^0.4.24; - - -/** - * Utility library of inline functions on addresses - */ -library AddressUtils { - - /** - * Returns whether the target address is a contract - * @dev This function will return false if invoked during the constructor of a contract, - * as the code is not actually created until after the constructor finishes. - * @param _addr address to check - * @return whether the target address is a contract - */ - function isContract(address _addr) internal view returns (bool) { - uint256 size; - // XXX Currently there is no better way to check if there is a contract in an address - // than to check the size of the code at that address. - // See https://ethereum.stackexchange.com/a/14016/36603 - // for more details about how this works. - // TODO Check this again before the Serenity release, because all addresses will be - // contracts then. - // solium-disable-next-line security/no-inline-assembly - assembly { size := extcodesize(_addr) } - return size > 0; - } - -} - - -// Dependency file: openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - - -/** - * @title SupportsInterfaceWithLookup - * @author Matt Condon (@shrugs) - * @dev Implements ERC165 using a lookup table. - */ -contract SupportsInterfaceWithLookup is ERC165 { - - bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; - /** - * 0x01ffc9a7 === - * bytes4(keccak256('supportsInterface(bytes4)')) - */ - - /** - * @dev a mapping of interface id to whether or not it's supported - */ - mapping(bytes4 => bool) internal supportedInterfaces; - - /** - * @dev A contract implementing SupportsInterfaceWithLookup - * implement ERC165 itself - */ - constructor() - public - { - _registerInterface(InterfaceId_ERC165); - } - - /** - * @dev implement supportsInterface(bytes4) using a lookup table - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool) - { - return supportedInterfaces[_interfaceId]; - } - - /** - * @dev private method for registering an interface - */ - function _registerInterface(bytes4 _interfaceId) - internal - { - require(_interfaceId != 0xffffffff); - supportedInterfaces[_interfaceId] = true; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721BasicToken.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol"; -// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -// import "openzeppelin-solidity/contracts/AddressUtils.sol"; -// import "openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.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 SupportsInterfaceWithLookup, ERC721Basic { - - 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; - - // Mapping from token ID to owner - mapping (uint256 => address) internal tokenOwner; - - // Mapping from token ID to approved address - mapping (uint256 => address) internal tokenApprovals; - - // Mapping from owner to number of owned token - mapping (address => uint256) internal ownedTokensCount; - - // Mapping from owner to operator approvals - mapping (address => mapping (address => bool)) internal operatorApprovals; - - constructor() - public - { - // register the supported interfaces to conform to ERC721 via ERC165 - _registerInterface(InterfaceId_ERC721); - _registerInterface(InterfaceId_ERC721Exists); - } - - /** - * @dev Gets the balance of the specified address - * @param _owner address to query the balance of - * @return uint256 representing the amount owned by the passed address - */ - function balanceOf(address _owner) public view returns (uint256) { - require(_owner != address(0)); - return ownedTokensCount[_owner]; - } - - /** - * @dev Gets the owner of the specified token ID - * @param _tokenId uint256 ID of the token to query the owner of - * @return owner address currently marked as the owner of the given token ID - */ - function ownerOf(uint256 _tokenId) public view returns (address) { - address owner = tokenOwner[_tokenId]; - require(owner != address(0)); - return owner; - } - - /** - * @dev Returns whether the specified token exists - * @param _tokenId uint256 ID of the token to query the existence of - * @return whether the token exists - */ - function exists(uint256 _tokenId) public view returns (bool) { - address owner = tokenOwner[_tokenId]; - return owner != address(0); - } - - /** - * @dev Approves another address to transfer the given token ID - * The zero address indicates there is no approved address. - * There can only be one approved address per token at a given time. - * Can only be called by the token owner or an approved operator. - * @param _to address to be approved for the given token ID - * @param _tokenId uint256 ID of the token to be approved - */ - function approve(address _to, uint256 _tokenId) public { - address owner = ownerOf(_tokenId); - require(_to != owner); - require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); - - tokenApprovals[_tokenId] = _to; - emit Approval(owner, _to, _tokenId); - } - - /** - * @dev Gets the approved address for a token ID, or zero if no address set - * @param _tokenId uint256 ID of the token to query the approval of - * @return address currently approved for the given token ID - */ - function getApproved(uint256 _tokenId) public view returns (address) { - return tokenApprovals[_tokenId]; - } - - /** - * @dev Sets or unsets the approval of a given operator - * An operator is allowed to transfer all tokens of the sender on their behalf - * @param _to operator address to set the approval - * @param _approved representing the status of the approval to be set - */ - function setApprovalForAll(address _to, bool _approved) public { - require(_to != msg.sender); - operatorApprovals[msg.sender][_to] = _approved; - emit ApprovalForAll(msg.sender, _to, _approved); - } - - /** - * @dev Tells whether an operator is approved by a given owner - * @param _owner owner address which you want to query the approval of - * @param _operator operator address which you want to query the approval of - * @return bool whether the given operator is approved by the given owner - */ - function isApprovedForAll( - address _owner, - address _operator - ) - public - view - returns (bool) - { - return operatorApprovals[_owner][_operator]; - } - - /** - * @dev Transfers the ownership of a given token ID to another address - * Usage of this method is discouraged, use `safeTransferFrom` whenever possible - * Requires the msg sender to be the owner, approved, or operator - * @param _from current owner of the token - * @param _to address to receive the ownership of the given token ID - * @param _tokenId uint256 ID of the token to be transferred - */ - function transferFrom( - address _from, - address _to, - uint256 _tokenId - ) - public - { - require(isApprovedOrOwner(msg.sender, _tokenId)); - require(_from != address(0)); - require(_to != address(0)); - - clearApproval(_from, _tokenId); - removeTokenFrom(_from, _tokenId); - addTokenTo(_to, _tokenId); - - emit Transfer(_from, _to, _tokenId); - } - - /** - * @dev Safely transfers the ownership of a given token ID to another address - * If the target address is a contract, it must implement `onERC721Received`, - * which is called upon a safe transfer, and return the magic value - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, - * the transfer is reverted. - * - * Requires the msg sender to be the owner, approved, or operator - * @param _from current owner of the token - * @param _to address to receive the ownership of the given token ID - * @param _tokenId uint256 ID of the token to be transferred - */ - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId - ) - public - { - // solium-disable-next-line arg-overflow - safeTransferFrom(_from, _to, _tokenId, ""); - } - - /** - * @dev Safely transfers the ownership of a given token ID to another address - * If the target address is a contract, it must implement `onERC721Received`, - * which is called upon a safe transfer, and return the magic value - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, - * the transfer is reverted. - * Requires the msg sender to be the owner, approved, or operator - * @param _from current owner of the token - * @param _to address to receive the ownership of the given token ID - * @param _tokenId uint256 ID of the token to be transferred - * @param _data bytes data to send along with a safe transfer check - */ - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - public - { - transferFrom(_from, _to, _tokenId); - // solium-disable-next-line arg-overflow - require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); - } - - /** - * @dev Returns whether the given spender can transfer a given token ID - * @param _spender address of the spender to query - * @param _tokenId uint256 ID of the token to be transferred - * @return bool whether the msg.sender is approved for the given token ID, - * is an operator of the owner, or is the owner of the token - */ - function isApprovedOrOwner( - address _spender, - uint256 _tokenId - ) - internal - view - returns (bool) - { - address owner = ownerOf(_tokenId); - // Disable solium check because of - // https://github.com/duaraghav8/Solium/issues/175 - // solium-disable-next-line operator-whitespace - return ( - _spender == owner || - getApproved(_tokenId) == _spender || - isApprovedForAll(owner, _spender) - ); - } - - /** - * @dev Internal function to mint a new token - * Reverts if the given token ID already exists - * @param _to The address that will own the minted token - * @param _tokenId uint256 ID of the token to be minted by the msg.sender - */ - function _mint(address _to, uint256 _tokenId) internal { - require(_to != address(0)); - addTokenTo(_to, _tokenId); - emit Transfer(address(0), _to, _tokenId); - } - - /** - * @dev Internal function to burn a specific token - * Reverts if the token does not exist - * @param _tokenId uint256 ID of the token being burned by the msg.sender - */ - function _burn(address _owner, uint256 _tokenId) internal { - clearApproval(_owner, _tokenId); - removeTokenFrom(_owner, _tokenId); - emit Transfer(_owner, address(0), _tokenId); - } - - /** - * @dev Internal function to clear current approval of a given token ID - * Reverts if the given address is not indeed the owner of the token - * @param _owner owner of the token - * @param _tokenId uint256 ID of the token to be transferred - */ - function clearApproval(address _owner, uint256 _tokenId) internal { - require(ownerOf(_tokenId) == _owner); - if (tokenApprovals[_tokenId] != address(0)) { - tokenApprovals[_tokenId] = address(0); - } - } - - /** - * @dev Internal function to add a token ID to the list of a given address - * @param _to address representing the new owner of the given token ID - * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address - */ - function addTokenTo(address _to, uint256 _tokenId) internal { - require(tokenOwner[_tokenId] == address(0)); - tokenOwner[_tokenId] = _to; - ownedTokensCount[_to] = ownedTokensCount[_to].add(1); - } - - /** - * @dev Internal function to remove a token ID from the list of a given address - * @param _from address representing the previous owner of the given token ID - * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address - */ - function removeTokenFrom(address _from, uint256 _tokenId) internal { - require(ownerOf(_tokenId) == _from); - ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); - tokenOwner[_tokenId] = address(0); - } - - /** - * @dev Internal function to invoke `onERC721Received` on a target address - * The call is not executed if the target address is not a contract - * @param _from address representing the previous owner of the given token ID - * @param _to target address that will receive the tokens - * @param _tokenId uint256 ID of the token to be transferred - * @param _data bytes optional data to send along with the call - * @return whether the call correctly returned the expected magic value - */ - function checkAndCallSafeTransfer( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - internal - returns (bool) - { - if (!_to.isContract()) { - return true; - } - bytes4 retval = ERC721Receiver(_to).onERC721Received( - msg.sender, _from, _tokenId, _data); - return (retval == ERC721_RECEIVED); - } -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721BasicToken.sol"; -// import "openzeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.sol"; - - -/** - * @title Full ERC721 Token - * This implementation includes all the required and some optional functionality of the ERC721 standard - * Moreover, it includes approve all functionality using operator terminology - * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 { - - // Token name - string internal name_; - - // Token symbol - string internal symbol_; - - // Mapping from owner to list of owned token IDs - mapping(address => uint256[]) internal ownedTokens; - - // Mapping from token ID to index of the owner tokens list - mapping(uint256 => uint256) internal ownedTokensIndex; - - // Array with all token ids, used for enumeration - uint256[] internal allTokens; - - // Mapping from token id to position in the allTokens array - mapping(uint256 => uint256) internal allTokensIndex; - - // Optional mapping for token URIs - mapping(uint256 => string) internal tokenURIs; - - /** - * @dev Constructor function - */ - constructor(string _name, string _symbol) public { - name_ = _name; - symbol_ = _symbol; - - // register the supported interfaces to conform to ERC721 via ERC165 - _registerInterface(InterfaceId_ERC721Enumerable); - _registerInterface(InterfaceId_ERC721Metadata); - } - - /** - * @dev Gets the token name - * @return string representing the token name - */ - function name() external view returns (string) { - return name_; - } - - /** - * @dev Gets the token symbol - * @return string representing the token symbol - */ - function symbol() external view returns (string) { - return symbol_; - } - - /** - * @dev Returns an URI for a given token ID - * Throws if the token ID does not exist. May return an empty string. - * @param _tokenId uint256 ID of the token to query - */ - function tokenURI(uint256 _tokenId) public view returns (string) { - require(exists(_tokenId)); - return tokenURIs[_tokenId]; - } - - /** - * @dev Gets the token ID at a given index of the tokens list of the requested owner - * @param _owner address owning the tokens list to be accessed - * @param _index uint256 representing the index to be accessed of the requested tokens list - * @return uint256 token ID at the given index of the tokens list owned by the requested address - */ - function tokenOfOwnerByIndex( - address _owner, - uint256 _index - ) - public - view - returns (uint256) - { - require(_index < balanceOf(_owner)); - return ownedTokens[_owner][_index]; - } - - /** - * @dev Gets the total amount of tokens stored by the contract - * @return uint256 representing the total amount of tokens - */ - function totalSupply() public view returns (uint256) { - return allTokens.length; - } - - /** - * @dev Gets the token ID at a given index of all the tokens in this contract - * Reverts if the index is greater or equal to the total number of tokens - * @param _index uint256 representing the index to be accessed of the tokens list - * @return uint256 token ID at the given index of the tokens list - */ - function tokenByIndex(uint256 _index) public view returns (uint256) { - require(_index < totalSupply()); - return allTokens[_index]; - } - - /** - * @dev Internal function to set the token URI for a given token - * Reverts if the token ID does not exist - * @param _tokenId uint256 ID of the token to set its URI - * @param _uri string URI to assign - */ - function _setTokenURI(uint256 _tokenId, string _uri) internal { - require(exists(_tokenId)); - tokenURIs[_tokenId] = _uri; - } - - /** - * @dev Internal function to add a token ID to the list of a given address - * @param _to address representing the new owner of the given token ID - * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address - */ - function addTokenTo(address _to, uint256 _tokenId) internal { - super.addTokenTo(_to, _tokenId); - uint256 length = ownedTokens[_to].length; - ownedTokens[_to].push(_tokenId); - ownedTokensIndex[_tokenId] = length; - } - - /** - * @dev Internal function to remove a token ID from the list of a given address - * @param _from address representing the previous owner of the given token ID - * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address - */ - function removeTokenFrom(address _from, uint256 _tokenId) internal { - super.removeTokenFrom(_from, _tokenId); - - // To prevent a gap in the array, we store the last token in the index of the token to delete, and - // then delete the last slot. - uint256 tokenIndex = ownedTokensIndex[_tokenId]; - uint256 lastTokenIndex = ownedTokens[_from].length.sub(1); - uint256 lastToken = ownedTokens[_from][lastTokenIndex]; - - ownedTokens[_from][tokenIndex] = lastToken; - // This also deletes the contents at the last position of the array - ownedTokens[_from].length--; - - // Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to - // be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping - // the lastToken to the first position, and then dropping the element placed in the last position of the list - - ownedTokensIndex[_tokenId] = 0; - ownedTokensIndex[lastToken] = tokenIndex; - } - - /** - * @dev Internal function to mint a new token - * Reverts if the given token ID already exists - * @param _to address the beneficiary that will own the minted token - * @param _tokenId uint256 ID of the token to be minted by the msg.sender - */ - function _mint(address _to, uint256 _tokenId) internal { - super._mint(_to, _tokenId); - - allTokensIndex[_tokenId] = allTokens.length; - allTokens.push(_tokenId); - } - - /** - * @dev Internal function to burn a specific token - * Reverts if the token does not exist - * @param _owner owner of the token to burn - * @param _tokenId uint256 ID of the token being burned by the msg.sender - */ - function _burn(address _owner, uint256 _tokenId) internal { - super._burn(_owner, _tokenId); - - // Clear metadata (if any) - if (bytes(tokenURIs[_tokenId]).length != 0) { - delete tokenURIs[_tokenId]; - } - - // Reorg all tokens array - uint256 tokenIndex = allTokensIndex[_tokenId]; - uint256 lastTokenIndex = allTokens.length.sub(1); - uint256 lastToken = allTokens[lastTokenIndex]; - - allTokens[tokenIndex] = lastToken; - allTokens[lastTokenIndex] = 0; - - allTokens.length--; - allTokensIndex[_tokenId] = 0; - allTokensIndex[lastToken] = tokenIndex; - } - -} - - -// Dependency file: contracts/interfaces/IInterstellarEncoder.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoder { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function registerNewTokenContract(address _tokenAddress) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Dependency file: contracts/StringUtil.sol - -// https://github.com/Arachnid/solidity-stringutils/tree/master/src - -// https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol#L1036 - -// pragma solidity ^0.4.14; - -library StringUtil { - struct slice { - uint _len; - uint _ptr; - } - - function memcpy(uint dest, uint src, uint len) private pure { - // Copy word-length chunks while possible - for(; len >= 32; len -= 32) { - assembly { - mstore(dest, mload(src)) - } - dest += 32; - src += 32; - } - - // Copy remaining bytes - uint mask = 256 ** (32 - len) - 1; - assembly { - let srcpart := and(mload(src), not(mask)) - let destpart := and(mload(dest), mask) - mstore(dest, or(destpart, srcpart)) - } - } - - /* - * @dev Returns a slice containing the entire string. - * @param self The string to make a slice from. - * @return A newly allocated slice containing the entire string. - */ - function toSlice(string memory self) internal pure returns (slice memory) { - uint ptr; - assembly { - ptr := add(self, 0x20) - } - return slice(bytes(self).length, ptr); - } - - /* - * @dev Returns the length of a null-terminated bytes32 string. - * @param self The value to find the length of. - * @return The length of the string, from 0 to 32. - */ - function len(bytes32 self) internal pure returns (uint) { - uint ret; - if (self == 0) - return 0; - if (self & 0xffffffffffffffffffffffffffffffff == 0) { - ret += 16; - self = bytes32(uint(self) / 0x100000000000000000000000000000000); - } - if (self & 0xffffffffffffffff == 0) { - ret += 8; - self = bytes32(uint(self) / 0x10000000000000000); - } - if (self & 0xffffffff == 0) { - ret += 4; - self = bytes32(uint(self) / 0x100000000); - } - if (self & 0xffff == 0) { - ret += 2; - self = bytes32(uint(self) / 0x10000); - } - if (self & 0xff == 0) { - ret += 1; - } - return 32 - ret; - } - - /* - * @dev Returns a slice containing the entire bytes32, interpreted as a - * null-terminated utf-8 string. - * @param self The bytes32 value to convert to a slice. - * @return A new slice containing the value of the input argument up to the - * first null. - */ - function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { - // Allocate space for `self` in memory, copy it there, and point ret at it - assembly { - let ptr := mload(0x40) - mstore(0x40, add(ptr, 0x20)) - mstore(ptr, self) - mstore(add(ret, 0x20), ptr) - } - ret._len = len(self); - } - - /* - * @dev Returns a new slice containing the same data as the current slice. - * @param self The slice to copy. - * @return A new slice containing the same data as `self`. - */ - function copy(slice memory self) internal pure returns (slice memory) { - return slice(self._len, self._ptr); - } - - /* - * @dev Copies a slice to a new string. - * @param self The slice to copy. - * @return A newly allocated string containing the slice's text. - */ - function toString(slice memory self) internal pure returns (string memory) { - string memory ret = new string(self._len); - uint retptr; - assembly { retptr := add(ret, 32) } - - memcpy(retptr, self._ptr, self._len); - return ret; - } - - /* - * @dev Returns the length in runes of the slice. Note that this operation - * takes time proportional to the length of the slice; avoid using it - * in loops, and call `slice.empty()` if you only need to know whether - * the slice is empty or not. - * @param self The slice to operate on. - * @return The length of the slice in runes. - */ - function len(slice memory self) internal pure returns (uint l) { - // Starting at ptr-31 means the LSB will be the byte we care about - uint ptr = self._ptr - 31; - uint end = ptr + self._len; - for (l = 0; ptr < end; l++) { - uint8 b; - assembly { b := and(mload(ptr), 0xFF) } - if (b < 0x80) { - ptr += 1; - } else if(b < 0xE0) { - ptr += 2; - } else if(b < 0xF0) { - ptr += 3; - } else if(b < 0xF8) { - ptr += 4; - } else if(b < 0xFC) { - ptr += 5; - } else { - ptr += 6; - } - } - } - - /* - * @dev Returns true if the slice is empty (has a length of 0). - * @param self The slice to operate on. - * @return True if the slice is empty, False otherwise. - */ - function empty(slice memory self) internal pure returns (bool) { - return self._len == 0; - } - - /* - * @dev Returns a positive number if `other` comes lexicographically after - * `self`, a negative number if it comes before, or zero if the - * contents of the two slices are equal. Comparison is done per-rune, - * on unicode codepoints. - * @param self The first slice to compare. - * @param other The second slice to compare. - * @return The result of the comparison. - */ - function compare(slice memory self, slice memory other) internal pure returns (int) { - uint shortest = self._len; - if (other._len < self._len) - shortest = other._len; - - uint selfptr = self._ptr; - uint otherptr = other._ptr; - for (uint idx = 0; idx < shortest; idx += 32) { - uint a; - uint b; - assembly { - a := mload(selfptr) - b := mload(otherptr) - } - if (a != b) { - // Mask out irrelevant bytes and check again - uint256 mask = uint256(-1); // 0xffff... - if(shortest < 32) { - mask = ~(2 ** (8 * (32 - shortest + idx)) - 1); - } - uint256 diff = (a & mask) - (b & mask); - if (diff != 0) - return int(diff); - } - selfptr += 32; - otherptr += 32; - } - return int(self._len) - int(other._len); - } - - /* - * @dev Returns true if the two slices contain the same text. - * @param self The first slice to compare. - * @param self The second slice to compare. - * @return True if the slices are equal, false otherwise. - */ - function equals(slice memory self, slice memory other) internal pure returns (bool) { - return compare(self, other) == 0; - } - - /* - * @dev Extracts the first rune in the slice into `rune`, advancing the - * slice to point to the next rune and returning `self`. - * @param self The slice to operate on. - * @param rune The slice that will contain the first rune. - * @return `rune`. - */ - function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) { - rune._ptr = self._ptr; - - if (self._len == 0) { - rune._len = 0; - return rune; - } - - uint l; - uint b; - // Load the first byte of the rune into the LSBs of b - assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) } - if (b < 0x80) { - l = 1; - } else if(b < 0xE0) { - l = 2; - } else if(b < 0xF0) { - l = 3; - } else { - l = 4; - } - - // Check for truncated codepoints - if (l > self._len) { - rune._len = self._len; - self._ptr += self._len; - self._len = 0; - return rune; - } - - self._ptr += l; - self._len -= l; - rune._len = l; - return rune; - } - - /* - * @dev Returns the first rune in the slice, advancing the slice to point - * to the next rune. - * @param self The slice to operate on. - * @return A slice containing only the first rune from `self`. - */ - function nextRune(slice memory self) internal pure returns (slice memory ret) { - nextRune(self, ret); - } - - /* - * @dev Returns the number of the first codepoint in the slice. - * @param self The slice to operate on. - * @return The number of the first codepoint in the slice. - */ - function ord(slice memory self) internal pure returns (uint ret) { - if (self._len == 0) { - return 0; - } - - uint word; - uint length; - uint divisor = 2 ** 248; - - // Load the rune into the MSBs of b - assembly { word:= mload(mload(add(self, 32))) } - uint b = word / divisor; - if (b < 0x80) { - ret = b; - length = 1; - } else if(b < 0xE0) { - ret = b & 0x1F; - length = 2; - } else if(b < 0xF0) { - ret = b & 0x0F; - length = 3; - } else { - ret = b & 0x07; - length = 4; - } - - // Check for truncated codepoints - if (length > self._len) { - return 0; - } - - for (uint i = 1; i < length; i++) { - divisor = divisor / 256; - b = (word / divisor) & 0xFF; - if (b & 0xC0 != 0x80) { - // Invalid UTF-8 sequence - return 0; - } - ret = (ret * 64) | (b & 0x3F); - } - - return ret; - } - - /* - * @dev Returns the keccak-256 hash of the slice. - * @param self The slice to hash. - * @return The hash of the slice. - */ - function keccak(slice memory self) internal pure returns (bytes32 ret) { - assembly { - ret := keccak256(mload(add(self, 32)), mload(self)) - } - } - - /* - * @dev Returns true if `self` starts with `needle`. - * @param self The slice to operate on. - * @param needle The slice to search for. - * @return True if the slice starts with the provided text, false otherwise. - */ - function startsWith(slice memory self, slice memory needle) internal pure returns (bool) { - if (self._len < needle._len) { - return false; - } - - if (self._ptr == needle._ptr) { - return true; - } - - bool equal; - assembly { - let length := mload(needle) - let selfptr := mload(add(self, 0x20)) - let needleptr := mload(add(needle, 0x20)) - equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) - } - return equal; - } - - /* - * @dev If `self` starts with `needle`, `needle` is removed from the - * beginning of `self`. Otherwise, `self` is unmodified. - * @param self The slice to operate on. - * @param needle The slice to search for. - * @return `self` - */ - function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) { - if (self._len < needle._len) { - return self; - } - - bool equal = true; - if (self._ptr != needle._ptr) { - assembly { - let length := mload(needle) - let selfptr := mload(add(self, 0x20)) - let needleptr := mload(add(needle, 0x20)) - equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) - } - } - - if (equal) { - self._len -= needle._len; - self._ptr += needle._len; - } - - return self; - } - - /* - * @dev Returns true if the slice ends with `needle`. - * @param self The slice to operate on. - * @param needle The slice to search for. - * @return True if the slice starts with the provided text, false otherwise. - */ - function endsWith(slice memory self, slice memory needle) internal pure returns (bool) { - if (self._len < needle._len) { - return false; - } - - uint selfptr = self._ptr + self._len - needle._len; - - if (selfptr == needle._ptr) { - return true; - } - - bool equal; - assembly { - let length := mload(needle) - let needleptr := mload(add(needle, 0x20)) - equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) - } - - return equal; - } - - /* - * @dev If `self` ends with `needle`, `needle` is removed from the - * end of `self`. Otherwise, `self` is unmodified. - * @param self The slice to operate on. - * @param needle The slice to search for. - * @return `self` - */ - function until(slice memory self, slice memory needle) internal pure returns (slice memory) { - if (self._len < needle._len) { - return self; - } - - uint selfptr = self._ptr + self._len - needle._len; - bool equal = true; - if (selfptr != needle._ptr) { - assembly { - let length := mload(needle) - let needleptr := mload(add(needle, 0x20)) - equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) - } - } - - if (equal) { - self._len -= needle._len; - } - - return self; - } - - // Returns the memory address of the first byte of the first occurrence of - // `needle` in `self`, or the first byte after `self` if not found. - function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { - uint ptr = selfptr; - uint idx; - - if (needlelen <= selflen) { - if (needlelen <= 32) { - bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); - - bytes32 needledata; - assembly { needledata := and(mload(needleptr), mask) } - - uint end = selfptr + selflen - needlelen; - bytes32 ptrdata; - assembly { ptrdata := and(mload(ptr), mask) } - - while (ptrdata != needledata) { - if (ptr >= end) - return selfptr + selflen; - ptr++; - assembly { ptrdata := and(mload(ptr), mask) } - } - return ptr; - } else { - // For long needles, use hashing - bytes32 hash; - assembly { hash := keccak256(needleptr, needlelen) } - - for (idx = 0; idx <= selflen - needlelen; idx++) { - bytes32 testHash; - assembly { testHash := keccak256(ptr, needlelen) } - if (hash == testHash) - return ptr; - ptr += 1; - } - } - } - return selfptr + selflen; - } - - // Returns the memory address of the first byte after the last occurrence of - // `needle` in `self`, or the address of `self` if not found. - function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { - uint ptr; - - if (needlelen <= selflen) { - if (needlelen <= 32) { - bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); - - bytes32 needledata; - assembly { needledata := and(mload(needleptr), mask) } - - ptr = selfptr + selflen - needlelen; - bytes32 ptrdata; - assembly { ptrdata := and(mload(ptr), mask) } - - while (ptrdata != needledata) { - if (ptr <= selfptr) - return selfptr; - ptr--; - assembly { ptrdata := and(mload(ptr), mask) } - } - return ptr + needlelen; - } else { - // For long needles, use hashing - bytes32 hash; - assembly { hash := keccak256(needleptr, needlelen) } - ptr = selfptr + (selflen - needlelen); - while (ptr >= selfptr) { - bytes32 testHash; - assembly { testHash := keccak256(ptr, needlelen) } - if (hash == testHash) - return ptr + needlelen; - ptr -= 1; - } - } - } - return selfptr; - } - - /* - * @dev Modifies `self` to contain everything from the first occurrence of - * `needle` to the end of the slice. `self` is set to the empty slice - * if `needle` is not found. - * @param self The slice to search and modify. - * @param needle The text to search for. - * @return `self`. - */ - function find(slice memory self, slice memory needle) internal pure returns (slice memory) { - uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); - self._len -= ptr - self._ptr; - self._ptr = ptr; - return self; - } - - /* - * @dev Modifies `self` to contain the part of the string from the start of - * `self` to the end of the first occurrence of `needle`. If `needle` - * is not found, `self` is set to the empty slice. - * @param self The slice to search and modify. - * @param needle The text to search for. - * @return `self`. - */ - function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) { - uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); - self._len = ptr - self._ptr; - return self; - } - - /* - * @dev Splits the slice, setting `self` to everything after the first - * occurrence of `needle`, and `token` to everything before it. If - * `needle` does not occur in `self`, `self` is set to the empty slice, - * and `token` is set to the entirety of `self`. - * @param self The slice to split. - * @param needle The text to search for in `self`. - * @param token An output parameter to which the first token is written. - * @return `token`. - */ - function split(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { - uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); - token._ptr = self._ptr; - token._len = ptr - self._ptr; - if (ptr == self._ptr + self._len) { - // Not found - self._len = 0; - } else { - self._len -= token._len + needle._len; - self._ptr = ptr + needle._len; - } - return token; - } - - /* - * @dev Splits the slice, setting `self` to everything after the first - * occurrence of `needle`, and returning everything before it. If - * `needle` does not occur in `self`, `self` is set to the empty slice, - * and the entirety of `self` is returned. - * @param self The slice to split. - * @param needle The text to search for in `self`. - * @return The part of `self` up to the first occurrence of `delim`. - */ - function split(slice memory self, slice memory needle) internal pure returns (slice memory token) { - split(self, needle, token); - } - - /* - * @dev Splits the slice, setting `self` to everything before the last - * occurrence of `needle`, and `token` to everything after it. If - * `needle` does not occur in `self`, `self` is set to the empty slice, - * and `token` is set to the entirety of `self`. - * @param self The slice to split. - * @param needle The text to search for in `self`. - * @param token An output parameter to which the first token is written. - * @return `token`. - */ - function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { - uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); - token._ptr = ptr; - token._len = self._len - (ptr - self._ptr); - if (ptr == self._ptr) { - // Not found - self._len = 0; - } else { - self._len -= token._len + needle._len; - } - return token; - } - - /* - * @dev Splits the slice, setting `self` to everything before the last - * occurrence of `needle`, and returning everything after it. If - * `needle` does not occur in `self`, `self` is set to the empty slice, - * and the entirety of `self` is returned. - * @param self The slice to split. - * @param needle The text to search for in `self`. - * @return The part of `self` after the last occurrence of `delim`. - */ - function rsplit(slice memory self, slice memory needle) internal pure returns (slice memory token) { - rsplit(self, needle, token); - } - - /* - * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`. - * @param self The slice to search. - * @param needle The text to search for in `self`. - * @return The number of occurrences of `needle` found in `self`. - */ - function count(slice memory self, slice memory needle) internal pure returns (uint cnt) { - uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; - while (ptr <= self._ptr + self._len) { - cnt++; - ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; - } - } - - /* - * @dev Returns True if `self` contains `needle`. - * @param self The slice to search. - * @param needle The text to search for in `self`. - * @return True if `needle` is found in `self`, false otherwise. - */ - function contains(slice memory self, slice memory needle) internal pure returns (bool) { - return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; - } - - /* - * @dev Returns a newly allocated string containing the concatenation of - * `self` and `other`. - * @param self The first slice to concatenate. - * @param other The second slice to concatenate. - * @return The concatenation of the two strings. - */ - function concat(slice memory self, slice memory other) internal pure returns (string memory) { - string memory ret = new string(self._len + other._len); - uint retptr; - assembly { retptr := add(ret, 32) } - memcpy(retptr, self._ptr, self._len); - memcpy(retptr + self._len, other._ptr, other._len); - return ret; - } - - /* - * @dev Joins an array of slices, using `self` as a delimiter, returning a - * newly allocated string. - * @param self The delimiter to use. - * @param parts A list of slices to join. - * @return A newly allocated string containing all the slices in `parts`, - * joined with `self`. - */ - function join(slice memory self, slice[] memory parts) internal pure returns (string memory) { - if (parts.length == 0) - return ""; - - uint length = self._len * (parts.length - 1); - for(uint i = 0; i < parts.length; i++) - length += parts[i]._len; - - string memory ret = new string(length); - uint retptr; - assembly { retptr := add(ret, 32) } - - for(i = 0; i < parts.length; i++) { - memcpy(retptr, parts[i]._ptr, parts[i]._len); - retptr += parts[i]._len; - if (i < parts.length - 1) { - memcpy(retptr, self._ptr, self._len); - retptr += self._len; - } - } - - return ret; - } - - function uint2str(uint _int) internal pure returns (string memory _uintAsString) { - uint _i = _int; - if (_i == 0) { - return "0"; - } - uint j = _i; - uint length; - while (j != 0) { - length++; - j /= 10; - } - bytes memory bstr = new bytes(length); - uint k = length - 1; - while (_i != 0) { - bstr[k--] = byte(uint8(48 + _i % 10)); - _i /= 10; - } - return string(bstr); - } -} - -// Root file: contracts/ObjectOwnershipV2.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol"; -// import "contracts/interfaces/IInterstellarEncoder.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/DSAuth.sol"; -// import "contracts/SettingIds.sol"; -// import "contracts/StringUtil.sol"; - -contract ObjectOwnershipV2 is ERC721Token("Evolution Land Objects","EVO"), DSAuth, SettingIds { - using StringUtil for *; - - ISettingsRegistry public registry; - - bool private singletonLock = false; - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - // https://docs.opensea.io/docs/2-adding-metadata - string public baseTokenURI; - - /** - * @dev Atlantis's constructor - */ - constructor () public { - // initializeContract(); - } - - /** - * @dev Same with constructor, but is used and called by storage proxy as logic contract. - */ - function initializeContract(address _registry) public singletonLockCall { - // Ownable constructor - owner = msg.sender; - emit LogSetOwner(msg.sender); - - // SupportsInterfaceWithLookup constructor - _registerInterface(InterfaceId_ERC165); - - // ERC721BasicToken constructor - _registerInterface(InterfaceId_ERC721); - _registerInterface(InterfaceId_ERC721Exists); - - // ERC721Token constructor - name_ = "Evolution Land Objects"; - symbol_ = "EVO"; // Evolution Land Objects - // register the supported interfaces to conform to ERC721 via ERC165 - _registerInterface(InterfaceId_ERC721Enumerable); - _registerInterface(InterfaceId_ERC721Metadata); - - registry = ISettingsRegistry(_registry); - } - - function tokenURI(uint256 _tokenId) public view returns (string) { - if (super.tokenURI(_tokenId).toSlice().empty()) { - return baseTokenURI.toSlice().concat(StringUtil.uint2str(_tokenId).toSlice()); - } - - return super.tokenURI(_tokenId); - } - - function setTokenURI(uint256 _tokenId, string _uri) public auth { - _setTokenURI(_tokenId, _uri); - } - - function setBaseTokenURI(string _newBaseTokenURI) public auth { - baseTokenURI = _newBaseTokenURI; - } - - function mintObject(address _to, uint128 _objectId) public auth returns (uint256 _tokenId) { - address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); - - _tokenId = IInterstellarEncoder(interstellarEncoder).encodeTokenIdForObjectContract( - address(this), msg.sender, _objectId); - super._mint(_to, _tokenId); - } - - function burnObject(address _to, uint128 _objectId) public auth returns (uint256 _tokenId) { - address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); - - _tokenId = IInterstellarEncoder(interstellarEncoder).encodeTokenIdForObjectContract( - address(this), msg.sender, _objectId); - super._burn(_to, _tokenId); - } - - function mint(address _to, uint256 _tokenId) public auth { - super._mint(_to, _tokenId); - } - - function burn(address _to, uint256 _tokenId) public auth { - super._burn(_to, _tokenId); - } - - //@dev user invoke approveAndCall to create auction - //@param _to - address of auction contractß - function approveAndCall( - address _to, - uint _tokenId, - bytes _extraData - ) public { - // set _to to the auction contract - approve(_to, _tokenId); - - if(!_to.call( - bytes4(keccak256("receiveApproval(address,uint256,bytes)")), abi.encode(msg.sender, _tokenId, _extraData) - )) { - revert(); - } - } -} diff --git a/flat/PausableDSAuth.sol b/flat/PausableDSAuth.sol deleted file mode 100644 index ad09228..0000000 --- a/flat/PausableDSAuth.sol +++ /dev/null @@ -1,123 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Root file: contracts/PausableDSAuth.sol - -pragma solidity ^0.4.24; - -// import "contracts/DSAuth.sol"; - - -/** - * @title Pausable - * @dev Base contract which allows children to implement an emergency stop mechanism. - */ -contract PausableDSAuth is DSAuth { - event Pause(); - event Unpause(); - - bool public paused = false; - - - /** - * @dev Modifier to make a function callable only when the contract is not paused. - */ - modifier whenNotPaused() { - require(!paused); - _; - } - - /** - * @dev Modifier to make a function callable only when the contract is paused. - */ - modifier whenPaused() { - require(paused); - _; - } - - /** - * @dev called by the owner to pause, triggers stopped state - */ - function pause() public onlyOwner whenNotPaused { - paused = true; - emit Pause(); - } - - /** - * @dev called by the owner to unpause, returns to normal state - */ - function unpause() public onlyOwner whenPaused { - paused = false; - emit Unpause(); - } -} \ No newline at end of file diff --git a/flat/PolkaPetAdaptor.sol b/flat/PolkaPetAdaptor.sol deleted file mode 100644 index 5d7198e..0000000 --- a/flat/PolkaPetAdaptor.sol +++ /dev/null @@ -1,696 +0,0 @@ -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: contracts/PausableDSAuth.sol - -// pragma solidity ^0.4.24; - -// import "contracts/DSAuth.sol"; - - -/** - * @title Pausable - * @dev Base contract which allows children to implement an emergency stop mechanism. - */ -contract PausableDSAuth is DSAuth { - event Pause(); - event Unpause(); - - bool public paused = false; - - - /** - * @dev Modifier to make a function callable only when the contract is not paused. - */ - modifier whenNotPaused() { - require(!paused); - _; - } - - /** - * @dev Modifier to make a function callable only when the contract is paused. - */ - modifier whenPaused() { - require(paused); - _; - } - - /** - * @dev called by the owner to pause, triggers stopped state - */ - function pause() public onlyOwner whenNotPaused { - paused = true; - emit Pause(); - } - - /** - * @dev called by the owner to unpause, returns to normal state - */ - function unpause() public onlyOwner whenPaused { - paused = false; - emit Unpause(); - } -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/interfaces/INFTAdaptor.sol - -// pragma solidity ^0.4.24; - - -contract INFTAdaptor { - function toMirrorTokenId(uint256 _originTokenId) public view returns (uint256); - - function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256); - - function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256); - - function approveOriginToken(address _bridge, uint256 _originTokenId) public; - - function ownerInOrigin(uint256 _originTokenId) public view returns (address); - - function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public; -} - - -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - - -/** - * @title ERC721 Non-Fungible Token Standard basic interface - * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Basic is ERC165 { - - bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; - /* - * 0x80ac58cd === - * bytes4(keccak256('balanceOf(address)')) ^ - * bytes4(keccak256('ownerOf(uint256)')) ^ - * bytes4(keccak256('approve(address,uint256)')) ^ - * bytes4(keccak256('getApproved(uint256)')) ^ - * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ - * bytes4(keccak256('isApprovedForAll(address,address)')) ^ - * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) - */ - - bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; - /* - * 0x4f558e79 === - * bytes4(keccak256('exists(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; - /** - * 0x780e9d63 === - * bytes4(keccak256('totalSupply()')) ^ - * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ - * bytes4(keccak256('tokenByIndex(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; - /** - * 0x5b5e139f === - * bytes4(keccak256('name()')) ^ - * bytes4(keccak256('symbol()')) ^ - * bytes4(keccak256('tokenURI(uint256)')) - */ - - event Transfer( - address indexed _from, - address indexed _to, - uint256 indexed _tokenId - ); - event Approval( - address indexed _owner, - address indexed _approved, - uint256 indexed _tokenId - ); - event ApprovalForAll( - address indexed _owner, - address indexed _operator, - bool _approved - ); - - function balanceOf(address _owner) public view returns (uint256 _balance); - function ownerOf(uint256 _tokenId) public view returns (address _owner); - function exists(uint256 _tokenId) public view returns (bool _exists); - - function approve(address _to, uint256 _tokenId) public; - function getApproved(uint256 _tokenId) - public view returns (address _operator); - - function setApprovalForAll(address _operator, bool _approved) public; - function isApprovedForAll(address _owner, address _operator) - public view returns (bool); - - function transferFrom(address _from, address _to, uint256 _tokenId) public; - function safeTransferFrom(address _from, address _to, uint256 _tokenId) - public; - - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - public; -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Enumerable is ERC721Basic { - function totalSupply() public view returns (uint256); - function tokenOfOwnerByIndex( - address _owner, - uint256 _index - ) - public - view - returns (uint256 _tokenId); - - function tokenByIndex(uint256 _index) public view returns (uint256); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional metadata extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Metadata is ERC721Basic { - function name() external view returns (string _name); - function symbol() external view returns (string _symbol); - function tokenURI(uint256 _tokenId) public view returns (string); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, full implementation interface - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { -} - - -// Dependency file: contracts/interfaces/IInterstellarEncoderV3.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoderV3 { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function encodeTokenIdForOuterObjectContract( - address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); - - function getProducerId(uint256 _tokenId) public view returns (uint16); - - function getOriginAddress(uint256 _tokenId) public view returns (address); - -} - -// Dependency file: contracts/interfaces/IERC165.sol - -// SPDX-License-Identifier: MIT - -// pragma solidity ^0.4.24; - -/** - * @dev Interface of the ERC165 standard, as defined in the - * https://eips.ethereum.org/EIPS/eip-165[EIP]. - * - * Implementers can declare support of contract interfaces, which can then be - * queried by others ({ERC165Checker}). - * - * For an implementation, see {ERC165}. - */ -contract IERC165 { - /** - * @dev Returns true if this contract implements the interface defined by - * `interfaceId`. See the corresponding - * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] - * to learn more about how these ids are created. - * - * This function call must use less than 30 000 gas. - */ - function supportsInterface(bytes4 interfaceId) external view returns (bool); -} - - -// Dependency file: contracts/interfaces/IERC1155.sol - - -// pragma solidity ^0.4.24; - -// import "contracts/interfaces/IERC165.sol"; - -/** - * @dev Required interface of an ERC1155 compliant contract, as defined in the - * https://eips.ethereum.org/EIPS/eip-1155[EIP]. - * - * _Available since v3.1._ - */ -contract IERC1155 is IERC165 { - /** - * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. - */ - event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); - - /** - * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all - * transfers. - */ - event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); - - /** - * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to - * `approved`. - */ - event ApprovalForAll(address indexed account, address indexed operator, bool approved); - - /** - * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. - * - * If an {URI} event was emitted for `id`, the standard - * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value - * returned by {IERC1155MetadataURI-uri}. - */ - event URI(string value, uint256 indexed id); - - /** - * @dev Returns the amount of tokens of token type `id` owned by `account`. - * - * Requirements: - * - * - `account` cannot be the zero address. - */ - function balanceOf(address account, uint256 id) external view returns (uint256); - - /** - * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. - * - * Requirements: - * - * - `accounts` and `ids` must have the same length. - */ - function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[] memory); - - /** - * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, - * - * Emits an {ApprovalForAll} event. - * - * Requirements: - * - * - `operator` cannot be the caller. - */ - function setApprovalForAll(address operator, bool approved) external; - - /** - * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. - * - * See {setApprovalForAll}. - */ - function isApprovedForAll(address account, address operator) external view returns (bool); - - /** - * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. - * - * Emits a {TransferSingle} event. - * - * Requirements: - * - * - `to` cannot be the zero address. - * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. - * - `from` must have a balance of tokens of type `id` of at least `amount`. - * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the - * acceptance magic value. - */ - function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external; - - /** - * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. - * - * Emits a {TransferBatch} event. - * - * Requirements: - * - * - `ids` and `amounts` must have the same length. - * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the - * acceptance magic value. - */ - function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external; -} - - -// Root file: contracts/PolkaPetAdaptor.sol - -pragma solidity ^0.4.24; - -// import "contracts/SettingIds.sol"; -// import "contracts/PausableDSAuth.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/interfaces/INFTAdaptor.sol"; -// // import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -// import "contracts/interfaces/IInterstellarEncoderV3.sol"; -// import "contracts/interfaces/IERC1155.sol"; - - -contract PolkaPetAdaptor is PausableDSAuth, SettingIds { - - event SetTokenIDAuth(uint256 indexed tokenId, bool status); - - /* - * Storage - */ - bool private singletonLock = false; - - uint16 public producerId; - - uint8 public convertType; - - ISettingsRegistry public registry; - - IERC1155 public originNft; - - uint128 public lastObjectId; - - // tokenID => bool allowList - mapping (uint256 => bool) public allowList; - - constructor(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public { - registry = _registry; - originNft = _originNft; - producerId = _producerId; - convertType = 128; // f(x) = x,fullfill with zero at left side. - - allowList[2] = true; - allowList[11] = true; - } - - function setTokenIDAuth(uint256 _tokenId, bool _status) public auth { - allowList[_tokenId] = _status; - emit SetTokenIDAuth(_tokenId, _status); - } - - function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256) { - require(allowList[_originTokenId], "POLKPET: PERMISSION"); - lastObjectId += 1; - uint128 mirrorObjectId = uint128(lastObjectId & 0xffffffffffffffffffffffffffffffff); - require(lastObjectId <= uint128(-1), "POLKPET: OBJECTID_OVERFLOW"); - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); - IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - uint256 mirrorTokenId = interstellarEncoder.encodeTokenIdForOuterObjectContract( - petBase, objectOwnership, address(originNft), mirrorObjectId, producerId, convertType); - - return mirrorTokenId; - } - - function ownerInOrigin(uint256 _originTokenId) public view returns (address) { - revert("NOT_SUPPORT"); - } - - // if the convertion is not calculatable, and need to use cache mapping in Bridge. - // then .. - function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256) { - revert("NOT_SUPPORT"); - } - - function approveToBridge(address _bridge) public onlyOwner { - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - IERC1155(objectOwnership).setApprovalForAll(_bridge, true); - } - - function cancelApprove(address _bridge) public onlyOwner { - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - IERC1155(objectOwnership).setApprovalForAll(_bridge, false); - } - - function getObjectClass(uint256 _originTokenId) public view returns (uint8) { - revert("NOT_SUPPORT"); - } - - function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public auth { - revert("NOT_SUPPORT"); - } -} diff --git a/flat/Proposal.sol b/flat/Proposal.sol deleted file mode 100644 index 2b9cf00..0000000 --- a/flat/Proposal.sol +++ /dev/null @@ -1,32 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Root file: contracts/Proposal.sol - -pragma solidity ^0.4.24; - -// import "contracts/interfaces/IAuthority.sol"; - -contract Proposal is IAuthority { - - function doSomething() public { - // do changes to destiantion - } - - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool) - { - if (src == address(this)) - { - return true; - } - } -} \ No newline at end of file diff --git a/flat/ProposalRegistry.sol b/flat/ProposalRegistry.sol deleted file mode 100644 index d9f5efd..0000000 --- a/flat/ProposalRegistry.sol +++ /dev/null @@ -1,215 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/Proposal.sol - -// pragma solidity ^0.4.24; - -// import "contracts/interfaces/IAuthority.sol"; - -contract Proposal is IAuthority { - - function doSomething() public { - // do changes to destiantion - } - - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool) - { - if (src == address(this)) - { - return true; - } - } -} - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Dependency file: contracts/KtonVoter.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; - -/// @title KtonVoter -/// @dev Voting and support specific proposal validator by deposit KTON -/// Vote will be cancel after KTON get withdrawd -/// 1 KTON means one vote -contract KtonVoter { - address public KTON; - - struct VoterItem { - // mapping (address => mapping (address => uint256)) public votes; - mapping (address => uint256) votes; - // mapping (address => uint256) public depositBalances; - uint256 balance; - // TODO: address[] candidates; - } - - struct CandidateItem { - uint256 voteCount; // contract address - uint256 sortedIndex; // index of the item in the list of sortedCandidate - bool isRegistered; // used to tell if the mapping element is defined - // TODO: address[] voters; - } - - mapping (address => VoterItem) public voterItems; - - mapping (address => CandidateItem) public cadidateItems; - - // descending - address[] public sortedCandidates; - - function vote(address _candidate, uint _amount) public { - require(cadidateItems[_candidate].isRegistered); - require(ERC20(KTON).transferFrom(msg.sender, address(this), _amount)); - - voterItems[msg.sender].votes[_candidate] += _amount; - voterItems[msg.sender].balance += _amount; - - cadidateItems[_candidate].voteCount += _amount; - - // TODO: update sortedIndex - quickSort(0, cadidateItems[_candidate].sortedIndex); - } - - function withdrawFrom(address _candidate, uint _amount) public { - require(voterItems[msg.sender].votes[_candidate] >= _amount); - - voterItems[msg.sender].votes[_candidate] -= _amount; - voterItems[msg.sender].balance -= _amount; - cadidateItems[_candidate].voteCount -= _amount; - - require(ERC20(KTON).transfer(msg.sender, _amount)); - - // TODO: update sortedIndex - quickSort(cadidateItems[_candidate].sortedIndex, sortedCandidates.length - 1); - } - - function getCandidate(uint _num) public view returns (address candidate){ - require(_num < sortedCandidates.length); - candidate = sortedCandidates[_num]; - } - - function registerCandidate() public { - // require(ERC20(KTON).transferFrom(msg.sender, address(this), 1000000000000000000000)); - require(!cadidateItems[msg.sender].isRegistered); - - cadidateItems[msg.sender].isRegistered = true; - sortedCandidates.push(msg.sender); - cadidateItems[msg.sender].sortedIndex = sortedCandidates.length - 1; - } - - // http://www.etherdevops.com/content/sorting-array-integer-ethereum - function quickSort(uint left, uint right) internal { - uint i = left; - uint j = right; - uint pivot = cadidateItems[sortedCandidates[left + (right - left) / 2]].voteCount; - while (i <= j) { - while (cadidateItems[sortedCandidates[i]].voteCount < pivot) i++; - while (pivot < cadidateItems[sortedCandidates[j]].voteCount) j--; - if (i <= j) { - (sortedCandidates[i], sortedCandidates[j]) = (sortedCandidates[j], sortedCandidates[i]); - cadidateItems[sortedCandidates[i]].sortedIndex = i; - cadidateItems[sortedCandidates[j]].sortedIndex = j; - - i++; - j--; - } - } - if (left < j) - quickSort(left, j); - if (i < right) - quickSort(i, right); - } -} - -// Root file: contracts/ProposalRegistry.sol - -pragma solidity ^0.4.24; - -// import "contracts/interfaces/IAuthority.sol"; -// import "contracts/Proposal.sol"; -// import "contracts/KtonVoter.sol"; - -contract ProposalRegistry is IAuthority { - - // refer https://github.com/gnosis/MultiSigWallet/blob/master/contracts/MultiSigWallet.sol - // TODO: We can create a similar VoterWallet.sol - mapping (uint => Proposal) public proposals; - mapping (uint => mapping (address => bool)) public confirmations; - - mapping (address => bool) public proposalsApproved; - - KtonVoter public voter; - - uint public required; - - uint public transactionCount; - - function executeProposal(uint proposalId) public { - // TODO - proposals[proposalId].doSomething(); - } - - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool) - { - if (proposalsApproved[src]) - { - return Proposal(src).canCall(src, dst, sig); - } - } -} \ No newline at end of file diff --git a/flat/RBACWithAdmin.sol b/flat/RBACWithAdmin.sol deleted file mode 100644 index ee3f162..0000000 --- a/flat/RBACWithAdmin.sol +++ /dev/null @@ -1,238 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/access/rbac/Roles.sol - -// pragma solidity ^0.4.24; - - -/** - * @title Roles - * @author Francisco Giordano (@frangio) - * @dev Library for managing addresses assigned to a Role. - * See RBAC.sol for example usage. - */ -library Roles { - struct Role { - mapping (address => bool) bearer; - } - - /** - * @dev give an address access to this role - */ - function add(Role storage _role, address _addr) - internal - { - _role.bearer[_addr] = true; - } - - /** - * @dev remove an address' access to this role - */ - function remove(Role storage _role, address _addr) - internal - { - _role.bearer[_addr] = false; - } - - /** - * @dev check if an address has this role - * // reverts - */ - function check(Role storage _role, address _addr) - internal - view - { - require(has(_role, _addr)); - } - - /** - * @dev check if an address has this role - * @return bool - */ - function has(Role storage _role, address _addr) - internal - view - returns (bool) - { - return _role.bearer[_addr]; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/access/rbac/RBAC.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/access/rbac/Roles.sol"; - - -/** - * @title RBAC (Role-Based Access Control) - * @author Matt Condon (@Shrugs) - * @dev Stores and provides setters and getters for roles and addresses. - * Supports unlimited numbers of roles and addresses. - * See //contracts/mocks/RBACMock.sol for an example of usage. - * This RBAC method uses strings to key roles. It may be beneficial - * for you to write your own implementation of this interface using Enums or similar. - */ -contract RBAC { - using Roles for Roles.Role; - - mapping (string => Roles.Role) private roles; - - event RoleAdded(address indexed operator, string role); - event RoleRemoved(address indexed operator, string role); - - /** - * @dev reverts if addr does not have role - * @param _operator address - * @param _role the name of the role - * // reverts - */ - function checkRole(address _operator, string _role) - public - view - { - roles[_role].check(_operator); - } - - /** - * @dev determine if addr has role - * @param _operator address - * @param _role the name of the role - * @return bool - */ - function hasRole(address _operator, string _role) - public - view - returns (bool) - { - return roles[_role].has(_operator); - } - - /** - * @dev add a role to an address - * @param _operator address - * @param _role the name of the role - */ - function addRole(address _operator, string _role) - internal - { - roles[_role].add(_operator); - emit RoleAdded(_operator, _role); - } - - /** - * @dev remove a role from an address - * @param _operator address - * @param _role the name of the role - */ - function removeRole(address _operator, string _role) - internal - { - roles[_role].remove(_operator); - emit RoleRemoved(_operator, _role); - } - - /** - * @dev modifier to scope access to a single role (uses msg.sender as addr) - * @param _role the name of the role - * // reverts - */ - modifier onlyRole(string _role) - { - checkRole(msg.sender, _role); - _; - } - - /** - * @dev modifier to scope access to a set of roles (uses msg.sender as addr) - * @param _roles the names of the roles to scope access to - * // reverts - * - * @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this - * see: https://github.com/ethereum/solidity/issues/2467 - */ - // modifier onlyRoles(string[] _roles) { - // bool hasAnyRole = false; - // for (uint8 i = 0; i < _roles.length; i++) { - // if (hasRole(msg.sender, _roles[i])) { - // hasAnyRole = true; - // break; - // } - // } - - // require(hasAnyRole); - - // _; - // } -} - - -// Root file: contracts/RBACWithAdmin.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/access/rbac/RBAC.sol"; - -// https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/examples/RBACWithAdmin.sol - -/** - * @title RBACWithAdmin - * @author Matt Condon (@Shrugs) - * @dev It's recommended that you define constants in the contract, - * like ROLE_ADMIN below, to avoid typos. - * @notice RBACWithAdmin is probably too expansive and powerful for your - * application; an admin is actually able to change any address to any role - * which is a very large API surface. It's recommended that you follow a strategy - * of strictly defining the abilities of your roles - * and the API-surface of your contract. - * This is just an example for example's sake. - */ -contract RBACWithAdmin is RBAC { - /** - * A constant role name for indicating admins. - */ - string public constant ROLE_ADMIN = "admin"; - - /** - * @dev modifier to scope access to admins - * // reverts - */ - modifier onlyAdmin() - { - checkRole(msg.sender, ROLE_ADMIN); - _; - } - - /** - * @dev constructor. Sets msg.sender as admin by default - */ - constructor() - public - { - addRole(msg.sender, ROLE_ADMIN); - } - - /** - * @dev add a role to an account - * @param _account the account that will have the role - * @param _roleName the name of the role - */ - function adminAddRole(address _account, string _roleName) - public - onlyAdmin - { - addRole(_account, _roleName); - } - - /** - * @dev remove a role from an account - * @param _account the account that will no longer have the role - * @param _roleName the name of the role - */ - function adminRemoveRole(address _account, string _roleName) - public - onlyAdmin - { - removeRole(_account, _roleName); - } -} \ No newline at end of file diff --git a/flat/RBACWithAuth.sol b/flat/RBACWithAuth.sol deleted file mode 100644 index e0e69e5..0000000 --- a/flat/RBACWithAuth.sol +++ /dev/null @@ -1,317 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: openzeppelin-solidity/contracts/access/rbac/Roles.sol - -// pragma solidity ^0.4.24; - - -/** - * @title Roles - * @author Francisco Giordano (@frangio) - * @dev Library for managing addresses assigned to a Role. - * See RBAC.sol for example usage. - */ -library Roles { - struct Role { - mapping (address => bool) bearer; - } - - /** - * @dev give an address access to this role - */ - function add(Role storage _role, address _addr) - internal - { - _role.bearer[_addr] = true; - } - - /** - * @dev remove an address' access to this role - */ - function remove(Role storage _role, address _addr) - internal - { - _role.bearer[_addr] = false; - } - - /** - * @dev check if an address has this role - * // reverts - */ - function check(Role storage _role, address _addr) - internal - view - { - require(has(_role, _addr)); - } - - /** - * @dev check if an address has this role - * @return bool - */ - function has(Role storage _role, address _addr) - internal - view - returns (bool) - { - return _role.bearer[_addr]; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/access/rbac/RBAC.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/access/rbac/Roles.sol"; - - -/** - * @title RBAC (Role-Based Access Control) - * @author Matt Condon (@Shrugs) - * @dev Stores and provides setters and getters for roles and addresses. - * Supports unlimited numbers of roles and addresses. - * See //contracts/mocks/RBACMock.sol for an example of usage. - * This RBAC method uses strings to key roles. It may be beneficial - * for you to write your own implementation of this interface using Enums or similar. - */ -contract RBAC { - using Roles for Roles.Role; - - mapping (string => Roles.Role) private roles; - - event RoleAdded(address indexed operator, string role); - event RoleRemoved(address indexed operator, string role); - - /** - * @dev reverts if addr does not have role - * @param _operator address - * @param _role the name of the role - * // reverts - */ - function checkRole(address _operator, string _role) - public - view - { - roles[_role].check(_operator); - } - - /** - * @dev determine if addr has role - * @param _operator address - * @param _role the name of the role - * @return bool - */ - function hasRole(address _operator, string _role) - public - view - returns (bool) - { - return roles[_role].has(_operator); - } - - /** - * @dev add a role to an address - * @param _operator address - * @param _role the name of the role - */ - function addRole(address _operator, string _role) - internal - { - roles[_role].add(_operator); - emit RoleAdded(_operator, _role); - } - - /** - * @dev remove a role from an address - * @param _operator address - * @param _role the name of the role - */ - function removeRole(address _operator, string _role) - internal - { - roles[_role].remove(_operator); - emit RoleRemoved(_operator, _role); - } - - /** - * @dev modifier to scope access to a single role (uses msg.sender as addr) - * @param _role the name of the role - * // reverts - */ - modifier onlyRole(string _role) - { - checkRole(msg.sender, _role); - _; - } - - /** - * @dev modifier to scope access to a set of roles (uses msg.sender as addr) - * @param _roles the names of the roles to scope access to - * // reverts - * - * @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this - * see: https://github.com/ethereum/solidity/issues/2467 - */ - // modifier onlyRoles(string[] _roles) { - // bool hasAnyRole = false; - // for (uint8 i = 0; i < _roles.length; i++) { - // if (hasRole(msg.sender, _roles[i])) { - // hasAnyRole = true; - // break; - // } - // } - - // require(hasAnyRole); - - // _; - // } -} - - -// Dependency file: contracts/RBACWithAdmin.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/access/rbac/RBAC.sol"; - -// https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/examples/RBACWithAdmin.sol - -/** - * @title RBACWithAdmin - * @author Matt Condon (@Shrugs) - * @dev It's recommended that you define constants in the contract, - * like ROLE_ADMIN below, to avoid typos. - * @notice RBACWithAdmin is probably too expansive and powerful for your - * application; an admin is actually able to change any address to any role - * which is a very large API surface. It's recommended that you follow a strategy - * of strictly defining the abilities of your roles - * and the API-surface of your contract. - * This is just an example for example's sake. - */ -contract RBACWithAdmin is RBAC { - /** - * A constant role name for indicating admins. - */ - string public constant ROLE_ADMIN = "admin"; - - /** - * @dev modifier to scope access to admins - * // reverts - */ - modifier onlyAdmin() - { - checkRole(msg.sender, ROLE_ADMIN); - _; - } - - /** - * @dev constructor. Sets msg.sender as admin by default - */ - constructor() - public - { - addRole(msg.sender, ROLE_ADMIN); - } - - /** - * @dev add a role to an account - * @param _account the account that will have the role - * @param _roleName the name of the role - */ - function adminAddRole(address _account, string _roleName) - public - onlyAdmin - { - addRole(_account, _roleName); - } - - /** - * @dev remove a role from an account - * @param _account the account that will no longer have the role - * @param _roleName the name of the role - */ - function adminRemoveRole(address _account, string _roleName) - public - onlyAdmin - { - removeRole(_account, _roleName); - } -} - -// Root file: contracts/RBACWithAuth.sol - -pragma solidity ^0.4.24; - -// import "contracts/interfaces/IAuthority.sol"; -// import "contracts/RBACWithAdmin.sol"; - -/** - * @title RBACWithAuth - * @dev It's recommended that you define constants in the contract, - * like ROLE_AUTH_CONTROLLER below, to avoid typos. - * This introduce the auth features from ds-auth, an advanced feature added to RBACWithAdmin. - * It's recommended that you follow a strategy - * of strictly defining the abilities of your roles - * and the API-surface of your contract. - */ -contract RBACWithAuth is RBACWithAdmin { - /** - * A constant role name for indicating auth controllers. - */ - string public constant ROLE_AUTH_CONTROLLER = "auth_controller"; - - IAuthority public authority; - - event LogSetAuthority (address indexed authority); - - /** - * @dev modifier to scope access to auth controllers - * // reverts - */ - modifier onlyAuthController() - { - checkRole(msg.sender, ROLE_AUTH_CONTROLLER); - _; - } - - modifier isAuth { - require( isAuthorized(msg.sender, msg.sig) ); - _; - } - - /** - * @dev constructor. Sets msg.sender as auth controllers by default - */ - constructor() public - { - addRole(msg.sender, ROLE_AUTH_CONTROLLER); - } - - function setAuthority(IAuthority _authority) - public - onlyAuthController - { - authority = _authority; - emit LogSetAuthority(authority); - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if ( hasRole(msg.sender, ROLE_AUTH_CONTROLLER) ) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } - -} \ No newline at end of file diff --git a/flat/SettingIds.sol b/flat/SettingIds.sol deleted file mode 100644 index bd1ccd4..0000000 --- a/flat/SettingIds.sol +++ /dev/null @@ -1,88 +0,0 @@ -// Root file: contracts/SettingIds.sol - -pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} \ No newline at end of file diff --git a/flat/SettingsRegistry.sol b/flat/SettingsRegistry.sol deleted file mode 100644 index 5abb2b6..0000000 --- a/flat/SettingsRegistry.sol +++ /dev/null @@ -1,224 +0,0 @@ -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Root file: contracts/SettingsRegistry.sol - -pragma solidity ^0.4.24; - -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/DSAuth.sol"; - -/** - * @title SettingsRegistry - * @dev This contract holds all the settings for updating and querying. - */ -contract SettingsRegistry is ISettingsRegistry, DSAuth { - - mapping(bytes32 => uint256) public uintProperties; - mapping(bytes32 => string) public stringProperties; - mapping(bytes32 => address) public addressProperties; - mapping(bytes32 => bytes) public bytesProperties; - mapping(bytes32 => bool) public boolProperties; - mapping(bytes32 => int256) public intProperties; - - mapping(bytes32 => SettingsValueTypes) public valueTypes; - - function uintOf(bytes32 _propertyName) public view returns (uint256) { - require(valueTypes[_propertyName] == SettingsValueTypes.UINT, "Property type does not match."); - return uintProperties[_propertyName]; - } - - function stringOf(bytes32 _propertyName) public view returns (string) { - require(valueTypes[_propertyName] == SettingsValueTypes.STRING, "Property type does not match."); - return stringProperties[_propertyName]; - } - - function addressOf(bytes32 _propertyName) public view returns (address) { - require(valueTypes[_propertyName] == SettingsValueTypes.ADDRESS, "Property type does not match."); - return addressProperties[_propertyName]; - } - - function bytesOf(bytes32 _propertyName) public view returns (bytes) { - require(valueTypes[_propertyName] == SettingsValueTypes.BYTES, "Property type does not match."); - return bytesProperties[_propertyName]; - } - - function boolOf(bytes32 _propertyName) public view returns (bool) { - require(valueTypes[_propertyName] == SettingsValueTypes.BOOL, "Property type does not match."); - return boolProperties[_propertyName]; - } - - function intOf(bytes32 _propertyName) public view returns (int) { - require(valueTypes[_propertyName] == SettingsValueTypes.INT, "Property type does not match."); - return intProperties[_propertyName]; - } - - function setUintProperty(bytes32 _propertyName, uint _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.UINT, "Property type does not match."); - uintProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.UINT; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.UINT)); - } - - function setStringProperty(bytes32 _propertyName, string _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.STRING, "Property type does not match."); - stringProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.STRING; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.STRING)); - } - - function setAddressProperty(bytes32 _propertyName, address _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.ADDRESS, "Property type does not match."); - - addressProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.ADDRESS; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.ADDRESS)); - } - - function setBytesProperty(bytes32 _propertyName, bytes _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.BYTES, "Property type does not match."); - - bytesProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.BYTES; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.BYTES)); - } - - function setBoolProperty(bytes32 _propertyName, bool _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.BOOL, "Property type does not match."); - - boolProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.BOOL; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.BOOL)); - } - - function setIntProperty(bytes32 _propertyName, int _value) public auth { - require( - valueTypes[_propertyName] == SettingsValueTypes.NONE || valueTypes[_propertyName] == SettingsValueTypes.INT, "Property type does not match."); - - intProperties[_propertyName] = _value; - valueTypes[_propertyName] = SettingsValueTypes.INT; - - emit ChangeProperty(_propertyName, uint256(SettingsValueTypes.INT)); - } - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint256 /* SettingsValueTypes */ ) { - return uint256(valueTypes[_propertyName]); - } - -} \ No newline at end of file diff --git a/flat/StandardERC20Base.sol b/flat/StandardERC20Base.sol deleted file mode 100644 index 21763b7..0000000 --- a/flat/StandardERC20Base.sol +++ /dev/null @@ -1,153 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol - -// pragma solidity ^0.4.24; - - -/** - * @title SafeMath - * @dev Math operations with safety checks that throw on error - */ -library SafeMath { - - /** - * @dev Multiplies two numbers, throws on overflow. - */ - function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - // Gas optimization: this is cheaper than asserting 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - c = _a * _b; - assert(c / _a == _b); - return c; - } - - /** - * @dev Integer division of two numbers, truncating the quotient. - */ - function div(uint256 _a, uint256 _b) internal pure returns (uint256) { - // assert(_b > 0); // Solidity automatically throws when dividing by 0 - // uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - return _a / _b; - } - - /** - * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - assert(_b <= _a); - return _a - _b; - } - - /** - * @dev Adds two numbers, throws on overflow. - */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - c = _a + _b; - assert(c >= _a); - return c; - } -} - - -// Root file: contracts/StandardERC20Base.sol - -pragma solidity ^0.4.23; - -// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol'; -// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; - -contract StandardERC20Base is ERC20 { - using SafeMath for uint256; - - uint256 _supply; - mapping (address => uint256) _balances; - mapping (address => mapping (address => uint256)) _approvals; - - function totalSupply() public view returns (uint) { - return _supply; - } - function balanceOf(address src) public view returns (uint) { - return _balances[src]; - } - function allowance(address src, address guy) public view returns (uint) { - return _approvals[src][guy]; - } - - function transfer(address dst, uint wad) public returns (bool) { - return transferFrom(msg.sender, dst, wad); - } - - function transferFrom(address src, address dst, uint wad) - public - returns (bool) - { - if (src != msg.sender) { - _approvals[src][msg.sender] = _approvals[src][msg.sender].sub(wad); - } - - _balances[src] = _balances[src].sub(wad); - _balances[dst] = _balances[dst].add(wad); - - emit Transfer(src, dst, wad); - - return true; - } - - function approve(address guy, uint wad) public returns (bool) { - _approvals[msg.sender][guy] = wad; - - emit Approval(msg.sender, guy, wad); - - return true; - } -} diff --git a/flat/StandardERC223.sol b/flat/StandardERC223.sol deleted file mode 100644 index c67f119..0000000 --- a/flat/StandardERC223.sol +++ /dev/null @@ -1,521 +0,0 @@ -// Dependency file: contracts/interfaces/ERC223ReceivingContract.sol - -// pragma solidity ^0.4.23; - - /* - * Contract that is working with ERC223 tokens - * https://github.com/ethereum/EIPs/issues/223 - */ - -/// @title ERC223ReceivingContract - Standard contract implementation for compatibility with ERC223 tokens. -contract ERC223ReceivingContract { - - /// @dev Function that is called when a user or another contract wants to transfer funds. - /// @param _from Transaction initiator, analogue of msg.sender - /// @param _value Number of tokens to transfer. - /// @param _data Data containig a function signature and/or parameters - function tokenFallback(address _from, uint256 _value, bytes _data) public; - -} - - -// Dependency file: contracts/interfaces/TokenController.sol - -// pragma solidity ^0.4.23; - - -/// @dev The token controller contract must implement these functions -contract TokenController { - /// @notice Called when `_owner` sends ether to the MiniMe Token contract - /// @param _owner The address that sent the ether to create tokens - /// @return True if the ether is accepted, false if it throws - function proxyPayment(address _owner, bytes4 sig, bytes data) payable public returns (bool); - - /// @notice Notifies the controller about a token transfer allowing the - /// controller to react if desired - /// @param _from The origin of the transfer - /// @param _to The destination of the transfer - /// @param _amount The amount of the transfer - /// @return False if the controller does not authorize the transfer - function onTransfer(address _from, address _to, uint _amount) public returns (bool); - - /// @notice Notifies the controller about an approval allowing the - /// controller to react if desired - /// @param _owner The address that calls `approve()` - /// @param _spender The spender in the `approve()` call - /// @param _amount The amount in the `approve()` call - /// @return False if the controller does not authorize the approval - function onApprove(address _owner, address _spender, uint _amount) public returns (bool); -} - - -// Dependency file: contracts/interfaces/ApproveAndCallFallBack.sol - -// pragma solidity ^0.4.23; - -contract ApproveAndCallFallBack { - function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public; -} - -// Dependency file: contracts/interfaces/ERC223.sol - -// pragma solidity ^0.4.23; - -contract ERC223 { - function transfer(address to, uint amount, bytes data) public returns (bool ok); - - function transferFrom(address from, address to, uint256 amount, bytes data) public returns (bool ok); - - event ERC223Transfer(address indexed from, address indexed to, uint amount, bytes data); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol - -// pragma solidity ^0.4.24; - - -/** - * @title SafeMath - * @dev Math operations with safety checks that throw on error - */ -library SafeMath { - - /** - * @dev Multiplies two numbers, throws on overflow. - */ - function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - // Gas optimization: this is cheaper than asserting 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - c = _a * _b; - assert(c / _a == _b); - return c; - } - - /** - * @dev Integer division of two numbers, truncating the quotient. - */ - function div(uint256 _a, uint256 _b) internal pure returns (uint256) { - // assert(_b > 0); // Solidity automatically throws when dividing by 0 - // uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - return _a / _b; - } - - /** - * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - assert(_b <= _a); - return _a - _b; - } - - /** - * @dev Adds two numbers, throws on overflow. - */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - c = _a + _b; - assert(c >= _a); - return c; - } -} - - -// Dependency file: contracts/StandardERC20Base.sol - -// pragma solidity ^0.4.23; - -// import '/Users/echo/workspace/contract/evolutionlandorg/common-contracts/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol'; -// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; - -contract StandardERC20Base is ERC20 { - using SafeMath for uint256; - - uint256 _supply; - mapping (address => uint256) _balances; - mapping (address => mapping (address => uint256)) _approvals; - - function totalSupply() public view returns (uint) { - return _supply; - } - function balanceOf(address src) public view returns (uint) { - return _balances[src]; - } - function allowance(address src, address guy) public view returns (uint) { - return _approvals[src][guy]; - } - - function transfer(address dst, uint wad) public returns (bool) { - return transferFrom(msg.sender, dst, wad); - } - - function transferFrom(address src, address dst, uint wad) - public - returns (bool) - { - if (src != msg.sender) { - _approvals[src][msg.sender] = _approvals[src][msg.sender].sub(wad); - } - - _balances[src] = _balances[src].sub(wad); - _balances[dst] = _balances[dst].add(wad); - - emit Transfer(src, dst, wad); - - return true; - } - - function approve(address guy, uint wad) public returns (bool) { - _approvals[msg.sender][guy] = wad; - - emit Approval(msg.sender, guy, wad); - - return true; - } -} - - -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Root file: contracts/StandardERC223.sol - -pragma solidity ^0.4.24; - -// import 'contracts/interfaces/ERC223ReceivingContract.sol'; -// import 'contracts/interfaces/TokenController.sol'; -// import 'contracts/interfaces/ApproveAndCallFallBack.sol'; -// import 'contracts/interfaces/ERC223.sol'; -// import 'contracts/StandardERC20Base.sol'; -// import 'contracts/DSAuth.sol'; - -// This is a contract for demo and test. -contract StandardERC223 is StandardERC20Base, DSAuth, ERC223 { - event Burn(address indexed burner, uint256 value); - event Mint(address indexed to, uint256 amount); - - bytes32 public symbol; - uint256 public decimals = 18; // standard token precision. override to customize - // Optional token name - bytes32 public name = ""; - - address public controller; - - constructor(bytes32 _symbol) public { - symbol = _symbol; - controller = msg.sender; - } - - function setName(bytes32 name_) public auth { - name = name_; - } - -////////// -// Controller Methods -////////// - /// @notice Changes the controller of the contract - /// @param _newController The new controller of the contract - function changeController(address _newController) public auth { - controller = _newController; - } - - /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it - /// is approved by `_from` - /// @param _from The address holding the tokens being transferred - /// @param _to The address of the recipient - /// @param _amount The amount of tokens to be transferred - /// @return True if the transfer was successful - function transferFrom(address _from, address _to, uint256 _amount - ) public returns (bool success) { - // Alerts the token controller of the transfer - if (isContract(controller)) { - if (!TokenController(controller).onTransfer(_from, _to, _amount)) - revert(); - } - - success = super.transferFrom(_from, _to, _amount); - } - - /* - * ERC 223 - * Added support for the ERC 223 "tokenFallback" method in a "transfer" function with a payload. - */ - function transferFrom(address _from, address _to, uint256 _amount, bytes _data) - public - returns (bool success) - { - // Alerts the token controller of the transfer - if (isContract(controller)) { - if (!TokenController(controller).onTransfer(_from, _to, _amount)) - revert(); - } - - require(super.transferFrom(_from, _to, _amount)); - - if (isContract(_to)) { - ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); - receiver.tokenFallback(_from, _amount, _data); - } - - emit ERC223Transfer(_from, _to, _amount, _data); - - return true; - } - - function issue(address _to, uint256 _amount) public auth { - mint(_to, _amount); - } - - function destroy(address _from, uint256 _amount) public auth { - burn(_from, _amount); - } - - function mint(address _to, uint _amount) public auth { - _supply = _supply.add(_amount); - _balances[_to] = _balances[_to].add(_amount); - emit Mint(_to, _amount); - emit Transfer(address(0), _to, _amount); - } - - function burn(address _who, uint _value) public auth { - require(_value <= _balances[_who]); - // no need to require value <= totalSupply, since that would imply the - // sender's balance is greater than the totalSupply, which *should* be an assertion failure - - _balances[_who] = _balances[_who].sub(_value); - _supply = _supply.sub(_value); - emit Burn(_who, _value); - emit Transfer(_who, address(0), _value); - } - - /* - * ERC 223 - * Added support for the ERC 223 "tokenFallback" method in a "transfer" function with a payload. - * https://github.com/ethereum/EIPs/issues/223 - * function transfer(address _to, uint256 _value, bytes _data) public returns (bool success); - */ - /// @notice Send `_value` tokens to `_to` from `msg.sender` and trigger - /// tokenFallback if sender is a contract. - /// @dev Function that is called when a user or another contract wants to transfer funds. - /// @param _to Address of token receiver. - /// @param _amount Number of tokens to transfer. - /// @param _data Data to be sent to tokenFallback - /// @return Returns success of function call. - function transfer( - address _to, - uint256 _amount, - bytes _data) - public - returns (bool success) - { - return transferFrom(msg.sender, _to, _amount, _data); - } - - /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on - /// its behalf. This is a modified version of the ERC20 approve function - /// to be a little bit safer - /// @param _spender The address of the account able to transfer the tokens - /// @param _amount The amount of tokens to be approved for transfer - /// @return True if the approval was successful - function approve(address _spender, uint256 _amount) public returns (bool success) { - // Alerts the token controller of the approve function call - if (isContract(controller)) { - if (!TokenController(controller).onApprove(msg.sender, _spender, _amount)) - revert(); - } - - return super.approve(_spender, _amount); - } - - /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on - /// its behalf, and then a function is triggered in the contract that is - /// being approved, `_spender`. This allows users to use their tokens to - /// interact with contracts in one function call instead of two - /// @param _spender The address of the contract able to transfer the tokens - /// @param _amount The amount of tokens to be approved for transfer - /// @return True if the function call was successful - function approveAndCall(address _spender, uint256 _amount, bytes _extraData - ) public returns (bool success) { - if (!approve(_spender, _amount)) revert(); - - ApproveAndCallFallBack(_spender).receiveApproval( - msg.sender, - _amount, - this, - _extraData - ); - - return true; - } - - /// @dev Internal function to determine if an address is a contract - /// @param _addr The address being queried - /// @return True if `_addr` is a contract - function isContract(address _addr) constant internal returns(bool) { - uint size; - if (_addr == 0) return false; - assembly { - size := extcodesize(_addr) - } - return size>0; - } - - /// @notice The fallback function: If the contract's controller has not been - /// set to 0, then the `proxyPayment` method is called which relays the - /// ether and creates tokens as described in the token controller contract - function () public payable { - if (isContract(controller)) { - if (! TokenController(controller).proxyPayment.value(msg.value)(msg.sender, msg.sig, msg.data)) - revert(); - } else { - revert(); - } - } - -////////// -// Safety Methods -////////// - - /// @notice This method can be used by the owner to extract mistakenly - /// sent tokens to this contract. - /// @param _token The address of the token contract that you want to recover - /// set to 0 in case you want to extract ether. - function claimTokens(address _token) public auth { - if (_token == 0x0) { - address(msg.sender).transfer(address(this).balance); - return; - } - - ERC20 token = ERC20(_token); - uint balance = token.balanceOf(this); - token.transfer(address(msg.sender), balance); - - emit ClaimedTokens(_token, address(msg.sender), balance); - } - -//////////////// -// Events -//////////////// - - event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); -} \ No newline at end of file diff --git a/flat/StringUtil.sol b/flat/StringUtil.sol deleted file mode 100644 index 4db925d..0000000 --- a/flat/StringUtil.sol +++ /dev/null @@ -1,706 +0,0 @@ -// Root file: contracts/StringUtil.sol - -// https://github.com/Arachnid/solidity-stringutils/tree/master/src - -// https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol#L1036 - -pragma solidity ^0.4.14; - -library StringUtil { - struct slice { - uint _len; - uint _ptr; - } - - function memcpy(uint dest, uint src, uint len) private pure { - // Copy word-length chunks while possible - for(; len >= 32; len -= 32) { - assembly { - mstore(dest, mload(src)) - } - dest += 32; - src += 32; - } - - // Copy remaining bytes - uint mask = 256 ** (32 - len) - 1; - assembly { - let srcpart := and(mload(src), not(mask)) - let destpart := and(mload(dest), mask) - mstore(dest, or(destpart, srcpart)) - } - } - - /* - * @dev Returns a slice containing the entire string. - * @param self The string to make a slice from. - * @return A newly allocated slice containing the entire string. - */ - function toSlice(string memory self) internal pure returns (slice memory) { - uint ptr; - assembly { - ptr := add(self, 0x20) - } - return slice(bytes(self).length, ptr); - } - - /* - * @dev Returns the length of a null-terminated bytes32 string. - * @param self The value to find the length of. - * @return The length of the string, from 0 to 32. - */ - function len(bytes32 self) internal pure returns (uint) { - uint ret; - if (self == 0) - return 0; - if (self & 0xffffffffffffffffffffffffffffffff == 0) { - ret += 16; - self = bytes32(uint(self) / 0x100000000000000000000000000000000); - } - if (self & 0xffffffffffffffff == 0) { - ret += 8; - self = bytes32(uint(self) / 0x10000000000000000); - } - if (self & 0xffffffff == 0) { - ret += 4; - self = bytes32(uint(self) / 0x100000000); - } - if (self & 0xffff == 0) { - ret += 2; - self = bytes32(uint(self) / 0x10000); - } - if (self & 0xff == 0) { - ret += 1; - } - return 32 - ret; - } - - /* - * @dev Returns a slice containing the entire bytes32, interpreted as a - * null-terminated utf-8 string. - * @param self The bytes32 value to convert to a slice. - * @return A new slice containing the value of the input argument up to the - * first null. - */ - function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { - // Allocate space for `self` in memory, copy it there, and point ret at it - assembly { - let ptr := mload(0x40) - mstore(0x40, add(ptr, 0x20)) - mstore(ptr, self) - mstore(add(ret, 0x20), ptr) - } - ret._len = len(self); - } - - /* - * @dev Returns a new slice containing the same data as the current slice. - * @param self The slice to copy. - * @return A new slice containing the same data as `self`. - */ - function copy(slice memory self) internal pure returns (slice memory) { - return slice(self._len, self._ptr); - } - - /* - * @dev Copies a slice to a new string. - * @param self The slice to copy. - * @return A newly allocated string containing the slice's text. - */ - function toString(slice memory self) internal pure returns (string memory) { - string memory ret = new string(self._len); - uint retptr; - assembly { retptr := add(ret, 32) } - - memcpy(retptr, self._ptr, self._len); - return ret; - } - - /* - * @dev Returns the length in runes of the slice. Note that this operation - * takes time proportional to the length of the slice; avoid using it - * in loops, and call `slice.empty()` if you only need to know whether - * the slice is empty or not. - * @param self The slice to operate on. - * @return The length of the slice in runes. - */ - function len(slice memory self) internal pure returns (uint l) { - // Starting at ptr-31 means the LSB will be the byte we care about - uint ptr = self._ptr - 31; - uint end = ptr + self._len; - for (l = 0; ptr < end; l++) { - uint8 b; - assembly { b := and(mload(ptr), 0xFF) } - if (b < 0x80) { - ptr += 1; - } else if(b < 0xE0) { - ptr += 2; - } else if(b < 0xF0) { - ptr += 3; - } else if(b < 0xF8) { - ptr += 4; - } else if(b < 0xFC) { - ptr += 5; - } else { - ptr += 6; - } - } - } - - /* - * @dev Returns true if the slice is empty (has a length of 0). - * @param self The slice to operate on. - * @return True if the slice is empty, False otherwise. - */ - function empty(slice memory self) internal pure returns (bool) { - return self._len == 0; - } - - /* - * @dev Returns a positive number if `other` comes lexicographically after - * `self`, a negative number if it comes before, or zero if the - * contents of the two slices are equal. Comparison is done per-rune, - * on unicode codepoints. - * @param self The first slice to compare. - * @param other The second slice to compare. - * @return The result of the comparison. - */ - function compare(slice memory self, slice memory other) internal pure returns (int) { - uint shortest = self._len; - if (other._len < self._len) - shortest = other._len; - - uint selfptr = self._ptr; - uint otherptr = other._ptr; - for (uint idx = 0; idx < shortest; idx += 32) { - uint a; - uint b; - assembly { - a := mload(selfptr) - b := mload(otherptr) - } - if (a != b) { - // Mask out irrelevant bytes and check again - uint256 mask = uint256(-1); // 0xffff... - if(shortest < 32) { - mask = ~(2 ** (8 * (32 - shortest + idx)) - 1); - } - uint256 diff = (a & mask) - (b & mask); - if (diff != 0) - return int(diff); - } - selfptr += 32; - otherptr += 32; - } - return int(self._len) - int(other._len); - } - - /* - * @dev Returns true if the two slices contain the same text. - * @param self The first slice to compare. - * @param self The second slice to compare. - * @return True if the slices are equal, false otherwise. - */ - function equals(slice memory self, slice memory other) internal pure returns (bool) { - return compare(self, other) == 0; - } - - /* - * @dev Extracts the first rune in the slice into `rune`, advancing the - * slice to point to the next rune and returning `self`. - * @param self The slice to operate on. - * @param rune The slice that will contain the first rune. - * @return `rune`. - */ - function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) { - rune._ptr = self._ptr; - - if (self._len == 0) { - rune._len = 0; - return rune; - } - - uint l; - uint b; - // Load the first byte of the rune into the LSBs of b - assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) } - if (b < 0x80) { - l = 1; - } else if(b < 0xE0) { - l = 2; - } else if(b < 0xF0) { - l = 3; - } else { - l = 4; - } - - // Check for truncated codepoints - if (l > self._len) { - rune._len = self._len; - self._ptr += self._len; - self._len = 0; - return rune; - } - - self._ptr += l; - self._len -= l; - rune._len = l; - return rune; - } - - /* - * @dev Returns the first rune in the slice, advancing the slice to point - * to the next rune. - * @param self The slice to operate on. - * @return A slice containing only the first rune from `self`. - */ - function nextRune(slice memory self) internal pure returns (slice memory ret) { - nextRune(self, ret); - } - - /* - * @dev Returns the number of the first codepoint in the slice. - * @param self The slice to operate on. - * @return The number of the first codepoint in the slice. - */ - function ord(slice memory self) internal pure returns (uint ret) { - if (self._len == 0) { - return 0; - } - - uint word; - uint length; - uint divisor = 2 ** 248; - - // Load the rune into the MSBs of b - assembly { word:= mload(mload(add(self, 32))) } - uint b = word / divisor; - if (b < 0x80) { - ret = b; - length = 1; - } else if(b < 0xE0) { - ret = b & 0x1F; - length = 2; - } else if(b < 0xF0) { - ret = b & 0x0F; - length = 3; - } else { - ret = b & 0x07; - length = 4; - } - - // Check for truncated codepoints - if (length > self._len) { - return 0; - } - - for (uint i = 1; i < length; i++) { - divisor = divisor / 256; - b = (word / divisor) & 0xFF; - if (b & 0xC0 != 0x80) { - // Invalid UTF-8 sequence - return 0; - } - ret = (ret * 64) | (b & 0x3F); - } - - return ret; - } - - /* - * @dev Returns the keccak-256 hash of the slice. - * @param self The slice to hash. - * @return The hash of the slice. - */ - function keccak(slice memory self) internal pure returns (bytes32 ret) { - assembly { - ret := keccak256(mload(add(self, 32)), mload(self)) - } - } - - /* - * @dev Returns true if `self` starts with `needle`. - * @param self The slice to operate on. - * @param needle The slice to search for. - * @return True if the slice starts with the provided text, false otherwise. - */ - function startsWith(slice memory self, slice memory needle) internal pure returns (bool) { - if (self._len < needle._len) { - return false; - } - - if (self._ptr == needle._ptr) { - return true; - } - - bool equal; - assembly { - let length := mload(needle) - let selfptr := mload(add(self, 0x20)) - let needleptr := mload(add(needle, 0x20)) - equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) - } - return equal; - } - - /* - * @dev If `self` starts with `needle`, `needle` is removed from the - * beginning of `self`. Otherwise, `self` is unmodified. - * @param self The slice to operate on. - * @param needle The slice to search for. - * @return `self` - */ - function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) { - if (self._len < needle._len) { - return self; - } - - bool equal = true; - if (self._ptr != needle._ptr) { - assembly { - let length := mload(needle) - let selfptr := mload(add(self, 0x20)) - let needleptr := mload(add(needle, 0x20)) - equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) - } - } - - if (equal) { - self._len -= needle._len; - self._ptr += needle._len; - } - - return self; - } - - /* - * @dev Returns true if the slice ends with `needle`. - * @param self The slice to operate on. - * @param needle The slice to search for. - * @return True if the slice starts with the provided text, false otherwise. - */ - function endsWith(slice memory self, slice memory needle) internal pure returns (bool) { - if (self._len < needle._len) { - return false; - } - - uint selfptr = self._ptr + self._len - needle._len; - - if (selfptr == needle._ptr) { - return true; - } - - bool equal; - assembly { - let length := mload(needle) - let needleptr := mload(add(needle, 0x20)) - equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) - } - - return equal; - } - - /* - * @dev If `self` ends with `needle`, `needle` is removed from the - * end of `self`. Otherwise, `self` is unmodified. - * @param self The slice to operate on. - * @param needle The slice to search for. - * @return `self` - */ - function until(slice memory self, slice memory needle) internal pure returns (slice memory) { - if (self._len < needle._len) { - return self; - } - - uint selfptr = self._ptr + self._len - needle._len; - bool equal = true; - if (selfptr != needle._ptr) { - assembly { - let length := mload(needle) - let needleptr := mload(add(needle, 0x20)) - equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) - } - } - - if (equal) { - self._len -= needle._len; - } - - return self; - } - - // Returns the memory address of the first byte of the first occurrence of - // `needle` in `self`, or the first byte after `self` if not found. - function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { - uint ptr = selfptr; - uint idx; - - if (needlelen <= selflen) { - if (needlelen <= 32) { - bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); - - bytes32 needledata; - assembly { needledata := and(mload(needleptr), mask) } - - uint end = selfptr + selflen - needlelen; - bytes32 ptrdata; - assembly { ptrdata := and(mload(ptr), mask) } - - while (ptrdata != needledata) { - if (ptr >= end) - return selfptr + selflen; - ptr++; - assembly { ptrdata := and(mload(ptr), mask) } - } - return ptr; - } else { - // For long needles, use hashing - bytes32 hash; - assembly { hash := keccak256(needleptr, needlelen) } - - for (idx = 0; idx <= selflen - needlelen; idx++) { - bytes32 testHash; - assembly { testHash := keccak256(ptr, needlelen) } - if (hash == testHash) - return ptr; - ptr += 1; - } - } - } - return selfptr + selflen; - } - - // Returns the memory address of the first byte after the last occurrence of - // `needle` in `self`, or the address of `self` if not found. - function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { - uint ptr; - - if (needlelen <= selflen) { - if (needlelen <= 32) { - bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); - - bytes32 needledata; - assembly { needledata := and(mload(needleptr), mask) } - - ptr = selfptr + selflen - needlelen; - bytes32 ptrdata; - assembly { ptrdata := and(mload(ptr), mask) } - - while (ptrdata != needledata) { - if (ptr <= selfptr) - return selfptr; - ptr--; - assembly { ptrdata := and(mload(ptr), mask) } - } - return ptr + needlelen; - } else { - // For long needles, use hashing - bytes32 hash; - assembly { hash := keccak256(needleptr, needlelen) } - ptr = selfptr + (selflen - needlelen); - while (ptr >= selfptr) { - bytes32 testHash; - assembly { testHash := keccak256(ptr, needlelen) } - if (hash == testHash) - return ptr + needlelen; - ptr -= 1; - } - } - } - return selfptr; - } - - /* - * @dev Modifies `self` to contain everything from the first occurrence of - * `needle` to the end of the slice. `self` is set to the empty slice - * if `needle` is not found. - * @param self The slice to search and modify. - * @param needle The text to search for. - * @return `self`. - */ - function find(slice memory self, slice memory needle) internal pure returns (slice memory) { - uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); - self._len -= ptr - self._ptr; - self._ptr = ptr; - return self; - } - - /* - * @dev Modifies `self` to contain the part of the string from the start of - * `self` to the end of the first occurrence of `needle`. If `needle` - * is not found, `self` is set to the empty slice. - * @param self The slice to search and modify. - * @param needle The text to search for. - * @return `self`. - */ - function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) { - uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); - self._len = ptr - self._ptr; - return self; - } - - /* - * @dev Splits the slice, setting `self` to everything after the first - * occurrence of `needle`, and `token` to everything before it. If - * `needle` does not occur in `self`, `self` is set to the empty slice, - * and `token` is set to the entirety of `self`. - * @param self The slice to split. - * @param needle The text to search for in `self`. - * @param token An output parameter to which the first token is written. - * @return `token`. - */ - function split(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { - uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); - token._ptr = self._ptr; - token._len = ptr - self._ptr; - if (ptr == self._ptr + self._len) { - // Not found - self._len = 0; - } else { - self._len -= token._len + needle._len; - self._ptr = ptr + needle._len; - } - return token; - } - - /* - * @dev Splits the slice, setting `self` to everything after the first - * occurrence of `needle`, and returning everything before it. If - * `needle` does not occur in `self`, `self` is set to the empty slice, - * and the entirety of `self` is returned. - * @param self The slice to split. - * @param needle The text to search for in `self`. - * @return The part of `self` up to the first occurrence of `delim`. - */ - function split(slice memory self, slice memory needle) internal pure returns (slice memory token) { - split(self, needle, token); - } - - /* - * @dev Splits the slice, setting `self` to everything before the last - * occurrence of `needle`, and `token` to everything after it. If - * `needle` does not occur in `self`, `self` is set to the empty slice, - * and `token` is set to the entirety of `self`. - * @param self The slice to split. - * @param needle The text to search for in `self`. - * @param token An output parameter to which the first token is written. - * @return `token`. - */ - function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { - uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); - token._ptr = ptr; - token._len = self._len - (ptr - self._ptr); - if (ptr == self._ptr) { - // Not found - self._len = 0; - } else { - self._len -= token._len + needle._len; - } - return token; - } - - /* - * @dev Splits the slice, setting `self` to everything before the last - * occurrence of `needle`, and returning everything after it. If - * `needle` does not occur in `self`, `self` is set to the empty slice, - * and the entirety of `self` is returned. - * @param self The slice to split. - * @param needle The text to search for in `self`. - * @return The part of `self` after the last occurrence of `delim`. - */ - function rsplit(slice memory self, slice memory needle) internal pure returns (slice memory token) { - rsplit(self, needle, token); - } - - /* - * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`. - * @param self The slice to search. - * @param needle The text to search for in `self`. - * @return The number of occurrences of `needle` found in `self`. - */ - function count(slice memory self, slice memory needle) internal pure returns (uint cnt) { - uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; - while (ptr <= self._ptr + self._len) { - cnt++; - ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; - } - } - - /* - * @dev Returns True if `self` contains `needle`. - * @param self The slice to search. - * @param needle The text to search for in `self`. - * @return True if `needle` is found in `self`, false otherwise. - */ - function contains(slice memory self, slice memory needle) internal pure returns (bool) { - return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; - } - - /* - * @dev Returns a newly allocated string containing the concatenation of - * `self` and `other`. - * @param self The first slice to concatenate. - * @param other The second slice to concatenate. - * @return The concatenation of the two strings. - */ - function concat(slice memory self, slice memory other) internal pure returns (string memory) { - string memory ret = new string(self._len + other._len); - uint retptr; - assembly { retptr := add(ret, 32) } - memcpy(retptr, self._ptr, self._len); - memcpy(retptr + self._len, other._ptr, other._len); - return ret; - } - - /* - * @dev Joins an array of slices, using `self` as a delimiter, returning a - * newly allocated string. - * @param self The delimiter to use. - * @param parts A list of slices to join. - * @return A newly allocated string containing all the slices in `parts`, - * joined with `self`. - */ - function join(slice memory self, slice[] memory parts) internal pure returns (string memory) { - if (parts.length == 0) - return ""; - - uint length = self._len * (parts.length - 1); - for(uint i = 0; i < parts.length; i++) - length += parts[i]._len; - - string memory ret = new string(length); - uint retptr; - assembly { retptr := add(ret, 32) } - - for(i = 0; i < parts.length; i++) { - memcpy(retptr, parts[i]._ptr, parts[i]._len); - retptr += parts[i]._len; - if (i < parts.length - 1) { - memcpy(retptr, self._ptr, self._len); - retptr += self._len; - } - } - - return ret; - } - - function uint2str(uint _int) internal pure returns (string memory _uintAsString) { - uint _i = _int; - if (_i == 0) { - return "0"; - } - uint j = _i; - uint length; - while (j != 0) { - length++; - j /= 10; - } - bytes memory bstr = new bytes(length); - uint k = length - 1; - while (_i != 0) { - bstr[k--] = byte(uint8(48 + _i % 10)); - _i /= 10; - } - return string(bstr); - } -} \ No newline at end of file diff --git a/flat/TokenBuildInGenesis.sol b/flat/TokenBuildInGenesis.sol deleted file mode 100644 index feb221a..0000000 --- a/flat/TokenBuildInGenesis.sol +++ /dev/null @@ -1,359 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Dependency file: contracts/interfaces/IBurnableERC20.sol - -// pragma solidity ^0.4.23; - -contract IBurnableERC20 { - function burn(address _from, uint _value) public; -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Root file: contracts/TokenBuildInGenesis.sol - -pragma solidity ^0.4.24; - -// import "contracts/DSAuth.sol"; -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; -// import "contracts/interfaces/IBurnableERC20.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/SettingIds.sol"; - -contract TokenBuildInGenesis is DSAuth, SettingIds { - // claimedToken event - event ClaimedTokens(address indexed token, address indexed owner, uint amount); - - // burndropTokens event - event RingBuildInEvent(address indexed token, address indexed owner, uint amount, bytes data); - - event KtonBuildInEvent(address indexed token, address indexed owner, uint amount, bytes data); - - event SetStatus(bool status); - - ISettingsRegistry public registry; - - bool public paused = false; - - bool private singletonLock = false; - - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - modifier isWork() { - require(!paused, "Not started"); - _; - } - - function initializeContract(address _registry, bool _status) public singletonLockCall{ - registry = ISettingsRegistry(_registry); - paused = _status; - owner = msg.sender; - } - - /** - * @dev ERC223 fallback function, make sure to check the msg.sender is from target token contracts - * @param _from - person who transfer token in for deposits or claim deposit with penalty KTON. - * @param _amount - amount of token. - * @param _data - data which indicate the operations. - */ - function tokenFallback(address _from, uint256 _amount, bytes _data) public isWork{ - bytes32 darwiniaAddress; - - assembly { - let ptr := mload(0x40) - calldatacopy(ptr, 0, calldatasize) - darwiniaAddress := mload(add(ptr, 132)) - } - - address ring = registry.addressOf(SettingIds.CONTRACT_RING_ERC20_TOKEN); - address kryptonite = registry.addressOf(SettingIds.CONTRACT_KTON_ERC20_TOKEN); - - require((msg.sender == ring) || (msg.sender == kryptonite), "Permission denied"); - - require(_data.length == 32, "The address (Darwinia Network) must be in a 32 bytes hexadecimal format"); - require(darwiniaAddress != bytes32(0x0), "Darwinia Network Address can't be empty"); - - // burndrop ring - if(ring == msg.sender) { - IBurnableERC20(ring).burn(address(this), _amount); - emit RingBuildInEvent(msg.sender, _from, _amount, _data); - } - - // burndrop kton - if (kryptonite == msg.sender) { - IBurnableERC20(kryptonite).burn(address(this), _amount); - emit KtonBuildInEvent(msg.sender, _from, _amount, _data); - } - } - - /// @notice This method can be used by the owner to extract mistakenly - /// sent tokens to this contract. - /// @param _token The address of the token contract that you want to recover - /// set to 0 in case you want to extract ether. - function claimTokens(address _token) public auth { - if (_token == 0x0) { - owner.transfer(address(this).balance); - return; - } - ERC20 token = ERC20(_token); - uint balance = token.balanceOf(address(this)); - token.transfer(owner, balance); - - emit ClaimedTokens(_token, owner, balance); - } - - function setPaused(bool _status) public auth { - paused = _status; - } - - function togglePaused() public auth { - paused = !paused; - } - - function setRegistry(address _registry) public auth { - registry = ISettingsRegistry(_registry); - } -} diff --git a/flat/TokenBurnDrop.sol b/flat/TokenBurnDrop.sol deleted file mode 100644 index 64cc79b..0000000 --- a/flat/TokenBurnDrop.sol +++ /dev/null @@ -1,331 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Dependency file: contracts/interfaces/IBurnableERC20.sol - -// pragma solidity ^0.4.23; - -contract IBurnableERC20 { - function burn(address _from, uint _value) public; -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Root file: contracts/TokenBurnDrop.sol - -pragma solidity ^0.4.24; - -// import "contracts/DSAuth.sol"; -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; -// import "contracts/interfaces/IBurnableERC20.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/SettingIds.sol"; - -contract TokenBurnDrop is DSAuth, SettingIds { - // claimedToken event - event ClaimedTokens(address indexed token, address indexed owner, uint amount); - - // burndropTokens event - event RingBurndropTokens(address indexed token, address indexed owner, uint amount, bytes data); - - event KtonBurndropTokens(address indexed token, address indexed owner, uint amount, bytes data); - - ISettingsRegistry public registry; - - byte public SS58_PREFIX_DARWINIA = 0x2a; - - function initializeContract(address _registry) public onlyOwner{ - registry = ISettingsRegistry(_registry); - } - - /** - * @dev ERC223 fallback function, make sure to check the msg.sender is from target token contracts - * @param _from - person who transfer token in for deposits or claim deposit with penalty KTON. - * @param _amount - amount of token. - * @param _data - data which indicate the operations. - */ - function tokenFallback(address _from, uint256 _amount, bytes _data) public { - bytes32 darwiniaAddress; - - assembly { - let ptr := mload(0x40) - calldatacopy(ptr, 0, calldatasize) - darwiniaAddress := mload(add(ptr, 133)) - } - - address ring = registry.addressOf(SettingIds.CONTRACT_RING_ERC20_TOKEN); - address kryptonite = registry.addressOf(SettingIds.CONTRACT_KTON_ERC20_TOKEN); - - require((msg.sender == ring) || (msg.sender == kryptonite), "Permission denied"); - - require(_data.length == 33, "The address (Darwinia Network) must be in a 33 bytes hexadecimal format"); - require(byte(_data[0]) == SS58_PREFIX_DARWINIA, "Darwinia Network Address ss58 prefix is 42"); - require(darwiniaAddress != bytes32(0x0), "Darwinia Network Address can't be empty"); - - // burndrop ring - if(ring == msg.sender) { - IBurnableERC20(ring).burn(address(this), _amount); - emit RingBurndropTokens(msg.sender, _from, _amount, _data); - } - - // burndrop kton - if (kryptonite == msg.sender) { - IBurnableERC20(kryptonite).burn(address(this), _amount); - emit KtonBurndropTokens(msg.sender, _from, _amount, _data); - } - } - - /// @notice This method can be used by the owner to extract mistakenly - /// sent tokens to this contract. - /// @param _token The address of the token contract that you want to recover - /// set to 0 in case you want to extract ether. - function claimTokens(address _token) public auth { - if (_token == 0x0) { - owner.transfer(address(this).balance); - return; - } - ERC20 token = ERC20(_token); - uint balance = token.balanceOf(address(this)); - token.transfer(owner, balance); - - emit ClaimedTokens(_token, owner, balance); - } -} diff --git a/flat/TokenController.sol b/flat/TokenController.sol deleted file mode 100644 index e9c3857..0000000 --- a/flat/TokenController.sol +++ /dev/null @@ -1,28 +0,0 @@ -// Root file: contracts/interfaces/TokenController.sol - -pragma solidity ^0.4.23; - - -/// @dev The token controller contract must implement these functions -contract TokenController { - /// @notice Called when `_owner` sends ether to the MiniMe Token contract - /// @param _owner The address that sent the ether to create tokens - /// @return True if the ether is accepted, false if it throws - function proxyPayment(address _owner, bytes4 sig, bytes data) payable public returns (bool); - - /// @notice Notifies the controller about a token transfer allowing the - /// controller to react if desired - /// @param _from The origin of the transfer - /// @param _to The destination of the transfer - /// @param _amount The amount of the transfer - /// @return False if the controller does not authorize the transfer - function onTransfer(address _from, address _to, uint _amount) public returns (bool); - - /// @notice Notifies the controller about an approval allowing the - /// controller to react if desired - /// @param _owner The address that calls `approve()` - /// @param _spender The spender in the `approve()` call - /// @param _amount The amount in the `approve()` call - /// @return False if the controller does not authorize the approval - function onApprove(address _owner, address _spender, uint _amount) public returns (bool); -} diff --git a/flat/TokenLocation.sol b/flat/TokenLocation.sol deleted file mode 100644 index a4780fb..0000000 --- a/flat/TokenLocation.sol +++ /dev/null @@ -1,226 +0,0 @@ -// Dependency file: contracts/interfaces/ITokenLocation.sol - -// pragma solidity ^0.4.24; - -contract ITokenLocation { - - function hasLocation(uint256 _tokenId) public view returns (bool); - - function getTokenLocation(uint256 _tokenId) public view returns (int, int); - - function setTokenLocation(uint256 _tokenId, int _x, int _y) public; - - function getTokenLocationHM(uint256 _tokenId) public view returns (int, int); - - function setTokenLocationHM(uint256 _tokenId, int _x, int _y) public; -} - -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: contracts/LocationCoder.sol - -// pragma solidity ^0.4.24; - -library LocationCoder { - // the allocation of the [x, y, z] is [0<1>, x<21>, y<21>, z<21>] - uint256 constant CLEAR_YZ = 0x0fffffffffffffffffffff000000000000000000000000000000000000000000; - uint256 constant CLEAR_XZ = 0x0000000000000000000000fffffffffffffffffffff000000000000000000000; - uint256 constant CLEAR_XY = 0x0000000000000000000000000000000000000000000fffffffffffffffffffff; - - uint256 constant NOT_ZERO = 0x1000000000000000000000000000000000000000000000000000000000000000; - uint256 constant APPEND_HIGH = 0xfffffffffffffffffffffffffffffffffffffffffff000000000000000000000; - - uint256 constant MAX_LOCATION_ID = 0x2000000000000000000000000000000000000000000000000000000000000000; - - int256 constant HMETER_DECIMAL = 10 ** 8; - - // x, y, z should between -2^83 (-9671406556917033397649408) and 2^83 - 1 (9671406556917033397649407). - int256 constant MIN_Location_XYZ = -9671406556917033397649408; - int256 constant MAX_Location_XYZ = 9671406556917033397649407; - // 96714065569170334.50000000 - int256 constant MAX_HM_DECIMAL = 9671406556917033450000000; - int256 constant MAX_HM = 96714065569170334; - - function encodeLocationIdXY(int _x, int _y) internal pure returns (uint result) { - return encodeLocationId3D(_x, _y, 0); - } - - function decodeLocationIdXY(uint _positionId) internal pure returns (int _x, int _y) { - (_x, _y, ) = decodeLocationId3D(_positionId); - } - - function encodeLocationId3D(int _x, int _y, int _z) internal pure returns (uint result) { - return _unsafeEncodeLocationId3D(_x, _y, _z); - } - - function _unsafeEncodeLocationId3D(int _x, int _y, int _z) internal pure returns (uint) { - require(_x >= MIN_Location_XYZ && _x <= MAX_Location_XYZ, "Invalid value."); - require(_y >= MIN_Location_XYZ && _y <= MAX_Location_XYZ, "Invalid value."); - require(_z >= MIN_Location_XYZ && _z <= MAX_Location_XYZ, "Invalid value."); - - // uint256 constant FACTOR_2 = 0x1000000000000000000000000000000000000000000; // <16 ** 42> or <2 ** 168> - // uint256 constant FACTOR = 0x1000000000000000000000; // <16 ** 21> or <2 ** 84> - return ((uint(_x) << 168) & CLEAR_YZ) | (uint(_y << 84) & CLEAR_XZ) | (uint(_z) & CLEAR_XY) | NOT_ZERO; - } - - function decodeLocationId3D(uint _positionId) internal pure returns (int, int, int) { - return _unsafeDecodeLocationId3D(_positionId); - } - - function _unsafeDecodeLocationId3D(uint _value) internal pure returns (int x, int y, int z) { - require(_value >= NOT_ZERO && _value < MAX_LOCATION_ID, "Invalid Location Id"); - - x = expandNegative84BitCast((_value & CLEAR_YZ) >> 168); - y = expandNegative84BitCast((_value & CLEAR_XZ) >> 84); - z = expandNegative84BitCast(_value & CLEAR_XY); - } - - function toHM(int _x) internal pure returns (int) { - return (_x + MAX_HM_DECIMAL)/HMETER_DECIMAL - MAX_HM; - } - - function toUM(int _x) internal pure returns (int) { - return _x * LocationCoder.HMETER_DECIMAL; - } - - function expandNegative84BitCast(uint _value) internal pure returns (int) { - if (_value & (1<<83) != 0) { - return int(_value | APPEND_HIGH); - } - return int(_value); - } - - function encodeLocationIdHM(int _x, int _y) internal pure returns (uint result) { - return encodeLocationIdXY(toUM(_x), toUM(_y)); - } - - function decodeLocationIdHM(uint _positionId) internal pure returns (int, int) { - (int _x, int _y) = decodeLocationIdXY(_positionId); - return (toHM(_x), toHM(_y)); - } -} - -// Root file: contracts/TokenLocation.sol - -pragma solidity ^0.4.24; - -// import "contracts/interfaces/ITokenLocation.sol"; -// import "contracts/DSAuth.sol"; -// import "contracts/LocationCoder.sol"; - -contract TokenLocation is DSAuth, ITokenLocation { - using LocationCoder for *; - - bool private singletonLock = false; - - // token id => encode(x,y) postiion in map, the location is in micron. - mapping (uint256 => uint256) public tokenId2LocationId; - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - function initializeContract() public singletonLockCall { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function hasLocation(uint256 _tokenId) public view returns (bool) { - return tokenId2LocationId[_tokenId] != 0; - } - - function getTokenLocationHM(uint256 _tokenId) public view returns (int, int){ - (int _x, int _y) = getTokenLocation(_tokenId); - return (LocationCoder.toHM(_x), LocationCoder.toHM(_y)); - } - - function setTokenLocationHM(uint256 _tokenId, int _x, int _y) public auth { - setTokenLocation(_tokenId, LocationCoder.toUM(_x), LocationCoder.toUM(_y)); - } - - // decode tokenId to get (x,y) - function getTokenLocation(uint256 _tokenId) public view returns (int, int) { - uint locationId = tokenId2LocationId[_tokenId]; - return LocationCoder.decodeLocationIdXY(locationId); - } - - function setTokenLocation(uint256 _tokenId, int _x, int _y) public auth { - tokenId2LocationId[_tokenId] = LocationCoder.encodeLocationIdXY(_x, _y); - } -} \ No newline at end of file diff --git a/flat/TokenLocationAuthority.sol b/flat/TokenLocationAuthority.sol deleted file mode 100644 index 7925b6d..0000000 --- a/flat/TokenLocationAuthority.sol +++ /dev/null @@ -1,20 +0,0 @@ -// Root file: contracts/TokenLocationAuthority.sol - -pragma solidity ^0.4.24; - -contract TokenLocationAuthority { - - mapping (address => bool) public whiteList; - - constructor(address[] _whitelists) public { - for (uint i = 0; i < _whitelists.length; i ++) { - whiteList[_whitelists[i]] = true; - } - } - - function canCall( - address _src, address _dst, bytes4 _sig - ) public view returns (bool) { - return ( whiteList[_src] && _sig == bytes4(keccak256("setTokenLocationHM(uint256,int256,int256)"))) ; - } -} \ No newline at end of file diff --git a/flat/TokenUse.sol b/flat/TokenUse.sol deleted file mode 100644 index 5ec5fdf..0000000 --- a/flat/TokenUse.sol +++ /dev/null @@ -1,913 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol - -// pragma solidity ^0.4.24; - - -/** - * @title SafeMath - * @dev Math operations with safety checks that throw on error - */ -library SafeMath { - - /** - * @dev Multiplies two numbers, throws on overflow. - */ - function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - // Gas optimization: this is cheaper than asserting 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - c = _a * _b; - assert(c / _a == _b); - return c; - } - - /** - * @dev Integer division of two numbers, truncating the quotient. - */ - function div(uint256 _a, uint256 _b) internal pure returns (uint256) { - // assert(_b > 0); // Solidity automatically throws when dividing by 0 - // uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - return _a / _b; - } - - /** - * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - assert(_b <= _a); - return _a - _b; - } - - /** - * @dev Adds two numbers, throws on overflow. - */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - c = _a + _b; - assert(c >= _a); - return c; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Dependency file: openzeppelin-solidity/contracts/introspection/ERC165.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC165 - * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md - */ -interface ERC165 { - - /** - * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - */ - function supportsInterface(bytes4 _interfaceId) - external - view - returns (bool); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - - -/** - * @title ERC721 Non-Fungible Token Standard basic interface - * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Basic is ERC165 { - - bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; - /* - * 0x80ac58cd === - * bytes4(keccak256('balanceOf(address)')) ^ - * bytes4(keccak256('ownerOf(uint256)')) ^ - * bytes4(keccak256('approve(address,uint256)')) ^ - * bytes4(keccak256('getApproved(uint256)')) ^ - * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ - * bytes4(keccak256('isApprovedForAll(address,address)')) ^ - * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ - * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) - */ - - bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; - /* - * 0x4f558e79 === - * bytes4(keccak256('exists(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; - /** - * 0x780e9d63 === - * bytes4(keccak256('totalSupply()')) ^ - * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ - * bytes4(keccak256('tokenByIndex(uint256)')) - */ - - bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; - /** - * 0x5b5e139f === - * bytes4(keccak256('name()')) ^ - * bytes4(keccak256('symbol()')) ^ - * bytes4(keccak256('tokenURI(uint256)')) - */ - - event Transfer( - address indexed _from, - address indexed _to, - uint256 indexed _tokenId - ); - event Approval( - address indexed _owner, - address indexed _approved, - uint256 indexed _tokenId - ); - event ApprovalForAll( - address indexed _owner, - address indexed _operator, - bool _approved - ); - - function balanceOf(address _owner) public view returns (uint256 _balance); - function ownerOf(uint256 _tokenId) public view returns (address _owner); - function exists(uint256 _tokenId) public view returns (bool _exists); - - function approve(address _to, uint256 _tokenId) public; - function getApproved(uint256 _tokenId) - public view returns (address _operator); - - function setApprovalForAll(address _operator, bool _approved) public; - function isApprovedForAll(address _owner, address _operator) - public view returns (bool); - - function transferFrom(address _from, address _to, uint256 _tokenId) public; - function safeTransferFrom(address _from, address _to, uint256 _tokenId) - public; - - function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data - ) - public; -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol"; - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Enumerable is ERC721Basic { - function totalSupply() public view returns (uint256); - function tokenOfOwnerByIndex( - address _owner, - uint256 _index - ) - public - view - returns (uint256 _tokenId); - - function tokenByIndex(uint256 _index) public view returns (uint256); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, optional metadata extension - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721Metadata is ERC721Basic { - function name() external view returns (string _name); - function symbol() external view returns (string _symbol); - function tokenURI(uint256 _tokenId) public view returns (string); -} - - -/** - * @title ERC-721 Non-Fungible Token Standard, full implementation interface - * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md - */ -contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { -} - - -// Dependency file: contracts/interfaces/ERC223.sol - -// pragma solidity ^0.4.23; - -contract ERC223 { - function transfer(address to, uint amount, bytes data) public returns (bool ok); - - function transferFrom(address from, address to, uint256 amount, bytes data) public returns (bool ok); - - event ERC223Transfer(address indexed from, address indexed to, uint amount, bytes data); -} - - -// Dependency file: contracts/interfaces/ITokenUse.sol - -// pragma solidity ^0.4.24; - -contract ITokenUse { - uint48 public constant MAX_UINT48_TIME = 281474976710655; - - function isObjectInHireStage(uint256 _tokenId) public view returns (bool); - - function isObjectReadyToUse(uint256 _tokenId) public view returns (bool); - - function getTokenUser(uint256 _tokenId) public view returns (address); - - function createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public; - - function cancelTokenUseOffer(uint256 _tokenId) public; - - function takeTokenUseOffer(uint256 _tokenId) public; - - function addActivity(uint256 _tokenId, address _user, uint256 _endTime) public; - - function removeActivity(uint256 _tokenId, address _user) public; -} - -// Dependency file: contracts/interfaces/IActivity.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - -contract IActivity is ERC165 { - bytes4 internal constant InterfaceId_IActivity = 0x6086e7f8; - /* - * 0x6086e7f8 === - * bytes4(keccak256('activityStopped(uint256)')) - */ - - function activityStopped(uint256 _tokenId) public; -} - -// Dependency file: contracts/interfaces/ISettingsRegistry.sol - -// pragma solidity ^0.4.24; - -contract ISettingsRegistry { - enum SettingsValueTypes { NONE, UINT, STRING, ADDRESS, BYTES, BOOL, INT } - - function uintOf(bytes32 _propertyName) public view returns (uint256); - - function stringOf(bytes32 _propertyName) public view returns (string); - - function addressOf(bytes32 _propertyName) public view returns (address); - - function bytesOf(bytes32 _propertyName) public view returns (bytes); - - function boolOf(bytes32 _propertyName) public view returns (bool); - - function intOf(bytes32 _propertyName) public view returns (int); - - function setUintProperty(bytes32 _propertyName, uint _value) public; - - function setStringProperty(bytes32 _propertyName, string _value) public; - - function setAddressProperty(bytes32 _propertyName, address _value) public; - - function setBytesProperty(bytes32 _propertyName, bytes _value) public; - - function setBoolProperty(bytes32 _propertyName, bool _value) public; - - function setIntProperty(bytes32 _propertyName, int _value) public; - - function getValueTypeOf(bytes32 _propertyName) public view returns (uint /* SettingsValueTypes */ ); - - event ChangeProperty(bytes32 indexed _propertyName, uint256 _type); -} - -// Dependency file: contracts/interfaces/IInterstellarEncoder.sol - -// pragma solidity ^0.4.24; - -contract IInterstellarEncoder { - uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; - - uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. - uint256 public constant CHAIN_ID = 1; // Ethereum mainet. - uint256 public constant CURRENT_LAND = 1; // 1 is Atlantis, 0 is NaN. - - enum ObjectClass { - NaN, - LAND, - APOSTLE, - OBJECT_CLASS_COUNT - } - - function registerNewObjectClass(address _objectContract, uint8 objectClass) public; - - function registerNewTokenContract(address _tokenAddress) public; - - function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); - - function encodeTokenIdForObjectContract( - address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); - - function getContractAddress(uint256 _tokenId) public view returns (address); - - function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); - - function getObjectClass(uint256 _tokenId) public view returns (uint8); - - function getObjectAddress(uint256 _tokenId) public view returns (address); -} - -// Dependency file: contracts/interfaces/IActivityObject.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/introspection/ERC165.sol"; - -contract IActivityObject is ERC165 { - bytes4 internal constant InterfaceId_IActivityObject = 0x2b9eccc6; - /* - * 0x2b9eccc6 === - * bytes4(keccak256('activityAdded(uint256,address,address)')) ^ - * bytes4(keccak256('activityRemoved(uint256,address,address)')) - */ - - function activityAdded(uint256 _tokenId, address _activity, address _user) public; - - function activityRemoved(uint256 _tokenId, address _activity, address _user) public; -} - -// Dependency file: contracts/SettingIds.sol - -// pragma solidity ^0.4.24; - -/** - Id definitions for SettingsRegistry.sol - Can be used in conjunction with the settings registry to get properties -*/ -contract SettingIds { - // 0x434f4e54524143545f52494e475f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_RING_ERC20_TOKEN = "CONTRACT_RING_ERC20_TOKEN"; - - // 0x434f4e54524143545f4b544f4e5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_KTON_ERC20_TOKEN = "CONTRACT_KTON_ERC20_TOKEN"; - - // 0x434f4e54524143545f474f4c445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_GOLD_ERC20_TOKEN = "CONTRACT_GOLD_ERC20_TOKEN"; - - // 0x434f4e54524143545f574f4f445f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_WOOD_ERC20_TOKEN = "CONTRACT_WOOD_ERC20_TOKEN"; - - // 0x434f4e54524143545f57415445525f45524332305f544f4b454e000000000000 - bytes32 public constant CONTRACT_WATER_ERC20_TOKEN = "CONTRACT_WATER_ERC20_TOKEN"; - - // 0x434f4e54524143545f464952455f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_FIRE_ERC20_TOKEN = "CONTRACT_FIRE_ERC20_TOKEN"; - - // 0x434f4e54524143545f534f494c5f45524332305f544f4b454e00000000000000 - bytes32 public constant CONTRACT_SOIL_ERC20_TOKEN = "CONTRACT_SOIL_ERC20_TOKEN"; - - // 0x434f4e54524143545f4f424a4543545f4f574e45525348495000000000000000 - bytes32 public constant CONTRACT_OBJECT_OWNERSHIP = "CONTRACT_OBJECT_OWNERSHIP"; - - // 0x434f4e54524143545f544f4b454e5f4c4f434154494f4e000000000000000000 - bytes32 public constant CONTRACT_TOKEN_LOCATION = "CONTRACT_TOKEN_LOCATION"; - - // 0x434f4e54524143545f4c414e445f424153450000000000000000000000000000 - bytes32 public constant CONTRACT_LAND_BASE = "CONTRACT_LAND_BASE"; - - // 0x434f4e54524143545f555345525f504f494e5453000000000000000000000000 - bytes32 public constant CONTRACT_USER_POINTS = "CONTRACT_USER_POINTS"; - - // 0x434f4e54524143545f494e5445525354454c4c41525f454e434f444552000000 - bytes32 public constant CONTRACT_INTERSTELLAR_ENCODER = "CONTRACT_INTERSTELLAR_ENCODER"; - - // 0x434f4e54524143545f4449564944454e44535f504f4f4c000000000000000000 - bytes32 public constant CONTRACT_DIVIDENDS_POOL = "CONTRACT_DIVIDENDS_POOL"; - - // 0x434f4e54524143545f544f4b454e5f5553450000000000000000000000000000 - bytes32 public constant CONTRACT_TOKEN_USE = "CONTRACT_TOKEN_USE"; - - // 0x434f4e54524143545f524556454e55455f504f4f4c0000000000000000000000 - bytes32 public constant CONTRACT_REVENUE_POOL = "CONTRACT_REVENUE_POOL"; - - // 0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000 - bytes32 public constant CONTRACT_BRIDGE_POOL = "CONTRACT_BRIDGE_POOL"; - - // 0x434f4e54524143545f4552433732315f42524944474500000000000000000000 - bytes32 public constant CONTRACT_ERC721_BRIDGE = "CONTRACT_ERC721_BRIDGE"; - - // 0x434f4e54524143545f5045545f42415345000000000000000000000000000000 - bytes32 public constant CONTRACT_PET_BASE = "CONTRACT_PET_BASE"; - - // Cut owner takes on each auction, measured in basis points (1/100 of a percent). - // this can be considered as transaction fee. - // Values 0-10,000 map to 0%-100% - // set ownerCut to 4% - // ownerCut = 400; - // 0x55494e545f41554354494f4e5f43555400000000000000000000000000000000 - bytes32 public constant UINT_AUCTION_CUT = "UINT_AUCTION_CUT"; // Denominator is 10000 - - // 0x55494e545f544f4b454e5f4f464645525f435554000000000000000000000000 - bytes32 public constant UINT_TOKEN_OFFER_CUT = "UINT_TOKEN_OFFER_CUT"; // Denominator is 10000 - - // Cut referer takes on each auction, measured in basis points (1/100 of a percent). - // which cut from transaction fee. - // Values 0-10,000 map to 0%-100% - // set refererCut to 4% - // refererCut = 400; - // 0x55494e545f524546455245525f43555400000000000000000000000000000000 - bytes32 public constant UINT_REFERER_CUT = "UINT_REFERER_CUT"; - - // 0x55494e545f4252494447455f4645450000000000000000000000000000000000 - bytes32 public constant UINT_BRIDGE_FEE = "UINT_BRIDGE_FEE"; - - // 0x434f4e54524143545f4c414e445f5245534f5552434500000000000000000000 - bytes32 public constant CONTRACT_LAND_RESOURCE = "CONTRACT_LAND_RESOURCE"; -} - -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Root file: contracts/TokenUse.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -// import "contracts/interfaces/ERC223.sol"; -// import "contracts/interfaces/ITokenUse.sol"; -// import "contracts/interfaces/IActivity.sol"; -// import "contracts/interfaces/ISettingsRegistry.sol"; -// import "contracts/interfaces/IInterstellarEncoder.sol"; -// import "contracts/interfaces/IActivityObject.sol"; -// import "contracts/SettingIds.sol"; -// import "contracts/DSAuth.sol"; - -contract TokenUse is DSAuth, ITokenUse, SettingIds { - using SafeMath for *; - - // claimedToken event - event ClaimedTokens(address indexed token, address indexed owner, uint amount); - - event OfferCreated(uint256 indexed tokenId, uint256 duration, uint256 price, address acceptedActivity, address owner); - event OfferCancelled(uint256 tokenId); - event OfferTaken(uint256 indexed tokenId, address from, address owner, uint256 now, uint256 endTime); - event ActivityAdded(uint256 indexed tokenId, address activity, uint256 endTime); - event ActivityRemoved(uint256 indexed tokenId, address activity); - event TokenUseRemoved(uint256 indexed tokenId, address owner, address user, address activity); - - struct UseStatus { - address user; - address owner; - uint48 startTime; - uint48 endTime; - uint256 price; // RING per second. - address acceptedActivity; // can only be used in this activity. - } - - struct UseOffer { - address owner; - uint48 duration; - // total price of hiring mft for full duration - uint256 price; - address acceptedActivity; // If 0, then accept any activity - } - - struct CurrentActivity { - address activity; - uint48 endTime; - } - - bool private singletonLock = false; - - ISettingsRegistry public registry; - mapping (uint256 => UseStatus) public tokenId2UseStatus; - mapping (uint256 => UseOffer) public tokenId2UseOffer; - - mapping (uint256 => CurrentActivity ) public tokenId2CurrentActivity; - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - function initializeContract(ISettingsRegistry _registry) public singletonLockCall { - owner = msg.sender; - emit LogSetOwner(msg.sender); - - registry = _registry; - } - - // false if it is not in useStage - // based on data in TokenUseStatus - function isObjectInHireStage(uint256 _tokenId) public view returns (bool) { - if (tokenId2UseStatus[_tokenId].user == address(0)) { - return false; - } - - return tokenId2UseStatus[_tokenId].startTime <= now && now <= tokenId2UseStatus[_tokenId].endTime; - } - - // by check this function - // you can know if an nft is ok to addActivity - // based on data in CurrentActivity - function isObjectReadyToUse(uint256 _tokenId) public view returns (bool) { - - if(tokenId2CurrentActivity[_tokenId].endTime == 0) { - return tokenId2CurrentActivity[_tokenId].activity == address(0); - } else { - return now > tokenId2CurrentActivity[_tokenId].endTime; - } - } - - - function getTokenUser(uint256 _tokenId) public view returns (address) { - return tokenId2UseStatus[_tokenId].user; - } - - function receiveApproval(address _from, uint _tokenId, bytes _data) public { - if(msg.sender == registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)) { - uint256 duration; - uint256 price; - address acceptedActivity; - assembly { - let ptr := mload(0x40) - calldatacopy(ptr, 0, calldatasize) - duration := mload(add(ptr, 132)) - price := mload(add(ptr, 164)) - acceptedActivity := mload(add(ptr, 196)) - } - - // already approve that msg.sender == ownerOf(_tokenId) - - _createTokenUseOffer(_tokenId, duration, price, acceptedActivity, _from); - } - } - - - // need approval from msg.sender - function createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public { - require(ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == msg.sender, "Only can call by the token owner."); - - _createTokenUseOffer(_tokenId, _duration, _price, _acceptedActivity, msg.sender); - } - - // TODO: be careful with unit of duration and price - // remember to deal with unit off chain - function _createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity, address _owner) internal { - require(isObjectReadyToUse(_tokenId), "No, it is still in use."); - require(tokenId2UseOffer[_tokenId].owner == 0, "Token already in another offer."); - require(_price >= 1 ether, "price must larger than 1 ring."); - require(_duration >= 7 days); - - ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom(_owner, address(this), _tokenId); - - tokenId2UseOffer[_tokenId] = UseOffer({ - owner: _owner, - duration: uint48(_duration), - price : _price, - acceptedActivity: _acceptedActivity - }); - - emit OfferCreated(_tokenId,_duration, _price, _acceptedActivity, _owner); - } - - function cancelTokenUseOffer(uint256 _tokenId) public { - require(tokenId2UseOffer[_tokenId].owner == msg.sender, "Only token owner can cancel the offer."); - - ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom(address(this), msg.sender, _tokenId); - - delete tokenId2UseOffer[_tokenId]; - - emit OfferCancelled(_tokenId); - } - - function takeTokenUseOffer(uint256 _tokenId) public { - uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); - - uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); - - address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); - - ERC20(ring).transferFrom( - msg.sender, tokenId2UseOffer[_tokenId].owner, expense.sub(cut)); - - ERC223(ring).transferFrom( - msg.sender, registry.addressOf(CONTRACT_REVENUE_POOL), cut, toBytes(msg.sender)); - - _takeTokenUseOffer(_tokenId, msg.sender); - } - - function _takeTokenUseOffer(uint256 _tokenId, address _from) internal { - require(tokenId2UseOffer[_tokenId].owner != address(0), "Offer does not exist for this token."); - require(isObjectReadyToUse(_tokenId), "Token already in another activity."); - - tokenId2UseStatus[_tokenId] = UseStatus({ - user: _from, - owner: tokenId2UseOffer[_tokenId].owner, - startTime: uint48(now), - endTime : uint48(now) + tokenId2UseOffer[_tokenId].duration, - price : tokenId2UseOffer[_tokenId].price, - acceptedActivity : tokenId2UseOffer[_tokenId].acceptedActivity - }); - - delete tokenId2UseOffer[_tokenId]; - - emit OfferTaken(_tokenId, _from, tokenId2UseStatus[_tokenId].owner, now, uint256(tokenId2UseStatus[_tokenId].endTime)); - - } - - //TODO: allow batch operation - function tokenFallback(address _from, uint256 _value, bytes _data) public { - address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); - if(ring == msg.sender) { - uint256 tokenId; - - assembly { - let ptr := mload(0x40) - calldatacopy(ptr, 0, calldatasize) - tokenId := mload(add(ptr, 132)) - } - - uint256 expense = uint256(tokenId2UseOffer[tokenId].price); - require(_value >= expense); - - uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); - - ERC20(ring).transfer(tokenId2UseOffer[tokenId].owner, expense.sub(cut)); - - ERC223(ring).transfer( - registry.addressOf(CONTRACT_REVENUE_POOL), cut, toBytes(_from)); - - _takeTokenUseOffer(tokenId, _from); - } - } - - // start activity when token has no user at all - function addActivity( - uint256 _tokenId, address _user, uint256 _endTime - ) public auth { - // require the token user to verify even if it is from business logic. - // if it is rent by others, can not addActivity by default. - if(tokenId2UseStatus[_tokenId].user != address(0)) { - require(_user == tokenId2UseStatus[_tokenId].user); - require( - tokenId2UseStatus[_tokenId].acceptedActivity == address(0) || - tokenId2UseStatus[_tokenId].acceptedActivity == msg.sender, "Token accepted activity is not accepted."); - } else { - require( - address(0) == _user || ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == _user, "you can not use this token."); - } - - require(tokenId2UseOffer[_tokenId].owner == address(0), "Can not start activity when offering."); - - require(IActivity(msg.sender).supportsInterface(0x6086e7f8), "Msg sender must be activity"); - - require(isObjectReadyToUse(_tokenId), "Token should be available."); - - address activityObject = IInterstellarEncoder(registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER)).getObjectAddress(_tokenId); - IActivityObject(activityObject).activityAdded(_tokenId, msg.sender, _user); - - tokenId2CurrentActivity[_tokenId].activity = msg.sender; - - if(tokenId2UseStatus[_tokenId].endTime != 0) { - tokenId2CurrentActivity[_tokenId].endTime = tokenId2UseStatus[_tokenId].endTime; - } else { - tokenId2CurrentActivity[_tokenId].endTime = uint48(_endTime); - } - - - emit ActivityAdded(_tokenId, msg.sender, uint48(tokenId2CurrentActivity[_tokenId].endTime)); - } - - function removeActivity(uint256 _tokenId, address _user) public auth { - // require the token user to verify even if it is from business logic. - // if it is rent by others, can not addActivity by default. - if(tokenId2UseStatus[_tokenId].user != address(0)) { - require(_user == tokenId2UseStatus[_tokenId].user); - } else { - require( - address(0) == _user || ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == _user, "you can not use this token."); - } - - require(tokenId2CurrentActivity[_tokenId].activity == msg.sender || msg.sender == address(this), "Must stop from current activity"); - - address activityObject = IInterstellarEncoder(registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER)).getObjectAddress(_tokenId); - IActivityObject(activityObject).activityRemoved(_tokenId, msg.sender, _user); - - IActivity(tokenId2CurrentActivity[_tokenId].activity).activityStopped(_tokenId); - - delete tokenId2CurrentActivity[_tokenId]; - - emit ActivityRemoved(_tokenId, msg.sender); - } - - function removeTokenUseAndActivity(uint256 _tokenId) public { - require(tokenId2UseStatus[_tokenId].user != address(0), "Object does not exist."); - - // when in activity, only user can stop - if(isObjectInHireStage(_tokenId)) { - require(tokenId2UseStatus[_tokenId].user == msg.sender); - } - - _removeTokenUse(_tokenId); - - if (tokenId2CurrentActivity[_tokenId].activity != address(0)) { - this.removeActivity(_tokenId, address(0)); - } - } - - - function _removeTokenUse(uint256 _tokenId) public { - - address owner = tokenId2UseStatus[_tokenId].owner; - address user = tokenId2UseStatus[_tokenId].user; - address activity = tokenId2CurrentActivity[_tokenId].activity; - ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom( - address(this), owner, _tokenId); - - delete tokenId2UseStatus[_tokenId]; -// delete tokenId2CurrentActivity[_tokenId]; - - emit TokenUseRemoved(_tokenId, owner, user, activity); - } - - // for user-friendly - function removeUseAndCreateOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public { - - require(msg.sender == tokenId2UseStatus[_tokenId].owner); - removeTokenUseAndActivity(_tokenId); - - tokenId2UseOffer[_tokenId] = UseOffer({ - owner: msg.sender, - duration: uint48(_duration), - price : _price, - acceptedActivity: _acceptedActivity - }); - - emit OfferCreated(_tokenId, _duration, _price, _acceptedActivity, msg.sender); - } - - /// @notice This method can be used by the owner to extract mistakenly - /// sent tokens to this contract. - /// @param _token The address of the token contract that you want to recover - /// set to 0 in case you want to extract ether. - function claimTokens(address _token) public auth { - if (_token == 0x0) { - owner.transfer(address(this).balance); - return; - } - ERC20 token = ERC20(_token); - uint balance = token.balanceOf(address(this)); - token.transfer(owner, balance); - - emit ClaimedTokens(_token, owner, balance); - } - - function toBytes(address x) public pure returns (bytes b) { - b = new bytes(32); - assembly { mstore(add(b, 32), x) } - } - -} \ No newline at end of file diff --git a/flat/TokenUseAuthority.sol b/flat/TokenUseAuthority.sol deleted file mode 100644 index 93acc1a..0000000 --- a/flat/TokenUseAuthority.sol +++ /dev/null @@ -1,21 +0,0 @@ -// Root file: contracts/TokenUseAuthority.sol - -pragma solidity ^0.4.24; - -contract TokenUseAuthority { - - mapping (address => bool) public whiteList; - - constructor(address[] _whitelists) public { - for (uint i = 0; i < _whitelists.length; i ++) { - whiteList[_whitelists[i]] = true; - } - } - - function canCall( - address _src, address _dst, bytes4 _sig - ) public view returns (bool) { - return (whiteList[_src] && _sig == bytes4(keccak256("addActivity(uint256,address,uint256)"))) || - ( whiteList[_src] && _sig == bytes4(keccak256("removeActivity(uint256,address)"))); - } -} \ No newline at end of file diff --git a/flat/TokenVestingFactory.sol b/flat/TokenVestingFactory.sol deleted file mode 100644 index 04015ec..0000000 --- a/flat/TokenVestingFactory.sol +++ /dev/null @@ -1,400 +0,0 @@ -// Dependency file: openzeppelin-solidity/contracts/ownership/Ownable.sol - -// pragma solidity ^0.4.24; - - -/** - * @title Ownable - * @dev The Ownable contract has an owner address, and provides basic authorization control - * functions, this simplifies the implementation of "user permissions". - */ -contract Ownable { - address public owner; - - - event OwnershipRenounced(address indexed previousOwner); - event OwnershipTransferred( - address indexed previousOwner, - address indexed newOwner - ); - - - /** - * @dev The Ownable constructor sets the original `owner` of the contract to the sender - * account. - */ - constructor() public { - owner = msg.sender; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - /** - * @dev Allows the current owner to relinquish control of the contract. - * @notice Renouncing to ownership will leave the contract without an owner. - * It will not be possible to call the functions with the `onlyOwner` - * modifier anymore. - */ - function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner); - owner = address(0); - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function transferOwnership(address _newOwner) public onlyOwner { - _transferOwnership(_newOwner); - } - - /** - * @dev Transfers control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. - */ - function _transferOwnership(address _newOwner) internal { - require(_newOwner != address(0)); - emit OwnershipTransferred(owner, _newOwner); - owner = _newOwner; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; - - -/** - * @title SafeERC20 - * @dev Wrappers around ERC20 operations that throw on failure. - * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, - * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. - */ -library SafeERC20 { - function safeTransfer( - ERC20Basic _token, - address _to, - uint256 _value - ) - internal - { - require(_token.transfer(_to, _value)); - } - - function safeTransferFrom( - ERC20 _token, - address _from, - address _to, - uint256 _value - ) - internal - { - require(_token.transferFrom(_from, _to, _value)); - } - - function safeApprove( - ERC20 _token, - address _spender, - uint256 _value - ) - internal - { - require(_token.approve(_spender, _value)); - } -} - - -// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol - -// pragma solidity ^0.4.24; - - -/** - * @title SafeMath - * @dev Math operations with safety checks that throw on error - */ -library SafeMath { - - /** - * @dev Multiplies two numbers, throws on overflow. - */ - function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - // Gas optimization: this is cheaper than asserting 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - c = _a * _b; - assert(c / _a == _b); - return c; - } - - /** - * @dev Integer division of two numbers, truncating the quotient. - */ - function div(uint256 _a, uint256 _b) internal pure returns (uint256) { - // assert(_b > 0); // Solidity automatically throws when dividing by 0 - // uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - return _a / _b; - } - - /** - * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - assert(_b <= _a); - return _a - _b; - } - - /** - * @dev Adds two numbers, throws on overflow. - */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - c = _a + _b; - assert(c >= _a); - return c; - } -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/TokenVesting.sol - -/* solium-disable security/no-block-members */ - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; -// import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; -// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; - - -/** - * @title TokenVesting - * @dev A token holder contract that can release its token balance gradually like a - * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the - * owner. - */ -contract TokenVesting is Ownable { - using SafeMath for uint256; - using SafeERC20 for ERC20Basic; - - event Released(uint256 amount); - event Revoked(); - - // beneficiary of tokens after they are released - address public beneficiary; - - uint256 public cliff; - uint256 public start; - uint256 public duration; - - bool public revocable; - - mapping (address => uint256) public released; - mapping (address => bool) public revoked; - - /** - * @dev Creates a vesting contract that vests its balance of any ERC20 token to the - * _beneficiary, gradually in a linear fashion until _start + _duration. By then all - * of the balance will have vested. - * @param _beneficiary address of the beneficiary to whom vested tokens are transferred - * @param _cliff duration in seconds of the cliff in which tokens will begin to vest - * @param _start the time (as Unix time) at which point vesting starts - * @param _duration duration in seconds of the period in which the tokens will vest - * @param _revocable whether the vesting is revocable or not - */ - constructor( - address _beneficiary, - uint256 _start, - uint256 _cliff, - uint256 _duration, - bool _revocable - ) - public - { - require(_beneficiary != address(0)); - require(_cliff <= _duration); - - beneficiary = _beneficiary; - revocable = _revocable; - duration = _duration; - cliff = _start.add(_cliff); - start = _start; - } - - /** - * @notice Transfers vested tokens to beneficiary. - * @param _token ERC20 token which is being vested - */ - function release(ERC20Basic _token) public { - uint256 unreleased = releasableAmount(_token); - - require(unreleased > 0); - - released[_token] = released[_token].add(unreleased); - - _token.safeTransfer(beneficiary, unreleased); - - emit Released(unreleased); - } - - /** - * @notice Allows the owner to revoke the vesting. Tokens already vested - * remain in the contract, the rest are returned to the owner. - * @param _token ERC20 token which is being vested - */ - function revoke(ERC20Basic _token) public onlyOwner { - require(revocable); - require(!revoked[_token]); - - uint256 balance = _token.balanceOf(address(this)); - - uint256 unreleased = releasableAmount(_token); - uint256 refund = balance.sub(unreleased); - - revoked[_token] = true; - - _token.safeTransfer(owner, refund); - - emit Revoked(); - } - - /** - * @dev Calculates the amount that has already vested but hasn't been released yet. - * @param _token ERC20 token which is being vested - */ - function releasableAmount(ERC20Basic _token) public view returns (uint256) { - return vestedAmount(_token).sub(released[_token]); - } - - /** - * @dev Calculates the amount that has already vested. - * @param _token ERC20 token which is being vested - */ - function vestedAmount(ERC20Basic _token) public view returns (uint256) { - uint256 currentBalance = _token.balanceOf(address(this)); - uint256 totalBalance = currentBalance.add(released[_token]); - - if (block.timestamp < cliff) { - return 0; - } else if (block.timestamp >= start.add(duration) || revoked[_token]) { - return totalBalance; - } else { - return totalBalance.mul(block.timestamp.sub(start)).div(duration); - } - } -} - - -// Root file: contracts/TokenVestingFactory.sol - -pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -// import "openzeppelin-solidity/contracts/token/ERC20/TokenVesting.sol"; - -contract TokenVestingFactory is Ownable { - // claimedToken event - event ClaimedTokens(address indexed token, address indexed owner, uint amount); - - // index of created contracts - address[] public contracts; - - // useful to know the row count in contracts index - function getContractCount() public constant returns(uint contractCount) - { - return contracts.length; - } - - // deploy a new contract - function newTokenVesting( - address _beneficiary, - uint256 _start, - uint256 _cliff, - uint256 _duration, - bool _revocable) public returns(address newContract) - { - TokenVesting tv = new TokenVesting(_beneficiary, _start, _cliff, _duration, _revocable); - contracts.push(tv); - return tv; - } - - function revokeVesting(uint256 _contractIndex, ERC20Basic _token) public onlyOwner { - TokenVesting(contracts[_contractIndex]).revoke(_token); - } - - /// @notice This method can be used by the owner to extract mistakenly - /// sent tokens to this contract. - /// @param _token The address of the token contract that you want to recover - /// set to 0 in case you want to extract ether. - function claimTokens(address _token) public onlyOwner { - if (_token == 0x0) { - owner.transfer(address(this).balance); - return; - } - ERC20 token = ERC20(_token); - uint balance = token.balanceOf(address(this)); - token.transfer(owner, balance); - - emit ClaimedTokens(_token, owner, balance); - } -} \ No newline at end of file diff --git a/flat/UserPoints.sol b/flat/UserPoints.sol deleted file mode 100644 index 98388ac..0000000 --- a/flat/UserPoints.sol +++ /dev/null @@ -1,265 +0,0 @@ -// Dependency file: contracts/interfaces/IAuthority.sol - -// pragma solidity ^0.4.24; - -contract IAuthority { - function canCall( - address src, address dst, bytes4 sig - ) public view returns (bool); -} - -// Dependency file: contracts/DSAuth.sol - -// pragma solidity ^0.4.24; - -// import 'contracts/interfaces/IAuthority.sol'; - -contract DSAuthEvents { - event LogSetAuthority (address indexed authority); - event LogSetOwner (address indexed owner); -} - -/** - * @title DSAuth - * @dev The DSAuth contract is reference implement of https://github.com/dapphub/ds-auth - * But in the isAuthorized method, the src from address(this) is remove for safty concern. - */ -contract DSAuth is DSAuthEvents { - IAuthority public authority; - address public owner; - - constructor() public { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function setOwner(address owner_) - public - auth - { - owner = owner_; - emit LogSetOwner(owner); - } - - function setAuthority(IAuthority authority_) - public - auth - { - authority = authority_; - emit LogSetAuthority(authority); - } - - modifier auth { - require(isAuthorized(msg.sender, msg.sig)); - _; - } - - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - function isAuthorized(address src, bytes4 sig) internal view returns (bool) { - if (src == owner) { - return true; - } else if (authority == IAuthority(0)) { - return false; - } else { - return authority.canCall(src, this, sig); - } - } -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol - -// pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * See https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address _who) public view returns (uint256); - function transfer(address _to, uint256 _value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} - - -// Dependency file: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol - -// pragma solidity ^0.4.24; - -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - function approve(address _spender, uint256 _value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - - -// Dependency file: openzeppelin-solidity/contracts/math/SafeMath.sol - -// pragma solidity ^0.4.24; - - -/** - * @title SafeMath - * @dev Math operations with safety checks that throw on error - */ -library SafeMath { - - /** - * @dev Multiplies two numbers, throws on overflow. - */ - function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - // Gas optimization: this is cheaper than asserting 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - c = _a * _b; - assert(c / _a == _b); - return c; - } - - /** - * @dev Integer division of two numbers, truncating the quotient. - */ - function div(uint256 _a, uint256 _b) internal pure returns (uint256) { - // assert(_b > 0); // Solidity automatically throws when dividing by 0 - // uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - return _a / _b; - } - - /** - * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - assert(_b <= _a); - return _a - _b; - } - - /** - * @dev Adds two numbers, throws on overflow. - */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { - c = _a + _b; - assert(c >= _a); - return c; - } -} - - -// Dependency file: contracts/interfaces/IUserPoints.sol - -// pragma solidity ^0.4.24; - -contract IUserPoints { - event AddedPoints(address indexed user, uint256 pointAmount); - event SubedPoints(address indexed user, uint256 pointAmount); - - function addPoints(address _user, uint256 _pointAmount) public; - - function subPoints(address _user, uint256 _pointAmount) public; - - function pointsSupply() public view returns (uint256); - - function pointsBalanceOf(address _user) public view returns (uint256); -} - - -// Root file: contracts/UserPoints.sol - -pragma solidity ^0.4.24; - -// import "contracts/DSAuth.sol"; -// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; -// import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -// import "contracts/interfaces/IUserPoints.sol"; - -contract UserPoints is DSAuth, IUserPoints { - using SafeMath for *; - - // claimedToken event - event ClaimedTokens(address indexed token, address indexed owner, uint amount); - - bool private singletonLock = false; - - // points - mapping (address => uint256) public points; - - uint256 public allUserPoints; - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - function initializeContract() public singletonLockCall { - owner = msg.sender; - emit LogSetOwner(msg.sender); - } - - function pointsSupply() public view returns (uint256) { - return allUserPoints; - } - - function pointsBalanceOf(address _user) public view returns (uint256) { - return points[_user]; - } - - function addPoints(address _user, uint256 _pointAmount) public auth { - points[_user] = points[_user].add(_pointAmount); - allUserPoints = allUserPoints.add(_pointAmount); - - emit AddedPoints(_user, _pointAmount); - } - - function subPoints(address _user, uint256 _pointAmount) public auth { - points[_user] = points[_user].sub(_pointAmount); - allUserPoints = allUserPoints.sub(_pointAmount); - emit SubedPoints(_user, _pointAmount); - } - - /// @notice This method can be used by the owner to extract mistakenly - /// sent tokens to this contract. - /// @param _token The address of the token contract that you want to recover - /// set to 0 in case you want to extract ether. - function claimTokens(address _token) public auth { - if (_token == 0x0) { - owner.transfer(address(this).balance); - return; - } - ERC20 token = ERC20(_token); - uint balance = token.balanceOf(address(this)); - token.transfer(owner, balance); - - emit ClaimedTokens(_token, owner, balance); - } -} \ No newline at end of file diff --git a/flat/UserPointsAuthority.sol b/flat/UserPointsAuthority.sol deleted file mode 100644 index ece830f..0000000 --- a/flat/UserPointsAuthority.sol +++ /dev/null @@ -1,20 +0,0 @@ -// Root file: contracts/UserPointsAuthority.sol - -pragma solidity ^0.4.24; - -contract UserPointsAuthority { - mapping (address => bool) public whiteList; - - constructor(address[] _whitelists) public { - for (uint i = 0; i < _whitelists.length; i ++) { - whiteList[_whitelists[i]] = true; - } - } - - function canCall( - address _src, address _dst, bytes4 _sig - ) public view returns (bool) { - return ( whiteList[_src] && _sig == bytes4(keccak256("addPoints(address,uint256)"))) || - ( whiteList[_src] && _sig == bytes4(keccak256("subPoints(address,uint256)"))); - } -} From 865b5399d478a12ba994159e2306b0a393a19c6e Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 22 Apr 2021 20:14:47 +0800 Subject: [PATCH 14/64] rm flat --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9e5592a..72ca788 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ scripts waffle.json cache /out +/flat From ef56f1451353ee64d4941aaf177198fa33368d0c Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 22 Apr 2021 20:20:56 +0800 Subject: [PATCH 15/64] move constant CHIAN_ID CURRENT_LAND to storage --- contracts/InterstellarEncoderV4.sol | 100 ++++++++++++++++++ .../interfaces/IInterstellarEncoderV3.sol | 2 +- .../interfaces/IInterstellarEncoderV4.sol | 37 +++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 contracts/InterstellarEncoderV4.sol create mode 100644 contracts/interfaces/IInterstellarEncoderV4.sol diff --git a/contracts/InterstellarEncoderV4.sol b/contracts/InterstellarEncoderV4.sol new file mode 100644 index 0000000..2cf2c6d --- /dev/null +++ b/contracts/InterstellarEncoderV4.sol @@ -0,0 +1,100 @@ +pragma solidity ^0.4.24; + +import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +import "./interfaces/IInterstellarEncoderV3.sol"; + +// TODO: upgrade. +contract InterstellarEncoderV3 is IInterstellarEncoderV3, Ownable { + + // [magic_number, chain_id, contract_id <2>, origin_chain_id, origin_contract_id<2>, object_class, convert_type, <6>, land, <128>] + mapping(uint8 => address) public ownershipId2Address; + mapping(address => uint8) public ownershipAddress2Id; + + mapping(address => uint8) public classAddress2Id; // class + // extended since V2 + mapping(uint8 => address) public classId2Address; + + uint256 public CHAIN_ID; // 1 is Ethereum mainet. + uint256 public CURRENT_LAND; // 1 is Atlantis, 0 is NaN. + + + constructor(uint256 _chainId, uint256 _currenLand) { + CHAIN_ID = _chainId; + CURRENT_LAND = _currenLand; + } + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectId) public view returns (uint256 _tokenId) { + uint16 contractId = ownershipAddress2Id[_tokenAddress]; + require(ownershipAddress2Id[_tokenAddress] > 0, "Contract address does not exist"); + + _tokenId = (MAGIC_NUMBER << 248) + (CHAIN_ID << 240) + (uint256(contractId) << 224) + + (CHAIN_ID << 216) + (uint256(contractId) << 200) + (uint256(_objectClass) << 192) + (CURRENT_LAND << 128) + uint256(_objectId); + } + + function encodeTokenIdForOuter( + address _nftAddress, address _originNftAddress, uint8 _objectClass, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256) { + uint16 contractId = ownershipAddress2Id[_nftAddress]; + uint16 originContractId = ownershipAddress2Id[_originNftAddress]; + require(contractId > 0 && originContractId > 0 && _producerId > 0, "Contract address does not exist"); + + uint256 tokenId = (MAGIC_NUMBER << 248) + (CHAIN_ID << 240) + (uint256(contractId) << 224) + + (CHAIN_ID << 216) + (uint256(originContractId) << 200) + (uint256(_objectClass) << 192) + (uint256(_convertType) << 184)+ (uint256(_producerId) << 128) + uint256(_objectId); + + return tokenId; + } + + // TODO; newly added + // @param _tokenAddress - objectOwnership + // @param _objectContract - xxxBase contract + function encodeTokenIdForOuterObjectContract( + address _objectContract, address _nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256) { + require (classAddress2Id[_objectContract] > 0, "Object class for this object contract does not exist."); + + return encodeTokenIdForOuter(_nftAddress, _originNftAddress, classAddress2Id[_objectContract], _objectId, _producerId, _convertType); + + } + // TODO; newly added + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId) { + require (classAddress2Id[_objectContract] > 0, "Object class for this object contract does not exist."); + + _tokenId = encodeTokenId(_tokenAddress, classAddress2Id[_objectContract], _objectId); + } + + function registerNewOwnershipContract(address _nftAddress, uint8 _nftId) public onlyOwner { + ownershipAddress2Id[_nftAddress] = _nftId; + ownershipId2Address[_nftId] = _nftAddress; + } + + function registerNewObjectClass(address _objectContract, uint8 _objectClass) public onlyOwner { + classAddress2Id[_objectContract] = _objectClass; + classId2Address[_objectClass] = _objectContract; + } + + function getProducerId(uint256 _tokenId) public view returns (uint16) { + return uint16((_tokenId >> 128) & 0xff); + } + + function getContractAddress(uint256 _tokenId) public view returns (address) { + return ownershipId2Address[uint8((_tokenId >> 240) & 0xff)]; + } + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId) { + return uint128(_tokenId & CLEAR_HIGH); + } + + function getObjectClass(uint256 _tokenId) public view returns (uint8) { + return uint8((_tokenId << 56) >> 248); + } + + function getObjectAddress(uint256 _tokenId) public view returns (address) { + return classId2Address[uint8((_tokenId << 56) >> 248)]; + } + + // TODO; newly added + function getOriginAddress(uint256 _tokenId) public view returns (address) { + uint8 originContractId = uint8((_tokenId >> 200) & 0xff); + return ownershipId2Address[originContractId]; + + } +} diff --git a/contracts/interfaces/IInterstellarEncoderV3.sol b/contracts/interfaces/IInterstellarEncoderV3.sol index 10eb1a8..b649d01 100644 --- a/contracts/interfaces/IInterstellarEncoderV3.sol +++ b/contracts/interfaces/IInterstellarEncoderV3.sol @@ -36,4 +36,4 @@ contract IInterstellarEncoderV3 { function getOriginAddress(uint256 _tokenId) public view returns (address); -} \ No newline at end of file +} diff --git a/contracts/interfaces/IInterstellarEncoderV4.sol b/contracts/interfaces/IInterstellarEncoderV4.sol new file mode 100644 index 0000000..2486e47 --- /dev/null +++ b/contracts/interfaces/IInterstellarEncoderV4.sol @@ -0,0 +1,37 @@ +pragma solidity ^0.4.24; + +contract IInterstellarEncoderV4 { + uint256 constant CLEAR_HIGH = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; + + uint256 public constant MAGIC_NUMBER = 42; // Interstellar Encoding Magic Number. + + enum ObjectClass { + NaN, + LAND, + APOSTLE, + OBJECT_CLASS_COUNT + } + + function registerNewObjectClass(address _objectContract, uint8 objectClass) public; + + function encodeTokenId(address _tokenAddress, uint8 _objectClass, uint128 _objectIndex) public view returns (uint256 _tokenId); + + function encodeTokenIdForObjectContract( + address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId); + + function encodeTokenIdForOuterObjectContract( + address _objectContract, address nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256); + + function getContractAddress(uint256 _tokenId) public view returns (address); + + function getObjectId(uint256 _tokenId) public view returns (uint128 _objectId); + + function getObjectClass(uint256 _tokenId) public view returns (uint8); + + function getObjectAddress(uint256 _tokenId) public view returns (address); + + function getProducerId(uint256 _tokenId) public view returns (uint16); + + function getOriginAddress(uint256 _tokenId) public view returns (address); + +} From 9ccefaeb2d3b3276f95fbd11ea1c45dc9e7253af Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 23 Apr 2021 12:23:11 +0800 Subject: [PATCH 16/64] make cleand --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8b2a92c..5775c51 100644 --- a/Makefile +++ b/Makefile @@ -1 +1,2 @@ -all :; source .env && dapp --use solc:0.4.24 build +all :; source .env && dapp --use solc:0.4.24 build +clean :; dapp clean From aaa4541f3abd8d88999b55122f8a3e90ba537b5e Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 23 Apr 2021 14:54:21 +0800 Subject: [PATCH 17/64] fix --- contracts/InterstellarEncoderV4.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/InterstellarEncoderV4.sol b/contracts/InterstellarEncoderV4.sol index 2cf2c6d..827658c 100644 --- a/contracts/InterstellarEncoderV4.sol +++ b/contracts/InterstellarEncoderV4.sol @@ -1,10 +1,10 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -import "./interfaces/IInterstellarEncoderV3.sol"; +import "./interfaces/IInterstellarEncoderV4.sol"; // TODO: upgrade. -contract InterstellarEncoderV3 is IInterstellarEncoderV3, Ownable { +contract InterstellarEncoderV4 is IInterstellarEncoderV4, Ownable { // [magic_number, chain_id, contract_id <2>, origin_chain_id, origin_contract_id<2>, object_class, convert_type, <6>, land, <128>] mapping(uint8 => address) public ownershipId2Address; From 33793bc6db0a497c566e92f875cafb2dce441125 Mon Sep 17 00:00:00 2001 From: echo Date: Mon, 26 Apr 2021 00:48:13 +0800 Subject: [PATCH 18/64] dapp uninstall upgradeability-using-unstructured-storage --- .gitmodules | 3 --- lib/upgradeability-using-unstructured-storage | 1 - 2 files changed, 4 deletions(-) delete mode 160000 lib/upgradeability-using-unstructured-storage diff --git a/.gitmodules b/.gitmodules index f7dc7ed..00ee208 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "lib/upgradeability-using-unstructured-storage"] - path = lib/upgradeability-using-unstructured-storage - url = https://github.com/evolutionlandorg/upgradeability-using-unstructured-storage [submodule "lib/zeppelin-solidity"] path = lib/zeppelin-solidity url = https://github.com/OpenZeppelin/zeppelin-solidity diff --git a/lib/upgradeability-using-unstructured-storage b/lib/upgradeability-using-unstructured-storage deleted file mode 160000 index 5d89ae1..0000000 --- a/lib/upgradeability-using-unstructured-storage +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5d89ae1a00943cbe06d2fb97ad8ade0f9a7f8f08 From c516486fe056f72e38c4b6357383397c9dccbc5b Mon Sep 17 00:00:00 2001 From: echo Date: Mon, 26 Apr 2021 10:12:15 +0800 Subject: [PATCH 19/64] rm outdate proxy --- contracts/DeployAndTest.sol | 2 +- contracts/Migrations.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/DeployAndTest.sol b/contracts/DeployAndTest.sol index fa138b9..680350b 100644 --- a/contracts/DeployAndTest.sol +++ b/contracts/DeployAndTest.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.23; import "./StandardERC223.sol"; import "./SettingsRegistry.sol"; -import "@evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol"; +// import "@evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol"; import "./MintAndBurnAuthority.sol"; contract DeployAndTest { diff --git a/contracts/Migrations.sol b/contracts/Migrations.sol index e289e49..7b02731 100644 --- a/contracts/Migrations.sol +++ b/contracts/Migrations.sol @@ -1,5 +1,5 @@ pragma solidity ^0.4.23; -import "@evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol"; +// import "@evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol"; contract Migrations { address public owner; From 09fa5f6e6384dc5ab33142a444a65ace7238d606 Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 29 Apr 2021 13:11:18 +0800 Subject: [PATCH 20/64] rm truffle --- .gitignore | 9 - README.md | 4 +- migrations/10_burndrop_migration.js | 25 - .../11_tokenbuildingenesis_migration.js | 24 - migrations/12_crosschain_migration.js | 53 - migrations/1_initial_migration.js | 5 - migrations/2_deploy_migration.js | 21 - migrations/3_tokenuse_migration.js | 46 - migrations/4_upgrade_tokenUse.js | 19 - migrations/5_upgrade_tokenUseAndAuthority.js | 27 - migrations/6_bridge_migration.js | 107 - migrations/7_update_erc721Bridge.js | 19 - migrations/9_registry_migration.js | 9 - package.json | 34 - test/InterstellarEncoder.js | 35 - test/LocationCoder.js | 58 - test/LocationEncodeTest.sol | 22 - test/SettingsRegistry.js | 99 - test/burndrop.js | 83 - test/helpers/Utils.js | 16 - truffle.js.sample | 70 - yarn.lock | 4835 ----------------- 22 files changed, 2 insertions(+), 5618 deletions(-) delete mode 100644 migrations/10_burndrop_migration.js delete mode 100644 migrations/11_tokenbuildingenesis_migration.js delete mode 100644 migrations/12_crosschain_migration.js delete mode 100644 migrations/1_initial_migration.js delete mode 100644 migrations/2_deploy_migration.js delete mode 100644 migrations/3_tokenuse_migration.js delete mode 100644 migrations/4_upgrade_tokenUse.js delete mode 100644 migrations/5_upgrade_tokenUseAndAuthority.js delete mode 100644 migrations/6_bridge_migration.js delete mode 100644 migrations/7_update_erc721Bridge.js delete mode 100644 migrations/9_registry_migration.js delete mode 100644 package.json delete mode 100644 test/InterstellarEncoder.js delete mode 100644 test/LocationCoder.js delete mode 100644 test/LocationEncodeTest.sol delete mode 100644 test/SettingsRegistry.js delete mode 100644 test/burndrop.js delete mode 100644 test/helpers/Utils.js delete mode 100644 truffle.js.sample delete mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index 72ca788..c9389b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,4 @@ -build .DS_Store -node_modules -package-lock.json .idea -contracts-flattener -truffle.js -truffle.config.js -scripts -waffle.json -cache /out /flat diff --git a/README.md b/README.md index d9389a4..b7ddd98 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,5 @@ ## Installing ```sh -npm install @evolutionland/common -``` \ No newline at end of file +dapp install evolutionlandorg/common-contracts +``` diff --git a/migrations/10_burndrop_migration.js b/migrations/10_burndrop_migration.js deleted file mode 100644 index fc02d05..0000000 --- a/migrations/10_burndrop_migration.js +++ /dev/null @@ -1,25 +0,0 @@ -const DeployAndTest = artifacts.require("./DeployAndTest.sol") -const TokenBurnDrop = artifacts.require("TokenBurnDrop") -const SettingsRegistry = artifacts.require("SettingsRegistry") -const SettingIds = artifacts.require("SettingIds") - -module.exports = async (deployer, network) => { - console.log('Burndrop Bank Test') - if (network != "development") { - return - } - - await deployer.deploy(SettingIds) - await deployer.deploy(DeployAndTest) - await deployer.deploy(TokenBurnDrop) - const settingsRegistry = await deployer.deploy(SettingsRegistry) - - const settingIds = await SettingIds.deployed(); - const deployAndTest = await DeployAndTest.deployed(); - const tokenBurnDrop = await TokenBurnDrop.deployed(); - - await settingsRegistry.setAddressProperty(await settingIds.CONTRACT_RING_ERC20_TOKEN.call(), await deployAndTest.testRING.call()) - await settingsRegistry.setAddressProperty(await settingIds.CONTRACT_KTON_ERC20_TOKEN.call(), await deployAndTest.testKTON.call()) - - await tokenBurnDrop.initializeContract(settingsRegistry.address) -} diff --git a/migrations/11_tokenbuildingenesis_migration.js b/migrations/11_tokenbuildingenesis_migration.js deleted file mode 100644 index 1d9d78c..0000000 --- a/migrations/11_tokenbuildingenesis_migration.js +++ /dev/null @@ -1,24 +0,0 @@ -const DeployAndTest = artifacts.require("./DeployAndTest.sol") -const TokenBuildInGenesis = artifacts.require("TokenBuildInGenesis") -const SettingsRegistry = artifacts.require("SettingsRegistry") -const SettingIds = artifacts.require("SettingIds") - -module.exports = async (deployer, network) => { - if (network != "ropsten") { - return - } - - await deployer.deploy(SettingIds) - await deployer.deploy(DeployAndTest) - await deployer.deploy(TokenBurnDrop) - const settingsRegistry = await deployer.deploy(SettingsRegistry) - - const settingIds = await SettingIds.deployed(); - const deployAndTest = await DeployAndTest.deployed(); - const tokenBurnDrop = await TokenBurnDrop.deployed(); - - await settingsRegistry.setAddressProperty(await settingIds.CONTRACT_RING_ERC20_TOKEN.call(), await deployAndTest.testRING.call()) - await settingsRegistry.setAddressProperty(await settingIds.CONTRACT_KTON_ERC20_TOKEN.call(), await deployAndTest.testKTON.call()) - - await tokenBurnDrop.initializeContract(settingsRegistry.address) -} diff --git a/migrations/12_crosschain_migration.js b/migrations/12_crosschain_migration.js deleted file mode 100644 index 90b1f2d..0000000 --- a/migrations/12_crosschain_migration.js +++ /dev/null @@ -1,53 +0,0 @@ -const Issuing = artifacts.require("Issuing") -const ERC223 = artifacts.require("StandardERC223") -const ISettingsRegistry = artifacts.require("ISettingsRegistry") - -module.exports = async (deployer, network, accounts) => { - console.log('Issuing Test, deployer:', accounts, accounts[0]) - if (network != "ropsten") { - return - } - - const params = { - ropsten: { - registry: "0x6982702995b053A21389219c1BFc0b188eB5a372", - isPaused: false, - ring: '0xb52FBE2B925ab79a821b261C82c5Ba0814AAA5e0', - kton: '0x1994100c58753793D52c6f457f189aa3ce9cEe94', - settingsRegistry: '0x6982702995b053A21389219c1BFc0b188eB5a372' - } - } - - let issuing = await Issuing.new(params[network].settingsRegistry) - // let issuing = await Issuing.at('xxx') - console.log('issuing.address: ', issuing.address) - // return - // set ring authrity - let registry = await ISettingsRegistry.at(params[network].settingsRegistry) - - // UINT_BRIDGE_FEE - await registry.setUintProperty('0x55494e545f4252494447455f4645450000000000000000000000000000000000', web3.utils.toWei('2')) - - // CONTRACT_BRIDGE_POOL - await registry.setAddressProperty('0x434f4e54524143545f4252494447455f504f4f4c000000000000000000000000', '0x7f5B598827359939606B3525712Fb124A1C7851d') - console.log('set registry success') - - await issuing.addSupportedTokens(params[network].ring); - await issuing.addSupportedTokens(params[network].kton); - console.log('add supported tokens success') - - // test - // crossChain test - const RING = await ERC223.at(params[network].ring); - const KTON = await ERC223.at(params[network].kton); - - // approve ring - await RING.approve(issuing.address, web3.utils.toWei('10000')) - console.log('approve ring success') - - let tx = await RING.transferFrom(accounts[0], issuing.address, web3.utils.toWei('1.2345'), '0xe44664996ab7b5d86c12e9d5ac3093f5b2efc9172cb7ce298cd6c3c51002c318') - console.log('transfer ring tx:', tx.tx) - - tx = await KTON.transferFrom(accounts[0], issuing.address, web3.utils.toWei('0.0001234'), '0xe44664996ab7b5d86c12e9d5ac3093f5b2efc9172cb7ce298cd6c3c51002c318') - console.log('transfer kton tx:', tx.tx) -} diff --git a/migrations/1_initial_migration.js b/migrations/1_initial_migration.js deleted file mode 100644 index 4d5f3f9..0000000 --- a/migrations/1_initial_migration.js +++ /dev/null @@ -1,5 +0,0 @@ -var Migrations = artifacts.require("./Migrations.sol"); - -module.exports = function(deployer) { - deployer.deploy(Migrations); -}; diff --git a/migrations/2_deploy_migration.js b/migrations/2_deploy_migration.js deleted file mode 100644 index 18bfb4b..0000000 --- a/migrations/2_deploy_migration.js +++ /dev/null @@ -1,21 +0,0 @@ -const LocationCoder = artifacts.require("./LocationCoder.sol"); -const TokenLocation = artifacts.require("./TokenLocation.sol"); -const InterstellarEncoder = artifacts.require("./InterstellarEncoder.sol"); - -module.exports = function(deployer, network, accounts) { - if (network == "develop") - { - deployer.then(async () => { - await deployOnLocal(deployer, network, accounts); - }); - } -}; - -async function deployOnLocal(deployer, network, accounts) { - console.log(network); - - await deployer.deploy(LocationCoder); - await deployer.deploy(TokenLocation); - - await deployer.deploy(InterstellarEncoder); -} diff --git a/migrations/3_tokenuse_migration.js b/migrations/3_tokenuse_migration.js deleted file mode 100644 index ccd96cf..0000000 --- a/migrations/3_tokenuse_migration.js +++ /dev/null @@ -1,46 +0,0 @@ -const TokenUse = artifacts.require('TokenUse'); -const TokenUseAuthority = artifacts.require('TokenUseAuthority'); -const SettingsRegistry = artifacts.require('SettingsRegistry'); -const Proxy = artifacts.require('OwnedUpgradeabilityProxy'); - - -const conf = { - registry_address: '0xd8b7a3f6076872c2c37fb4d5cbfeb5bf45826ed7', - apostleBaseProxy_address: '0x23236af7d03c4b0720f709593f5ace0ea92e77cf', - uint_token_offer_cut: 400 -} - -module.exports = async(deployer, network) => { - if(network == 'kovan') { - return; - } - - deployer.deploy(Proxy); - deployer.deploy(TokenUse) - .then(async() => { - await deployer.deploy(TokenUseAuthority, [conf.apostleBaseProxy_address]); - }).then(async() => { - let registry = await SettingsRegistry.at(conf.registry_address); - - let tokenUseCutId = await TokenUse.at(TokenUse.address).UINT_TOKEN_OFFER_CUT.call(); - await registry.setUintProperty(tokenUseCutId, conf.uint_token_offer_cut); - - let tokenUseId = await TokenUse.at(TokenUse.address).CONTRACT_TOKEN_USE.call(); - await registry.setAddressProperty(tokenUseId, Proxy.address); - console.log("REGISTER DONE!"); - - await Proxy.at(Proxy.address).upgradeTo(TokenUse.address); - console.log("UPGRADE DONE!"); - - let tokenUseProxy = await TokenUse.at(Proxy.address); - await tokenUseProxy.initializeContract(conf.registry_address); - console.log("INITIALIZE DONE!"); - - // set authority - await tokenUseProxy.setAuthority(TokenUseAuthority.address); - - - }) - - -} \ No newline at end of file diff --git a/migrations/4_upgrade_tokenUse.js b/migrations/4_upgrade_tokenUse.js deleted file mode 100644 index f691655..0000000 --- a/migrations/4_upgrade_tokenUse.js +++ /dev/null @@ -1,19 +0,0 @@ -const Proxy = artifacts.require('OwnedUpgradeabilityProxy'); -const TokenUse = artifacts.require('TokenUse'); - -const conf = { - tokenUseProxy_address: '0xd2bcd143db59ddd43df2002fbf650e46b2b7ea19' -} - -module.exports = async(deployer, network) => { - - if(network == 'kovan') { - return; - } - - deployer.deploy(TokenUse).then(async() => { - await Proxy.at(conf.tokenUseProxy_address).upgradeTo(TokenUse.address); - }) - - -} \ No newline at end of file diff --git a/migrations/5_upgrade_tokenUseAndAuthority.js b/migrations/5_upgrade_tokenUseAndAuthority.js deleted file mode 100644 index 12435a5..0000000 --- a/migrations/5_upgrade_tokenUseAndAuthority.js +++ /dev/null @@ -1,27 +0,0 @@ -const Proxy = artifacts.require('OwnedUpgradeabilityProxy'); -const TokenUse = artifacts.require('TokenUse'); -const TokenUseAuthority = artifacts.require('TokenUseAuthority'); - -const conf = { - tokenUseProxy_address: '0xd2bcd143db59ddd43df2002fbf650e46b2b7ea19', - apostleBaseProxy_address: '0x23236af7d03c4b0720f709593f5ace0ea92e77cf', - landResourceProxy_address: '0x6bcb3c94040ba63e4da086f2a8d0d6f5f72b8490' -} - -module.exports = async(deployer, network) => { - - if(network == 'kovan') { - return; - } - - deployer.deploy(TokenUseAuthority, [conf.tokenUseProxy_address,conf.apostleBaseProxy_address, conf.landResourceProxy_address]); - deployer.deploy(TokenUse).then(async() => { - await Proxy.at(conf.tokenUseProxy_address).upgradeTo(TokenUse.address); - - console.log("UPGRADE DONE!"); - let tokenUseProxy = await TokenUse.at(conf.tokenUseProxy_address); - await tokenUseProxy.setAuthority(TokenUseAuthority.address); - }) - - -} \ No newline at end of file diff --git a/migrations/6_bridge_migration.js b/migrations/6_bridge_migration.js deleted file mode 100644 index f233b7b..0000000 --- a/migrations/6_bridge_migration.js +++ /dev/null @@ -1,107 +0,0 @@ -const ERC721Bridge = artifacts.require("ERC721Bridge"); -const ERC721Adaptor = artifacts.require("ERC721Adaptor"); -const Proxy = artifacts.require("OwnedUpgradeabilityProxy"); -const SettingsRegistry = artifacts.require("SettingsRegistry"); -const ObjectOwnershipAuthorityV2 = artifacts.require("ObjectOwnershipAuthorityV2"); -const ObjectOwnershipV2 = artifacts.require("ObjectOwnershipV2"); -// TODO -const InterstellarEncoderV3 = artifacts.require("InterstellarEncoderV3"); -const ERC721AdaptorAuthority = artifacts.require("ERC721AdaptorAuthority"); - -const conf = { - registry_address: "0xd8b7a3f6076872c2c37fb4d5cbfeb5bf45826ed7", - objectOwnershipProxy_address: "0xe94b9ebf9609a0d20270e8de317381ff4bcdcd79", - apostleBaseProxy_address: "0x23236af7d03c4b0720f709593f5ace0ea92e77cf", - landBaseProxy_address: "0x72eec3a6a9a8628e0f7a2dbbad5df083bd985c5f", - kittyCore_address: '0x9782865f91f9aace5582f695bf678121a0359edd', - ck_producerId: 256, - objectOwnership_id: 1, - ck_ownership_id: 2 -} - -var erc721BridgeProxy_address; -var erc721AdaptorProxy_address; - -module.exports = async (deployer, network) => { - - if(network == "kovan") { - return; - } - - deployer.deploy(Proxy).then(async() => { - let erc721BridgeProxy = await Proxy.deployed(); - erc721BridgeProxy_address = erc721BridgeProxy.address; - console.log("ERC721BridgeProxy: ", erc721BridgeProxy_address); - await deployer.deploy(ERC721Bridge); - await deployer.deploy(Proxy); - }).then(async() => { - let erc721AdaptorProxy = await Proxy.deployed(); - erc721AdaptorProxy_address = erc721AdaptorProxy.address; - console.log("ERC721AdaptorProxy: ", erc721AdaptorProxy_address); - await deployer.deploy(ERC721Adaptor); - }).then(async() => { - await deployer.deploy(ObjectOwnershipAuthorityV2, [erc721BridgeProxy_address, conf.apostleBaseProxy_address, conf.landBaseProxy_address]); - await deployer.deploy(InterstellarEncoderV3); - }).then(async() => { - await deployer.deploy(ERC721AdaptorAuthority, [erc721BridgeProxy_address]); - }).then(async() => { - - // register address in registry - let bridge = await ERC721Bridge.deployed(); - let bridgeId = await bridge.CONTRACT_ERC721_BRIDGE.call(); - let registry = await SettingsRegistry.at(conf.registry_address); - await registry.setAddressProperty(bridgeId, erc721BridgeProxy_address); - - // register interstellarEncoder - let encoderId = await bridge.CONTRACT_INTERSTELLAR_ENCODER.call(); - let encoder = await InterstellarEncoderV3.deployed(); - await registry.setAddressProperty(encoderId, encoder.address); - - console.log("REGISTER IN REGISTRY DONE"); - - // upgrade - let bridgeProxy = await Proxy.at(erc721BridgeProxy_address); - await bridgeProxy.upgradeTo(ERC721Bridge.address); - - let adaptorProxy = await Proxy.at(erc721AdaptorProxy_address); - await adaptorProxy.upgradeTo(ERC721Adaptor.address); - - console.log("UPGRADE DONE!"); - - // initialize - let erc721Bridge = await ERC721Bridge.at(erc721BridgeProxy_address); - await erc721Bridge.initializeContract(conf.registry_address); - - let erc721Adaptor = await ERC721Adaptor.at(erc721AdaptorProxy_address); - await erc721Adaptor.initializeContract(conf.registry_address, conf.kittyCore_address, conf.ck_producerId); - - console.log("INITIALIZATION DONE!"); - - // setAuthority - let objectOwnershipProxy = await ObjectOwnershipV2.at(conf.objectOwnershipProxy_address); - await objectOwnershipProxy.setAuthority(ObjectOwnershipAuthorityV2.address); - - await erc721Adaptor.setAuthority(ERC721AdaptorAuthority.address); - - console.log("AUTHORITY DONE!"); - - - - await encoder.registerNewOwnershipContract(conf.objectOwnershipProxy_address, conf.objectOwnership_id); - await encoder.registerNewOwnershipContract(conf.kittyCore_address, conf.ck_ownership_id); - - console.log("ENCODER REGISTER TOKEN DONE!"); - - await encoder.registerNewObjectClass(conf.landBaseProxy_address, 1); - await encoder.registerNewObjectClass(conf.apostleBaseProxy_address, 2); - - console.log("ENCODER REGISTER OBJECT CLASS DONE!"); - - await erc721Bridge.registerAdaptor(conf.kittyCore_address, erc721AdaptorProxy_address); - - console.log("SUCCESS!") - - - - }) -} \ No newline at end of file diff --git a/migrations/7_update_erc721Bridge.js b/migrations/7_update_erc721Bridge.js deleted file mode 100644 index 28d4880..0000000 --- a/migrations/7_update_erc721Bridge.js +++ /dev/null @@ -1,19 +0,0 @@ -const Proxy = artifacts.require('OwnedUpgradeabilityProxy'); -const ERC721Bridge = artifacts.require("ERC721Bridge"); - -const conf = { - erc721Bridge_proxy: '0x3af088062a6ab3b9706eb1c58506fc0fcf898588' -} - -module.exports = async(deployer, network) => { - - if(network != 'kovan') { - return; - } - - deployer.deploy(ERC721Bridge).then(async() => { - await Proxy.at(conf.erc721Bridge_proxy).upgradeTo(ERC721Bridge.address); - }) - - -} \ No newline at end of file diff --git a/migrations/9_registry_migration.js b/migrations/9_registry_migration.js deleted file mode 100644 index 508a7db..0000000 --- a/migrations/9_registry_migration.js +++ /dev/null @@ -1,9 +0,0 @@ -const SettingsRegistry = artifacts.require("SettingsRegistry") -module.exports = async (deployer, network) => { - - if(network != "development") { - return; - } - - deployer.deploy(SettingsRegistry); -} diff --git a/package.json b/package.json deleted file mode 100644 index 2a2a166..0000000 --- a/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@evolutionland/common", - "version": "1.7.9", - "description": "Common Contracts for Evolution Land", - "main": "truffle-config.js", - "directories": { - "test": "test" - }, - "scripts": { - "build": "npx waffle", - "flatten": "npx waffle flatten", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/evolutionlandorg/common-contracts.git" - }, - "keywords": [], - "author": "", - "license": "ISC", - "bugs": { - "url": "https://github.com/evolutionlandorg/common-contracts/issues" - }, - "homepage": "https://github.com/evolutionlandorg/common-contracts#readme", - "dependencies": { - "@evolutionland/upgraeability-using-unstructured-storage": "^0.1.1", - "@truffle/hdwallet-provider": "^1.0.23", - "openzeppelin-solidity": "1.12.0", - "web3": "^1.2.11" - }, - "devDependencies": { - "ethereum-waffle": "^3.2.1" - } -} diff --git a/test/InterstellarEncoder.js b/test/InterstellarEncoder.js deleted file mode 100644 index ead2d89..0000000 --- a/test/InterstellarEncoder.js +++ /dev/null @@ -1,35 +0,0 @@ -const InterstellarEncoder = artifacts.require('InterstellarEncoder'); - -contract('InterstellarEncoder Test', async(accounts) => { - let interstellarEncoder; - - before('deploy and configure', async() => { - // get contract from deployed version - interstellarEncoder = await InterstellarEncoder.deployed(); - - console.log('interstellarEncoder address: ', interstellarEncoder.address); - - await interstellarEncoder.registerNewTokenContract(0x01); - - await interstellarEncoder.registerNewObjectClass(0x0f, 1); - }) - - it('test encode and decode in decimal', async() => { - let tokenId = await interstellarEncoder.encodeTokenIdForObjectContract(0x01, 0x0f, 3); - console.log(tokenId.toString(16)); - - assert.equal(tokenId, 0x2a01000101000101000000000000000100000000000000000000000000000003); - - let tokenId2 = await interstellarEncoder.encodeTokenId(0x01, 1, 3); - - assert.equal(tokenId.toString(16), tokenId2.toString(16)); - - let contractAddress = await interstellarEncoder.getContractAddress.call(tokenId.valueOf()); - console.log(contractAddress); - assert.equal(contractAddress, 0x01); - - let objectId = await interstellarEncoder.getObjectId.call(tokenId.valueOf()); - assert.equal(objectId, 0x03); - - }); -}) \ No newline at end of file diff --git a/test/LocationCoder.js b/test/LocationCoder.js deleted file mode 100644 index c4a6b0d..0000000 --- a/test/LocationCoder.js +++ /dev/null @@ -1,58 +0,0 @@ -const LocationCoder = artifacts.require('LocationCoder'); - -const HMETER = 10 ** 8; - -contract('Token Location Test', async(accounts) => { - let deployer = accounts[0]; - let investor = accounts[1]; - let locationCoder; - - before('deploy and configure', async() => { - // get contract from deployed version - locationCoder = await LocationCoder.deployed(); - - console.log('locationCoder address: ', locationCoder.address); - }) - - it('test encode and decode in decimal', async() => { - - let locationId = await locationCoder.encodeLocationIdXY.call(-49 * HMETER, 49 * HMETER); - let location = await locationCoder.decodeLocationIdXY.call(locationId); - assert.equal(location[0].toNumber(), -49 * HMETER); - assert.equal(location[1].toNumber(), 49 * HMETER); - - let locationId1 = await locationCoder.encodeLocationIdXY.call(1, -1); - console.log("locationId1... " + locationId1); - let location1 = await locationCoder.decodeLocationIdXY.call(locationId1); - assert.equal(location1[0].toNumber(), 1); - assert.equal(location1[1].toNumber(), -1); - - }); - - it('test encode and decode in 100M', async() => { - - let locationId = await locationCoder.encodeLocationIdHM.call(-49, 49); - let location = await locationCoder.decodeLocationIdHM.call(locationId); - assert.equal(location[0].toNumber(), -49); - assert.equal(location[1].toNumber(), 49); - - let locationId1 = await locationCoder.encodeLocationIdHM.call(1, -1); - console.log("locationId1... " + locationId1); - let location1 = await locationCoder.decodeLocationIdHM.call(locationId1); - assert.equal(location1[0].toNumber(), 1); - assert.equal(location1[1].toNumber(), -1); - - }); - - it('test encode and decode 3d points', async() => { - - let locationId = await locationCoder.encodeLocationId3D.call(-49, 49, -1); - let location = await locationCoder.decodeLocationId3D.call(locationId); - assert.equal(location[0].toNumber(), -49); - assert.equal(location[1].toNumber(), 49); - assert.equal(location[2].toNumber(), -1); - - }); - - -}) \ No newline at end of file diff --git a/test/LocationEncodeTest.sol b/test/LocationEncodeTest.sol deleted file mode 100644 index 1dbe0e9..0000000 --- a/test/LocationEncodeTest.sol +++ /dev/null @@ -1,22 +0,0 @@ -pragma solidity ^0.4.24; - -contract LocationEncodeTest { - - uint256 constant FACTOR = 0x100000000000000000000000000000000; - - function test0() public pure returns (bytes32) { - return bytes32(uint(-2)); - } - - function test1() public pure returns (bytes32) { - return bytes32(uint(-2) * FACTOR); - } - - function test2() public pure returns (bytes32) { - return bytes32(uint(2) * FACTOR); - } - - function test3() public pure returns (bytes32) { - return bytes32(int(uint(-2))); - } -} \ No newline at end of file diff --git a/test/SettingsRegistry.js b/test/SettingsRegistry.js deleted file mode 100644 index aa2c939..0000000 --- a/test/SettingsRegistry.js +++ /dev/null @@ -1,99 +0,0 @@ -/* global artifacts, contract, it, assert */ -/* eslint-disable prefer-reflect */ - -const SettingsRegistry = artifacts.require('SettingsRegistry.sol'); -const utils = require('./helpers/Utils'); - -let contractName1 = 'red'; -let contractName2 = 'blue'; -let contractName3 = 'black'; - -contract('SettingsRegistry', accounts => { - it('verifies that a given contract address is not set after construction', async () => { - let contractRegistry = await SettingsRegistry.new(); - let address = await contractRegistry.addressOf.call(contractName1); - assert.equal(address, utils.zeroAddress); - }); - - it('verifies that the owner can register a contract address', async () => { - let contractRegistry = await SettingsRegistry.new(); - await contractRegistry.setAddressProperty(contractName1, accounts[1]); - let address = await contractRegistry.addressOf.call(contractName1); - assert.equal(address, accounts[1]); - }); - - it('should throw when a non owner attempts to register a contract address', async () => { - let contractRegistry = await SettingsRegistry.new(); - - try { - await contractRegistry.setAddressProperites(contractName1, accounts[1], { from: accounts[2] }); - assert(false, "didn't throw"); - } - catch (error) { - return utils.ensureException(error); - } - }); - - it('verifies that the contract name list gets updated correctly when registering addresses', async () => { - let contractRegistry = await SettingsRegistry.new(); - await contractRegistry.setAddressProperty(contractName1, accounts[1]); - await contractRegistry.setAddressProperty(contractName2, accounts[2]); - - let itemCount = await contractRegistry.itemCount.call(); - assert.equal(itemCount, 2); - let name = await contractRegistry.contractNames.call(0); - assert.equal(name, contractName1); - name = await contractRegistry.contractNames.call(1); - assert.equal(name, contractName2); - }); - - it('verifies that the owner can unregister a contract address', async () => { - let contractRegistry = await SettingsRegistry.new(); - await contractRegistry.setAddressProperty(contractName1, accounts[1]); - let address = await contractRegistry.addressOf.call(contractName1); - assert.equal(address, accounts[1]); - - await contractRegistry.unsetAddressProperty(contractName1); - address = await contractRegistry.addressOf.call(contractName1); - assert.equal(address, utils.zeroAddress); - }); - - it('should throw when a non owner attempts to unregister a contract address', async () => { - let contractRegistry = await SettingsRegistry.new(); - await contractRegistry.setAddressProperty(contractName1, accounts[1]); - let address = await contractRegistry.addressOf.call(contractName1); - assert.equal(address, accounts[1]); - - try { - await contractRegistry.unsetAddressProperty(contractName1, { from: accounts[2] }); - assert(false, "didn't throw"); - } - catch (error) { - return utils.ensureException(error); - } - }); - - it('verifies that the contract name list gets updated correctly when unregistering addresses', async () => { - let contractRegistry = await SettingsRegistry.new(); - await contractRegistry.setAddressProperty(contractName1, accounts[1]); - await contractRegistry.setAddressProperty(contractName2, accounts[2]); - await contractRegistry.setAddressProperty(contractName3, accounts[3]); - - let itemCount = await contractRegistry.itemCount.call(); - assert.equal(itemCount, 3); - let name = await contractRegistry.contractNames.call(0); - assert.equal(name, contractName1); - name = await contractRegistry.contractNames.call(1); - assert.equal(name, contractName2); - name = await contractRegistry.contractNames.call(2); - assert.equal(name, contractName3); - - await contractRegistry.unsetAddressProperty(contractName1); - itemCount = await contractRegistry.itemCount.call(); - assert.equal(itemCount, 2); - name = await contractRegistry.contractNames.call(0); - assert.equal(name, contractName3); - name = await contractRegistry.contractNames.call(1); - assert.equal(name, contractName2); - }); -}); diff --git a/test/burndrop.js b/test/burndrop.js deleted file mode 100644 index c8ce433..0000000 --- a/test/burndrop.js +++ /dev/null @@ -1,83 +0,0 @@ -const StandardERC223 = artifacts.require('StandardERC223') -const DeployAndTest = artifacts.require("./DeployAndTest.sol") -const TokenBurnDrop = artifacts.require("TokenBurnDrop") -const SettingsRegistry = artifacts.require("SettingsRegistry") - -const log = console.log - -function toWei(ether) { - if(ether == 0) { - return '0' - } - return `${ether}000000000000000000` -} - - -function mine () { - const id = Date.now() - return new Promise((resolve, reject) => { - web3.currentProvider.send({ - jsonrpc: '2.0', - method: 'evm_mine', - id: id , - }, (err, res) => { - return err ? reject(err) : resolve(res) - }) - }) -} - -contract('Burndrop Bank Test', async (accounts) => { - let deployer = accounts[0] - let investor = accounts[1] - let investor2 = accounts[2] - let registry - let ring - let kton - - async function printBalance(ring, kton, user) { - log(`${user} -> ring balance: ${await ring.balanceOf(user)}, kton balance: ${await kton.balanceOf(user)}`) - } - - before('config', async () => { - const deployAndTest = await DeployAndTest.deployed() - ring = await StandardERC223.at(await deployAndTest.testRING.call()) - kton = await StandardERC223.at(await deployAndTest.testKTON.call()) - - log(`ring: ${ring.address}, kton: ${kton.address}`) - - await ring.mint(investor, toWei(10000)) - await kton.mint(investor2, toWei(10000)) - - await printBalance(ring, kton, investor) - await printBalance(ring, kton, investor2) - }) - - it('burndrop balance', async () => { - const tokenBurnDrop = await TokenBurnDrop.deployed() - log('tokenBurndrop:', tokenBurnDrop.address) - assert.strictEqual((await ring.balanceOf(investor)).toString(), toWei(10000)) - assert.strictEqual((await kton.balanceOf(investor2)).toString(), toWei(10000)) - - log(await web3.eth.getBlockNumber()) - await mine() - log(await web3.eth.getBlockNumber()) - await ring.transfer(tokenBurnDrop.address, toWei(3000), {from: investor}) - await kton.transfer(tokenBurnDrop.address, toWei(4000), {from: investor2}) - - await printBalance(ring, kton, investor) - await printBalance(ring, kton, investor2) - - // assert.strictEqual((await ring.balanceOf(investor)).toString(), toWei(7000), 'ring balance') - // assert.strictEqual((await kton.balanceOf(investor2)).toString(), toWei(6000), 'kton balance') - // - // assert.strictEqual((await ring.balanceOf(tokenBurnDrop.address)).toString(), toWei(0), 'ring balance') - // assert.strictEqual((await kton.balanceOf(tokenBurnDrop.address)).toString(), toWei(0), 'kton balance') - - await ring.transfer(tokenBurnDrop.address, toWei(3000), {from: investor}) - await kton.transfer(tokenBurnDrop.address, toWei(4000), {from: investor2}) - - await printBalance(ring, kton, tokenBurnDrop.address) - - - }) -}) diff --git a/test/helpers/Utils.js b/test/helpers/Utils.js deleted file mode 100644 index ebb21e4..0000000 --- a/test/helpers/Utils.js +++ /dev/null @@ -1,16 +0,0 @@ -/* global assert */ - -function isException(error) { - let strError = error.toString(); - return strError.includes('VM Exception') || strError.includes('invalid opcode') || strError.includes('invalid JUMP'); -} - -function ensureException(error) { - assert(isException(error), error.toString()); -} - -module.exports = { - zeroAddress: '0x0000000000000000000000000000000000000000', - isException: isException, - ensureException: ensureException -}; diff --git a/truffle.js.sample b/truffle.js.sample deleted file mode 100644 index 27e90c5..0000000 --- a/truffle.js.sample +++ /dev/null @@ -1,70 +0,0 @@ -// require('babel-register')({ -// ignore: /node_modules\/(?!openzeppelin-solidity\/test\/helpers)/ -// }); -// require('babel-polyfill'); - -var HDWalletProvider = require("truffle-hdwallet-provider"); -// Either use this key or get yours at https://infura.io/signup. It's free. -var infura_apikey = "INFURA_APIKEY"; -// use your deployer account's mnemonic -var mnemonic = "BLAH * 16"; - -module.exports = { - // See - // to customize your Truffle configuration! - networks: { - development: { // ganache by default - host: "localhost", - port: 7545, - gas: 6500000, - gasPrice: 20000000000, - from: "xxxx", // default from account setting - network_id: "5777" - }, - kovan: { - provider: () => new HDWalletProvider(mnemonic, "https://kovan.infura.io/" + infura_apikey), - network_id: 42, - gas: 4500000 - }, - rinkeby: { - provider: () => new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/" + infura_apikey), - network_id: 4, - gas: 4500000 - }, - live: { - } - }, - solc: { - optimizer: { - enabled: true, - runs: 200 - } - }, - mocha: { - useColors: true - } -}; - -/* -module.exports = { - // See - // to customize your Truffle configuration! - networks: { - privateNode: { - host: '127.0.0.1', - port: 8501, - network_id: '*' - }, - ganache: { - host: "127.0.0.1", - port: 7545, - network_id: "*" - }, - ganache_cli: { - host: "127.0.0.1", - port: 8545, - network_id: "*" - } - } -}; -*/ \ No newline at end of file diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index 9280201..0000000 --- a/yarn.lock +++ /dev/null @@ -1,4835 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/helper-module-imports@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz#4c5c54be04bd31670a7382797d75b9fa2e5b5620" - integrity sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw== - dependencies: - "@babel/types" "^7.10.4" - -"@babel/helper-plugin-utils@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375" - integrity sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg== - -"@babel/helper-validator-identifier@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" - integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== - -"@babel/plugin-transform-runtime@^7.5.5": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.10.4.tgz#594fb53453ea1b6f0779cceb48ce0718a447feb7" - integrity sha512-8ULlGv8p+Vuxu+kz2Y1dk6MYS2b/Dki+NO6/0ZlfSj5tMalfDL7jI/o/2a+rrWLqSXvnadEqc2WguB4gdQIxZw== - dependencies: - "@babel/helper-module-imports" "^7.10.4" - "@babel/helper-plugin-utils" "^7.10.4" - resolve "^1.8.1" - semver "^5.5.1" - -"@babel/runtime@^7.5.5": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.10.4.tgz#a6724f1a6b8d2f6ea5236dbfe58c7d7ea9c5eb99" - integrity sha512-UpTN5yUJr9b4EX2CnGNWIvER7Ab83ibv0pcvvHc4UOdrBI5jb8bj+32cCwPX6xu0mt2daFNjYhoi+X7beH0RSw== - dependencies: - regenerator-runtime "^0.13.4" - -"@babel/types@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.10.4.tgz#369517188352e18219981efd156bfdb199fff1ee" - integrity sha512-UTCFOxC3FsFHb7lkRMVvgLzaRVamXuAs2Tz4wajva4WxtVY82eZeaUBtC2Zt95FU9TiznuC0Zk35tsim8jeVpg== - dependencies: - "@babel/helper-validator-identifier" "^7.10.4" - lodash "^4.17.13" - to-fast-properties "^2.0.0" - -"@ethersproject/abi@5.0.0-beta.153": - version "5.0.0-beta.153" - resolved "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.0.0-beta.153.tgz#43a37172b33794e4562999f6e2d555b7599a8eee" - integrity sha512-aXweZ1Z7vMNzJdLpR1CZUAIgnwjrZeUSvN9syCwlBaEBUFJmFY+HHnfuTI5vIhVs/mRkfJVrbEyl51JZQqyjAg== - dependencies: - "@ethersproject/address" ">=5.0.0-beta.128" - "@ethersproject/bignumber" ">=5.0.0-beta.130" - "@ethersproject/bytes" ">=5.0.0-beta.129" - "@ethersproject/constants" ">=5.0.0-beta.128" - "@ethersproject/hash" ">=5.0.0-beta.128" - "@ethersproject/keccak256" ">=5.0.0-beta.127" - "@ethersproject/logger" ">=5.0.0-beta.129" - "@ethersproject/properties" ">=5.0.0-beta.131" - "@ethersproject/strings" ">=5.0.0-beta.130" - -"@ethersproject/address@>=5.0.0-beta.128", "@ethersproject/address@^5.0.3": - version "5.0.3" - resolved "https://registry.npmjs.org/@ethersproject/address/-/address-5.0.3.tgz#86489f836d1656135fa6cae56d9fd1ab5b2c95af" - integrity sha512-LMmLxL1wTNtvwgm/eegcaxtG/W7vHXKzHGUkK9KZEI9W+SfHrpT7cGX+hBcatcUXPANjS3TmOaQ+mq5JU5sGTw== - dependencies: - "@ethersproject/bignumber" "^5.0.6" - "@ethersproject/bytes" "^5.0.4" - "@ethersproject/keccak256" "^5.0.3" - "@ethersproject/logger" "^5.0.5" - "@ethersproject/rlp" "^5.0.3" - bn.js "^4.4.0" - -"@ethersproject/bignumber@>=5.0.0-beta.130", "@ethersproject/bignumber@^5.0.6": - version "5.0.6" - resolved "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.0.6.tgz#1b5494a640c64096538e622b6ba8a5b8439ebde4" - integrity sha512-fLilYOSH3DJXBrimx7PwrJdY/zAI5MGp229Mvhtcur76Lgt4qNWu9HTiwMGHP01Tkm3YP5gweF83GrQrA2tYUA== - dependencies: - "@ethersproject/bytes" "^5.0.4" - "@ethersproject/logger" "^5.0.5" - bn.js "^4.4.0" - -"@ethersproject/bytes@>=5.0.0-beta.129", "@ethersproject/bytes@^5.0.4": - version "5.0.4" - resolved "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.0.4.tgz#328d9d929a3e970964ecf5d62e12568a187189f1" - integrity sha512-9R6A6l9JN8x1U4s1dJCR+9h3MZTT3xQofr/Xx8wbDvj6NnY4CbBB0o8ZgHXvR74yV90pY2EzCekpkMBJnRzkSw== - dependencies: - "@ethersproject/logger" "^5.0.5" - -"@ethersproject/constants@>=5.0.0-beta.128", "@ethersproject/constants@^5.0.3": - version "5.0.3" - resolved "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.0.3.tgz#7ccb8e2e9f14fbcc2d52d0e1402a83a5613a2f65" - integrity sha512-iN7KBrA0zNFybDyrkcAPOcyU3CHXYFMd+KM2Jr07Kjg+DVB5wPpEXsOdd/K1KWFsFtGfNdPZ7QP8siLtCePXrQ== - dependencies: - "@ethersproject/bignumber" "^5.0.6" - -"@ethersproject/hash@>=5.0.0-beta.128": - version "5.0.3" - resolved "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.0.3.tgz#41f17fd7972838831620338dad932bfe3d684209" - integrity sha512-KSnJyL0G9lxbOK0UPrUcaYTc/RidrX8c+kn7xnEpTmSGxqlndw4BzvQcRgYt31bOIwuFtwlWvOo6AN2tJgdQtA== - dependencies: - "@ethersproject/bytes" "^5.0.4" - "@ethersproject/keccak256" "^5.0.3" - "@ethersproject/logger" "^5.0.5" - "@ethersproject/strings" "^5.0.3" - -"@ethersproject/keccak256@>=5.0.0-beta.127", "@ethersproject/keccak256@^5.0.3": - version "5.0.3" - resolved "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.0.3.tgz#f094a8fca3bb913c044593c4f382be424292e588" - integrity sha512-VhW3mgZMBZlETV6AyOmjNeNG+Pg68igiKkPpat8/FZl0CKnfgQ+KZQZ/ee1vT+X0IUM8/djqnei6btmtbA27Ug== - dependencies: - "@ethersproject/bytes" "^5.0.4" - js-sha3 "0.5.7" - -"@ethersproject/logger@>=5.0.0-beta.129", "@ethersproject/logger@^5.0.5": - version "5.0.5" - resolved "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.0.5.tgz#e3ba3d0bcf9f5be4da5f043b1e328eb98b80002f" - integrity sha512-gJj72WGzQhUtCk6kfvI8elTaPOQyMvrMghp/nbz0ivTo39fZ7IjypFh/ySDeUSdBNplAwhzWKKejQhdpyefg/w== - -"@ethersproject/properties@>=5.0.0-beta.131", "@ethersproject/properties@^5.0.3": - version "5.0.3" - resolved "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.0.3.tgz#991aef39a5f87d4645cee76cec4df868bfb08be6" - integrity sha512-wLCSrbywkQgTO6tIF9ZdKsH9AIxPEqAJF/z5xcPkz1DK4mMAZgAXRNw1MrKYhyb+7CqNHbj3vxenNKFavGY/IA== - dependencies: - "@ethersproject/logger" "^5.0.5" - -"@ethersproject/rlp@^5.0.3": - version "5.0.3" - resolved "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.0.3.tgz#841a5edfdf725f92155fe74424f5510c9043c13a" - integrity sha512-Hz4yyA/ilGafASAqtTlLWkA/YqwhQmhbDAq2LSIp1AJNx+wtbKWFAKSckpeZ+WG/xZmT+fw5OFKK7a5IZ4DR5g== - dependencies: - "@ethersproject/bytes" "^5.0.4" - "@ethersproject/logger" "^5.0.5" - -"@ethersproject/signing-key@^5.0.4": - version "5.0.4" - resolved "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.0.4.tgz#a5334ce8a52d4e9736dc8fb6ecc384704ecf8783" - integrity sha512-I6pJoga1IvhtjYK5yXzCjs4ZpxrVbt9ZRAlpEw0SW9UuV020YfJH5EIVEGR2evdRceS3nAQIggqbsXSkP8Y1Dg== - dependencies: - "@ethersproject/bytes" "^5.0.4" - "@ethersproject/logger" "^5.0.5" - "@ethersproject/properties" "^5.0.3" - elliptic "6.5.3" - -"@ethersproject/strings@>=5.0.0-beta.130", "@ethersproject/strings@^5.0.3": - version "5.0.3" - resolved "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.0.3.tgz#756cc4b93203a091966d40824b0b28048e2d5d9b" - integrity sha512-8kEx3+Z6cMn581yh093qnaSa8H7XzmLn6g8YFDHUpzXM7+bvXvnL2ciHrJ+EbvaMQZpej6nNtl0nm7XF4PmQHA== - dependencies: - "@ethersproject/bytes" "^5.0.4" - "@ethersproject/constants" "^5.0.3" - "@ethersproject/logger" "^5.0.5" - -"@ethersproject/transactions@^5.0.0-beta.135": - version "5.0.3" - resolved "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.0.3.tgz#7cd82fa6d63043fb5cd561a8ed72df046a968430" - integrity sha512-cqsAAFUQV6iWqfgLL7KCPNfd3pXJPDdYtE6QuBEAIpc7cgbJ7TIDCF/dN+1otfERHJIbjGSNrhh4axKRnSFswg== - dependencies: - "@ethersproject/address" "^5.0.3" - "@ethersproject/bignumber" "^5.0.6" - "@ethersproject/bytes" "^5.0.4" - "@ethersproject/constants" "^5.0.3" - "@ethersproject/keccak256" "^5.0.3" - "@ethersproject/logger" "^5.0.5" - "@ethersproject/properties" "^5.0.3" - "@ethersproject/rlp" "^5.0.3" - "@ethersproject/signing-key" "^5.0.4" - -"@evolutionland/upgraeability-using-unstructured-storage@^0.1.1": - version "0.1.1" - resolved "https://registry.yarnpkg.com/@evolutionland/upgraeability-using-unstructured-storage/-/upgraeability-using-unstructured-storage-0.1.1.tgz#6dd8c6a2a048feb00e8d1bdafb471fda72ed940e" - integrity sha512-YmoEWnLsMhD3P348AsHcTtugKr67yDrDVfpj4tOetQlB25KiY/xbnBSZtWDKCRsreum84rTjp5YZ75avqW0CKg== - -"@sindresorhus/is@^0.14.0": - version "0.14.0" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" - integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== - -"@szmarczak/http-timer@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" - integrity sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA== - dependencies: - defer-to-connect "^1.0.1" - -"@truffle/hdwallet-provider@^1.0.23": - version "1.0.37" - resolved "https://registry.yarnpkg.com/@truffle/hdwallet-provider/-/hdwallet-provider-1.0.37.tgz#ff514ab0c17aea91505207b5faa23fe602333794" - integrity sha512-LPsMNaBxwpCpDrTgvMGvNtk4c/pDDpZ5AXLrugzK1lVT3SW/DCpjPDgcUckOCNNAx8ktG0PzJbiVFM6Ami92nQ== - dependencies: - "@trufflesuite/web3-provider-engine" "14.0.7" - any-promise "^1.3.0" - bindings "^1.5.0" - bip39 "^2.4.2" - ethereum-protocol "^1.0.1" - ethereumjs-tx "^1.0.0" - ethereumjs-util "^6.1.0" - ethereumjs-wallet "^0.6.3" - source-map-support "^0.5.19" - web3 "1.2.1" - -"@trufflesuite/web3-provider-engine@14.0.7": - version "14.0.7" - resolved "https://registry.yarnpkg.com/@trufflesuite/web3-provider-engine/-/web3-provider-engine-14.0.7.tgz#8ffa31148d68cfdd4da067e5df30e03871ec8a74" - integrity sha512-+OCKZOF1aVCOW9gWIXdK1l/SQnRPVcve56LpSGZQ+LZ6OKT6xVoLNNF+wKVvFxIis1JAZvnVKJFbUYbKEZ5aPQ== - dependencies: - async "^2.5.0" - backoff "^2.5.0" - clone "^2.0.0" - cross-fetch "^2.1.0" - eth-block-tracker "^4.2.0" - eth-json-rpc-filters "^4.0.2" - eth-json-rpc-infura "^3.1.0" - eth-json-rpc-middleware "^4.1.1" - eth-sig-util "^1.4.2" - ethereumjs-block "^1.2.2" - ethereumjs-tx "^1.2.0" - ethereumjs-util "^5.1.5" - ethereumjs-vm "^2.3.4" - json-rpc-error "^2.0.0" - json-stable-stringify "^1.0.1" - promise-to-callback "^1.0.0" - readable-stream "^2.2.9" - request "^2.85.0" - semaphore "^1.0.3" - ws "^5.1.1" - xhr "^2.2.0" - xtend "^4.0.1" - -"@types/bn.js@^4.11.3", "@types/bn.js@^4.11.5": - version "4.11.6" - resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.6.tgz#c306c70d9358aaea33cd4eda092a742b9505967c" - integrity sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg== - dependencies: - "@types/node" "*" - -"@types/node@*": - version "14.0.14" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.14.tgz#24a0b5959f16ac141aeb0c5b3cd7a15b7c64cbce" - integrity sha512-syUgf67ZQpaJj01/tRTknkMNoBBLWJOBODF0Zm4NrXmiSuxjymFrxnTu1QVYRubhVkRcZLYZG8STTwJRdVm/WQ== - -"@types/node@^10.3.2": - version "10.17.26" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.26.tgz#a8a119960bff16b823be4c617da028570779bcfd" - integrity sha512-myMwkO2Cr82kirHY8uknNRHEVtn0wV3DTQfkrjx17jmkstDRZ24gNUdl8AHXVyVclTYI/bNjgTPTAWvWLqXqkw== - -"@types/node@^12.12.6": - version "12.12.54" - resolved "https://registry.npmjs.org/@types/node/-/node-12.12.54.tgz#a4b58d8df3a4677b6c08bfbc94b7ad7a7a5f82d1" - integrity sha512-ge4xZ3vSBornVYlDnk7yZ0gK6ChHf/CHB7Gl1I0Jhah8DDnEQqBzgohYG4FX4p81TNirSETOiSyn+y1r9/IR6w== - -abstract-leveldown@~2.6.0: - version "2.6.3" - resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-2.6.3.tgz#1c5e8c6a5ef965ae8c35dfb3a8770c476b82c4b8" - integrity sha512-2++wDf/DYqkPR3o5tbfdhF96EfMApo1GpPfzOsR/ZYXdkSmELlvOOEAl9iKkRsktMPHdGjO4rtkBpf2I7TiTeA== - dependencies: - xtend "~4.0.0" - -abstract-leveldown@~2.7.1: - version "2.7.2" - resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-2.7.2.tgz#87a44d7ebebc341d59665204834c8b7e0932cc93" - integrity sha512-+OVvxH2rHVEhWLdbudP6p0+dNMXu8JA1CbhP19T8paTYAcX7oJ4OVjT+ZUVpv7mITxXHqDMej+GdqXBmXkw09w== - dependencies: - xtend "~4.0.0" - -accepts@~1.3.7: - version "1.3.7" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" - integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA== - dependencies: - mime-types "~2.1.24" - negotiator "0.6.2" - -aes-js@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" - integrity sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0= - -aes-js@^3.1.1: - version "3.1.2" - resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.1.2.tgz#db9aabde85d5caabbfc0d4f2a4446960f627146a" - integrity sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ== - -ajv@^6.5.5: - version "6.12.3" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.3.tgz#18c5af38a111ddeb4f2697bd78d68abc1cabd706" - integrity sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= - -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4= - -any-promise@1.3.0, any-promise@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" - integrity sha1-q8av7tzqUugJzcA3au0845Y10X8= - -array-flatten@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" - integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI= - -asn1.js@^4.0.0: - version "4.10.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.10.1.tgz#b9c2bf5805f1e64aadeed6df3a2bfafb5a73f5a0" - integrity sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw== - dependencies: - bn.js "^4.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - -asn1@~0.2.3: - version "0.2.4" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" - integrity sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg== - dependencies: - safer-buffer "~2.1.0" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= - -async-eventemitter@^0.2.2: - version "0.2.4" - resolved "https://registry.yarnpkg.com/async-eventemitter/-/async-eventemitter-0.2.4.tgz#f5e7c8ca7d3e46aab9ec40a292baf686a0bafaca" - integrity sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw== - dependencies: - async "^2.4.0" - -async-limiter@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" - integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== - -async@^1.4.2: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" - integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= - -async@^2.0.1, async@^2.1.2, async@^2.4.0, async@^2.5.0: - version "2.6.3" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" - integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== - dependencies: - lodash "^4.17.14" - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= - -await-semaphore@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/await-semaphore/-/await-semaphore-0.1.3.tgz#2b88018cc8c28e06167ae1cdff02504f1f9688d3" - integrity sha512-d1W2aNSYcz/sxYO4pMGX9vq65qOTu0P800epMud+6cYYX0QcT7zyqcxec3VWzpgvdXo57UWmVbZpLMjX2m1I7Q== - -aws-sign2@~0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" - integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= - -aws4@^1.8.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.0.tgz#a17b3a8ea811060e74d47d306122400ad4497ae2" - integrity sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA== - -babel-code-frame@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" - integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s= - dependencies: - chalk "^1.1.3" - esutils "^2.0.2" - js-tokens "^3.0.2" - -babel-core@^6.0.14, babel-core@^6.26.0: - version "6.26.3" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.3.tgz#b2e2f09e342d0f0c88e2f02e067794125e75c207" - integrity sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA== - dependencies: - babel-code-frame "^6.26.0" - babel-generator "^6.26.0" - babel-helpers "^6.24.1" - babel-messages "^6.23.0" - babel-register "^6.26.0" - babel-runtime "^6.26.0" - babel-template "^6.26.0" - babel-traverse "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - convert-source-map "^1.5.1" - debug "^2.6.9" - json5 "^0.5.1" - lodash "^4.17.4" - minimatch "^3.0.4" - path-is-absolute "^1.0.1" - private "^0.1.8" - slash "^1.0.0" - source-map "^0.5.7" - -babel-generator@^6.26.0: - version "6.26.1" - resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90" - integrity sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA== - dependencies: - babel-messages "^6.23.0" - babel-runtime "^6.26.0" - babel-types "^6.26.0" - detect-indent "^4.0.0" - jsesc "^1.3.0" - lodash "^4.17.4" - source-map "^0.5.7" - trim-right "^1.0.1" - -babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" - integrity sha1-zORReto1b0IgvK6KAsKzRvmlZmQ= - dependencies: - babel-helper-explode-assignable-expression "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-call-delegate@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" - integrity sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340= - dependencies: - babel-helper-hoist-variables "^6.24.1" - babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-define-map@^6.24.1: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz#a5f56dab41a25f97ecb498c7ebaca9819f95be5f" - integrity sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8= - dependencies: - babel-helper-function-name "^6.24.1" - babel-runtime "^6.26.0" - babel-types "^6.26.0" - lodash "^4.17.4" - -babel-helper-explode-assignable-expression@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" - integrity sha1-8luCz33BBDPFX3BZLVdGQArCLKo= - dependencies: - babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-function-name@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" - integrity sha1-00dbjAPtmCQqJbSDUasYOZ01gKk= - dependencies: - babel-helper-get-function-arity "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-get-function-arity@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" - integrity sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-hoist-variables@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" - integrity sha1-HssnaJydJVE+rbyZFKc/VAi+enY= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-optimise-call-expression@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" - integrity sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-regex@^6.24.1: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz#325c59f902f82f24b74faceed0363954f6495e72" - integrity sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI= - dependencies: - babel-runtime "^6.26.0" - babel-types "^6.26.0" - lodash "^4.17.4" - -babel-helper-remap-async-to-generator@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" - integrity sha1-XsWBgnrXI/7N04HxySg5BnbkVRs= - dependencies: - babel-helper-function-name "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-replace-supers@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" - integrity sha1-v22/5Dk40XNpohPKiov3S2qQqxo= - dependencies: - babel-helper-optimise-call-expression "^6.24.1" - babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helpers@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" - integrity sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI= - dependencies: - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-messages@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" - integrity sha1-8830cDhYA1sqKVHG7F7fbGLyYw4= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-check-es2015-constants@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" - integrity sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-syntax-async-functions@^6.8.0: - version "6.13.0" - resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" - integrity sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU= - -babel-plugin-syntax-exponentiation-operator@^6.8.0: - version "6.13.0" - resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" - integrity sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4= - -babel-plugin-syntax-trailing-function-commas@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" - integrity sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM= - -babel-plugin-transform-async-to-generator@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" - integrity sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E= - dependencies: - babel-helper-remap-async-to-generator "^6.24.1" - babel-plugin-syntax-async-functions "^6.8.0" - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-arrow-functions@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" - integrity sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz#bbc51b49f964d70cb8d8e0b94e820246ce3a6141" - integrity sha1-u8UbSflk1wy42OC5ToICRs46YUE= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-block-scoping@^6.23.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz#d70f5299c1308d05c12f463813b0a09e73b1895f" - integrity sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8= - dependencies: - babel-runtime "^6.26.0" - babel-template "^6.26.0" - babel-traverse "^6.26.0" - babel-types "^6.26.0" - lodash "^4.17.4" - -babel-plugin-transform-es2015-classes@^6.23.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" - integrity sha1-WkxYpQyclGHlZLSyo7+ryXolhNs= - dependencies: - babel-helper-define-map "^6.24.1" - babel-helper-function-name "^6.24.1" - babel-helper-optimise-call-expression "^6.24.1" - babel-helper-replace-supers "^6.24.1" - babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-computed-properties@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" - integrity sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM= - dependencies: - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-destructuring@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" - integrity sha1-mXux8auWf2gtKwh2/jWNYOdlxW0= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-duplicate-keys@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" - integrity sha1-c+s9MQypaePvnskcU3QabxV2Qj4= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-for-of@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" - integrity sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-function-name@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" - integrity sha1-g0yJhTvDaxrw86TF26qU/Y6sqos= - dependencies: - babel-helper-function-name "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-literals@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz#4f54a02d6cd66cf915280019a31d31925377ca2e" - integrity sha1-T1SgLWzWbPkVKAAZox0xklN3yi4= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-modules-amd@^6.22.0, babel-plugin-transform-es2015-modules-amd@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" - integrity sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ= - dependencies: - babel-plugin-transform-es2015-modules-commonjs "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-es2015-modules-commonjs@^6.24.1: - version "6.26.2" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz#58a793863a9e7ca870bdc5a881117ffac27db6f3" - integrity sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q== - dependencies: - babel-plugin-transform-strict-mode "^6.24.1" - babel-runtime "^6.26.0" - babel-template "^6.26.0" - babel-types "^6.26.0" - -babel-plugin-transform-es2015-modules-systemjs@^6.23.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" - integrity sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM= - dependencies: - babel-helper-hoist-variables "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-modules-umd@^6.23.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" - integrity sha1-rJl+YoXNGO1hdq22B9YCNErThGg= - dependencies: - babel-plugin-transform-es2015-modules-amd "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-object-super@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" - integrity sha1-JM72muIcuDp/hgPa0CH1cusnj40= - dependencies: - babel-helper-replace-supers "^6.24.1" - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-parameters@^6.23.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" - integrity sha1-V6w1GrScrxSpfNE7CfZv3wpiXys= - dependencies: - babel-helper-call-delegate "^6.24.1" - babel-helper-get-function-arity "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-shorthand-properties@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" - integrity sha1-JPh11nIch2YbvZmkYi5R8U3jiqA= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-spread@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz#d6d68a99f89aedc4536c81a542e8dd9f1746f8d1" - integrity sha1-1taKmfia7cRTbIGlQujdnxdG+NE= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-sticky-regex@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" - integrity sha1-AMHNsaynERLN8M9hJsLta0V8zbw= - dependencies: - babel-helper-regex "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-template-literals@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz#a84b3450f7e9f8f1f6839d6d687da84bb1236d8d" - integrity sha1-qEs0UPfp+PH2g51taH2oS7EjbY0= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-typeof-symbol@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" - integrity sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-unicode-regex@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" - integrity sha1-04sS9C6nMj9yk4fxinxa4frrNek= - dependencies: - babel-helper-regex "^6.24.1" - babel-runtime "^6.22.0" - regexpu-core "^2.0.0" - -babel-plugin-transform-exponentiation-operator@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" - integrity sha1-KrDJx/MJj6SJB3cruBP+QejeOg4= - dependencies: - babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" - babel-plugin-syntax-exponentiation-operator "^6.8.0" - babel-runtime "^6.22.0" - -babel-plugin-transform-regenerator@^6.22.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f" - integrity sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8= - dependencies: - regenerator-transform "^0.10.0" - -babel-plugin-transform-strict-mode@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" - integrity sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-preset-env@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.7.0.tgz#dea79fa4ebeb883cd35dab07e260c1c9c04df77a" - integrity sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg== - dependencies: - babel-plugin-check-es2015-constants "^6.22.0" - babel-plugin-syntax-trailing-function-commas "^6.22.0" - babel-plugin-transform-async-to-generator "^6.22.0" - babel-plugin-transform-es2015-arrow-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoping "^6.23.0" - babel-plugin-transform-es2015-classes "^6.23.0" - babel-plugin-transform-es2015-computed-properties "^6.22.0" - babel-plugin-transform-es2015-destructuring "^6.23.0" - babel-plugin-transform-es2015-duplicate-keys "^6.22.0" - babel-plugin-transform-es2015-for-of "^6.23.0" - babel-plugin-transform-es2015-function-name "^6.22.0" - babel-plugin-transform-es2015-literals "^6.22.0" - babel-plugin-transform-es2015-modules-amd "^6.22.0" - babel-plugin-transform-es2015-modules-commonjs "^6.23.0" - babel-plugin-transform-es2015-modules-systemjs "^6.23.0" - babel-plugin-transform-es2015-modules-umd "^6.23.0" - babel-plugin-transform-es2015-object-super "^6.22.0" - babel-plugin-transform-es2015-parameters "^6.23.0" - babel-plugin-transform-es2015-shorthand-properties "^6.22.0" - babel-plugin-transform-es2015-spread "^6.22.0" - babel-plugin-transform-es2015-sticky-regex "^6.22.0" - babel-plugin-transform-es2015-template-literals "^6.22.0" - babel-plugin-transform-es2015-typeof-symbol "^6.23.0" - babel-plugin-transform-es2015-unicode-regex "^6.22.0" - babel-plugin-transform-exponentiation-operator "^6.22.0" - babel-plugin-transform-regenerator "^6.22.0" - browserslist "^3.2.6" - invariant "^2.2.2" - semver "^5.3.0" - -babel-register@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" - integrity sha1-btAhFz4vy0htestFxgCahW9kcHE= - dependencies: - babel-core "^6.26.0" - babel-runtime "^6.26.0" - core-js "^2.5.0" - home-or-tmp "^2.0.0" - lodash "^4.17.4" - mkdirp "^0.5.1" - source-map-support "^0.4.15" - -babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" - integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.11.0" - -babel-template@^6.24.1, babel-template@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" - integrity sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI= - dependencies: - babel-runtime "^6.26.0" - babel-traverse "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - lodash "^4.17.4" - -babel-traverse@^6.24.1, babel-traverse@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" - integrity sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4= - dependencies: - babel-code-frame "^6.26.0" - babel-messages "^6.23.0" - babel-runtime "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - debug "^2.6.8" - globals "^9.18.0" - invariant "^2.2.2" - lodash "^4.17.4" - -babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" - integrity sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc= - dependencies: - babel-runtime "^6.26.0" - esutils "^2.0.2" - lodash "^4.17.4" - to-fast-properties "^1.0.3" - -babelify@^7.3.0: - version "7.3.0" - resolved "https://registry.yarnpkg.com/babelify/-/babelify-7.3.0.tgz#aa56aede7067fd7bd549666ee16dc285087e88e5" - integrity sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU= - dependencies: - babel-core "^6.0.14" - object-assign "^4.0.0" - -babylon@^6.18.0: - version "6.18.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" - integrity sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ== - -backoff@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/backoff/-/backoff-2.5.0.tgz#f616eda9d3e4b66b8ca7fca79f695722c5f8e26f" - integrity sha1-9hbtqdPktmuMp/ynn2lXIsX44m8= - dependencies: - precond "0.2" - -balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= - -base-x@^3.0.2, base-x@^3.0.8: - version "3.0.8" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.8.tgz#1e1106c2537f0162e8b52474a557ebb09000018d" - integrity sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA== - dependencies: - safe-buffer "^5.0.1" - -base64-js@^1.0.2: - version "1.3.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1" - integrity sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g== - -bcrypt-pbkdf@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" - integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4= - dependencies: - tweetnacl "^0.14.3" - -bignumber.js@^9.0.0: - version "9.0.0" - resolved "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz#805880f84a329b5eac6e7cb6f8274b6d82bdf075" - integrity sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A== - -bindings@^1.2.1, bindings@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" - integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== - dependencies: - file-uri-to-path "1.0.0" - -bip39@^2.4.2: - version "2.6.0" - resolved "https://registry.yarnpkg.com/bip39/-/bip39-2.6.0.tgz#9e3a720b42ec8b3fbe4038f1e445317b6a99321c" - integrity sha512-RrnQRG2EgEoqO24ea+Q/fftuPUZLmrEM3qNhhGsA3PbaXaCW791LTzPuVyx/VprXQcTbPJ3K3UeTna8ZnVl2sg== - dependencies: - create-hash "^1.1.0" - pbkdf2 "^3.0.9" - randombytes "^2.0.1" - safe-buffer "^5.0.1" - unorm "^1.3.3" - -bip66@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/bip66/-/bip66-1.1.5.tgz#01fa8748785ca70955d5011217d1b3139969ca22" - integrity sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI= - dependencies: - safe-buffer "^5.0.1" - -bl@^1.0.0: - version "1.2.2" - resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c" - integrity sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA== - dependencies: - readable-stream "^2.3.5" - safe-buffer "^5.1.1" - -bluebird@^3.5.0: - version "3.7.2" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" - integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== - -bn.js@4.11.6: - version "4.11.6" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" - integrity sha1-UzRK2xRhehP26N0s4okF0cC6MhU= - -bn.js@4.11.8: - version "4.11.8" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" - integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== - -bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.0, bn.js@^4.11.1, bn.js@^4.11.6, bn.js@^4.11.8, bn.js@^4.11.9, bn.js@^4.4.0: - version "4.11.9" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828" - integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw== - -bn.js@^5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.2.tgz#c9686902d3c9a27729f43ab10f9d79c2004da7b0" - integrity sha512-40rZaf3bUNKTVYu9sIeeEGOg7g14Yvnj9kH7b50EiwX0Q7A6umbvfI5tvHaOERH0XigqKkfLkFQxzb4e6CIXnA== - -body-parser@1.19.0, body-parser@^1.16.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" - integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw== - dependencies: - bytes "3.1.0" - content-type "~1.0.4" - debug "2.6.9" - depd "~1.1.2" - http-errors "1.7.2" - iconv-lite "0.4.24" - on-finished "~2.3.0" - qs "6.7.0" - raw-body "2.4.0" - type-is "~1.6.17" - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -brorand@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" - integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= - -browserify-aes@^1.0.0, browserify-aes@^1.0.4, browserify-aes@^1.0.6: - version "1.2.0" - resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" - integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== - dependencies: - buffer-xor "^1.0.3" - cipher-base "^1.0.0" - create-hash "^1.1.0" - evp_bytestokey "^1.0.3" - inherits "^2.0.1" - safe-buffer "^5.0.1" - -browserify-cipher@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" - integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== - dependencies: - browserify-aes "^1.0.4" - browserify-des "^1.0.0" - evp_bytestokey "^1.0.0" - -browserify-des@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.2.tgz#3af4f1f59839403572f1c66204375f7a7f703e9c" - integrity sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A== - dependencies: - cipher-base "^1.0.1" - des.js "^1.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.0.1.tgz#21e0abfaf6f2029cf2fafb133567a701d4135524" - integrity sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ= - dependencies: - bn.js "^4.1.0" - randombytes "^2.0.1" - -browserify-sign@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.2.0.tgz#545d0b1b07e6b2c99211082bf1b12cce7a0b0e11" - integrity sha512-hEZC1KEeYuoHRqhGhTy6gWrpJA3ZDjFWv0DE61643ZnOXAKJb3u7yWcrU0mMc9SwAqK1n7myPGndkp0dFG7NFA== - dependencies: - bn.js "^5.1.1" - browserify-rsa "^4.0.1" - create-hash "^1.2.0" - create-hmac "^1.1.7" - elliptic "^6.5.2" - inherits "^2.0.4" - parse-asn1 "^5.1.5" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -browserslist@^3.2.6: - version "3.2.8" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.8.tgz#b0005361d6471f0f5952797a76fc985f1f978fc6" - integrity sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ== - dependencies: - caniuse-lite "^1.0.30000844" - electron-to-chromium "^1.3.47" - -bs58@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" - integrity sha1-vhYedsNU9veIrkBx9j806MTwpCo= - dependencies: - base-x "^3.0.2" - -bs58check@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" - integrity sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA== - dependencies: - bs58 "^4.0.0" - create-hash "^1.1.0" - safe-buffer "^5.1.2" - -btoa@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/btoa/-/btoa-1.2.1.tgz#01a9909f8b2c93f6bf680ba26131eb30f7fa3d73" - integrity sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g== - -buffer-alloc-unsafe@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" - integrity sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg== - -buffer-alloc@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/buffer-alloc/-/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec" - integrity sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow== - dependencies: - buffer-alloc-unsafe "^1.1.0" - buffer-fill "^1.0.0" - -buffer-crc32@~0.2.3: - version "0.2.13" - resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" - integrity sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI= - -buffer-fill@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" - integrity sha1-+PeLdniYiO858gXNY39o5wISKyw= - -buffer-from@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" - integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== - -buffer-to-arraybuffer@^0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz#6064a40fa76eb43c723aba9ef8f6e1216d10511a" - integrity sha1-YGSkD6dutDxyOrqe+PbhIW0QURo= - -buffer-xor@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" - integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= - -buffer@^5.0.5, buffer@^5.2.1, buffer@^5.5.0, buffer@^5.6.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.6.0.tgz#a31749dc7d81d84db08abf937b6b8c4033f62786" - integrity sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw== - dependencies: - base64-js "^1.0.2" - ieee754 "^1.1.4" - -bufferutil@^4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.1.tgz#3a177e8e5819a1243fe16b63a199951a7ad8d4a7" - integrity sha512-xowrxvpxojqkagPcWRQVXZl0YXhRhAtBEIq3VoER1NH5Mw1n1o0ojdspp+GS2J//2gCVyrzQDApQ4unGF+QOoA== - dependencies: - node-gyp-build "~3.7.0" - -bytes@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" - integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== - -cacheable-request@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912" - integrity sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg== - dependencies: - clone-response "^1.0.2" - get-stream "^5.1.0" - http-cache-semantics "^4.0.0" - keyv "^3.0.0" - lowercase-keys "^2.0.0" - normalize-url "^4.1.0" - responselike "^1.0.2" - -caniuse-lite@^1.0.30000844: - version "1.0.30001094" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001094.tgz#0b11d02e1cdc201348dbd8e3e57bd9b6ce82b175" - integrity sha512-ufHZNtMaDEuRBpTbqD93tIQnngmJ+oBknjvr0IbFympSdtFpAUFmNv4mVKbb53qltxFx0nK3iy32S9AqkLzUNA== - -caseless@~0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" - integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= - -chalk@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg= - dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" - -checkpoint-store@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/checkpoint-store/-/checkpoint-store-1.1.0.tgz#04e4cb516b91433893581e6d4601a78e9552ea06" - integrity sha1-BOTLUWuRQziTWB5tRgGnjpVS6gY= - dependencies: - functional-red-black-tree "^1.0.1" - -chownr@^1.1.1: - version "1.1.4" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" - integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== - -cids@^0.7.1: - version "0.7.5" - resolved "https://registry.npmjs.org/cids/-/cids-0.7.5.tgz#60a08138a99bfb69b6be4ceb63bfef7a396b28b2" - integrity sha512-zT7mPeghoWAu+ppn8+BS1tQ5qGmbMfB4AregnQjA/qHY3GC1m1ptI9GkWNlgeu38r7CuRdXB47uY2XgAYt6QVA== - dependencies: - buffer "^5.5.0" - class-is "^1.1.0" - multibase "~0.6.0" - multicodec "^1.0.0" - multihashes "~0.4.15" - -cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" - integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -class-is@^1.1.0: - version "1.1.0" - resolved "https://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz#9d3c0fba0440d211d843cec3dedfa48055005825" - integrity sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw== - -clone-response@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b" - integrity sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws= - dependencies: - mimic-response "^1.0.0" - -clone@^2.0.0, clone@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" - integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= - -combined-stream@^1.0.6, combined-stream@~1.0.6: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -commander@~2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.8.1.tgz#06be367febfda0c330aa1e2a072d3dc9762425d4" - integrity sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ= - dependencies: - graceful-readlink ">= 1.0.0" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -concat-stream@^1.5.1: - version "1.6.2" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" - integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== - dependencies: - buffer-from "^1.0.0" - inherits "^2.0.3" - readable-stream "^2.2.2" - typedarray "^0.0.6" - -content-disposition@0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd" - integrity sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g== - dependencies: - safe-buffer "5.1.2" - -content-hash@^2.5.2: - version "2.5.2" - resolved "https://registry.npmjs.org/content-hash/-/content-hash-2.5.2.tgz#bbc2655e7c21f14fd3bfc7b7d4bfe6e454c9e211" - integrity sha512-FvIQKy0S1JaWV10sMsA7TRx8bpU+pqPkhbsfvOJAdjRXvYxEckAwQWGwtRjiaJfh+E0DvcWUGqcdjwMGFjsSdw== - dependencies: - cids "^0.7.1" - multicodec "^0.5.5" - multihashes "^0.4.15" - -content-type@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" - integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== - -convert-source-map@^1.5.1: - version "1.7.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442" - integrity sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA== - dependencies: - safe-buffer "~5.1.1" - -cookie-signature@1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" - integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw= - -cookie@0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" - integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== - -cookiejar@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c" - integrity sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA== - -core-js@^2.4.0, core-js@^2.5.0: - version "2.6.11" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.11.tgz#38831469f9922bded8ee21c9dc46985e0399308c" - integrity sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg== - -core-util-is@1.0.2, core-util-is@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= - -cors@^2.8.1: - version "2.8.5" - resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" - integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== - dependencies: - object-assign "^4" - vary "^1" - -create-ecdh@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.3.tgz#c9111b6f33045c4697f144787f9254cdc77c45ff" - integrity sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw== - dependencies: - bn.js "^4.1.0" - elliptic "^6.0.0" - -create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" - integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== - dependencies: - cipher-base "^1.0.1" - inherits "^2.0.1" - md5.js "^1.3.4" - ripemd160 "^2.0.1" - sha.js "^2.4.0" - -create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" - integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== - dependencies: - cipher-base "^1.0.3" - create-hash "^1.1.0" - inherits "^2.0.1" - ripemd160 "^2.0.0" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -cross-fetch@^2.1.0, cross-fetch@^2.1.1: - version "2.2.3" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-2.2.3.tgz#e8a0b3c54598136e037f8650f8e823ccdfac198e" - integrity sha512-PrWWNH3yL2NYIb/7WF/5vFG3DCQiXDOVf8k3ijatbrtnwNuhMWLC7YF7uqf53tbTFDzHIUD8oITw4Bxt8ST3Nw== - dependencies: - node-fetch "2.1.2" - whatwg-fetch "2.0.4" - -crypto-browserify@3.12.0: - version "3.12.0" - resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" - integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== - dependencies: - browserify-cipher "^1.0.0" - browserify-sign "^4.0.0" - create-ecdh "^4.0.0" - create-hash "^1.1.0" - create-hmac "^1.1.0" - diffie-hellman "^5.0.0" - inherits "^2.0.1" - pbkdf2 "^3.0.3" - public-encrypt "^4.0.0" - randombytes "^2.0.0" - randomfill "^1.0.3" - -d@1, d@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a" - integrity sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA== - dependencies: - es5-ext "^0.10.50" - type "^1.0.1" - -dashdash@^1.12.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" - integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= - dependencies: - assert-plus "^1.0.0" - -debug@2.6.9, debug@^2.2.0, debug@^2.6.8, debug@^2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - -decode-uri-component@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" - integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= - -decompress-response@^3.2.0, decompress-response@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" - integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M= - dependencies: - mimic-response "^1.0.0" - -decompress-tar@^4.0.0, decompress-tar@^4.1.0, decompress-tar@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/decompress-tar/-/decompress-tar-4.1.1.tgz#718cbd3fcb16209716e70a26b84e7ba4592e5af1" - integrity sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ== - dependencies: - file-type "^5.2.0" - is-stream "^1.1.0" - tar-stream "^1.5.2" - -decompress-tarbz2@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz#3082a5b880ea4043816349f378b56c516be1a39b" - integrity sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A== - dependencies: - decompress-tar "^4.1.0" - file-type "^6.1.0" - is-stream "^1.1.0" - seek-bzip "^1.0.5" - unbzip2-stream "^1.0.9" - -decompress-targz@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/decompress-targz/-/decompress-targz-4.1.1.tgz#c09bc35c4d11f3de09f2d2da53e9de23e7ce1eee" - integrity sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w== - dependencies: - decompress-tar "^4.1.1" - file-type "^5.2.0" - is-stream "^1.1.0" - -decompress-unzip@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/decompress-unzip/-/decompress-unzip-4.0.1.tgz#deaaccdfd14aeaf85578f733ae8210f9b4848f69" - integrity sha1-3qrM39FK6vhVePczroIQ+bSEj2k= - dependencies: - file-type "^3.8.0" - get-stream "^2.2.0" - pify "^2.3.0" - yauzl "^2.4.2" - -decompress@^4.0.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/decompress/-/decompress-4.2.1.tgz#007f55cc6a62c055afa37c07eb6a4ee1b773f118" - integrity sha512-e48kc2IjU+2Zw8cTb6VZcJQ3lgVbS4uuB1TfCHbiZIP/haNXm+SVyhu+87jts5/3ROpd82GSVCoNs/z8l4ZOaQ== - dependencies: - decompress-tar "^4.0.0" - decompress-tarbz2 "^4.0.0" - decompress-targz "^4.0.0" - decompress-unzip "^4.0.1" - graceful-fs "^4.1.10" - make-dir "^1.0.0" - pify "^2.3.0" - strip-dirs "^2.0.0" - -deep-equal@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a" - integrity sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g== - dependencies: - is-arguments "^1.0.4" - is-date-object "^1.0.1" - is-regex "^1.0.4" - object-is "^1.0.1" - object-keys "^1.1.1" - regexp.prototype.flags "^1.2.0" - -defer-to-connect@^1.0.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" - integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== - -deferred-leveldown@~1.2.1: - version "1.2.2" - resolved "https://registry.yarnpkg.com/deferred-leveldown/-/deferred-leveldown-1.2.2.tgz#3acd2e0b75d1669924bc0a4b642851131173e1eb" - integrity sha512-uukrWD2bguRtXilKt6cAWKyoXrTSMo5m7crUdLfWQmu8kIm88w3QZoUL+6nhpfKVmhHANER6Re3sKoNoZ3IKMA== - dependencies: - abstract-leveldown "~2.6.0" - -define-properties@^1.1.2, define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== - dependencies: - object-keys "^1.0.12" - -defined@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" - integrity sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM= - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= - -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= - -des.js@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" - integrity sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA== - dependencies: - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - -destroy@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" - integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= - -detect-indent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" - integrity sha1-920GQ1LN9Docts5hnE7jqUdd4gg= - dependencies: - repeating "^2.0.0" - -diffie-hellman@^5.0.0: - version "5.0.3" - resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" - integrity sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg== - dependencies: - bn.js "^4.1.0" - miller-rabin "^4.0.0" - randombytes "^2.0.0" - -dom-walk@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84" - integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w== - -dotignore@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/dotignore/-/dotignore-0.1.2.tgz#f942f2200d28c3a76fbdd6f0ee9f3257c8a2e905" - integrity sha512-UGGGWfSauusaVJC+8fgV+NVvBXkCTmVv7sk6nojDZZvuOUNGUy0Zk4UpHQD6EDjS0jpBwcACvH4eofvyzBcRDw== - dependencies: - minimatch "^3.0.4" - -drbg.js@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/drbg.js/-/drbg.js-1.0.1.tgz#3e36b6c42b37043823cdbc332d58f31e2445480b" - integrity sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs= - dependencies: - browserify-aes "^1.0.6" - create-hash "^1.1.2" - create-hmac "^1.1.4" - -duplexer3@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" - integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= - -ecc-jsbn@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" - integrity sha1-OoOpBOVDUyh4dMVkt1SThoSamMk= - dependencies: - jsbn "~0.1.0" - safer-buffer "^2.1.0" - -ee-first@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" - integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= - -electron-to-chromium@^1.3.47: - version "1.3.488" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.488.tgz#9226229f5fbc825959210e81e0bb3e63035d1c06" - integrity sha512-NReBdOugu1yl8ly+0VDtiQ6Yw/1sLjnvflWq0gvY1nfUXU2PbA+1XAVuEb7ModnwL/MfUPjby7e4pAFnSHiy6Q== - -elliptic@6.3.3: - version "6.3.3" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.3.3.tgz#5482d9646d54bcb89fd7d994fc9e2e9568876e3f" - integrity sha1-VILZZG1UvLif19mU/J4ulWiHbj8= - dependencies: - bn.js "^4.4.0" - brorand "^1.0.1" - hash.js "^1.0.0" - inherits "^2.0.1" - -elliptic@6.5.3, elliptic@^6.0.0, elliptic@^6.4.0, elliptic@^6.5.2: - version "6.5.3" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6" - integrity sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw== - dependencies: - bn.js "^4.4.0" - brorand "^1.0.1" - hash.js "^1.0.0" - hmac-drbg "^1.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.0" - -encodeurl@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" - integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= - -encoding@^0.1.11: - version "0.1.12" - resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" - integrity sha1-U4tm8+5izRq1HsMjgp0flIDHS+s= - dependencies: - iconv-lite "~0.4.13" - -end-of-stream@^1.0.0, end-of-stream@^1.1.0: - version "1.4.4" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" - integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== - dependencies: - once "^1.4.0" - -errno@~0.1.1: - version "0.1.7" - resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.7.tgz#4684d71779ad39af177e3f007996f7c67c852618" - integrity sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg== - dependencies: - prr "~1.0.1" - -es-abstract@^1.17.0-next.1, es-abstract@^1.17.5: - version "1.17.6" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.6.tgz#9142071707857b2cacc7b89ecb670316c3e2d52a" - integrity sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw== - dependencies: - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - is-callable "^1.2.0" - is-regex "^1.1.0" - object-inspect "^1.7.0" - object-keys "^1.1.1" - object.assign "^4.1.0" - string.prototype.trimend "^1.0.1" - string.prototype.trimstart "^1.0.1" - -es-to-primitive@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" - integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== - dependencies: - is-callable "^1.1.4" - is-date-object "^1.0.1" - is-symbol "^1.0.2" - -es5-ext@^0.10.35, es5-ext@^0.10.50: - version "0.10.53" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.53.tgz#93c5a3acfdbef275220ad72644ad02ee18368de1" - integrity sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q== - dependencies: - es6-iterator "~2.0.3" - es6-symbol "~3.1.3" - next-tick "~1.0.0" - -es6-iterator@~2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" - integrity sha1-p96IkUGgWpSwhUQDstCg+/qY87c= - dependencies: - d "1" - es5-ext "^0.10.35" - es6-symbol "^3.1.1" - -es6-symbol@^3.1.1, es6-symbol@~3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.3.tgz#bad5d3c1bcdac28269f4cb331e431c78ac705d18" - integrity sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA== - dependencies: - d "^1.0.1" - ext "^1.1.2" - -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= - -escape-string-regexp@^1.0.2: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - -etag@~1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" - integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= - -eth-block-tracker@^4.2.0: - version "4.4.3" - resolved "https://registry.yarnpkg.com/eth-block-tracker/-/eth-block-tracker-4.4.3.tgz#766a0a0eb4a52c867a28328e9ae21353812cf626" - integrity sha512-A8tG4Z4iNg4mw5tP1Vung9N9IjgMNqpiMoJ/FouSFwNCGHv2X0mmOYwtQOJzki6XN7r7Tyo01S29p7b224I4jw== - dependencies: - "@babel/plugin-transform-runtime" "^7.5.5" - "@babel/runtime" "^7.5.5" - eth-query "^2.1.0" - json-rpc-random-id "^1.0.1" - pify "^3.0.0" - safe-event-emitter "^1.0.1" - -eth-ens-namehash@2.0.8: - version "2.0.8" - resolved "https://registry.yarnpkg.com/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz#229ac46eca86d52e0c991e7cb2aef83ff0f68bcf" - integrity sha1-IprEbsqG1S4MmR58sq74P/D2i88= - dependencies: - idna-uts46-hx "^2.3.1" - js-sha3 "^0.5.7" - -eth-json-rpc-errors@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/eth-json-rpc-errors/-/eth-json-rpc-errors-1.1.1.tgz#148377ef55155585981c21ff574a8937f9d6991f" - integrity sha512-WT5shJ5KfNqHi9jOZD+ID8I1kuYWNrigtZat7GOQkvwo99f8SzAVaEcWhJUv656WiZOAg3P1RiJQANtUmDmbIg== - dependencies: - fast-safe-stringify "^2.0.6" - -eth-json-rpc-errors@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/eth-json-rpc-errors/-/eth-json-rpc-errors-2.0.2.tgz#c1965de0301fe941c058e928bebaba2e1285e3c4" - integrity sha512-uBCRM2w2ewusRHGxN8JhcuOb2RN3ueAOYH/0BhqdFmQkZx5lj5+fLKTz0mIVOzd4FG5/kUksCzCD7eTEim6gaA== - dependencies: - fast-safe-stringify "^2.0.6" - -eth-json-rpc-filters@^4.0.2: - version "4.1.1" - resolved "https://registry.yarnpkg.com/eth-json-rpc-filters/-/eth-json-rpc-filters-4.1.1.tgz#15277c66790236d85f798f4d7dc6bab99a798cd2" - integrity sha512-GkXb2h6STznD+AmMzblwXgm1JMvjdK9PTIXG7BvIkTlXQ9g0QOxuU1iQRYHoslF9S30BYBSoLSisAYPdLggW+A== - dependencies: - await-semaphore "^0.1.3" - eth-json-rpc-middleware "^4.1.4" - eth-query "^2.1.2" - json-rpc-engine "^5.1.3" - lodash.flatmap "^4.5.0" - safe-event-emitter "^1.0.1" - -eth-json-rpc-infura@^3.1.0: - version "3.2.1" - resolved "https://registry.yarnpkg.com/eth-json-rpc-infura/-/eth-json-rpc-infura-3.2.1.tgz#26702a821067862b72d979c016fd611502c6057f" - integrity sha512-W7zR4DZvyTn23Bxc0EWsq4XGDdD63+XPUCEhV2zQvQGavDVC4ZpFDK4k99qN7bd7/fjj37+rxmuBOBeIqCA5Mw== - dependencies: - cross-fetch "^2.1.1" - eth-json-rpc-middleware "^1.5.0" - json-rpc-engine "^3.4.0" - json-rpc-error "^2.0.0" - -eth-json-rpc-middleware@^1.5.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/eth-json-rpc-middleware/-/eth-json-rpc-middleware-1.6.0.tgz#5c9d4c28f745ccb01630f0300ba945f4bef9593f" - integrity sha512-tDVCTlrUvdqHKqivYMjtFZsdD7TtpNLBCfKAcOpaVs7orBMS/A8HWro6dIzNtTZIR05FAbJ3bioFOnZpuCew9Q== - dependencies: - async "^2.5.0" - eth-query "^2.1.2" - eth-tx-summary "^3.1.2" - ethereumjs-block "^1.6.0" - ethereumjs-tx "^1.3.3" - ethereumjs-util "^5.1.2" - ethereumjs-vm "^2.1.0" - fetch-ponyfill "^4.0.0" - json-rpc-engine "^3.6.0" - json-rpc-error "^2.0.0" - json-stable-stringify "^1.0.1" - promise-to-callback "^1.0.0" - tape "^4.6.3" - -eth-json-rpc-middleware@^4.1.1, eth-json-rpc-middleware@^4.1.4: - version "4.4.1" - resolved "https://registry.yarnpkg.com/eth-json-rpc-middleware/-/eth-json-rpc-middleware-4.4.1.tgz#07d3dd0724c24a8d31e4a172ee96271da71b4228" - integrity sha512-yoSuRgEYYGFdVeZg3poWOwAlRI+MoBIltmOB86MtpoZjvLbou9EB/qWMOWSmH2ryCWLW97VYY6NWsmWm3OAA7A== - dependencies: - btoa "^1.2.1" - clone "^2.1.1" - eth-json-rpc-errors "^1.0.1" - eth-query "^2.1.2" - eth-sig-util "^1.4.2" - ethereumjs-block "^1.6.0" - ethereumjs-tx "^1.3.7" - ethereumjs-util "^5.1.2" - ethereumjs-vm "^2.6.0" - fetch-ponyfill "^4.0.0" - json-rpc-engine "^5.1.3" - json-stable-stringify "^1.0.1" - pify "^3.0.0" - safe-event-emitter "^1.0.1" - -eth-lib@0.2.7: - version "0.2.7" - resolved "https://registry.yarnpkg.com/eth-lib/-/eth-lib-0.2.7.tgz#2f93f17b1e23aec3759cd4a3fe20c1286a3fc1ca" - integrity sha1-L5Pxex4jrsN1nNSj/iDBKGo/wco= - dependencies: - bn.js "^4.11.6" - elliptic "^6.4.0" - xhr-request-promise "^0.1.2" - -eth-lib@0.2.8: - version "0.2.8" - resolved "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.8.tgz#b194058bef4b220ad12ea497431d6cb6aa0623c8" - integrity sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw== - dependencies: - bn.js "^4.11.6" - elliptic "^6.4.0" - xhr-request-promise "^0.1.2" - -eth-lib@^0.1.26: - version "0.1.29" - resolved "https://registry.yarnpkg.com/eth-lib/-/eth-lib-0.1.29.tgz#0c11f5060d42da9f931eab6199084734f4dbd1d9" - integrity sha512-bfttrr3/7gG4E02HoWTDUcDDslN003OlOoBxk9virpAZQ1ja/jDgwkWB8QfJF7ojuEowrqy+lzp9VcJG7/k5bQ== - dependencies: - bn.js "^4.11.6" - elliptic "^6.4.0" - nano-json-stream-parser "^0.1.2" - servify "^0.1.12" - ws "^3.0.0" - xhr-request-promise "^0.1.2" - -eth-query@^2.0.2, eth-query@^2.1.0, eth-query@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/eth-query/-/eth-query-2.1.2.tgz#d6741d9000106b51510c72db92d6365456a6da5e" - integrity sha1-1nQdkAAQa1FRDHLbktY2VFam2l4= - dependencies: - json-rpc-random-id "^1.0.0" - xtend "^4.0.1" - -eth-sig-util@^1.4.2: - version "1.4.2" - resolved "https://registry.yarnpkg.com/eth-sig-util/-/eth-sig-util-1.4.2.tgz#8d958202c7edbaae839707fba6f09ff327606210" - integrity sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA= - dependencies: - ethereumjs-abi "git+https://github.com/ethereumjs/ethereumjs-abi.git" - ethereumjs-util "^5.1.1" - -eth-tx-summary@^3.1.2: - version "3.2.4" - resolved "https://registry.yarnpkg.com/eth-tx-summary/-/eth-tx-summary-3.2.4.tgz#e10eb95eb57cdfe549bf29f97f1e4f1db679035c" - integrity sha512-NtlDnaVZah146Rm8HMRUNMgIwG/ED4jiqk0TME9zFheMl1jOp6jL1m0NKGjJwehXQ6ZKCPr16MTr+qspKpEXNg== - dependencies: - async "^2.1.2" - clone "^2.0.0" - concat-stream "^1.5.1" - end-of-stream "^1.1.0" - eth-query "^2.0.2" - ethereumjs-block "^1.4.1" - ethereumjs-tx "^1.1.1" - ethereumjs-util "^5.0.1" - ethereumjs-vm "^2.6.0" - through2 "^2.0.3" - -ethereum-bloom-filters@^1.0.6: - version "1.0.7" - resolved "https://registry.npmjs.org/ethereum-bloom-filters/-/ethereum-bloom-filters-1.0.7.tgz#b7b80735e385dbb7f944ce6b4533e24511306060" - integrity sha512-cDcJJSJ9GMAcURiAWO3DxIEhTL/uWqlQnvgKpuYQzYPrt/izuGU+1ntQmHt0IRq6ADoSYHFnB+aCEFIldjhkMQ== - dependencies: - js-sha3 "^0.8.0" - -ethereum-common@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/ethereum-common/-/ethereum-common-0.2.0.tgz#13bf966131cce1eeade62a1b434249bb4cb120ca" - integrity sha512-XOnAR/3rntJgbCdGhqdaLIxDLWKLmsZOGhHdBKadEr6gEnJLH52k93Ou+TUdFaPN3hJc3isBZBal3U/XZ15abA== - -ethereum-common@^0.0.18: - version "0.0.18" - resolved "https://registry.yarnpkg.com/ethereum-common/-/ethereum-common-0.0.18.tgz#2fdc3576f232903358976eb39da783213ff9523f" - integrity sha1-L9w1dvIykDNYl26znaeDIT/5Uj8= - -ethereum-protocol@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/ethereum-protocol/-/ethereum-protocol-1.0.1.tgz#b7d68142f4105e0ae7b5e178cf42f8d4dc4b93cf" - integrity sha512-3KLX1mHuEsBW0dKG+c6EOJS1NBNqdCICvZW9sInmZTt5aY0oxmHVggYRE0lJu1tcnMD1K+AKHdLi6U43Awm1Vg== - -"ethereumjs-abi@git+https://github.com/ethereumjs/ethereumjs-abi.git": - version "0.6.8" - resolved "git+https://github.com/ethereumjs/ethereumjs-abi.git#1cfbb13862f90f0b391d8a699544d5fe4dfb8c7b" - dependencies: - bn.js "^4.11.8" - ethereumjs-util "^6.0.0" - -ethereumjs-account@^2.0.3: - version "2.0.5" - resolved "https://registry.yarnpkg.com/ethereumjs-account/-/ethereumjs-account-2.0.5.tgz#eeafc62de544cb07b0ee44b10f572c9c49e00a84" - integrity sha512-bgDojnXGjhMwo6eXQC0bY6UK2liSFUSMwwylOmQvZbSl/D7NXQ3+vrGO46ZeOgjGfxXmgIeVNDIiHw7fNZM4VA== - dependencies: - ethereumjs-util "^5.0.0" - rlp "^2.0.0" - safe-buffer "^5.1.1" - -ethereumjs-block@^1.2.2, ethereumjs-block@^1.4.1, ethereumjs-block@^1.6.0: - version "1.7.1" - resolved "https://registry.yarnpkg.com/ethereumjs-block/-/ethereumjs-block-1.7.1.tgz#78b88e6cc56de29a6b4884ee75379b6860333c3f" - integrity sha512-B+sSdtqm78fmKkBq78/QLKJbu/4Ts4P2KFISdgcuZUPDm9x+N7qgBPIIFUGbaakQh8bzuquiRVbdmvPKqbILRg== - dependencies: - async "^2.0.1" - ethereum-common "0.2.0" - ethereumjs-tx "^1.2.2" - ethereumjs-util "^5.0.0" - merkle-patricia-tree "^2.1.2" - -ethereumjs-block@~2.2.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/ethereumjs-block/-/ethereumjs-block-2.2.2.tgz#c7654be7e22df489fda206139ecd63e2e9c04965" - integrity sha512-2p49ifhek3h2zeg/+da6XpdFR3GlqY3BIEiqxGF8j9aSRIgkb7M1Ky+yULBKJOu8PAZxfhsYA+HxUk2aCQp3vg== - dependencies: - async "^2.0.1" - ethereumjs-common "^1.5.0" - ethereumjs-tx "^2.1.1" - ethereumjs-util "^5.0.0" - merkle-patricia-tree "^2.1.2" - -ethereumjs-common@^1.1.0, ethereumjs-common@^1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/ethereumjs-common/-/ethereumjs-common-1.5.1.tgz#4e75042473a64daec0ed9fe84323dd9576aa5dba" - integrity sha512-aVUPRLgmXORGXXEVkFYgPhr9TGtpBY2tGhZ9Uh0A3lIUzUDr1x6kQx33SbjPUkLkX3eniPQnIL/2psjkjrOfcQ== - -ethereumjs-common@^1.3.2: - version "1.5.2" - resolved "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-1.5.2.tgz#2065dbe9214e850f2e955a80e650cb6999066979" - integrity sha512-hTfZjwGX52GS2jcVO6E2sx4YuFnf0Fhp5ylo4pEPhEffNln7vS59Hr5sLnp3/QCazFLluuBZ+FZ6J5HTp0EqCA== - -ethereumjs-tx@^1.0.0, ethereumjs-tx@^1.1.1, ethereumjs-tx@^1.2.0, ethereumjs-tx@^1.2.2, ethereumjs-tx@^1.3.3, ethereumjs-tx@^1.3.7: - version "1.3.7" - resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-1.3.7.tgz#88323a2d875b10549b8347e09f4862b546f3d89a" - integrity sha512-wvLMxzt1RPhAQ9Yi3/HKZTn0FZYpnsmQdbKYfUUpi4j1SEIcbkd9tndVjcPrufY3V7j2IebOpC00Zp2P/Ay2kA== - dependencies: - ethereum-common "^0.0.18" - ethereumjs-util "^5.0.0" - -ethereumjs-tx@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-2.1.2.tgz#5dfe7688bf177b45c9a23f86cf9104d47ea35fed" - integrity sha512-zZEK1onCeiORb0wyCXUvg94Ve5It/K6GD1K+26KfFKodiBiS6d9lfCXlUKGBBdQ+bv7Day+JK0tj1K+BeNFRAw== - dependencies: - ethereumjs-common "^1.5.0" - ethereumjs-util "^6.0.0" - -ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereumjs-util@^5.1.2, ethereumjs-util@^5.1.5: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz#3e0c0d1741471acf1036052d048623dee54ad642" - integrity sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA== - dependencies: - bn.js "^4.11.0" - create-hash "^1.1.2" - ethjs-util "^0.1.3" - keccak "^1.0.2" - rlp "^2.0.0" - safe-buffer "^5.1.1" - secp256k1 "^3.0.1" - -ethereumjs-util@^6.0.0, ethereumjs-util@^6.1.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-6.2.0.tgz#23ec79b2488a7d041242f01e25f24e5ad0357960" - integrity sha512-vb0XN9J2QGdZGIEKG2vXM+kUdEivUfU6Wmi5y0cg+LRhDYKnXIZ/Lz7XjFbHRR9VIKq2lVGLzGBkA++y2nOdOQ== - dependencies: - "@types/bn.js" "^4.11.3" - bn.js "^4.11.0" - create-hash "^1.1.2" - ethjs-util "0.1.6" - keccak "^2.0.0" - rlp "^2.2.3" - secp256k1 "^3.0.1" - -ethereumjs-vm@^2.1.0, ethereumjs-vm@^2.3.4, ethereumjs-vm@^2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/ethereumjs-vm/-/ethereumjs-vm-2.6.0.tgz#76243ed8de031b408793ac33907fb3407fe400c6" - integrity sha512-r/XIUik/ynGbxS3y+mvGnbOKnuLo40V5Mj1J25+HEO63aWYREIqvWeRO/hnROlMBE5WoniQmPmhiaN0ctiHaXw== - dependencies: - async "^2.1.2" - async-eventemitter "^0.2.2" - ethereumjs-account "^2.0.3" - ethereumjs-block "~2.2.0" - ethereumjs-common "^1.1.0" - ethereumjs-util "^6.0.0" - fake-merkle-patricia-tree "^1.0.1" - functional-red-black-tree "^1.0.1" - merkle-patricia-tree "^2.3.2" - rustbn.js "~0.2.0" - safe-buffer "^5.1.1" - -ethereumjs-wallet@^0.6.3: - version "0.6.4" - resolved "https://registry.yarnpkg.com/ethereumjs-wallet/-/ethereumjs-wallet-0.6.4.tgz#67dd013dd839e69a8eb9a8f78cacfc9bff307167" - integrity sha512-xAYLWVH/MA9Ds1+BiDTfdRrCBQIz7r70EJSjuBnvw/x40qJ1jBoBBAp8/l+I9VPGAsUXvHTfcnp2OZ9LbcTs/g== - dependencies: - aes-js "^3.1.1" - bs58check "^2.1.2" - ethereumjs-util "^6.0.0" - hdkey "^1.1.1" - randombytes "^2.0.6" - safe-buffer "^5.1.2" - scryptsy "^1.2.1" - utf8 "^3.0.0" - uuid "^3.3.2" - -ethers@4.0.0-beta.3: - version "4.0.0-beta.3" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.0-beta.3.tgz#15bef14e57e94ecbeb7f9b39dd0a4bd435bc9066" - integrity sha512-YYPogooSknTwvHg3+Mv71gM/3Wcrx+ZpCzarBj3mqs9njjRkrOo2/eufzhHloOCo3JSoNI4TQJJ6yU5ABm3Uog== - dependencies: - "@types/node" "^10.3.2" - aes-js "3.0.0" - bn.js "^4.4.0" - elliptic "6.3.3" - hash.js "1.1.3" - js-sha3 "0.5.7" - scrypt-js "2.0.3" - setimmediate "1.0.4" - uuid "2.0.1" - xmlhttprequest "1.8.0" - -ethjs-unit@0.1.6: - version "0.1.6" - resolved "https://registry.yarnpkg.com/ethjs-unit/-/ethjs-unit-0.1.6.tgz#c665921e476e87bce2a9d588a6fe0405b2c41699" - integrity sha1-xmWSHkduh7ziqdWIpv4EBbLEFpk= - dependencies: - bn.js "4.11.6" - number-to-bn "1.7.0" - -ethjs-util@0.1.6, ethjs-util@^0.1.3: - version "0.1.6" - resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" - integrity sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w== - dependencies: - is-hex-prefixed "1.0.0" - strip-hex-prefix "1.0.0" - -eventemitter3@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7" - integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q== - -eventemitter3@4.0.4: - version "4.0.4" - resolved "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.4.tgz#b5463ace635a083d018bdc7c917b4c5f10a85384" - integrity sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ== - -events@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.1.0.tgz#84279af1b34cb75aa88bf5ff291f6d0bd9b31a59" - integrity sha512-Rv+u8MLHNOdMjTAFeT3nCjHn2aGlx435FP/sDHNaRhDEMwyI/aB22Kj2qIN8R0cw3z28psEQLYwxVKLsKrMgWg== - -evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" - integrity sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA== - dependencies: - md5.js "^1.3.4" - safe-buffer "^5.1.1" - -express@^4.14.0: - version "4.17.1" - resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134" - integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g== - dependencies: - accepts "~1.3.7" - array-flatten "1.1.1" - body-parser "1.19.0" - content-disposition "0.5.3" - content-type "~1.0.4" - cookie "0.4.0" - cookie-signature "1.0.6" - debug "2.6.9" - depd "~1.1.2" - encodeurl "~1.0.2" - escape-html "~1.0.3" - etag "~1.8.1" - finalhandler "~1.1.2" - fresh "0.5.2" - merge-descriptors "1.0.1" - methods "~1.1.2" - on-finished "~2.3.0" - parseurl "~1.3.3" - path-to-regexp "0.1.7" - proxy-addr "~2.0.5" - qs "6.7.0" - range-parser "~1.2.1" - safe-buffer "5.1.2" - send "0.17.1" - serve-static "1.14.1" - setprototypeof "1.1.1" - statuses "~1.5.0" - type-is "~1.6.18" - utils-merge "1.0.1" - vary "~1.1.2" - -ext@^1.1.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/ext/-/ext-1.4.0.tgz#89ae7a07158f79d35517882904324077e4379244" - integrity sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A== - dependencies: - type "^2.0.0" - -extend@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== - -extsprintf@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" - integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= - -extsprintf@^1.2.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" - integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= - -fake-merkle-patricia-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/fake-merkle-patricia-tree/-/fake-merkle-patricia-tree-1.0.1.tgz#4b8c3acfb520afadf9860b1f14cd8ce3402cddd3" - integrity sha1-S4w6z7Ugr635hgsfFM2M40As3dM= - dependencies: - checkpoint-store "^1.1.0" - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fast-safe-stringify@^2.0.6: - version "2.0.7" - resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz#124aa885899261f68aedb42a7c080de9da608743" - integrity sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA== - -fd-slicer@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" - integrity sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4= - dependencies: - pend "~1.2.0" - -fetch-ponyfill@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/fetch-ponyfill/-/fetch-ponyfill-4.1.0.tgz#ae3ce5f732c645eab87e4ae8793414709b239893" - integrity sha1-rjzl9zLGReq4fkroeTQUcJsjmJM= - dependencies: - node-fetch "~1.7.1" - -file-type@^3.8.0: - version "3.9.0" - resolved "https://registry.yarnpkg.com/file-type/-/file-type-3.9.0.tgz#257a078384d1db8087bc449d107d52a52672b9e9" - integrity sha1-JXoHg4TR24CHvESdEH1SpSZyuek= - -file-type@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/file-type/-/file-type-5.2.0.tgz#2ddbea7c73ffe36368dfae49dc338c058c2b8ad6" - integrity sha1-LdvqfHP/42No365J3DOMBYwritY= - -file-type@^6.1.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/file-type/-/file-type-6.2.0.tgz#e50cd75d356ffed4e306dc4f5bcf52a79903a919" - integrity sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg== - -file-uri-to-path@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" - integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== - -finalhandler@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" - integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== - dependencies: - debug "2.6.9" - encodeurl "~1.0.2" - escape-html "~1.0.3" - on-finished "~2.3.0" - parseurl "~1.3.3" - statuses "~1.5.0" - unpipe "~1.0.0" - -for-each@~0.3.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" - integrity sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw== - dependencies: - is-callable "^1.1.3" - -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" - integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= - -form-data@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" - integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.6" - mime-types "^2.1.12" - -forwarded@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" - integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ= - -fresh@0.5.2: - version "0.5.2" - resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" - integrity sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac= - -fs-constants@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" - integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== - -fs-extra@^4.0.2: - version "4.0.3" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" - integrity sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg== - dependencies: - graceful-fs "^4.1.2" - jsonfile "^4.0.0" - universalify "^0.1.0" - -fs-minipass@^1.2.5: - version "1.2.7" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" - integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== - dependencies: - minipass "^2.6.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -function-bind@^1.1.1, function-bind@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= - -get-stream@^2.2.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de" - integrity sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4= - dependencies: - object-assign "^4.0.1" - pinkie-promise "^2.0.0" - -get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= - -get-stream@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" - integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== - dependencies: - pump "^3.0.0" - -get-stream@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.1.0.tgz#01203cdc92597f9b909067c3e656cc1f4d3c4dc9" - integrity sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw== - dependencies: - pump "^3.0.0" - -getpass@^0.1.1: - version "0.1.7" - resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" - integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= - dependencies: - assert-plus "^1.0.0" - -glob@~7.1.6: - version "7.1.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -global@~4.3.0: - version "4.3.2" - resolved "https://registry.yarnpkg.com/global/-/global-4.3.2.tgz#e76989268a6c74c38908b1305b10fc0e394e9d0f" - integrity sha1-52mJJopsdMOJCLEwWxD8DjlOnQ8= - dependencies: - min-document "^2.19.0" - process "~0.5.1" - -globals@^9.18.0: - version "9.18.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" - integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== - -got@9.6.0: - version "9.6.0" - resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" - integrity sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q== - dependencies: - "@sindresorhus/is" "^0.14.0" - "@szmarczak/http-timer" "^1.1.2" - cacheable-request "^6.0.0" - decompress-response "^3.3.0" - duplexer3 "^0.1.4" - get-stream "^4.1.0" - lowercase-keys "^1.0.1" - mimic-response "^1.0.1" - p-cancelable "^1.0.0" - to-readable-stream "^1.0.0" - url-parse-lax "^3.0.0" - -got@^7.1.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/got/-/got-7.1.0.tgz#05450fd84094e6bbea56f451a43a9c289166385a" - integrity sha512-Y5WMo7xKKq1muPsxD+KmrR8DH5auG7fBdDVueZwETwV6VytKyU9OX/ddpq2/1hp1vIPvVb4T81dKQz3BivkNLw== - dependencies: - decompress-response "^3.2.0" - duplexer3 "^0.1.4" - get-stream "^3.0.0" - is-plain-obj "^1.1.0" - is-retry-allowed "^1.0.0" - is-stream "^1.0.0" - isurl "^1.0.0-alpha5" - lowercase-keys "^1.0.0" - p-cancelable "^0.3.0" - p-timeout "^1.1.1" - safe-buffer "^5.0.1" - timed-out "^4.0.0" - url-parse-lax "^1.0.0" - url-to-options "^1.0.1" - -graceful-fs@^4.1.10, graceful-fs@^4.1.2, graceful-fs@^4.1.6: - version "4.2.4" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" - integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== - -"graceful-readlink@>= 1.0.0": - version "1.0.1" - resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" - integrity sha1-TK+tdrxi8C+gObL5Tpo906ORpyU= - -har-schema@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" - integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= - -har-validator@~5.1.3: - version "5.1.3" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.3.tgz#1ef89ebd3e4996557675eed9893110dc350fa080" - integrity sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g== - dependencies: - ajv "^6.5.5" - har-schema "^2.0.0" - -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE= - dependencies: - ansi-regex "^2.0.0" - -has-symbol-support-x@^1.4.1: - version "1.4.2" - resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455" - integrity sha512-3ToOva++HaW+eCpgqZrCfN51IPB+7bJNVT6CUATzueB5Heb8o6Nam0V3HG5dlDvZU1Gn5QLcbahiKw/XVk5JJw== - -has-symbols@^1.0.0, has-symbols@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" - integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== - -has-to-string-tag-x@^1.2.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d" - integrity sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw== - dependencies: - has-symbol-support-x "^1.4.1" - -has@^1.0.3, has@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -hash-base@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" - integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== - dependencies: - inherits "^2.0.4" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -hash.js@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.3.tgz#340dedbe6290187151c1ea1d777a3448935df846" - integrity sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.0" - -hash.js@^1.0.0, hash.js@^1.0.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" - integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.1" - -hdkey@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/hdkey/-/hdkey-1.1.2.tgz#c60f9cf6f90fbf24a8a52ea06893f36a0108cd3e" - integrity sha512-PTQ4VKu0oRnCrYfLp04iQZ7T2Cxz0UsEXYauk2j8eh6PJXCpbXuCFhOmtIFtbET0i3PMWmHN9J11gU8LEgUljQ== - dependencies: - bs58check "^2.1.2" - safe-buffer "^5.1.1" - secp256k1 "^3.0.1" - -hmac-drbg@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" - integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= - dependencies: - hash.js "^1.0.3" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.1" - -home-or-tmp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" - integrity sha1-42w/LSyufXRqhX440Y1fMqeILbg= - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.1" - -http-cache-semantics@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390" - integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== - -http-errors@1.7.2: - version "1.7.2" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f" - integrity sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg== - dependencies: - depd "~1.1.2" - inherits "2.0.3" - setprototypeof "1.1.1" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.0" - -http-errors@~1.7.2: - version "1.7.3" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06" - integrity sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw== - dependencies: - depd "~1.1.2" - inherits "2.0.4" - setprototypeof "1.1.1" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.0" - -http-https@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/http-https/-/http-https-1.0.0.tgz#2f908dd5f1db4068c058cd6e6d4ce392c913389b" - integrity sha1-L5CN1fHbQGjAWM1ubUzjkskTOJs= - -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= - dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -iconv-lite@0.4.24, iconv-lite@~0.4.13: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - -idna-uts46-hx@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/idna-uts46-hx/-/idna-uts46-hx-2.3.1.tgz#a1dc5c4df37eee522bf66d969cc980e00e8711f9" - integrity sha512-PWoF9Keq6laYdIRwwCdhTPl60xRqAloYNMQLiyUnG42VjT53oW07BXIRM+NK7eQjzXjAk2gUvX9caRxlnF9TAA== - dependencies: - punycode "2.1.0" - -ieee754@^1.1.4: - version "1.1.13" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84" - integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg== - -immediate@^3.2.3: - version "3.3.0" - resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.3.0.tgz#1aef225517836bcdf7f2a2de2600c79ff0269266" - integrity sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3, inherits@~2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -inherits@2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= - -invariant@^2.2.2: - version "2.2.4" - resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" - integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== - dependencies: - loose-envify "^1.0.0" - -ipaddr.js@1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" - integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== - -is-arguments@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.0.4.tgz#3faf966c7cba0ff437fb31f6250082fcf0448cf3" - integrity sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA== - -is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.0.tgz#83336560b54a38e35e3a2df7afd0454d691468bb" - integrity sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw== - -is-date-object@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" - integrity sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g== - -is-finite@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3" - integrity sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w== - -is-fn@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-fn/-/is-fn-1.0.0.tgz#9543d5de7bcf5b08a22ec8a20bae6e286d510d8c" - integrity sha1-lUPV3nvPWwiiLsiiC65uKG1RDYw= - -is-function@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.2.tgz#4f097f30abf6efadac9833b17ca5dc03f8144e08" - integrity sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ== - -is-hex-prefixed@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz#7d8d37e6ad77e5d127148913c573e082d777f554" - integrity sha1-fY035q135dEnFIkTxXPggtd39VQ= - -is-natural-number@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-natural-number/-/is-natural-number-4.0.1.tgz#ab9d76e1db4ced51e35de0c72ebecf09f734cde8" - integrity sha1-q5124dtM7VHjXeDHLr7PCfc0zeg= - -is-object@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-object/-/is-object-1.0.1.tgz#8952688c5ec2ffd6b03ecc85e769e02903083470" - integrity sha1-iVJojF7C/9awPsyF52ngKQMINHA= - -is-plain-obj@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" - integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= - -is-regex@^1.0.4, is-regex@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.0.tgz#ece38e389e490df0dc21caea2bd596f987f767ff" - integrity sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw== - dependencies: - has-symbols "^1.0.1" - -is-regex@~1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.5.tgz#39d589a358bf18967f726967120b8fc1aed74eae" - integrity sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ== - dependencies: - has "^1.0.3" - -is-retry-allowed@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4" - integrity sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg== - -is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= - -is-symbol@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" - integrity sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ== - dependencies: - has-symbols "^1.0.1" - -is-typedarray@^1.0.0, is-typedarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= - -isarray@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" - integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= - -isstream@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" - integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= - -isurl@^1.0.0-alpha5: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isurl/-/isurl-1.0.0.tgz#b27f4f49f3cdaa3ea44a0a5b7f3462e6edc39d67" - integrity sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w== - dependencies: - has-to-string-tag-x "^1.2.0" - is-object "^1.0.1" - -js-sha3@0.5.7, js-sha3@^0.5.7: - version "0.5.7" - resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.7.tgz#0d4ffd8002d5333aabaf4a23eed2f6374c9f28e7" - integrity sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc= - -js-sha3@^0.8.0: - version "0.8.0" - resolved "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" - integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== - -"js-tokens@^3.0.0 || ^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-tokens@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" - integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= - -jsbn@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" - integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= - -jsesc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" - integrity sha1-RsP+yMGJKxKwgz25vHYiF226s0s= - -jsesc@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" - integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= - -json-buffer@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" - integrity sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg= - -json-rpc-engine@^3.4.0, json-rpc-engine@^3.6.0: - version "3.8.0" - resolved "https://registry.yarnpkg.com/json-rpc-engine/-/json-rpc-engine-3.8.0.tgz#9d4ff447241792e1d0a232f6ef927302bb0c62a9" - integrity sha512-6QNcvm2gFuuK4TKU1uwfH0Qd/cOSb9c1lls0gbnIhciktIUQJwz6NQNAW4B1KiGPenv7IKu97V222Yo1bNhGuA== - dependencies: - async "^2.0.1" - babel-preset-env "^1.7.0" - babelify "^7.3.0" - json-rpc-error "^2.0.0" - promise-to-callback "^1.0.0" - safe-event-emitter "^1.0.1" - -json-rpc-engine@^5.1.3: - version "5.1.8" - resolved "https://registry.yarnpkg.com/json-rpc-engine/-/json-rpc-engine-5.1.8.tgz#5ba0147ce571899bbaa7133ffbc05317c34a3c7f" - integrity sha512-vTBSDEPJV1fPAsbm2g5sEuPjsgLdiab2f1CTn2PyRr8nxggUpA996PDlNQDsM0gnrA99F8KIBLq2nIKrOFl1Mg== - dependencies: - async "^2.0.1" - eth-json-rpc-errors "^2.0.1" - promise-to-callback "^1.0.0" - safe-event-emitter "^1.0.1" - -json-rpc-error@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/json-rpc-error/-/json-rpc-error-2.0.0.tgz#a7af9c202838b5e905c7250e547f1aff77258a02" - integrity sha1-p6+cICg4tekFxyUOVH8a/3cligI= - dependencies: - inherits "^2.0.1" - -json-rpc-random-id@^1.0.0, json-rpc-random-id@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-rpc-random-id/-/json-rpc-random-id-1.0.1.tgz#ba49d96aded1444dbb8da3d203748acbbcdec8c8" - integrity sha1-uknZat7RRE27jaPSA3SKy7zeyMg= - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json-schema@0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" - integrity sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM= - -json-stable-stringify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" - integrity sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8= - dependencies: - jsonify "~0.0.0" - -json-stringify-safe@~5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - -json5@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" - integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE= - -jsonfile@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" - integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= - optionalDependencies: - graceful-fs "^4.1.6" - -jsonify@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" - integrity sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM= - -jsprim@^1.2.2: - version "1.4.1" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" - integrity sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.2.3" - verror "1.10.0" - -keccak@^1.0.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/keccak/-/keccak-1.4.0.tgz#572f8a6dbee8e7b3aa421550f9e6408ca2186f80" - integrity sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw== - dependencies: - bindings "^1.2.1" - inherits "^2.0.3" - nan "^2.2.1" - safe-buffer "^5.1.0" - -keccak@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/keccak/-/keccak-2.1.0.tgz#734ea53f2edcfd0f42cdb8d5f4c358fef052752b" - integrity sha512-m1wbJRTo+gWbctZWay9i26v5fFnYkOn7D5PCxJ3fZUGUEb49dE1Pm4BREUYCt/aoO6di7jeoGmhvqN9Nzylm3Q== - dependencies: - bindings "^1.5.0" - inherits "^2.0.4" - nan "^2.14.0" - safe-buffer "^5.2.0" - -keyv@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9" - integrity sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA== - dependencies: - json-buffer "3.0.0" - -level-codec@~7.0.0: - version "7.0.1" - resolved "https://registry.yarnpkg.com/level-codec/-/level-codec-7.0.1.tgz#341f22f907ce0f16763f24bddd681e395a0fb8a7" - integrity sha512-Ua/R9B9r3RasXdRmOtd+t9TCOEIIlts+TN/7XTT2unhDaL6sJn83S3rUyljbr6lVtw49N3/yA0HHjpV6Kzb2aQ== - -level-errors@^1.0.3: - version "1.1.2" - resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-1.1.2.tgz#4399c2f3d3ab87d0625f7e3676e2d807deff404d" - integrity sha512-Sw/IJwWbPKF5Ai4Wz60B52yj0zYeqzObLh8k1Tk88jVmD51cJSKWSYpRyhVIvFzZdvsPqlH5wfhp/yxdsaQH4w== - dependencies: - errno "~0.1.1" - -level-errors@~1.0.3: - version "1.0.5" - resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-1.0.5.tgz#83dbfb12f0b8a2516bdc9a31c4876038e227b859" - integrity sha512-/cLUpQduF6bNrWuAC4pwtUKA5t669pCsCi2XbmojG2tFeOr9j6ShtdDCtFFQO1DRt+EVZhx9gPzP9G2bUaG4ig== - dependencies: - errno "~0.1.1" - -level-iterator-stream@~1.3.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-1.3.1.tgz#e43b78b1a8143e6fa97a4f485eb8ea530352f2ed" - integrity sha1-5Dt4sagUPm+pek9IXrjqUwNS8u0= - dependencies: - inherits "^2.0.1" - level-errors "^1.0.3" - readable-stream "^1.0.33" - xtend "^4.0.0" - -level-ws@0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/level-ws/-/level-ws-0.0.0.tgz#372e512177924a00424b0b43aef2bb42496d228b" - integrity sha1-Ny5RIXeSSgBCSwtDrvK7QkltIos= - dependencies: - readable-stream "~1.0.15" - xtend "~2.1.1" - -levelup@^1.2.1: - version "1.3.9" - resolved "https://registry.yarnpkg.com/levelup/-/levelup-1.3.9.tgz#2dbcae845b2bb2b6bea84df334c475533bbd82ab" - integrity sha512-VVGHfKIlmw8w1XqpGOAGwq6sZm2WwWLmlDcULkKWQXEA5EopA8OBNJ2Ck2v6bdk8HeEZSbCSEgzXadyQFm76sQ== - dependencies: - deferred-leveldown "~1.2.1" - level-codec "~7.0.0" - level-errors "~1.0.3" - level-iterator-stream "~1.3.0" - prr "~1.0.1" - semver "~5.4.1" - xtend "~4.0.0" - -lodash.flatmap@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.flatmap/-/lodash.flatmap-4.5.0.tgz#ef8cbf408f6e48268663345305c6acc0b778702e" - integrity sha1-74y/QI9uSCaGYzRTBcaswLd4cC4= - -lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.4: - version "4.17.20" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" - integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== - -loose-envify@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" - integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== - dependencies: - js-tokens "^3.0.0 || ^4.0.0" - -lowercase-keys@^1.0.0, lowercase-keys@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" - integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== - -lowercase-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" - integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== - -ltgt@~2.2.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" - integrity sha1-81ypHEk/e3PaDgdJUwTxezH4fuU= - -make-dir@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" - integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== - dependencies: - pify "^3.0.0" - -md5.js@^1.3.4: - version "1.3.5" - resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" - integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -media-typer@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" - integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= - -memdown@^1.0.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/memdown/-/memdown-1.4.1.tgz#b4e4e192174664ffbae41361aa500f3119efe215" - integrity sha1-tOThkhdGZP+65BNhqlAPMRnv4hU= - dependencies: - abstract-leveldown "~2.7.1" - functional-red-black-tree "^1.0.1" - immediate "^3.2.3" - inherits "~2.0.1" - ltgt "~2.2.0" - safe-buffer "~5.1.1" - -merge-descriptors@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" - integrity sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E= - -merkle-patricia-tree@^2.1.2, merkle-patricia-tree@^2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-2.3.2.tgz#982ca1b5a0fde00eed2f6aeed1f9152860b8208a" - integrity sha512-81PW5m8oz/pz3GvsAwbauj7Y00rqm81Tzad77tHBwU7pIAtN+TJnMSOJhxBKflSVYhptMMb9RskhqHqrSm1V+g== - dependencies: - async "^1.4.2" - ethereumjs-util "^5.0.0" - level-ws "0.0.0" - levelup "^1.2.1" - memdown "^1.0.0" - readable-stream "^2.0.0" - rlp "^2.0.0" - semaphore ">=1.0.1" - -methods@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" - integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= - -miller-rabin@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" - integrity sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA== - dependencies: - bn.js "^4.0.0" - brorand "^1.0.1" - -mime-db@1.44.0: - version "1.44.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" - integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== - -mime-types@^2.1.12, mime-types@^2.1.16, mime-types@~2.1.19, mime-types@~2.1.24: - version "2.1.27" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" - integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== - dependencies: - mime-db "1.44.0" - -mime@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" - integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== - -mimic-response@^1.0.0, mimic-response@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" - integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== - -min-document@^2.19.0: - version "2.19.0" - resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685" - integrity sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU= - dependencies: - dom-walk "^0.1.0" - -minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" - integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= - -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== - dependencies: - brace-expansion "^1.1.7" - -minimist@^1.2.5, minimist@~1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== - -minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" - integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== - dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" - -minizlib@^1.2.1: - version "1.3.3" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" - integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== - dependencies: - minipass "^2.9.0" - -mkdirp-promise@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/mkdirp-promise/-/mkdirp-promise-5.0.1.tgz#e9b8f68e552c68a9c1713b84883f7a1dd039b8a1" - integrity sha1-6bj2jlUsaKnBcTuEiD96HdA5uKE= - dependencies: - mkdirp "*" - -mkdirp@*: - version "1.0.4" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" - integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - -mkdirp@^0.5.0, mkdirp@^0.5.1: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -mock-fs@^4.1.0: - version "4.12.0" - resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.12.0.tgz#a5d50b12d2d75e5bec9dac3b67ffe3c41d31ade4" - integrity sha512-/P/HtrlvBxY4o/PzXY9cCNBrdylDNxg7gnrv2sMNxj+UJ2m8jSpl0/A6fuJeNAWr99ZvGWH8XCbE0vmnM5KupQ== - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - -ms@2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" - integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== - -multibase@^0.7.0: - version "0.7.0" - resolved "https://registry.npmjs.org/multibase/-/multibase-0.7.0.tgz#1adfc1c50abe05eefeb5091ac0c2728d6b84581b" - integrity sha512-TW8q03O0f6PNFTQDvh3xxH03c8CjGaaYrjkl9UQPG6rz53TQzzxJVCIWVjzcbN/Q5Y53Zd0IBQBMVktVgNx4Fg== - dependencies: - base-x "^3.0.8" - buffer "^5.5.0" - -multibase@~0.6.0: - version "0.6.1" - resolved "https://registry.npmjs.org/multibase/-/multibase-0.6.1.tgz#b76df6298536cc17b9f6a6db53ec88f85f8cc12b" - integrity sha512-pFfAwyTjbbQgNc3G7D48JkJxWtoJoBMaR4xQUOuB8RnCgRqaYmWNFeJTTvrJ2w51bjLq2zTby6Rqj9TQ9elSUw== - dependencies: - base-x "^3.0.8" - buffer "^5.5.0" - -multicodec@^0.5.5: - version "0.5.7" - resolved "https://registry.npmjs.org/multicodec/-/multicodec-0.5.7.tgz#1fb3f9dd866a10a55d226e194abba2dcc1ee9ffd" - integrity sha512-PscoRxm3f+88fAtELwUnZxGDkduE2HD9Q6GHUOywQLjOGT/HAdhjLDYNZ1e7VR0s0TP0EwZ16LNUTFpoBGivOA== - dependencies: - varint "^5.0.0" - -multicodec@^1.0.0: - version "1.0.4" - resolved "https://registry.npmjs.org/multicodec/-/multicodec-1.0.4.tgz#46ac064657c40380c28367c90304d8ed175a714f" - integrity sha512-NDd7FeS3QamVtbgfvu5h7fd1IlbaC4EQ0/pgU4zqE2vdHCmBGsUa0TiM8/TdSeG6BMPC92OOCf8F1ocE/Wkrrg== - dependencies: - buffer "^5.6.0" - varint "^5.0.0" - -multihashes@^0.4.15, multihashes@~0.4.15: - version "0.4.21" - resolved "https://registry.npmjs.org/multihashes/-/multihashes-0.4.21.tgz#dc02d525579f334a7909ade8a122dabb58ccfcb5" - integrity sha512-uVSvmeCWf36pU2nB4/1kzYZjsXD9vofZKpgudqkceYY5g2aZZXJ5r9lxuzoRLl1OAp28XljXsEJ/X/85ZsKmKw== - dependencies: - buffer "^5.5.0" - multibase "^0.7.0" - varint "^5.0.0" - -nan@^2.14.0, nan@^2.2.1: - version "2.14.1" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01" - integrity sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw== - -nano-json-stream-parser@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz#0cc8f6d0e2b622b479c40d499c46d64b755c6f5f" - integrity sha1-DMj20OK2IrR5xA1JnEbWS3Vcb18= - -negotiator@0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" - integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw== - -next-tick@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" - integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= - -node-fetch@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5" - integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U= - -node-fetch@~1.7.1: - version "1.7.3" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" - integrity sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ== - dependencies: - encoding "^0.1.11" - is-stream "^1.0.1" - -node-gyp-build@~3.7.0: - version "3.7.0" - resolved "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-3.7.0.tgz#daa77a4f547b9aed3e2aac779eaf151afd60ec8d" - integrity sha512-L/Eg02Epx6Si2NXmedx+Okg+4UHqmaf3TNcxd50SF9NQGcJaON3AtU++kax69XV7YWz4tUspqZSAsVofhFKG2w== - -normalize-url@^4.1.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129" - integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ== - -number-to-bn@1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/number-to-bn/-/number-to-bn-1.7.0.tgz#bb3623592f7e5f9e0030b1977bd41a0c53fe1ea0" - integrity sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA= - dependencies: - bn.js "4.11.6" - strip-hex-prefix "1.0.0" - -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" - integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== - -object-assign@^4, object-assign@^4.0.0, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - -object-inspect@^1.7.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0" - integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA== - -object-inspect@~1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" - integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw== - -object-is@^1.0.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.2.tgz#c5d2e87ff9e119f78b7a088441519e2eec1573b6" - integrity sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - -object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -object-keys@~0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-0.4.0.tgz#28a6aae7428dd2c3a92f3d95f21335dd204e0336" - integrity sha1-KKaq50KN0sOpLz2V8hM13SBOAzY= - -object.assign@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" - integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== - dependencies: - define-properties "^1.1.2" - function-bind "^1.1.1" - has-symbols "^1.0.0" - object-keys "^1.0.11" - -oboe@2.1.4: - version "2.1.4" - resolved "https://registry.yarnpkg.com/oboe/-/oboe-2.1.4.tgz#20c88cdb0c15371bb04119257d4fdd34b0aa49f6" - integrity sha1-IMiM2wwVNxuwQRklfU/dNLCqSfY= - dependencies: - http-https "^1.0.0" - -on-finished@~2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" - integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= - dependencies: - ee-first "1.1.1" - -once@^1.3.0, once@^1.3.1, once@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -openzeppelin-solidity@1.12.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/openzeppelin-solidity/-/openzeppelin-solidity-1.12.0.tgz#7b9c55975e73370d4541e3442b30cb3d91ac973a" - integrity sha512-WlorzMXIIurugiSdw121RVD5qA3EfSI7GybTn+/Du0mPNgairjt29NpVTAaH8eLjAeAwlw46y7uQKy0NYem/gA== - -os-homedir@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" - integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= - -os-tmpdir@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= - -p-cancelable@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.3.0.tgz#b9e123800bcebb7ac13a479be195b507b98d30fa" - integrity sha512-RVbZPLso8+jFeq1MfNvgXtCRED2raz/dKpacfTNxsx6pLEpEomM7gah6VeHSYV3+vo0OAi4MkArtQcWWXuQoyw== - -p-cancelable@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc" - integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw== - -p-finally@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= - -p-timeout@^1.1.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-1.2.1.tgz#5eb3b353b7fce99f101a1038880bb054ebbea386" - integrity sha1-XrOzU7f86Z8QGhA4iAuwVOu+o4Y= - dependencies: - p-finally "^1.0.0" - -parse-asn1@^5.0.0, parse-asn1@^5.1.5: - version "5.1.5" - resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.5.tgz#003271343da58dc94cace494faef3d2147ecea0e" - integrity sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ== - dependencies: - asn1.js "^4.0.0" - browserify-aes "^1.0.0" - create-hash "^1.1.0" - evp_bytestokey "^1.0.0" - pbkdf2 "^3.0.3" - safe-buffer "^5.1.1" - -parse-headers@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/parse-headers/-/parse-headers-2.0.3.tgz#5e8e7512383d140ba02f0c7aa9f49b4399c92515" - integrity sha512-QhhZ+DCCit2Coi2vmAKbq5RGTRcQUOE2+REgv8vdyu7MnYx2eZztegqtTx99TZ86GTIwqiy3+4nQTWZ2tgmdCA== - -parseurl@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" - integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== - -path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-parse@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" - integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== - -path-to-regexp@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" - integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w= - -pbkdf2@^3.0.3, pbkdf2@^3.0.9: - version "3.1.1" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.1.tgz#cb8724b0fada984596856d1a6ebafd3584654b94" - integrity sha512-4Ejy1OPxi9f2tt1rRV7Go7zmfDQ+ZectEQz3VGUQhgq62HtIRPDyG/JtnwIxs6x3uNMwo2V7q1fMvKjb+Tnpqg== - dependencies: - create-hash "^1.1.2" - create-hmac "^1.1.4" - ripemd160 "^2.0.1" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -pend@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" - integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA= - -performance-now@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" - integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= - -pify@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" - integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= - -pify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= - -pinkie-promise@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" - integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o= - dependencies: - pinkie "^2.0.0" - -pinkie@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" - integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= - -precond@0.2: - version "0.2.3" - resolved "https://registry.yarnpkg.com/precond/-/precond-0.2.3.tgz#aa9591bcaa24923f1e0f4849d240f47efc1075ac" - integrity sha1-qpWRvKokkj8eD0hJ0kD0fvwQdaw= - -prepend-http@^1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" - integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= - -prepend-http@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" - integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= - -private@^0.1.6, private@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" - integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg== - -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -process@~0.5.1: - version "0.5.2" - resolved "https://registry.yarnpkg.com/process/-/process-0.5.2.tgz#1638d8a8e34c2f440a91db95ab9aeb677fc185cf" - integrity sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8= - -promise-to-callback@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/promise-to-callback/-/promise-to-callback-1.0.0.tgz#5d2a749010bfb67d963598fcd3960746a68feef7" - integrity sha1-XSp0kBC/tn2WNZj805YHRqaP7vc= - dependencies: - is-fn "^1.0.0" - set-immediate-shim "^1.0.1" - -proxy-addr@~2.0.5: - version "2.0.6" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf" - integrity sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw== - dependencies: - forwarded "~0.1.2" - ipaddr.js "1.9.1" - -prr@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" - integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY= - -psl@^1.1.28: - version "1.8.0" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" - integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== - -public-encrypt@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" - integrity sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q== - dependencies: - bn.js "^4.1.0" - browserify-rsa "^4.0.0" - create-hash "^1.1.0" - parse-asn1 "^5.0.0" - randombytes "^2.0.1" - safe-buffer "^5.1.2" - -pump@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" - integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -punycode@2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d" - integrity sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0= - -punycode@^2.1.0, punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -qs@6.7.0: - version "6.7.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" - integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== - -qs@~6.5.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" - integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== - -query-string@^5.0.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb" - integrity sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw== - dependencies: - decode-uri-component "^0.2.0" - object-assign "^4.1.0" - strict-uri-encode "^1.0.0" - -randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.0.6, randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -randomfill@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" - integrity sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw== - dependencies: - randombytes "^2.0.5" - safe-buffer "^5.1.0" - -randomhex@0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/randomhex/-/randomhex-0.1.5.tgz#baceef982329091400f2a2912c6cd02f1094f585" - integrity sha1-us7vmCMpCRQA8qKRLGzQLxCU9YU= - -range-parser@~1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" - integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== - -raw-body@2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332" - integrity sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q== - dependencies: - bytes "3.1.0" - http-errors "1.7.2" - iconv-lite "0.4.24" - unpipe "1.0.0" - -readable-stream@^1.0.33: - version "1.1.14" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" - integrity sha1-fPTFTvZI44EwhMY23SB54WbAgdk= - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -readable-stream@^2.0.0, readable-stream@^2.2.2, readable-stream@^2.2.9, readable-stream@^2.3.0, readable-stream@^2.3.5, readable-stream@~2.3.6: - version "2.3.7" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" - integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -readable-stream@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readable-stream@~1.0.15: - version "1.0.34" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" - integrity sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw= - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -regenerate@^1.2.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.1.tgz#cad92ad8e6b591773485fbe05a485caf4f457e6f" - integrity sha512-j2+C8+NtXQgEKWk49MMP5P/u2GhnahTtVkRIHr5R5lVRlbKvmQ+oS+A5aLKWp2ma5VkT8sh6v+v4hbH0YHR66A== - -regenerator-runtime@^0.11.0: - version "0.11.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" - integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== - -regenerator-runtime@^0.13.4: - version "0.13.5" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz#d878a1d094b4306d10b9096484b33ebd55e26697" - integrity sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA== - -regenerator-transform@^0.10.0: - version "0.10.1" - resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd" - integrity sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q== - dependencies: - babel-runtime "^6.18.0" - babel-types "^6.19.0" - private "^0.1.6" - -regexp.prototype.flags@^1.2.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz#7aba89b3c13a64509dabcf3ca8d9fbb9bdf5cb75" - integrity sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.0-next.1" - -regexpu-core@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" - integrity sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA= - dependencies: - regenerate "^1.2.1" - regjsgen "^0.2.0" - regjsparser "^0.1.4" - -regjsgen@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" - integrity sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc= - -regjsparser@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" - integrity sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw= - dependencies: - jsesc "~0.5.0" - -repeating@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" - integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= - dependencies: - is-finite "^1.0.0" - -request@^2.79.0, request@^2.85.0: - version "2.88.2" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - -resolve@^1.8.1, resolve@~1.17.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" - integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== - dependencies: - path-parse "^1.0.6" - -responselike@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" - integrity sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec= - dependencies: - lowercase-keys "^1.0.0" - -resumer@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759" - integrity sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k= - dependencies: - through "~2.3.4" - -ripemd160@^2.0.0, ripemd160@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" - integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - -rlp@^2.0.0, rlp@^2.2.3: - version "2.2.5" - resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.2.5.tgz#b0577b763e909f21a9dea31b4b235b2393f15ef1" - integrity sha512-y1QxTQOp0OZnjn19FxBmped4p+BSKPHwGndaqrESseyd2xXZtcgR3yuTIosh8CaMaOii9SKIYerBXnV/CpJ3qw== - dependencies: - bn.js "^4.11.1" - -rustbn.js@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/rustbn.js/-/rustbn.js-0.2.0.tgz#8082cb886e707155fd1cb6f23bd591ab8d55d0ca" - integrity sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA== - -safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-event-emitter@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/safe-event-emitter/-/safe-event-emitter-1.0.1.tgz#5b692ef22329ed8f69fdce607e50ca734f6f20af" - integrity sha512-e1wFe99A91XYYxoQbcq2ZJUWurxEyP8vfz7A7vuUe1s95q8r5ebraVaA1BukYJcpM6V16ugWoD9vngi8Ccu5fg== - dependencies: - events "^3.0.0" - -"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -scrypt-js@2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-2.0.3.tgz#bb0040be03043da9a012a2cea9fc9f852cfc87d4" - integrity sha1-uwBAvgMEPamgEqLOqfyfhSz8h9Q= - -scrypt-js@^3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312" - integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== - -scryptsy@2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/scryptsy/-/scryptsy-2.1.0.tgz#8d1e8d0c025b58fdd25b6fa9a0dc905ee8faa790" - integrity sha512-1CdSqHQowJBnMAFyPEBRfqag/YP9OF394FV+4YREIJX4ljD7OxvQRDayyoyyCk+senRjSkP6VnUNQmVQqB6g7w== - -scryptsy@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/scryptsy/-/scryptsy-1.2.1.tgz#a3225fa4b2524f802700761e2855bdf3b2d92163" - integrity sha1-oyJfpLJST4AnAHYeKFW987LZIWM= - dependencies: - pbkdf2 "^3.0.3" - -secp256k1@^3.0.1: - version "3.8.0" - resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-3.8.0.tgz#28f59f4b01dbee9575f56a47034b7d2e3b3b352d" - integrity sha512-k5ke5avRZbtl9Tqx/SA7CbY3NF6Ro+Sj9cZxezFzuBlLDmyqPiL8hJJ+EmzD8Ig4LUDByHJ3/iPOVoRixs/hmw== - dependencies: - bindings "^1.5.0" - bip66 "^1.1.5" - bn.js "^4.11.8" - create-hash "^1.2.0" - drbg.js "^1.0.1" - elliptic "^6.5.2" - nan "^2.14.0" - safe-buffer "^5.1.2" - -seek-bzip@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/seek-bzip/-/seek-bzip-1.0.5.tgz#cfe917cb3d274bcffac792758af53173eb1fabdc" - integrity sha1-z+kXyz0nS8/6x5J1ivUxc+sfq9w= - dependencies: - commander "~2.8.1" - -semaphore@>=1.0.1, semaphore@^1.0.3: - version "1.1.0" - resolved "https://registry.yarnpkg.com/semaphore/-/semaphore-1.1.0.tgz#aaad8b86b20fe8e9b32b16dc2ee682a8cd26a8aa" - integrity sha512-O4OZEaNtkMd/K0i6js9SL+gqy0ZCBMgUvlSqHKi4IBdjhe7wB8pwztUk1BbZ1fmrvpwFrPbHzqd2w5pTcJH6LA== - -semver@6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.2.0.tgz#4d813d9590aaf8a9192693d6c85b9344de5901db" - integrity sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A== - -semver@^5.3.0, semver@^5.5.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -semver@~5.4.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" - integrity sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg== - -send@0.17.1: - version "0.17.1" - resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8" - integrity sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg== - dependencies: - debug "2.6.9" - depd "~1.1.2" - destroy "~1.0.4" - encodeurl "~1.0.2" - escape-html "~1.0.3" - etag "~1.8.1" - fresh "0.5.2" - http-errors "~1.7.2" - mime "1.6.0" - ms "2.1.1" - on-finished "~2.3.0" - range-parser "~1.2.1" - statuses "~1.5.0" - -serve-static@1.14.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9" - integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg== - dependencies: - encodeurl "~1.0.2" - escape-html "~1.0.3" - parseurl "~1.3.3" - send "0.17.1" - -servify@^0.1.12: - version "0.1.12" - resolved "https://registry.yarnpkg.com/servify/-/servify-0.1.12.tgz#142ab7bee1f1d033b66d0707086085b17c06db95" - integrity sha512-/xE6GvsKKqyo1BAY+KxOWXcLpPsUUyji7Qg3bVD7hh1eRze5bR1uYiuDA/k3Gof1s9BTzQZEJK8sNcNGFIzeWw== - dependencies: - body-parser "^1.16.0" - cors "^2.8.1" - express "^4.14.0" - request "^2.79.0" - xhr "^2.3.3" - -set-immediate-shim@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" - integrity sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E= - -setimmediate@1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.4.tgz#20e81de622d4a02588ce0c8da8973cbcf1d3138f" - integrity sha1-IOgd5iLUoCWIzgyNqJc8vPHTE48= - -setimmediate@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= - -setprototypeof@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" - integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw== - -sha.js@^2.4.0, sha.js@^2.4.8: - version "2.4.11" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" - integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -simple-concat@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6" - integrity sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY= - -simple-get@^2.7.0: - version "2.8.1" - resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-2.8.1.tgz#0e22e91d4575d87620620bc91308d57a77f44b5d" - integrity sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw== - dependencies: - decompress-response "^3.3.0" - once "^1.3.1" - simple-concat "^1.0.0" - -slash@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" - integrity sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU= - -source-map-support@^0.4.15: - version "0.4.18" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" - integrity sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA== - dependencies: - source-map "^0.5.6" - -source-map-support@^0.5.19: - version "0.5.19" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" - integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.5.6, source-map@^0.5.7: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -source-map@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -sshpk@^1.7.0: - version "1.16.1" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877" - integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg== - dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - bcrypt-pbkdf "^1.0.0" - dashdash "^1.12.0" - ecc-jsbn "~0.1.1" - getpass "^0.1.1" - jsbn "~0.1.0" - safer-buffer "^2.0.2" - tweetnacl "~0.14.0" - -"statuses@>= 1.5.0 < 2", statuses@~1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" - integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= - -strict-uri-encode@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" - integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM= - -string.prototype.trim@~1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.2.1.tgz#141233dff32c82bfad80684d7e5f0869ee0fb782" - integrity sha512-MjGFEeqixw47dAMFMtgUro/I0+wNqZB5GKXGt1fFr24u3TzDXCPu7J9Buppzoe3r/LqkSDLDDJzE15RGWDGAVw== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.0-next.1" - function-bind "^1.1.1" - -string.prototype.trimend@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" - integrity sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - -string.prototype.trimstart@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" - integrity sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -string_decoder@~0.10.x: - version "0.10.31" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" - integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ= - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - -strip-ansi@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= - dependencies: - ansi-regex "^2.0.0" - -strip-dirs@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/strip-dirs/-/strip-dirs-2.1.0.tgz#4987736264fc344cf20f6c34aca9d13d1d4ed6c5" - integrity sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g== - dependencies: - is-natural-number "^4.0.1" - -strip-hex-prefix@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz#0c5f155fef1151373377de9dbb588da05500e36f" - integrity sha1-DF8VX+8RUTczd96du1iNoFUA428= - dependencies: - is-hex-prefixed "1.0.0" - -supports-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= - -swarm-js@0.1.39: - version "0.1.39" - resolved "https://registry.yarnpkg.com/swarm-js/-/swarm-js-0.1.39.tgz#79becb07f291d4b2a178c50fee7aa6e10342c0e8" - integrity sha512-QLMqL2rzF6n5s50BptyD6Oi0R1aWlJC5Y17SRIVXRj6OR1DRIPM7nepvrxxkjA1zNzFz6mUOMjfeqeDaWB7OOg== - dependencies: - bluebird "^3.5.0" - buffer "^5.0.5" - decompress "^4.0.0" - eth-lib "^0.1.26" - fs-extra "^4.0.2" - got "^7.1.0" - mime-types "^2.1.16" - mkdirp-promise "^5.0.1" - mock-fs "^4.1.0" - setimmediate "^1.0.5" - tar "^4.0.2" - xhr-request-promise "^0.1.2" - -swarm-js@^0.1.40: - version "0.1.40" - resolved "https://registry.npmjs.org/swarm-js/-/swarm-js-0.1.40.tgz#b1bc7b6dcc76061f6c772203e004c11997e06b99" - integrity sha512-yqiOCEoA4/IShXkY3WKwP5PvZhmoOOD8clsKA7EEcRILMkTEYHCQ21HDCAcVpmIxZq4LyZvWeRJ6quIyHk1caA== - dependencies: - bluebird "^3.5.0" - buffer "^5.0.5" - eth-lib "^0.1.26" - fs-extra "^4.0.2" - got "^7.1.0" - mime-types "^2.1.16" - mkdirp-promise "^5.0.1" - mock-fs "^4.1.0" - setimmediate "^1.0.5" - tar "^4.0.2" - xhr-request "^1.0.1" - -tape@^4.6.3: - version "4.13.3" - resolved "https://registry.yarnpkg.com/tape/-/tape-4.13.3.tgz#51b3d91c83668c7a45b1a594b607dee0a0b46278" - integrity sha512-0/Y20PwRIUkQcTCSi4AASs+OANZZwqPKaipGCEwp10dQMipVvSZwUUCi01Y/OklIGyHKFhIcjock+DKnBfLAFw== - dependencies: - deep-equal "~1.1.1" - defined "~1.0.0" - dotignore "~0.1.2" - for-each "~0.3.3" - function-bind "~1.1.1" - glob "~7.1.6" - has "~1.0.3" - inherits "~2.0.4" - is-regex "~1.0.5" - minimist "~1.2.5" - object-inspect "~1.7.0" - resolve "~1.17.0" - resumer "~0.0.0" - string.prototype.trim "~1.2.1" - through "~2.3.8" - -tar-stream@^1.5.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.6.2.tgz#8ea55dab37972253d9a9af90fdcd559ae435c555" - integrity sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A== - dependencies: - bl "^1.0.0" - buffer-alloc "^1.2.0" - end-of-stream "^1.0.0" - fs-constants "^1.0.0" - readable-stream "^2.3.0" - to-buffer "^1.1.1" - xtend "^4.0.0" - -tar@^4.0.2: - version "4.4.13" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" - integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== - dependencies: - chownr "^1.1.1" - fs-minipass "^1.2.5" - minipass "^2.8.6" - minizlib "^1.2.1" - mkdirp "^0.5.0" - safe-buffer "^5.1.2" - yallist "^3.0.3" - -through2@^2.0.3: - version "2.0.5" - resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" - integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== - dependencies: - readable-stream "~2.3.6" - xtend "~4.0.1" - -through@^2.3.8, through@~2.3.4, through@~2.3.8: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -timed-out@^4.0.0, timed-out@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" - integrity sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8= - -to-buffer@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80" - integrity sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg== - -to-fast-properties@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" - integrity sha1-uDVx+k2MJbguIxsG46MFXeTKGkc= - -to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= - -to-readable-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/to-readable-stream/-/to-readable-stream-1.0.0.tgz#ce0aa0c2f3df6adf852efb404a783e77c0475771" - integrity sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q== - -toidentifier@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" - integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== - -tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - -trim-right@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" - integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= - -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" - integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= - dependencies: - safe-buffer "^5.0.1" - -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" - integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= - -type-is@~1.6.17, type-is@~1.6.18: - version "1.6.18" - resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" - integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== - dependencies: - media-typer "0.3.0" - mime-types "~2.1.24" - -type@^1.0.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/type/-/type-1.2.0.tgz#848dd7698dafa3e54a6c479e759c4bc3f18847a0" - integrity sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg== - -type@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/type/-/type-2.0.0.tgz#5f16ff6ef2eb44f260494dae271033b29c09a9c3" - integrity sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow== - -typedarray-to-buffer@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" - integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q== - dependencies: - is-typedarray "^1.0.0" - -typedarray@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= - -ultron@~1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" - integrity sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og== - -unbzip2-stream@^1.0.9: - version "1.4.3" - resolved "https://registry.yarnpkg.com/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz#b0da04c4371311df771cdc215e87f2130991ace7" - integrity sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg== - dependencies: - buffer "^5.2.1" - through "^2.3.8" - -underscore@1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.1.tgz#06dce34a0e68a7babc29b365b8e74b8925203961" - integrity sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg== - -universalify@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== - -unorm@^1.3.3: - version "1.6.0" - resolved "https://registry.yarnpkg.com/unorm/-/unorm-1.6.0.tgz#029b289661fba714f1a9af439eb51d9b16c205af" - integrity sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA== - -unpipe@1.0.0, unpipe@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" - integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= - -uri-js@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" - integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== - dependencies: - punycode "^2.1.0" - -url-parse-lax@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" - integrity sha1-evjzA2Rem9eaJy56FKxovAYJ2nM= - dependencies: - prepend-http "^1.0.1" - -url-parse-lax@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c" - integrity sha1-FrXK/Afb42dsGxmZF3gj1lA6yww= - dependencies: - prepend-http "^2.0.0" - -url-set-query@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/url-set-query/-/url-set-query-1.0.0.tgz#016e8cfd7c20ee05cafe7795e892bd0702faa339" - integrity sha1-AW6M/Xwg7gXK/neV6JK9BwL6ozk= - -url-to-options@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/url-to-options/-/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9" - integrity sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k= - -utf-8-validate@^5.0.2: - version "5.0.2" - resolved "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.2.tgz#63cfbccd85dc1f2b66cf7a1d0eebc08ed056bfb3" - integrity sha512-SwV++i2gTD5qh2XqaPzBnNX88N6HdyhQrNNRykvcS0QKvItV9u3vPEJr+X5Hhfb1JC0r0e1alL0iB09rY8+nmw== - dependencies: - node-gyp-build "~3.7.0" - -utf8@3.0.0, utf8@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1" - integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ== - -util-deprecate@^1.0.1, util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -utils-merge@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" - integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= - -uuid@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.1.tgz#c2a30dedb3e535d72ccf82e343941a50ba8533ac" - integrity sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w= - -uuid@3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" - integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== - -uuid@^3.3.2: - version "3.4.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" - integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== - -varint@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/varint/-/varint-5.0.0.tgz#d826b89f7490732fabc0c0ed693ed475dcb29ebf" - integrity sha1-2Ca4n3SQcy+rwMDtaT7Uddyynr8= - -vary@^1, vary@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" - integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= - -verror@1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" - integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= - dependencies: - assert-plus "^1.0.0" - core-util-is "1.0.2" - extsprintf "^1.2.0" - -web3-bzz@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-bzz/-/web3-bzz-1.2.1.tgz#c3bd1e8f0c02a13cd6d4e3c3e9e1713f144f6f0d" - integrity sha512-LdOO44TuYbGIPfL4ilkuS89GQovxUpmLz6C1UC7VYVVRILeZS740FVB3j9V4P4FHUk1RenaDfKhcntqgVCHtjw== - dependencies: - got "9.6.0" - swarm-js "0.1.39" - underscore "1.9.1" - -web3-bzz@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-bzz/-/web3-bzz-1.2.11.tgz#41bc19a77444bd5365744596d778b811880f707f" - integrity sha512-XGpWUEElGypBjeFyUhTkiPXFbDVD6Nr/S5jznE3t8cWUA0FxRf1n3n/NuIZeb0H9RkN2Ctd/jNma/k8XGa3YKg== - dependencies: - "@types/node" "^12.12.6" - got "9.6.0" - swarm-js "^0.1.40" - underscore "1.9.1" - -web3-core-helpers@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-1.2.1.tgz#f5f32d71c60a4a3bd14786118e633ce7ca6d5d0d" - integrity sha512-Gx3sTEajD5r96bJgfuW377PZVFmXIH4TdqDhgGwd2lZQCcMi+DA4TgxJNJGxn0R3aUVzyyE76j4LBrh412mXrw== - dependencies: - underscore "1.9.1" - web3-eth-iban "1.2.1" - web3-utils "1.2.1" - -web3-core-helpers@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.2.11.tgz#84c681ed0b942c0203f3b324a245a127e8c67a99" - integrity sha512-PEPoAoZd5ME7UfbnCZBdzIerpe74GEvlwT4AjOmHeCVZoIFk7EqvOZDejJHt+feJA6kMVTdd0xzRNN295UhC1A== - dependencies: - underscore "1.9.1" - web3-eth-iban "1.2.11" - web3-utils "1.2.11" - -web3-core-method@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-1.2.1.tgz#9df1bafa2cd8be9d9937e01c6a47fc768d15d90a" - integrity sha512-Ghg2WS23qi6Xj8Od3VCzaImLHseEA7/usvnOItluiIc5cKs00WYWsNy2YRStzU9a2+z8lwQywPYp0nTzR/QXdQ== - dependencies: - underscore "1.9.1" - web3-core-helpers "1.2.1" - web3-core-promievent "1.2.1" - web3-core-subscriptions "1.2.1" - web3-utils "1.2.1" - -web3-core-method@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.2.11.tgz#f880137d1507a0124912bf052534f168b8d8fbb6" - integrity sha512-ff0q76Cde94HAxLDZ6DbdmKniYCQVtvuaYh+rtOUMB6kssa5FX0q3vPmixi7NPooFnbKmmZCM6NvXg4IreTPIw== - dependencies: - "@ethersproject/transactions" "^5.0.0-beta.135" - underscore "1.9.1" - web3-core-helpers "1.2.11" - web3-core-promievent "1.2.11" - web3-core-subscriptions "1.2.11" - web3-utils "1.2.11" - -web3-core-promievent@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-core-promievent/-/web3-core-promievent-1.2.1.tgz#003e8a3eb82fb27b6164a6d5b9cad04acf733838" - integrity sha512-IVUqgpIKoeOYblwpex4Hye6npM0aMR+kU49VP06secPeN0rHMyhGF0ZGveWBrGvf8WDPI7jhqPBFIC6Jf3Q3zw== - dependencies: - any-promise "1.3.0" - eventemitter3 "3.1.2" - -web3-core-promievent@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.2.11.tgz#51fe97ca0ddec2f99bf8c3306a7a8e4b094ea3cf" - integrity sha512-il4McoDa/Ox9Agh4kyfQ8Ak/9ABYpnF8poBLL33R/EnxLsJOGQG2nZhkJa3I067hocrPSjEdlPt/0bHXsln4qA== - dependencies: - eventemitter3 "4.0.4" - -web3-core-requestmanager@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-core-requestmanager/-/web3-core-requestmanager-1.2.1.tgz#fa2e2206c3d738db38db7c8fe9c107006f5c6e3d" - integrity sha512-xfknTC69RfYmLKC+83Jz73IC3/sS2ZLhGtX33D4Q5nQ8yc39ElyAolxr9sJQS8kihOcM6u4J+8gyGMqsLcpIBg== - dependencies: - underscore "1.9.1" - web3-core-helpers "1.2.1" - web3-providers-http "1.2.1" - web3-providers-ipc "1.2.1" - web3-providers-ws "1.2.1" - -web3-core-requestmanager@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.2.11.tgz#fe6eb603fbaee18530293a91f8cf26d8ae28c45a" - integrity sha512-oFhBtLfOiIbmfl6T6gYjjj9igOvtyxJ+fjS+byRxiwFJyJ5BQOz4/9/17gWR1Cq74paTlI7vDGxYfuvfE/mKvA== - dependencies: - underscore "1.9.1" - web3-core-helpers "1.2.11" - web3-providers-http "1.2.11" - web3-providers-ipc "1.2.11" - web3-providers-ws "1.2.11" - -web3-core-subscriptions@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-core-subscriptions/-/web3-core-subscriptions-1.2.1.tgz#8c2368a839d4eec1c01a4b5650bbeb82d0e4a099" - integrity sha512-nmOwe3NsB8V8UFsY1r+sW6KjdOS68h8nuh7NzlWxBQT/19QSUGiERRTaZXWu5BYvo1EoZRMxCKyCQpSSXLc08g== - dependencies: - eventemitter3 "3.1.2" - underscore "1.9.1" - web3-core-helpers "1.2.1" - -web3-core-subscriptions@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.2.11.tgz#beca908fbfcb050c16f45f3f0f4c205e8505accd" - integrity sha512-qEF/OVqkCvQ7MPs1JylIZCZkin0aKK9lDxpAtQ1F8niEDGFqn7DT8E/vzbIa0GsOjL2fZjDhWJsaW+BSoAW1gg== - dependencies: - eventemitter3 "4.0.4" - underscore "1.9.1" - web3-core-helpers "1.2.11" - -web3-core@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-1.2.1.tgz#7278b58fb6495065e73a77efbbce781a7fddf1a9" - integrity sha512-5ODwIqgl8oIg/0+Ai4jsLxkKFWJYE0uLuE1yUKHNVCL4zL6n3rFjRMpKPokd6id6nJCNgeA64KdWQ4XfpnjdMg== - dependencies: - web3-core-helpers "1.2.1" - web3-core-method "1.2.1" - web3-core-requestmanager "1.2.1" - web3-utils "1.2.1" - -web3-core@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-core/-/web3-core-1.2.11.tgz#1043cacc1becb80638453cc5b2a14be9050288a7" - integrity sha512-CN7MEYOY5ryo5iVleIWRE3a3cZqVaLlIbIzDPsvQRUfzYnvzZQRZBm9Mq+ttDi2STOOzc1MKylspz/o3yq/LjQ== - dependencies: - "@types/bn.js" "^4.11.5" - "@types/node" "^12.12.6" - bignumber.js "^9.0.0" - web3-core-helpers "1.2.11" - web3-core-method "1.2.11" - web3-core-requestmanager "1.2.11" - web3-utils "1.2.11" - -web3-eth-abi@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-eth-abi/-/web3-eth-abi-1.2.1.tgz#9b915b1c9ebf82f70cca631147035d5419064689" - integrity sha512-jI/KhU2a/DQPZXHjo2GW0myEljzfiKOn+h1qxK1+Y9OQfTcBMxrQJyH5AP89O6l6NZ1QvNdq99ThAxBFoy5L+g== - dependencies: - ethers "4.0.0-beta.3" - underscore "1.9.1" - web3-utils "1.2.1" - -web3-eth-abi@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.2.11.tgz#a887494e5d447c2926d557a3834edd66e17af9b0" - integrity sha512-PkRYc0+MjuLSgg03QVWqWlQivJqRwKItKtEpRUaxUAeLE7i/uU39gmzm2keHGcQXo3POXAbOnMqkDvOep89Crg== - dependencies: - "@ethersproject/abi" "5.0.0-beta.153" - underscore "1.9.1" - web3-utils "1.2.11" - -web3-eth-accounts@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-eth-accounts/-/web3-eth-accounts-1.2.1.tgz#2741a8ef337a7219d57959ac8bd118b9d68d63cf" - integrity sha512-26I4qq42STQ8IeKUyur3MdQ1NzrzCqPsmzqpux0j6X/XBD7EjZ+Cs0lhGNkSKH5dI3V8CJasnQ5T1mNKeWB7nQ== - dependencies: - any-promise "1.3.0" - crypto-browserify "3.12.0" - eth-lib "0.2.7" - scryptsy "2.1.0" - semver "6.2.0" - underscore "1.9.1" - uuid "3.3.2" - web3-core "1.2.1" - web3-core-helpers "1.2.1" - web3-core-method "1.2.1" - web3-utils "1.2.1" - -web3-eth-accounts@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.2.11.tgz#a9e3044da442d31903a7ce035a86d8fa33f90520" - integrity sha512-6FwPqEpCfKIh3nSSGeo3uBm2iFSnFJDfwL3oS9pyegRBXNsGRVpgiW63yhNzL0796StsvjHWwQnQHsZNxWAkGw== - dependencies: - crypto-browserify "3.12.0" - eth-lib "0.2.8" - ethereumjs-common "^1.3.2" - ethereumjs-tx "^2.1.1" - scrypt-js "^3.0.1" - underscore "1.9.1" - uuid "3.3.2" - web3-core "1.2.11" - web3-core-helpers "1.2.11" - web3-core-method "1.2.11" - web3-utils "1.2.11" - -web3-eth-contract@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-eth-contract/-/web3-eth-contract-1.2.1.tgz#3542424f3d341386fd9ff65e78060b85ac0ea8c4" - integrity sha512-kYFESbQ3boC9bl2rYVghj7O8UKMiuKaiMkxvRH5cEDHil8V7MGEGZNH0slSdoyeftZVlaWSMqkRP/chfnKND0g== - dependencies: - underscore "1.9.1" - web3-core "1.2.1" - web3-core-helpers "1.2.1" - web3-core-method "1.2.1" - web3-core-promievent "1.2.1" - web3-core-subscriptions "1.2.1" - web3-eth-abi "1.2.1" - web3-utils "1.2.1" - -web3-eth-contract@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-eth-contract/-/web3-eth-contract-1.2.11.tgz#917065902bc27ce89da9a1da26e62ef663663b90" - integrity sha512-MzYuI/Rq2o6gn7vCGcnQgco63isPNK5lMAan2E51AJLknjSLnOxwNY3gM8BcKoy4Z+v5Dv00a03Xuk78JowFow== - dependencies: - "@types/bn.js" "^4.11.5" - underscore "1.9.1" - web3-core "1.2.11" - web3-core-helpers "1.2.11" - web3-core-method "1.2.11" - web3-core-promievent "1.2.11" - web3-core-subscriptions "1.2.11" - web3-eth-abi "1.2.11" - web3-utils "1.2.11" - -web3-eth-ens@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-eth-ens/-/web3-eth-ens-1.2.1.tgz#a0e52eee68c42a8b9865ceb04e5fb022c2d971d5" - integrity sha512-lhP1kFhqZr2nnbu3CGIFFrAnNxk2veXpOXBY48Tub37RtobDyHijHgrj+xTh+mFiPokyrapVjpFsbGa+Xzye4Q== - dependencies: - eth-ens-namehash "2.0.8" - underscore "1.9.1" - web3-core "1.2.1" - web3-core-helpers "1.2.1" - web3-core-promievent "1.2.1" - web3-eth-abi "1.2.1" - web3-eth-contract "1.2.1" - web3-utils "1.2.1" - -web3-eth-ens@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-eth-ens/-/web3-eth-ens-1.2.11.tgz#26d4d7f16d6cbcfff918e39832b939edc3162532" - integrity sha512-dbW7dXP6HqT1EAPvnniZVnmw6TmQEKF6/1KgAxbo8iBBYrVTMDGFQUUnZ+C4VETGrwwaqtX4L9d/FrQhZ6SUiA== - dependencies: - content-hash "^2.5.2" - eth-ens-namehash "2.0.8" - underscore "1.9.1" - web3-core "1.2.11" - web3-core-helpers "1.2.11" - web3-core-promievent "1.2.11" - web3-eth-abi "1.2.11" - web3-eth-contract "1.2.11" - web3-utils "1.2.11" - -web3-eth-iban@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-1.2.1.tgz#2c3801718946bea24e9296993a975c80b5acf880" - integrity sha512-9gkr4QPl1jCU+wkgmZ8EwODVO3ovVj6d6JKMos52ggdT2YCmlfvFVF6wlGLwi0VvNa/p+0BjJzaqxnnG/JewjQ== - dependencies: - bn.js "4.11.8" - web3-utils "1.2.1" - -web3-eth-iban@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.2.11.tgz#f5f73298305bc7392e2f188bf38a7362b42144ef" - integrity sha512-ozuVlZ5jwFC2hJY4+fH9pIcuH1xP0HEFhtWsR69u9uDIANHLPQQtWYmdj7xQ3p2YT4bQLq/axKhZi7EZVetmxQ== - dependencies: - bn.js "^4.11.9" - web3-utils "1.2.11" - -web3-eth-personal@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-eth-personal/-/web3-eth-personal-1.2.1.tgz#244e9911b7b482dc17c02f23a061a627c6e47faf" - integrity sha512-RNDVSiaSoY4aIp8+Hc7z+X72H7lMb3fmAChuSBADoEc7DsJrY/d0R5qQDK9g9t2BO8oxgLrLNyBP/9ub2Hc6Bg== - dependencies: - web3-core "1.2.1" - web3-core-helpers "1.2.1" - web3-core-method "1.2.1" - web3-net "1.2.1" - web3-utils "1.2.1" - -web3-eth-personal@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.2.11.tgz#a38b3942a1d87a62070ce0622a941553c3d5aa70" - integrity sha512-42IzUtKq9iHZ8K9VN0vAI50iSU9tOA1V7XU2BhF/tb7We2iKBVdkley2fg26TxlOcKNEHm7o6HRtiiFsVK4Ifw== - dependencies: - "@types/node" "^12.12.6" - web3-core "1.2.11" - web3-core-helpers "1.2.11" - web3-core-method "1.2.11" - web3-net "1.2.11" - web3-utils "1.2.11" - -web3-eth@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-eth/-/web3-eth-1.2.1.tgz#b9989e2557c73a9e8ffdc107c6dafbe72c79c1b0" - integrity sha512-/2xly4Yry5FW1i+uygPjhfvgUP/MS/Dk+PDqmzp5M88tS86A+j8BzKc23GrlA8sgGs0645cpZK/999LpEF5UdA== - dependencies: - underscore "1.9.1" - web3-core "1.2.1" - web3-core-helpers "1.2.1" - web3-core-method "1.2.1" - web3-core-subscriptions "1.2.1" - web3-eth-abi "1.2.1" - web3-eth-accounts "1.2.1" - web3-eth-contract "1.2.1" - web3-eth-ens "1.2.1" - web3-eth-iban "1.2.1" - web3-eth-personal "1.2.1" - web3-net "1.2.1" - web3-utils "1.2.1" - -web3-eth@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-eth/-/web3-eth-1.2.11.tgz#4c81fcb6285b8caf544058fba3ae802968fdc793" - integrity sha512-REvxW1wJ58AgHPcXPJOL49d1K/dPmuw4LjPLBPStOVkQjzDTVmJEIsiLwn2YeuNDd4pfakBwT8L3bz1G1/wVsQ== - dependencies: - underscore "1.9.1" - web3-core "1.2.11" - web3-core-helpers "1.2.11" - web3-core-method "1.2.11" - web3-core-subscriptions "1.2.11" - web3-eth-abi "1.2.11" - web3-eth-accounts "1.2.11" - web3-eth-contract "1.2.11" - web3-eth-ens "1.2.11" - web3-eth-iban "1.2.11" - web3-eth-personal "1.2.11" - web3-net "1.2.11" - web3-utils "1.2.11" - -web3-net@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-net/-/web3-net-1.2.1.tgz#edd249503315dd5ab4fa00220f6509d95bb7ab10" - integrity sha512-Yt1Bs7WgnLESPe0rri/ZoPWzSy55ovioaP35w1KZydrNtQ5Yq4WcrAdhBzcOW7vAkIwrsLQsvA+hrOCy7mNauw== - dependencies: - web3-core "1.2.1" - web3-core-method "1.2.1" - web3-utils "1.2.1" - -web3-net@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-net/-/web3-net-1.2.11.tgz#eda68ef25e5cdb64c96c39085cdb74669aabbe1b" - integrity sha512-sjrSDj0pTfZouR5BSTItCuZ5K/oZPVdVciPQ6981PPPIwJJkCMeVjD7I4zO3qDPCnBjBSbWvVnLdwqUBPtHxyg== - dependencies: - web3-core "1.2.11" - web3-core-method "1.2.11" - web3-utils "1.2.11" - -web3-providers-http@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-providers-http/-/web3-providers-http-1.2.1.tgz#c93ea003a42e7b894556f7e19dd3540f947f5013" - integrity sha512-BDtVUVolT9b3CAzeGVA/np1hhn7RPUZ6YYGB/sYky+GjeO311Yoq8SRDUSezU92x8yImSC2B+SMReGhd1zL+bQ== - dependencies: - web3-core-helpers "1.2.1" - xhr2-cookies "1.1.0" - -web3-providers-http@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.2.11.tgz#1cd03442c61670572d40e4dcdf1faff8bd91e7c6" - integrity sha512-psh4hYGb1+ijWywfwpB2cvvOIMISlR44F/rJtYkRmQ5jMvG4FOCPlQJPiHQZo+2cc3HbktvvSJzIhkWQJdmvrA== - dependencies: - web3-core-helpers "1.2.11" - xhr2-cookies "1.1.0" - -web3-providers-ipc@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-providers-ipc/-/web3-providers-ipc-1.2.1.tgz#017bfc687a8fc5398df2241eb98f135e3edd672c" - integrity sha512-oPEuOCwxVx8L4CPD0TUdnlOUZwGBSRKScCz/Ws2YHdr9Ium+whm+0NLmOZjkjQp5wovQbyBzNa6zJz1noFRvFA== - dependencies: - oboe "2.1.4" - underscore "1.9.1" - web3-core-helpers "1.2.1" - -web3-providers-ipc@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.2.11.tgz#d16d6c9be1be6e0b4f4536c4acc16b0f4f27ef21" - integrity sha512-yhc7Y/k8hBV/KlELxynWjJDzmgDEDjIjBzXK+e0rHBsYEhdCNdIH5Psa456c+l0qTEU2YzycF8VAjYpWfPnBpQ== - dependencies: - oboe "2.1.4" - underscore "1.9.1" - web3-core-helpers "1.2.11" - -web3-providers-ws@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-providers-ws/-/web3-providers-ws-1.2.1.tgz#2d941eaf3d5a8caa3214eff8dc16d96252b842cb" - integrity sha512-oqsQXzu+ejJACVHy864WwIyw+oB21nw/pI65/sD95Zi98+/HQzFfNcIFneF1NC4bVF3VNX4YHTNq2I2o97LAiA== - dependencies: - underscore "1.9.1" - web3-core-helpers "1.2.1" - websocket "github:web3-js/WebSocket-Node#polyfill/globalThis" - -web3-providers-ws@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.2.11.tgz#a1dfd6d9778d840561d9ec13dd453046451a96bb" - integrity sha512-ZxnjIY1Er8Ty+cE4migzr43zA/+72AF1myzsLaU5eVgdsfV7Jqx7Dix1hbevNZDKFlSoEyq/3j/jYalh3So1Zg== - dependencies: - eventemitter3 "4.0.4" - underscore "1.9.1" - web3-core-helpers "1.2.11" - websocket "^1.0.31" - -web3-shh@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-shh/-/web3-shh-1.2.1.tgz#4460e3c1e07faf73ddec24ccd00da46f89152b0c" - integrity sha512-/3Cl04nza5kuFn25bV3FJWa0s3Vafr5BlT933h26xovQ6HIIz61LmvNQlvX1AhFL+SNJOTcQmK1SM59vcyC8bA== - dependencies: - web3-core "1.2.1" - web3-core-method "1.2.1" - web3-core-subscriptions "1.2.1" - web3-net "1.2.1" - -web3-shh@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-shh/-/web3-shh-1.2.11.tgz#f5d086f9621c9a47e98d438010385b5f059fd88f" - integrity sha512-B3OrO3oG1L+bv3E1sTwCx66injW1A8hhwpknDUbV+sw3fehFazA06z9SGXUefuFI1kVs4q2vRi0n4oCcI4dZDg== - dependencies: - web3-core "1.2.11" - web3-core-method "1.2.11" - web3-core-subscriptions "1.2.11" - web3-net "1.2.11" - -web3-utils@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.2.1.tgz#21466e38291551de0ab34558de21512ac4274534" - integrity sha512-Mrcn3l58L+yCKz3zBryM6JZpNruWuT0OCbag8w+reeNROSGVlXzUQkU+gtAwc9JCZ7tKUyg67+2YUGqUjVcyBA== - dependencies: - bn.js "4.11.8" - eth-lib "0.2.7" - ethjs-unit "0.1.6" - number-to-bn "1.7.0" - randomhex "0.1.5" - underscore "1.9.1" - utf8 "3.0.0" - -web3-utils@1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.11.tgz#af1942aead3fb166ae851a985bed8ef2c2d95a82" - integrity sha512-3Tq09izhD+ThqHEaWYX4VOT7dNPdZiO+c/1QMA0s5X2lDFKK/xHJb7cyTRRVzN2LvlHbR7baS1tmQhSua51TcQ== - dependencies: - bn.js "^4.11.9" - eth-lib "0.2.8" - ethereum-bloom-filters "^1.0.6" - ethjs-unit "0.1.6" - number-to-bn "1.7.0" - randombytes "^2.1.0" - underscore "1.9.1" - utf8 "3.0.0" - -web3@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/web3/-/web3-1.2.1.tgz#5d8158bcca47838ab8c2b784a2dee4c3ceb4179b" - integrity sha512-nNMzeCK0agb5i/oTWNdQ1aGtwYfXzHottFP2Dz0oGIzavPMGSKyVlr8ibVb1yK5sJBjrWVnTdGaOC2zKDFuFRw== - dependencies: - web3-bzz "1.2.1" - web3-core "1.2.1" - web3-eth "1.2.1" - web3-eth-personal "1.2.1" - web3-net "1.2.1" - web3-shh "1.2.1" - web3-utils "1.2.1" - -web3@^1.2.11: - version "1.2.11" - resolved "https://registry.npmjs.org/web3/-/web3-1.2.11.tgz#50f458b2e8b11aa37302071c170ed61cff332975" - integrity sha512-mjQ8HeU41G6hgOYm1pmeH0mRAeNKJGnJEUzDMoerkpw7QUQT4exVREgF1MYPvL/z6vAshOXei25LE/t/Bxl8yQ== - dependencies: - web3-bzz "1.2.11" - web3-core "1.2.11" - web3-eth "1.2.11" - web3-eth-personal "1.2.11" - web3-net "1.2.11" - web3-shh "1.2.11" - web3-utils "1.2.11" - -websocket@^1.0.31: - version "1.0.32" - resolved "https://registry.npmjs.org/websocket/-/websocket-1.0.32.tgz#1f16ddab3a21a2d929dec1687ab21cfdc6d3dbb1" - integrity sha512-i4yhcllSP4wrpoPMU2N0TQ/q0O94LRG/eUQjEAamRltjQ1oT1PFFKOG4i877OlJgCG8rw6LrrowJp+TYCEWF7Q== - dependencies: - bufferutil "^4.0.1" - debug "^2.2.0" - es5-ext "^0.10.50" - typedarray-to-buffer "^3.1.5" - utf-8-validate "^5.0.2" - yaeti "^0.0.6" - -"websocket@github:web3-js/WebSocket-Node#polyfill/globalThis": - version "1.0.29" - resolved "https://codeload.github.com/web3-js/WebSocket-Node/tar.gz/ef5ea2f41daf4a2113b80c9223df884b4d56c400" - dependencies: - debug "^2.2.0" - es5-ext "^0.10.50" - nan "^2.14.0" - typedarray-to-buffer "^3.1.5" - yaeti "^0.0.6" - -whatwg-fetch@2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" - integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng== - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -ws@^3.0.0: - version "3.3.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" - integrity sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA== - dependencies: - async-limiter "~1.0.0" - safe-buffer "~5.1.0" - ultron "~1.1.0" - -ws@^5.1.1: - version "5.2.2" - resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.2.tgz#dffef14866b8e8dc9133582514d1befaf96e980f" - integrity sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA== - dependencies: - async-limiter "~1.0.0" - -xhr-request-promise@^0.1.2: - version "0.1.3" - resolved "https://registry.yarnpkg.com/xhr-request-promise/-/xhr-request-promise-0.1.3.tgz#2d5f4b16d8c6c893be97f1a62b0ed4cf3ca5f96c" - integrity sha512-YUBytBsuwgitWtdRzXDDkWAXzhdGB8bYm0sSzMPZT7Z2MBjMSTHFsyCT1yCRATY+XC69DUrQraRAEgcoCRaIPg== - dependencies: - xhr-request "^1.1.0" - -xhr-request@^1.0.1, xhr-request@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/xhr-request/-/xhr-request-1.1.0.tgz#f4a7c1868b9f198723444d82dcae317643f2e2ed" - integrity sha512-Y7qzEaR3FDtL3fP30k9wO/e+FBnBByZeybKOhASsGP30NIkRAAkKD/sCnLvgEfAIEC1rcmK7YG8f4oEnIrrWzA== - dependencies: - buffer-to-arraybuffer "^0.0.5" - object-assign "^4.1.1" - query-string "^5.0.1" - simple-get "^2.7.0" - timed-out "^4.0.1" - url-set-query "^1.0.0" - xhr "^2.0.4" - -xhr2-cookies@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/xhr2-cookies/-/xhr2-cookies-1.1.0.tgz#7d77449d0999197f155cb73b23df72505ed89d48" - integrity sha1-fXdEnQmZGX8VXLc7I99yUF7YnUg= - dependencies: - cookiejar "^2.1.1" - -xhr@^2.0.4, xhr@^2.2.0, xhr@^2.3.3: - version "2.5.0" - resolved "https://registry.yarnpkg.com/xhr/-/xhr-2.5.0.tgz#bed8d1676d5ca36108667692b74b316c496e49dd" - integrity sha512-4nlO/14t3BNUZRXIXfXe+3N6w3s1KoxcJUUURctd64BLRe67E4gRwp4PjywtDY72fXpZ1y6Ch0VZQRY/gMPzzQ== - dependencies: - global "~4.3.0" - is-function "^1.0.1" - parse-headers "^2.0.0" - xtend "^4.0.0" - -xmlhttprequest@1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc" - integrity sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw= - -xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.0, xtend@~4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - -xtend@~2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-2.1.2.tgz#6efecc2a4dad8e6962c4901b337ce7ba87b5d28b" - integrity sha1-bv7MKk2tjmlixJAbM3znuoe10os= - dependencies: - object-keys "~0.4.0" - -yaeti@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/yaeti/-/yaeti-0.0.6.tgz#f26f484d72684cf42bedfb76970aa1608fbf9577" - integrity sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc= - -yallist@^3.0.0, yallist@^3.0.3: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" - integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== - -yauzl@^2.4.2: - version "2.10.0" - resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9" - integrity sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk= - dependencies: - buffer-crc32 "~0.2.3" - fd-slicer "~1.1.0" From 51cbd019ca418b6f42ca937baf0a9e6c950fc19a Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 29 Apr 2021 13:49:09 +0800 Subject: [PATCH 21/64] fix warning --- contracts/ERC721Adaptor.sol | 2 +- contracts/ERC721AdaptorAuthority.sol | 4 +- contracts/ERC721BridgeV2.sol | 8 +- contracts/ERC721Container.sol | 2 +- contracts/InterstellarEncoderV4.sol | 2 +- contracts/Issuing.sol | 2 +- contracts/MintAndBurnAuthority.sol | 2 +- contracts/MintAndBurnAuthorityV2.sol | 2 +- contracts/MintAndBurnMutableAuthority.sol | 2 +- contracts/MultiSigWallet.sol | 131 +++++++++++++--------- contracts/ObjectOwnershipAuthority.sol | 4 +- contracts/ObjectOwnershipAuthorityV2.sol | 4 +- contracts/PolkaPetAdaptor.sol | 8 +- contracts/Proposal.sol | 6 +- contracts/ProposalRegistry.sol | 4 +- contracts/TokenLocationAuthority.sol | 4 +- contracts/TokenUse.sol | 6 +- contracts/TokenUseAuthority.sol | 4 +- contracts/UserPointsAuthority.sol | 2 +- 19 files changed, 113 insertions(+), 86 deletions(-) diff --git a/contracts/ERC721Adaptor.sol b/contracts/ERC721Adaptor.sol index 59af4b2..4c0dc73 100644 --- a/contracts/ERC721Adaptor.sol +++ b/contracts/ERC721Adaptor.sol @@ -68,7 +68,7 @@ contract ERC721Adaptor is PausableDSAuth, SettingIds { // if the convertion is not calculatable, and need to use cache mapping in Bridge. // then .. - function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256) { + function toOriginTokenId(uint256 _mirrorTokenId) public pure returns (uint256) { return (_mirrorTokenId & 0xffffffffffffffffffffffffffffffff); } diff --git a/contracts/ERC721AdaptorAuthority.sol b/contracts/ERC721AdaptorAuthority.sol index 8d2e2b7..b245097 100644 --- a/contracts/ERC721AdaptorAuthority.sol +++ b/contracts/ERC721AdaptorAuthority.sol @@ -10,9 +10,9 @@ contract ERC721AdaptorAuthority { } function canCall( - address _src, address _dst, bytes4 _sig + address _src, address /*_dst*/, bytes4 _sig ) public view returns (bool) { return ( whiteList[_src] && _sig == bytes4(keccak256("approveOriginToken(address,uint256)")) ) || ( whiteList[_src] && _sig == bytes4(keccak256("cacheMirrorTokenId(uint256,uint256)")) ); } -} \ No newline at end of file +} diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 7f6efc2..64fb57f 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -193,11 +193,11 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { } function onERC1155Received( - address operator, + address /*operator*/, address from, uint256 id, uint256 value, - bytes data + bytes /*data*/ ) whenNotPaused() external @@ -208,11 +208,11 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { } function onERC1155BatchReceived( - address operator, + address /*operator*/, address from, uint256[] ids, uint256[] values, - bytes data + bytes /*data*/ ) whenNotPaused() external diff --git a/contracts/ERC721Container.sol b/contracts/ERC721Container.sol index 0717b1c..f534178 100644 --- a/contracts/ERC721Container.sol +++ b/contracts/ERC721Container.sol @@ -75,7 +75,7 @@ contract ERC721Container is Ownable, SettingIds { } - function transferToOtherContainer(uint256 _objectTokenId, uint256 _toContainer) public { + function transferToOtherContainer(uint256 /*_objectTokenId*/, uint256 /*_toContainer*/) public pure { } diff --git a/contracts/InterstellarEncoderV4.sol b/contracts/InterstellarEncoderV4.sol index 827658c..57b1549 100644 --- a/contracts/InterstellarEncoderV4.sol +++ b/contracts/InterstellarEncoderV4.sol @@ -18,7 +18,7 @@ contract InterstellarEncoderV4 is IInterstellarEncoderV4, Ownable { uint256 public CURRENT_LAND; // 1 is Atlantis, 0 is NaN. - constructor(uint256 _chainId, uint256 _currenLand) { + constructor(uint256 _chainId, uint256 _currenLand) public { CHAIN_ID = _chainId; CURRENT_LAND = _currenLand; } diff --git a/contracts/Issuing.sol b/contracts/Issuing.sol index 30d5777..edd9120 100644 --- a/contracts/Issuing.sol +++ b/contracts/Issuing.sol @@ -24,7 +24,7 @@ contract Issuing is PausableDSAuth { mapping(address => bool) public supportedTokens; - constructor(address _registry) { + constructor(address _registry) public { registry = ISettingsRegistry(_registry); } diff --git a/contracts/MintAndBurnAuthority.sol b/contracts/MintAndBurnAuthority.sol index db28d12..1eb2705 100644 --- a/contracts/MintAndBurnAuthority.sol +++ b/contracts/MintAndBurnAuthority.sol @@ -11,7 +11,7 @@ contract MintAndBurnAuthority { } function canCall( - address _src, address _dst, bytes4 _sig + address _src, address /*_dst*/, bytes4 _sig ) public view returns (bool) { return ( whiteList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || ( whiteList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); diff --git a/contracts/MintAndBurnAuthorityV2.sol b/contracts/MintAndBurnAuthorityV2.sol index f894e56..48306d3 100644 --- a/contracts/MintAndBurnAuthorityV2.sol +++ b/contracts/MintAndBurnAuthorityV2.sol @@ -11,7 +11,7 @@ contract MintAndBurnAuthorityV2 { } function canCall( - address _src, address _dst, bytes4 _sig + address _src, address /*_dst*/, bytes4 _sig ) public view returns (bool) { return ( allowList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || ( allowList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); diff --git a/contracts/MintAndBurnMutableAuthority.sol b/contracts/MintAndBurnMutableAuthority.sol index 3d65236..4e94be6 100644 --- a/contracts/MintAndBurnMutableAuthority.sol +++ b/contracts/MintAndBurnMutableAuthority.sol @@ -13,7 +13,7 @@ contract MintAndBurnAuthority is DSAuth { } function canCall( - address _src, address _dst, bytes4 _sig + address _src, address /*_dst*/, bytes4 _sig ) public view returns (bool) { return ( allowList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || ( allowList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); diff --git a/contracts/MultiSigWallet.sol b/contracts/MultiSigWallet.sol index 0ad36bd..7166e7f 100644 --- a/contracts/MultiSigWallet.sol +++ b/contracts/MultiSigWallet.sol @@ -1,22 +1,31 @@ -pragma solidity ^0.4.17; +pragma solidity ^0.4.15; /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. /// @author Stefan George - contract MultiSigWallet { - uint constant public MAX_OWNER_COUNT = 50; + /* + * Events + */ + event Confirmation(address indexed sender, uint indexed transactionId); + event Revocation(address indexed sender, uint indexed transactionId); + event Submission(uint indexed transactionId); + event Execution(uint indexed transactionId); + event ExecutionFailure(uint indexed transactionId); + event Deposit(address indexed sender, uint value); + event OwnerAddition(address indexed owner); + event OwnerRemoval(address indexed owner); + event RequirementChange(uint required); - event Confirmation(address indexed _sender, uint indexed _transactionId); - event Revocation(address indexed _sender, uint indexed _transactionId); - event Submission(uint indexed _transactionId); - event Execution(uint indexed _transactionId); - event ExecutionFailure(uint indexed _transactionId); - event Deposit(address indexed _sender, uint _value); - event OwnerAddition(address indexed _owner); - event OwnerRemoval(address indexed _owner); - event RequirementChange(uint _required); + /* + * Constants + */ + uint constant public MAX_OWNER_COUNT = 50; + /* + * Storage + */ mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; @@ -31,69 +40,64 @@ contract MultiSigWallet { bool executed; } + /* + * Modifiers + */ modifier onlyWallet() { - if (msg.sender != address(this)) - throw; + require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { - if (isOwner[owner]) - throw; + require(!isOwner[owner]); _; } modifier ownerExists(address owner) { - if (!isOwner[owner]) - throw; + require(isOwner[owner]); _; } modifier transactionExists(uint transactionId) { - if (transactions[transactionId].destination == 0) - throw; + require(transactions[transactionId].destination != 0); _; } modifier confirmed(uint transactionId, address owner) { - if (!confirmations[transactionId][owner]) - throw; + require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint transactionId, address owner) { - if (confirmations[transactionId][owner]) - throw; + require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint transactionId) { - if (transactions[transactionId].executed) - throw; + require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { - if (_address == 0) - throw; + require(_address != 0); _; } modifier validRequirement(uint ownerCount, uint _required) { - if ( ownerCount > MAX_OWNER_COUNT - || _required > ownerCount - || _required == 0 - || ownerCount == 0) - throw; + require(ownerCount <= MAX_OWNER_COUNT + && _required <= ownerCount + && _required != 0 + && ownerCount != 0); _; } /// @dev Fallback function allows to deposit ether. function() + public payable { if (msg.value > 0) - Deposit(msg.sender, msg.value); + emit Deposit(msg.sender, msg.value); } /* @@ -102,13 +106,12 @@ contract MultiSigWallet { /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. - function MultiSigWallet(address[] _owners, uint _required) + constructor(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { - if (isOwner[_owners[i]] || _owners[i] == 0) - throw; + require(!isOwner[_owners[i]] && _owners[i] != 0); isOwner[_owners[i]] = true; } owners = _owners; @@ -126,7 +129,7 @@ contract MultiSigWallet { { isOwner[owner] = true; owners.push(owner); - OwnerAddition(owner); + emit OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. @@ -145,12 +148,12 @@ contract MultiSigWallet { owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); - OwnerRemoval(owner); + emit OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. - /// @param owner Address of new owner. + /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet @@ -164,8 +167,8 @@ contract MultiSigWallet { } isOwner[owner] = false; isOwner[newOwner] = true; - OwnerRemoval(owner); - OwnerAddition(newOwner); + emit OwnerRemoval(owner); + emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. @@ -176,7 +179,7 @@ contract MultiSigWallet { validRequirement(owners.length, _required) { required = _required; - RequirementChange(_required); + emit RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. @@ -201,7 +204,7 @@ contract MultiSigWallet { notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; - Confirmation(msg.sender, transactionId); + emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } @@ -214,27 +217,51 @@ contract MultiSigWallet { notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; - Revocation(msg.sender, transactionId); + emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public + ownerExists(msg.sender) + confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { - Transaction tx = transactions[transactionId]; - tx.executed = true; - if (tx.destination.call.value(tx.value)(tx.data)) - Execution(transactionId); + Transaction storage txn = transactions[transactionId]; + txn.executed = true; + if (external_call(txn.destination, txn.value, txn.data.length, txn.data)) + emit Execution(transactionId); else { - ExecutionFailure(transactionId); - tx.executed = false; + emit ExecutionFailure(transactionId); + txn.executed = false; } } } + // call has been separated into its own function in order to take advantage + // of the Solidity's code generator to produce a loop that copies tx.data into memory. + function external_call(address destination, uint value, uint dataLength, bytes data) internal returns (bool) { + bool result; + assembly { + let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) + let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that + result := call( + sub(gas, 34710), // 34710 is the value that solidity is currently emitting + // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) + destination, + value, + d, + dataLength, // Size of the input (in bytes) - this is what fixes the padding problem + x, + 0 // Output is ignored, therefore the output size is zero + ) + } + return result; + } + /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. @@ -273,7 +300,7 @@ contract MultiSigWallet { executed: false }); transactionCount += 1; - Submission(transactionId); + emit Submission(transactionId); } /* @@ -292,7 +319,7 @@ contract MultiSigWallet { count += 1; } - /// @dev Returns total number of transactions after filters are applied. + /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. diff --git a/contracts/ObjectOwnershipAuthority.sol b/contracts/ObjectOwnershipAuthority.sol index a947d2a..f5a0ad9 100644 --- a/contracts/ObjectOwnershipAuthority.sol +++ b/contracts/ObjectOwnershipAuthority.sol @@ -11,9 +11,9 @@ contract ObjectOwnershipAuthority { } function canCall( - address _src, address _dst, bytes4 _sig + address _src, address /*_dst*/, bytes4 _sig ) public view returns (bool) { return ( whiteList[_src] && _sig == bytes4(keccak256("mintObject(address,uint128)")) ) || ( whiteList[_src] && _sig == bytes4(keccak256("burnObject(address,uint128)")) ); } -} \ No newline at end of file +} diff --git a/contracts/ObjectOwnershipAuthorityV2.sol b/contracts/ObjectOwnershipAuthorityV2.sol index aea15a7..ac20e7e 100644 --- a/contracts/ObjectOwnershipAuthorityV2.sol +++ b/contracts/ObjectOwnershipAuthorityV2.sol @@ -11,11 +11,11 @@ contract ObjectOwnershipAuthorityV2 { } function canCall( - address _src, address _dst, bytes4 _sig + address _src, address /*_dst*/, bytes4 _sig ) public view returns (bool) { return ( whiteList[_src] && _sig == bytes4(keccak256("mintObject(address,uint128)")) ) || ( whiteList[_src] && _sig == bytes4(keccak256("burnObject(address,uint128)")) ) || ( whiteList[_src] && _sig == bytes4(keccak256("mint(address,uint256)")) ) || ( whiteList[_src] && _sig == bytes4(keccak256("burn(address,uint256)")) ); } -} \ No newline at end of file +} diff --git a/contracts/PolkaPetAdaptor.sol b/contracts/PolkaPetAdaptor.sol index 5d26968..1653c03 100644 --- a/contracts/PolkaPetAdaptor.sol +++ b/contracts/PolkaPetAdaptor.sol @@ -60,13 +60,13 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { return mirrorTokenId; } - function ownerInOrigin(uint256 _originTokenId) public view returns (address) { + function ownerInOrigin(uint256 /*_originTokenId*/) public pure returns (address) { revert("NOT_SUPPORT"); } // if the convertion is not calculatable, and need to use cache mapping in Bridge. // then .. - function toOriginTokenId(uint256 _mirrorTokenId) public view returns (uint256) { + function toOriginTokenId(uint256 /*_mirrorTokenId*/) public pure returns (uint256) { revert("NOT_SUPPORT"); } @@ -80,11 +80,11 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { IERC1155(objectOwnership).setApprovalForAll(_bridge, false); } - function getObjectClass(uint256 _originTokenId) public view returns (uint8) { + function getObjectClass(uint256 /*_originTokenId*/) public pure returns (uint8) { revert("NOT_SUPPORT"); } - function cacheMirrorTokenId(uint256 _originTokenId, uint256 _mirrorTokenId) public auth { + function cacheMirrorTokenId(uint256 /*_originTokenId*/, uint256 /*_mirrorTokenId*/) public view auth { revert("NOT_SUPPORT"); } } diff --git a/contracts/Proposal.sol b/contracts/Proposal.sol index 4baf513..e9066c9 100644 --- a/contracts/Proposal.sol +++ b/contracts/Proposal.sol @@ -4,12 +4,12 @@ import "./interfaces/IAuthority.sol"; contract Proposal is IAuthority { - function doSomething() public { + function doSomething() public pure { // do changes to destiantion } function canCall( - address src, address dst, bytes4 sig + address src, address /*dst*/, bytes4 /*sig*/ ) public view returns (bool) { if (src == address(this)) @@ -17,4 +17,4 @@ contract Proposal is IAuthority { return true; } } -} \ No newline at end of file +} diff --git a/contracts/ProposalRegistry.sol b/contracts/ProposalRegistry.sol index 313903c..1b5c689 100644 --- a/contracts/ProposalRegistry.sol +++ b/contracts/ProposalRegistry.sol @@ -19,7 +19,7 @@ contract ProposalRegistry is IAuthority { uint public transactionCount; - function executeProposal(uint proposalId) public { + function executeProposal(uint proposalId) public view { // TODO proposals[proposalId].doSomething(); } @@ -33,4 +33,4 @@ contract ProposalRegistry is IAuthority { return Proposal(src).canCall(src, dst, sig); } } -} \ No newline at end of file +} diff --git a/contracts/TokenLocationAuthority.sol b/contracts/TokenLocationAuthority.sol index 6b7b2de..2a915ab 100644 --- a/contracts/TokenLocationAuthority.sol +++ b/contracts/TokenLocationAuthority.sol @@ -11,8 +11,8 @@ contract TokenLocationAuthority { } function canCall( - address _src, address _dst, bytes4 _sig + address _src, address /*_dst*/, bytes4 _sig ) public view returns (bool) { return ( whiteList[_src] && _sig == bytes4(keccak256("setTokenLocationHM(uint256,int256,int256)"))) ; } -} \ No newline at end of file +} diff --git a/contracts/TokenUse.sol b/contracts/TokenUse.sol index 306a734..27c2b2e 100644 --- a/contracts/TokenUse.sol +++ b/contracts/TokenUse.sol @@ -98,7 +98,7 @@ contract TokenUse is DSAuth, ITokenUse, SettingIds { return tokenId2UseStatus[_tokenId].user; } - function receiveApproval(address _from, uint _tokenId, bytes _data) public { + function receiveApproval(address _from, uint _tokenId, bytes /*_data*/) public { if(msg.sender == registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)) { uint256 duration; uint256 price; @@ -191,7 +191,7 @@ contract TokenUse is DSAuth, ITokenUse, SettingIds { } //TODO: allow batch operation - function tokenFallback(address _from, uint256 _value, bytes _data) public { + function tokenFallback(address _from, uint256 _value, bytes /*_data*/) public { address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); if(ring == msg.sender) { uint256 tokenId; @@ -342,4 +342,4 @@ contract TokenUse is DSAuth, ITokenUse, SettingIds { assembly { mstore(add(b, 32), x) } } -} \ No newline at end of file +} diff --git a/contracts/TokenUseAuthority.sol b/contracts/TokenUseAuthority.sol index 507edac..f5770e5 100644 --- a/contracts/TokenUseAuthority.sol +++ b/contracts/TokenUseAuthority.sol @@ -11,9 +11,9 @@ contract TokenUseAuthority { } function canCall( - address _src, address _dst, bytes4 _sig + address _src, address /*_dst*/, bytes4 _sig ) public view returns (bool) { return (whiteList[_src] && _sig == bytes4(keccak256("addActivity(uint256,address,uint256)"))) || ( whiteList[_src] && _sig == bytes4(keccak256("removeActivity(uint256,address)"))); } -} \ No newline at end of file +} diff --git a/contracts/UserPointsAuthority.sol b/contracts/UserPointsAuthority.sol index 4d79ba4..8ad5d9d 100644 --- a/contracts/UserPointsAuthority.sol +++ b/contracts/UserPointsAuthority.sol @@ -10,7 +10,7 @@ contract UserPointsAuthority { } function canCall( - address _src, address _dst, bytes4 _sig + address _src, address /*_dst*/, bytes4 _sig ) public view returns (bool) { return ( whiteList[_src] && _sig == bytes4(keccak256("addPoints(address,uint256)"))) || ( whiteList[_src] && _sig == bytes4(keccak256("subPoints(address,uint256)"))); From af19b4e34e32ab9e1a25dabe0af4b64fbd7fa22c Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 29 Apr 2021 13:50:59 +0800 Subject: [PATCH 22/64] rm migration --- contracts/Migrations.sol | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 contracts/Migrations.sol diff --git a/contracts/Migrations.sol b/contracts/Migrations.sol deleted file mode 100644 index 7b02731..0000000 --- a/contracts/Migrations.sol +++ /dev/null @@ -1,24 +0,0 @@ -pragma solidity ^0.4.23; -// import "@evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol"; - -contract Migrations { - address public owner; - uint public last_completed_migration; - - constructor() public { - owner = msg.sender; - } - - modifier restricted() { - if (msg.sender == owner) _; - } - - function setCompleted(uint completed) public restricted { - last_completed_migration = completed; - } - - function upgrade(address new_address) public restricted { - Migrations upgraded = Migrations(new_address); - upgraded.setCompleted(last_completed_migration); - } -} From 3e309b6c943b65138b65e30064dbe788a2a8be66 Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 29 Apr 2021 15:59:38 +0800 Subject: [PATCH 23/64] add common authority --- contracts/Authority.sol | 33 +++++++++++++++++++++++++++++++++ contracts/DeployAndTest.sol | 19 ------------------- 2 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 contracts/Authority.sol delete mode 100644 contracts/DeployAndTest.sol diff --git a/contracts/Authority.sol b/contracts/Authority.sol new file mode 100644 index 0000000..866c4af --- /dev/null +++ b/contracts/Authority.sol @@ -0,0 +1,33 @@ +pragma solidity ^0.4.24; + +contract Authority { + event Rely(address indexed usr); + event Deny(address indexed usr); + event Allow(bytes4 indexed usr); + event Forbid(bytes4 indexed usr); + event SetRoot(address indexed newRoot); + + address public root; + mapping (address => uint) public wards; + mapping (bytes4 => uint) public sigs; + + modifier sudo { require(msg.sender == root); _; } + function setRoot(address usr) public sudo { root = usr; emit SetRoot(usr); } + function rely(address usr) public sudo { wards[usr] = 1; emit Rely(usr); } + function deny(address usr) public sudo { wards[usr] = 0; emit Deny(usr); } + function allow(bytes4 sig) public sudo { sigs[sig] = 1; emit Allow(sig); } + function forbid(bytes4 sig) public sudo { sigs[sig] = 0; emit Forbid(sig); } + + constructor(address[] _wards, bytes4[] _sigs) public { + root = msg.sender; + emit SetRoot(root); + for (uint i = 0; i < _wards.length; i++) { rely(_wards[i]); } + for (uint j = 0; j < _sigs.length; j++) { allow(_sigs[j]); } + } + + function canCall( + address _src, address, bytes4 _sig + ) public view returns (bool) { + return wards[_src] == 1 && sigs[_sig] == 1; + } +} diff --git a/contracts/DeployAndTest.sol b/contracts/DeployAndTest.sol deleted file mode 100644 index 680350b..0000000 --- a/contracts/DeployAndTest.sol +++ /dev/null @@ -1,19 +0,0 @@ -pragma solidity ^0.4.23; - -import "./StandardERC223.sol"; -import "./SettingsRegistry.sol"; -// import "@evolutionland/upgraeability-using-unstructured-storage/contracts/OwnedUpgradeabilityProxy.sol"; -import "./MintAndBurnAuthority.sol"; - -contract DeployAndTest { - address public testRING = new StandardERC223("RING"); - address public testKTON = new StandardERC223("KTON"); - - constructor() public { - StandardERC223(testRING).changeController(msg.sender); - StandardERC223(testKTON).changeController(msg.sender); - StandardERC223(testRING).setOwner(msg.sender); - StandardERC223(testKTON).setOwner(msg.sender); - } - -} From 7babf42ce6a1277238c4986ae822fef1459046e2 Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 29 Apr 2021 16:33:07 +0800 Subject: [PATCH 24/64] add auth revert msg --- contracts/DSAuth.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/DSAuth.sol b/contracts/DSAuth.sol index 9f34145..57cd7b5 100644 --- a/contracts/DSAuth.sol +++ b/contracts/DSAuth.sol @@ -38,7 +38,7 @@ contract DSAuth is DSAuthEvents { } modifier auth { - require(isAuthorized(msg.sender, msg.sig)); + require(isAuthorized(msg.sender, msg.sig), "ds-auth-unauthorized"); _; } From ed89a59b1dcafc965a1112f885cca89aefde5eea Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 7 May 2021 10:38:00 +0800 Subject: [PATCH 25/64] make flat --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 5775c51..298ab41 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,3 @@ all :; source .env && dapp --use solc:0.4.24 build +flat :; source .env && dapp --use solc:0.4.24 flat clean :; dapp clean From 788f37de4fdc95a3c6dd4cef865b3c502c219a62 Mon Sep 17 00:00:00 2001 From: echo Date: Sat, 8 May 2021 19:32:54 +0800 Subject: [PATCH 26/64] fix tokenuse auth bug --- contracts/TokenUse.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/TokenUse.sol b/contracts/TokenUse.sol index 27c2b2e..9986428 100644 --- a/contracts/TokenUse.sol +++ b/contracts/TokenUse.sol @@ -291,7 +291,7 @@ contract TokenUse is DSAuth, ITokenUse, SettingIds { } - function _removeTokenUse(uint256 _tokenId) public { + function _removeTokenUse(uint256 _tokenId) internal { address owner = tokenId2UseStatus[_tokenId].owner; address user = tokenId2UseStatus[_tokenId].user; From 95bbd2b6cf8479e9dcb3d8752fb8d21ac13a5f9d Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 19 May 2021 17:22:28 +0800 Subject: [PATCH 27/64] bridge: add tiePetToApostle --- contracts/ERC721BridgeV2.sol | 60 +++++++++++++++---------------- contracts/interfaces/IPetBase.sol | 6 ++++ 2 files changed, 34 insertions(+), 32 deletions(-) create mode 100644 contracts/interfaces/IPetBase.sol diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 64fb57f..0a56095 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.4.24; import "./PausableDSAuth.sol"; import "./interfaces/ISettingsRegistry.sol"; @@ -10,6 +10,7 @@ import "./interfaces/INFTAdaptor.sol"; import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; import "./interfaces/IERC1155.sol"; import "./interfaces/IERC1155Receiver.sol"; +import "./interfaces/IPetBase.sol"; /* @@ -114,7 +115,9 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { require(adaptor != address(0), "not registered!"); require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); - // TODO: if it is needed to check its current status + address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); + (uint256 apostleTokenId,) = IPetBase(petBase).pet2TiedStatus(_mirrorTokenId); + require(apostleTokenId == 0, "Pet has been tied."); uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); @@ -132,7 +135,9 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { require(adaptor != address(0), "not registered!"); require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); - // TODO: if it is needed to check its current status + address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); + (uint256 apostleTokenId,) = IPetBase(petBase).pet2TiedStatus(_mirrorTokenId); + require(apostleTokenId == 0, "Pet has been tied."); uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); @@ -177,19 +182,17 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { return (mirrorId2OriginId[_mirrorTokenId] != 0); } - // V2 add - Support PolkaPet - function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from, uint256 _value) private { + function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from) private returns (uint256) { address adaptor = originNFT2Adaptor[msg.sender]; require(adaptor != address(0), "Not registered!"); address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - for (uint256 i = 0; i < _value; i++) { - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); - IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); - emit SwapIn(_originTokenId, mirrorTokenId, _from); - } + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); + IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); + emit SwapIn(_originTokenId, mirrorTokenId, _from); + return mirrorTokenId; } function onERC1155Received( @@ -197,31 +200,24 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { address from, uint256 id, uint256 value, - bytes /*data*/ + bytes data ) whenNotPaused() external returns(bytes4) { - _bridgeIn1155(msg.sender, id, from, value); - return ERC1155_RECEIVED_VALUE; - } - - function onERC1155BatchReceived( - address /*operator*/, - address from, - uint256[] ids, - uint256[] values, - bytes /*data*/ - ) - whenNotPaused() - external - returns(bytes4) - { - require(ids.length == values.length, "INVALID_ARRAYS_LENGTH"); - for (uint256 i = 0; i < ids.length; i++) { - _bridgeIn1155(msg.sender, ids[i], from, values[i]); + require(value == 1, "Value should be one"); + uint256 mirrorTokenId = _bridgeIn1155(msg.sender, id, from); + if (data.length == 32) { + uint256 apostleTokenId; + assembly { + let ptr := mload(0x40) + calldatacopy(ptr, 0, calldatasize) + apostleTokenId := mload(add(ptr, 196)) + } + address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); + IPetBase(petBase).tiePetTokenToApostle(mirrorTokenId, apostleTokenId); } - return ERC1155_BATCH_RECEIVED_VALUE; + return ERC1155_RECEIVED_VALUE; } } diff --git a/contracts/interfaces/IPetBase.sol b/contracts/interfaces/IPetBase.sol new file mode 100644 index 0000000..4782abf --- /dev/null +++ b/contracts/interfaces/IPetBase.sol @@ -0,0 +1,6 @@ +pragma solidity ^0.4.24; + +interface IPetBase { + function tiePetTokenToApostle(uint256 _mirrorTokenId, uint256 _apostleTokenId) external; + function pet2TiedStatus(uint256 _mirrorTokenId) external returns (uint256, uint256); +} From a9d28c337ab482d12310098b2b94e8eee89ba12d Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 19 May 2021 18:30:13 +0800 Subject: [PATCH 28/64] fix compile miss bin --- Makefile | 2 ++ contracts/ERC721BridgeV2.sol | 14 ++++++++++++++ contracts/interfaces/IPetBase.sol | 6 +++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 298ab41..40c3b48 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ all :; source .env && dapp --use solc:0.4.24 build flat :; source .env && dapp --use solc:0.4.24 flat clean :; dapp clean + +.PHONY: all flat clean diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 0a56095..9627f67 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -220,4 +220,18 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { } return ERC1155_RECEIVED_VALUE; } + + function onERC1155BatchReceived( + address, + address, + uint256[], + uint256[], + bytes + ) + external + returns(bytes4) + { + revert("NOT_SUPPORT"); + return ERC1155_RECEIVED_VALUE; + } } diff --git a/contracts/interfaces/IPetBase.sol b/contracts/interfaces/IPetBase.sol index 4782abf..d824962 100644 --- a/contracts/interfaces/IPetBase.sol +++ b/contracts/interfaces/IPetBase.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.24; -interface IPetBase { - function tiePetTokenToApostle(uint256 _mirrorTokenId, uint256 _apostleTokenId) external; - function pet2TiedStatus(uint256 _mirrorTokenId) external returns (uint256, uint256); +contract IPetBase { + function tiePetTokenToApostle(uint256 _mirrorTokenId, uint256 _apostleTokenId) public; + function pet2TiedStatus(uint256 _mirrorTokenId) public returns (uint256, uint256); } From 6d88ca44efba0a1ecfcc493c253f5d000537f5f5 Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 19 May 2021 18:33:56 +0800 Subject: [PATCH 29/64] Update ERC721BridgeV2.sol fmt --- contracts/ERC721BridgeV2.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 9627f67..733270e 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -202,10 +202,10 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { uint256 value, bytes data ) - whenNotPaused() + whenNotPaused() external returns(bytes4) - { + { require(value == 1, "Value should be one"); uint256 mirrorTokenId = _bridgeIn1155(msg.sender, id, from); if (data.length == 32) { @@ -218,8 +218,8 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); IPetBase(petBase).tiePetTokenToApostle(mirrorTokenId, apostleTokenId); } - return ERC1155_RECEIVED_VALUE; - } + return ERC1155_RECEIVED_VALUE; + } function onERC1155BatchReceived( address, @@ -231,7 +231,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { external returns(bytes4) { - revert("NOT_SUPPORT"); - return ERC1155_RECEIVED_VALUE; + revert("NOT_SUPPORT"); + return ERC1155_RECEIVED_VALUE; } } From 70402fef7ea20ff15294c335d0dcb2ac0eb6e16e Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 19 May 2021 19:55:42 +0800 Subject: [PATCH 30/64] bridge: revert to two step --- contracts/ERC721BridgeV2.sol | 62 ++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 733270e..4d6f910 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -183,16 +183,17 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { } // V2 add - Support PolkaPet - function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from) private returns (uint256) { + function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from, uint256 _value) private { address adaptor = originNFT2Adaptor[msg.sender]; require(adaptor != address(0), "Not registered!"); address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); - IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); - emit SwapIn(_originTokenId, mirrorTokenId, _from); - return mirrorTokenId; + for (uint256 i = 0; i < _value; i++) { + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); + IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); + emit SwapIn(_originTokenId, mirrorTokenId, _from); + } } function onERC1155Received( @@ -200,38 +201,31 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { address from, uint256 id, uint256 value, - bytes data + bytes /*data*/ ) - whenNotPaused() + whenNotPaused() external returns(bytes4) - { - require(value == 1, "Value should be one"); - uint256 mirrorTokenId = _bridgeIn1155(msg.sender, id, from); - if (data.length == 32) { - uint256 apostleTokenId; - assembly { - let ptr := mload(0x40) - calldatacopy(ptr, 0, calldatasize) - apostleTokenId := mload(add(ptr, 196)) - } - address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); - IPetBase(petBase).tiePetTokenToApostle(mirrorTokenId, apostleTokenId); - } - return ERC1155_RECEIVED_VALUE; - } + { + _bridgeIn1155(msg.sender, id, from, value); + return ERC1155_RECEIVED_VALUE; + } function onERC1155BatchReceived( - address, - address, - uint256[], - uint256[], - bytes + address /*operator*/, + address from, + uint256[] ids, + uint256[] values, + bytes /*data*/ ) + whenNotPaused() external - returns(bytes4) - { - revert("NOT_SUPPORT"); - return ERC1155_RECEIVED_VALUE; - } + returns(bytes4) + { + require(ids.length == values.length, "INVALID_ARRAYS_LENGTH"); + for (uint256 i = 0; i < ids.length; i++) { + _bridgeIn1155(msg.sender, ids[i], from, values[i]); + } + return ERC1155_BATCH_RECEIVED_VALUE; + } } From fda6a551b1eabfdd96d7c7b913675f5be91620a5 Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 19 May 2021 19:59:42 +0800 Subject: [PATCH 31/64] bridge: fix #49 --- contracts/ERC721BridgeV2.sol | 21 +-------------------- contracts/interfaces/IPetBase.sol | 1 - 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 4d6f910..d233fb3 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -109,7 +109,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { function swapOut(uint256 _mirrorTokenId) public { IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); + address nftContract = interstellarEncoder.getOriginAddress(_mirrorTokenId); require(nftContract != address(0), "No such NFT contract"); address adaptor = originNFT2Adaptor[nftContract]; require(adaptor != address(0), "not registered!"); @@ -126,25 +126,6 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); } - // V2 add - Support PolkaPet - function swapOut1155(uint256 _mirrorTokenId) public { - IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - address nftContract = interstellarEncoder.getOriginAddress(_mirrorTokenId); - require(nftContract != address(0), "No such NFT contract"); - address adaptor = originNFT2Adaptor[nftContract]; - require(adaptor != address(0), "not registered!"); - require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); - - address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); - (uint256 apostleTokenId,) = IPetBase(petBase).pet2TiedStatus(_mirrorTokenId); - require(apostleTokenId == 0, "Pet has been tied."); - uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); - IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); - emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); - } - function approveOriginToken(address _originNFT, address _approved, uint256 _originTokenId) public auth { ERC721(_originNFT).approve(_approved, _originTokenId); } diff --git a/contracts/interfaces/IPetBase.sol b/contracts/interfaces/IPetBase.sol index d824962..b50913d 100644 --- a/contracts/interfaces/IPetBase.sol +++ b/contracts/interfaces/IPetBase.sol @@ -1,6 +1,5 @@ pragma solidity ^0.4.24; contract IPetBase { - function tiePetTokenToApostle(uint256 _mirrorTokenId, uint256 _apostleTokenId) public; function pet2TiedStatus(uint256 _mirrorTokenId) public returns (uint256, uint256); } From 1521c3987e1880df0cd2a7569384497b71296d12 Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 19 May 2021 20:55:19 +0800 Subject: [PATCH 32/64] bridge: revert --- contracts/ERC721BridgeV2.sol | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index d233fb3..4d6f910 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -109,7 +109,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { function swapOut(uint256 _mirrorTokenId) public { IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - address nftContract = interstellarEncoder.getOriginAddress(_mirrorTokenId); + address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); require(nftContract != address(0), "No such NFT contract"); address adaptor = originNFT2Adaptor[nftContract]; require(adaptor != address(0), "not registered!"); @@ -126,6 +126,25 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); } + // V2 add - Support PolkaPet + function swapOut1155(uint256 _mirrorTokenId) public { + IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); + address nftContract = interstellarEncoder.getOriginAddress(_mirrorTokenId); + require(nftContract != address(0), "No such NFT contract"); + address adaptor = originNFT2Adaptor[nftContract]; + require(adaptor != address(0), "not registered!"); + require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); + + address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); + (uint256 apostleTokenId,) = IPetBase(petBase).pet2TiedStatus(_mirrorTokenId); + require(apostleTokenId == 0, "Pet has been tied."); + uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); + IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); + emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); + } + function approveOriginToken(address _originNFT, address _approved, uint256 _originTokenId) public auth { ERC721(_originNFT).approve(_approved, _originTokenId); } From d4173d11135033524970d95ca473b2ad33fa388a Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 20 May 2021 16:40:52 +0800 Subject: [PATCH 33/64] pet: add erc721reiver --- contracts/ERC721BridgeV2.sol | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 4d6f910..1ae4ecc 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -8,6 +8,7 @@ import "./interfaces/IMintableERC20.sol"; import "./interfaces/IBurnableERC20.sol"; import "./interfaces/INFTAdaptor.sol"; import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +import "openzeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol"; import "./interfaces/IERC1155.sol"; import "./interfaces/IERC1155Receiver.sol"; import "./interfaces/IPetBase.sol"; @@ -18,7 +19,7 @@ import "./interfaces/IPetBase.sol"; * originTokenId - token outside evolutionLand * mirrorTokenId - mirror token */ -contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { +contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155Receiver { /* * Storage @@ -196,6 +197,19 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC1155Receiver { } } + function onERC721Received( + address /*_operator*/, + address /*_from*/, + uint256 _tokenId, + bytes /*_data*/ + ) + public + returns(bytes4) + { + bridgeAndSwapIn(msg.sender, _tokenId); + return ERC721_RECEIVED; + } + function onERC1155Received( address /*operator*/, address from, From df928b2d692aaaf625243b1f459f0a51b0f8fa79 Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 25 May 2021 15:13:04 +0800 Subject: [PATCH 34/64] pet: erc721 erc1155 bridge in the same way --- contracts/ERC721BridgeV2.sol | 87 +++++++++--------------------------- 1 file changed, 20 insertions(+), 67 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 1ae4ecc..71da6b5 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -49,65 +49,6 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; } - // used by PetBase - function bridgeInAuth(address _originNftAddress, uint256 _originTokenId, address _owner) public auth returns (uint256) { - return _bridgeIn(_originNftAddress, _originTokenId, _owner); - } - - - // generate new mirror token without origin token frozen - function bridgeIn(address _originNftAddress, uint256 _originTokenId) public returns (uint256) { - _bridgeIn(_originNftAddress, _originTokenId, msg.sender); - } - - function _bridgeIn(address _originNftAddress, uint256 _originTokenId, address _owner) internal returns (uint256) { - address adaptor = originNFT2Adaptor[_originNftAddress]; - require(adaptor != address(0), "Not registered!"); - - require(INFTAdaptor(adaptor).ownerInOrigin(_originTokenId) == _owner, "Invalid owner!"); - - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); - - // if it is the first time to bridge in - if (!isBridged(mirrorTokenId)) { - // keep new mirror object in this contract - // before the owner has transferred his/her outerObject into this contract - // mirror object can not be transferred - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); - - // link objects_in and objects_out - INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; - - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); - } - - return mirrorTokenId; - } - - // freeze origin token to free mirror token - function swapIn(address _originNftAddress, uint256 _originTokenId) public { - require(ERC721(_originNftAddress).ownerOf(_originTokenId) == msg.sender, "Invalid owner!"); - - address adaptor = originNFT2Adaptor[_originNftAddress]; - require(adaptor != address(0), "Not registered!"); - - // all specific originTokens are kept in bridge - ERC721(_originNftAddress).transferFrom(msg.sender, address(this), _originTokenId); - - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - ERC721(objectOwnership).transferFrom(address(this), msg.sender, mirrorTokenId); - - emit SwapIn(_originTokenId, mirrorTokenId, msg.sender); - } - - function bridgeAndSwapIn(address _originNftAddress, uint256 _originTokenId) public { - bridgeIn(_originNftAddress, _originTokenId); - swapIn(_originNftAddress, _originTokenId); - } - function swapOut(uint256 _mirrorTokenId) public { IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); @@ -146,10 +87,6 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); } - function approveOriginToken(address _originNFT, address _approved, uint256 _originTokenId) public auth { - ERC721(_originNFT).approve(_approved, _originTokenId); - } - function ownerOf(uint256 _mirrorTokenId) public view returns (address) { return ownerOfMirror(_mirrorTokenId); } @@ -185,7 +122,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R // V2 add - Support PolkaPet function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from, uint256 _value) private { - address adaptor = originNFT2Adaptor[msg.sender]; + address adaptor = originNFT2Adaptor[_originNftAddress]; require(adaptor != address(0), "Not registered!"); address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); for (uint256 i = 0; i < _value; i++) { @@ -197,16 +134,32 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R } } + function _bridgeIn721(address _originNftAddress, uint256 _originTokenId, address _owner) private { + address adaptor = originNFT2Adaptor[_originNftAddress]; + require(adaptor != address(0), "Not registered!"); + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + if (!isBridged(mirrorTokenId)) { + IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); + INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); + } + ERC721(objectOwnership).transferFrom(address(this), _owner, mirrorTokenId); + emit SwapIn(_originTokenId, mirrorTokenId, _owner); + } + function onERC721Received( address /*_operator*/, - address /*_from*/, + address _from, uint256 _tokenId, bytes /*_data*/ ) - public + whenNotPaused() + public returns(bytes4) { - bridgeAndSwapIn(msg.sender, _tokenId); + _bridgeIn721(msg.sender, _tokenId, _from); return ERC721_RECEIVED; } From 2f9b927ce3042ae9345e2e44237e26632ae2431b Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 25 May 2021 15:23:41 +0800 Subject: [PATCH 35/64] fmt --- contracts/ERC721BridgeV2.sol | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 71da6b5..e284f20 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -82,8 +82,8 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R require(apostleTokenId == 0, "Pet has been tied."); uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); - IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); + IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); + IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); } @@ -120,19 +120,19 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R return (mirrorId2OriginId[_mirrorTokenId] != 0); } - // V2 add - Support PolkaPet - function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from, uint256 _value) private { + // V2 add - Support PolkaPet + function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from, uint256 _value) private { address adaptor = originNFT2Adaptor[_originNftAddress]; require(adaptor != address(0), "Not registered!"); address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - for (uint256 i = 0; i < _value; i++) { - uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); - IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); - emit SwapIn(_originTokenId, mirrorTokenId, _from); - } - } + for (uint256 i = 0; i < _value; i++) { + uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); + IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; + emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); + emit SwapIn(_originTokenId, mirrorTokenId, _from); + } + } function _bridgeIn721(address _originNftAddress, uint256 _originTokenId, address _owner) private { address adaptor = originNFT2Adaptor[_originNftAddress]; @@ -170,13 +170,13 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R uint256 value, bytes /*data*/ ) - whenNotPaused() + whenNotPaused() external returns(bytes4) - { - _bridgeIn1155(msg.sender, id, from, value); - return ERC1155_RECEIVED_VALUE; - } + { + _bridgeIn1155(msg.sender, id, from, value); + return ERC1155_RECEIVED_VALUE; + } function onERC1155BatchReceived( address /*operator*/, @@ -185,14 +185,14 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R uint256[] values, bytes /*data*/ ) - whenNotPaused() + whenNotPaused() external returns(bytes4) - { + { require(ids.length == values.length, "INVALID_ARRAYS_LENGTH"); for (uint256 i = 0; i < ids.length; i++) { - _bridgeIn1155(msg.sender, ids[i], from, values[i]); + _bridgeIn1155(msg.sender, ids[i], from, values[i]); } - return ERC1155_BATCH_RECEIVED_VALUE; - } + return ERC1155_BATCH_RECEIVED_VALUE; + } } From 9f7f241db2045bf1c7107fc51d37f5eee5120ac0 Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 27 May 2021 11:49:24 +0800 Subject: [PATCH 36/64] rm erc223 support --- contracts/TokenUse.sol | 33 ++++----------------------- contracts/interfaces/IRevenuePool.sol | 6 +++++ 2 files changed, 10 insertions(+), 29 deletions(-) create mode 100644 contracts/interfaces/IRevenuePool.sol diff --git a/contracts/TokenUse.sol b/contracts/TokenUse.sol index 9986428..8578893 100644 --- a/contracts/TokenUse.sol +++ b/contracts/TokenUse.sol @@ -3,12 +3,12 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -import "./interfaces/ERC223.sol"; import "./interfaces/ITokenUse.sol"; import "./interfaces/IActivity.sol"; import "./interfaces/ISettingsRegistry.sol"; import "./interfaces/IInterstellarEncoder.sol"; import "./interfaces/IActivityObject.sol"; +import "./interfaces/IRevenuePool.sol"; import "./SettingIds.sol"; import "./DSAuth.sol"; @@ -165,8 +165,9 @@ contract TokenUse is DSAuth, ITokenUse, SettingIds { ERC20(ring).transferFrom( msg.sender, tokenId2UseOffer[_tokenId].owner, expense.sub(cut)); - ERC223(ring).transferFrom( - msg.sender, registry.addressOf(CONTRACT_REVENUE_POOL), cut, toBytes(msg.sender)); + address pool = registry.addressOf(CONTRACT_REVENUE_POOL); + ERC20(ring).approve(pool, cut); + IRevenuePool(pool).reward(ring, cut, msg.sender); _takeTokenUseOffer(_tokenId, msg.sender); } @@ -190,32 +191,6 @@ contract TokenUse is DSAuth, ITokenUse, SettingIds { } - //TODO: allow batch operation - function tokenFallback(address _from, uint256 _value, bytes /*_data*/) public { - address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); - if(ring == msg.sender) { - uint256 tokenId; - - assembly { - let ptr := mload(0x40) - calldatacopy(ptr, 0, calldatasize) - tokenId := mload(add(ptr, 132)) - } - - uint256 expense = uint256(tokenId2UseOffer[tokenId].price); - require(_value >= expense); - - uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); - - ERC20(ring).transfer(tokenId2UseOffer[tokenId].owner, expense.sub(cut)); - - ERC223(ring).transfer( - registry.addressOf(CONTRACT_REVENUE_POOL), cut, toBytes(_from)); - - _takeTokenUseOffer(tokenId, _from); - } - } - // start activity when token has no user at all function addActivity( uint256 _tokenId, address _user, uint256 _endTime diff --git a/contracts/interfaces/IRevenuePool.sol b/contracts/interfaces/IRevenuePool.sol new file mode 100644 index 0000000..240fbba --- /dev/null +++ b/contracts/interfaces/IRevenuePool.sol @@ -0,0 +1,6 @@ +pragma solidity >=0.4.24; + +interface IRevenuePool { + function reward(address _token, uint256 _value, address _buyer) external; + function settleToken(address _tokenAddress) external; +} From c09ab1fb688791de16bbc1c3ce258c5fc3ff63ed Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 27 May 2021 11:57:20 +0800 Subject: [PATCH 37/64] rm erc223 support --- contracts/TokenUseV2.sol | 320 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 320 insertions(+) create mode 100644 contracts/TokenUseV2.sol diff --git a/contracts/TokenUseV2.sol b/contracts/TokenUseV2.sol new file mode 100644 index 0000000..184a83d --- /dev/null +++ b/contracts/TokenUseV2.sol @@ -0,0 +1,320 @@ +pragma solidity ^0.4.24; + +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; +import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +import "./interfaces/ITokenUse.sol"; +import "./interfaces/IActivity.sol"; +import "./interfaces/ISettingsRegistry.sol"; +import "./interfaces/IInterstellarEncoder.sol"; +import "./interfaces/IActivityObject.sol"; +import "./interfaces/IRevenuePool.sol"; +import "./SettingIds.sol"; +import "./DSAuth.sol"; + +contract TokenUseV2 is DSAuth, ITokenUse, SettingIds { + using SafeMath for *; + + // claimedToken event + event ClaimedTokens(address indexed token, address indexed owner, uint amount); + + event OfferCreated(uint256 indexed tokenId, uint256 duration, uint256 price, address acceptedActivity, address owner); + event OfferCancelled(uint256 tokenId); + event OfferTaken(uint256 indexed tokenId, address from, address owner, uint256 now, uint256 endTime); + event ActivityAdded(uint256 indexed tokenId, address activity, uint256 endTime); + event ActivityRemoved(uint256 indexed tokenId, address activity); + event TokenUseRemoved(uint256 indexed tokenId, address owner, address user, address activity); + + struct UseStatus { + address user; + address owner; + uint48 startTime; + uint48 endTime; + uint256 price; // RING per second. + address acceptedActivity; // can only be used in this activity. + } + + struct UseOffer { + address owner; + uint48 duration; + // total price of hiring mft for full duration + uint256 price; + address acceptedActivity; // If 0, then accept any activity + } + + struct CurrentActivity { + address activity; + uint48 endTime; + } + + bool private singletonLock = false; + + ISettingsRegistry public registry; + mapping (uint256 => UseStatus) public tokenId2UseStatus; + mapping (uint256 => UseOffer) public tokenId2UseOffer; + + mapping (uint256 => CurrentActivity ) public tokenId2CurrentActivity; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract(ISettingsRegistry _registry) public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + + registry = _registry; + } + + // false if it is not in useStage + // based on data in TokenUseStatus + function isObjectInHireStage(uint256 _tokenId) public view returns (bool) { + if (tokenId2UseStatus[_tokenId].user == address(0)) { + return false; + } + + return tokenId2UseStatus[_tokenId].startTime <= now && now <= tokenId2UseStatus[_tokenId].endTime; + } + + // by check this function + // you can know if an nft is ok to addActivity + // based on data in CurrentActivity + function isObjectReadyToUse(uint256 _tokenId) public view returns (bool) { + + if(tokenId2CurrentActivity[_tokenId].endTime == 0) { + return tokenId2CurrentActivity[_tokenId].activity == address(0); + } else { + return now > tokenId2CurrentActivity[_tokenId].endTime; + } + } + + + function getTokenUser(uint256 _tokenId) public view returns (address) { + return tokenId2UseStatus[_tokenId].user; + } + + function receiveApproval(address _from, uint _tokenId, bytes /*_data*/) public { + if(msg.sender == registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)) { + uint256 duration; + uint256 price; + address acceptedActivity; + assembly { + let ptr := mload(0x40) + calldatacopy(ptr, 0, calldatasize) + duration := mload(add(ptr, 132)) + price := mload(add(ptr, 164)) + acceptedActivity := mload(add(ptr, 196)) + } + + // already approve that msg.sender == ownerOf(_tokenId) + + _createTokenUseOffer(_tokenId, duration, price, acceptedActivity, _from); + } + } + + + // need approval from msg.sender + function createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public { + require(ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == msg.sender, "Only can call by the token owner."); + + _createTokenUseOffer(_tokenId, _duration, _price, _acceptedActivity, msg.sender); + } + + // TODO: be careful with unit of duration and price + // remember to deal with unit off chain + function _createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity, address _owner) internal { + require(isObjectReadyToUse(_tokenId), "No, it is still in use."); + require(tokenId2UseOffer[_tokenId].owner == 0, "Token already in another offer."); + require(_price >= 1 ether, "price must larger than 1 ring."); + require(_duration >= 7 days); + + ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom(_owner, address(this), _tokenId); + + tokenId2UseOffer[_tokenId] = UseOffer({ + owner: _owner, + duration: uint48(_duration), + price : _price, + acceptedActivity: _acceptedActivity + }); + + emit OfferCreated(_tokenId,_duration, _price, _acceptedActivity, _owner); + } + + function cancelTokenUseOffer(uint256 _tokenId) public { + require(tokenId2UseOffer[_tokenId].owner == msg.sender, "Only token owner can cancel the offer."); + + ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom(address(this), msg.sender, _tokenId); + + delete tokenId2UseOffer[_tokenId]; + + emit OfferCancelled(_tokenId); + } + + function takeTokenUseOffer(uint256 _tokenId) public { + uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); + + uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); + + address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); + + ERC20(ring).transferFrom( + msg.sender, tokenId2UseOffer[_tokenId].owner, expense.sub(cut)); + + address pool = registry.addressOf(CONTRACT_REVENUE_POOL); + ERC20(ring).approve(pool, cut); + IRevenuePool(pool).reward(ring, cut, msg.sender); + + _takeTokenUseOffer(_tokenId, msg.sender); + } + + function _takeTokenUseOffer(uint256 _tokenId, address _from) internal { + require(tokenId2UseOffer[_tokenId].owner != address(0), "Offer does not exist for this token."); + require(isObjectReadyToUse(_tokenId), "Token already in another activity."); + + tokenId2UseStatus[_tokenId] = UseStatus({ + user: _from, + owner: tokenId2UseOffer[_tokenId].owner, + startTime: uint48(now), + endTime : uint48(now) + tokenId2UseOffer[_tokenId].duration, + price : tokenId2UseOffer[_tokenId].price, + acceptedActivity : tokenId2UseOffer[_tokenId].acceptedActivity + }); + + delete tokenId2UseOffer[_tokenId]; + + emit OfferTaken(_tokenId, _from, tokenId2UseStatus[_tokenId].owner, now, uint256(tokenId2UseStatus[_tokenId].endTime)); + + } + + // start activity when token has no user at all + function addActivity( + uint256 _tokenId, address _user, uint256 _endTime + ) public auth { + // require the token user to verify even if it is from business logic. + // if it is rent by others, can not addActivity by default. + if(tokenId2UseStatus[_tokenId].user != address(0)) { + require(_user == tokenId2UseStatus[_tokenId].user); + require( + tokenId2UseStatus[_tokenId].acceptedActivity == address(0) || + tokenId2UseStatus[_tokenId].acceptedActivity == msg.sender, "Token accepted activity is not accepted."); + } else { + require( + address(0) == _user || ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == _user, "you can not use this token."); + } + + require(tokenId2UseOffer[_tokenId].owner == address(0), "Can not start activity when offering."); + + require(IActivity(msg.sender).supportsInterface(0x6086e7f8), "Msg sender must be activity"); + + require(isObjectReadyToUse(_tokenId), "Token should be available."); + + address activityObject = IInterstellarEncoder(registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER)).getObjectAddress(_tokenId); + IActivityObject(activityObject).activityAdded(_tokenId, msg.sender, _user); + + tokenId2CurrentActivity[_tokenId].activity = msg.sender; + + if(tokenId2UseStatus[_tokenId].endTime != 0) { + tokenId2CurrentActivity[_tokenId].endTime = tokenId2UseStatus[_tokenId].endTime; + } else { + tokenId2CurrentActivity[_tokenId].endTime = uint48(_endTime); + } + + + emit ActivityAdded(_tokenId, msg.sender, uint48(tokenId2CurrentActivity[_tokenId].endTime)); + } + + function removeActivity(uint256 _tokenId, address _user) public auth { + // require the token user to verify even if it is from business logic. + // if it is rent by others, can not addActivity by default. + if(tokenId2UseStatus[_tokenId].user != address(0)) { + require(_user == tokenId2UseStatus[_tokenId].user); + } else { + require( + address(0) == _user || ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == _user, "you can not use this token."); + } + + require(tokenId2CurrentActivity[_tokenId].activity == msg.sender || msg.sender == address(this), "Must stop from current activity"); + + address activityObject = IInterstellarEncoder(registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER)).getObjectAddress(_tokenId); + IActivityObject(activityObject).activityRemoved(_tokenId, msg.sender, _user); + + IActivity(tokenId2CurrentActivity[_tokenId].activity).activityStopped(_tokenId); + + delete tokenId2CurrentActivity[_tokenId]; + + emit ActivityRemoved(_tokenId, msg.sender); + } + + function removeTokenUseAndActivity(uint256 _tokenId) public { + require(tokenId2UseStatus[_tokenId].user != address(0), "Object does not exist."); + + // when in activity, only user can stop + if(isObjectInHireStage(_tokenId)) { + require(tokenId2UseStatus[_tokenId].user == msg.sender); + } + + _removeTokenUse(_tokenId); + + if (tokenId2CurrentActivity[_tokenId].activity != address(0)) { + this.removeActivity(_tokenId, address(0)); + } + } + + + function _removeTokenUse(uint256 _tokenId) internal { + + address owner = tokenId2UseStatus[_tokenId].owner; + address user = tokenId2UseStatus[_tokenId].user; + address activity = tokenId2CurrentActivity[_tokenId].activity; + ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom( + address(this), owner, _tokenId); + + delete tokenId2UseStatus[_tokenId]; +// delete tokenId2CurrentActivity[_tokenId]; + + emit TokenUseRemoved(_tokenId, owner, user, activity); + } + + // for user-friendly + function removeUseAndCreateOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public { + + require(msg.sender == tokenId2UseStatus[_tokenId].owner); + removeTokenUseAndActivity(_tokenId); + + tokenId2UseOffer[_tokenId] = UseOffer({ + owner: msg.sender, + duration: uint48(_duration), + price : _price, + acceptedActivity: _acceptedActivity + }); + + emit OfferCreated(_tokenId, _duration, _price, _acceptedActivity, msg.sender); + } + + /// @notice This method can be used by the owner to extract mistakenly + /// sent tokens to this contract. + /// @param _token The address of the token contract that you want to recover + /// set to 0 in case you want to extract ether. + function claimTokens(address _token) public auth { + if (_token == 0x0) { + owner.transfer(address(this).balance); + return; + } + ERC20 token = ERC20(_token); + uint balance = token.balanceOf(address(this)); + token.transfer(owner, balance); + + emit ClaimedTokens(_token, owner, balance); + } + + function toBytes(address x) public pure returns (bytes b) { + b = new bytes(32); + assembly { mstore(add(b, 32), x) } + } + +} From 0a869246839c3c1a2d52080cbdaaa63fc82e18be Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 27 May 2021 16:40:39 +0800 Subject: [PATCH 38/64] fix (#49) --- contracts/ERC721BridgeV2.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index e284f20..c719107 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -51,7 +51,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R function swapOut(uint256 _mirrorTokenId) public { IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); - address nftContract = interstellarEncoder.getContractAddress(_mirrorTokenId); + address nftContract = interstellarEncoder.getOriginAddress(_mirrorTokenId); require(nftContract != address(0), "No such NFT contract"); address adaptor = originNFT2Adaptor[nftContract]; require(adaptor != address(0), "not registered!"); From c43f1e90d4f11e0f1ac1e7c7a886b21f7a523eab Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 27 May 2021 17:02:13 +0800 Subject: [PATCH 39/64] fix --- contracts/ERC721BridgeV2.sol | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index c719107..242e8a3 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -37,6 +37,8 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R // tokenId_inside => tokenId_outside mapping(uint256 => uint256) public mirrorId2OriginId; + mapping(uint256 => uint256) public mirrorId2OriginId1155; + /* * Event */ @@ -80,10 +82,11 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); (uint256 apostleTokenId,) = IPetBase(petBase).pet2TiedStatus(_mirrorTokenId); require(apostleTokenId == 0, "Pet has been tied."); - uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; + uint256 originTokenId = mirrorId2OriginId1155[_mirrorTokenId]; address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); + delete mirrorId2OriginId1155[_mirrorTokenId]; emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); } @@ -128,7 +131,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R for (uint256 i = 0; i < _value; i++) { uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; + mirrorId2OriginId1155[mirrorTokenId] = _originTokenId; emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); emit SwapIn(_originTokenId, mirrorTokenId, _from); } From c2461c3194879bd2d77713fc99cf8ede74c53ef3 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 28 May 2021 12:03:16 +0800 Subject: [PATCH 40/64] fix amount input issue --- contracts/TokenUseV2.sol | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/contracts/TokenUseV2.sol b/contracts/TokenUseV2.sol index 184a83d..5f48add 100644 --- a/contracts/TokenUseV2.sol +++ b/contracts/TokenUseV2.sol @@ -155,13 +155,18 @@ contract TokenUseV2 is DSAuth, ITokenUse, SettingIds { emit OfferCancelled(_tokenId); } - function takeTokenUseOffer(uint256 _tokenId) public { + function takeTokenUseOffer(uint256 _tokenId, uint256 _amountMax) public { uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); + address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); + require(_amountMax >= expense, + "your offer is lower than the current price, try again with a higher one."); + uint refund = _amountMax - expense; + if (refund > 0) { + ERC20(ring).transfer(msg.sender, refund); + } uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); - address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); - ERC20(ring).transferFrom( msg.sender, tokenId2UseOffer[_tokenId].owner, expense.sub(cut)); From 15d51fb85b35c38fd9dbafe7545871605879cbf6 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 28 May 2021 12:37:44 +0800 Subject: [PATCH 41/64] fix amount input issue --- contracts/TokenUseV2.sol | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/contracts/TokenUseV2.sol b/contracts/TokenUseV2.sol index 184a83d..a1ee6e2 100644 --- a/contracts/TokenUseV2.sol +++ b/contracts/TokenUseV2.sol @@ -155,20 +155,24 @@ contract TokenUseV2 is DSAuth, ITokenUse, SettingIds { emit OfferCancelled(_tokenId); } - function takeTokenUseOffer(uint256 _tokenId) public { - uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); - - uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); - + function _pay(address _seller, uint256 expense, uint256 _amountMax) internal { address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); - - ERC20(ring).transferFrom( - msg.sender, tokenId2UseOffer[_tokenId].owner, expense.sub(cut)); - + uint256 refoud = _amountMax - expense; + if (refoud > 0) { + ERC20(ring).transfer(msg.sender, refoud); + } + uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); + ERC20(ring).transferFrom(msg.sender, _seller, expense.sub(cut)); address pool = registry.addressOf(CONTRACT_REVENUE_POOL); ERC20(ring).approve(pool, cut); IRevenuePool(pool).reward(ring, cut, msg.sender); + } + + function takeTokenUseOffer(uint256 _tokenId, uint256 _amountMax) public { + uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); + require(_amountMax >= expense, "offer too low"); + _pay(tokenId2UseOffer[_tokenId].owner, expense, _amountMax); _takeTokenUseOffer(_tokenId, msg.sender); } From 45a8556b16b08bbedfa64377e915934e609d1054 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 28 May 2021 12:38:42 +0800 Subject: [PATCH 42/64] fix amount input issue --- contracts/TokenUseV2.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/TokenUseV2.sol b/contracts/TokenUseV2.sol index a1ee6e2..e65264b 100644 --- a/contracts/TokenUseV2.sol +++ b/contracts/TokenUseV2.sol @@ -166,7 +166,6 @@ contract TokenUseV2 is DSAuth, ITokenUse, SettingIds { address pool = registry.addressOf(CONTRACT_REVENUE_POOL); ERC20(ring).approve(pool, cut); IRevenuePool(pool).reward(ring, cut, msg.sender); - } function takeTokenUseOffer(uint256 _tokenId, uint256 _amountMax) public { From 679b9173f35cd0728bf1b9cdca18b99e8e064f0d Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 28 May 2021 12:41:43 +0800 Subject: [PATCH 43/64] fix amount input issue --- contracts/TokenUseV2.sol | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contracts/TokenUseV2.sol b/contracts/TokenUseV2.sol index e65264b..77f1db0 100644 --- a/contracts/TokenUseV2.sol +++ b/contracts/TokenUseV2.sol @@ -3,7 +3,6 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -import "./interfaces/ITokenUse.sol"; import "./interfaces/IActivity.sol"; import "./interfaces/ISettingsRegistry.sol"; import "./interfaces/IInterstellarEncoder.sol"; @@ -12,7 +11,7 @@ import "./interfaces/IRevenuePool.sol"; import "./SettingIds.sol"; import "./DSAuth.sol"; -contract TokenUseV2 is DSAuth, ITokenUse, SettingIds { +contract TokenUseV2 is DSAuth, SettingIds { using SafeMath for *; // claimedToken event From a7cd9040cb835992f0b3e560bd3076e579868528 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 28 May 2021 13:24:09 +0800 Subject: [PATCH 44/64] fix decuct fee issue --- contracts/TokenUseV2.sol | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/contracts/TokenUseV2.sol b/contracts/TokenUseV2.sol index 77f1db0..e1473fe 100644 --- a/contracts/TokenUseV2.sol +++ b/contracts/TokenUseV2.sol @@ -154,12 +154,8 @@ contract TokenUseV2 is DSAuth, SettingIds { emit OfferCancelled(_tokenId); } - function _pay(address _seller, uint256 expense, uint256 _amountMax) internal { + function _pay(address _seller, uint256 expense) internal { address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); - uint256 refoud = _amountMax - expense; - if (refoud > 0) { - ERC20(ring).transfer(msg.sender, refoud); - } uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); ERC20(ring).transferFrom(msg.sender, _seller, expense.sub(cut)); address pool = registry.addressOf(CONTRACT_REVENUE_POOL); @@ -170,7 +166,7 @@ contract TokenUseV2 is DSAuth, SettingIds { function takeTokenUseOffer(uint256 _tokenId, uint256 _amountMax) public { uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); require(_amountMax >= expense, "offer too low"); - _pay(tokenId2UseOffer[_tokenId].owner, expense, _amountMax); + _pay(tokenId2UseOffer[_tokenId].owner, expense); _takeTokenUseOffer(_tokenId, msg.sender); } From a9d97c9fc482ef24573f827cceb26a203207ef8f Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 28 May 2021 14:04:24 +0800 Subject: [PATCH 45/64] fix amount input issue --- contracts/TokenUseV2.sol | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contracts/TokenUseV2.sol b/contracts/TokenUseV2.sol index e1473fe..dd649b9 100644 --- a/contracts/TokenUseV2.sol +++ b/contracts/TokenUseV2.sol @@ -154,10 +154,9 @@ contract TokenUseV2 is DSAuth, SettingIds { emit OfferCancelled(_tokenId); } - function _pay(address _seller, uint256 expense) internal { - address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); + function _pay(address ring, address _seller, uint256 expense) internal { uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); - ERC20(ring).transferFrom(msg.sender, _seller, expense.sub(cut)); + ERC20(ring).transfer(_seller, expense.sub(cut)); address pool = registry.addressOf(CONTRACT_REVENUE_POOL); ERC20(ring).approve(pool, cut); IRevenuePool(pool).reward(ring, cut, msg.sender); @@ -166,7 +165,9 @@ contract TokenUseV2 is DSAuth, SettingIds { function takeTokenUseOffer(uint256 _tokenId, uint256 _amountMax) public { uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); require(_amountMax >= expense, "offer too low"); - _pay(tokenId2UseOffer[_tokenId].owner, expense); + address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); + ERC20(ring).transferFrom(msg.sender, address(this), expense); + _pay(ring, tokenId2UseOffer[_tokenId].owner, expense); _takeTokenUseOffer(_tokenId, msg.sender); } From 4eb70312635d79565d771db0ac71b90f8f427dfb Mon Sep 17 00:00:00 2001 From: echo Date: Mon, 31 May 2021 13:22:30 +0800 Subject: [PATCH 46/64] add origin contract to swap event --- contracts/ERC721BridgeV2.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 242e8a3..6e8683a 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -44,8 +44,8 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R */ event BridgeIn(uint256 originTokenId, uint256 mirrorTokenId, address originContract, address adaptorAddress, address owner); - event SwapIn(uint256 originTokenId, uint256 mirrorTokenId, address owner); - event SwapOut(uint256 originTokenId, uint256 mirrorTokenId, address owner); + event SwapIn(uint256 originTokenId, uint256 mirrorTokenId, address owner, address originContract); + event SwapOut(uint256 originTokenId, uint256 mirrorTokenId, address owner, address originContract); function registerAdaptor(address _originNftAddress, address _erc721Adaptor) public whenNotPaused onlyOwner { originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; @@ -67,7 +67,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); - emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); + emit SwapOut(originTokenId, _mirrorTokenId, msg.sender, nftContract); } // V2 add - Support PolkaPet @@ -87,7 +87,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); delete mirrorId2OriginId1155[_mirrorTokenId]; - emit SwapOut(originTokenId, _mirrorTokenId, msg.sender); + emit SwapOut(originTokenId, _mirrorTokenId, msg.sender, nftContract); } function ownerOf(uint256 _mirrorTokenId) public view returns (address) { @@ -133,7 +133,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); mirrorId2OriginId1155[mirrorTokenId] = _originTokenId; emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); - emit SwapIn(_originTokenId, mirrorTokenId, _from); + emit SwapIn(_originTokenId, mirrorTokenId, _from, _originNftAddress); } } @@ -149,7 +149,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); } ERC721(objectOwnership).transferFrom(address(this), _owner, mirrorTokenId); - emit SwapIn(_originTokenId, mirrorTokenId, _owner); + emit SwapIn(_originTokenId, mirrorTokenId, _owner, _originNftAddress); } function onERC721Received( From 8657133cb03f9016802de55fa65df60b153733f7 Mon Sep 17 00:00:00 2001 From: echo Date: Mon, 31 May 2021 13:33:15 +0800 Subject: [PATCH 47/64] rm pet bridgein event --- contracts/ERC721BridgeV2.sol | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 6e8683a..2d58561 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -42,10 +42,10 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R /* * Event */ - event BridgeIn(uint256 originTokenId, uint256 mirrorTokenId, address originContract, address adaptorAddress, address owner); + // event BridgeIn(uint256 originTokenId, uint256 mirrorTokenId, address originContract, address adaptorAddress, address owner); - event SwapIn(uint256 originTokenId, uint256 mirrorTokenId, address owner, address originContract); - event SwapOut(uint256 originTokenId, uint256 mirrorTokenId, address owner, address originContract); + event SwapIn(address originContract, uint256 originTokenId, uint256 mirrorTokenId, address owner); + event SwapOut(address originContract, uint256 originTokenId, uint256 mirrorTokenId, address owner); function registerAdaptor(address _originNftAddress, address _erc721Adaptor) public whenNotPaused onlyOwner { originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; @@ -66,8 +66,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); - - emit SwapOut(originTokenId, _mirrorTokenId, msg.sender, nftContract); + emit SwapOut(nftContract, originTokenId, _mirrorTokenId, msg.sender); } // V2 add - Support PolkaPet @@ -87,7 +86,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); delete mirrorId2OriginId1155[_mirrorTokenId]; - emit SwapOut(originTokenId, _mirrorTokenId, msg.sender, nftContract); + emit SwapOut(nftContract, originTokenId, _mirrorTokenId, msg.sender); } function ownerOf(uint256 _mirrorTokenId) public view returns (address) { @@ -132,8 +131,8 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenIdAndIncrease(_originTokenId); IMintableERC20(objectOwnership).mint(_from, mirrorTokenId); mirrorId2OriginId1155[mirrorTokenId] = _originTokenId; - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); - emit SwapIn(_originTokenId, mirrorTokenId, _from, _originNftAddress); + // emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _from); + emit SwapIn(_originNftAddress, _originTokenId, mirrorTokenId, _from); } } @@ -146,10 +145,10 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); mirrorId2OriginId[mirrorTokenId] = _originTokenId; - emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); + // emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); } ERC721(objectOwnership).transferFrom(address(this), _owner, mirrorTokenId); - emit SwapIn(_originTokenId, mirrorTokenId, _owner, _originNftAddress); + emit SwapIn(_originNftAddress, _originTokenId, mirrorTokenId, _owner); } function onERC721Received( From d87643d4dba037da885461ba5f0df3d45d73aa0c Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 1 Jun 2021 11:47:21 +0800 Subject: [PATCH 48/64] add abi --- abi/AddressUtils.abi | 1 + abi/ApproveAndCallFallBack.abi | 1 + abi/Authority.abi | 1 + abi/DSAuth.abi | 1 + abi/DSAuthEvents.abi | 1 + abi/ERC165.abi | 1 + abi/ERC20.abi | 1 + abi/ERC20Basic.abi | 1 + abi/ERC20Container.abi | 1 + abi/ERC223.abi | 1 + abi/ERC223ReceivingContract.abi | 1 + abi/ERC721.abi | 1 + abi/ERC721Adaptor.abi | 1 + abi/ERC721AdaptorAuthority.abi | 1 + abi/ERC721Basic.abi | 1 + abi/ERC721BasicToken.abi | 1 + abi/ERC721Bridge.abi | 1 + abi/ERC721BridgeV2.abi | 1 + abi/ERC721Container.abi | 1 + abi/ERC721Enumerable.abi | 1 + abi/ERC721Metadata.abi | 1 + abi/ERC721Receiver.abi | 1 + abi/ERC721Token.abi | 1 + abi/IActivity.abi | 1 + abi/IActivityObject.abi | 1 + abi/IAuthority.abi | 1 + abi/IBurnableERC20.abi | 1 + abi/IContainer.abi | 1 + abi/IERC1155.abi | 1 + abi/IERC1155Receiver.abi | 1 + abi/IERC165.abi | 1 + abi/IInterstellarEncoder.abi | 1 + abi/IInterstellarEncoderV3.abi | 1 + abi/IInterstellarEncoderV4.abi | 1 + abi/IMinerObject.abi | 1 + abi/IMintableERC20.abi | 1 + abi/INFTAdaptor.abi | 1 + abi/IObjectOwnership.abi | 1 + abi/IPetBase.abi | 1 + abi/IRevenuePool.abi | 1 + abi/ISettingsRegistry.abi | 1 + abi/ISmartToken.abi | 1 + abi/ITokenLocation.abi | 1 + abi/ITokenUse.abi | 1 + abi/ITokenVendor.abi | 1 + abi/IUserPoints.abi | 1 + abi/InterstellarEncoder.abi | 1 + abi/InterstellarEncoderV2.abi | 1 + abi/InterstellarEncoderV3.abi | 1 + abi/InterstellarEncoderV4.abi | 1 + abi/Issuing.abi | 1 + abi/KtonVoter.abi | 1 + abi/LocationCoder.abi | 1 + abi/MintAndBurnAuthority.abi | 1 + abi/MintAndBurnAuthorityV2.abi | 1 + abi/MultiSigWallet.abi | 1 + abi/ObjectOwnership.abi | 1 + abi/ObjectOwnershipAuthority.abi | 1 + abi/ObjectOwnershipAuthorityV2.abi | 1 + abi/ObjectOwnershipAuthorityV3.abi | 1 + abi/ObjectOwnershipV2.abi | 1 + abi/Ownable.abi | 1 + abi/PausableDSAuth.abi | 1 + abi/PolkaPetAdaptor.abi | 1 + abi/Proposal.abi | 1 + abi/ProposalRegistry.abi | 1 + abi/RBAC.abi | 1 + abi/RBACWithAdmin.abi | 1 + abi/RBACWithAuth.abi | 1 + abi/Roles.abi | 1 + abi/SafeERC20.abi | 1 + abi/SafeMath.abi | 1 + abi/SettingIds.abi | 1 + abi/SettingsRegistry.abi | 1 + abi/StandardERC20Base.abi | 1 + abi/StandardERC223.abi | 1 + abi/StringUtil.abi | 1 + abi/SupportsInterfaceWithLookup.abi | 1 + abi/TokenBuildInGenesis.abi | 1 + abi/TokenBurnDrop.abi | 1 + abi/TokenController.abi | 1 + abi/TokenLocation.abi | 1 + abi/TokenLocationAuthority.abi | 1 + abi/TokenUse.abi | 1 + abi/TokenUseAuthority.abi | 1 + abi/TokenUseV2.abi | 1 + abi/TokenVesting.abi | 1 + abi/TokenVestingFactory.abi | 1 + abi/UserPoints.abi | 1 + abi/UserPointsAuthority.abi | 1 + 90 files changed, 90 insertions(+) create mode 100644 abi/AddressUtils.abi create mode 100644 abi/ApproveAndCallFallBack.abi create mode 100644 abi/Authority.abi create mode 100644 abi/DSAuth.abi create mode 100644 abi/DSAuthEvents.abi create mode 100644 abi/ERC165.abi create mode 100644 abi/ERC20.abi create mode 100644 abi/ERC20Basic.abi create mode 100644 abi/ERC20Container.abi create mode 100644 abi/ERC223.abi create mode 100644 abi/ERC223ReceivingContract.abi create mode 100644 abi/ERC721.abi create mode 100644 abi/ERC721Adaptor.abi create mode 100644 abi/ERC721AdaptorAuthority.abi create mode 100644 abi/ERC721Basic.abi create mode 100644 abi/ERC721BasicToken.abi create mode 100644 abi/ERC721Bridge.abi create mode 100644 abi/ERC721BridgeV2.abi create mode 100644 abi/ERC721Container.abi create mode 100644 abi/ERC721Enumerable.abi create mode 100644 abi/ERC721Metadata.abi create mode 100644 abi/ERC721Receiver.abi create mode 100644 abi/ERC721Token.abi create mode 100644 abi/IActivity.abi create mode 100644 abi/IActivityObject.abi create mode 100644 abi/IAuthority.abi create mode 100644 abi/IBurnableERC20.abi create mode 100644 abi/IContainer.abi create mode 100644 abi/IERC1155.abi create mode 100644 abi/IERC1155Receiver.abi create mode 100644 abi/IERC165.abi create mode 100644 abi/IInterstellarEncoder.abi create mode 100644 abi/IInterstellarEncoderV3.abi create mode 100644 abi/IInterstellarEncoderV4.abi create mode 100644 abi/IMinerObject.abi create mode 100644 abi/IMintableERC20.abi create mode 100644 abi/INFTAdaptor.abi create mode 100644 abi/IObjectOwnership.abi create mode 100644 abi/IPetBase.abi create mode 100644 abi/IRevenuePool.abi create mode 100644 abi/ISettingsRegistry.abi create mode 100644 abi/ISmartToken.abi create mode 100644 abi/ITokenLocation.abi create mode 100644 abi/ITokenUse.abi create mode 100644 abi/ITokenVendor.abi create mode 100644 abi/IUserPoints.abi create mode 100644 abi/InterstellarEncoder.abi create mode 100644 abi/InterstellarEncoderV2.abi create mode 100644 abi/InterstellarEncoderV3.abi create mode 100644 abi/InterstellarEncoderV4.abi create mode 100644 abi/Issuing.abi create mode 100644 abi/KtonVoter.abi create mode 100644 abi/LocationCoder.abi create mode 100644 abi/MintAndBurnAuthority.abi create mode 100644 abi/MintAndBurnAuthorityV2.abi create mode 100644 abi/MultiSigWallet.abi create mode 100644 abi/ObjectOwnership.abi create mode 100644 abi/ObjectOwnershipAuthority.abi create mode 100644 abi/ObjectOwnershipAuthorityV2.abi create mode 100644 abi/ObjectOwnershipAuthorityV3.abi create mode 100644 abi/ObjectOwnershipV2.abi create mode 100644 abi/Ownable.abi create mode 100644 abi/PausableDSAuth.abi create mode 100644 abi/PolkaPetAdaptor.abi create mode 100644 abi/Proposal.abi create mode 100644 abi/ProposalRegistry.abi create mode 100644 abi/RBAC.abi create mode 100644 abi/RBACWithAdmin.abi create mode 100644 abi/RBACWithAuth.abi create mode 100644 abi/Roles.abi create mode 100644 abi/SafeERC20.abi create mode 100644 abi/SafeMath.abi create mode 100644 abi/SettingIds.abi create mode 100644 abi/SettingsRegistry.abi create mode 100644 abi/StandardERC20Base.abi create mode 100644 abi/StandardERC223.abi create mode 100644 abi/StringUtil.abi create mode 100644 abi/SupportsInterfaceWithLookup.abi create mode 100644 abi/TokenBuildInGenesis.abi create mode 100644 abi/TokenBurnDrop.abi create mode 100644 abi/TokenController.abi create mode 100644 abi/TokenLocation.abi create mode 100644 abi/TokenLocationAuthority.abi create mode 100644 abi/TokenUse.abi create mode 100644 abi/TokenUseAuthority.abi create mode 100644 abi/TokenUseV2.abi create mode 100644 abi/TokenVesting.abi create mode 100644 abi/TokenVestingFactory.abi create mode 100644 abi/UserPoints.abi create mode 100644 abi/UserPointsAuthority.abi diff --git a/abi/AddressUtils.abi b/abi/AddressUtils.abi new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/abi/AddressUtils.abi @@ -0,0 +1 @@ +[] diff --git a/abi/ApproveAndCallFallBack.abi b/abi/ApproveAndCallFallBack.abi new file mode 100644 index 0000000..9e2f077 --- /dev/null +++ b/abi/ApproveAndCallFallBack.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_token","type":"address"},{"name":"_data","type":"bytes"}],"name":"receiveApproval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/Authority.abi b/abi/Authority.abi new file mode 100644 index 0000000..fdf1371 --- /dev/null +++ b/abi/Authority.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"usr","type":"address"}],"name":"setRoot","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"sig","type":"bytes4"}],"name":"allow","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"usr","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"usr","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_src","type":"address"},{"name":"","type":"address"},{"name":"_sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"wards","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes4"}],"name":"sigs","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"sig","type":"bytes4"}],"name":"forbid","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"root","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_wards","type":"address[]"},{"name":"_sigs","type":"bytes4[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"usr","type":"address"}],"name":"Rely","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"usr","type":"address"}],"name":"Deny","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"usr","type":"bytes4"}],"name":"Allow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"usr","type":"bytes4"}],"name":"Forbid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"newRoot","type":"address"}],"name":"SetRoot","type":"event"}] diff --git a/abi/DSAuth.abi b/abi/DSAuth.abi new file mode 100644 index 0000000..be1f375 --- /dev/null +++ b/abi/DSAuth.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/DSAuthEvents.abi b/abi/DSAuthEvents.abi new file mode 100644 index 0000000..4183aa3 --- /dev/null +++ b/abi/DSAuthEvents.abi @@ -0,0 +1 @@ +[{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/ERC165.abi b/abi/ERC165.abi new file mode 100644 index 0000000..32bba35 --- /dev/null +++ b/abi/ERC165.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/ERC20.abi b/abi/ERC20.abi new file mode 100644 index 0000000..d45dce9 --- /dev/null +++ b/abi/ERC20.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}] diff --git a/abi/ERC20Basic.abi b/abi/ERC20Basic.abi new file mode 100644 index 0000000..9416175 --- /dev/null +++ b/abi/ERC20Basic.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}] diff --git a/abi/ERC20Container.abi b/abi/ERC20Container.abi new file mode 100644 index 0000000..eebf168 --- /dev/null +++ b/abi/ERC20Container.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"address"}],"name":"fungibleTokensInContainer","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] diff --git a/abi/ERC223.abi b/abi/ERC223.abi new file mode 100644 index 0000000..0abc502 --- /dev/null +++ b/abi/ERC223.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"amount","type":"uint256"},{"name":"data","type":"bytes"}],"name":"transferFrom","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"amount","type":"uint256"},{"name":"data","type":"bytes"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"}],"name":"ERC223Transfer","type":"event"}] diff --git a/abi/ERC223ReceivingContract.abi b/abi/ERC223ReceivingContract.abi new file mode 100644 index 0000000..bd77b61 --- /dev/null +++ b/abi/ERC223ReceivingContract.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_value","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"tokenFallback","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/ERC721.abi b/abi/ERC721.abi new file mode 100644 index 0000000..66d5423 --- /dev/null +++ b/abi/ERC721.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"_name","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"name":"_operator","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"name":"_exists","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"_owner","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"_balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"_symbol","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_operator","type":"address"},{"name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_approved","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_operator","type":"address"},{"indexed":false,"name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"}] diff --git a/abi/ERC721Adaptor.abi b/abi/ERC721Adaptor.abi new file mode 100644 index 0000000..3a9b620 --- /dev/null +++ b/abi/ERC721Adaptor.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_bridge","type":"address"}],"name":"approveToBridge","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_originTokenId","type":"uint256"}],"name":"ownerInOrigin","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"originNft","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"toOriginTokenId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"cachedOriginId2MirrorId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"convertType","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"},{"name":"_originNft","type":"address"},{"name":"_producerId","type":"uint16"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_originTokenId","type":"uint256"}],"name":"toMirrorTokenId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_originTokenId","type":"uint256"},{"name":"_mirrorTokenId","type":"uint256"}],"name":"cacheMirrorTokenId","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_bridge","type":"address"}],"name":"cancelApprove","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"producerId","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_originTokenId","type":"uint256"}],"name":"getObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/ERC721AdaptorAuthority.abi b/abi/ERC721AdaptorAuthority.abi new file mode 100644 index 0000000..75d63a2 --- /dev/null +++ b/abi/ERC721AdaptorAuthority.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"whiteList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_src","type":"address"},{"name":"","type":"address"},{"name":"_sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_whitelists","type":"address[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] diff --git a/abi/ERC721Basic.abi b/abi/ERC721Basic.abi new file mode 100644 index 0000000..86ea9fd --- /dev/null +++ b/abi/ERC721Basic.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"name":"_operator","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"name":"_exists","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"_owner","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"_balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_operator","type":"address"},{"name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_approved","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_operator","type":"address"},{"indexed":false,"name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"}] diff --git a/abi/ERC721BasicToken.abi b/abi/ERC721BasicToken.abi new file mode 100644 index 0000000..f0c76ad --- /dev/null +++ b/abi/ERC721BasicToken.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"InterfaceId_ERC165","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_approved","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_operator","type":"address"},{"indexed":false,"name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"}] diff --git a/abi/ERC721Bridge.abi b/abi/ERC721Bridge.abi new file mode 100644 index 0000000..199a8f2 --- /dev/null +++ b/abi/ERC721Bridge.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"mirrorId2OriginId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_originNftAddress","type":"address"},{"name":"_originTokenId","type":"uint256"}],"name":"bridgeAndSwapIn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_originNFT","type":"address"},{"name":"_originTokenId","type":"uint256"}],"name":"mirrorOfOrigin","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"originNFT2Adaptor","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_originNftAddress","type":"address"},{"name":"_originTokenId","type":"uint256"}],"name":"swapIn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"originOwnershipAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"swapOut","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_originNftAddress","type":"address"},{"name":"_originTokenId","type":"uint256"},{"name":"_owner","type":"address"}],"name":"bridgeInAuth","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_originNftAddress","type":"address"},{"name":"_erc721Adaptor","type":"address"}],"name":"registerAdaptor","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"isBridged","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_originNFT","type":"address"},{"name":"_approved","type":"address"},{"name":"_originTokenId","type":"uint256"}],"name":"approveOriginToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"ownerOfMirror","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_originNftAddress","type":"address"},{"name":"_originTokenId","type":"uint256"}],"name":"bridgeIn","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"originTokenId","type":"uint256"},{"indexed":false,"name":"mirrorTokenId","type":"uint256"},{"indexed":false,"name":"originContract","type":"address"},{"indexed":false,"name":"adaptorAddress","type":"address"},{"indexed":false,"name":"owner","type":"address"}],"name":"BridgeIn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"originTokenId","type":"uint256"},{"indexed":false,"name":"mirrorTokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"}],"name":"SwapIn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"originTokenId","type":"uint256"},{"indexed":false,"name":"mirrorTokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"}],"name":"SwapOut","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/ERC721BridgeV2.abi b/abi/ERC721BridgeV2.abi new file mode 100644 index 0000000..49292ef --- /dev/null +++ b/abi/ERC721BridgeV2.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"mirrorId2OriginId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"","type":"address"},{"name":"_from","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_originNFT","type":"address"},{"name":"_originTokenId","type":"uint256"}],"name":"mirrorOfOrigin","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"originNFT2Adaptor","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"mirrorId2OriginId1155","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"originOwnershipAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"swapOut","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_originNftAddress","type":"address"},{"name":"_erc721Adaptor","type":"address"}],"name":"registerAdaptor","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"isBridged","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"ownerOfMirror","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"","type":"address"},{"name":"from","type":"address"},{"name":"ids","type":"uint256[]"},{"name":"values","type":"uint256[]"},{"name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"swapOut1155","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"","type":"address"},{"name":"from","type":"address"},{"name":"id","type":"uint256"},{"name":"value","type":"uint256"},{"name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"originContract","type":"address"},{"indexed":false,"name":"originTokenId","type":"uint256"},{"indexed":false,"name":"mirrorTokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"}],"name":"SwapIn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"originContract","type":"address"},{"indexed":false,"name":"originTokenId","type":"uint256"},{"indexed":false,"name":"mirrorTokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"}],"name":"SwapOut","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/ERC721Container.abi b/abi/ERC721Container.abi new file mode 100644 index 0000000..9782253 --- /dev/null +++ b/abi/ERC721Container.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_containerTokenId","type":"uint256"},{"name":"_objectTokenId","type":"uint256"}],"name":"addToContainer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"object2IndexInContainer","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"name":"objectsInContainer","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_containerTokenId","type":"uint256"},{"name":"_objectTokenId","type":"uint256"}],"name":"contains","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"object2Container","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_containerTokenId","type":"uint256"}],"name":"isContainer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"name":"transferToOtherContainer","outputs":[],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_objectTokenId","type":"uint256"},{"name":"_receiver","type":"address"}],"name":"transferToAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_objectTokenId","type":"uint256"}],"name":"getTopContainerOwnerAndApproved","outputs":[{"name":"_owner","type":"address"},{"name":"_approved","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] diff --git a/abi/ERC721Enumerable.abi b/abi/ERC721Enumerable.abi new file mode 100644 index 0000000..c27d756 --- /dev/null +++ b/abi/ERC721Enumerable.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"name":"_operator","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"name":"_exists","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"_owner","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"_balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_operator","type":"address"},{"name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_approved","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_operator","type":"address"},{"indexed":false,"name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"}] diff --git a/abi/ERC721Metadata.abi b/abi/ERC721Metadata.abi new file mode 100644 index 0000000..84b5b78 --- /dev/null +++ b/abi/ERC721Metadata.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"_name","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"name":"_operator","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"name":"_exists","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"_owner","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"_balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"_symbol","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_operator","type":"address"},{"name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_approved","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_operator","type":"address"},{"indexed":false,"name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"}] diff --git a/abi/ERC721Receiver.abi b/abi/ERC721Receiver.abi new file mode 100644 index 0000000..a92f4cc --- /dev/null +++ b/abi/ERC721Receiver.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_operator","type":"address"},{"name":"_from","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"onERC721Received","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/ERC721Token.abi b/abi/ERC721Token.abi new file mode 100644 index 0000000..c21671b --- /dev/null +++ b/abi/ERC721Token.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"InterfaceId_ERC165","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_approved","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_operator","type":"address"},{"indexed":false,"name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"}] diff --git a/abi/IActivity.abi b/abi/IActivity.abi new file mode 100644 index 0000000..7d93972 --- /dev/null +++ b/abi/IActivity.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"activityStopped","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/IActivityObject.abi b/abi/IActivityObject.abi new file mode 100644 index 0000000..69cb2dd --- /dev/null +++ b/abi/IActivityObject.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_activity","type":"address"},{"name":"_user","type":"address"}],"name":"activityAdded","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_activity","type":"address"},{"name":"_user","type":"address"}],"name":"activityRemoved","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/IAuthority.abi b/abi/IAuthority.abi new file mode 100644 index 0000000..367dc84 --- /dev/null +++ b/abi/IAuthority.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/IBurnableERC20.abi b/abi/IBurnableERC20.abi new file mode 100644 index 0000000..b602dec --- /dev/null +++ b/abi/IBurnableERC20.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_value","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/IContainer.abi b/abi/IContainer.abi new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/abi/IContainer.abi @@ -0,0 +1 @@ +[] diff --git a/abi/IERC1155.abi b/abi/IERC1155.abi new file mode 100644 index 0000000..65f9a7a --- /dev/null +++ b/abi/IERC1155.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"account","type":"address"},{"name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"ids","type":"uint256[]"},{"name":"amounts","type":"uint256[]"},{"name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"accounts","type":"address[]"},{"name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"operator","type":"address"},{"name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"account","type":"address"},{"name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"id","type":"uint256"},{"name":"amount","type":"uint256"},{"name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"id","type":"uint256"},{"indexed":false,"name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"ids","type":"uint256[]"},{"indexed":false,"name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"account","type":"address"},{"indexed":true,"name":"operator","type":"address"},{"indexed":false,"name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"value","type":"string"},{"indexed":true,"name":"id","type":"uint256"}],"name":"URI","type":"event"}] diff --git a/abi/IERC1155Receiver.abi b/abi/IERC1155Receiver.abi new file mode 100644 index 0000000..827d185 --- /dev/null +++ b/abi/IERC1155Receiver.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"operator","type":"address"},{"name":"from","type":"address"},{"name":"ids","type":"uint256[]"},{"name":"values","type":"uint256[]"},{"name":"data","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"operator","type":"address"},{"name":"from","type":"address"},{"name":"id","type":"uint256"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"}],"name":"onERC1155Received","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/IERC165.abi b/abi/IERC165.abi new file mode 100644 index 0000000..79c1c75 --- /dev/null +++ b/abi/IERC165.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/IInterstellarEncoder.abi b/abi/IInterstellarEncoder.abi new file mode 100644 index 0000000..21a524e --- /dev/null +++ b/abi/IInterstellarEncoder.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectContract","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenIdForObjectContract","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAGIC_NUMBER","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CURRENT_LAND","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectClass","type":"uint8"},{"name":"_objectIndex","type":"uint128"}],"name":"encodeTokenId","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CHAIN_ID","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectId","outputs":[{"name":"_objectId","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenAddress","type":"address"}],"name":"registerNewTokenContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_objectContract","type":"address"},{"name":"objectClass","type":"uint8"}],"name":"registerNewObjectClass","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/IInterstellarEncoderV3.abi b/abi/IInterstellarEncoderV3.abi new file mode 100644 index 0000000..d60584b --- /dev/null +++ b/abi/IInterstellarEncoderV3.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectContract","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenIdForObjectContract","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getProducerId","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAGIC_NUMBER","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getOriginAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CURRENT_LAND","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectClass","type":"uint8"},{"name":"_objectIndex","type":"uint128"}],"name":"encodeTokenId","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CHAIN_ID","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_objectContract","type":"address"},{"name":"nftAddress","type":"address"},{"name":"_originNftAddress","type":"address"},{"name":"_objectId","type":"uint128"},{"name":"_producerId","type":"uint16"},{"name":"_convertType","type":"uint8"}],"name":"encodeTokenIdForOuterObjectContract","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectId","outputs":[{"name":"_objectId","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_objectContract","type":"address"},{"name":"objectClass","type":"uint8"}],"name":"registerNewObjectClass","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/IInterstellarEncoderV4.abi b/abi/IInterstellarEncoderV4.abi new file mode 100644 index 0000000..f2d3d30 --- /dev/null +++ b/abi/IInterstellarEncoderV4.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectContract","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenIdForObjectContract","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getProducerId","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAGIC_NUMBER","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getOriginAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectClass","type":"uint8"},{"name":"_objectIndex","type":"uint128"}],"name":"encodeTokenId","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_objectContract","type":"address"},{"name":"nftAddress","type":"address"},{"name":"_originNftAddress","type":"address"},{"name":"_objectId","type":"uint128"},{"name":"_producerId","type":"uint16"},{"name":"_convertType","type":"uint8"}],"name":"encodeTokenIdForOuterObjectContract","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectId","outputs":[{"name":"_objectId","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_objectContract","type":"address"},{"name":"objectClass","type":"uint8"}],"name":"registerNewObjectClass","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/IMinerObject.abi b/abi/IMinerObject.abi new file mode 100644 index 0000000..d7fb2c9 --- /dev/null +++ b/abi/IMinerObject.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_resourceToken","type":"address"},{"name":"_landTokenId","type":"uint256"}],"name":"strengthOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/IMintableERC20.abi b/abi/IMintableERC20.abi new file mode 100644 index 0000000..37a4fb4 --- /dev/null +++ b/abi/IMintableERC20.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/INFTAdaptor.abi b/abi/INFTAdaptor.abi new file mode 100644 index 0000000..64a4975 --- /dev/null +++ b/abi/INFTAdaptor.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_bridge","type":"address"},{"name":"_originTokenId","type":"uint256"}],"name":"approveOriginToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_originTokenId","type":"uint256"}],"name":"ownerInOrigin","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"toOriginTokenId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_originTokenId","type":"uint256"}],"name":"toMirrorTokenId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_originTokenId","type":"uint256"},{"name":"_mirrorTokenId","type":"uint256"}],"name":"cacheMirrorTokenId","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_originTokenId","type":"uint256"}],"name":"toMirrorTokenIdAndIncrease","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/IObjectOwnership.abi b/abi/IObjectOwnership.abi new file mode 100644 index 0000000..786ea75 --- /dev/null +++ b/abi/IObjectOwnership.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"mintObject","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"burnObject","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/IPetBase.abi b/abi/IPetBase.abi new file mode 100644 index 0000000..38629ae --- /dev/null +++ b/abi/IPetBase.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"pet2TiedStatus","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/IRevenuePool.abi b/abi/IRevenuePool.abi new file mode 100644 index 0000000..1d273ce --- /dev/null +++ b/abi/IRevenuePool.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_token","type":"address"},{"name":"_value","type":"uint256"},{"name":"_buyer","type":"address"}],"name":"reward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tokenAddress","type":"address"}],"name":"settleToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/ISettingsRegistry.abi b/abi/ISettingsRegistry.abi new file mode 100644 index 0000000..e231b5a --- /dev/null +++ b/abi/ISettingsRegistry.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"uint256"}],"name":"setUintProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"bytesOf","outputs":[{"name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"uintOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"bytes"}],"name":"setBytesProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"bool"}],"name":"setBoolProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"int256"}],"name":"setIntProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"intOf","outputs":[{"name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"address"}],"name":"setAddressProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"boolOf","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"addressOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"stringOf","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"getValueTypeOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"string"}],"name":"setStringProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_propertyName","type":"bytes32"},{"indexed":false,"name":"_type","type":"uint256"}],"name":"ChangeProperty","type":"event"}] diff --git a/abi/ISmartToken.abi b/abi/ISmartToken.abi new file mode 100644 index 0000000..804bb3f --- /dev/null +++ b/abi/ISmartToken.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_disable","type":"bool"}],"name":"disableTransfers","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"issue","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_amount","type":"uint256"}],"name":"destroy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/ITokenLocation.abi b/abi/ITokenLocation.abi new file mode 100644 index 0000000..c50b1d6 --- /dev/null +++ b/abi/ITokenLocation.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_x","type":"int256"},{"name":"_y","type":"int256"}],"name":"setTokenLocationHM","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getTokenLocation","outputs":[{"name":"","type":"int256"},{"name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getTokenLocationHM","outputs":[{"name":"","type":"int256"},{"name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"hasLocation","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_x","type":"int256"},{"name":"_y","type":"int256"}],"name":"setTokenLocation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/ITokenUse.abi b/abi/ITokenUse.abi new file mode 100644 index 0000000..03e2fec --- /dev/null +++ b/abi/ITokenUse.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_user","type":"address"}],"name":"removeActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getTokenUser","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"takeTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"cancelTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"isObjectInHireStage","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"isObjectReadyToUse","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAX_UINT48_TIME","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"_acceptedActivity","type":"address"}],"name":"createTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_user","type":"address"},{"name":"_endTime","type":"uint256"}],"name":"addActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/ITokenVendor.abi b/abi/ITokenVendor.abi new file mode 100644 index 0000000..d627572 --- /dev/null +++ b/abi/ITokenVendor.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[],"name":"totalSellEthTransfered","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"sellTokenRate","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newSellTokenRate","type":"uint256"}],"name":"changeSellTokenRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_th","type":"address"}],"name":"buyToken","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"totalBuyTokenTransfered","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"totalBuyEtherCollected","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_value","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"tokenFallback","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"buyTokenRate","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newBuyTokenRate","type":"uint256"}],"name":"changeBuyTokenRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_th","type":"address"},{"name":"_value","type":"uint256"}],"name":"sellToken","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"totalSellTokenCollected","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/IUserPoints.abi b/abi/IUserPoints.abi new file mode 100644 index 0000000..25f2101 --- /dev/null +++ b/abi/IUserPoints.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"pointsBalanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_pointAmount","type":"uint256"}],"name":"addPoints","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"pointsSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_pointAmount","type":"uint256"}],"name":"subPoints","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"user","type":"address"},{"indexed":false,"name":"pointAmount","type":"uint256"}],"name":"AddedPoints","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"user","type":"address"},{"indexed":false,"name":"pointAmount","type":"uint256"}],"name":"SubedPoints","type":"event"}] diff --git a/abi/InterstellarEncoder.abi b/abi/InterstellarEncoder.abi new file mode 100644 index 0000000..cd0c5da --- /dev/null +++ b/abi/InterstellarEncoder.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"contractAddress2Id","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectContract","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenIdForObjectContract","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAGIC_NUMBER","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"objectContract2ObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CURRENT_LAND","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastContractId","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectClass","type":"uint8"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenId","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CHAIN_ID","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint16"}],"name":"contractId2Address","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectId","outputs":[{"name":"_objectId","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenAddress","type":"address"}],"name":"registerNewTokenContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_objectContract","type":"address"},{"name":"objectClass","type":"uint8"}],"name":"registerNewObjectClass","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] diff --git a/abi/InterstellarEncoderV2.abi b/abi/InterstellarEncoderV2.abi new file mode 100644 index 0000000..17aa9ea --- /dev/null +++ b/abi/InterstellarEncoderV2.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"contractAddress2Id","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectContract","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenIdForObjectContract","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAGIC_NUMBER","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"objectContract2ObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CURRENT_LAND","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastContractId","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectClass","type":"uint8"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenId","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CHAIN_ID","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint16"}],"name":"contractId2Address","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectId","outputs":[{"name":"_objectId","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint8"}],"name":"objectClass2ObjectContract","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenAddress","type":"address"}],"name":"registerNewTokenContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_objectContract","type":"address"},{"name":"_objectClass","type":"uint8"}],"name":"registerNewObjectClass","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] diff --git a/abi/InterstellarEncoderV3.abi b/abi/InterstellarEncoderV3.abi new file mode 100644 index 0000000..eb4f16f --- /dev/null +++ b/abi/InterstellarEncoderV3.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectContract","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenIdForObjectContract","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getProducerId","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAGIC_NUMBER","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_nftAddress","type":"address"},{"name":"_nftId","type":"uint8"}],"name":"registerNewOwnershipContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getOriginAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CURRENT_LAND","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectClass","type":"uint8"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenId","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CHAIN_ID","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint8"}],"name":"classId2Address","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_objectContract","type":"address"},{"name":"_nftAddress","type":"address"},{"name":"_originNftAddress","type":"address"},{"name":"_objectId","type":"uint128"},{"name":"_producerId","type":"uint16"},{"name":"_convertType","type":"uint8"}],"name":"encodeTokenIdForOuterObjectContract","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"ownershipAddress2Id","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"classAddress2Id","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectId","outputs":[{"name":"_objectId","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint8"}],"name":"ownershipId2Address","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_objectContract","type":"address"},{"name":"_objectClass","type":"uint8"}],"name":"registerNewObjectClass","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_nftAddress","type":"address"},{"name":"_originNftAddress","type":"address"},{"name":"_objectClass","type":"uint8"},{"name":"_objectId","type":"uint128"},{"name":"_producerId","type":"uint16"},{"name":"_convertType","type":"uint8"}],"name":"encodeTokenIdForOuter","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] diff --git a/abi/InterstellarEncoderV4.abi b/abi/InterstellarEncoderV4.abi new file mode 100644 index 0000000..781e587 --- /dev/null +++ b/abi/InterstellarEncoderV4.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectContract","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenIdForObjectContract","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getProducerId","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAGIC_NUMBER","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_nftAddress","type":"address"},{"name":"_nftId","type":"uint8"}],"name":"registerNewOwnershipContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getOriginAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CURRENT_LAND","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_objectClass","type":"uint8"},{"name":"_objectId","type":"uint128"}],"name":"encodeTokenId","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CHAIN_ID","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint8"}],"name":"classId2Address","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_objectContract","type":"address"},{"name":"_nftAddress","type":"address"},{"name":"_originNftAddress","type":"address"},{"name":"_objectId","type":"uint128"},{"name":"_producerId","type":"uint16"},{"name":"_convertType","type":"uint8"}],"name":"encodeTokenIdForOuterObjectContract","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"ownershipAddress2Id","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"classAddress2Id","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectId","outputs":[{"name":"_objectId","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint8"}],"name":"ownershipId2Address","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_objectContract","type":"address"},{"name":"_objectClass","type":"uint8"}],"name":"registerNewObjectClass","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_nftAddress","type":"address"},{"name":"_originNftAddress","type":"address"},{"name":"_objectClass","type":"uint8"},{"name":"_objectId","type":"uint128"},{"name":"_producerId","type":"uint16"},{"name":"_convertType","type":"uint8"}],"name":"encodeTokenIdForOuter","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_chainId","type":"uint256"},{"name":"_currenLand","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] diff --git a/abi/Issuing.abi b/abi/Issuing.abi new file mode 100644 index 0000000..2eed326 --- /dev/null +++ b/abi/Issuing.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"addSupportedTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"supportedTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"removeSupportedTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"tokenFallback","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_registry","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"receiver","type":"bytes"}],"name":"BurnAndRedeem","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/KtonVoter.abi b/abi/KtonVoter.abi new file mode 100644 index 0000000..d53a635 --- /dev/null +++ b/abi/KtonVoter.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_num","type":"uint256"}],"name":"getCandidate","outputs":[{"name":"candidate","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"cadidateItems","outputs":[{"name":"voteCount","type":"uint256"},{"name":"sortedIndex","type":"uint256"},{"name":"isRegistered","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_candidate","type":"address"},{"name":"_amount","type":"uint256"}],"name":"vote","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_candidate","type":"address"},{"name":"_amount","type":"uint256"}],"name":"withdrawFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"voterItems","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"sortedCandidates","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"KTON","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"registerCandidate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/LocationCoder.abi b/abi/LocationCoder.abi new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/abi/LocationCoder.abi @@ -0,0 +1 @@ +[] diff --git a/abi/MintAndBurnAuthority.abi b/abi/MintAndBurnAuthority.abi new file mode 100644 index 0000000..75d63a2 --- /dev/null +++ b/abi/MintAndBurnAuthority.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"whiteList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_src","type":"address"},{"name":"","type":"address"},{"name":"_sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_whitelists","type":"address[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] diff --git a/abi/MintAndBurnAuthorityV2.abi b/abi/MintAndBurnAuthorityV2.abi new file mode 100644 index 0000000..774900e --- /dev/null +++ b/abi/MintAndBurnAuthorityV2.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"allowList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_src","type":"address"},{"name":"","type":"address"},{"name":"_sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_allowlists","type":"address[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] diff --git a/abi/MultiSigWallet.abi b/abi/MultiSigWallet.abi new file mode 100644 index 0000000..2926fc0 --- /dev/null +++ b/abi/MultiSigWallet.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"owners","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"}],"name":"removeOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"revokeConfirmation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isOwner","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"address"}],"name":"confirmations","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"pending","type":"bool"},{"name":"executed","type":"bool"}],"name":"getTransactionCount","outputs":[{"name":"count","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"}],"name":"addOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"isConfirmed","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"getConfirmationCount","outputs":[{"name":"count","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"transactions","outputs":[{"name":"destination","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"},{"name":"executed","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getOwners","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"from","type":"uint256"},{"name":"to","type":"uint256"},{"name":"pending","type":"bool"},{"name":"executed","type":"bool"}],"name":"getTransactionIds","outputs":[{"name":"_transactionIds","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"getConfirmations","outputs":[{"name":"_confirmations","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"transactionCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_required","type":"uint256"}],"name":"changeRequirement","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"confirmTransaction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"destination","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"}],"name":"submitTransaction","outputs":[{"name":"transactionId","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"MAX_OWNER_COUNT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"required","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"},{"name":"newOwner","type":"address"}],"name":"replaceOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"executeTransaction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_owners","type":"address[]"},{"name":"_required","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":true,"name":"transactionId","type":"uint256"}],"name":"Confirmation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":true,"name":"transactionId","type":"uint256"}],"name":"Revocation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"transactionId","type":"uint256"}],"name":"Submission","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"transactionId","type":"uint256"}],"name":"Execution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"transactionId","type":"uint256"}],"name":"ExecutionFailure","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"OwnerAddition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"OwnerRemoval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"required","type":"uint256"}],"name":"RequirementChange","type":"event"}] diff --git a/abi/ObjectOwnership.abi b/abi/ObjectOwnership.abi new file mode 100644 index 0000000..27bbc0a --- /dev/null +++ b/abi/ObjectOwnership.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"InterfaceId_ERC165","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"mintObject","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"burnObject","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_approved","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_operator","type":"address"},{"indexed":false,"name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"}] diff --git a/abi/ObjectOwnershipAuthority.abi b/abi/ObjectOwnershipAuthority.abi new file mode 100644 index 0000000..75d63a2 --- /dev/null +++ b/abi/ObjectOwnershipAuthority.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"whiteList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_src","type":"address"},{"name":"","type":"address"},{"name":"_sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_whitelists","type":"address[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] diff --git a/abi/ObjectOwnershipAuthorityV2.abi b/abi/ObjectOwnershipAuthorityV2.abi new file mode 100644 index 0000000..75d63a2 --- /dev/null +++ b/abi/ObjectOwnershipAuthorityV2.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"whiteList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_src","type":"address"},{"name":"","type":"address"},{"name":"_sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_whitelists","type":"address[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] diff --git a/abi/ObjectOwnershipAuthorityV3.abi b/abi/ObjectOwnershipAuthorityV3.abi new file mode 100644 index 0000000..75d63a2 --- /dev/null +++ b/abi/ObjectOwnershipAuthorityV3.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"whiteList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_src","type":"address"},{"name":"","type":"address"},{"name":"_sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_whitelists","type":"address[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] diff --git a/abi/ObjectOwnershipV2.abi b/abi/ObjectOwnershipV2.abi new file mode 100644 index 0000000..f709d76 --- /dev/null +++ b/abi/ObjectOwnershipV2.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_uri","type":"string"}],"name":"setTokenURI","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"InterfaceId_ERC165","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newBaseTokenURI","type":"string"}],"name":"setBaseTokenURI","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"mintObject","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_objectId","type":"uint128"}],"name":"burnObject","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"baseTokenURI","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_approved","type":"address"},{"indexed":true,"name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_operator","type":"address"},{"indexed":false,"name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"}] diff --git a/abi/Ownable.abi b/abi/Ownable.abi new file mode 100644 index 0000000..5776aef --- /dev/null +++ b/abi/Ownable.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] diff --git a/abi/PausableDSAuth.abi b/abi/PausableDSAuth.abi new file mode 100644 index 0000000..8fc788f --- /dev/null +++ b/abi/PausableDSAuth.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/PolkaPetAdaptor.abi b/abi/PolkaPetAdaptor.abi new file mode 100644 index 0000000..9768e30 --- /dev/null +++ b/abi/PolkaPetAdaptor.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_bridge","type":"address"}],"name":"approveToBridge","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastObjectId","outputs":[{"name":"","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"ownerInOrigin","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"allowList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"originNft","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"toOriginTokenId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"convertType","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"name":"cacheMirrorTokenId","outputs":[],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_status","type":"bool"}],"name":"setTokenIDAuth","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_originTokenId","type":"uint256"}],"name":"toMirrorTokenIdAndIncrease","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_bridge","type":"address"}],"name":"cancelApprove","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"producerId","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"getObjectClass","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"pure","type":"function"},{"inputs":[{"name":"_registry","type":"address"},{"name":"_originNft","type":"address"},{"name":"_producerId","type":"uint16"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"status","type":"bool"}],"name":"SetTokenIDAuth","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/Proposal.abi b/abi/Proposal.abi new file mode 100644 index 0000000..27ad024 --- /dev/null +++ b/abi/Proposal.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"doSomething","outputs":[],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"","type":"address"},{"name":"","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/ProposalRegistry.abi b/abi/ProposalRegistry.abi new file mode 100644 index 0000000..87cd4fe --- /dev/null +++ b/abi/ProposalRegistry.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"proposals","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"proposalId","type":"uint256"}],"name":"executeProposal","outputs":[],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"proposalsApproved","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"address"}],"name":"confirmations","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"voter","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"transactionCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"required","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/RBAC.abi b/abi/RBAC.abi new file mode 100644 index 0000000..9eca7f8 --- /dev/null +++ b/abi/RBAC.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_operator","type":"address"},{"name":"_role","type":"string"}],"name":"checkRole","outputs":[],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_operator","type":"address"},{"name":"_role","type":"string"}],"name":"hasRole","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":false,"name":"role","type":"string"}],"name":"RoleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":false,"name":"role","type":"string"}],"name":"RoleRemoved","type":"event"}] diff --git a/abi/RBACWithAdmin.abi b/abi/RBACWithAdmin.abi new file mode 100644 index 0000000..bad6e7a --- /dev/null +++ b/abi/RBACWithAdmin.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_operator","type":"address"},{"name":"_role","type":"string"}],"name":"checkRole","outputs":[],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_operator","type":"address"},{"name":"_role","type":"string"}],"name":"hasRole","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_account","type":"address"},{"name":"_roleName","type":"string"}],"name":"adminRemoveRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_account","type":"address"},{"name":"_roleName","type":"string"}],"name":"adminAddRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"ROLE_ADMIN","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":false,"name":"role","type":"string"}],"name":"RoleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":false,"name":"role","type":"string"}],"name":"RoleRemoved","type":"event"}] diff --git a/abi/RBACWithAuth.abi b/abi/RBACWithAuth.abi new file mode 100644 index 0000000..85543b3 --- /dev/null +++ b/abi/RBACWithAuth.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_operator","type":"address"},{"name":"_role","type":"string"}],"name":"checkRole","outputs":[],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_operator","type":"address"},{"name":"_role","type":"string"}],"name":"hasRole","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ROLE_AUTH_CONTROLLER","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_authority","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_account","type":"address"},{"name":"_roleName","type":"string"}],"name":"adminRemoveRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_account","type":"address"},{"name":"_roleName","type":"string"}],"name":"adminAddRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ROLE_ADMIN","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":false,"name":"role","type":"string"}],"name":"RoleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":false,"name":"role","type":"string"}],"name":"RoleRemoved","type":"event"}] diff --git a/abi/Roles.abi b/abi/Roles.abi new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/abi/Roles.abi @@ -0,0 +1 @@ +[] diff --git a/abi/SafeERC20.abi b/abi/SafeERC20.abi new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/abi/SafeERC20.abi @@ -0,0 +1 @@ +[] diff --git a/abi/SafeMath.abi b/abi/SafeMath.abi new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/abi/SafeMath.abi @@ -0,0 +1 @@ +[] diff --git a/abi/SettingIds.abi b/abi/SettingIds.abi new file mode 100644 index 0000000..76a4475 --- /dev/null +++ b/abi/SettingIds.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/SettingsRegistry.abi b/abi/SettingsRegistry.abi new file mode 100644 index 0000000..f1a27a7 --- /dev/null +++ b/abi/SettingsRegistry.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"uint256"}],"name":"setUintProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"bytesOf","outputs":[{"name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"addressProperties","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"valueTypes","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"uintOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"bytes"}],"name":"setBytesProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"bool"}],"name":"setBoolProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"boolProperties","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"int256"}],"name":"setIntProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"intOf","outputs":[{"name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"address"}],"name":"setAddressProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"boolOf","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"bytesProperties","outputs":[{"name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"intProperties","outputs":[{"name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"addressOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"stringOf","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_propertyName","type":"bytes32"}],"name":"getValueTypeOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_propertyName","type":"bytes32"},{"name":"_value","type":"string"}],"name":"setStringProperty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"uintProperties","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"stringProperties","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_propertyName","type":"bytes32"},{"indexed":false,"name":"_type","type":"uint256"}],"name":"ChangeProperty","type":"event"}] diff --git a/abi/StandardERC20Base.abi b/abi/StandardERC20Base.abi new file mode 100644 index 0000000..20286c1 --- /dev/null +++ b/abi/StandardERC20Base.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"guy","type":"address"},{"name":"wad","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"guy","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}] diff --git a/abi/StandardERC223.abi b/abi/StandardERC223.abi new file mode 100644 index 0000000..f41c22f --- /dev/null +++ b/abi/StandardERC223.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newController","type":"address"}],"name":"changeController","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"name_","type":"bytes32"}],"name":"setName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"issue","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_who","type":"address"},{"name":"_value","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_amount","type":"uint256"}],"name":"destroy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"guy","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_symbol","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"burner","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_token","type":"address"},{"indexed":true,"name":"_controller","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"}],"name":"ERC223Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}] diff --git a/abi/StringUtil.abi b/abi/StringUtil.abi new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/abi/StringUtil.abi @@ -0,0 +1 @@ +[] diff --git a/abi/SupportsInterfaceWithLookup.abi b/abi/SupportsInterfaceWithLookup.abi new file mode 100644 index 0000000..ed3fed4 --- /dev/null +++ b/abi/SupportsInterfaceWithLookup.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"InterfaceId_ERC165","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] diff --git a/abi/TokenBuildInGenesis.abi b/abi/TokenBuildInGenesis.abi new file mode 100644 index 0000000..5b1c641 --- /dev/null +++ b/abi/TokenBuildInGenesis.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_status","type":"bool"}],"name":"setPaused","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"togglePaused","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"},{"name":"_status","type":"bool"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"setRegistry","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"tokenFallback","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"}],"name":"RingBuildInEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"}],"name":"KtonBuildInEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"status","type":"bool"}],"name":"SetStatus","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/TokenBurnDrop.abi b/abi/TokenBurnDrop.abi new file mode 100644 index 0000000..d6b3db1 --- /dev/null +++ b/abi/TokenBurnDrop.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"SS58_PREFIX_DARWINIA","outputs":[{"name":"","type":"bytes1"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"tokenFallback","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"}],"name":"RingBurndropTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"}],"name":"KtonBurndropTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/TokenController.abi b/abi/TokenController.abi new file mode 100644 index 0000000..2b10587 --- /dev/null +++ b/abi/TokenController.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"onTransfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"sig","type":"bytes4"},{"name":"data","type":"bytes"}],"name":"proxyPayment","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"onApprove","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/abi/TokenLocation.abi b/abi/TokenLocation.abi new file mode 100644 index 0000000..d9db01b --- /dev/null +++ b/abi/TokenLocation.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_x","type":"int256"},{"name":"_y","type":"int256"}],"name":"setTokenLocationHM","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getTokenLocation","outputs":[{"name":"","type":"int256"},{"name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getTokenLocationHM","outputs":[{"name":"","type":"int256"},{"name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2LocationId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"hasLocation","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_x","type":"int256"},{"name":"_y","type":"int256"}],"name":"setTokenLocation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/TokenLocationAuthority.abi b/abi/TokenLocationAuthority.abi new file mode 100644 index 0000000..75d63a2 --- /dev/null +++ b/abi/TokenLocationAuthority.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"whiteList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_src","type":"address"},{"name":"","type":"address"},{"name":"_sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_whitelists","type":"address[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] diff --git a/abi/TokenUse.abi b/abi/TokenUse.abi new file mode 100644 index 0000000..0f3d0cc --- /dev/null +++ b/abi/TokenUse.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_user","type":"address"}],"name":"removeActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"removeTokenUseAndActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getTokenUser","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"takeTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"x","type":"address"}],"name":"toBytes","outputs":[{"name":"b","type":"bytes"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"cancelTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2UseOffer","outputs":[{"name":"owner","type":"address"},{"name":"duration","type":"uint48"},{"name":"price","type":"uint256"},{"name":"acceptedActivity","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2CurrentActivity","outputs":[{"name":"activity","type":"address"},{"name":"endTime","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"_acceptedActivity","type":"address"}],"name":"removeUseAndCreateOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"isObjectInHireStage","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"isObjectReadyToUse","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAX_UINT48_TIME","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"","type":"bytes"}],"name":"receiveApproval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"_acceptedActivity","type":"address"}],"name":"createTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2UseStatus","outputs":[{"name":"user","type":"address"},{"name":"owner","type":"address"},{"name":"startTime","type":"uint48"},{"name":"endTime","type":"uint48"},{"name":"price","type":"uint256"},{"name":"acceptedActivity","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_user","type":"address"},{"name":"_endTime","type":"uint256"}],"name":"addActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"duration","type":"uint256"},{"indexed":false,"name":"price","type":"uint256"},{"indexed":false,"name":"acceptedActivity","type":"address"},{"indexed":false,"name":"owner","type":"address"}],"name":"OfferCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"tokenId","type":"uint256"}],"name":"OfferCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"now","type":"uint256"},{"indexed":false,"name":"endTime","type":"uint256"}],"name":"OfferTaken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"activity","type":"address"},{"indexed":false,"name":"endTime","type":"uint256"}],"name":"ActivityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"activity","type":"address"}],"name":"ActivityRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"user","type":"address"},{"indexed":false,"name":"activity","type":"address"}],"name":"TokenUseRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/TokenUseAuthority.abi b/abi/TokenUseAuthority.abi new file mode 100644 index 0000000..75d63a2 --- /dev/null +++ b/abi/TokenUseAuthority.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"whiteList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_src","type":"address"},{"name":"","type":"address"},{"name":"_sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_whitelists","type":"address[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] diff --git a/abi/TokenUseV2.abi b/abi/TokenUseV2.abi new file mode 100644 index 0000000..e636aea --- /dev/null +++ b/abi/TokenUseV2.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_user","type":"address"}],"name":"removeActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_amountMax","type":"uint256"}],"name":"takeTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"removeTokenUseAndActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getTokenUser","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"x","type":"address"}],"name":"toBytes","outputs":[{"name":"b","type":"bytes"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"cancelTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2UseOffer","outputs":[{"name":"owner","type":"address"},{"name":"duration","type":"uint48"},{"name":"price","type":"uint256"},{"name":"acceptedActivity","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2CurrentActivity","outputs":[{"name":"activity","type":"address"},{"name":"endTime","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"_acceptedActivity","type":"address"}],"name":"removeUseAndCreateOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"isObjectInHireStage","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"isObjectReadyToUse","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"","type":"bytes"}],"name":"receiveApproval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"_acceptedActivity","type":"address"}],"name":"createTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2UseStatus","outputs":[{"name":"user","type":"address"},{"name":"owner","type":"address"},{"name":"startTime","type":"uint48"},{"name":"endTime","type":"uint48"},{"name":"price","type":"uint256"},{"name":"acceptedActivity","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_user","type":"address"},{"name":"_endTime","type":"uint256"}],"name":"addActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"duration","type":"uint256"},{"indexed":false,"name":"price","type":"uint256"},{"indexed":false,"name":"acceptedActivity","type":"address"},{"indexed":false,"name":"owner","type":"address"}],"name":"OfferCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"tokenId","type":"uint256"}],"name":"OfferCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"now","type":"uint256"},{"indexed":false,"name":"endTime","type":"uint256"}],"name":"OfferTaken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"activity","type":"address"},{"indexed":false,"name":"endTime","type":"uint256"}],"name":"ActivityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"activity","type":"address"}],"name":"ActivityRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"user","type":"address"},{"indexed":false,"name":"activity","type":"address"}],"name":"TokenUseRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/TokenVesting.abi b/abi/TokenVesting.abi new file mode 100644 index 0000000..5893960 --- /dev/null +++ b/abi/TokenVesting.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[],"name":"duration","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cliff","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_token","type":"address"}],"name":"releasableAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"release","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_token","type":"address"}],"name":"vestedAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"beneficiary","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"revoke","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"revocable","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"released","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"start","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"revoked","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_beneficiary","type":"address"},{"name":"_start","type":"uint256"},{"name":"_cliff","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_revocable","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"Released","type":"event"},{"anonymous":false,"inputs":[],"name":"Revoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] diff --git a/abi/TokenVestingFactory.abi b/abi/TokenVestingFactory.abi new file mode 100644 index 0000000..3fdefbd --- /dev/null +++ b/abi/TokenVestingFactory.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"_beneficiary","type":"address"},{"name":"_start","type":"uint256"},{"name":"_cliff","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_revocable","type":"bool"}],"name":"newTokenVesting","outputs":[{"name":"newContract","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"contracts","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getContractCount","outputs":[{"name":"contractCount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_contractIndex","type":"uint256"},{"name":"_token","type":"address"}],"name":"revokeVesting","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] diff --git a/abi/UserPoints.abi b/abi/UserPoints.abi new file mode 100644 index 0000000..556a033 --- /dev/null +++ b/abi/UserPoints.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"pointsBalanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"points","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_pointAmount","type":"uint256"}],"name":"addPoints","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"allUserPoints","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pointsSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_pointAmount","type":"uint256"}],"name":"subPoints","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"user","type":"address"},{"indexed":false,"name":"pointAmount","type":"uint256"}],"name":"AddedPoints","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"user","type":"address"},{"indexed":false,"name":"pointAmount","type":"uint256"}],"name":"SubedPoints","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/UserPointsAuthority.abi b/abi/UserPointsAuthority.abi new file mode 100644 index 0000000..75d63a2 --- /dev/null +++ b/abi/UserPointsAuthority.abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"whiteList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_src","type":"address"},{"name":"","type":"address"},{"name":"_sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_whitelists","type":"address[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] From 4ebe8cf67f55b4ebe2c6d8a39b6d1180160b1f07 Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 1 Jun 2021 22:21:53 +0800 Subject: [PATCH 49/64] fix transfer issue --- contracts/TokenUseV2.sol | 10 +++++----- contracts/interfaces/IERC20.sol | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 contracts/interfaces/IERC20.sol diff --git a/contracts/TokenUseV2.sol b/contracts/TokenUseV2.sol index dd649b9..9ac04fd 100644 --- a/contracts/TokenUseV2.sol +++ b/contracts/TokenUseV2.sol @@ -1,7 +1,6 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; import "./interfaces/IActivity.sol"; import "./interfaces/ISettingsRegistry.sol"; @@ -10,6 +9,7 @@ import "./interfaces/IActivityObject.sol"; import "./interfaces/IRevenuePool.sol"; import "./SettingIds.sol"; import "./DSAuth.sol"; +import "./interfaces/IERC20.sol"; contract TokenUseV2 is DSAuth, SettingIds { using SafeMath for *; @@ -156,9 +156,9 @@ contract TokenUseV2 is DSAuth, SettingIds { function _pay(address ring, address _seller, uint256 expense) internal { uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); - ERC20(ring).transfer(_seller, expense.sub(cut)); + IERC20(ring).transfer(_seller, expense.sub(cut)); address pool = registry.addressOf(CONTRACT_REVENUE_POOL); - ERC20(ring).approve(pool, cut); + IERC20(ring).approve(pool, cut); IRevenuePool(pool).reward(ring, cut, msg.sender); } @@ -166,7 +166,7 @@ contract TokenUseV2 is DSAuth, SettingIds { uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); require(_amountMax >= expense, "offer too low"); address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); - ERC20(ring).transferFrom(msg.sender, address(this), expense); + IERC20(ring).transferFrom(msg.sender, address(this), expense); _pay(ring, tokenId2UseOffer[_tokenId].owner, expense); _takeTokenUseOffer(_tokenId, msg.sender); } @@ -304,7 +304,7 @@ contract TokenUseV2 is DSAuth, SettingIds { owner.transfer(address(this).balance); return; } - ERC20 token = ERC20(_token); + IERC20 token = IERC20(_token); uint balance = token.balanceOf(address(this)); token.transfer(owner, balance); diff --git a/contracts/interfaces/IERC20.sol b/contracts/interfaces/IERC20.sol new file mode 100644 index 0000000..329ba4d --- /dev/null +++ b/contracts/interfaces/IERC20.sol @@ -0,0 +1,10 @@ +pragma solidity ^0.4.24; + +interface IERC20 { + function totalSupply() external view returns (uint256); + function balanceOf(address account) external view returns (uint256); + function transfer(address recipient, uint256 amount) external returns (bool); + function allowance(address owner, address spender) external view returns (uint256); + function approve(address spender, uint256 amount) external returns (bool); + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); +} From 701bb85409c899bf932a9c127b5b8061557c8990 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 4 Jun 2021 17:51:29 +0800 Subject: [PATCH 50/64] rm unsed code --- contracts/TokenUseV2.sol | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contracts/TokenUseV2.sol b/contracts/TokenUseV2.sol index 9ac04fd..8601a13 100644 --- a/contracts/TokenUseV2.sol +++ b/contracts/TokenUseV2.sol @@ -311,9 +311,4 @@ contract TokenUseV2 is DSAuth, SettingIds { emit ClaimedTokens(_token, owner, balance); } - function toBytes(address x) public pure returns (bytes b) { - b = new bytes(32); - assembly { mstore(add(b, 32), x) } - } - } From ea0ab33679984b68465c4c1aafb90d66ebcb23c3 Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 30 Jun 2021 10:35:48 +0800 Subject: [PATCH 51/64] fix kitty issue --- contracts/ERC721BridgeV2.sol | 53 ++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 2d58561..ce25f5a 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -51,7 +51,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R originNFT2Adaptor[_originNftAddress] = _erc721Adaptor; } - function swapOut(uint256 _mirrorTokenId) public { + function swapOut721(uint256 _mirrorTokenId) public { IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); address nftContract = interstellarEncoder.getOriginAddress(_mirrorTokenId); require(nftContract != address(0), "No such NFT contract"); @@ -123,7 +123,9 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R } // V2 add - Support PolkaPet - function _bridgeIn1155(address _originNftAddress, uint256 _originTokenId, address _from, uint256 _value) private { + function swapIn1155(address _originNftAddress, uint256 _originTokenId, uint256 _value) public whenNotPaused() { + address _from = msg.sender; + IERC1155(_originNftAddress).safeTransferFrom(_from, address(this), _originTokenId, _value, ""); address adaptor = originNFT2Adaptor[_originNftAddress]; require(adaptor != address(0), "Not registered!"); address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); @@ -136,7 +138,9 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R } } - function _bridgeIn721(address _originNftAddress, uint256 _originTokenId, address _owner) private { + function swapIn721(address _originNftAddress, uint256 _originTokenId) public whenNotPaused() { + address _owner = msg.sender; + ERC721(_originNftAddress).transferFrom(_owner, address(this), _originTokenId); address adaptor = originNFT2Adaptor[_originNftAddress]; require(adaptor != address(0), "Not registered!"); uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); @@ -153,48 +157,39 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R function onERC721Received( address /*_operator*/, - address _from, - uint256 _tokenId, + address /*_from*/, + uint256 /*_tokenId*/, bytes /*_data*/ ) - whenNotPaused() - public + external returns(bytes4) { - _bridgeIn721(msg.sender, _tokenId, _from); return ERC721_RECEIVED; } function onERC1155Received( - address /*operator*/, - address from, - uint256 id, - uint256 value, - bytes /*data*/ + address /*operator*/, + address /*from*/, + uint256 /*id*/, + uint256 /*value*/, + bytes /*data*/ ) - whenNotPaused() - external - returns(bytes4) + external + returns(bytes4) { - _bridgeIn1155(msg.sender, id, from, value); return ERC1155_RECEIVED_VALUE; } function onERC1155BatchReceived( - address /*operator*/, - address from, - uint256[] ids, - uint256[] values, - bytes /*data*/ + address /*operator*/, + address /*from*/, + uint256[] /*ids*/, + uint256[] /*values*/, + bytes /*data*/ ) - whenNotPaused() - external - returns(bytes4) + external + returns(bytes4) { - require(ids.length == values.length, "INVALID_ARRAYS_LENGTH"); - for (uint256 i = 0; i < ids.length; i++) { - _bridgeIn1155(msg.sender, ids[i], from, values[i]); - } return ERC1155_BATCH_RECEIVED_VALUE; } } From 92ffa1592d235b58e8eff26f82882d97dec00cb2 Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 30 Jun 2021 10:38:14 +0800 Subject: [PATCH 52/64] build --- contracts/ERC721BridgeV2.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index ce25f5a..9e69fdf 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -161,7 +161,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R uint256 /*_tokenId*/, bytes /*_data*/ ) - external + public returns(bytes4) { return ERC721_RECEIVED; From 0cc262188958d7136cc8c3453ca3e9dc2ae715f5 Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 30 Jun 2021 13:59:02 +0800 Subject: [PATCH 53/64] update abi --- abi/ERC721BridgeV2.abi | 2 +- abi/IERC20.abi | 1 + abi/TokenUseV2.abi | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 abi/IERC20.abi diff --git a/abi/ERC721BridgeV2.abi b/abi/ERC721BridgeV2.abi index 49292ef..370ce44 100644 --- a/abi/ERC721BridgeV2.abi +++ b/abi/ERC721BridgeV2.abi @@ -1 +1 @@ -[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"mirrorId2OriginId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"","type":"address"},{"name":"_from","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_originNFT","type":"address"},{"name":"_originTokenId","type":"uint256"}],"name":"mirrorOfOrigin","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"originNFT2Adaptor","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"mirrorId2OriginId1155","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"originOwnershipAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"swapOut","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_originNftAddress","type":"address"},{"name":"_erc721Adaptor","type":"address"}],"name":"registerAdaptor","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"isBridged","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"ownerOfMirror","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"","type":"address"},{"name":"from","type":"address"},{"name":"ids","type":"uint256[]"},{"name":"values","type":"uint256[]"},{"name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"swapOut1155","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"","type":"address"},{"name":"from","type":"address"},{"name":"id","type":"uint256"},{"name":"value","type":"uint256"},{"name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"originContract","type":"address"},{"indexed":false,"name":"originTokenId","type":"uint256"},{"indexed":false,"name":"mirrorTokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"}],"name":"SwapIn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"originContract","type":"address"},{"indexed":false,"name":"originTokenId","type":"uint256"},{"indexed":false,"name":"mirrorTokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"}],"name":"SwapOut","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"mirrorId2OriginId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_originNftAddress","type":"address"},{"name":"_originTokenId","type":"uint256"},{"name":"_value","type":"uint256"}],"name":"swapIn1155","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_originNFT","type":"address"},{"name":"_originTokenId","type":"uint256"}],"name":"mirrorOfOrigin","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"originNFT2Adaptor","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"mirrorId2OriginId1155","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"swapOut721","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"originOwnershipAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_originNftAddress","type":"address"},{"name":"_erc721Adaptor","type":"address"}],"name":"registerAdaptor","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"isBridged","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"ownerOfMirror","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_originNftAddress","type":"address"},{"name":"_originTokenId","type":"uint256"}],"name":"swapIn721","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"uint256[]"},{"name":"","type":"uint256[]"},{"name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_mirrorTokenId","type":"uint256"}],"name":"swapOut1155","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"originContract","type":"address"},{"indexed":false,"name":"originTokenId","type":"uint256"},{"indexed":false,"name":"mirrorTokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"}],"name":"SwapIn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"originContract","type":"address"},{"indexed":false,"name":"originTokenId","type":"uint256"},{"indexed":false,"name":"mirrorTokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"}],"name":"SwapOut","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] diff --git a/abi/IERC20.abi b/abi/IERC20.abi new file mode 100644 index 0000000..5c3f94f --- /dev/null +++ b/abi/IERC20.abi @@ -0,0 +1 @@ +[{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"amount","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"sender","type":"address"},{"name":"recipient","type":"address"},{"name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"account","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"recipient","type":"address"},{"name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}] diff --git a/abi/TokenUseV2.abi b/abi/TokenUseV2.abi index e636aea..b5f5dde 100644 --- a/abi/TokenUseV2.abi +++ b/abi/TokenUseV2.abi @@ -1 +1 @@ -[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_user","type":"address"}],"name":"removeActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_amountMax","type":"uint256"}],"name":"takeTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"removeTokenUseAndActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getTokenUser","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"x","type":"address"}],"name":"toBytes","outputs":[{"name":"b","type":"bytes"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"cancelTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2UseOffer","outputs":[{"name":"owner","type":"address"},{"name":"duration","type":"uint48"},{"name":"price","type":"uint256"},{"name":"acceptedActivity","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2CurrentActivity","outputs":[{"name":"activity","type":"address"},{"name":"endTime","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"_acceptedActivity","type":"address"}],"name":"removeUseAndCreateOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"isObjectInHireStage","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"isObjectReadyToUse","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"","type":"bytes"}],"name":"receiveApproval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"_acceptedActivity","type":"address"}],"name":"createTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2UseStatus","outputs":[{"name":"user","type":"address"},{"name":"owner","type":"address"},{"name":"startTime","type":"uint48"},{"name":"endTime","type":"uint48"},{"name":"price","type":"uint256"},{"name":"acceptedActivity","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_user","type":"address"},{"name":"_endTime","type":"uint256"}],"name":"addActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"duration","type":"uint256"},{"indexed":false,"name":"price","type":"uint256"},{"indexed":false,"name":"acceptedActivity","type":"address"},{"indexed":false,"name":"owner","type":"address"}],"name":"OfferCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"tokenId","type":"uint256"}],"name":"OfferCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"now","type":"uint256"},{"indexed":false,"name":"endTime","type":"uint256"}],"name":"OfferTaken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"activity","type":"address"},{"indexed":false,"name":"endTime","type":"uint256"}],"name":"ActivityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"activity","type":"address"}],"name":"ActivityRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"user","type":"address"},{"indexed":false,"name":"activity","type":"address"}],"name":"TokenUseRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] +[{"constant":true,"inputs":[],"name":"CONTRACT_USER_POINTS","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_BRIDGE_FEE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_BRIDGE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WATER_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_GOLD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_user","type":"address"}],"name":"removeActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_RING_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_AUCTION_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_amountMax","type":"uint256"}],"name":"takeTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_LOCATION","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"removeTokenUseAndActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getTokenUser","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_KTON_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_WOOD_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_FIRE_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"cancelTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2UseOffer","outputs":[{"name":"owner","type":"address"},{"name":"duration","type":"uint48"},{"name":"price","type":"uint256"},{"name":"acceptedActivity","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2CurrentActivity","outputs":[{"name":"activity","type":"address"},{"name":"endTime","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"_acceptedActivity","type":"address"}],"name":"removeUseAndCreateOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_INTERSTELLAR_ENCODER","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_PET_BASE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"isObjectInHireStage","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"isObjectReadyToUse","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_SOIL_ERC20_TOKEN","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_OBJECT_OWNERSHIP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"","type":"bytes"}],"name":"receiveApproval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TOKEN_USE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_registry","type":"address"}],"name":"initializeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ERC721_BRIDGE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_REVENUE_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_duration","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"_acceptedActivity","type":"address"}],"name":"createTokenUseOffer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_LAND_RESOURCE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenId2UseStatus","outputs":[{"name":"user","type":"address"},{"name":"owner","type":"address"},{"name":"startTime","type":"uint48"},{"name":"endTime","type":"uint48"},{"name":"price","type":"uint256"},{"name":"acceptedActivity","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_REFERER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UINT_TOKEN_OFFER_CUT","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_DIVIDENDS_POOL","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_user","type":"address"},{"name":"_endTime","type":"uint256"}],"name":"addActivity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"duration","type":"uint256"},{"indexed":false,"name":"price","type":"uint256"},{"indexed":false,"name":"acceptedActivity","type":"address"},{"indexed":false,"name":"owner","type":"address"}],"name":"OfferCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"tokenId","type":"uint256"}],"name":"OfferCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"now","type":"uint256"},{"indexed":false,"name":"endTime","type":"uint256"}],"name":"OfferTaken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"activity","type":"address"},{"indexed":false,"name":"endTime","type":"uint256"}],"name":"ActivityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"activity","type":"address"}],"name":"ActivityRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"user","type":"address"},{"indexed":false,"name":"activity","type":"address"}],"name":"TokenUseRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] From 416f296c798d3a6d0e64b597847407e9c2b70884 Mon Sep 17 00:00:00 2001 From: echo Date: Sat, 3 Jul 2021 12:28:32 +0800 Subject: [PATCH 54/64] pet: kitty approve --- contracts/ERC721BridgeV2.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 9e69fdf..fc498af 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -65,6 +65,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); + ERC721(nftContract).approve(address(this), originTokenId); ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); emit SwapOut(nftContract, originTokenId, _mirrorTokenId, msg.sender); } From b1d24653aa4b3e8124d05e5c80197ef4632124f5 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 9 Jul 2021 00:25:13 +0800 Subject: [PATCH 55/64] pet: forward compatible --- contracts/ERC721BridgeV2.sol | 20 +++++++++++--------- contracts/PolkaPetAdaptor.sol | 5 +++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index fc498af..4539ebd 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -64,9 +64,13 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R require(apostleTokenId == 0, "Pet has been tied."); uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - ERC721(objectOwnership).transferFrom(msg.sender, address(this), _mirrorTokenId); - ERC721(nftContract).approve(address(this), originTokenId); - ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); + address owner = ERC721(objectOwnership).ownerOf(_mirrorTokenId); + if (owner != address(this)) { + ERC721(nftContract).approve(address(this), originTokenId); + ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); + } + IBurnableERC20(objectOwnership).burn(owner, _mirrorTokenId); + delete mirrorId2OriginId[_mirrorTokenId]; emit SwapOut(nftContract, originTokenId, _mirrorTokenId, msg.sender); } @@ -146,12 +150,10 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R require(adaptor != address(0), "Not registered!"); uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - if (!isBridged(mirrorTokenId)) { - IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); - INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); - mirrorId2OriginId[mirrorTokenId] = _originTokenId; - // emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner); - } + require(!isBridged(mirrorTokenId), "Already swap in"); + IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); + INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); + mirrorId2OriginId[mirrorTokenId] = _originTokenId; ERC721(objectOwnership).transferFrom(address(this), _owner, mirrorTokenId); emit SwapIn(_originNftAddress, _originTokenId, mirrorTokenId, _owner); } diff --git a/contracts/PolkaPetAdaptor.sol b/contracts/PolkaPetAdaptor.sol index 1653c03..139a211 100644 --- a/contracts/PolkaPetAdaptor.sol +++ b/contracts/PolkaPetAdaptor.sol @@ -37,8 +37,9 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { producerId = _producerId; convertType = 128; // f(x) = x,fullfill with zero at left side. - allowList[2] = true; - allowList[11] = true; + allowList[2] = true; // Darwinia + allowList[11] = true; // EVO + allowList[20] = true; // Crab } function setTokenIDAuth(uint256 _tokenId, bool _status) public auth { From 866332e854c23b8122c44fa1de8cec52d60aa3e1 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 9 Jul 2021 10:13:35 +0800 Subject: [PATCH 56/64] pet: polkadot adaptor auth --- contracts/PolkaPetAdaptor.sol | 38 +++----------------------- contracts/PolkaPetAdaptorAuthority.sol | 17 ++++++++++++ 2 files changed, 21 insertions(+), 34 deletions(-) create mode 100644 contracts/PolkaPetAdaptorAuthority.sol diff --git a/contracts/PolkaPetAdaptor.sol b/contracts/PolkaPetAdaptor.sol index 139a211..414de26 100644 --- a/contracts/PolkaPetAdaptor.sol +++ b/contracts/PolkaPetAdaptor.sol @@ -3,10 +3,7 @@ pragma solidity ^0.4.24; import "./SettingIds.sol"; import "./PausableDSAuth.sol"; import "./interfaces/ISettingsRegistry.sol"; -import "./interfaces/INFTAdaptor.sol"; -// import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; import "./interfaces/IInterstellarEncoderV3.sol"; -import "./interfaces/IERC1155.sol"; contract PolkaPetAdaptor is PausableDSAuth, SettingIds { @@ -24,14 +21,14 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { ISettingsRegistry public registry; - IERC1155 public originNft; + address public originNft; uint128 public lastObjectId; // tokenID => bool allowList mapping (uint256 => bool) public allowList; - constructor(ISettingsRegistry _registry, IERC1155 _originNft, uint16 _producerId) public { + constructor(ISettingsRegistry _registry, address _originNft, uint16 _producerId) public { registry = _registry; originNft = _originNft; producerId = _producerId; @@ -47,7 +44,7 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { emit SetTokenIDAuth(_tokenId, _status); } - function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public returns (uint256) { + function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public auth returns (uint256) { require(allowList[_originTokenId], "POLKPET: PERMISSION"); lastObjectId += 1; uint128 mirrorObjectId = uint128(lastObjectId & 0xffffffffffffffffffffffffffffffff); @@ -56,36 +53,9 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); uint256 mirrorTokenId = interstellarEncoder.encodeTokenIdForOuterObjectContract( - petBase, objectOwnership, address(originNft), mirrorObjectId, producerId, convertType); + petBase, objectOwnership, originNft, mirrorObjectId, producerId, convertType); return mirrorTokenId; } - function ownerInOrigin(uint256 /*_originTokenId*/) public pure returns (address) { - revert("NOT_SUPPORT"); - } - - // if the convertion is not calculatable, and need to use cache mapping in Bridge. - // then .. - function toOriginTokenId(uint256 /*_mirrorTokenId*/) public pure returns (uint256) { - revert("NOT_SUPPORT"); - } - - function approveToBridge(address _bridge) public onlyOwner { - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - IERC1155(objectOwnership).setApprovalForAll(_bridge, true); - } - - function cancelApprove(address _bridge) public onlyOwner { - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - IERC1155(objectOwnership).setApprovalForAll(_bridge, false); - } - - function getObjectClass(uint256 /*_originTokenId*/) public pure returns (uint8) { - revert("NOT_SUPPORT"); - } - - function cacheMirrorTokenId(uint256 /*_originTokenId*/, uint256 /*_mirrorTokenId*/) public view auth { - revert("NOT_SUPPORT"); - } } diff --git a/contracts/PolkaPetAdaptorAuthority.sol b/contracts/PolkaPetAdaptorAuthority.sol new file mode 100644 index 0000000..d168ef1 --- /dev/null +++ b/contracts/PolkaPetAdaptorAuthority.sol @@ -0,0 +1,17 @@ +pragma solidity ^0.4.24; + +contract ERC721AdaptorAuthority { + mapping (address => bool) public whiteList; + + constructor(address[] _whitelists) public { + for (uint i = 0; i < _whitelists.length; i++) { + whiteList[_whitelists[i]] = true; + } + } + + function canCall( + address _src, address /*_dst*/, bytes4 _sig + ) public view returns (bool) { + return whiteList[_src] && _sig == bytes4(keccak256("toMirrorTokenIdAndIncrease(uint256)")); + } +} From d795de6d984a0c3131af57fb0f39a5a9b102dbea Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 9 Jul 2021 10:21:06 +0800 Subject: [PATCH 57/64] pet: polkadot adaptor auth --- contracts/PolkaPetAdaptorAuthority.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/PolkaPetAdaptorAuthority.sol b/contracts/PolkaPetAdaptorAuthority.sol index d168ef1..00060e2 100644 --- a/contracts/PolkaPetAdaptorAuthority.sol +++ b/contracts/PolkaPetAdaptorAuthority.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.24; -contract ERC721AdaptorAuthority { +contract PolkaPetAdaptorAuthority { mapping (address => bool) public whiteList; constructor(address[] _whitelists) public { From c39e99f8d5751308c73c6ae79c2cf2cea7a1b741 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 9 Jul 2021 15:21:40 +0800 Subject: [PATCH 58/64] pet: review --- contracts/ERC721BridgeV2.sol | 9 ++++----- contracts/PolkaPetAdaptor.sol | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index 4539ebd..fcd1e68 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -66,7 +66,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); address owner = ERC721(objectOwnership).ownerOf(_mirrorTokenId); if (owner != address(this)) { - ERC721(nftContract).approve(address(this), originTokenId); + ERC721(nftContract).approve(address(this), originTokenId); // kitty must approve first ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); } IBurnableERC20(objectOwnership).burn(owner, _mirrorTokenId); @@ -81,13 +81,13 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R require(nftContract != address(0), "No such NFT contract"); address adaptor = originNFT2Adaptor[nftContract]; require(adaptor != address(0), "not registered!"); - require(ownerOfMirror(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); + address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); + require(ERC721(objectOwnership).ownerOf(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); (uint256 apostleTokenId,) = IPetBase(petBase).pet2TiedStatus(_mirrorTokenId); require(apostleTokenId == 0, "Pet has been tied."); uint256 originTokenId = mirrorId2OriginId1155[_mirrorTokenId]; - address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); IBurnableERC20(objectOwnership).burn(msg.sender, _mirrorTokenId); IERC1155(nftContract).safeTransferFrom(address(this), msg.sender, originTokenId, 1, ""); delete mirrorId2OriginId1155[_mirrorTokenId]; @@ -151,10 +151,9 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); require(!isBridged(mirrorTokenId), "Already swap in"); - IMintableERC20(objectOwnership).mint(address(this), mirrorTokenId); INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId); mirrorId2OriginId[mirrorTokenId] = _originTokenId; - ERC721(objectOwnership).transferFrom(address(this), _owner, mirrorTokenId); + IMintableERC20(objectOwnership).mint(_owner, mirrorTokenId); emit SwapIn(_originNftAddress, _originTokenId, mirrorTokenId, _owner); } diff --git a/contracts/PolkaPetAdaptor.sol b/contracts/PolkaPetAdaptor.sol index 414de26..236572a 100644 --- a/contracts/PolkaPetAdaptor.sol +++ b/contracts/PolkaPetAdaptor.sol @@ -13,7 +13,6 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { /* * Storage */ - bool private singletonLock = false; uint16 public producerId; @@ -47,8 +46,8 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public auth returns (uint256) { require(allowList[_originTokenId], "POLKPET: PERMISSION"); lastObjectId += 1; + require(lastObjectId < uint128(-1), "POLKPET: OBJECTID_OVERFLOW"); uint128 mirrorObjectId = uint128(lastObjectId & 0xffffffffffffffffffffffffffffffff); - require(lastObjectId <= uint128(-1), "POLKPET: OBJECTID_OVERFLOW"); address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); From 83c26799317a7aac92d664450c8cbfb5bd290286 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 9 Jul 2021 17:50:00 +0800 Subject: [PATCH 59/64] Format --- contracts/PolkaPetAdaptor.sol | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/contracts/PolkaPetAdaptor.sol b/contracts/PolkaPetAdaptor.sol index 236572a..c1e0ce5 100644 --- a/contracts/PolkaPetAdaptor.sol +++ b/contracts/PolkaPetAdaptor.sol @@ -8,7 +8,7 @@ import "./interfaces/IInterstellarEncoderV3.sol"; contract PolkaPetAdaptor is PausableDSAuth, SettingIds { - event SetTokenIDAuth(uint256 indexed tokenId, bool status); + event SetTokenIDAuth(uint256 indexed tokenId, bool status); /* * Storage @@ -22,9 +22,9 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { address public originNft; - uint128 public lastObjectId; + uint128 public lastObjectId; - // tokenID => bool allowList + // tokenID => bool allowList mapping (uint256 => bool) public allowList; constructor(ISettingsRegistry _registry, address _originNft, uint16 _producerId) public { @@ -38,21 +38,21 @@ contract PolkaPetAdaptor is PausableDSAuth, SettingIds { allowList[20] = true; // Crab } - function setTokenIDAuth(uint256 _tokenId, bool _status) public auth { - allowList[_tokenId] = _status; - emit SetTokenIDAuth(_tokenId, _status); - } + function setTokenIDAuth(uint256 _tokenId, bool _status) public auth { + allowList[_tokenId] = _status; + emit SetTokenIDAuth(_tokenId, _status); + } function toMirrorTokenIdAndIncrease(uint256 _originTokenId) public auth returns (uint256) { - require(allowList[_originTokenId], "POLKPET: PERMISSION"); + require(allowList[_originTokenId], "POLKPET: PERMISSION"); lastObjectId += 1; - require(lastObjectId < uint128(-1), "POLKPET: OBJECTID_OVERFLOW"); + require(lastObjectId < uint128(-1), "POLKPET: OBJECTID_OVERFLOW"); uint128 mirrorObjectId = uint128(lastObjectId & 0xffffffffffffffffffffffffffffffff); address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); IInterstellarEncoderV3 interstellarEncoder = IInterstellarEncoderV3(registry.addressOf(SettingIds.CONTRACT_INTERSTELLAR_ENCODER)); uint256 mirrorTokenId = interstellarEncoder.encodeTokenIdForOuterObjectContract( - petBase, objectOwnership, originNft, mirrorObjectId, producerId, convertType); + petBase, objectOwnership, originNft, mirrorObjectId, producerId, convertType); return mirrorTokenId; } From 3877465d9dcf4dd53ea023d97eb8c23da14f2d4a Mon Sep 17 00:00:00 2001 From: echo Date: Sat, 10 Jul 2021 12:09:11 +0800 Subject: [PATCH 60/64] pet: change interface --- contracts/ERC721BridgeV2.sol | 18 ++--- contracts/interfaces/IERC721.sol | 86 ++++++++++++++++++++++++ contracts/interfaces/IERC721Receiver.sol | 38 +++++++++++ 3 files changed, 133 insertions(+), 9 deletions(-) create mode 100644 contracts/interfaces/IERC721.sol create mode 100644 contracts/interfaces/IERC721Receiver.sol diff --git a/contracts/ERC721BridgeV2.sol b/contracts/ERC721BridgeV2.sol index fcd1e68..f742d8a 100644 --- a/contracts/ERC721BridgeV2.sol +++ b/contracts/ERC721BridgeV2.sol @@ -7,10 +7,10 @@ import "./interfaces/IInterstellarEncoderV3.sol"; import "./interfaces/IMintableERC20.sol"; import "./interfaces/IBurnableERC20.sol"; import "./interfaces/INFTAdaptor.sol"; -import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -import "openzeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol"; import "./interfaces/IERC1155.sol"; import "./interfaces/IERC1155Receiver.sol"; +import "./interfaces/IERC721.sol"; +import "./interfaces/IERC721Receiver.sol"; import "./interfaces/IPetBase.sol"; @@ -19,7 +19,7 @@ import "./interfaces/IPetBase.sol"; * originTokenId - token outside evolutionLand * mirrorTokenId - mirror token */ -contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155Receiver { +contract ERC721BridgeV2 is SettingIds, PausableDSAuth, IERC721Receiver, IERC1155Receiver { /* * Storage @@ -64,10 +64,10 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R require(apostleTokenId == 0, "Pet has been tied."); uint256 originTokenId = mirrorId2OriginId[_mirrorTokenId]; address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - address owner = ERC721(objectOwnership).ownerOf(_mirrorTokenId); + address owner = IERC721(objectOwnership).ownerOf(_mirrorTokenId); if (owner != address(this)) { - ERC721(nftContract).approve(address(this), originTokenId); // kitty must approve first - ERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); + IERC721(nftContract).approve(address(this), originTokenId); // kitty must approve first + IERC721(nftContract).transferFrom(address(this), msg.sender, originTokenId); } IBurnableERC20(objectOwnership).burn(owner, _mirrorTokenId); delete mirrorId2OriginId[_mirrorTokenId]; @@ -82,7 +82,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R address adaptor = originNFT2Adaptor[nftContract]; require(adaptor != address(0), "not registered!"); address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - require(ERC721(objectOwnership).ownerOf(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); + require(IERC721(objectOwnership).ownerOf(_mirrorTokenId) == msg.sender, "you have no right to swap it out!"); address petBase = registry.addressOf(SettingIds.CONTRACT_PET_BASE); (uint256 apostleTokenId,) = IPetBase(petBase).pet2TiedStatus(_mirrorTokenId); @@ -108,7 +108,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R // return human owner of the token function ownerOfMirror(uint256 _mirrorTokenId) public view returns (address) { address objectOwnership = registry.addressOf(SettingIds.CONTRACT_OBJECT_OWNERSHIP); - address owner = ERC721(objectOwnership).ownerOf(_mirrorTokenId); + address owner = IERC721(objectOwnership).ownerOf(_mirrorTokenId); if(owner != address(this)) { return owner; } else { @@ -145,7 +145,7 @@ contract ERC721BridgeV2 is SettingIds, PausableDSAuth, ERC721Receiver, IERC1155R function swapIn721(address _originNftAddress, uint256 _originTokenId) public whenNotPaused() { address _owner = msg.sender; - ERC721(_originNftAddress).transferFrom(_owner, address(this), _originTokenId); + IERC721(_originNftAddress).transferFrom(_owner, address(this), _originTokenId); address adaptor = originNFT2Adaptor[_originNftAddress]; require(adaptor != address(0), "Not registered!"); uint256 mirrorTokenId = INFTAdaptor(adaptor).toMirrorTokenId(_originTokenId); diff --git a/contracts/interfaces/IERC721.sol b/contracts/interfaces/IERC721.sol new file mode 100644 index 0000000..8324966 --- /dev/null +++ b/contracts/interfaces/IERC721.sol @@ -0,0 +1,86 @@ +pragma solidity ^0.4.24; + +import "./IERC165.sol"; + +/** + * @title IERC721 Non-Fungible Token Standard basic interface + * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md + */ +contract IERC721 is IERC165 { + + bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; + /* + * 0x80ac58cd === + * bytes4(keccak256('balanceOf(address)')) ^ + * bytes4(keccak256('ownerOf(uint256)')) ^ + * bytes4(keccak256('approve(address,uint256)')) ^ + * bytes4(keccak256('getApproved(uint256)')) ^ + * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ + * bytes4(keccak256('isApprovedForAll(address,address)')) ^ + * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ + * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) + */ + + bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; + /* + * 0x4f558e79 === + * bytes4(keccak256('exists(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; + /** + * 0x780e9d63 === + * bytes4(keccak256('totalSupply()')) ^ + * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ + * bytes4(keccak256('tokenByIndex(uint256)')) + */ + + bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; + /** + * 0x5b5e139f === + * bytes4(keccak256('name()')) ^ + * bytes4(keccak256('symbol()')) ^ + * bytes4(keccak256('tokenURI(uint256)')) + */ + + event Transfer( + address indexed _from, + address indexed _to, + uint256 indexed _tokenId + ); + event Approval( + address indexed _owner, + address indexed _approved, + uint256 indexed _tokenId + ); + event ApprovalForAll( + address indexed _owner, + address indexed _operator, + bool _approved + ); + + function balanceOf(address _owner) public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view returns (bool _exists); + + function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) + public view returns (address _operator); + + function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) + public view returns (bool); + + function transferFrom(address _from, address _to, uint256 _tokenId) public; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) + public; + + function safeTransferFrom( + address _from, + address _to, + uint256 _tokenId, + bytes _data + ) + public; +} diff --git a/contracts/interfaces/IERC721Receiver.sol b/contracts/interfaces/IERC721Receiver.sol new file mode 100644 index 0000000..dca4bb6 --- /dev/null +++ b/contracts/interfaces/IERC721Receiver.sol @@ -0,0 +1,38 @@ +pragma solidity ^0.4.24; + + +/** + * @title ERC721 token receiver interface + * @dev Interface for any contract that wants to support safeTransfers + * from ERC721 asset contracts. + */ +contract IERC721Receiver { + /** + * @dev Magic value to be returned upon successful reception of an NFT + * Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`, + * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` + */ + bytes4 internal constant ERC721_RECEIVED = 0x150b7a02; + + /** + * @notice Handle the receipt of an NFT + * @dev The ERC721 smart contract calls this function on the recipient + * after a `safetransfer`. This function MAY throw to revert and reject the + * transfer. Return of other than the magic value MUST result in the + * transaction being reverted. + * Note: the contract address is always the message sender. + * @param _operator The address which called `safeTransferFrom` function + * @param _from The address which previously owned the token + * @param _tokenId The NFT identifier which is being transferred + * @param _data Additional data with no specified format + * @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` + */ + function onERC721Received( + address _operator, + address _from, + uint256 _tokenId, + bytes _data + ) + public + returns(bytes4); +} From 67c3a0fb31c3c6d9e8c8c4e6aefb2bb50352f898 Mon Sep 17 00:00:00 2001 From: echo Date: Tue, 3 Aug 2021 13:34:25 +0800 Subject: [PATCH 61/64] multisig --- contracts/MultiSigWalletContribution.sol | 393 ++++++++++++++++++ ...ltiSigWallet.sol => MultiSigWalletDev.sol} | 2 +- 2 files changed, 394 insertions(+), 1 deletion(-) create mode 100644 contracts/MultiSigWalletContribution.sol rename contracts/{MultiSigWallet.sol => MultiSigWalletDev.sol} (99%) diff --git a/contracts/MultiSigWalletContribution.sol b/contracts/MultiSigWalletContribution.sol new file mode 100644 index 0000000..030ad08 --- /dev/null +++ b/contracts/MultiSigWalletContribution.sol @@ -0,0 +1,393 @@ +pragma solidity ^0.4.15; + + +/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. +/// @author Stefan George - +contract MultiSigWalletContribution { + + /* + * Events + */ + event Confirmation(address indexed sender, uint indexed transactionId); + event Revocation(address indexed sender, uint indexed transactionId); + event Submission(uint indexed transactionId); + event Execution(uint indexed transactionId); + event ExecutionFailure(uint indexed transactionId); + event Deposit(address indexed sender, uint value); + event OwnerAddition(address indexed owner); + event OwnerRemoval(address indexed owner); + event RequirementChange(uint required); + + /* + * Constants + */ + uint constant public MAX_OWNER_COUNT = 50; + + /* + * Storage + */ + mapping (uint => Transaction) public transactions; + mapping (uint => mapping (address => bool)) public confirmations; + mapping (address => bool) public isOwner; + address[] public owners; + uint public required; + uint public transactionCount; + + struct Transaction { + address destination; + uint value; + bytes data; + bool executed; + } + + /* + * Modifiers + */ + modifier onlyWallet() { + require(msg.sender == address(this)); + _; + } + + modifier ownerDoesNotExist(address owner) { + require(!isOwner[owner]); + _; + } + + modifier ownerExists(address owner) { + require(isOwner[owner]); + _; + } + + modifier transactionExists(uint transactionId) { + require(transactions[transactionId].destination != 0); + _; + } + + modifier confirmed(uint transactionId, address owner) { + require(confirmations[transactionId][owner]); + _; + } + + modifier notConfirmed(uint transactionId, address owner) { + require(!confirmations[transactionId][owner]); + _; + } + + modifier notExecuted(uint transactionId) { + require(!transactions[transactionId].executed); + _; + } + + modifier notNull(address _address) { + require(_address != 0); + _; + } + + modifier validRequirement(uint ownerCount, uint _required) { + require(ownerCount <= MAX_OWNER_COUNT + && _required <= ownerCount + && _required != 0 + && ownerCount != 0); + _; + } + + /// @dev Fallback function allows to deposit ether. + function() + public + payable + { + if (msg.value > 0) + emit Deposit(msg.sender, msg.value); + } + + /* + * Public functions + */ + /// @dev Contract constructor sets initial owners and required number of confirmations. + /// @param _owners List of initial owners. + /// @param _required Number of required confirmations. + constructor(address[] _owners, uint _required) + public + validRequirement(_owners.length, _required) + { + for (uint i=0; i<_owners.length; i++) { + require(!isOwner[_owners[i]] && _owners[i] != 0); + isOwner[_owners[i]] = true; + } + owners = _owners; + required = _required; + } + + /// @dev Allows to add a new owner. Transaction has to be sent by wallet. + /// @param owner Address of new owner. + function addOwner(address owner) + public + onlyWallet + ownerDoesNotExist(owner) + notNull(owner) + validRequirement(owners.length + 1, required) + { + isOwner[owner] = true; + owners.push(owner); + emit OwnerAddition(owner); + } + + /// @dev Allows to remove an owner. Transaction has to be sent by wallet. + /// @param owner Address of owner. + function removeOwner(address owner) + public + onlyWallet + ownerExists(owner) + { + isOwner[owner] = false; + for (uint i=0; i owners.length) + changeRequirement(owners.length); + emit OwnerRemoval(owner); + } + + /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. + /// @param owner Address of owner to be replaced. + /// @param newOwner Address of new owner. + function replaceOwner(address owner, address newOwner) + public + onlyWallet + ownerExists(owner) + ownerDoesNotExist(newOwner) + { + for (uint i=0; i -contract MultiSigWallet { +contract MultiSigWalletDev { /* * Events From 0356083655eb241d77389f31f06ccb81d337ffcd Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 11 Feb 2022 19:28:52 +0800 Subject: [PATCH 62/64] crabtest: special name --- contracts/TokenUseCrab.sol | 314 +++++++++++++++++++++++++++++++++++++ 1 file changed, 314 insertions(+) create mode 100644 contracts/TokenUseCrab.sol diff --git a/contracts/TokenUseCrab.sol b/contracts/TokenUseCrab.sol new file mode 100644 index 0000000..bfa14c4 --- /dev/null +++ b/contracts/TokenUseCrab.sol @@ -0,0 +1,314 @@ +pragma solidity ^0.4.24; + +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; +import "./interfaces/IActivity.sol"; +import "./interfaces/ISettingsRegistry.sol"; +import "./interfaces/IInterstellarEncoder.sol"; +import "./interfaces/IActivityObject.sol"; +import "./interfaces/IRevenuePool.sol"; +import "./SettingIds.sol"; +import "./DSAuth.sol"; +import "./interfaces/IERC20.sol"; + +contract TokenUseCrab is DSAuth, SettingIds { + using SafeMath for *; + + // claimedToken event + event ClaimedTokens(address indexed token, address indexed owner, uint amount); + + event OfferCreated(uint256 indexed tokenId, uint256 duration, uint256 price, address acceptedActivity, address owner); + event OfferCancelled(uint256 tokenId); + event OfferTaken(uint256 indexed tokenId, address from, address owner, uint256 now, uint256 endTime); + event ActivityAdded(uint256 indexed tokenId, address activity, uint256 endTime); + event ActivityRemoved(uint256 indexed tokenId, address activity); + event TokenUseRemoved(uint256 indexed tokenId, address owner, address user, address activity); + + struct UseStatus { + address user; + address owner; + uint48 startTime; + uint48 endTime; + uint256 price; // RING per second. + address acceptedActivity; // can only be used in this activity. + } + + struct UseOffer { + address owner; + uint48 duration; + // total price of hiring mft for full duration + uint256 price; + address acceptedActivity; // If 0, then accept any activity + } + + struct CurrentActivity { + address activity; + uint48 endTime; + } + + bool private singletonLock = false; + + ISettingsRegistry public registry; + mapping (uint256 => UseStatus) public tokenId2UseStatus; + mapping (uint256 => UseOffer) public tokenId2UseOffer; + + mapping (uint256 => CurrentActivity ) public tokenId2CurrentActivity; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + function initializeContract(ISettingsRegistry _registry) public singletonLockCall { + owner = msg.sender; + emit LogSetOwner(msg.sender); + + registry = _registry; + } + + // false if it is not in useStage + // based on data in TokenUseStatus + function isObjectInHireStage(uint256 _tokenId) public view returns (bool) { + if (tokenId2UseStatus[_tokenId].user == address(0)) { + return false; + } + + return tokenId2UseStatus[_tokenId].startTime <= now && now <= tokenId2UseStatus[_tokenId].endTime; + } + + // by check this function + // you can know if an nft is ok to addActivity + // based on data in CurrentActivity + function isObjectReadyToUse(uint256 _tokenId) public view returns (bool) { + + if(tokenId2CurrentActivity[_tokenId].endTime == 0) { + return tokenId2CurrentActivity[_tokenId].activity == address(0); + } else { + return now > tokenId2CurrentActivity[_tokenId].endTime; + } + } + + + function getTokenUser(uint256 _tokenId) public view returns (address) { + return tokenId2UseStatus[_tokenId].user; + } + + function receiveApproval(address _from, uint _tokenId, bytes /*_data*/) public { + if(msg.sender == registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)) { + uint256 duration; + uint256 price; + address acceptedActivity; + assembly { + let ptr := mload(0x40) + calldatacopy(ptr, 0, calldatasize) + duration := mload(add(ptr, 132)) + price := mload(add(ptr, 164)) + acceptedActivity := mload(add(ptr, 196)) + } + + // already approve that msg.sender == ownerOf(_tokenId) + + _createTokenUseOffer(_tokenId, duration, price, acceptedActivity, _from); + } + } + + + // need approval from msg.sender + function createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public { + require(ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == msg.sender, "Only can call by the token owner."); + + _createTokenUseOffer(_tokenId, _duration, _price, _acceptedActivity, msg.sender); + } + + // TODO: be careful with unit of duration and price + // remember to deal with unit off chain + function _createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity, address _owner) internal { + require(isObjectReadyToUse(_tokenId), "No, it is still in use."); + require(tokenId2UseOffer[_tokenId].owner == 0, "Token already in another offer."); + require(_price >= 1e9, "price must larger than 1 ring."); + require(_duration >= 7 days); + + ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom(_owner, address(this), _tokenId); + + tokenId2UseOffer[_tokenId] = UseOffer({ + owner: _owner, + duration: uint48(_duration), + price : _price, + acceptedActivity: _acceptedActivity + }); + + emit OfferCreated(_tokenId,_duration, _price, _acceptedActivity, _owner); + } + + function cancelTokenUseOffer(uint256 _tokenId) public { + require(tokenId2UseOffer[_tokenId].owner == msg.sender, "Only token owner can cancel the offer."); + + ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom(address(this), msg.sender, _tokenId); + + delete tokenId2UseOffer[_tokenId]; + + emit OfferCancelled(_tokenId); + } + + function _pay(address ring, address _seller, uint256 expense) internal { + uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); + IERC20(ring).transfer(_seller, expense.sub(cut)); + address pool = registry.addressOf(CONTRACT_REVENUE_POOL); + IERC20(ring).approve(pool, cut); + IRevenuePool(pool).reward(ring, cut, msg.sender); + } + + function takeTokenUseOffer(uint256 _tokenId, uint256 _amountMax) public { + uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); + require(_amountMax >= expense, "offer too low"); + address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); + IERC20(ring).transferFrom(msg.sender, address(this), expense); + _pay(ring, tokenId2UseOffer[_tokenId].owner, expense); + _takeTokenUseOffer(_tokenId, msg.sender); + } + + function _takeTokenUseOffer(uint256 _tokenId, address _from) internal { + require(tokenId2UseOffer[_tokenId].owner != address(0), "Offer does not exist for this token."); + require(isObjectReadyToUse(_tokenId), "Token already in another activity."); + + tokenId2UseStatus[_tokenId] = UseStatus({ + user: _from, + owner: tokenId2UseOffer[_tokenId].owner, + startTime: uint48(now), + endTime : uint48(now) + tokenId2UseOffer[_tokenId].duration, + price : tokenId2UseOffer[_tokenId].price, + acceptedActivity : tokenId2UseOffer[_tokenId].acceptedActivity + }); + + delete tokenId2UseOffer[_tokenId]; + + emit OfferTaken(_tokenId, _from, tokenId2UseStatus[_tokenId].owner, now, uint256(tokenId2UseStatus[_tokenId].endTime)); + + } + + // start activity when token has no user at all + function addActivity( + uint256 _tokenId, address _user, uint256 _endTime + ) public auth { + // require the token user to verify even if it is from business logic. + // if it is rent by others, can not addActivity by default. + if(tokenId2UseStatus[_tokenId].user != address(0)) { + require(_user == tokenId2UseStatus[_tokenId].user); + require( + tokenId2UseStatus[_tokenId].acceptedActivity == address(0) || + tokenId2UseStatus[_tokenId].acceptedActivity == msg.sender, "Token accepted activity is not accepted."); + } else { + require( + address(0) == _user || ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == _user, "you can not use this token."); + } + + require(tokenId2UseOffer[_tokenId].owner == address(0), "Can not start activity when offering."); + + require(IActivity(msg.sender).supportsInterface(0x6086e7f8), "Msg sender must be activity"); + + require(isObjectReadyToUse(_tokenId), "Token should be available."); + + address activityObject = IInterstellarEncoder(registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER)).getObjectAddress(_tokenId); + IActivityObject(activityObject).activityAdded(_tokenId, msg.sender, _user); + + tokenId2CurrentActivity[_tokenId].activity = msg.sender; + + if(tokenId2UseStatus[_tokenId].endTime != 0) { + tokenId2CurrentActivity[_tokenId].endTime = tokenId2UseStatus[_tokenId].endTime; + } else { + tokenId2CurrentActivity[_tokenId].endTime = uint48(_endTime); + } + + + emit ActivityAdded(_tokenId, msg.sender, uint48(tokenId2CurrentActivity[_tokenId].endTime)); + } + + function removeActivity(uint256 _tokenId, address _user) public auth { + // require the token user to verify even if it is from business logic. + // if it is rent by others, can not addActivity by default. + if(tokenId2UseStatus[_tokenId].user != address(0)) { + require(_user == tokenId2UseStatus[_tokenId].user); + } else { + require( + address(0) == _user || ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == _user, "you can not use this token."); + } + + require(tokenId2CurrentActivity[_tokenId].activity == msg.sender || msg.sender == address(this), "Must stop from current activity"); + + address activityObject = IInterstellarEncoder(registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER)).getObjectAddress(_tokenId); + IActivityObject(activityObject).activityRemoved(_tokenId, msg.sender, _user); + + IActivity(tokenId2CurrentActivity[_tokenId].activity).activityStopped(_tokenId); + + delete tokenId2CurrentActivity[_tokenId]; + + emit ActivityRemoved(_tokenId, msg.sender); + } + + function removeTokenUseAndActivity(uint256 _tokenId) public { + require(tokenId2UseStatus[_tokenId].user != address(0), "Object does not exist."); + + // when in activity, only user can stop + if(isObjectInHireStage(_tokenId)) { + require(tokenId2UseStatus[_tokenId].user == msg.sender); + } + + _removeTokenUse(_tokenId); + + if (tokenId2CurrentActivity[_tokenId].activity != address(0)) { + this.removeActivity(_tokenId, address(0)); + } + } + + + function _removeTokenUse(uint256 _tokenId) internal { + + address owner = tokenId2UseStatus[_tokenId].owner; + address user = tokenId2UseStatus[_tokenId].user; + address activity = tokenId2CurrentActivity[_tokenId].activity; + ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom( + address(this), owner, _tokenId); + + delete tokenId2UseStatus[_tokenId]; +// delete tokenId2CurrentActivity[_tokenId]; + + emit TokenUseRemoved(_tokenId, owner, user, activity); + } + + // for user-friendly + function removeUseAndCreateOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public { + + require(msg.sender == tokenId2UseStatus[_tokenId].owner); + removeTokenUseAndActivity(_tokenId); + + tokenId2UseOffer[_tokenId] = UseOffer({ + owner: msg.sender, + duration: uint48(_duration), + price : _price, + acceptedActivity: _acceptedActivity + }); + + emit OfferCreated(_tokenId, _duration, _price, _acceptedActivity, msg.sender); + } + + /// @notice This method can be used by the owner to extract mistakenly + /// sent tokens to this contract. + /// @param _token The address of the token contract that you want to recover + /// set to 0 in case you want to extract ether. + function claimTokens(address _token) public auth { + if (_token == 0x0) { + owner.transfer(address(this).balance); + return; + } + IERC20 token = IERC20(_token); + uint balance = token.balanceOf(address(this)); + token.transfer(owner, balance); + + emit ClaimedTokens(_token, owner, balance); + } + +} From e0e8fa6a9ea6d720858729b0eb5ed8419d966c54 Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 17 Mar 2022 16:11:42 +0800 Subject: [PATCH 63/64] ownership add batch transfer --- contracts/ObjectOwnershipV3.sol | 133 ++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 contracts/ObjectOwnershipV3.sol diff --git a/contracts/ObjectOwnershipV3.sol b/contracts/ObjectOwnershipV3.sol new file mode 100644 index 0000000..c450c9a --- /dev/null +++ b/contracts/ObjectOwnershipV3.sol @@ -0,0 +1,133 @@ +pragma solidity ^0.4.24; + +import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; +import "openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol"; +import "./interfaces/IInterstellarEncoder.sol"; +import "./interfaces/ISettingsRegistry.sol"; +import "./DSAuth.sol"; +import "./SettingIds.sol"; +import "./StringUtil.sol"; + +contract ObjectOwnershipV3 is ERC721Token("Evolution Land Objects","EVO"), DSAuth, SettingIds { + using StringUtil for *; + + ISettingsRegistry public registry; + + bool private singletonLock = false; + + /* + * Modifiers + */ + modifier singletonLockCall() { + require(!singletonLock, "Only can call once"); + _; + singletonLock = true; + } + + // https://docs.opensea.io/docs/2-adding-metadata + string public baseTokenURI; + + /** + * @dev Atlantis's constructor + */ + constructor () public { + // initializeContract(); + } + + /** + * @dev Same with constructor, but is used and called by storage proxy as logic contract. + */ + function initializeContract(address _registry) public singletonLockCall { + // Ownable constructor + owner = msg.sender; + emit LogSetOwner(msg.sender); + + // SupportsInterfaceWithLookup constructor + _registerInterface(InterfaceId_ERC165); + + // ERC721BasicToken constructor + _registerInterface(InterfaceId_ERC721); + _registerInterface(InterfaceId_ERC721Exists); + + // ERC721Token constructor + name_ = "Evolution Land Objects"; + symbol_ = "EVO"; // Evolution Land Objects + // register the supported interfaces to conform to ERC721 via ERC165 + _registerInterface(InterfaceId_ERC721Enumerable); + _registerInterface(InterfaceId_ERC721Metadata); + + registry = ISettingsRegistry(_registry); + } + + function tokenURI(uint256 _tokenId) public view returns (string) { + if (super.tokenURI(_tokenId).toSlice().empty()) { + return baseTokenURI.toSlice().concat(StringUtil.uint2str(_tokenId).toSlice()); + } + + return super.tokenURI(_tokenId); + } + + function setTokenURI(uint256 _tokenId, string _uri) public auth { + _setTokenURI(_tokenId, _uri); + } + + function setBaseTokenURI(string _newBaseTokenURI) public auth { + baseTokenURI = _newBaseTokenURI; + } + + function mintObject(address _to, uint128 _objectId) public auth returns (uint256 _tokenId) { + address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); + + _tokenId = IInterstellarEncoder(interstellarEncoder).encodeTokenIdForObjectContract( + address(this), msg.sender, _objectId); + super._mint(_to, _tokenId); + } + + function burnObject(address _to, uint128 _objectId) public auth returns (uint256 _tokenId) { + address interstellarEncoder = registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER); + + _tokenId = IInterstellarEncoder(interstellarEncoder).encodeTokenIdForObjectContract( + address(this), msg.sender, _objectId); + super._burn(_to, _tokenId); + } + + function mint(address _to, uint256 _tokenId) public auth { + super._mint(_to, _tokenId); + } + + function burn(address _to, uint256 _tokenId) public auth { + super._burn(_to, _tokenId); + } + + //@dev user invoke approveAndCall to create auction + //@param _to - address of auction contractß + function approveAndCall( + address _to, + uint _tokenId, + bytes _extraData + ) public { + // set _to to the auction contract + approve(_to, _tokenId); + + if(!_to.call( + bytes4(keccak256("receiveApproval(address,uint256,bytes)")), abi.encode(msg.sender, _tokenId, _extraData) + )) { + revert(); + } + } + + /// @notice Transfer many tokens between 2 addresses, while + /// ensuring the receiving contract has a receiver method. + /// @param from The sender of the token. + /// @param to The recipient of the token. + /// @param ids The ids of the tokens. + function batchTransferFrom( + address from, + address to, + uint256[] ids + ) external { + for (uint256 i = 0; i < ids.length; ++i) { + transferFrom(from, to, ids[i]); + } + } +} From 7f2cd777133d33c9d149cfe38db7acf609a6eb39 Mon Sep 17 00:00:00 2001 From: echo Date: Mon, 31 Oct 2022 16:54:44 +0800 Subject: [PATCH 64/64] migrate to xWRING --- contracts/TokenUseCrab.sol | 314 ------------------------------------- 1 file changed, 314 deletions(-) delete mode 100644 contracts/TokenUseCrab.sol diff --git a/contracts/TokenUseCrab.sol b/contracts/TokenUseCrab.sol deleted file mode 100644 index bfa14c4..0000000 --- a/contracts/TokenUseCrab.sol +++ /dev/null @@ -1,314 +0,0 @@ -pragma solidity ^0.4.24; - -import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; -import "./interfaces/IActivity.sol"; -import "./interfaces/ISettingsRegistry.sol"; -import "./interfaces/IInterstellarEncoder.sol"; -import "./interfaces/IActivityObject.sol"; -import "./interfaces/IRevenuePool.sol"; -import "./SettingIds.sol"; -import "./DSAuth.sol"; -import "./interfaces/IERC20.sol"; - -contract TokenUseCrab is DSAuth, SettingIds { - using SafeMath for *; - - // claimedToken event - event ClaimedTokens(address indexed token, address indexed owner, uint amount); - - event OfferCreated(uint256 indexed tokenId, uint256 duration, uint256 price, address acceptedActivity, address owner); - event OfferCancelled(uint256 tokenId); - event OfferTaken(uint256 indexed tokenId, address from, address owner, uint256 now, uint256 endTime); - event ActivityAdded(uint256 indexed tokenId, address activity, uint256 endTime); - event ActivityRemoved(uint256 indexed tokenId, address activity); - event TokenUseRemoved(uint256 indexed tokenId, address owner, address user, address activity); - - struct UseStatus { - address user; - address owner; - uint48 startTime; - uint48 endTime; - uint256 price; // RING per second. - address acceptedActivity; // can only be used in this activity. - } - - struct UseOffer { - address owner; - uint48 duration; - // total price of hiring mft for full duration - uint256 price; - address acceptedActivity; // If 0, then accept any activity - } - - struct CurrentActivity { - address activity; - uint48 endTime; - } - - bool private singletonLock = false; - - ISettingsRegistry public registry; - mapping (uint256 => UseStatus) public tokenId2UseStatus; - mapping (uint256 => UseOffer) public tokenId2UseOffer; - - mapping (uint256 => CurrentActivity ) public tokenId2CurrentActivity; - - /* - * Modifiers - */ - modifier singletonLockCall() { - require(!singletonLock, "Only can call once"); - _; - singletonLock = true; - } - - function initializeContract(ISettingsRegistry _registry) public singletonLockCall { - owner = msg.sender; - emit LogSetOwner(msg.sender); - - registry = _registry; - } - - // false if it is not in useStage - // based on data in TokenUseStatus - function isObjectInHireStage(uint256 _tokenId) public view returns (bool) { - if (tokenId2UseStatus[_tokenId].user == address(0)) { - return false; - } - - return tokenId2UseStatus[_tokenId].startTime <= now && now <= tokenId2UseStatus[_tokenId].endTime; - } - - // by check this function - // you can know if an nft is ok to addActivity - // based on data in CurrentActivity - function isObjectReadyToUse(uint256 _tokenId) public view returns (bool) { - - if(tokenId2CurrentActivity[_tokenId].endTime == 0) { - return tokenId2CurrentActivity[_tokenId].activity == address(0); - } else { - return now > tokenId2CurrentActivity[_tokenId].endTime; - } - } - - - function getTokenUser(uint256 _tokenId) public view returns (address) { - return tokenId2UseStatus[_tokenId].user; - } - - function receiveApproval(address _from, uint _tokenId, bytes /*_data*/) public { - if(msg.sender == registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)) { - uint256 duration; - uint256 price; - address acceptedActivity; - assembly { - let ptr := mload(0x40) - calldatacopy(ptr, 0, calldatasize) - duration := mload(add(ptr, 132)) - price := mload(add(ptr, 164)) - acceptedActivity := mload(add(ptr, 196)) - } - - // already approve that msg.sender == ownerOf(_tokenId) - - _createTokenUseOffer(_tokenId, duration, price, acceptedActivity, _from); - } - } - - - // need approval from msg.sender - function createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public { - require(ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == msg.sender, "Only can call by the token owner."); - - _createTokenUseOffer(_tokenId, _duration, _price, _acceptedActivity, msg.sender); - } - - // TODO: be careful with unit of duration and price - // remember to deal with unit off chain - function _createTokenUseOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity, address _owner) internal { - require(isObjectReadyToUse(_tokenId), "No, it is still in use."); - require(tokenId2UseOffer[_tokenId].owner == 0, "Token already in another offer."); - require(_price >= 1e9, "price must larger than 1 ring."); - require(_duration >= 7 days); - - ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom(_owner, address(this), _tokenId); - - tokenId2UseOffer[_tokenId] = UseOffer({ - owner: _owner, - duration: uint48(_duration), - price : _price, - acceptedActivity: _acceptedActivity - }); - - emit OfferCreated(_tokenId,_duration, _price, _acceptedActivity, _owner); - } - - function cancelTokenUseOffer(uint256 _tokenId) public { - require(tokenId2UseOffer[_tokenId].owner == msg.sender, "Only token owner can cancel the offer."); - - ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom(address(this), msg.sender, _tokenId); - - delete tokenId2UseOffer[_tokenId]; - - emit OfferCancelled(_tokenId); - } - - function _pay(address ring, address _seller, uint256 expense) internal { - uint256 cut = expense.mul(registry.uintOf(UINT_TOKEN_OFFER_CUT)).div(10000); - IERC20(ring).transfer(_seller, expense.sub(cut)); - address pool = registry.addressOf(CONTRACT_REVENUE_POOL); - IERC20(ring).approve(pool, cut); - IRevenuePool(pool).reward(ring, cut, msg.sender); - } - - function takeTokenUseOffer(uint256 _tokenId, uint256 _amountMax) public { - uint256 expense = uint256(tokenId2UseOffer[_tokenId].price); - require(_amountMax >= expense, "offer too low"); - address ring = registry.addressOf(CONTRACT_RING_ERC20_TOKEN); - IERC20(ring).transferFrom(msg.sender, address(this), expense); - _pay(ring, tokenId2UseOffer[_tokenId].owner, expense); - _takeTokenUseOffer(_tokenId, msg.sender); - } - - function _takeTokenUseOffer(uint256 _tokenId, address _from) internal { - require(tokenId2UseOffer[_tokenId].owner != address(0), "Offer does not exist for this token."); - require(isObjectReadyToUse(_tokenId), "Token already in another activity."); - - tokenId2UseStatus[_tokenId] = UseStatus({ - user: _from, - owner: tokenId2UseOffer[_tokenId].owner, - startTime: uint48(now), - endTime : uint48(now) + tokenId2UseOffer[_tokenId].duration, - price : tokenId2UseOffer[_tokenId].price, - acceptedActivity : tokenId2UseOffer[_tokenId].acceptedActivity - }); - - delete tokenId2UseOffer[_tokenId]; - - emit OfferTaken(_tokenId, _from, tokenId2UseStatus[_tokenId].owner, now, uint256(tokenId2UseStatus[_tokenId].endTime)); - - } - - // start activity when token has no user at all - function addActivity( - uint256 _tokenId, address _user, uint256 _endTime - ) public auth { - // require the token user to verify even if it is from business logic. - // if it is rent by others, can not addActivity by default. - if(tokenId2UseStatus[_tokenId].user != address(0)) { - require(_user == tokenId2UseStatus[_tokenId].user); - require( - tokenId2UseStatus[_tokenId].acceptedActivity == address(0) || - tokenId2UseStatus[_tokenId].acceptedActivity == msg.sender, "Token accepted activity is not accepted."); - } else { - require( - address(0) == _user || ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == _user, "you can not use this token."); - } - - require(tokenId2UseOffer[_tokenId].owner == address(0), "Can not start activity when offering."); - - require(IActivity(msg.sender).supportsInterface(0x6086e7f8), "Msg sender must be activity"); - - require(isObjectReadyToUse(_tokenId), "Token should be available."); - - address activityObject = IInterstellarEncoder(registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER)).getObjectAddress(_tokenId); - IActivityObject(activityObject).activityAdded(_tokenId, msg.sender, _user); - - tokenId2CurrentActivity[_tokenId].activity = msg.sender; - - if(tokenId2UseStatus[_tokenId].endTime != 0) { - tokenId2CurrentActivity[_tokenId].endTime = tokenId2UseStatus[_tokenId].endTime; - } else { - tokenId2CurrentActivity[_tokenId].endTime = uint48(_endTime); - } - - - emit ActivityAdded(_tokenId, msg.sender, uint48(tokenId2CurrentActivity[_tokenId].endTime)); - } - - function removeActivity(uint256 _tokenId, address _user) public auth { - // require the token user to verify even if it is from business logic. - // if it is rent by others, can not addActivity by default. - if(tokenId2UseStatus[_tokenId].user != address(0)) { - require(_user == tokenId2UseStatus[_tokenId].user); - } else { - require( - address(0) == _user || ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).ownerOf(_tokenId) == _user, "you can not use this token."); - } - - require(tokenId2CurrentActivity[_tokenId].activity == msg.sender || msg.sender == address(this), "Must stop from current activity"); - - address activityObject = IInterstellarEncoder(registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER)).getObjectAddress(_tokenId); - IActivityObject(activityObject).activityRemoved(_tokenId, msg.sender, _user); - - IActivity(tokenId2CurrentActivity[_tokenId].activity).activityStopped(_tokenId); - - delete tokenId2CurrentActivity[_tokenId]; - - emit ActivityRemoved(_tokenId, msg.sender); - } - - function removeTokenUseAndActivity(uint256 _tokenId) public { - require(tokenId2UseStatus[_tokenId].user != address(0), "Object does not exist."); - - // when in activity, only user can stop - if(isObjectInHireStage(_tokenId)) { - require(tokenId2UseStatus[_tokenId].user == msg.sender); - } - - _removeTokenUse(_tokenId); - - if (tokenId2CurrentActivity[_tokenId].activity != address(0)) { - this.removeActivity(_tokenId, address(0)); - } - } - - - function _removeTokenUse(uint256 _tokenId) internal { - - address owner = tokenId2UseStatus[_tokenId].owner; - address user = tokenId2UseStatus[_tokenId].user; - address activity = tokenId2CurrentActivity[_tokenId].activity; - ERC721(registry.addressOf(CONTRACT_OBJECT_OWNERSHIP)).transferFrom( - address(this), owner, _tokenId); - - delete tokenId2UseStatus[_tokenId]; -// delete tokenId2CurrentActivity[_tokenId]; - - emit TokenUseRemoved(_tokenId, owner, user, activity); - } - - // for user-friendly - function removeUseAndCreateOffer(uint256 _tokenId, uint256 _duration, uint256 _price, address _acceptedActivity) public { - - require(msg.sender == tokenId2UseStatus[_tokenId].owner); - removeTokenUseAndActivity(_tokenId); - - tokenId2UseOffer[_tokenId] = UseOffer({ - owner: msg.sender, - duration: uint48(_duration), - price : _price, - acceptedActivity: _acceptedActivity - }); - - emit OfferCreated(_tokenId, _duration, _price, _acceptedActivity, msg.sender); - } - - /// @notice This method can be used by the owner to extract mistakenly - /// sent tokens to this contract. - /// @param _token The address of the token contract that you want to recover - /// set to 0 in case you want to extract ether. - function claimTokens(address _token) public auth { - if (_token == 0x0) { - owner.transfer(address(this).balance); - return; - } - IERC20 token = IERC20(_token); - uint balance = token.balanceOf(address(this)); - token.transfer(owner, balance); - - emit ClaimedTokens(_token, owner, balance); - } - -}