├── .env-example ├── .eslintrc ├── contracts ├── interfaces │ ├── IMedianizer.sol │ ├── IExchangeRateOracle.sol │ ├── ITaxCollector.sol │ ├── IERC223ReceivingContract.sol │ ├── ICertifier.sol │ ├── IGeoRegistry.sol │ ├── IKlerosArbitrable.sol │ ├── ICertifierRegistry.sol │ ├── IShopsDispute.sol │ ├── ITeller.sol │ ├── IDetherToken.sol │ ├── IZoneFactory.sol │ ├── IShops.sol │ ├── IUsers.sol │ └── IZone.sol ├── Migrations.sol ├── eip1167 │ └── EIP1167CloneFactory.sol ├── core │ ├── TaxCollector.sol │ └── Users.sol ├── kleros │ ├── Arbitrable.sol │ └── IArbitrable.sol └── certifier │ └── CertifierRegistry.sol ├── data └── trees_countries │ ├── BL.json │ ├── GI.json │ ├── SX.json │ ├── VA.json │ ├── BB.json │ ├── MC.json │ ├── MF.json │ ├── NF.json │ ├── NR.json │ ├── SM.json │ ├── AD.json │ ├── GG.json │ ├── MS.json │ ├── NU.json │ ├── AI.json │ ├── AW.json │ ├── GD.json │ ├── HM.json │ ├── KN.json │ ├── LI.json │ ├── MO.json │ ├── DM.json │ ├── LC.json │ ├── MT.json │ ├── JE.json │ ├── SG.json │ ├── WF.json │ ├── IM.json │ ├── BH.json │ ├── CW.json │ ├── GU.json │ ├── AG.json │ ├── VG.json │ ├── PM.json │ ├── PN.json │ ├── BM.json │ ├── KY.json │ ├── VC.json │ ├── VI.json │ ├── ST.json │ ├── HK.json │ ├── TC.json │ ├── IO.json │ ├── LU.json │ ├── KM.json │ ├── WS.json │ ├── AS.json │ ├── TV.json │ ├── PW.json │ ├── SH.json │ ├── FO.json │ ├── MU.json │ ├── TT.json │ ├── AX.json │ ├── BN.json │ ├── CK.json │ ├── CY.json │ ├── MP.json │ ├── TO.json │ ├── PS.json │ ├── UM.json │ ├── QA.json │ ├── SC.json │ ├── JM.json │ ├── GM.json │ ├── LB.json │ ├── PR.json │ ├── CV.json │ ├── SZ.json │ ├── ME.json │ ├── FM.json │ ├── KW.json │ ├── GS.json │ ├── TL.json │ ├── SV.json │ ├── MH.json │ ├── DJ.json │ ├── RW.json │ ├── BI.json │ ├── BZ.json │ ├── SI.json │ ├── FK.json │ ├── MK.json │ ├── LS.json │ ├── IL.json │ ├── TF.json │ ├── GQ.json │ ├── HT.json │ ├── AL.json │ ├── NC.json │ ├── GW.json │ ├── BT.json │ ├── AM.json │ ├── MV.json │ ├── TW.json │ ├── KI.json │ ├── BE.json │ ├── VU.json │ ├── pbcopy │ ├── MD.json │ ├── DO.json │ ├── CH.json │ ├── CR.json │ ├── TG.json │ ├── FJ.json │ ├── LK.json │ ├── SL.json │ ├── BA.json │ └── BS.json ├── test └── utils │ ├── output.js │ ├── ipfs.js │ ├── accounts.js │ ├── chai.js │ ├── convert.js │ ├── timeTravel.js │ ├── evmErrors.js │ ├── values.js │ └── geo.js ├── migrations ├── 1_initial_migration.js ├── 2_deploy_contracts.js └── constructor_arguments_in_abi.js ├── testrpc.sh ├── LICENSE.md ├── PULL_REQUEST_TEMPLATE.md ├── ISSUE_TEMPLATE.md ├── scripts ├── transferToken.js └── openZone.js ├── .gitignore ├── package.json ├── truffle-config.js └── CONTRIBUTING.md /.env-example: -------------------------------------------------------------------------------- 1 | MNEMONIC = "xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx" 2 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | // { 2 | // "env": { 3 | // "es6": true, 4 | // "node": true 5 | // }, 6 | // "extends": "airbnb-base" 7 | // } 8 | -------------------------------------------------------------------------------- /contracts/interfaces/IMedianizer.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract IMedianizer { 4 | function peek() view public returns (bytes32, bool); 5 | } -------------------------------------------------------------------------------- /data/trees_countries/BL.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "e": { 4 | "5": { 5 | "m": {} 6 | } 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /data/trees_countries/GI.json: -------------------------------------------------------------------------------- 1 | { 2 | "e": { 3 | "y": { 4 | "k": { 5 | "j": {} 6 | } 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /data/trees_countries/SX.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "e": { 4 | "5": { 5 | "n": {} 6 | } 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /data/trees_countries/VA.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "r": { 4 | "2": { 5 | "y": {} 6 | } 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /test/utils/output.js: -------------------------------------------------------------------------------- 1 | const addNumberDots = num => ( 2 | num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1.') 3 | ); 4 | 5 | module.exports = { 6 | addNumberDots, 7 | }; 8 | -------------------------------------------------------------------------------- /migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations, {gas: 4700000}); 5 | }; 6 | -------------------------------------------------------------------------------- /data/trees_countries/BB.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "d": { 4 | "m": { 5 | "e": {}, 6 | "d": {} 7 | } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /data/trees_countries/MC.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "p": { 4 | "v": { 5 | "0": {}, 6 | "2": {} 7 | } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /data/trees_countries/MF.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "e": { 4 | "5": { 5 | "n": {}, 6 | "p": {} 7 | } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /data/trees_countries/NF.json: -------------------------------------------------------------------------------- 1 | { 2 | "r": { 3 | "d": { 4 | "z": { 5 | "7": {}, 6 | "6": {} 7 | } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /data/trees_countries/NR.json: -------------------------------------------------------------------------------- 1 | { 2 | "r": { 3 | "x": { 4 | "y": { 5 | "t": {}, 6 | "s": {} 7 | } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /data/trees_countries/SM.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "r": { 4 | "b": { 5 | "f": {}, 6 | "c": {} 7 | } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /data/trees_countries/AD.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "p": { 4 | "9": { 5 | "6": {}, 6 | "1": {}, 7 | "4": {} 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /data/trees_countries/GG.json: -------------------------------------------------------------------------------- 1 | { 2 | "g": { 3 | "b": { 4 | "y": { 5 | "3": {}, 6 | "6": {}, 7 | "1": {} 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /data/trees_countries/MS.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "d": { 4 | "g": { 5 | "x": {}, 6 | "y": {}, 7 | "z": {} 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /data/trees_countries/NU.json: -------------------------------------------------------------------------------- 1 | { 2 | "2": { 3 | "h": { 4 | "x": { 5 | "7": {}, 6 | "5": {}, 7 | "h": {} 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/utils/ipfs.js: -------------------------------------------------------------------------------- 1 | const Web3 = require('web3'); 2 | const web3 = new Web3(); 3 | 4 | const getRandomBytes32 = () => ( 5 | web3.utils.randomHex(32) 6 | ); 7 | 8 | module.exports = { 9 | getRandomBytes32, 10 | }; 11 | -------------------------------------------------------------------------------- /data/trees_countries/AI.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "e": { 4 | "6": { 5 | "c": {} 6 | }, 7 | "5": { 8 | "p": {} 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /data/trees_countries/AW.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "6": { 4 | "n": { 5 | "q": {}, 6 | "p": {}, 7 | "r": {}, 8 | "n": {} 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /data/trees_countries/GD.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "d": { 4 | "h": { 5 | "q": {}, 6 | "j": {}, 7 | "h": {}, 8 | "r": {} 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /data/trees_countries/HM.json: -------------------------------------------------------------------------------- 1 | { 2 | "j": { 3 | "w": { 4 | "s": { 5 | "6": {}, 6 | "4": {}, 7 | "1": {}, 8 | "3": {} 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /data/trees_countries/KN.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "e": { 4 | "5": { 5 | "7": {}, 6 | "3": {}, 7 | "6": {}, 8 | "9": {} 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /data/trees_countries/LI.json: -------------------------------------------------------------------------------- 1 | { 2 | "u": { 3 | "0": { 4 | "q": { 5 | "s": {}, 6 | "u": {}, 7 | "g": {}, 8 | "e": {} 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /data/trees_countries/MO.json: -------------------------------------------------------------------------------- 1 | { 2 | "w": { 3 | "e": { 4 | "b": { 5 | "y": {}, 6 | "w": {}, 7 | "t": {}, 8 | "v": {} 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /data/trees_countries/DM.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "d": { 4 | "s": { 5 | "q": {}, 6 | "r": {} 7 | }, 8 | "u": { 9 | "2": {} 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /data/trees_countries/LC.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "d": { 4 | "s": { 5 | "8": {} 6 | }, 7 | "k": { 8 | "x": {}, 9 | "w": {} 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /test/utils/accounts.js: -------------------------------------------------------------------------------- 1 | const getAccounts = web3 => new Promise((resolve, reject) => { 2 | web3.eth.getAccounts((err, acc) => err ? reject(err) : resolve(acc.map(a => a.toLowerCase()))); // eslint-disable-line 3 | }); 4 | 5 | module.exports = { 6 | getAccounts, 7 | }; 8 | -------------------------------------------------------------------------------- /data/trees_countries/MT.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "q": { 4 | "6": { 5 | "5": {}, 6 | "7": {}, 7 | "k": {}, 8 | "h": {}, 9 | "j": {} 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /contracts/interfaces/IExchangeRateOracle.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract IExchangeRateOracle { 4 | function WAD() view external returns(uint256); 5 | function mkrPriceFeed() view external returns(address); 6 | function getWeiPriceOneUsd() view external returns(uint256); 7 | } 8 | -------------------------------------------------------------------------------- /data/trees_countries/JE.json: -------------------------------------------------------------------------------- 1 | { 2 | "g": { 3 | "b": { 4 | "y": { 5 | "8": {}, 6 | "2": {} 7 | }, 8 | "w": { 9 | "x": {}, 10 | "r": {} 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /data/trees_countries/SG.json: -------------------------------------------------------------------------------- 1 | { 2 | "w": { 3 | "2": { 4 | "1": { 5 | "x": {}, 6 | "z": {} 7 | }, 8 | "3": { 9 | "8": {}, 10 | "b": {} 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /data/trees_countries/WF.json: -------------------------------------------------------------------------------- 1 | { 2 | "2": { 3 | "j": { 4 | "3": { 5 | "q": {}, 6 | "r": {} 7 | }, 8 | "d": { 9 | "s": {}, 10 | "u": {} 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /test/utils/chai.js: -------------------------------------------------------------------------------- 1 | const chai = require('chai'); 2 | const Web3 = require('web3'); 3 | 4 | const web3 = new Web3(Web3.givenProvider); 5 | 6 | chai.use(require('chai-bn')(web3.utils.BN)); 7 | chai.use(require('chai-as-promised')); 8 | 9 | const { expect } = chai; 10 | 11 | module.exports = expect; 12 | -------------------------------------------------------------------------------- /data/trees_countries/IM.json: -------------------------------------------------------------------------------- 1 | { 2 | "g": { 3 | "c": { 4 | "s": { 5 | "s": {}, 6 | "u": {}, 7 | "e": {}, 8 | "t": {}, 9 | "g": {}, 10 | "v": {} 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /contracts/interfaces/ITaxCollector.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract ITaxCollector { 4 | function unchangeableRecipient() external; 5 | function changeRecipient() external; 6 | function collect() external; 7 | function tokenFallback(address _from, uint256 _value, bytes memory _data) public; 8 | } 9 | -------------------------------------------------------------------------------- /data/trees_countries/BH.json: -------------------------------------------------------------------------------- 1 | { 2 | "t": { 3 | "h": { 4 | "e": { 5 | "g": {}, 6 | "v": {}, 7 | "u": {}, 8 | "f": {} 9 | }, 10 | "s": { 11 | "h": {} 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /data/trees_countries/CW.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "6": { 4 | "n": { 5 | "y": {}, 6 | "v": {}, 7 | "u": {} 8 | }, 9 | "p": { 10 | "h": {}, 11 | "j": {} 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /data/trees_countries/GU.json: -------------------------------------------------------------------------------- 1 | { 2 | "x": { 3 | "4": { 4 | "r": { 5 | "h": {}, 6 | "j": {} 7 | }, 8 | "q": { 9 | "g": {}, 10 | "u": {}, 11 | "v": {} 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /data/trees_countries/AG.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "e": { 4 | "5": { 5 | "c": {}, 6 | "b": {} 7 | }, 8 | "h": { 9 | "5": {}, 10 | "h": {}, 11 | "0": {}, 12 | "1": {} 13 | } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /data/trees_countries/VG.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "e": { 4 | "6": { 5 | "3": {}, 6 | "1": {}, 7 | "6": {}, 8 | "0": {}, 9 | "4": {} 10 | }, 11 | "3": { 12 | "b": {} 13 | } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /data/trees_countries/PM.json: -------------------------------------------------------------------------------- 1 | { 2 | "f": { 3 | "8": { 4 | "r": { 5 | "g": {}, 6 | "f": {}, 7 | "u": {} 8 | } 9 | }, 10 | "b": { 11 | "2": { 12 | "1": {}, 13 | "4": {} 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /data/trees_countries/PN.json: -------------------------------------------------------------------------------- 1 | { 2 | "3": { 3 | "5": { 4 | "e": { 5 | "3": {}, 6 | "p": {} 7 | }, 8 | "s": { 9 | "v": {}, 10 | "t": {} 11 | }, 12 | "x": { 13 | "7": {} 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /data/trees_countries/BM.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "t": { 4 | "d": { 5 | "p": {} 6 | }, 7 | "c": { 8 | "b": {} 9 | }, 10 | "9": { 11 | "z": {} 12 | }, 13 | "f": { 14 | "0": {} 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /data/trees_countries/KY.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "5": { 4 | "q": { 5 | "n": {}, 6 | "m": {}, 7 | "q": {}, 8 | "j": {} 9 | }, 10 | "x": { 11 | "0": {}, 12 | "2": {} 13 | }, 14 | "r": { 15 | "p": {} 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /data/trees_countries/VC.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "d": { 4 | "k": { 5 | "3": {}, 6 | "s": {}, 7 | "d": {}, 8 | "6": {}, 9 | "k": {}, 10 | "7": {}, 11 | "2": {}, 12 | "e": {} 13 | }, 14 | "h": { 15 | "r": {} 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /data/trees_countries/VI.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "e": { 4 | "4": { 5 | "h": {}, 6 | "j": {} 7 | }, 8 | "1": { 9 | "u": {}, 10 | "v": {} 11 | }, 12 | "6": { 13 | "0": {} 14 | }, 15 | "3": { 16 | "8": {}, 17 | "b": {} 18 | } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /data/trees_countries/ST.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "0": { 4 | "m": { 5 | "2": {}, 6 | "3": {}, 7 | "1": {}, 8 | "0": {} 9 | }, 10 | "h": { 11 | "f": {}, 12 | "b": {}, 13 | "c": {}, 14 | "d": {}, 15 | "8": {}, 16 | "9": {} 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /data/trees_countries/HK.json: -------------------------------------------------------------------------------- 1 | { 2 | "w": { 3 | "e": { 4 | "b": { 5 | "y": {}, 6 | "z": {} 7 | }, 8 | "c": { 9 | "p": {}, 10 | "r": {}, 11 | "n": {}, 12 | "q": {} 13 | } 14 | }, 15 | "s": { 16 | "1": { 17 | "2": {}, 18 | "0": {} 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /data/trees_countries/TC.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "7": { 4 | "v": { 5 | "4": {}, 6 | "h": {}, 7 | "6": {}, 8 | "3": {}, 9 | "1": {}, 10 | "5": {} 11 | }, 12 | "u": { 13 | "e": {}, 14 | "7": {}, 15 | "s": {}, 16 | "g": {}, 17 | "u": {} 18 | } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /contracts/interfaces/IERC223ReceivingContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | /// @title Contract that supports the receival of ERC223 tokens. 4 | contract IERC223ReceivingContract { 5 | 6 | /// @dev Standard ERC223 function that will handle incoming token transfers. 7 | /// @param _from Token sender address. 8 | /// @param _value Amount of tokens. 9 | /// @param _data Transaction metadata. 10 | function tokenFallback(address _from, uint _value, bytes memory _data) public; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /data/trees_countries/IO.json: -------------------------------------------------------------------------------- 1 | { 2 | "m": { 3 | "w": { 4 | "f": { 5 | "d": {}, 6 | "e": {}, 7 | "s": {} 8 | }, 9 | "e": { 10 | "w": {}, 11 | "t": {}, 12 | "q": {} 13 | } 14 | }, 15 | "x": { 16 | "5": { 17 | "3": {}, 18 | "4": {}, 19 | "1": {} 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /data/trees_countries/LU.json: -------------------------------------------------------------------------------- 1 | { 2 | "u": { 3 | "0": { 4 | "u": { 5 | "6": {}, 6 | "e": {}, 7 | "d": {}, 8 | "h": {}, 9 | "9": {}, 10 | "5": {}, 11 | "4": {}, 12 | "m": {}, 13 | "1": {}, 14 | "k": {}, 15 | "7": {}, 16 | "j": {}, 17 | "3": {} 18 | } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /data/trees_countries/KM.json: -------------------------------------------------------------------------------- 1 | { 2 | "k": { 3 | "v": { 4 | "z": { 5 | "4": {}, 6 | "d": {}, 7 | "e": {}, 8 | "6": {}, 9 | "1": {}, 10 | "9": {} 11 | }, 12 | "y": { 13 | "z": {}, 14 | "v": {}, 15 | "s": {}, 16 | "t": {}, 17 | "u": {}, 18 | "y": {} 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /data/trees_countries/WS.json: -------------------------------------------------------------------------------- 1 | { 2 | "2": { 3 | "j": { 4 | "t": { 5 | "e": {}, 6 | "5": {}, 7 | "9": {}, 8 | "c": {}, 9 | "7": {}, 10 | "3": {}, 11 | "8": {}, 12 | "4": {}, 13 | "d": {}, 14 | "b": {}, 15 | "6": {} 16 | }, 17 | "w": { 18 | "0": {} 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /data/trees_countries/AS.json: -------------------------------------------------------------------------------- 1 | { 2 | "2": { 3 | "j": { 4 | "r": { 5 | "w": {}, 6 | "x": {}, 7 | "q": {}, 8 | "r": {} 9 | }, 10 | "q": { 11 | "w": {} 12 | } 13 | }, 14 | "n": { 15 | "n": { 16 | "3": {} 17 | } 18 | }, 19 | "m": { 20 | "2": { 21 | "m": {} 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /test/utils/convert.js: -------------------------------------------------------------------------------- 1 | const Web3 = require("web3"); 2 | 3 | const web3 = new Web3(); 4 | 5 | const toBN = val => web3.utils.toBN(val); 6 | const ethToWei = eth => web3.utils.toWei(eth.toString(), "ether"); 7 | const weiToEth = eth => web3.utils.fromWei(eth, "ether"); 8 | const asciiToHex = ascii => web3.utils.asciiToHex(ascii); 9 | const remove0x = txt => (txt.startsWith("0x") ? txt.slice(2) : txt); // eslint-disable-line 10 | const str = val => val.toString(); 11 | 12 | module.exports = { 13 | toBN, 14 | ethToWei, 15 | asciiToHex, 16 | remove0x, 17 | str, 18 | weiToEth 19 | }; 20 | -------------------------------------------------------------------------------- /data/trees_countries/TV.json: -------------------------------------------------------------------------------- 1 | { 2 | "r": { 3 | "y": { 4 | "t": { 5 | "z": {} 6 | }, 7 | "r": { 8 | "f": {}, 9 | "r": {} 10 | }, 11 | "y": { 12 | "j": {} 13 | }, 14 | "w": { 15 | "f": {} 16 | }, 17 | "v": { 18 | "r": {}, 19 | "k": {}, 20 | "p": {} 21 | }, 22 | "x": { 23 | "j": {} 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /testrpc.sh: -------------------------------------------------------------------------------- 1 | testrpc --account="0x6a936b41ff2044aa470c693b1cba7af1f7ea10139d9d65dc403518df037515d5,10000000000000000000000" --account="0x5ebd6d2fa870e35d48ee3f803dbbab34403aa42c67a3036dee721235a87cdd69,10000000000000000000000" --account="0x56383562a52a451683c2cae3c09b2c1b2a173ab0cdfb8526006fb0b8654d54c3,10000000000000000000000" --account="0xc73e31c9705af249fde8c4d01dc43e536f57c8fc9fd33612dfb83f3de7b4307e,10000000000000000000000" --account="0xf9f8a80e31d63d91371324b43723ccf293af28213c8b6824162fed90b4f465a4,10000000000000000000000" --account="0x571ed1b6eb404fcd7fc2562f6e0d5fa27c4be6db079f9e658ad4137f059472b3,10000000000000000000000" 2 | -------------------------------------------------------------------------------- /contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } -------------------------------------------------------------------------------- /data/trees_countries/PW.json: -------------------------------------------------------------------------------- 1 | { 2 | "w": { 3 | "c": { 4 | "r": { 5 | "y": {}, 6 | "2": {}, 7 | "g": {}, 8 | "v": {}, 9 | "e": {}, 10 | "9": {}, 11 | "d": {} 12 | }, 13 | "p": { 14 | "r": {} 15 | } 16 | }, 17 | "b": { 18 | "y": { 19 | "n": {} 20 | }, 21 | "t": { 22 | "1": {}, 23 | "3": {}, 24 | "8": {} 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /data/trees_countries/SH.json: -------------------------------------------------------------------------------- 1 | { 2 | "7": { 3 | "w": { 4 | "t": { 5 | "d": {}, 6 | "g": {}, 7 | "f": {} 8 | } 9 | }, 10 | "9": { 11 | "r": { 12 | "k": {}, 13 | "j": {}, 14 | "h": {}, 15 | "m": {} 16 | } 17 | }, 18 | "v": { 19 | "5": { 20 | "v": {}, 21 | "u": {} 22 | } 23 | }, 24 | "b": { 25 | "b": { 26 | "f": {} 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /contracts/interfaces/ICertifier.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract ICertifier { 4 | function certs(address) view public returns(bool active); 5 | function delegate(address) view public returns(bool active); 6 | function addDelegate(address _delegate) public; 7 | function removeDelegate(address _delegate) public; 8 | function certify(address _who) public; 9 | function revoke(address _who) public; 10 | function isDelegate(address _who) view public returns(bool); 11 | function certified(address _who) view public returns(bool); 12 | function get(address _who, string memory _field) view public returns(bytes32); 13 | } 14 | -------------------------------------------------------------------------------- /data/trees_countries/FO.json: -------------------------------------------------------------------------------- 1 | { 2 | "g": { 3 | "g": { 4 | "5": { 5 | "1": {}, 6 | "4": {}, 7 | "d": {}, 8 | "3": {}, 9 | "0": {}, 10 | "6": {} 11 | }, 12 | "4": { 13 | "9": {}, 14 | "c": {}, 15 | "b": {}, 16 | "f": {} 17 | } 18 | }, 19 | "f": { 20 | "g": { 21 | "r": {}, 22 | "p": {}, 23 | "n": {}, 24 | "m": {}, 25 | "j": {} 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /data/trees_countries/MU.json: -------------------------------------------------------------------------------- 1 | { 2 | "m": { 3 | "k": { 4 | "2": { 5 | "u": {}, 6 | "g": {}, 7 | "v": {}, 8 | "e": {}, 9 | "y": {} 10 | }, 11 | "3": { 12 | "5": {}, 13 | "n": {}, 14 | "j": {}, 15 | "h": {} 16 | }, 17 | "t": { 18 | "0": {} 19 | }, 20 | "m": { 21 | "p": {} 22 | } 23 | }, 24 | "q": { 25 | "0": { 26 | "h": {}, 27 | "j": {} 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /data/trees_countries/TT.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "9": { 4 | "g": { 5 | "c": {} 6 | }, 7 | "u": { 8 | "z": {}, 9 | "s": {}, 10 | "x": {}, 11 | "e": {}, 12 | "m": {}, 13 | "k": {}, 14 | "d": {}, 15 | "4": {}, 16 | "h": {}, 17 | "j": {}, 18 | "t": {}, 19 | "3": {}, 20 | "6": {}, 21 | "9": {}, 22 | "1": {}, 23 | "7": {} 24 | } 25 | }, 26 | "d": { 27 | "h": { 28 | "b": {} 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /data/trees_countries/AX.json: -------------------------------------------------------------------------------- 1 | { 2 | "u": { 3 | "6": { 4 | "z": { 5 | "0": {} 6 | }, 7 | "w": { 8 | "q": {}, 9 | "r": {}, 10 | "t": {}, 11 | "z": {}, 12 | "j": {}, 13 | "w": {}, 14 | "x": {}, 15 | "y": {}, 16 | "n": {}, 17 | "v": {}, 18 | "u": {}, 19 | "m": {}, 20 | "p": {} 21 | }, 22 | "y": { 23 | "b": {} 24 | }, 25 | "x": { 26 | "p": {} 27 | }, 28 | "t": { 29 | "y": {} 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /contracts/interfaces/IGeoRegistry.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract IGeoRegistry { 4 | function zoneIsEnabled(bytes2) view public returns(bool); 5 | function enabledZone(uint256) view public returns(bytes2); 6 | function level_2(bytes2, bytes3) view public returns(bytes4); 7 | function validGeohashChars(bytes memory _bytes) public returns(bool); 8 | function validGeohashChars12(bytes12 _bytes) public returns(bool); 9 | function zoneInsideBiggerZone(bytes2 _countryCode, bytes4 _zone) view public returns(bool); 10 | function updateLevel2(bytes2 _countryCode, bytes3 _letter, bytes4 _subLetters) public; 11 | function updateLevel2batch(bytes2 _countryCode, bytes3[] memory _letters, bytes4[] memory _subLetters) public; 12 | function endInit(bytes2 _countryCode) external; 13 | } 14 | -------------------------------------------------------------------------------- /contracts/interfaces/IKlerosArbitrable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract IKlerosArbitrable { 4 | enum DisputeStatus {Waiting, Appealable, Solved} // copied from IArbitrable.sol 5 | function createDispute(uint _choices, bytes memory _extraData) public payable returns(uint disputeID); 6 | function arbitrationCost(bytes memory _extraData) public view returns(uint fee); 7 | function appeal(uint _disputeID, bytes memory _extraData) public payable; 8 | function appealCost(uint _disputeID, bytes memory _extraData) public view returns(uint fee); 9 | function appealPeriod(uint _disputeID) public view returns(uint start, uint end) {} 10 | function disputeStatus(uint _disputeID) public view returns(DisputeStatus status); 11 | function currentRuling(uint _disputeID) public view returns(uint ruling); 12 | } 13 | -------------------------------------------------------------------------------- /data/trees_countries/BN.json: -------------------------------------------------------------------------------- 1 | { 2 | "w": { 3 | "8": { 4 | "c": { 5 | "g": {}, 6 | "s": {}, 7 | "f": {}, 8 | "6": {}, 9 | "1": {}, 10 | "u": {}, 11 | "e": {}, 12 | "8": {}, 13 | "3": {}, 14 | "4": {}, 15 | "c": {}, 16 | "2": {}, 17 | "b": {}, 18 | "9": {}, 19 | "d": {}, 20 | "7": {} 21 | }, 22 | "9": { 23 | "r": {}, 24 | "w": {}, 25 | "x": {}, 26 | "q": {} 27 | }, 28 | "f": { 29 | "1": {}, 30 | "0": {} 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /data/trees_countries/CK.json: -------------------------------------------------------------------------------- 1 | { 2 | "2": { 3 | "q": { 4 | "j": { 5 | "s": {}, 6 | "q": {} 7 | }, 8 | "4": { 9 | "4": {} 10 | }, 11 | "r": { 12 | "s": {}, 13 | "t": {} 14 | } 15 | }, 16 | "k": { 17 | "w": { 18 | "f": {}, 19 | "k": {} 20 | }, 21 | "p": { 22 | "e": {} 23 | }, 24 | "r": { 25 | "r": {}, 26 | "w": {}, 27 | "z": {} 28 | }, 29 | "n": { 30 | "r": {} 31 | } 32 | }, 33 | "s": { 34 | "2": { 35 | "j": {} 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /data/trees_countries/CY.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "w": { 4 | "p": { 5 | "q": {}, 6 | "w": {}, 7 | "p": {}, 8 | "x": {}, 9 | "j": {}, 10 | "k": {}, 11 | "m": {}, 12 | "t": {}, 13 | "v": {}, 14 | "r": {}, 15 | "y": {}, 16 | "n": {}, 17 | "z": {} 18 | }, 19 | "r": { 20 | "0": {}, 21 | "2": {}, 22 | "8": {}, 23 | "b": {} 24 | }, 25 | "n": { 26 | "y": {}, 27 | "z": {} 28 | } 29 | }, 30 | "y": { 31 | "0": { 32 | "p": {}, 33 | "n": {} 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /contracts/eip1167/EIP1167CloneFactory.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | /** 4 | * @title EIP 1167: Minimal Proxy Contract 5 | * 6 | * @dev To simply and cheaply clone contract functionality in an immutable way, 7 | * this standard specifies a minimal bytecode implementation that delegates 8 | * all calls to a known, fixed address. 9 | * 10 | * https://eips.ethereum.org/EIPS/eip-1167 11 | */ 12 | contract EIP1167CloneFactory { 13 | function createClone(address target) internal returns (address result) { 14 | bytes20 targetBytes = bytes20(target); 15 | assembly { 16 | let clone := mload(0x40) 17 | mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) 18 | mstore(add(clone, 0x14), targetBytes) 19 | mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) 20 | result := create(0, clone, 0x37) 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /data/trees_countries/MP.json: -------------------------------------------------------------------------------- 1 | { 2 | "x": { 3 | "5": { 4 | "x": { 5 | "2": {}, 6 | "6": {}, 7 | "3": {}, 8 | "h": {} 9 | }, 10 | "p": { 11 | "w": {}, 12 | "s": {}, 13 | "d": {}, 14 | "e": {}, 15 | "x": {} 16 | }, 17 | "r": { 18 | "r": {}, 19 | "d": {}, 20 | "e": {} 21 | } 22 | }, 23 | "4": { 24 | "x": { 25 | "0": {}, 26 | "w": {}, 27 | "s": {}, 28 | "2": {}, 29 | "t": {} 30 | }, 31 | "z": { 32 | "x": {}, 33 | "w": {}, 34 | "s": {}, 35 | "t": {} 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /data/trees_countries/TO.json: -------------------------------------------------------------------------------- 1 | { 2 | "2": { 3 | "h": { 4 | "4": { 5 | "9": {}, 6 | "8": {} 7 | }, 8 | "e": { 9 | "u": {}, 10 | "v": {} 11 | }, 12 | "s": { 13 | "m": {}, 14 | "q": {}, 15 | "0": {}, 16 | "n": {}, 17 | "j": {} 18 | }, 19 | "7": { 20 | "x": {}, 21 | "r": {}, 22 | "2": {} 23 | }, 24 | "5": { 25 | "r": {}, 26 | "x": {}, 27 | "w": {}, 28 | "t": {} 29 | }, 30 | "k": { 31 | "p": {} 32 | } 33 | }, 34 | "j": { 35 | "5": { 36 | "p": {} 37 | } 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /data/trees_countries/PS.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "v": { 4 | "9": { 5 | "n": {}, 6 | "p": {}, 7 | "j": {}, 8 | "r": {}, 9 | "k": {}, 10 | "m": {}, 11 | "4": {}, 12 | "q": {}, 13 | "h": {}, 14 | "5": {} 15 | }, 16 | "8": { 17 | "d": {}, 18 | "f": {}, 19 | "g": {}, 20 | "y": {}, 21 | "u": {}, 22 | "6": {}, 23 | "3": {}, 24 | "v": {}, 25 | "7": {}, 26 | "z": {}, 27 | "e": {} 28 | }, 29 | "c": { 30 | "2": {}, 31 | "0": {}, 32 | "1": {} 33 | }, 34 | "b": { 35 | "b": {} 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /contracts/interfaces/ICertifierRegistry.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | pragma experimental ABIEncoderV2; 3 | 4 | contract ICertifierRegistry { 5 | struct Certification { 6 | address certifier; 7 | int8 ref; 8 | uint timestamp; 9 | } 10 | function createCertifier(string memory _url) public returns (address ); 11 | function modifyUrl(address _certifierId, string memory _newUrl) public; 12 | function addCertificationType(address _certifierId, int8 ref, string memory description) public; 13 | function addDelegate(address _certifierId, address _delegate) public; 14 | function removeDelegate(address _certifierId, address _delegate) public; 15 | function certify(address _certifierId, address _who, int8 _type) public; 16 | function revoke(address _certifierId, address _who) public; 17 | function isDelegate(address _certifierId, address _who) public view returns(bool); 18 | function getCerts( address _who) public view returns(Certification[] memory); 19 | } 20 | -------------------------------------------------------------------------------- /data/trees_countries/UM.json: -------------------------------------------------------------------------------- 1 | { 2 | "x": { 3 | "e": { 4 | "q": { 5 | "m": {}, 6 | "t": {} 7 | } 8 | } 9 | }, 10 | "8": { 11 | "0": { 12 | "4": { 13 | "k": {}, 14 | "9": {}, 15 | "3": {} 16 | } 17 | }, 18 | "j": { 19 | "1": { 20 | "b": {} 21 | } 22 | }, 23 | "4": { 24 | "z": { 25 | "r": {} 26 | } 27 | }, 28 | "3": { 29 | "h": { 30 | "s": {}, 31 | "9": {}, 32 | "c": {} 33 | } 34 | } 35 | }, 36 | "d": { 37 | "7": { 38 | "6": { 39 | "8": {} 40 | } 41 | } 42 | }, 43 | "2": { 44 | "r": { 45 | "y": { 46 | "j": {} 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /data/trees_countries/QA.json: -------------------------------------------------------------------------------- 1 | { 2 | "t": { 3 | "h": { 4 | "s": { 5 | "2": {}, 6 | "6": {}, 7 | "k": {}, 8 | "d": {}, 9 | "e": {}, 10 | "8": {}, 11 | "4": {}, 12 | "1": {}, 13 | "9": {}, 14 | "3": {}, 15 | "0": {}, 16 | "7": {}, 17 | "5": {}, 18 | "s": {} 19 | }, 20 | "k": { 21 | "q": {}, 22 | "r": {}, 23 | "m": {}, 24 | "n": {}, 25 | "t": {}, 26 | "p": {}, 27 | "w": {}, 28 | "h": {}, 29 | "5": {}, 30 | "k": {}, 31 | "e": {}, 32 | "x": {}, 33 | "j": {}, 34 | "7": {}, 35 | "s": {} 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /data/trees_countries/SC.json: -------------------------------------------------------------------------------- 1 | { 2 | "m": { 3 | "q": { 4 | "8": { 5 | "p": {} 6 | } 7 | }, 8 | "p": { 9 | "r": { 10 | "d": {}, 11 | "8": {} 12 | }, 13 | "p": { 14 | "k": {}, 15 | "v": {}, 16 | "x": {}, 17 | "q": {}, 18 | "z": {}, 19 | "m": {} 20 | }, 21 | "j": { 22 | "c": {} 23 | } 24 | }, 25 | "n": { 26 | "2": { 27 | "f": {} 28 | }, 29 | "3": { 30 | "0": {}, 31 | "4": {}, 32 | "b": {} 33 | }, 34 | "z": { 35 | "q": {} 36 | }, 37 | "x": { 38 | "z": {} 39 | }, 40 | "v": { 41 | "8": {} 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /data/trees_countries/JM.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "7": { 4 | "1": { 5 | "n": {}, 6 | "p": {}, 7 | "j": {}, 8 | "y": {}, 9 | "m": {}, 10 | "t": {}, 11 | "v": {}, 12 | "x": {}, 13 | "r": {}, 14 | "q": {}, 15 | "w": {}, 16 | "h": {} 17 | }, 18 | "0": { 19 | "y": {}, 20 | "z": {}, 21 | "v": {}, 22 | "r": {}, 23 | "t": {}, 24 | "w": {}, 25 | "x": {} 26 | }, 27 | "2": { 28 | "b": {}, 29 | "c": {}, 30 | "9": {}, 31 | "2": {}, 32 | "8": {} 33 | }, 34 | "3": { 35 | "0": {}, 36 | "2": {}, 37 | "1": {} 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /data/trees_countries/GM.json: -------------------------------------------------------------------------------- 1 | { 2 | "e": { 3 | "d": { 4 | "m": { 5 | "n": {}, 6 | "q": {}, 7 | "m": {}, 8 | "h": {}, 9 | "v": {}, 10 | "s": {}, 11 | "e": {}, 12 | "u": {}, 13 | "j": {}, 14 | "g": {}, 15 | "k": {}, 16 | "t": {} 17 | }, 18 | "k": { 19 | "j": {}, 20 | "h": {}, 21 | "m": {}, 22 | "v": {}, 23 | "k": {}, 24 | "t": {}, 25 | "d": {}, 26 | "7": {}, 27 | "5": {}, 28 | "u": {}, 29 | "s": {}, 30 | "6": {}, 31 | "4": {}, 32 | "g": {}, 33 | "e": {} 34 | }, 35 | "q": { 36 | "5": {}, 37 | "h": {}, 38 | "j": {} 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2017 Dether. https://dether.io 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Requirements 2 | 3 | * Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. 4 | * All new code requires tests to ensure against regressions 5 | 6 | ### Description of the Change 7 | 8 | 13 | 14 | ### Alternate Designs 15 | 16 | 17 | 18 | ### Benefits 19 | 20 | 21 | 22 | ### Possible Drawbacks 23 | 24 | 25 | 26 | ### Applicable Issues 27 | 28 | -------------------------------------------------------------------------------- /contracts/interfaces/IShopsDispute.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract IShopsDispute { 4 | function arbitratorExtraData() view public returns(bytes memory); 5 | function AMOUNT_OF_CHOICES() view public returns(uint8); 6 | function RULING_OPTIONS() view public returns(string memory); 7 | function arbitrator() view public returns(address); 8 | function disputeTypes(uint256) view public returns(string memory); 9 | function shops() view public returns(address); 10 | function users() view public returns(address); 11 | function getDisputeCreateCost() view public returns(uint256); 12 | function getDisputeAppealCost(address _shopAddress) view external returns(uint256); 13 | function getDispute(address _shopAddress) view public returns(uint256, address, address, uint256, uint256, uint256); 14 | function addDisputeType(string calldata _disputeTypeLink) external; 15 | function createDispute(address _shopAddress, uint256 _metaEvidenceId, string memory _evidenceLink) payable public; 16 | function appealDispute(address _shopAddress, string calldata _evidenceLink) payable external; 17 | function rule(uint256 _disputeID, uint256 _ruling) public; 18 | } 19 | -------------------------------------------------------------------------------- /data/trees_countries/LB.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "v": { 4 | "c": { 5 | "r": {}, 6 | "j": {}, 7 | "p": {}, 8 | "h": {}, 9 | "x": {}, 10 | "w": {}, 11 | "n": {}, 12 | "k": {}, 13 | "q": {}, 14 | "m": {} 15 | }, 16 | "b": { 17 | "u": {} 18 | } 19 | }, 20 | "y": { 21 | "1": { 22 | "d": {}, 23 | "9": {}, 24 | "e": {}, 25 | "7": {}, 26 | "b": {}, 27 | "c": {}, 28 | "u": {}, 29 | "s": {}, 30 | "6": {}, 31 | "0": {}, 32 | "v": {}, 33 | "8": {}, 34 | "f": {}, 35 | "3": {}, 36 | "g": {}, 37 | "t": {}, 38 | "k": {}, 39 | "2": {} 40 | }, 41 | "4": { 42 | "4": {}, 43 | "5": {} 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /contracts/interfaces/ITeller.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract ITeller { 4 | function funds() view public returns(uint256); 5 | function geo() view public returns(address); 6 | function withdrawableEth(address) view public returns(uint256); 7 | function canPlaceCertifiedComment(address, address) view public returns(uint256); 8 | function zone() view public returns(address); 9 | function init(address _geo, address _zone) external; 10 | function getComments() view external returns(bytes32[] memory); 11 | function calcReferrerFee(uint256 _value) view public returns(uint256 referrerAmount); 12 | function getTeller() view external returns(address, uint8, bytes16, bytes12, bytes1, int16, int16, uint256, address); 13 | function getReferrer() view external returns(address, uint); 14 | function hasTeller() view external returns(bool); 15 | function removeTellerByZone() external; 16 | function removeTeller() external; 17 | function addTeller(bytes calldata _position, uint8 _currencyId, bytes16 _messenger, int16 _sellRate, int16 _buyRate, bytes1 _settings, address _referrer, bytes32 _description) external; 18 | function addComment(bytes32 _commentHash) external; 19 | } 20 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | ### Prerequisites 10 | 11 | * [ ] Put an X between the brackets on this line if you have done all of the following: 12 | * Checked with the Dether team on Slack 13 | * Checked that your issue isn't already filed 14 | 15 | ### Description 16 | 17 | [Description of the issue] 18 | 19 | ### Steps to Reproduce 20 | 21 | 1. [First Step] 22 | 2. [Second Step] 23 | 3. [and so on...] 24 | 25 | **Expected behavior:** [What you expect to happen] 26 | 27 | **Actual behavior:** [What actually happens] 28 | 29 | **Reproduces how often:** [What percentage of the time does it reproduce?] 30 | 31 | ### Versions 32 | 33 | Specify the version of the software and any relevant dependencies. 34 | 35 | ### Additional Information 36 | 37 | Any additional information, configuration or data that might be necessary to reproduce the issue. -------------------------------------------------------------------------------- /data/trees_countries/PR.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "e": { 4 | "2": { 5 | "8": {}, 6 | "2": {}, 7 | "1": {}, 8 | "b": {}, 9 | "c": {}, 10 | "9": {}, 11 | "0": {}, 12 | "3": {} 13 | }, 14 | "0": { 15 | "r": {}, 16 | "x": {}, 17 | "z": {}, 18 | "w": {}, 19 | "m": {}, 20 | "v": {}, 21 | "q": {}, 22 | "y": {}, 23 | "n": {}, 24 | "p": {} 25 | }, 26 | "3": { 27 | "0": {}, 28 | "8": {}, 29 | "1": {}, 30 | "2": {} 31 | }, 32 | "1": { 33 | "p": {}, 34 | "q": {}, 35 | "x": {}, 36 | "r": {}, 37 | "n": {} 38 | } 39 | }, 40 | "7": { 41 | "p": { 42 | "y": {}, 43 | "x": {}, 44 | "z": {}, 45 | "w": {} 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /data/trees_countries/CV.json: -------------------------------------------------------------------------------- 1 | { 2 | "e": { 3 | "6": { 4 | "x": { 5 | "h": {}, 6 | "p": {}, 7 | "k": {}, 8 | "j": {}, 9 | "x": {}, 10 | "r": {}, 11 | "n": {}, 12 | "q": {}, 13 | "w": {}, 14 | "m": {} 15 | }, 16 | "z": { 17 | "e": {}, 18 | "x": {}, 19 | "g": {}, 20 | "f": {}, 21 | "s": {}, 22 | "u": {}, 23 | "w": {}, 24 | "d": {} 25 | }, 26 | "w": { 27 | "t": {}, 28 | "s": {}, 29 | "k": {} 30 | }, 31 | "y": { 32 | "t": {}, 33 | "y": {}, 34 | "p": {}, 35 | "w": {}, 36 | "r": {} 37 | } 38 | }, 39 | "7": { 40 | "n": { 41 | "1": {}, 42 | "2": {}, 43 | "0": {} 44 | }, 45 | "j": { 46 | "b": {}, 47 | "c": {} 48 | } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /test/utils/timeTravel.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-underscore-dangle */ 2 | class TimeTravel { 3 | constructor(web3) { 4 | this.web3 = web3; 5 | } 6 | 7 | saveState() { 8 | return new Promise((resolve, reject) => { 9 | this.web3.currentProvider.send({ 10 | jsonrpc: '2.0', 11 | method: 'evm_snapshot', 12 | id: 0, 13 | }, (e, d) => ( 14 | e ? reject(e) : resolve(d) 15 | )); 16 | }); 17 | } 18 | 19 | revertState(id) { 20 | return new Promise((resolve, reject) => { 21 | this.web3.currentProvider.send({ 22 | jsonrpc: '2.0', 23 | method: 'evm_revert', 24 | params: [id], 25 | id: 0, 26 | }, (e, d) => ( 27 | e ? reject(e) : resolve(d) 28 | )); 29 | }); 30 | } 31 | 32 | _evmSend(method, params = []) { 33 | return new Promise((resolve, reject) => { 34 | // NOTE: why is this not yet a promise, we're using web3 v1.0? 35 | this.web3.currentProvider.send({ id: '2.0', method, params }, (e, d) => ( 36 | e ? reject(e) : resolve(d) 37 | )); 38 | }); 39 | } 40 | 41 | async inSecs(seconds) { 42 | await this._evmSend('evm_increaseTime', [seconds]); 43 | await this._evmSend('evm_mine'); 44 | } 45 | } 46 | 47 | module.exports = TimeTravel; -------------------------------------------------------------------------------- /test/utils/evmErrors.js: -------------------------------------------------------------------------------- 1 | const forgeErrorMessage = str => `Returned error: VM Exception while processing transaction: revert ${str} -- Reason given: ${str}.`; 2 | // const forgeErrorMessage = str => `VM Exception while processing transaction: revert ${str}`; 3 | const forgeErrorMessage2 = str => `Returned error: VM Exception while processing transaction: revert ${str}`; 4 | 5 | const expectRevert = async (fn, errMsg) => { 6 | try { 7 | await fn; 8 | } catch (err) { 9 | if (!err.message.includes(errMsg)) { 10 | throw err; 11 | } 12 | return; 13 | } 14 | throw new Error('should have thrown'); 15 | }; 16 | 17 | const expectRevert2 = async (fn, errMsg) => { 18 | try { 19 | await fn; 20 | } catch (err) { 21 | // console.log('expectRevert2', err); 22 | if (!err.message.includes(errMsg)) { 23 | throw err; 24 | } 25 | return; 26 | } 27 | throw new Error('should have thrown'); 28 | }; 29 | const expectRevert3 = async (fn, errMsg) => { 30 | try { 31 | const ret = await fn; 32 | } catch (err) { 33 | // if (!err.message.includes(errMsg)) { 34 | // throw err; 35 | // } 36 | return; 37 | } 38 | throw new Error('should have thrown'); 39 | }; 40 | module.exports = { 41 | expectRevert, 42 | expectRevert2, 43 | expectRevert3, 44 | }; 45 | -------------------------------------------------------------------------------- /contracts/interfaces/IDetherToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract IDetherToken { 4 | function mintingFinished() view public returns(bool); 5 | function name() view public returns(string memory); 6 | function approve(address _spender, uint256 _value) public returns(bool); 7 | function totalSupply() view public returns(uint256); 8 | function transferFrom(address _from, address _to, uint256 _value) public returns(bool); 9 | function decimals() view public returns(uint8); 10 | function mint(address _to, uint256 _amount) public returns(bool); 11 | function decreaseApproval(address _spender, uint256 _subtractedValue) public returns(bool); 12 | function balanceOf(address _owner) view public returns(uint256 balance); 13 | function finishMinting() public returns(bool); 14 | function owner() view public returns(address); 15 | function symbol() view public returns(string memory); 16 | function transfer(address _to, uint256 _value) public returns(bool); 17 | function transfer(address _to, uint256 _value, bytes memory _data) public returns(bool); 18 | function increaseApproval(address _spender, uint256 _addedValue) public returns(bool); 19 | function allowance(address _owner, address _spender) view public returns(uint256); 20 | function transferOwnership(address newOwner) public; 21 | } 22 | -------------------------------------------------------------------------------- /data/trees_countries/SZ.json: -------------------------------------------------------------------------------- 1 | { 2 | "k": { 3 | "e": { 4 | "q": { 5 | "7": {}, 6 | "3": {}, 7 | "6": {}, 8 | "2": {}, 9 | "d": {}, 10 | "1": {}, 11 | "8": {}, 12 | "9": {}, 13 | "e": {}, 14 | "0": {}, 15 | "u": {}, 16 | "s": {}, 17 | "c": {}, 18 | "5": {}, 19 | "h": {}, 20 | "b": {}, 21 | "f": {}, 22 | "k": {}, 23 | "g": {}, 24 | "j": {}, 25 | "m": {}, 26 | "4": {} 27 | }, 28 | "n": { 29 | "q": {}, 30 | "m": {}, 31 | "r": {}, 32 | "t": {}, 33 | "j": {}, 34 | "w": {}, 35 | "p": {}, 36 | "s": {}, 37 | "k": {}, 38 | "z": {}, 39 | "x": {}, 40 | "n": {}, 41 | "h": {} 42 | }, 43 | "j": { 44 | "z": {} 45 | }, 46 | "m": { 47 | "f": {}, 48 | "b": {}, 49 | "c": {} 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /data/trees_countries/ME.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "r": { 4 | "t": { 5 | "s": {}, 6 | "u": {}, 7 | "d": {}, 8 | "e": {}, 9 | "t": {}, 10 | "g": {}, 11 | "7": {}, 12 | "6": {}, 13 | "9": {}, 14 | "c": {}, 15 | "1": {}, 16 | "k": {}, 17 | "b": {}, 18 | "8": {}, 19 | "5": {}, 20 | "h": {}, 21 | "3": {}, 22 | "v": {}, 23 | "y": {}, 24 | "f": {}, 25 | "m": {}, 26 | "2": {}, 27 | "x": {}, 28 | "4": {}, 29 | "w": {}, 30 | "r": {}, 31 | "q": {}, 32 | "j": {} 33 | }, 34 | "w": { 35 | "k": {}, 36 | "6": {}, 37 | "1": {}, 38 | "h": {}, 39 | "5": {}, 40 | "4": {}, 41 | "j": {}, 42 | "7": {} 43 | }, 44 | "m": { 45 | "z": {}, 46 | "r": {}, 47 | "x": {}, 48 | "w": {}, 49 | "y": {} 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /data/trees_countries/FM.json: -------------------------------------------------------------------------------- 1 | { 2 | "x": { 3 | "3": { 4 | "4": { 5 | "n": {} 6 | }, 7 | "k": { 8 | "4": {} 9 | }, 10 | "d": { 11 | "2": {}, 12 | "b": {}, 13 | "3": {}, 14 | "g": {} 15 | }, 16 | "p": { 17 | "b": {} 18 | }, 19 | "7": { 20 | "c": {}, 21 | "f": {} 22 | }, 23 | "6": { 24 | "1": {} 25 | } 26 | }, 27 | "1": { 28 | "e": { 29 | "z": {} 30 | }, 31 | "d": { 32 | "q": {}, 33 | "n": {}, 34 | "j": {} 35 | } 36 | }, 37 | "2": { 38 | "v": { 39 | "q": {} 40 | }, 41 | "n": { 42 | "j": {} 43 | }, 44 | "w": { 45 | "j": {} 46 | } 47 | }, 48 | "9": { 49 | "0": { 50 | "x": {}, 51 | "q": {}, 52 | "w": {}, 53 | "r": {} 54 | } 55 | }, 56 | "8": { 57 | "g": { 58 | "v": {}, 59 | "y": {} 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /data/trees_countries/KW.json: -------------------------------------------------------------------------------- 1 | { 2 | "t": { 3 | "j": { 4 | "1": { 5 | "x": {}, 6 | "y": {}, 7 | "w": {}, 8 | "v": {}, 9 | "m": {}, 10 | "q": {}, 11 | "s": {}, 12 | "t": {}, 13 | "j": {}, 14 | "z": {}, 15 | "r": {}, 16 | "u": {}, 17 | "f": {}, 18 | "g": {}, 19 | "n": {} 20 | }, 21 | "4": { 22 | "h": {}, 23 | "5": {}, 24 | "4": {}, 25 | "k": {}, 26 | "m": {}, 27 | "j": {}, 28 | "p": {}, 29 | "n": {}, 30 | "7": {}, 31 | "6": {}, 32 | "r": {} 33 | }, 34 | "3": { 35 | "9": {}, 36 | "b": {}, 37 | "8": {}, 38 | "c": {}, 39 | "f": {}, 40 | "3": {}, 41 | "6": {}, 42 | "d": {}, 43 | "g": {}, 44 | "e": {}, 45 | "2": {} 46 | }, 47 | "6": { 48 | "2": {}, 49 | "0": {}, 50 | "4": {}, 51 | "1": {}, 52 | "3": {}, 53 | "6": {} 54 | } 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /contracts/core/TaxCollector.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; 4 | 5 | import "../interfaces/IERC223ReceivingContract.sol"; 6 | import "../interfaces/IDetherToken.sol"; 7 | 8 | 9 | contract TaxCollector is IERC223ReceivingContract, Ownable { 10 | 11 | // Address where collected taxes are sent to 12 | address public taxRecipient; 13 | bool public unchangeable; 14 | IDetherToken public dth; 15 | // Daily tax rate (there are no floats in solidity) 16 | event ReceivedTaxes(address indexed tokenFrom, uint taxes, address indexed from); 17 | 18 | constructor (address _dth, address _taxRecipient) public { 19 | dth = IDetherToken(_dth); 20 | taxRecipient = _taxRecipient; 21 | } 22 | 23 | function unchangeableRecipient() 24 | onlyOwner 25 | external 26 | { 27 | unchangeable = true; 28 | } 29 | 30 | function changeRecipient(address _newRecipient) 31 | external 32 | onlyOwner 33 | { 34 | require(!unchangeable, 'Impossible to change the recipient'); 35 | taxRecipient = _newRecipient; 36 | } 37 | 38 | function collect() 39 | public 40 | { 41 | uint balance = dth.balanceOf(address(this)); 42 | dth.transfer(taxRecipient, balance); 43 | } 44 | 45 | function tokenFallback(address _from, uint _value, bytes memory _data) 46 | public 47 | { 48 | emit ReceivedTaxes(msg.sender, _value, _from); 49 | } 50 | } -------------------------------------------------------------------------------- /data/trees_countries/GS.json: -------------------------------------------------------------------------------- 1 | { 2 | "5": { 3 | "n": { 4 | "m": { 5 | "9": {}, 6 | "k": {}, 7 | "c": {}, 8 | "f": {}, 9 | "h": {}, 10 | "g": {}, 11 | "d": {}, 12 | "s": {}, 13 | "u": {}, 14 | "7": {}, 15 | "5": {}, 16 | "e": {} 17 | }, 18 | "q": { 19 | "4": {}, 20 | "2": {}, 21 | "6": {}, 22 | "3": {}, 23 | "1": {}, 24 | "8": {}, 25 | "5": {}, 26 | "0": {} 27 | }, 28 | "k": { 29 | "u": {} 30 | }, 31 | "n": { 32 | "r": {} 33 | } 34 | }, 35 | "m": { 36 | "v": { 37 | "5": {} 38 | }, 39 | "t": { 40 | "r": {}, 41 | "7": {}, 42 | "0": {}, 43 | "p": {}, 44 | "5": {} 45 | }, 46 | "u": { 47 | "r": {}, 48 | "t": {}, 49 | "g": {} 50 | }, 51 | "m": { 52 | "p": {} 53 | }, 54 | "g": { 55 | "v": {} 56 | }, 57 | "k": { 58 | "t": {} 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /data/trees_countries/TL.json: -------------------------------------------------------------------------------- 1 | { 2 | "q": { 3 | "y": { 4 | "3": { 5 | "m": {}, 6 | "q": {}, 7 | "t": {}, 8 | "w": {}, 9 | "j": {}, 10 | "y": {}, 11 | "u": {}, 12 | "h": {}, 13 | "7": {}, 14 | "5": {}, 15 | "v": {}, 16 | "p": {}, 17 | "4": {}, 18 | "x": {}, 19 | "n": {}, 20 | "s": {}, 21 | "r": {}, 22 | "z": {}, 23 | "k": {} 24 | }, 25 | "d": { 26 | "0": {}, 27 | "2": {}, 28 | "8": {} 29 | }, 30 | "2": { 31 | "3": {}, 32 | "4": {}, 33 | "u": {}, 34 | "6": {}, 35 | "v": {}, 36 | "g": {}, 37 | "f": {}, 38 | "7": {}, 39 | "y": {}, 40 | "5": {} 41 | }, 42 | "6": { 43 | "q": {}, 44 | "r": {}, 45 | "n": {}, 46 | "j": {}, 47 | "x": {}, 48 | "p": {} 49 | }, 50 | "9": { 51 | "1": {}, 52 | "b": {}, 53 | "2": {}, 54 | "3": {}, 55 | "0": {} 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /data/trees_countries/SV.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "4": { 4 | "2": { 5 | "r": {}, 6 | "t": {}, 7 | "w": {}, 8 | "u": {}, 9 | "x": {}, 10 | "v": {}, 11 | "y": {}, 12 | "n": {}, 13 | "m": {}, 14 | "q": {}, 15 | "h": {}, 16 | "k": {}, 17 | "z": {}, 18 | "e": {}, 19 | "g": {}, 20 | "p": {}, 21 | "j": {}, 22 | "s": {} 23 | }, 24 | "3": { 25 | "m": {}, 26 | "k": {}, 27 | "h": {}, 28 | "j": {}, 29 | "r": {}, 30 | "w": {}, 31 | "4": {}, 32 | "n": {}, 33 | "x": {}, 34 | "e": {}, 35 | "q": {}, 36 | "p": {}, 37 | "7": {}, 38 | "s": {}, 39 | "5": {}, 40 | "t": {}, 41 | "d": {}, 42 | "6": {} 43 | }, 44 | "8": { 45 | "8": {}, 46 | "0": {}, 47 | "3": {}, 48 | "6": {}, 49 | "2": {}, 50 | "9": {}, 51 | "b": {} 52 | } 53 | } 54 | }, 55 | "9": { 56 | "f": { 57 | "r": { 58 | "z": {}, 59 | "v": {}, 60 | "y": {} 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /data/trees_countries/MH.json: -------------------------------------------------------------------------------- 1 | { 2 | "x": { 3 | "c": { 4 | "2": { 5 | "1": {}, 6 | "5": {} 7 | }, 8 | "3": { 9 | "b": {}, 10 | "8": {} 11 | }, 12 | "0": { 13 | "8": {}, 14 | "2": {}, 15 | "d": {}, 16 | "9": {} 17 | }, 18 | "6": { 19 | "0": {}, 20 | "2": {} 21 | }, 22 | "4": { 23 | "6": {}, 24 | "p": {}, 25 | "4": {} 26 | }, 27 | "9": { 28 | "6": {}, 29 | "j": {} 30 | }, 31 | "c": { 32 | "d": {} 33 | } 34 | }, 35 | "8": { 36 | "z": { 37 | "f": {}, 38 | "x": {} 39 | } 40 | }, 41 | "f": { 42 | "8": { 43 | "4": {}, 44 | "5": {} 45 | } 46 | }, 47 | "9": { 48 | "y": { 49 | "x": {} 50 | }, 51 | "r": { 52 | "c": {}, 53 | "f": {}, 54 | "p": {} 55 | }, 56 | "x": { 57 | "3": {} 58 | }, 59 | "p": { 60 | "8": {} 61 | } 62 | }, 63 | "d": { 64 | "j": { 65 | "d": {} 66 | } 67 | }, 68 | "b": { 69 | "b": { 70 | "4": {} 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /data/trees_countries/DJ.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "f": { 4 | "j": { 5 | "c": {}, 6 | "b": {}, 7 | "9": {}, 8 | "8": {}, 9 | "g": {}, 10 | "d": {}, 11 | "f": {}, 12 | "u": {}, 13 | "v": {} 14 | }, 15 | "n": { 16 | "0": {}, 17 | "4": {}, 18 | "2": {}, 19 | "w": {}, 20 | "t": {}, 21 | "m": {}, 22 | "5": {}, 23 | "h": {}, 24 | "k": {}, 25 | "e": {}, 26 | "q": {}, 27 | "n": {}, 28 | "j": {}, 29 | "d": {}, 30 | "6": {}, 31 | "7": {}, 32 | "s": {}, 33 | "y": {}, 34 | "1": {}, 35 | "9": {}, 36 | "v": {}, 37 | "x": {}, 38 | "8": {}, 39 | "z": {}, 40 | "p": {}, 41 | "r": {}, 42 | "u": {}, 43 | "3": {} 44 | }, 45 | "q": { 46 | "8": {} 47 | } 48 | }, 49 | "c": { 50 | "v": { 51 | "z": {}, 52 | "x": {}, 53 | "w": {}, 54 | "y": {} 55 | }, 56 | "y": { 57 | "x": {}, 58 | "n": {}, 59 | "p": {}, 60 | "q": {}, 61 | "w": {}, 62 | "r": {} 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /data/trees_countries/RW.json: -------------------------------------------------------------------------------- 1 | { 2 | "k": { 3 | "x": { 4 | "t": { 5 | "e": {}, 6 | "k": {}, 7 | "w": {}, 8 | "7": {}, 9 | "j": {}, 10 | "s": {}, 11 | "n": {}, 12 | "t": {}, 13 | "h": {}, 14 | "4": {}, 15 | "q": {}, 16 | "m": {}, 17 | "1": {}, 18 | "x": {}, 19 | "5": {}, 20 | "z": {}, 21 | "g": {}, 22 | "f": {}, 23 | "d": {}, 24 | "v": {}, 25 | "p": {}, 26 | "0": {}, 27 | "y": {}, 28 | "3": {}, 29 | "r": {}, 30 | "2": {}, 31 | "u": {}, 32 | "6": {} 33 | }, 34 | "s": { 35 | "g": {}, 36 | "f": {}, 37 | "v": {}, 38 | "u": {}, 39 | "8": {}, 40 | "d": {}, 41 | "t": {}, 42 | "9": {}, 43 | "b": {}, 44 | "e": {}, 45 | "s": {}, 46 | "z": {}, 47 | "c": {}, 48 | "w": {}, 49 | "y": {} 50 | }, 51 | "v": { 52 | "0": {}, 53 | "b": {}, 54 | "8": {}, 55 | "9": {}, 56 | "2": {} 57 | }, 58 | "m": { 59 | "p": {} 60 | }, 61 | "k": { 62 | "z": {} 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /scripts/transferToken.js: -------------------------------------------------------------------------------- 1 | 2 | const DetherToken = artifacts.require('./dth/DetherToken.sol'); 3 | const DetherInterface = artifacts.require('./DetherInterface'); 4 | const DetherStorage = artifacts.require('./DetherTellerStorage.sol'); 5 | const SmsCertifier = artifacts.require('./certifier/SmsCertifier.sol'); 6 | const DthRegistry = artifacts.require('./DthRegistry.sol'); 7 | const Dth = artifacts.require('./DetherInterface.sol'); 8 | 9 | module.exports = async (callback) => { 10 | 11 | const web3Abi = require('web3-eth-abi'); 12 | const web3 = DthAbs.web3; 13 | const overloadedTransferAbi = { 14 | "constant": false, 15 | "inputs": [ 16 | { 17 | "name": "_to", 18 | "type": "address" 19 | }, 20 | { 21 | "name": "_value", 22 | "type": "uint256" 23 | }, 24 | { 25 | "name": "_data", 26 | "type": "bytes" 27 | } 28 | ], 29 | "name": "transfer", 30 | "outputs": [ 31 | { 32 | "name": "", 33 | "type": "bool" 34 | } 35 | ], 36 | "payable": false, 37 | "stateMutability": "nonpayable", 38 | "type": "function" 39 | }; 40 | 41 | 42 | 43 | const transferMethodTransactionData = web3Abi.encodeFunctionCall( 44 | overloadedTransferAbi, 45 | [ 46 | '0x969b6C352Ef0713484d54479457685A304ac96Aa', 47 | 10, 48 | web3.toHex('test') 49 | ] 50 | ); 51 | const tsx = await web3.eth.sendTransaction({from: '0x6AAb2B0913B70270E840B14c2b23B716C0a43522', to: '0x85CAcBBCa83cE5d461e16cAF3F84c99eD5c6BE1c', data: transferMethodTransactionData, value: 0, gas: 5700000}); 52 | console.log(tsx); 53 | callback(); 54 | }; 55 | -------------------------------------------------------------------------------- /contracts/interfaces/IZoneFactory.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract IZoneFactory { 4 | function dth() view public returns(address); 5 | function zoneToGeohash(address) view public returns(bytes6); 6 | function geohashToZone(bytes6) view public returns(address); 7 | function activeBidderToZone(address) view public returns(address); 8 | function ownerToZone(address) view public returns(address); 9 | function zoneImplementation() view public returns(address); 10 | function tellerImplementation() view public returns(address); 11 | function geo() view public returns(address); 12 | function users() view public returns(address); 13 | // function getActiveBidderZone(address _bidder) view public returns(address); 14 | function transferOwnership(address newOwner) public; 15 | function changeOwner( address _newOwner, address _oldOwner, address _zone) public; 16 | function zoneExists(bytes6 _geohash) view external returns(bool); 17 | function proxyUpdateUserDailySold(bytes2 _countryCode, address _from, address _to, uint256 _amount) external; 18 | function emitAuctionCreated(bytes6 zoneFrom, address sender, uint auctionId, uint bidAmount) public; 19 | function emitAuctionEnded(bytes6 zoneFrom, address newOwner, uint auctionId, uint winningBid) public; 20 | function emitBid(bytes6 zoneFrom, address sender, uint auctionId, uint bidAmount) public; 21 | function emitClaimFreeZone(bytes6 zoneFrom, address newOwner, uint bidAmount) public; 22 | function emitReleaseZone(bytes6 zoneFrom, address sender) public; 23 | function fillCurrentZoneBidder(address bidder) public; 24 | function removeActiveBidder(address activeBidder) public; 25 | function removeCurrentZoneBidders() public; 26 | function tokenFallback(address _from, uint256 _value, bytes memory _data) public; 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Global 2 | node_modules/ 3 | .env 4 | sigmate-v3-deploysc.json 5 | 6 | 7 | 8 | ### JetBrains template 9 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 10 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 11 | 12 | # User-specific stuff: 13 | .idea/**/workspace.xml 14 | .idea/**/tasks.xml 15 | .idea/dictionaries 16 | 17 | # Sensitive or high-churn files: 18 | .idea/**/dataSources/ 19 | .idea/**/dataSources.ids 20 | .idea/**/dataSources.xml 21 | .idea/**/dataSources.local.xml 22 | .idea/**/sqlDataSources.xml 23 | .idea/**/dynamic.xml 24 | .idea/**/uiDesigner.xml 25 | 26 | # Gradle: 27 | .idea/**/gradle.xml 28 | .idea/**/libraries 29 | 30 | # CMake 31 | cmake-build-debug/ 32 | 33 | # Mongo Explorer plugin: 34 | .idea/**/mongoSettings.xml 35 | 36 | ## File-based project format: 37 | *.iws 38 | 39 | ## Plugin-specific files: 40 | 41 | # IntelliJ 42 | out/ 43 | 44 | # mpeltonen/sbt-idea plugin 45 | .idea_modules/ 46 | 47 | # JIRA plugin 48 | atlassian-ide-plugin.xml 49 | 50 | # Cursive Clojure plugin 51 | .idea/replstate.xml 52 | 53 | # Crashlytics plugin (for Android Studio and IntelliJ) 54 | com_crashlytics_export_strings.xml 55 | crashlytics.properties 56 | crashlytics-build.properties 57 | fabric.properties 58 | 59 | 60 | ### macOS template 61 | # General 62 | .DS_Store 63 | .AppleDouble 64 | .LSOverride 65 | 66 | # Icon must end with two \r 67 | Icon 68 | 69 | # Thumbnails 70 | ._* 71 | 72 | # Files that might appear in the root of a volume 73 | .DocumentRevisions-V100 74 | .fseventsd 75 | .Spotlight-V100 76 | .TemporaryItems 77 | .Trashes 78 | .VolumeIcon.icns 79 | .com.apple.timemachine.donotpresent 80 | 81 | # Directories potentially created on remote AFP share 82 | .AppleDB 83 | .AppleDesktop 84 | Network Trash Folder 85 | Temporary Items 86 | .apdisk 87 | -------------------------------------------------------------------------------- /contracts/interfaces/IShops.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract IShops { 4 | function dth() view public returns(address); 5 | function withdrawableDth(address) view public returns(uint256); 6 | function positionToShopAddress(bytes12) view public returns(address); 7 | function shopsDispute() view public returns(address); 8 | function zoneToShopAddresses(bytes7, uint256) view public returns(address); 9 | function geo() view public returns(address); 10 | function users() view public returns(address); 11 | function countryLicensePrice(bytes2) view public returns(uint256); 12 | function setShopsDisputeContract(address _shopsDispute) external; 13 | function getShopByAddr(address _addr) view public returns(bytes12, bytes16, bytes16, bytes32, bytes16, uint256, bool, uint256); 14 | function getShopByPos(bytes12 _position) view external returns(bytes12, bytes16, bytes16, bytes32, bytes16, uint256, bool, uint256); 15 | function getShopAddressesInZone(bytes7 _zoneGeohash) view external returns(address[] memory); 16 | function shopByAddrExists(address _shopAddress) view external returns(bool); 17 | function getShopDisputeID(address _shopAddress) view external returns(uint256); 18 | function hasDispute(address _shopAddress) view external returns(bool); 19 | function getShopStaked(address _shopAddress) view external returns(uint256); 20 | function setCountryLicensePrice(bytes2 _countryCode, uint256 _priceDTH) external; 21 | function tokenFallback(address _from, uint256 _value, bytes memory _data) public; 22 | function removeShop() external; 23 | function withdrawDth() external; 24 | function setDispute(address _shopAddress, uint256 _disputeID) external; 25 | function unsetDispute(address _shopAddress) external; 26 | function removeDisputedShop(address _shopAddress, address _challenger) external; 27 | } 28 | -------------------------------------------------------------------------------- /data/trees_countries/BI.json: -------------------------------------------------------------------------------- 1 | { 2 | "k": { 3 | "x": { 4 | "m": { 5 | "r": {}, 6 | "w": {}, 7 | "t": {}, 8 | "6": {}, 9 | "j": {}, 10 | "h": {}, 11 | "n": {}, 12 | "m": {}, 13 | "7": {}, 14 | "q": {}, 15 | "5": {}, 16 | "0": {}, 17 | "k": {}, 18 | "4": {}, 19 | "1": {}, 20 | "v": {}, 21 | "u": {}, 22 | "d": {}, 23 | "x": {}, 24 | "s": {}, 25 | "9": {}, 26 | "3": {}, 27 | "e": {}, 28 | "y": {}, 29 | "z": {}, 30 | "2": {}, 31 | "p": {} 32 | }, 33 | "k": { 34 | "c": {}, 35 | "g": {}, 36 | "b": {}, 37 | "u": {}, 38 | "y": {}, 39 | "f": {}, 40 | "z": {}, 41 | "x": {}, 42 | "w": {}, 43 | "v": {} 44 | }, 45 | "j": { 46 | "r": {}, 47 | "p": {}, 48 | "n": {} 49 | }, 50 | "t": { 51 | "9": {}, 52 | "8": {}, 53 | "d": {}, 54 | "0": {}, 55 | "3": {}, 56 | "2": {}, 57 | "6": {} 58 | }, 59 | "s": { 60 | "8": {}, 61 | "9": {}, 62 | "b": {}, 63 | "c": {} 64 | }, 65 | "h": { 66 | "y": {}, 67 | "z": {} 68 | } 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /contracts/interfaces/IUsers.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract IUsers { 4 | function zoneFactoryAddress() view public returns(address); 5 | function kycCertifier() view public returns(address); 6 | function priceOracle() view public returns(address); 7 | function smsCertifier() view public returns(address); 8 | function getHour(uint256 timestamp) pure public returns(uint8); 9 | function volumeSell(address) view public returns(uint256); 10 | function nbTrade(address) view public returns(uint256); 11 | function getWeekday(uint256 timestamp) pure public returns(uint8); 12 | function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute) pure public returns(uint256 timestamp); 13 | function getDay(uint256 timestamp) pure public returns(uint8); 14 | function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour) pure public returns(uint256 timestamp); 15 | function getSecond(uint256 timestamp) pure public returns(uint8); 16 | function toTimestamp(uint16 year, uint8 month, uint8 day) pure public returns(uint256 timestamp); 17 | function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute, uint8 second) pure public returns(uint256 timestamp); 18 | function getYear(uint256 timestamp) pure public returns(uint16); 19 | function getMonth(uint256 timestamp) pure public returns(uint8); 20 | function isLeapYear(uint16 year) pure public returns(bool); 21 | function leapYearsBefore(uint256 year) pure public returns(uint256); 22 | function getDaysInMonth(uint8 month, uint16 year) pure public returns(uint8); 23 | function geo() view public returns(address); 24 | function volumeBuy(address) view public returns(uint256); 25 | function getMinute(uint256 timestamp) pure public returns(uint8); 26 | function getDateInfo(uint256 timestamp) pure external returns(uint16, uint16, uint16); 27 | } 28 | -------------------------------------------------------------------------------- /data/trees_countries/BZ.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "5": { 4 | "1": { 5 | "j": {}, 6 | "p": {}, 7 | "n": {}, 8 | "7": {}, 9 | "m": {}, 10 | "0": {}, 11 | "r": {}, 12 | "e": {}, 13 | "2": {}, 14 | "5": {}, 15 | "1": {}, 16 | "q": {}, 17 | "h": {}, 18 | "k": {}, 19 | "3": {}, 20 | "d": {}, 21 | "x": {}, 22 | "6": {}, 23 | "w": {}, 24 | "4": {} 25 | }, 26 | "0": { 27 | "c": {}, 28 | "b": {}, 29 | "u": {}, 30 | "g": {}, 31 | "f": {}, 32 | "s": {}, 33 | "9": {}, 34 | "t": {}, 35 | "e": {}, 36 | "v": {}, 37 | "z": {}, 38 | "d": {}, 39 | "8": {}, 40 | "y": {}, 41 | "w": {} 42 | }, 43 | "3": { 44 | "2": {}, 45 | "0": {}, 46 | "1": {} 47 | }, 48 | "2": { 49 | "b": {} 50 | } 51 | }, 52 | "4": { 53 | "b": { 54 | "z": {}, 55 | "y": {}, 56 | "v": {}, 57 | "f": {}, 58 | "d": {}, 59 | "t": {}, 60 | "u": {}, 61 | "e": {}, 62 | "s": {}, 63 | "x": {}, 64 | "g": {}, 65 | "w": {} 66 | }, 67 | "c": { 68 | "p": {}, 69 | "j": {}, 70 | "n": {}, 71 | "h": {} 72 | } 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /contracts/core/Users.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | pragma experimental ABIEncoderV2; 3 | 4 | import "openzeppelin-solidity/contracts/math/SafeMath.sol"; 5 | 6 | import "../interfaces/ICertifier.sol"; 7 | import "../interfaces/IGeoRegistry.sol"; 8 | import "../interfaces/ICertifierRegistry.sol"; 9 | 10 | contract Users { 11 | // ------------------------------------------------ 12 | // 13 | // Library init 14 | // 15 | // ------------------------------------------------ 16 | 17 | using SafeMath for uint; 18 | 19 | // ------------------------------------------------ 20 | // 21 | // Variables Public 22 | // 23 | // ------------------------------------------------ 24 | 25 | IGeoRegistry public geo; 26 | ICertifierRegistry public certifierRegistry; 27 | 28 | address public zoneFactoryAddress; 29 | bool public isInit = false; 30 | 31 | // ------------------------------------------------ 32 | // 33 | // Constructor 34 | // 35 | // ------------------------------------------------ 36 | 37 | constructor(address _geo, address _certifierRegistry) 38 | public 39 | { 40 | geo = IGeoRegistry(_geo); 41 | certifierRegistry = ICertifierRegistry(_certifierRegistry); 42 | } 43 | 44 | // ------------------------------------------------ 45 | // 46 | // Functions Setters 47 | // 48 | // ------------------------------------------------ 49 | 50 | function setZoneFactory(address _zoneFactory) 51 | external 52 | { 53 | require(isInit == false, 'cannot be called more than once'); 54 | zoneFactoryAddress = _zoneFactory; 55 | isInit = true; 56 | } 57 | 58 | // ------------------------------------------------ 59 | // 60 | // Functions Getters 61 | // 62 | // ------------------------------------------------ 63 | 64 | function getCertifications(address _who) 65 | external view 66 | returns ( ICertifierRegistry.Certification[] memory) 67 | { 68 | return certifierRegistry.getCerts(_who); 69 | } 70 | } -------------------------------------------------------------------------------- /data/trees_countries/SI.json: -------------------------------------------------------------------------------- 1 | { 2 | "u": { 3 | "2": { 4 | "4": { 5 | "w": {}, 6 | "v": {}, 7 | "x": {}, 8 | "q": {}, 9 | "j": {}, 10 | "y": {}, 11 | "s": {}, 12 | "e": {}, 13 | "p": {}, 14 | "t": {}, 15 | "m": {}, 16 | "k": {}, 17 | "z": {}, 18 | "5": {}, 19 | "h": {}, 20 | "n": {}, 21 | "7": {}, 22 | "f": {}, 23 | "d": {}, 24 | "4": {}, 25 | "6": {}, 26 | "g": {}, 27 | "u": {}, 28 | "r": {} 29 | }, 30 | "7": { 31 | "0": {}, 32 | "2": {}, 33 | "1": {}, 34 | "9": {}, 35 | "3": {}, 36 | "6": {}, 37 | "8": {}, 38 | "d": {} 39 | }, 40 | "1": { 41 | "z": {}, 42 | "v": {}, 43 | "y": {}, 44 | "f": {}, 45 | "e": {}, 46 | "g": {}, 47 | "w": {}, 48 | "u": {}, 49 | "x": {}, 50 | "d": {}, 51 | "s": {}, 52 | "t": {} 53 | }, 54 | "6": { 55 | "b": {}, 56 | "8": {}, 57 | "9": {}, 58 | "2": {}, 59 | "0": {}, 60 | "c": {} 61 | }, 62 | "5": { 63 | "h": {}, 64 | "n": {}, 65 | "j": {}, 66 | "p": {}, 67 | "r": {}, 68 | "x": {} 69 | }, 70 | "3": { 71 | "b": {}, 72 | "8": {} 73 | } 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /data/trees_countries/FK.json: -------------------------------------------------------------------------------- 1 | { 2 | "4": { 3 | "w": { 4 | "y": { 5 | "3": {}, 6 | "c": {}, 7 | "8": {}, 8 | "2": {}, 9 | "f": {}, 10 | "d": {}, 11 | "6": {}, 12 | "h": {}, 13 | "7": {}, 14 | "e": {}, 15 | "9": {}, 16 | "g": {}, 17 | "k": {}, 18 | "1": {}, 19 | "0": {}, 20 | "5": {}, 21 | "4": {} 22 | }, 23 | "t": { 24 | "x": {}, 25 | "q": {}, 26 | "t": {}, 27 | "r": {}, 28 | "y": {}, 29 | "p": {}, 30 | "z": {}, 31 | "w": {} 32 | }, 33 | "v": { 34 | "7": {}, 35 | "5": {}, 36 | "8": {}, 37 | "s": {}, 38 | "b": {}, 39 | "d": {}, 40 | "0": {}, 41 | "9": {}, 42 | "6": {}, 43 | "1": {}, 44 | "4": {}, 45 | "k": {}, 46 | "e": {}, 47 | "g": {}, 48 | "c": {}, 49 | "f": {}, 50 | "2": {}, 51 | "h": {}, 52 | "3": {} 53 | }, 54 | "w": { 55 | "r": {}, 56 | "n": {}, 57 | "p": {} 58 | }, 59 | "s": { 60 | "x": {}, 61 | "z": {}, 62 | "y": {} 63 | }, 64 | "u": { 65 | "f": {}, 66 | "c": {}, 67 | "9": {}, 68 | "u": {}, 69 | "3": {}, 70 | "b": {}, 71 | "2": {}, 72 | "g": {}, 73 | "8": {}, 74 | "t": {} 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /data/trees_countries/MK.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "r": { 4 | "r": { 5 | "w": {}, 6 | "r": {}, 7 | "e": {}, 8 | "y": {}, 9 | "v": {}, 10 | "n": {}, 11 | "6": {}, 12 | "m": {}, 13 | "j": {}, 14 | "5": {}, 15 | "4": {}, 16 | "q": {}, 17 | "x": {}, 18 | "1": {}, 19 | "7": {}, 20 | "s": {}, 21 | "u": {}, 22 | "k": {}, 23 | "t": {}, 24 | "g": {}, 25 | "h": {}, 26 | "p": {}, 27 | "z": {}, 28 | "0": {}, 29 | "2": {}, 30 | "f": {}, 31 | "3": {}, 32 | "9": {}, 33 | "c": {}, 34 | "d": {} 35 | }, 36 | "q": { 37 | "g": {}, 38 | "v": {}, 39 | "c": {}, 40 | "u": {}, 41 | "f": {}, 42 | "z": {}, 43 | "8": {}, 44 | "t": {}, 45 | "d": {}, 46 | "y": {}, 47 | "e": {}, 48 | "b": {}, 49 | "9": {}, 50 | "s": {}, 51 | "w": {} 52 | }, 53 | "x": { 54 | "8": {}, 55 | "2": {}, 56 | "b": {}, 57 | "c": {}, 58 | "0": {} 59 | }, 60 | "w": { 61 | "b": {} 62 | } 63 | }, 64 | "x": { 65 | "2": { 66 | "j": {}, 67 | "h": {}, 68 | "p": {}, 69 | "q": {}, 70 | "k": {}, 71 | "7": {}, 72 | "5": {}, 73 | "m": {}, 74 | "4": {}, 75 | "1": {}, 76 | "n": {} 77 | } 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /data/trees_countries/LS.json: -------------------------------------------------------------------------------- 1 | { 2 | "k": { 3 | "d": { 4 | "g": { 5 | "f": {}, 6 | "8": {}, 7 | "b": {}, 8 | "c": {}, 9 | "u": {}, 10 | "d": {}, 11 | "e": {}, 12 | "9": {}, 13 | "3": {}, 14 | "2": {}, 15 | "g": {} 16 | }, 17 | "e": { 18 | "z": {}, 19 | "v": {}, 20 | "t": {}, 21 | "g": {}, 22 | "x": {}, 23 | "w": {}, 24 | "y": {}, 25 | "u": {}, 26 | "s": {}, 27 | "c": {}, 28 | "k": {}, 29 | "7": {}, 30 | "m": {}, 31 | "n": {}, 32 | "f": {}, 33 | "q": {}, 34 | "r": {}, 35 | "d": {}, 36 | "9": {}, 37 | "p": {}, 38 | "e": {} 39 | }, 40 | "u": { 41 | "5": {}, 42 | "7": {}, 43 | "4": {}, 44 | "6": {}, 45 | "8": {}, 46 | "0": {}, 47 | "9": {}, 48 | "3": {}, 49 | "2": {}, 50 | "1": {}, 51 | "d": {}, 52 | "m": {}, 53 | "f": {}, 54 | "b": {}, 55 | "c": {}, 56 | "e": {}, 57 | "k": {}, 58 | "s": {}, 59 | "j": {}, 60 | "h": {} 61 | }, 62 | "s": { 63 | "p": {}, 64 | "j": {}, 65 | "m": {}, 66 | "r": {}, 67 | "q": {}, 68 | "n": {}, 69 | "t": {}, 70 | "k": {}, 71 | "s": {}, 72 | "x": {}, 73 | "z": {}, 74 | "5": {}, 75 | "4": {}, 76 | "h": {}, 77 | "w": {} 78 | } 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /data/trees_countries/IL.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "v": { 4 | "2": { 5 | "z": {}, 6 | "y": {}, 7 | "x": {}, 8 | "e": {}, 9 | "g": {}, 10 | "r": {}, 11 | "s": {}, 12 | "q": {}, 13 | "c": {}, 14 | "v": {}, 15 | "d": {}, 16 | "b": {}, 17 | "u": {}, 18 | "f": {}, 19 | "t": {}, 20 | "9": {}, 21 | "w": {} 22 | }, 23 | "c": { 24 | "4": {}, 25 | "5": {}, 26 | "2": {}, 27 | "6": {}, 28 | "7": {}, 29 | "m": {}, 30 | "h": {}, 31 | "e": {}, 32 | "k": {}, 33 | "q": {}, 34 | "3": {}, 35 | "1": {}, 36 | "0": {} 37 | }, 38 | "8": { 39 | "9": {}, 40 | "8": {}, 41 | "c": {}, 42 | "b": {}, 43 | "w": {}, 44 | "g": {}, 45 | "6": {}, 46 | "f": {}, 47 | "v": {}, 48 | "u": {}, 49 | "x": {}, 50 | "e": {}, 51 | "z": {}, 52 | "s": {}, 53 | "3": {}, 54 | "t": {}, 55 | "y": {}, 56 | "2": {}, 57 | "d": {} 58 | }, 59 | "0": { 60 | "z": {} 61 | }, 62 | "b": { 63 | "g": {}, 64 | "c": {}, 65 | "f": {}, 66 | "u": {}, 67 | "b": {} 68 | }, 69 | "3": { 70 | "j": {}, 71 | "h": {}, 72 | "n": {}, 73 | "p": {} 74 | }, 75 | "9": { 76 | "h": {}, 77 | "4": {}, 78 | "0": {}, 79 | "5": {}, 80 | "1": {} 81 | } 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dethercontractrepo", 3 | "version": "2.1.0", 4 | "description": "Dether provides a decentralized peer-to-peer ether network that enables anyone on Earth to buy ether with cash and spend it at physical stores nearby.", 5 | "main": "truffle.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "node_modules/.bin/truffle test", 11 | "trace": "MODE=trace node_modules/.bin/truffle test", 12 | "testKovanInfura": "node_modules/.bin/truffle test --network kovanInfura", 13 | "compile": "node_modules/.bin/truffle compile", 14 | "migrate": "node_modules/.bin/truffle migrate --reset", 15 | "migrateKovan": "node_modules/.bin/truffle migrate --network kovan --reset", 16 | "esdoc": "./node_modules/.bin/esdoc", 17 | "security": "./node_modules/.bin/truffle run verify Zone" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/dethertech/dethercontracts.git" 22 | }, 23 | "author": "Dether's team (https://github.com/dethertech)", 24 | "contributors": [ 25 | "Dether team " 26 | ], 27 | "license": "MIT", 28 | "bugs": { 29 | "url": "https://github.com/dethertech/dethercontracts/issues" 30 | }, 31 | "dependencies": { 32 | "bignum": "^0.13.0", 33 | "ethereum-datetime": "^1.0.0", 34 | "ethereumjs-util": "^5.2.0", 35 | "openzeppelin-solidity": "^2.1.2", 36 | "truffle": "^5.0.33", 37 | "truffle-hdwallet-provider": "^1.0.0-web3one.5", 38 | "truffle-privatekey-provider": "^0.1.0", 39 | "web3": "1.2.1" 40 | }, 41 | "devDependencies": { 42 | "bignumber.js": "^8.0.1", 43 | "chai": "^4.2.0", 44 | "chai-as-promised": "^7.1.1", 45 | "chai-bn": "^0.1.1", 46 | "dotenv": "^4.0.0", 47 | "eslint": "^4.3.0", 48 | "eslint-config-airbnb-base": "^12.1.0", 49 | "eslint-plugin-html": "^3.0.0", 50 | "eslint-plugin-import": "^2.7.0", 51 | "ethereumjs-abi": "^0.6.4", 52 | "ethers": "^2.1.3", 53 | "for-async": "^1.0.1", 54 | "fs": "0.0.1-security", 55 | "papaparse": "^4.6.3", 56 | "pretty-time": "^1.1.0", 57 | "truffle-assertions": "^0.8.2", 58 | "truffle-security": "git+https://github.com/ConsenSys/truffle-security.git" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /truffle-config.js: -------------------------------------------------------------------------------- 1 | require("dotenv").config({ path: ".env" }); 2 | 3 | const { MNEMONIC, MNEMONIC_MAIN, PRIVKEY_MAIN, INFURA_KEY } = process.env; 4 | const HDWalletProvider = require("truffle-hdwallet-provider"); 5 | const PKWalletProvider = require("truffle-privatekey-provider"); 6 | 7 | module.exports = { 8 | networks: { 9 | development: { 10 | host: "localhost", 11 | port: 8545, 12 | network_id: "*", // Match any network id 13 | gas: 6700000, 14 | }, 15 | kovan: { 16 | provider: () => 17 | new HDWalletProvider( 18 | MNEMONIC, 19 | `https://kovan.infura.io/v3/v3/${INFURA_KEY}` 20 | ), 21 | 22 | // provider: () => new HDWalletProvider(MNEMONIC, 'http://localhost:8545'), 23 | network_id: 42, 24 | gas: 6700000, 25 | gasPrice: 20000000000, 26 | skipDryRun: true, 27 | // from: '0x6AAb2B0913B70270E840B14c2b23B716C0a43522', 28 | }, 29 | rinkeby: { 30 | provider: () => 31 | new HDWalletProvider(MNEMONIC, "https://rinkeby.infura.io/"), 32 | // provider: () => new HDWalletProvider(MNEMONIC, 'http://localhost:8545'), 33 | network_id: 4, 34 | // gas: 4700000, 35 | gasPrice: 20000000000, 36 | // from: '0x6AAb2B0913B70270E840B14c2b23B716C0a43522', 37 | }, 38 | ropsten: { 39 | provider: () => 40 | new HDWalletProvider(MNEMONIC, "https://ropsten.infura.io/"), 41 | network_id: 3, 42 | // gas: 4700000, 43 | gasPrice: 2000000000, 44 | skipDryRun: true, 45 | }, 46 | mainnet: { 47 | // provider: () => new HDWalletProvider(MNEMONIC_MAIN, 'http://localhost:8545'), 48 | provider: () => 49 | new HDWalletProvider( 50 | MNEMONIC, 51 | `https://mainnet.infura.io/v3/${INFURA_KEY}` 52 | ), 53 | // provider: () => new PKWalletProvider(PRIVKEY_MAIN, 'http://localhost:8545'), 54 | network_id: 1, 55 | gasPrice: 23100000000, 56 | gas: 8110000, 57 | skipDryRun: true, 58 | // gasPrice: 25000000000, 59 | }, 60 | }, 61 | plugins: ["truffle-security"], 62 | compilers: { 63 | solc: { 64 | version: "0.5.10", 65 | optimizer: { 66 | enabled: true, 67 | runs: 200, 68 | }, 69 | }, 70 | }, 71 | }; 72 | -------------------------------------------------------------------------------- /data/trees_countries/TF.json: -------------------------------------------------------------------------------- 1 | { 2 | "j": { 3 | "x": { 4 | "0": { 5 | "z": {}, 6 | "y": {}, 7 | "v": {} 8 | }, 9 | "1": { 10 | "z": {}, 11 | "r": {}, 12 | "q": {}, 13 | "m": {}, 14 | "n": {}, 15 | "y": {}, 16 | "p": {}, 17 | "x": {}, 18 | "w": {}, 19 | "j": {}, 20 | "v": {}, 21 | "t": {} 22 | }, 23 | "2": { 24 | "b": {}, 25 | "c": {}, 26 | "g": {}, 27 | "f": {} 28 | }, 29 | "3": { 30 | "9": {}, 31 | "6": {}, 32 | "b": {}, 33 | "5": {}, 34 | "2": {}, 35 | "4": {}, 36 | "8": {}, 37 | "1": {}, 38 | "0": {}, 39 | "3": {} 40 | }, 41 | "4": { 42 | "j": {}, 43 | "n": {}, 44 | "p": {} 45 | }, 46 | "6": { 47 | "0": {} 48 | } 49 | }, 50 | "p": { 51 | "s": { 52 | "z": {}, 53 | "x": {} 54 | }, 55 | "g": { 56 | "d": {}, 57 | "c": {}, 58 | "f": {}, 59 | "9": {} 60 | }, 61 | "u": { 62 | "b": {}, 63 | "8": {} 64 | } 65 | } 66 | }, 67 | "m": { 68 | "j": { 69 | "c": { 70 | "w": {} 71 | }, 72 | "n": { 73 | "v": {} 74 | } 75 | }, 76 | "9": { 77 | "p": { 78 | "5": {} 79 | }, 80 | "r": { 81 | "0": {} 82 | } 83 | } 84 | }, 85 | "k": { 86 | "u": { 87 | "h": { 88 | "8": {}, 89 | "q": {}, 90 | "9": {} 91 | }, 92 | "y": { 93 | "q": {} 94 | } 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /contracts/kleros/Arbitrable.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * @title Arbitrable 3 | * @author Clément Lesaege - 4 | * Bug Bounties: This code hasn't undertaken a bug bounty program yet. 5 | */ 6 | 7 | pragma solidity ^0.5.10; 8 | 9 | import "./IArbitrable.sol"; 10 | 11 | /** @title Arbitrable 12 | * Arbitrable abstract contract. 13 | * When developing arbitrable contracts, we need to: 14 | * -Define the action taken when a ruling is received by the contract. We should do so in executeRuling. 15 | * -Allow dispute creation. For this a function must: 16 | * -Call arbitrator.createDispute.value(_fee)(_choices,_extraData); 17 | * -Create the event Dispute(_arbitrator,_disputeID,_rulingOptions); 18 | */ 19 | contract Arbitrable is IArbitrable { 20 | Arbitrator public arbitrator; 21 | bytes public arbitratorExtraData; // Extra data to require particular dispute and appeal behaviour. 22 | 23 | modifier onlyArbitrator {require(msg.sender == address(arbitrator), "Can only be called by the arbitrator."); _;} 24 | 25 | /** @dev Constructor. Choose the arbitrator. 26 | * @param _arbitrator The arbitrator of the contract. 27 | * @param _arbitratorExtraData Extra data for the arbitrator. 28 | */ 29 | constructor(Arbitrator _arbitrator, bytes memory _arbitratorExtraData) public { 30 | arbitrator = _arbitrator; 31 | arbitratorExtraData = _arbitratorExtraData; 32 | } 33 | 34 | /** @dev Give a ruling for a dispute. Must be called by the arbitrator. 35 | * The purpose of this function is to ensure that the address calling it has the right to rule on the contract. 36 | * @param _disputeID ID of the dispute in the Arbitrator contract. 37 | * @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision". 38 | */ 39 | function rule(uint _disputeID, uint _ruling) public onlyArbitrator { 40 | emit Ruling(Arbitrator(msg.sender),_disputeID,_ruling); 41 | 42 | executeRuling(_disputeID,_ruling); 43 | } 44 | 45 | 46 | /** @dev Execute a ruling of a dispute. 47 | * @param _disputeID ID of the dispute in the Arbitrator contract. 48 | * @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision". 49 | */ 50 | function executeRuling(uint _disputeID, uint _ruling) internal; 51 | } 52 | -------------------------------------------------------------------------------- /data/trees_countries/GQ.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "0": { 4 | "r": { 5 | "6": {}, 6 | "4": {}, 7 | "0": {}, 8 | "7": {}, 9 | "f": {}, 10 | "g": {}, 11 | "5": {}, 12 | "9": {}, 13 | "d": {}, 14 | "3": {}, 15 | "2": {}, 16 | "c": {}, 17 | "b": {}, 18 | "1": {}, 19 | "e": {}, 20 | "8": {}, 21 | "s": {}, 22 | "u": {}, 23 | "h": {}, 24 | "k": {} 25 | }, 26 | "p": { 27 | "z": {}, 28 | "q": {}, 29 | "w": {}, 30 | "y": {}, 31 | "x": {}, 32 | "r": {}, 33 | "p": {}, 34 | "j": {}, 35 | "m": {}, 36 | "n": {}, 37 | "v": {}, 38 | "t": {} 39 | }, 40 | "n": { 41 | "z": {}, 42 | "v": {}, 43 | "x": {}, 44 | "w": {}, 45 | "y": {} 46 | }, 47 | "w": { 48 | "4": {}, 49 | "5": {}, 50 | "k": {}, 51 | "j": {}, 52 | "7": {}, 53 | "m": {}, 54 | "h": {} 55 | }, 56 | "q": { 57 | "u": {}, 58 | "8": {}, 59 | "v": {}, 60 | "c": {}, 61 | "b": {}, 62 | "f": {}, 63 | "g": {} 64 | }, 65 | "t": { 66 | "f": {}, 67 | "g": {} 68 | } 69 | }, 70 | "2": { 71 | "2": { 72 | "4": {}, 73 | "1": {}, 74 | "h": {}, 75 | "0": {}, 76 | "5": {} 77 | }, 78 | "0": { 79 | "p": {}, 80 | "n": {}, 81 | "j": {} 82 | } 83 | } 84 | }, 85 | "k": { 86 | "p": { 87 | "s": { 88 | "p": {} 89 | }, 90 | "e": { 91 | "z": {} 92 | } 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /data/trees_countries/HT.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "7": { 4 | "k": { 5 | "s": {}, 6 | "t": {}, 7 | "w": {}, 8 | "r": {}, 9 | "x": {}, 10 | "8": {}, 11 | "e": {}, 12 | "1": {}, 13 | "q": {}, 14 | "6": {}, 15 | "p": {}, 16 | "h": {}, 17 | "y": {}, 18 | "m": {}, 19 | "9": {}, 20 | "7": {}, 21 | "u": {}, 22 | "j": {}, 23 | "5": {}, 24 | "f": {}, 25 | "b": {}, 26 | "k": {}, 27 | "v": {}, 28 | "c": {}, 29 | "g": {}, 30 | "d": {}, 31 | "n": {}, 32 | "3": {}, 33 | "z": {}, 34 | "0": {}, 35 | "2": {}, 36 | "4": {} 37 | }, 38 | "s": { 39 | "0": {}, 40 | "3": {}, 41 | "2": {}, 42 | "6": {}, 43 | "1": {}, 44 | "4": {}, 45 | "8": {}, 46 | "b": {} 47 | }, 48 | "7": { 49 | "b": {}, 50 | "8": {}, 51 | "2": {}, 52 | "4": {}, 53 | "9": {}, 54 | "0": {}, 55 | "3": {}, 56 | "c": {}, 57 | "z": {}, 58 | "g": {}, 59 | "1": {}, 60 | "6": {}, 61 | "d": {} 62 | }, 63 | "h": { 64 | "y": {}, 65 | "p": {}, 66 | "r": {}, 67 | "x": {}, 68 | "z": {} 69 | }, 70 | "5": { 71 | "w": {}, 72 | "r": {}, 73 | "q": {}, 74 | "z": {}, 75 | "p": {}, 76 | "x": {} 77 | }, 78 | "m": { 79 | "0": {}, 80 | "n": {}, 81 | "h": {}, 82 | "p": {}, 83 | "j": {} 84 | }, 85 | "e": { 86 | "c": {}, 87 | "b": {} 88 | } 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /contracts/interfaces/IZone.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | 3 | contract IZone { 4 | function dth() view public returns(address); 5 | function geohash() view public returns(bytes6); 6 | function currentAuctionId() view public returns(uint256); 7 | function auctionBids(uint256, address) view public returns(uint256); 8 | function withdrawableDth(address) view public returns(uint256); 9 | function teller() view public returns(address); 10 | function zoneFactory() view public returns(address); 11 | function MIN_STAKE() view public returns(uint256); 12 | function country() view public returns(bytes2); 13 | function geo() view public returns(address); 14 | function withdrawableEth(address) view public returns(uint256); 15 | // function init(bytes2 _countryCode, bytes6 _geohash, address _zoneOwner, uint256 _dthAmount, address _dth, address _geo, address _zoneFactory, address _taxCollector, address _teller) external; 16 | function init(bytes2 _countryCode, bytes6 _geohash, address _zoneOwner, uint256 _dthAmount, address _dth, address _zoneFactory, address _taxCollector, address _teller) external; 17 | function connectToTellerContract(address _teller) external; 18 | function ownerAddr() view external returns(address); 19 | function computeCSC(bytes6 _geohash, address _addr) pure public returns(bytes12); 20 | function calcHarbergerTax(uint256 _startTime, uint256 _endTime, uint256 _dthAmount) view public returns(uint256 taxAmount, uint256 keepAmount); 21 | function calcEntryFee(uint256 _value) view public returns(uint256 burnAmount, uint256 bidAmount); 22 | function auctionExists(uint256 _auctionId) view external returns(bool); 23 | function getZoneOwner() view external returns(address, uint256, uint256, uint256, uint256, uint256); 24 | function getAuction(uint256 _auctionId) view public returns(uint256, uint256, uint256, uint256, address, uint256); 25 | function getLastAuction() view external returns(uint256, uint256, uint256, uint256, address, uint256); 26 | function processState() external; 27 | function tokenFallback(address _from, uint256 _value, bytes memory _data) public; 28 | function release() external; 29 | function withdrawFromAuction(uint256 _auctionId) external; 30 | function withdrawFromAuctions(uint256[] calldata _auctionIds) external; 31 | function withdrawDth() external; 32 | function proxyUpdateUserDailySold(address _to, uint256 _amount) external; 33 | } 34 | -------------------------------------------------------------------------------- /data/trees_countries/AL.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "r": { 4 | "q": { 5 | "j": {}, 6 | "1": {}, 7 | "3": {}, 8 | "0": {}, 9 | "q": {}, 10 | "m": {}, 11 | "h": {}, 12 | "r": {}, 13 | "5": {}, 14 | "n": {}, 15 | "k": {}, 16 | "p": {}, 17 | "2": {}, 18 | "7": {}, 19 | "6": {}, 20 | "4": {}, 21 | "8": {}, 22 | "t": {}, 23 | "d": {}, 24 | "x": {}, 25 | "e": {}, 26 | "b": {}, 27 | "9": {}, 28 | "s": {}, 29 | "w": {} 30 | }, 31 | "n": { 32 | "n": {}, 33 | "j": {}, 34 | "p": {}, 35 | "x": {}, 36 | "w": {}, 37 | "m": {}, 38 | "q": {}, 39 | "k": {}, 40 | "r": {}, 41 | "h": {}, 42 | "t": {}, 43 | "y": {}, 44 | "s": {}, 45 | "5": {}, 46 | "v": {}, 47 | "z": {}, 48 | "4": {}, 49 | "d": {}, 50 | "7": {}, 51 | "e": {}, 52 | "3": {}, 53 | "6": {}, 54 | "1": {} 55 | }, 56 | "w": { 57 | "0": {}, 58 | "6": {}, 59 | "3": {}, 60 | "1": {}, 61 | "8": {}, 62 | "4": {}, 63 | "2": {} 64 | }, 65 | "t": { 66 | "c": {}, 67 | "b": {}, 68 | "8": {}, 69 | "f": {} 70 | }, 71 | "j": { 72 | "y": {}, 73 | "t": {}, 74 | "w": {}, 75 | "z": {}, 76 | "u": {}, 77 | "x": {}, 78 | "v": {} 79 | }, 80 | "m": { 81 | "f": {}, 82 | "c": {}, 83 | "u": {}, 84 | "g": {}, 85 | "b": {}, 86 | "z": {}, 87 | "x": {}, 88 | "v": {}, 89 | "y": {} 90 | } 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /data/trees_countries/NC.json: -------------------------------------------------------------------------------- 1 | { 2 | "r": { 3 | "s": { 4 | "m": { 5 | "2": {}, 6 | "1": {}, 7 | "0": {}, 8 | "4": {}, 9 | "3": {}, 10 | "8": {}, 11 | "6": {}, 12 | "9": {}, 13 | "h": {}, 14 | "5": {} 15 | }, 16 | "j": { 17 | "w": {}, 18 | "v": {}, 19 | "p": {}, 20 | "g": {}, 21 | "s": {}, 22 | "r": {}, 23 | "q": {}, 24 | "u": {}, 25 | "m": {}, 26 | "z": {}, 27 | "x": {}, 28 | "t": {}, 29 | "y": {} 30 | }, 31 | "n": { 32 | "c": {}, 33 | "z": {}, 34 | "8": {}, 35 | "6": {}, 36 | "5": {}, 37 | "e": {}, 38 | "4": {}, 39 | "h": {}, 40 | "b": {}, 41 | "j": {}, 42 | "k": {}, 43 | "n": {}, 44 | "3": {}, 45 | "1": {}, 46 | "d": {}, 47 | "9": {}, 48 | "7": {} 49 | }, 50 | "q": { 51 | "e": {}, 52 | "k": {}, 53 | "c": {}, 54 | "b": {}, 55 | "f": {}, 56 | "7": {}, 57 | "6": {} 58 | }, 59 | "s": { 60 | "2": {} 61 | }, 62 | "k": { 63 | "f": {}, 64 | "w": {}, 65 | "v": {}, 66 | "c": {}, 67 | "t": {}, 68 | "r": {}, 69 | "s": {}, 70 | "g": {}, 71 | "u": {}, 72 | "e": {} 73 | }, 74 | "p": { 75 | "s": {}, 76 | "q": {}, 77 | "p": {}, 78 | "m": {}, 79 | "w": {}, 80 | "t": {}, 81 | "k": {} 82 | }, 83 | "r": { 84 | "0": {} 85 | } 86 | }, 87 | "u": { 88 | "1": { 89 | "b": {} 90 | } 91 | }, 92 | "e": { 93 | "z": { 94 | "p": {} 95 | } 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /data/trees_countries/GW.json: -------------------------------------------------------------------------------- 1 | { 2 | "e": { 3 | "d": { 4 | "j": { 5 | "u": {}, 6 | "m": {}, 7 | "v": {}, 8 | "w": {}, 9 | "e": {}, 10 | "g": {}, 11 | "z": {}, 12 | "s": {}, 13 | "r": {}, 14 | "x": {}, 15 | "t": {}, 16 | "d": {}, 17 | "j": {}, 18 | "n": {}, 19 | "y": {}, 20 | "q": {}, 21 | "6": {}, 22 | "0": {}, 23 | "5": {}, 24 | "1": {}, 25 | "p": {}, 26 | "9": {}, 27 | "7": {}, 28 | "2": {}, 29 | "4": {}, 30 | "c": {}, 31 | "8": {}, 32 | "h": {}, 33 | "f": {}, 34 | "k": {}, 35 | "3": {} 36 | }, 37 | "n": { 38 | "n": {}, 39 | "4": {}, 40 | "q": {}, 41 | "r": {}, 42 | "p": {}, 43 | "h": {}, 44 | "j": {}, 45 | "5": {}, 46 | "m": {} 47 | }, 48 | "h": { 49 | "v": {}, 50 | "z": {}, 51 | "9": {}, 52 | "g": {}, 53 | "w": {}, 54 | "2": {}, 55 | "n": {}, 56 | "q": {}, 57 | "s": {}, 58 | "c": {}, 59 | "b": {}, 60 | "m": {}, 61 | "d": {}, 62 | "8": {}, 63 | "7": {}, 64 | "3": {}, 65 | "u": {}, 66 | "j": {}, 67 | "t": {}, 68 | "y": {}, 69 | "f": {}, 70 | "k": {}, 71 | "e": {} 72 | }, 73 | "m": { 74 | "2": {}, 75 | "8": {}, 76 | "b": {}, 77 | "0": {} 78 | }, 79 | "q": { 80 | "0": {} 81 | } 82 | }, 83 | "9": { 84 | "u": { 85 | "z": {}, 86 | "w": {}, 87 | "r": {}, 88 | "x": {}, 89 | "q": {} 90 | }, 91 | "v": { 92 | "r": {}, 93 | "p": {}, 94 | "n": {}, 95 | "q": {} 96 | } 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | I'm really glad you're reading this, because we need volunteer developers to help this project come to fruition. 4 | 5 | If you haven't already, come find us in Slack ([Dether Slack](https://dether.slack.com). We want you working on things you're excited about. 6 | 7 | Here are some important resources: 8 | 9 | * [Dether Slack](https://slack.dether.io). We're usually there during business hours. 10 | * [SubReddit](https://www.reddit.com/r/Dether/) 11 | * [Telegram](http://t.me/Dether_io) 12 | * [Medium blog](https://medium.com/@DETHER) is where we explain our project and do announcements 13 | * [Twitter](https://twitter.com/dether_io) to follow us 14 | * [Facebook](https://www.facebook.com/dether.io/) to follow us 15 | * Mailing list: Join our [mailing list](https://dether.us16.list-manage.com/subscribe/post?u=dd727296ebfd8ba845b23f156&id=f11fdb74cb) 16 | * Non critical Bug? [Github issue](https://github.com/dethertech/dethercontracts/issues) is where to report them 17 | * Critical Bug? [Private email](bug@dether.io) is where to report them 18 | 19 | ## Testing 20 | 21 | We are testing the smart contracts with Javascript in async/await style, and the Truffle framework to run them. Please write test examples for new code you create. 22 | 23 | ## Submitting changes 24 | 25 | Please send a [GitHub Pull Request to Dether](https://github.com/dethertech/dethercontracts/pulls) with a clear list of what you've done (read more about [pull requests](http://help.github.com/pull-requests/)). When you send a pull request, we will love you forever if you include tests. We can always use more test coverage. Please follow our coding conventions (below) and make sure all of your commits are atomic (one feature per commit). 26 | 27 | 28 | ### Commit guidelines 29 | 30 | ``` 31 | git checkout -b feature/... 32 | git checkout -b fix/... 33 | ``` 34 | 35 | ``` 36 | [ADD] new file/function/feature 37 | [UPD] update file/function/feature 38 | [UPG] upgrade dependency 39 | [ARC] refactor part of the project 40 | [DEL] remove file/function/feature 41 | [WIP] work in progress 42 | ``` 43 | 44 | ``` 45 | git checkout develop 46 | git merge origin feature/... 47 | git merge origin fix/... 48 | ``` 49 | 50 | Always write a clear log message for your commits. One-line messages are fine for small changes, but bigger changes should look like this: 51 | 52 | $ git commit -m “[???] A brief summary of the commit 53 | > 54 | > A paragraph describing what changed and its impact.” 55 | 56 | 57 | 58 | ## Coding conventions 59 | 60 | Start reading our code and you'll get the hang of it. We optimize for readability: 61 | 62 | * We indent using two spaces (soft tabs) 63 | * We use async/await for tests 64 | -------------------------------------------------------------------------------- /scripts/openZone.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const Papa = require('papaparse'); 3 | const GeoRegistry = artifacts.require('GeoRegistry'); 4 | const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); 5 | const { addCountry } = require('../test/utils/geo'); 6 | const BATCH_SIZE = 300; 7 | // require message sender is certifer, CSO, ADD ENOUGH DTH 8 | const cmo = '0x1ecb59E6EAb86eCdE351229e64E47dD6B65b9329' 9 | 10 | 11 | const toNBytes = (str, n) => { 12 | let buffer = ''; 13 | for (let i = 0; i < n; i += 1) { 14 | buffer += str[i] ? str[i].charCodeAt(0).toString(16) : '00'; 15 | } 16 | return buffer; 17 | }; 18 | let tsx; 19 | 20 | 21 | module.exports = async (callback) => { 22 | 23 | const geoRegistryInstance = await GeoRegistry.deployed(); 24 | console.log('address geoRegistryInstance => ', geoRegistryInstance.address); 25 | 26 | 27 | 28 | // const factory = async (noncestart, noncetsx, country) => { 29 | 30 | // console.log('factory', noncestart, noncetsx, noncetsx - noncestart); 31 | // await delay(5000); 32 | // console.log('hello') 33 | // // setTimeout(async () => { 34 | // // console.log('factory', country, toNBytes(country, 2)); 35 | // // try { 36 | // // // tsx = geoRegistryInstance.enableCountry(toNBytes(country, 2)) 37 | 38 | // // // console.log('tsx', tsx); 39 | // // } catch (e) { 40 | // // console.log('err', e); 41 | // // } 42 | // // }, (noncetsx - noncestart) * 1500); 43 | // }; 44 | 45 | const Web3 = require('web3'); 46 | const web3 = new Web3('https://kovan.infura.io/v3/f19f6c9d405a460f91964949efe0e78e'); 47 | 48 | const csv = fs.readFileSync('./openedCountry.csv', 'utf8'); 49 | const { data } = Papa.parse(csv, { 50 | header: true, 51 | }); 52 | 53 | console.log('Performing whitelisting operations'); 54 | 55 | 56 | const nonce = 1180; 57 | let counter = 10; 58 | console.log('data lenght', data.length); 59 | 60 | data.forEach(async (countryCode) => { 61 | 62 | console.log('add country =>', countryCode, toNBytes(country, 2)); 63 | // await geoRegistryInstance.enableCountry(toNBytes(country, 2)) 64 | // const { countryGasCost, mostExpensiveTrxGasCost, txCount, countryMap } = await addCountry(owner, web3, geoRegistryInstance, countryCode, BATCH_SIZE); 65 | // for (const key in countryMap) { 66 | // await geoRegistryContract.level_2(web3.utils.asciiToHex(countryCode), web3.utils.asciiToHex(key)); 67 | // // assert.deepStrictEqual(onchainContent, countryMap[key], `content for key ${key} does not match expected`); 68 | // } 69 | }) 70 | 71 | // for (let i = 0; i < data.length; i++) { 72 | // const { COUNTRY } = data[i]; 73 | // if (i < counter) { 74 | 75 | // factory(nonce, nonce + i + 1, COUNTRY); 76 | 77 | // } 78 | // } 79 | 80 | 81 | callback(); 82 | } 83 | -------------------------------------------------------------------------------- /data/trees_countries/BT.json: -------------------------------------------------------------------------------- 1 | { 2 | "w": { 3 | "h": { 4 | "b": { 5 | "s": {}, 6 | "u": {}, 7 | "c": {}, 8 | "5": {}, 9 | "p": {}, 10 | "f": {}, 11 | "k": {}, 12 | "d": {}, 13 | "j": {}, 14 | "n": {}, 15 | "v": {}, 16 | "q": {}, 17 | "w": {}, 18 | "9": {}, 19 | "e": {}, 20 | "y": {}, 21 | "4": {}, 22 | "g": {}, 23 | "7": {}, 24 | "6": {}, 25 | "m": {}, 26 | "h": {}, 27 | "t": {}, 28 | "r": {}, 29 | "3": {}, 30 | "x": {}, 31 | "0": {}, 32 | "8": {}, 33 | "z": {}, 34 | "1": {}, 35 | "2": {}, 36 | "b": {} 37 | }, 38 | "c": { 39 | "1": {}, 40 | "4": {}, 41 | "h": {}, 42 | "3": {}, 43 | "7": {}, 44 | "0": {}, 45 | "n": {}, 46 | "j": {}, 47 | "p": {}, 48 | "2": {}, 49 | "5": {}, 50 | "k": {}, 51 | "6": {} 52 | } 53 | }, 54 | "j": { 55 | "0": { 56 | "1": {}, 57 | "2": {}, 58 | "0": {} 59 | } 60 | } 61 | }, 62 | "t": { 63 | "u": { 64 | "z": { 65 | "t": {}, 66 | "z": {}, 67 | "6": {}, 68 | "v": {}, 69 | "d": {}, 70 | "y": {}, 71 | "g": {}, 72 | "9": {}, 73 | "e": {}, 74 | "s": {}, 75 | "c": {}, 76 | "u": {}, 77 | "f": {}, 78 | "k": {}, 79 | "4": {}, 80 | "8": {}, 81 | "1": {}, 82 | "7": {}, 83 | "2": {}, 84 | "x": {}, 85 | "m": {}, 86 | "5": {}, 87 | "w": {}, 88 | "3": {}, 89 | "b": {}, 90 | "q": {} 91 | }, 92 | "x": { 93 | "z": {}, 94 | "x": {} 95 | } 96 | }, 97 | "v": { 98 | "p": { 99 | "b": {}, 100 | "8": {}, 101 | "c": {} 102 | } 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /data/trees_countries/AM.json: -------------------------------------------------------------------------------- 1 | { 2 | "t": { 3 | "p": { 4 | "2": { 5 | "0": {}, 6 | "3": {}, 7 | "2": {}, 8 | "1": {}, 9 | "4": {} 10 | }, 11 | "0": { 12 | "5": {}, 13 | "h": {}, 14 | "p": {}, 15 | "j": {}, 16 | "6": {}, 17 | "n": {}, 18 | "k": {}, 19 | "8": {}, 20 | "4": {}, 21 | "d": {}, 22 | "3": {}, 23 | "9": {}, 24 | "b": {}, 25 | "0": {}, 26 | "s": {}, 27 | "m": {}, 28 | "t": {}, 29 | "e": {}, 30 | "1": {}, 31 | "c": {}, 32 | "r": {}, 33 | "7": {}, 34 | "2": {}, 35 | "q": {} 36 | }, 37 | "1": { 38 | "1": {}, 39 | "0": {} 40 | } 41 | }, 42 | "n": { 43 | "c": { 44 | "p": {}, 45 | "n": {}, 46 | "j": {} 47 | }, 48 | "b": { 49 | "y": {}, 50 | "w": {}, 51 | "z": {}, 52 | "t": {}, 53 | "v": {}, 54 | "x": {} 55 | } 56 | } 57 | }, 58 | "s": { 59 | "z": { 60 | "r": { 61 | "9": {}, 62 | "b": {}, 63 | "2": {}, 64 | "3": {}, 65 | "8": {}, 66 | "c": {}, 67 | "1": {}, 68 | "d": {}, 69 | "6": {}, 70 | "4": {}, 71 | "0": {}, 72 | "f": {} 73 | }, 74 | "p": { 75 | "v": {}, 76 | "u": {}, 77 | "r": {}, 78 | "g": {}, 79 | "y": {}, 80 | "t": {}, 81 | "k": {}, 82 | "z": {}, 83 | "q": {}, 84 | "x": {}, 85 | "s": {}, 86 | "w": {}, 87 | "m": {}, 88 | "p": {}, 89 | "f": {}, 90 | "7": {}, 91 | "5": {}, 92 | "c": {}, 93 | "n": {}, 94 | "d": {}, 95 | "e": {}, 96 | "h": {}, 97 | "j": {} 98 | }, 99 | "n": { 100 | "y": {} 101 | }, 102 | "q": { 103 | "c": {} 104 | } 105 | } 106 | } 107 | } -------------------------------------------------------------------------------- /data/trees_countries/MV.json: -------------------------------------------------------------------------------- 1 | { 2 | "t": { 3 | "8": { 4 | "u": { 5 | "m": {}, 6 | "6": {}, 7 | "1": {}, 8 | "j": {}, 9 | "r": {}, 10 | "p": {}, 11 | "q": {}, 12 | "h": {}, 13 | "3": {}, 14 | "2": {}, 15 | "4": {}, 16 | "n": {} 17 | }, 18 | "s": { 19 | "q": {}, 20 | "p": {}, 21 | "j": {}, 22 | "3": {}, 23 | "2": {}, 24 | "r": {}, 25 | "7": {}, 26 | "0": {}, 27 | "n": {} 28 | }, 29 | "7": { 30 | "u": {}, 31 | "z": {}, 32 | "v": {} 33 | }, 34 | "g": { 35 | "b": {}, 36 | "g": {}, 37 | "c": {}, 38 | "u": {}, 39 | "y": {}, 40 | "z": {}, 41 | "v": {} 42 | }, 43 | "h": { 44 | "1": {}, 45 | "6": {}, 46 | "h": {}, 47 | "5": {} 48 | }, 49 | "k": { 50 | "j": {}, 51 | "p": {}, 52 | "7": {}, 53 | "4": {}, 54 | "5": {}, 55 | "n": {}, 56 | "6": {}, 57 | "k": {} 58 | }, 59 | "5": { 60 | "f": {}, 61 | "c": {} 62 | }, 63 | "e": { 64 | "w": {}, 65 | "b": {}, 66 | "t": {}, 67 | "v": {}, 68 | "c": {}, 69 | "f": {}, 70 | "u": {}, 71 | "g": {} 72 | } 73 | }, 74 | "9": { 75 | "5": { 76 | "c": {}, 77 | "v": {}, 78 | "g": {}, 79 | "u": {}, 80 | "s": {}, 81 | "f": {}, 82 | "z": {}, 83 | "y": {}, 84 | "b": {} 85 | }, 86 | "h": { 87 | "4": {}, 88 | "1": {}, 89 | "5": {}, 90 | "h": {}, 91 | "n": {}, 92 | "p": {}, 93 | "0": {} 94 | }, 95 | "7": { 96 | "b": {} 97 | } 98 | } 99 | }, 100 | "m": { 101 | "x": { 102 | "g": { 103 | "u": {} 104 | }, 105 | "u": { 106 | "h": {}, 107 | "n": {} 108 | } 109 | } 110 | } 111 | } -------------------------------------------------------------------------------- /contracts/kleros/IArbitrable.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * @title IArbitrable 3 | * @author Enrique Piqueras - 4 | * Bug Bounties: This code hasn't undertaken a bug bounty program yet. 5 | */ 6 | 7 | pragma solidity ^0.5.10; 8 | 9 | import "./Arbitrator.sol"; 10 | 11 | /** @title IArbitrable 12 | * Arbitrable interface. 13 | * When developing arbitrable contracts, we need to: 14 | * -Define the action taken when a ruling is received by the contract. We should do so in executeRuling. 15 | * -Allow dispute creation. For this a function must: 16 | * -Call arbitrator.createDispute.value(_fee)(_choices,_extraData); 17 | * -Create the event Dispute(_arbitrator,_disputeID,_rulingOptions); 18 | */ 19 | contract IArbitrable { 20 | /** @dev To be emmited when meta-evidence is submitted. 21 | * @param _metaEvidenceID Unique identifier of meta-evidence. 22 | * @param _evidence A link to the meta-evidence JSON. 23 | */ 24 | event MetaEvidence(uint indexed _metaEvidenceID, string _evidence); 25 | 26 | /** @dev To be emmited when a dispute is created to link the correct meta-evidence to the disputeID 27 | * @param _arbitrator The arbitrator of the contract. 28 | * @param _disputeID ID of the dispute in the Arbitrator contract. 29 | * @param _metaEvidenceID Unique identifier of meta-evidence. 30 | */ 31 | event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID); 32 | 33 | /** @dev To be raised when evidence are submitted. Should point to the ressource (evidences are not to be stored on chain due to gas considerations). 34 | * @param _arbitrator The arbitrator of the contract. 35 | * @param _disputeID ID of the dispute in the Arbitrator contract. 36 | * @param _party The address of the party submiting the evidence. Note that 0x0 refers to evidence not submitted by any party. 37 | * @param _evidence A URI to the evidence JSON file whose name should be its keccak256 hash followed by .json. 38 | */ 39 | event Evidence(Arbitrator indexed _arbitrator, uint indexed _disputeID, address indexed _party, string _evidence); 40 | 41 | /** @dev To be raised when a ruling is given. 42 | * @param _arbitrator The arbitrator giving the ruling. 43 | * @param _disputeID ID of the dispute in the Arbitrator contract. 44 | * @param _ruling The ruling which was given. 45 | */ 46 | event Ruling(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _ruling); 47 | 48 | /** @dev Give a ruling for a dispute. Must be called by the arbitrator. 49 | * The purpose of this function is to ensure that the address calling it has the right to rule on the contract. 50 | * @param _disputeID ID of the dispute in the Arbitrator contract. 51 | * @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision". 52 | */ 53 | function rule(uint _disputeID, uint _ruling) public; 54 | } 55 | -------------------------------------------------------------------------------- /data/trees_countries/TW.json: -------------------------------------------------------------------------------- 1 | { 2 | "w": { 3 | "s": { 4 | "j": { 5 | "e": {}, 6 | "y": {}, 7 | "t": {}, 8 | "f": {}, 9 | "c": {}, 10 | "v": {}, 11 | "b": {}, 12 | "w": {}, 13 | "d": {}, 14 | "s": {}, 15 | "z": {}, 16 | "u": {}, 17 | "g": {}, 18 | "3": {}, 19 | "j": {}, 20 | "m": {}, 21 | "n": {}, 22 | "k": {}, 23 | "6": {}, 24 | "x": {}, 25 | "7": {}, 26 | "8": {}, 27 | "q": {}, 28 | "9": {}, 29 | "r": {} 30 | }, 31 | "q": { 32 | "1": {}, 33 | "7": {}, 34 | "h": {}, 35 | "m": {}, 36 | "k": {}, 37 | "0": {}, 38 | "6": {}, 39 | "5": {}, 40 | "4": {}, 41 | "3": {}, 42 | "w": {}, 43 | "j": {}, 44 | "d": {}, 45 | "s": {}, 46 | "2": {}, 47 | "t": {}, 48 | "n": {}, 49 | "q": {}, 50 | "e": {}, 51 | "9": {}, 52 | "r": {}, 53 | "y": {}, 54 | "x": {} 55 | }, 56 | "m": { 57 | "b": {}, 58 | "c": {}, 59 | "d": {}, 60 | "g": {}, 61 | "9": {}, 62 | "u": {}, 63 | "8": {}, 64 | "f": {}, 65 | "v": {} 66 | }, 67 | "n": { 68 | "p": {}, 69 | "n": {}, 70 | "h": {}, 71 | "5": {}, 72 | "j": {}, 73 | "1": {}, 74 | "r": {}, 75 | "q": {}, 76 | "4": {}, 77 | "2": {}, 78 | "0": {}, 79 | "m": {}, 80 | "6": {}, 81 | "k": {}, 82 | "7": {}, 83 | "3": {} 84 | }, 85 | "k": { 86 | "4": {}, 87 | "5": {} 88 | }, 89 | "h": { 90 | "v": {}, 91 | "y": {} 92 | } 93 | }, 94 | "e": { 95 | "y": { 96 | "p": {}, 97 | "m": {} 98 | }, 99 | "v": { 100 | "x": {}, 101 | "y": {}, 102 | "u": {}, 103 | "z": {}, 104 | "v": {} 105 | } 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /data/trees_countries/KI.json: -------------------------------------------------------------------------------- 1 | { 2 | "x": { 3 | "b": { 4 | "5": { 5 | "2": {}, 6 | "j": {}, 7 | "3": {}, 8 | "h": {}, 9 | "p": {}, 10 | "d": {} 11 | }, 12 | "6": { 13 | "g": {}, 14 | "b": {}, 15 | "f": {}, 16 | "c": {} 17 | }, 18 | "e": { 19 | "1": {} 20 | }, 21 | "7": { 22 | "1": {}, 23 | "4": {}, 24 | "0": {}, 25 | "5": {} 26 | }, 27 | "d": { 28 | "c": {} 29 | } 30 | } 31 | }, 32 | "8": { 33 | "2": { 34 | "w": { 35 | "t": {}, 36 | "w": {}, 37 | "v": {} 38 | }, 39 | "v": { 40 | "f": {} 41 | }, 42 | "r": { 43 | "f": {}, 44 | "g": {} 45 | } 46 | }, 47 | "8": { 48 | "2": { 49 | "5": {}, 50 | "1": {}, 51 | "4": {} 52 | } 53 | } 54 | }, 55 | "r": { 56 | "z": { 57 | "u": { 58 | "5": {}, 59 | "3": {}, 60 | "h": {}, 61 | "2": {}, 62 | "1": {} 63 | }, 64 | "s": { 65 | "v": {}, 66 | "r": {} 67 | }, 68 | "v": { 69 | "2": {}, 70 | "0": {} 71 | }, 72 | "b": { 73 | "e": {} 74 | }, 75 | "t": { 76 | "r": {}, 77 | "b": {}, 78 | "9": {}, 79 | "1": {}, 80 | "c": {}, 81 | "8": {} 82 | } 83 | } 84 | }, 85 | "2": { 86 | "p": { 87 | "q": { 88 | "q": {} 89 | }, 90 | "t": { 91 | "b": {} 92 | }, 93 | "m": { 94 | "z": {} 95 | }, 96 | "n": { 97 | "n": {} 98 | }, 99 | "j": { 100 | "w": {} 101 | }, 102 | "5": { 103 | "v": {} 104 | } 105 | }, 106 | "x": { 107 | "1": { 108 | "0": {} 109 | }, 110 | "3": { 111 | "c": {}, 112 | "b": {} 113 | } 114 | }, 115 | "t": { 116 | "u": { 117 | "n": {}, 118 | "p": {} 119 | } 120 | }, 121 | "w": { 122 | "c": { 123 | "p": {} 124 | } 125 | } 126 | } 127 | } -------------------------------------------------------------------------------- /data/trees_countries/BE.json: -------------------------------------------------------------------------------- 1 | { 2 | "u": { 3 | "1": { 4 | "5": { 5 | "3": {}, 6 | "f": {}, 7 | "d": {}, 8 | "1": {}, 9 | "4": {}, 10 | "9": {}, 11 | "2": {}, 12 | "0": {}, 13 | "b": {}, 14 | "8": {}, 15 | "6": {}, 16 | "7": {}, 17 | "5": {}, 18 | "e": {}, 19 | "h": {}, 20 | "c": {}, 21 | "s": {}, 22 | "k": {}, 23 | "g": {} 24 | }, 25 | "4": { 26 | "6": {}, 27 | "c": {}, 28 | "d": {}, 29 | "3": {}, 30 | "1": {}, 31 | "f": {}, 32 | "b": {}, 33 | "8": {}, 34 | "9": {}, 35 | "4": {}, 36 | "e": {}, 37 | "7": {}, 38 | "g": {}, 39 | "0": {}, 40 | "h": {}, 41 | "2": {}, 42 | "5": {}, 43 | "u": {}, 44 | "k": {} 45 | }, 46 | "1": { 47 | "c": {}, 48 | "b": {}, 49 | "g": {}, 50 | "f": {} 51 | }, 52 | "h": { 53 | "5": {}, 54 | "0": {}, 55 | "4": {}, 56 | "2": {}, 57 | "1": {} 58 | } 59 | }, 60 | "0": { 61 | "g": { 62 | "x": {}, 63 | "p": {}, 64 | "r": {}, 65 | "q": {}, 66 | "s": {}, 67 | "g": {}, 68 | "w": {}, 69 | "v": {}, 70 | "u": {}, 71 | "y": {}, 72 | "z": {}, 73 | "n": {}, 74 | "t": {}, 75 | "j": {}, 76 | "c": {}, 77 | "k": {}, 78 | "d": {}, 79 | "h": {}, 80 | "7": {}, 81 | "m": {}, 82 | "e": {}, 83 | "f": {} 84 | }, 85 | "u": { 86 | "n": {}, 87 | "p": {}, 88 | "h": {}, 89 | "m": {}, 90 | "1": {}, 91 | "5": {}, 92 | "j": {}, 93 | "q": {}, 94 | "x": {}, 95 | "r": {}, 96 | "w": {}, 97 | "4": {} 98 | }, 99 | "f": { 100 | "z": {}, 101 | "v": {}, 102 | "u": {}, 103 | "r": {}, 104 | "w": {}, 105 | "y": {}, 106 | "x": {} 107 | } 108 | } 109 | } 110 | } -------------------------------------------------------------------------------- /data/trees_countries/VU.json: -------------------------------------------------------------------------------- 1 | { 2 | "r": { 3 | "s": { 4 | "z": { 5 | "y": {}, 6 | "x": {}, 7 | "f": {}, 8 | "e": {}, 9 | "s": {}, 10 | "w": {}, 11 | "z": {}, 12 | "d": {}, 13 | "u": {}, 14 | "g": {} 15 | } 16 | }, 17 | "t": { 18 | "w": { 19 | "m": {}, 20 | "f": {}, 21 | "g": {}, 22 | "k": {}, 23 | "s": {}, 24 | "e": {} 25 | }, 26 | "r": { 27 | "d": {}, 28 | "2": {}, 29 | "n": {}, 30 | "9": {}, 31 | "8": {}, 32 | "0": {}, 33 | "e": {}, 34 | "p": {}, 35 | "3": {} 36 | }, 37 | "q": { 38 | "c": {}, 39 | "b": {}, 40 | "k": {}, 41 | "2": {}, 42 | "e": {}, 43 | "s": {}, 44 | "d": {}, 45 | "3": {}, 46 | "9": {}, 47 | "g": {}, 48 | "8": {}, 49 | "f": {}, 50 | "7": {}, 51 | "6": {} 52 | }, 53 | "n": { 54 | "z": {}, 55 | "u": {}, 56 | "y": {}, 57 | "w": {}, 58 | "v": {}, 59 | "x": {} 60 | }, 61 | "p": { 62 | "j": {}, 63 | "t": {}, 64 | "7": {}, 65 | "8": {}, 66 | "b": {}, 67 | "x": {}, 68 | "w": {}, 69 | "h": {}, 70 | "r": {}, 71 | "4": {}, 72 | "9": {}, 73 | "6": {}, 74 | "p": {}, 75 | "1": {}, 76 | "s": {}, 77 | "3": {}, 78 | "e": {}, 79 | "d": {}, 80 | "5": {} 81 | }, 82 | "x": { 83 | "5": {}, 84 | "4": {}, 85 | "6": {}, 86 | "1": {}, 87 | "0": {} 88 | } 89 | }, 90 | "u": { 91 | "2": { 92 | "u": {}, 93 | "s": {}, 94 | "t": {}, 95 | "v": {} 96 | }, 97 | "8": { 98 | "m": {}, 99 | "k": {}, 100 | "8": {}, 101 | "7": {}, 102 | "q": {}, 103 | "6": {}, 104 | "n": {}, 105 | "9": {}, 106 | "3": {}, 107 | "j": {}, 108 | "h": {}, 109 | "2": {} 110 | } 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /data/trees_countries/pbcopy: -------------------------------------------------------------------------------- 1 | AD.json 2 | AE.json 3 | AF.json 4 | AG.json 5 | AI.json 6 | AL.json 7 | AM.json 8 | AO.json 9 | AR.json 10 | AS.json 11 | AT.json 12 | AU.json 13 | AW.json 14 | AX.json 15 | AZ.json 16 | BA.json 17 | BB.json 18 | BD.json 19 | BE.json 20 | BF.json 21 | BG.json 22 | BH.json 23 | BI.json 24 | BJ.json 25 | BL.json 26 | BM.json 27 | BN.json 28 | BO.json 29 | BR.json 30 | BS.json 31 | BT.json 32 | BW.json 33 | BY.json 34 | BZ.json 35 | CA.json 36 | CD.json 37 | CF.json 38 | CG.json 39 | CH.json 40 | CI.json 41 | CK.json 42 | CL.json 43 | CM.json 44 | CN.json 45 | CO.json 46 | CR.json 47 | CU.json 48 | CV.json 49 | CW.json 50 | CY.json 51 | CZ.json 52 | DE.json 53 | DJ.json 54 | DK.json 55 | DM.json 56 | DO.json 57 | DZ.json 58 | EC.json 59 | EE.json 60 | EG.json 61 | EH.json 62 | ER.json 63 | ES.json 64 | ET.json 65 | FI.json 66 | FJ.json 67 | FK.json 68 | FM.json 69 | FO.json 70 | GA.json 71 | GB.json 72 | GD.json 73 | GE.json 74 | GG.json 75 | GH.json 76 | GI.json 77 | GL.json 78 | GM.json 79 | GN.json 80 | GQ.json 81 | GR.json 82 | GS.json 83 | GT.json 84 | GU.json 85 | GW.json 86 | GY.json 87 | HK.json 88 | HM.json 89 | HN.json 90 | HR.json 91 | HT.json 92 | HU.json 93 | ID.json 94 | IE.json 95 | IL.json 96 | IM.json 97 | IN.json 98 | IO.json 99 | IQ.json 100 | IR.json 101 | IS.json 102 | IT.json 103 | JE.json 104 | JM.json 105 | JO.json 106 | JP.json 107 | KE.json 108 | KG.json 109 | KH.json 110 | KI.json 111 | KM.json 112 | KN.json 113 | KP.json 114 | KR.json 115 | KW.json 116 | KY.json 117 | KZ.json 118 | LA.json 119 | LB.json 120 | LC.json 121 | LI.json 122 | LK.json 123 | LR.json 124 | LS.json 125 | LT.json 126 | LU.json 127 | LV.json 128 | LY.json 129 | MA.json 130 | MC.json 131 | MD.json 132 | ME.json 133 | MF.json 134 | MG.json 135 | MH.json 136 | MK.json 137 | ML.json 138 | MM.json 139 | MN.json 140 | MO.json 141 | MP.json 142 | MR.json 143 | MS.json 144 | MT.json 145 | MU.json 146 | MV.json 147 | MW.json 148 | MX.json 149 | MY.json 150 | MZ.json 151 | NA.json 152 | NC.json 153 | NE.json 154 | NF.json 155 | NG.json 156 | NI.json 157 | NL.json 158 | NP.json 159 | NR.json 160 | NU.json 161 | NZ.json 162 | OM.json 163 | PA.json 164 | PE.json 165 | PF.json 166 | PG.json 167 | PH.json 168 | PK.json 169 | PL.json 170 | PM.json 171 | PN.json 172 | PR.json 173 | PS.json 174 | PT.json 175 | PW.json 176 | PY.json 177 | QA.json 178 | RO.json 179 | RS.json 180 | RU.json 181 | RW.json 182 | SA.json 183 | SB.json 184 | SC.json 185 | SD.json 186 | SE.json 187 | SG.json 188 | SH.json 189 | SI.json 190 | SK.json 191 | SL.json 192 | SM.json 193 | SN.json 194 | SO.json 195 | SR.json 196 | SS.json 197 | ST.json 198 | SV.json 199 | SX.json 200 | SY.json 201 | SZ.json 202 | TC.json 203 | TD.json 204 | TF.json 205 | TG.json 206 | TH.json 207 | TJ.json 208 | TL.json 209 | TM.json 210 | TN.json 211 | TO.json 212 | TR.json 213 | TT.json 214 | TV.json 215 | TW.json 216 | TZ.json 217 | UA.json 218 | UG.json 219 | UM.json 220 | US.json 221 | UY.json 222 | UZ.json 223 | VA.json 224 | VC.json 225 | VE.json 226 | VG.json 227 | VI.json 228 | VN.json 229 | VU.json 230 | WF.json 231 | WS.json 232 | YE.json 233 | ZA.json 234 | ZM.json 235 | ZW.json 236 | -------------------------------------------------------------------------------- /test/utils/values.js: -------------------------------------------------------------------------------- 1 | const BYTES1_ZERO = "0x00"; 2 | const BYTES6_ZERO = "0x000000000000"; 3 | const BYTES7_ZERO = "0x00000000000000"; 4 | const BYTES12_ZERO = "0x000000000000000000000000"; 5 | const BYTES16_ZERO = "0x00000000000000000000000000000000"; 6 | const BYTES32_ZERO = 7 | "0x0000000000000000000000000000000000000000000000000000000000000000"; 8 | const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000"; 9 | const ADDRESS_BURN = "0xffffffffffffffffffffffffffffffffffffffff"; 10 | 11 | const COUNTRY_CG = "CG"; 12 | // const VALID_CG_ZONE_GEOHASH = 'krcztse'; // krcz is in CG 13 | // const INVALID_CG_ZONE_GEOHASH = 'krcttse'; // krct is not in CG 14 | const VALID_CG_ZONE_GEOHASH = "krczts"; // krcz is in CG 15 | const INVALID_CG_ZONE_GEOHASH = "krctts"; // krct is not in CG 16 | const NONEXISTING_CG_ZONE_GEOHASH = "krcats"; // krca, a is not a valid geohash char 17 | const VALID_CG_SHOP_GEOHASH = "krcztseeeeee"; // krcz is in CG 18 | const VALID_CG_SHOP_GEOHASH_2 = "krcztseeceee"; // krcy is alo in CG 19 | const VALID_CG_SHOP_GEOHASH_3 = "krcztseedeee"; // krcy is alo in CG 20 | const VALID_CG_SHOP_GEOHASH_4 = "krcztseedeet"; 21 | const INVALID_CG_SHOP_GEOHASH = "krcatseeeeee"; // krca, a is not a valid geohash char 22 | const NONEXISTING_CG_SHOP_GEOHASH = "krcttseeeeee"; // krct is not in CG 23 | 24 | const CG_SHOP_LICENSE_PRICE = 42; 25 | const MIN_ZONE_DTH_STAKE = 100; 26 | 27 | const ONE_HOUR = 60 * 60; 28 | const ONE_DAY = ONE_HOUR * 24; 29 | const BID_PERIOD = 60 * 8; // 30MIN 30 | const COOLDOWN_PERIOD = 60; // 5MIN 31 | 32 | const KLEROS_ARBITRATION_PRICE = 1; // eth 33 | const KLEROS_DISPUTE_TIMEOUT = 60; // seconds 34 | const KLEROS_ARBITRATOR_EXTRADATA = "0x8575"; 35 | const KLEROS_SHOP_WINS = 1; 36 | const KLEROS_CHALLENGER_WINS = 2; 37 | const KLEROS_NO_RULING = 0; 38 | 39 | const ZONE_AUCTION_STATE_STARTED = "0"; 40 | const ZONE_AUCTION_STATE_ENDED = "1"; 41 | 42 | const TELLER_CG_POSITION = "krcztsebcddd"; 43 | const TELLER_CG_CURRENCY_ID = "1"; 44 | const TELLER_CG_MESSENGER = "my_telegram_nick"; 45 | const TELLER_CG_SELLRATE = "177"; // 1.77% 46 | const TELLER_CG_BUYRATE = "1364"; // 13.64% 47 | const TELLER_CG_SETTINGS = "0x03"; // 0000 0011 <-- both buyer and seller bit set 48 | const TELLER_CG_REFFEE = 21; 49 | 50 | const ONE_WEEK_IN_SEC = 604800; 51 | 52 | module.exports = { 53 | BYTES1_ZERO, 54 | BYTES6_ZERO, 55 | BYTES7_ZERO, 56 | BYTES12_ZERO, 57 | BYTES16_ZERO, 58 | BYTES32_ZERO, 59 | ADDRESS_ZERO, 60 | ADDRESS_BURN, 61 | 62 | COUNTRY_CG, 63 | VALID_CG_ZONE_GEOHASH, 64 | INVALID_CG_ZONE_GEOHASH, 65 | NONEXISTING_CG_ZONE_GEOHASH, 66 | VALID_CG_SHOP_GEOHASH, 67 | VALID_CG_SHOP_GEOHASH_2, 68 | VALID_CG_SHOP_GEOHASH_3, 69 | VALID_CG_SHOP_GEOHASH_4, 70 | INVALID_CG_SHOP_GEOHASH, 71 | NONEXISTING_CG_SHOP_GEOHASH, 72 | 73 | MIN_ZONE_DTH_STAKE, 74 | CG_SHOP_LICENSE_PRICE, 75 | 76 | ONE_HOUR, 77 | ONE_DAY, 78 | BID_PERIOD, 79 | COOLDOWN_PERIOD, 80 | 81 | KLEROS_ARBITRATION_PRICE, 82 | KLEROS_DISPUTE_TIMEOUT, 83 | KLEROS_ARBITRATOR_EXTRADATA, 84 | KLEROS_SHOP_WINS, 85 | KLEROS_CHALLENGER_WINS, 86 | KLEROS_NO_RULING, 87 | 88 | ZONE_AUCTION_STATE_STARTED, 89 | ZONE_AUCTION_STATE_ENDED, 90 | 91 | TELLER_CG_POSITION, 92 | TELLER_CG_CURRENCY_ID, 93 | TELLER_CG_MESSENGER, 94 | TELLER_CG_SELLRATE, 95 | TELLER_CG_BUYRATE, 96 | TELLER_CG_SETTINGS, 97 | TELLER_CG_REFFEE, 98 | 99 | ONE_WEEK_IN_SEC 100 | }; 101 | -------------------------------------------------------------------------------- /data/trees_countries/MD.json: -------------------------------------------------------------------------------- 1 | { 2 | "u": { 3 | "8": { 4 | "k": { 5 | "9": {}, 6 | "f": {}, 7 | "j": {}, 8 | "d": {}, 9 | "q": {}, 10 | "p": {}, 11 | "7": {}, 12 | "3": {}, 13 | "2": {}, 14 | "6": {}, 15 | "s": {}, 16 | "e": {}, 17 | "h": {}, 18 | "r": {}, 19 | "m": {}, 20 | "c": {}, 21 | "n": {}, 22 | "k": {}, 23 | "5": {}, 24 | "1": {}, 25 | "8": {}, 26 | "z": {}, 27 | "w": {}, 28 | "0": {}, 29 | "b": {}, 30 | "v": {}, 31 | "g": {}, 32 | "u": {}, 33 | "x": {}, 34 | "y": {}, 35 | "4": {}, 36 | "t": {} 37 | }, 38 | "e": { 39 | "b": {}, 40 | "9": {}, 41 | "d": {}, 42 | "8": {}, 43 | "6": {}, 44 | "c": {}, 45 | "3": {}, 46 | "7": {}, 47 | "1": {}, 48 | "f": {}, 49 | "2": {}, 50 | "4": {}, 51 | "5": {}, 52 | "e": {}, 53 | "g": {} 54 | }, 55 | "m": { 56 | "1": {}, 57 | "5": {}, 58 | "2": {}, 59 | "3": {}, 60 | "6": {}, 61 | "j": {}, 62 | "4": {}, 63 | "h": {}, 64 | "0": {} 65 | }, 66 | "s": { 67 | "0": {}, 68 | "2": {}, 69 | "b": {}, 70 | "8": {}, 71 | "1": {}, 72 | "9": {}, 73 | "4": {}, 74 | "3": {} 75 | }, 76 | "h": { 77 | "q": {}, 78 | "r": {}, 79 | "p": {}, 80 | "w": {}, 81 | "6": {}, 82 | "4": {}, 83 | "j": {}, 84 | "t": {}, 85 | "5": {}, 86 | "z": {}, 87 | "h": {}, 88 | "7": {}, 89 | "m": {}, 90 | "x": {}, 91 | "k": {}, 92 | "n": {} 93 | }, 94 | "7": { 95 | "y": {}, 96 | "x": {}, 97 | "z": {}, 98 | "v": {}, 99 | "r": {}, 100 | "s": {}, 101 | "q": {}, 102 | "f": {}, 103 | "u": {}, 104 | "w": {}, 105 | "t": {}, 106 | "g": {} 107 | }, 108 | "5": { 109 | "u": {}, 110 | "v": {}, 111 | "g": {}, 112 | "y": {}, 113 | "z": {} 114 | }, 115 | "j": { 116 | "p": {}, 117 | "r": {} 118 | }, 119 | "d": { 120 | "f": {} 121 | } 122 | } 123 | } 124 | } -------------------------------------------------------------------------------- /data/trees_countries/DO.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "7": { 4 | "q": { 5 | "4": {}, 6 | "5": {}, 7 | "d": {}, 8 | "n": {}, 9 | "h": {}, 10 | "9": {}, 11 | "1": {}, 12 | "e": {}, 13 | "j": {}, 14 | "f": {}, 15 | "7": {}, 16 | "c": {}, 17 | "6": {}, 18 | "b": {}, 19 | "m": {}, 20 | "w": {}, 21 | "r": {}, 22 | "t": {}, 23 | "q": {}, 24 | "v": {}, 25 | "p": {}, 26 | "0": {}, 27 | "2": {}, 28 | "k": {}, 29 | "u": {}, 30 | "3": {}, 31 | "g": {}, 32 | "8": {}, 33 | "s": {}, 34 | "y": {} 35 | }, 36 | "m": { 37 | "5": {}, 38 | "r": {}, 39 | "4": {}, 40 | "m": {}, 41 | "x": {}, 42 | "1": {}, 43 | "y": {}, 44 | "9": {}, 45 | "c": {}, 46 | "v": {}, 47 | "f": {}, 48 | "d": {}, 49 | "7": {}, 50 | "u": {}, 51 | "k": {}, 52 | "g": {}, 53 | "6": {}, 54 | "3": {}, 55 | "w": {}, 56 | "e": {}, 57 | "s": {}, 58 | "q": {}, 59 | "t": {}, 60 | "z": {}, 61 | "h": {}, 62 | "p": {}, 63 | "2": {}, 64 | "b": {}, 65 | "0": {}, 66 | "n": {}, 67 | "8": {}, 68 | "j": {} 69 | }, 70 | "r": { 71 | "1": {}, 72 | "h": {}, 73 | "3": {}, 74 | "6": {}, 75 | "2": {}, 76 | "0": {}, 77 | "4": {}, 78 | "5": {} 79 | }, 80 | "j": { 81 | "p": {}, 82 | "j": {}, 83 | "n": {}, 84 | "x": {}, 85 | "k": {}, 86 | "r": {}, 87 | "m": {}, 88 | "q": {}, 89 | "z": {}, 90 | "h": {}, 91 | "5": {} 92 | }, 93 | "n": { 94 | "p": {} 95 | }, 96 | "t": { 97 | "9": {}, 98 | "0": {}, 99 | "3": {}, 100 | "1": {}, 101 | "b": {}, 102 | "8": {}, 103 | "2": {} 104 | }, 105 | "k": { 106 | "f": {}, 107 | "z": {}, 108 | "y": {}, 109 | "u": {}, 110 | "c": {}, 111 | "g": {}, 112 | "b": {}, 113 | "v": {} 114 | }, 115 | "h": { 116 | "y": {}, 117 | "z": {} 118 | }, 119 | "s": { 120 | "b": {} 121 | }, 122 | "p": { 123 | "p": {} 124 | } 125 | } 126 | } 127 | } -------------------------------------------------------------------------------- /data/trees_countries/CH.json: -------------------------------------------------------------------------------- 1 | { 2 | "u": { 3 | "0": { 4 | "m": { 5 | "u": {}, 6 | "2": {}, 7 | "v": {}, 8 | "s": {}, 9 | "c": {}, 10 | "f": {}, 11 | "4": {}, 12 | "e": {}, 13 | "7": {}, 14 | "0": {}, 15 | "9": {}, 16 | "5": {}, 17 | "h": {}, 18 | "8": {}, 19 | "t": {}, 20 | "d": {}, 21 | "g": {}, 22 | "6": {}, 23 | "1": {}, 24 | "3": {}, 25 | "k": {}, 26 | "j": {}, 27 | "z": {}, 28 | "n": {}, 29 | "q": {}, 30 | "y": {}, 31 | "w": {}, 32 | "b": {}, 33 | "m": {} 34 | }, 35 | "q": { 36 | "2": {}, 37 | "1": {}, 38 | "m": {}, 39 | "k": {}, 40 | "j": {}, 41 | "7": {}, 42 | "q": {}, 43 | "6": {}, 44 | "9": {}, 45 | "b": {}, 46 | "d": {}, 47 | "t": {}, 48 | "3": {}, 49 | "c": {}, 50 | "5": {}, 51 | "h": {}, 52 | "4": {}, 53 | "f": {}, 54 | "y": {}, 55 | "g": {}, 56 | "v": {}, 57 | "8": {}, 58 | "r": {}, 59 | "e": {}, 60 | "s": {}, 61 | "n": {}, 62 | "u": {}, 63 | "w": {}, 64 | "x": {}, 65 | "0": {}, 66 | "p": {} 67 | }, 68 | "n": { 69 | "r": {}, 70 | "q": {}, 71 | "k": {}, 72 | "n": {}, 73 | "j": {}, 74 | "m": {}, 75 | "w": {}, 76 | "x": {}, 77 | "z": {}, 78 | "p": {} 79 | }, 80 | "j": { 81 | "q": {}, 82 | "n": {}, 83 | "p": {}, 84 | "r": {}, 85 | "z": {}, 86 | "j": {}, 87 | "m": {}, 88 | "y": {}, 89 | "t": {}, 90 | "x": {}, 91 | "w": {}, 92 | "h": {} 93 | }, 94 | "k": { 95 | "f": {}, 96 | "c": {}, 97 | "g": {}, 98 | "v": {}, 99 | "b": {}, 100 | "8": {}, 101 | "2": {}, 102 | "d": {}, 103 | "9": {}, 104 | "3": {}, 105 | "y": {}, 106 | "e": {}, 107 | "u": {} 108 | }, 109 | "h": { 110 | "q": {}, 111 | "r": {}, 112 | "z": {}, 113 | "y": {}, 114 | "v": {}, 115 | "x": {}, 116 | "n": {} 117 | }, 118 | "r": { 119 | "2": {}, 120 | "6": {}, 121 | "1": {}, 122 | "5": {}, 123 | "7": {}, 124 | "4": {}, 125 | "3": {}, 126 | "0": {} 127 | }, 128 | "p": { 129 | "p": {}, 130 | "n": {} 131 | } 132 | } 133 | } 134 | } -------------------------------------------------------------------------------- /data/trees_countries/CR.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "1": { 4 | "g": { 5 | "g": {}, 6 | "d": {}, 7 | "k": {}, 8 | "4": {}, 9 | "v": {}, 10 | "s": {}, 11 | "f": {}, 12 | "m": {}, 13 | "u": {}, 14 | "c": {}, 15 | "7": {}, 16 | "e": {}, 17 | "t": {}, 18 | "w": {}, 19 | "p": {}, 20 | "r": {}, 21 | "9": {}, 22 | "h": {}, 23 | "n": {}, 24 | "q": {}, 25 | "0": {}, 26 | "5": {}, 27 | "j": {}, 28 | "1": {}, 29 | "8": {}, 30 | "2": {}, 31 | "y": {}, 32 | "6": {}, 33 | "b": {}, 34 | "3": {} 35 | }, 36 | "u": { 37 | "9": {}, 38 | "2": {}, 39 | "4": {}, 40 | "3": {}, 41 | "0": {}, 42 | "7": {}, 43 | "5": {}, 44 | "1": {}, 45 | "6": {}, 46 | "h": {}, 47 | "8": {}, 48 | "b": {}, 49 | "c": {}, 50 | "n": {}, 51 | "m": {}, 52 | "f": {}, 53 | "t": {}, 54 | "s": {}, 55 | "w": {}, 56 | "e": {}, 57 | "k": {}, 58 | "j": {}, 59 | "d": {} 60 | }, 61 | "s": { 62 | "x": {}, 63 | "v": {}, 64 | "w": {}, 65 | "y": {}, 66 | "s": {}, 67 | "r": {}, 68 | "q": {}, 69 | "p": {}, 70 | "z": {}, 71 | "t": {}, 72 | "u": {}, 73 | "f": {}, 74 | "g": {}, 75 | "9": {}, 76 | "d": {}, 77 | "k": {}, 78 | "b": {}, 79 | "m": {}, 80 | "3": {}, 81 | "8": {}, 82 | "7": {}, 83 | "c": {}, 84 | "e": {}, 85 | "j": {}, 86 | "n": {}, 87 | "2": {} 88 | }, 89 | "k": { 90 | "x": {}, 91 | "y": {}, 92 | "z": {} 93 | }, 94 | "e": { 95 | "z": {}, 96 | "w": {}, 97 | "r": {}, 98 | "x": {}, 99 | "q": {}, 100 | "y": {} 101 | }, 102 | "f": { 103 | "g": {}, 104 | "c": {}, 105 | "y": {}, 106 | "v": {}, 107 | "f": {} 108 | }, 109 | "t": { 110 | "n": {}, 111 | "0": {}, 112 | "p": {}, 113 | "1": {}, 114 | "h": {}, 115 | "4": {}, 116 | "q": {}, 117 | "j": {}, 118 | "m": {}, 119 | "5": {} 120 | }, 121 | "v": { 122 | "0": {} 123 | }, 124 | "m": { 125 | "n": {}, 126 | "j": {}, 127 | "p": {} 128 | } 129 | }, 130 | "0": { 131 | "f": { 132 | "p": {} 133 | } 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /test/utils/geo.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len, no-await-in-loop, guard-for-in, no-restricted-syntax, object-curly-newline */ 2 | const path = require('path'); 3 | const ethUtil = require('ethereumjs-util'); 4 | const bignum = require('bignum'); 5 | 6 | const toBitMap = (chars) => { 7 | let res = bignum('0'); 8 | chars.forEach((char) => { 9 | switch (char) { 10 | case 'v': res = res.or('2147483648'); break; 11 | case 'y': res = res.or('1073741824'); break; 12 | case 'z': res = res.or('536870912'); break; 13 | case 'b': res = res.or('268435456'); break; 14 | case 'c': res = res.or('134217728'); break; 15 | case 'f': res = res.or('67108864'); break; 16 | case 'g': res = res.or('33554432'); break; 17 | case 'u': res = res.or('16777216'); break; 18 | case 't': res = res.or('8388608'); break; 19 | case 'w': res = res.or('4194304'); break; 20 | case 'x': res = res.or('2097152'); break; 21 | case '8': res = res.or('1048576'); break; 22 | case '9': res = res.or('524288'); break; 23 | case 'd': res = res.or('262144'); break; 24 | case 'e': res = res.or('131072'); break; 25 | case 's': res = res.or('65536'); break; 26 | case 'm': res = res.or('32768'); break; 27 | case 'q': res = res.or('16384'); break; 28 | case 'r': res = res.or('8192'); break; 29 | case '2': res = res.or('4096'); break; 30 | case '3': res = res.or('2048'); break; 31 | case '6': res = res.or('1024'); break; 32 | case '7': res = res.or('512'); break; 33 | case 'k': res = res.or('256'); break; 34 | case 'j': res = res.or('128'); break; 35 | case 'n': res = res.or('64'); break; 36 | case 'p': res = res.or('32'); break; 37 | case '0': res = res.or('16'); break; 38 | case '1': res = res.or('8'); break; 39 | case '4': res = res.or('4'); break; 40 | case '5': res = res.or('2'); break; 41 | case 'h': res = res.or('1'); break; 42 | default: throw new Error(`unknown geohash char ${char}`); 43 | } 44 | }); 45 | return ethUtil.bufferToHex(ethUtil.setLengthLeft(res.toNumber(), 4)); 46 | }; 47 | 48 | const addCountry = async (from, web3, geoRegistryContract, countryCode, batchSize) => { 49 | const countryFile = require(path.join(__dirname, '..', '..', 'data', 'trees_countries', countryCode)); // eslint-disable-line 50 | const countryMap = Object.keys(countryFile).reduce((memo, level0char) => { 51 | Object.keys(countryFile[level0char]).forEach((level1char) => { 52 | Object.keys(countryFile[level0char][level1char]).forEach((level2char) => { 53 | const level4chars = Object.keys(countryFile[level0char][level1char][level2char]); 54 | memo[`${level0char}${level1char}${level2char}`] = toBitMap(level4chars); // eslint-disable-line 55 | }); 56 | }); 57 | return memo; 58 | }, {}); 59 | const keys = Object.keys(countryMap); 60 | let countryGasCost = 0; 61 | let txCount = 0; 62 | let mostExpensiveTrxGasCost = 0; 63 | 64 | for (let batchStartIdx = 0; batchStartIdx < keys.length; batchStartIdx += batchSize) { 65 | const keysBatch = keys.slice(batchStartIdx, batchStartIdx + batchSize); 66 | const valuesBatch = keysBatch.map(key => countryMap[key]); 67 | const receipt = await geoRegistryContract.updateLevel2batch(web3.utils.asciiToHex(countryCode), keysBatch.map(web3.utils.asciiToHex), valuesBatch, { from }); 68 | const gasCost = receipt.receipt.gasUsed; 69 | if (gasCost > mostExpensiveTrxGasCost) { 70 | mostExpensiveTrxGasCost = gasCost; 71 | } 72 | countryGasCost += gasCost; 73 | txCount += 1; 74 | } 75 | await geoRegistryContract.endInit(web3.utils.asciiToHex(countryCode), { from }); 76 | return { countryGasCost, mostExpensiveTrxGasCost, txCount, countryMap }; 77 | }; 78 | 79 | module.exports = { 80 | addCountry, 81 | }; 82 | -------------------------------------------------------------------------------- /data/trees_countries/TG.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "1": { 4 | "0": { 5 | "x": {}, 6 | "v": {}, 7 | "u": {}, 8 | "z": {}, 9 | "y": {}, 10 | "w": {}, 11 | "e": {}, 12 | "t": {}, 13 | "s": {}, 14 | "r": {}, 15 | "g": {}, 16 | "f": {}, 17 | "q": {}, 18 | "m": {} 19 | }, 20 | "2": { 21 | "b": {}, 22 | "f": {}, 23 | "g": {}, 24 | "y": {}, 25 | "c": {}, 26 | "8": {}, 27 | "w": {}, 28 | "u": {}, 29 | "e": {}, 30 | "d": {}, 31 | "9": {}, 32 | "s": {}, 33 | "t": {}, 34 | "v": {}, 35 | "z": {}, 36 | "q": {}, 37 | "m": {}, 38 | "k": {}, 39 | "7": {}, 40 | "6": {}, 41 | "2": {}, 42 | "3": {}, 43 | "r": {}, 44 | "x": {} 45 | }, 46 | "8": { 47 | "s": {}, 48 | "f": {}, 49 | "8": {}, 50 | "g": {}, 51 | "w": {}, 52 | "b": {}, 53 | "c": {}, 54 | "r": {}, 55 | "9": {}, 56 | "e": {}, 57 | "x": {}, 58 | "t": {}, 59 | "d": {}, 60 | "m": {}, 61 | "j": {}, 62 | "z": {}, 63 | "v": {}, 64 | "k": {}, 65 | "q": {}, 66 | "u": {}, 67 | "3": {}, 68 | "n": {}, 69 | "6": {}, 70 | "y": {}, 71 | "2": {}, 72 | "p": {}, 73 | "7": {} 74 | }, 75 | "b": { 76 | "k": {}, 77 | "j": {}, 78 | "7": {}, 79 | "8": {}, 80 | "m": {}, 81 | "4": {}, 82 | "h": {}, 83 | "n": {}, 84 | "s": {}, 85 | "b": {}, 86 | "p": {}, 87 | "1": {}, 88 | "0": {}, 89 | "6": {}, 90 | "9": {}, 91 | "w": {}, 92 | "3": {}, 93 | "2": {}, 94 | "d": {}, 95 | "c": {}, 96 | "e": {}, 97 | "5": {}, 98 | "q": {}, 99 | "t": {} 100 | }, 101 | "1": { 102 | "j": {}, 103 | "5": {}, 104 | "n": {}, 105 | "h": {}, 106 | "7": {}, 107 | "k": {}, 108 | "p": {} 109 | }, 110 | "3": { 111 | "5": {}, 112 | "j": {}, 113 | "n": {}, 114 | "1": {}, 115 | "0": {}, 116 | "p": {}, 117 | "h": {}, 118 | "4": {} 119 | }, 120 | "9": { 121 | "1": {}, 122 | "4": {}, 123 | "h": {}, 124 | "5": {}, 125 | "0": {} 126 | } 127 | } 128 | }, 129 | "e": { 130 | "c": { 131 | "z": { 132 | "v": {}, 133 | "u": {}, 134 | "z": {}, 135 | "y": {} 136 | } 137 | } 138 | } 139 | } -------------------------------------------------------------------------------- /data/trees_countries/FJ.json: -------------------------------------------------------------------------------- 1 | { 2 | "r": { 3 | "u": { 4 | "y": { 5 | "e": {}, 6 | "9": {}, 7 | "7": {}, 8 | "d": {}, 9 | "6": {}, 10 | "3": {}, 11 | "u": {}, 12 | "b": {}, 13 | "k": {}, 14 | "t": {}, 15 | "5": {}, 16 | "h": {}, 17 | "m": {}, 18 | "8": {}, 19 | "n": {}, 20 | "s": {}, 21 | "g": {}, 22 | "p": {}, 23 | "4": {}, 24 | "c": {}, 25 | "2": {}, 26 | "v": {}, 27 | "1": {}, 28 | "0": {}, 29 | "f": {} 30 | }, 31 | "z": { 32 | "0": {}, 33 | "7": {}, 34 | "z": {}, 35 | "t": {}, 36 | "8": {}, 37 | "4": {}, 38 | "5": {}, 39 | "d": {}, 40 | "9": {}, 41 | "p": {}, 42 | "3": {}, 43 | "1": {}, 44 | "r": {} 45 | }, 46 | "w": { 47 | "x": {}, 48 | "q": {}, 49 | "u": {}, 50 | "s": {}, 51 | "g": {}, 52 | "e": {} 53 | }, 54 | "h": { 55 | "h": {} 56 | }, 57 | "v": { 58 | "v": {}, 59 | "y": {} 60 | }, 61 | "x": { 62 | "v": {}, 63 | "g": {}, 64 | "f": {}, 65 | "y": {} 66 | } 67 | }, 68 | "v": { 69 | "n": { 70 | "b": {}, 71 | "c": {}, 72 | "3": {}, 73 | "2": {}, 74 | "0": {} 75 | }, 76 | "p": { 77 | "c": {}, 78 | "6": {}, 79 | "e": {}, 80 | "8": {}, 81 | "0": {}, 82 | "g": {}, 83 | "b": {}, 84 | "4": {}, 85 | "u": {}, 86 | "d": {}, 87 | "3": {}, 88 | "1": {}, 89 | "f": {}, 90 | "2": {}, 91 | "9": {} 92 | }, 93 | "v": { 94 | "b": {}, 95 | "c": {} 96 | } 97 | } 98 | }, 99 | "2": { 100 | "h": { 101 | "b": { 102 | "d": {}, 103 | "b": {}, 104 | "p": {}, 105 | "9": {}, 106 | "y": {}, 107 | "e": {}, 108 | "6": {}, 109 | "s": {}, 110 | "v": {}, 111 | "w": {}, 112 | "7": {}, 113 | "t": {} 114 | }, 115 | "3": { 116 | "r": {} 117 | }, 118 | "c": { 119 | "3": {}, 120 | "1": {}, 121 | "4": {}, 122 | "6": {} 123 | }, 124 | "8": { 125 | "u": {}, 126 | "g": {}, 127 | "e": {}, 128 | "h": {}, 129 | "s": {}, 130 | "5": {} 131 | }, 132 | "9": { 133 | "5": {}, 134 | "4": {}, 135 | "j": {} 136 | }, 137 | "2": { 138 | "f": {} 139 | } 140 | }, 141 | "j": { 142 | "0": { 143 | "h": {}, 144 | "0": {}, 145 | "1": {}, 146 | "4": {} 147 | } 148 | } 149 | } 150 | } -------------------------------------------------------------------------------- /data/trees_countries/LK.json: -------------------------------------------------------------------------------- 1 | { 2 | "t": { 3 | "c": { 4 | "3": { 5 | "4": {}, 6 | "g": {}, 7 | "s": {}, 8 | "6": {}, 9 | "t": {}, 10 | "q": {}, 11 | "7": {}, 12 | "5": {}, 13 | "r": {}, 14 | "h": {}, 15 | "8": {}, 16 | "u": {}, 17 | "3": {}, 18 | "9": {}, 19 | "n": {}, 20 | "2": {}, 21 | "c": {}, 22 | "k": {}, 23 | "j": {}, 24 | "0": {}, 25 | "1": {}, 26 | "f": {}, 27 | "p": {}, 28 | "e": {}, 29 | "d": {}, 30 | "b": {}, 31 | "x": {}, 32 | "m": {}, 33 | "w": {}, 34 | "y": {}, 35 | "z": {}, 36 | "v": {} 37 | }, 38 | "1": { 39 | "p": {}, 40 | "r": {}, 41 | "v": {}, 42 | "y": {}, 43 | "h": {}, 44 | "t": {}, 45 | "5": {}, 46 | "z": {}, 47 | "k": {}, 48 | "s": {}, 49 | "7": {}, 50 | "w": {}, 51 | "q": {}, 52 | "m": {}, 53 | "j": {}, 54 | "n": {}, 55 | "x": {}, 56 | "d": {}, 57 | "4": {}, 58 | "g": {}, 59 | "e": {}, 60 | "u": {}, 61 | "1": {}, 62 | "6": {}, 63 | "3": {} 64 | }, 65 | "9": { 66 | "4": {}, 67 | "2": {}, 68 | "3": {}, 69 | "6": {}, 70 | "0": {}, 71 | "1": {}, 72 | "5": {}, 73 | "h": {}, 74 | "d": {}, 75 | "q": {}, 76 | "b": {}, 77 | "m": {}, 78 | "e": {}, 79 | "s": {}, 80 | "c": {}, 81 | "n": {}, 82 | "8": {}, 83 | "p": {}, 84 | "j": {}, 85 | "9": {}, 86 | "k": {}, 87 | "7": {} 88 | }, 89 | "2": { 90 | "g": {}, 91 | "u": {}, 92 | "z": {}, 93 | "c": {}, 94 | "s": {}, 95 | "v": {}, 96 | "f": {}, 97 | "y": {}, 98 | "e": {}, 99 | "b": {}, 100 | "w": {}, 101 | "x": {}, 102 | "d": {}, 103 | "t": {} 104 | }, 105 | "4": { 106 | "j": {}, 107 | "n": {}, 108 | "h": {}, 109 | "p": {} 110 | }, 111 | "0": { 112 | "y": {}, 113 | "v": {}, 114 | "u": {}, 115 | "z": {}, 116 | "g": {}, 117 | "f": {} 118 | }, 119 | "8": { 120 | "b": {}, 121 | "z": {}, 122 | "c": {}, 123 | "v": {}, 124 | "f": {}, 125 | "t": {}, 126 | "e": {}, 127 | "w": {}, 128 | "u": {}, 129 | "g": {}, 130 | "y": {} 131 | }, 132 | "6": { 133 | "h": {}, 134 | "0": {}, 135 | "j": {}, 136 | "5": {}, 137 | "1": {}, 138 | "4": {} 139 | } 140 | } 141 | } 142 | } -------------------------------------------------------------------------------- /data/trees_countries/SL.json: -------------------------------------------------------------------------------- 1 | { 2 | "e": { 3 | "9": { 4 | "x": { 5 | "q": {}, 6 | "v": {}, 7 | "f": {}, 8 | "u": {}, 9 | "3": {}, 10 | "2": {}, 11 | "s": {}, 12 | "m": {}, 13 | "h": {}, 14 | "g": {}, 15 | "1": {}, 16 | "7": {}, 17 | "y": {}, 18 | "8": {}, 19 | "6": {}, 20 | "0": {}, 21 | "9": {}, 22 | "c": {}, 23 | "t": {}, 24 | "5": {}, 25 | "d": {}, 26 | "r": {}, 27 | "e": {}, 28 | "j": {}, 29 | "w": {}, 30 | "4": {}, 31 | "b": {}, 32 | "x": {}, 33 | "k": {}, 34 | "z": {}, 35 | "n": {}, 36 | "p": {} 37 | }, 38 | "r": { 39 | "v": {}, 40 | "9": {}, 41 | "p": {}, 42 | "t": {}, 43 | "x": {}, 44 | "y": {}, 45 | "w": {}, 46 | "z": {}, 47 | "g": {}, 48 | "q": {}, 49 | "d": {}, 50 | "j": {}, 51 | "n": {}, 52 | "k": {}, 53 | "u": {}, 54 | "e": {}, 55 | "s": {}, 56 | "f": {}, 57 | "r": {}, 58 | "m": {}, 59 | "4": {}, 60 | "c": {}, 61 | "1": {}, 62 | "8": {}, 63 | "3": {}, 64 | "5": {}, 65 | "7": {}, 66 | "2": {}, 67 | "h": {}, 68 | "6": {}, 69 | "b": {} 70 | }, 71 | "q": { 72 | "z": {}, 73 | "y": {}, 74 | "g": {}, 75 | "f": {}, 76 | "x": {}, 77 | "w": {}, 78 | "u": {}, 79 | "v": {} 80 | }, 81 | "z": { 82 | "b": {}, 83 | "0": {}, 84 | "8": {}, 85 | "2": {} 86 | }, 87 | "w": { 88 | "y": {}, 89 | "8": {}, 90 | "u": {}, 91 | "e": {}, 92 | "c": {}, 93 | "f": {}, 94 | "9": {}, 95 | "b": {}, 96 | "d": {}, 97 | "v": {}, 98 | "g": {} 99 | }, 100 | "p": { 101 | "z": {}, 102 | "x": {} 103 | } 104 | }, 105 | "c": { 106 | "2": { 107 | "h": {}, 108 | "5": {}, 109 | "j": {}, 110 | "n": {}, 111 | "p": {}, 112 | "q": {}, 113 | "r": {}, 114 | "w": {}, 115 | "4": {}, 116 | "7": {}, 117 | "k": {}, 118 | "m": {}, 119 | "x": {}, 120 | "6": {}, 121 | "1": {} 122 | }, 123 | "8": { 124 | "5": {}, 125 | "h": {}, 126 | "1": {}, 127 | "0": {}, 128 | "j": {}, 129 | "4": {}, 130 | "7": {}, 131 | "p": {}, 132 | "2": {}, 133 | "6": {}, 134 | "m": {}, 135 | "k": {}, 136 | "q": {}, 137 | "9": {}, 138 | "n": {}, 139 | "3": {}, 140 | "8": {} 141 | }, 142 | "b": { 143 | "0": {} 144 | } 145 | } 146 | } 147 | } -------------------------------------------------------------------------------- /migrations/2_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | /* global artifacts */ 3 | const DetherToken = artifacts.require("DetherToken.sol"); 4 | const CertifierRegistry = artifacts.require("CertifierRegistry"); 5 | const Users = artifacts.require("Users.sol"); 6 | const GeoRegistry = artifacts.require("GeoRegistry.sol"); 7 | const ZoneFactory = artifacts.require("ZoneFactory.sol"); 8 | const Zone = artifacts.require("Zone.sol"); 9 | const Teller = artifacts.require("Teller.sol"); 10 | const Shops = artifacts.require("Shops.sol"); 11 | const ShopsDispute = artifacts.require("ShopsDispute.sol"); 12 | const TaxCollector = artifacts.require("TaxCollector.sol"); 13 | 14 | const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000"; 15 | // const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); 16 | 17 | const CONTRACT_ADDRESSES = { 18 | "kovan-fork": { 19 | mkrPriceFeed: "0xa944bd4b25c9f186a846fd5668941aa3d3b8425f" 20 | }, 21 | kovan: { 22 | mkrPriceFeed: "0xa944bd4b25c9f186a846fd5668941aa3d3b8425f" 23 | }, 24 | mainnet: { 25 | mkrPriceFeed: "0x729D19f657BD0614b4985Cf1D82531c67569197B" 26 | } 27 | }; 28 | 29 | // NOTE: when running 'truffle test' the migrations will also run, and if we have a 60 second 30 | // delay, right in the middle of the tests after 60 seconds, the next contract in this migration 31 | // file will be deployed. therefore comment them out until you actually want to deploy. 32 | module.exports = async (deployer, network) => { 33 | console.log("Deploy contract to => ", network); 34 | 35 | // await deployer.deploy(DetherToken, { gas: 6500000 }); 36 | let dth; 37 | switch (network) { 38 | case "develop": 39 | // use a fake instance to test locally using truffle develop 40 | // fall through 41 | case "rinkeby": 42 | // use a fake instance to test locally using truffle develop 43 | // fall through 44 | case "development": 45 | // use a fake instance to test locally using ganache 46 | // fall through 47 | case "ropsten": 48 | await deployer.deploy(DetherToken, { gas: 6500000 }); 49 | dth = await DetherToken.deployed(); 50 | break; 51 | 52 | case "kovan-fork": 53 | // fall through 54 | 55 | case "kovan": 56 | dth = await DetherToken.at("0x9027e9fc4641e2991a36eaeb0347bc5b35322741"); // DTH kovan address 57 | break; 58 | 59 | case "mainnet": 60 | dth = await DetherToken.at("0x5adc961D6AC3f7062D2eA45FEFB8D8167d44b190"); // DTH mainnet address 61 | break; 62 | 63 | default: 64 | throw new Error( 65 | `did not specify how to deploy ExchangeRateOracle on this network (${network})` 66 | ); 67 | } 68 | 69 | await deployer.deploy(TaxCollector, dth.address, ADDRESS_ZERO, { 70 | gas: 6500000 71 | }); 72 | const taxCollector = await TaxCollector.deployed(); 73 | 74 | await deployer.deploy(CertifierRegistry, { gas: 6500000 }); 75 | const certifierRegistry = await CertifierRegistry.deployed(); 76 | 77 | await deployer.deploy(GeoRegistry, { gas: 6500000 }); 78 | const geo = await GeoRegistry.deployed(); 79 | 80 | await deployer.deploy(Zone, { gas: 6700000 }); 81 | const zoneImplementation = await Zone.deployed(); 82 | 83 | await deployer.deploy(Teller, { gas: 6500000 }); 84 | const tellerImplementation = await Teller.deployed(); 85 | 86 | await deployer.deploy(Users, geo.address, certifierRegistry.address, { 87 | gas: 6500000 88 | }); 89 | const users = await Users.deployed(); 90 | 91 | await deployer.deploy( 92 | ZoneFactory, 93 | dth.address, 94 | geo.address, 95 | users.address, 96 | zoneImplementation.address, 97 | tellerImplementation.address, 98 | taxCollector.address, 99 | { gas: 6500000 } 100 | ); 101 | const zoneFactory = await ZoneFactory.deployed(); 102 | 103 | switch (network) { 104 | case "kovan": 105 | 106 | case "mainnet": 107 | await users.setZoneFactory(ZoneFactory.address, { gas: 6500000 }); 108 | console.log("Set zone factory"); 109 | } 110 | 111 | await deployer.deploy( 112 | Shops, 113 | dth.address, 114 | geo.address, 115 | users.address, 116 | zoneFactory.address, 117 | { gas: 6500000 } 118 | ); 119 | }; 120 | -------------------------------------------------------------------------------- /contracts/certifier/CertifierRegistry.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.10; 2 | pragma experimental ABIEncoderV2; 3 | 4 | // TO DO 5 | // add gas cost 6 | 7 | contract CertifierRegistry { 8 | // ------------------------------------------------ 9 | // 10 | // Structs 11 | // 12 | // ------------------------------------------------ 13 | 14 | struct Certification { 15 | address certifier; 16 | int8 ref; 17 | uint timestamp; 18 | } 19 | 20 | struct Certifier { 21 | address owner; 22 | string url; // need a website url to prove the certifier ID 23 | mapping (address => bool) delegate; 24 | mapping (int8 => string) certificationType; 25 | } 26 | 27 | // ------------------------------------------------ 28 | // 29 | // Variables Public 30 | // 31 | // ------------------------------------------------ 32 | 33 | mapping (address => Certification[]) public certs; 34 | mapping (address => Certifier) public certifier; 35 | 36 | // ------------------------------------------------ 37 | // 38 | // Events 39 | // 40 | // ------------------------------------------------ 41 | 42 | event Certified(address indexed certifier, address certified, int8 certification); 43 | event AddDelegate(address indexed certifierID, address _delegate); 44 | event RemoveDelegate(address indexed certifierID, address _delegate); 45 | 46 | // ------------------------------------------------ 47 | // 48 | // Modifiers 49 | // 50 | // ------------------------------------------------ 51 | modifier only_certification_owner(address _certifierId, address _who) { 52 | require(certifier[_certifierId].owner == _who, "caller must be certification owner"); 53 | _; 54 | } 55 | modifier only_delegate(address _certifierId, address _who) { 56 | require(certifier[_certifierId].delegate[_who], "caller must be delegate"); 57 | _; 58 | } 59 | 60 | 61 | // ------------------------------------------------ 62 | // 63 | // Functions Certifier management 64 | // 65 | // ------------------------------------------------ 66 | 67 | function createCertifier(string memory _url) public returns (address certifiedId) { 68 | certifiedId = msg.sender; 69 | certifier[certifiedId].owner = msg.sender; 70 | certifier[certifiedId].url = _url; 71 | } 72 | function modifyUrl(address _certifierId, string memory _newUrl) public only_certification_owner(_certifierId, msg.sender) { 73 | certifier[msg.sender].url = _newUrl; 74 | } 75 | function addCertificationType(address _certifierId, int8 ref, string memory description) public only_certification_owner(_certifierId, msg.sender) { 76 | certifier[msg.sender].certificationType[ref] = description; 77 | } 78 | function addDelegate(address _certifierId, address _delegate) public only_certification_owner(_certifierId, msg.sender) 79 | { 80 | certifier[_certifierId].delegate[_delegate] = true; 81 | emit AddDelegate(_certifierId, _delegate); 82 | } 83 | function removeDelegate(address _certifierId, address _delegate) public only_certification_owner(_certifierId, msg.sender) 84 | { 85 | certifier[_certifierId].delegate[_delegate] = false; 86 | emit RemoveDelegate(_certifierId, _delegate); 87 | } 88 | 89 | // ------------------------------------------------ 90 | // 91 | // Functions Certifier 92 | // 93 | // ------------------------------------------------ 94 | 95 | function certify(address _certifierId, address _who, int8 _type) 96 | public 97 | only_delegate(_certifierId, msg.sender) 98 | { 99 | certs[_who].push(Certification({certifier: _certifierId, ref: _type, timestamp: now})); 100 | emit Certified(_certifierId, _who, _type); 101 | } 102 | 103 | // ------------------------------------------------ 104 | // 105 | // Functions Getters Public 106 | // 107 | // ------------------------------------------------ 108 | 109 | function isDelegate(address _certifierId, address _who) public view returns(bool) { return certifier[_certifierId].delegate[_who]; } 110 | 111 | function getCertificationType(address _certifierId, int8 _number) public view returns( string memory) { 112 | return certifier[_certifierId].certificationType[_number]; 113 | } 114 | 115 | function getCerts( address _who) public view returns(Certification[] memory) { 116 | return certs[_who]; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /data/trees_countries/BA.json: -------------------------------------------------------------------------------- 1 | { 2 | "s": { 3 | "r": { 4 | "v": { 5 | "n": {}, 6 | "7": {}, 7 | "p": {}, 8 | "6": {}, 9 | "h": {}, 10 | "0": {}, 11 | "m": {}, 12 | "3": {}, 13 | "2": {}, 14 | "1": {}, 15 | "j": {}, 16 | "q": {}, 17 | "k": {}, 18 | "4": {}, 19 | "5": {}, 20 | "e": {}, 21 | "f": {}, 22 | "y": {}, 23 | "w": {}, 24 | "c": {}, 25 | "x": {}, 26 | "b": {}, 27 | "g": {}, 28 | "z": {}, 29 | "8": {}, 30 | "r": {}, 31 | "t": {}, 32 | "s": {}, 33 | "d": {}, 34 | "9": {} 35 | }, 36 | "u": { 37 | "3": {}, 38 | "y": {}, 39 | "n": {}, 40 | "j": {}, 41 | "z": {}, 42 | "h": {}, 43 | "6": {}, 44 | "s": {}, 45 | "2": {}, 46 | "7": {}, 47 | "q": {}, 48 | "4": {}, 49 | "r": {}, 50 | "k": {}, 51 | "d": {}, 52 | "m": {}, 53 | "x": {}, 54 | "g": {}, 55 | "p": {}, 56 | "1": {}, 57 | "e": {}, 58 | "c": {}, 59 | "f": {}, 60 | "w": {}, 61 | "b": {}, 62 | "u": {}, 63 | "8": {}, 64 | "t": {}, 65 | "9": {}, 66 | "5": {}, 67 | "v": {}, 68 | "0": {} 69 | }, 70 | "t": { 71 | "p": {}, 72 | "n": {}, 73 | "m": {}, 74 | "k": {}, 75 | "h": {}, 76 | "4": {}, 77 | "j": {}, 78 | "5": {}, 79 | "x": {}, 80 | "q": {}, 81 | "z": {}, 82 | "w": {}, 83 | "r": {} 84 | }, 85 | "g": { 86 | "v": {}, 87 | "y": {}, 88 | "x": {}, 89 | "t": {}, 90 | "z": {}, 91 | "w": {}, 92 | "g": {}, 93 | "u": {}, 94 | "r": {}, 95 | "c": {}, 96 | "m": {}, 97 | "e": {}, 98 | "k": {}, 99 | "p": {}, 100 | "s": {}, 101 | "n": {}, 102 | "d": {}, 103 | "b": {}, 104 | "f": {}, 105 | "q": {} 106 | }, 107 | "s": { 108 | "z": {}, 109 | "y": {}, 110 | "x": {}, 111 | "w": {}, 112 | "v": {}, 113 | "u": {}, 114 | "t": {}, 115 | "s": {}, 116 | "r": {}, 117 | "f": {}, 118 | "e": {}, 119 | "p": {}, 120 | "q": {}, 121 | "m": {}, 122 | "k": {}, 123 | "g": {} 124 | } 125 | } 126 | }, 127 | "u": { 128 | "2": { 129 | "5": { 130 | "b": {}, 131 | "8": {}, 132 | "3": {}, 133 | "9": {}, 134 | "0": {}, 135 | "c": {}, 136 | "2": {}, 137 | "1": {} 138 | }, 139 | "h": { 140 | "b": {}, 141 | "3": {}, 142 | "2": {}, 143 | "0": {}, 144 | "1": {}, 145 | "8": {} 146 | }, 147 | "j": { 148 | "2": {}, 149 | "0": {} 150 | } 151 | } 152 | } 153 | } -------------------------------------------------------------------------------- /migrations/constructor_arguments_in_abi.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Robert Lie (mobilefish.com) 3 | More information about this file, see: 4 | https://www.mobilefish.com/developer/blockchain/blockchain_quickguide_ethereum_tools.html 5 | 6 | More information about ethereumjs-abi 7 | https://www.npmjs.com/package/ethereumjs-abi 8 | https://github.com/ethereumjs/ethereumjs-abi 9 | 10 | WARNING: 11 | The library ethereumjs-abi is not fully implemented yet! 12 | For example: 13 | - byte not supported. Use bytes1 instead 14 | var parameterTypes = ['byte']; 15 | var parameterValues = [5]; 16 | 17 | Purpose: 18 | Encode the constructor arguments in ABI hex form. 19 | The output can be used for Contract Verification (For contracts that accept constructor parameters), see: 20 | https://etherscan.io/verifyContract 21 | 22 | Prerequisites: 23 | + Nodejs: https://nodejs.org/en/download/ 24 | + ethereumjs-abi: https://www.npmjs.com/package/ethereumjs-abi 25 | npm install -g ethereumjs-abi 26 | + bn.js: https://www.npmjs.com/package/bn.js 27 | npm install -g bn.js 28 | 29 | Note: Show all installed node modules: 30 | npm list -g --depth=0 31 | 32 | Usage: 33 | - Rename this file to constructor_arguments_in_abi.js 34 | - Specify parameterTypes and parameterValues 35 | You can see several examples how it is done. 36 | Examples found in: 37 | https://github.com/ethereumjs/ethereumjs-abi/blob/master/test/index.js 38 | - Run this script, type: node constructor_arguments_in_abi.js 39 | */ 40 | 41 | var abi = require('ethereumjs-abi'); 42 | var BN = require('bn.js') 43 | 44 | // Example 1 45 | //var parameterTypes = ['address', 'uint256', 'bool']; 46 | //var parameterValues = ['0x1234567812345678', '0x314159268', true]; 47 | 48 | // Example 2 49 | //var parameterTypes = ['address', 'uint', 'uint']; 50 | //var parameterValues = ['0x829bd824b016326a401d083b33d092293333a830', 4, 177772]; 51 | 52 | // Example 3 53 | //var parameterTypes = ['bytes', 'bool', 'uint256[]']; 54 | //var parameterValues = ['dave', true, [ 1, 2, 3 ] ]; 55 | 56 | // Example 4 57 | //var parameterTypes = ['uint', 'uint32[]', 'bytes10', 'bytes']; 58 | //var parameterValues = [0x123, [ 0x456, 0x789 ], '1234567890', 'Hello, world!']; 59 | 60 | // Example 5 61 | //var parameterTypes = ['int32', 'int32', int256]; 62 | //var parameterValues = [-2, 6, -1]; 63 | 64 | // Example 6 65 | //var parameterTypes = ['string']; 66 | //var parameterValues = ['hello world']; 67 | 68 | // Example 7 69 | //var parameterTypes = ['uint256']; 70 | //var val = new BN("115792089237316195423570985008687907853269984665640564039457584007913129639935", 10); 71 | //var parameterValues = [val]; 72 | 73 | // Example 8: Largest value for bytes32 74 | //var parameterTypes = ['bytes32']; 75 | //var val = new BN("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 16); 76 | //var parameterValues = [val]; 77 | 78 | // Example 9: Largest negative value for type int256 79 | //var parameterTypes = ['int256']; 80 | //var val = new BN("-57896044618658097711785492504343953926634992332820282019728792003956564819968", 10); 81 | //var parameterValues = [val]; 82 | 83 | // Example 10: Largest positive value for type int256 84 | //var parameterTypes = ['int256']; 85 | //var val = new BN("57896044618658097711785492504343953926634992332820282019728792003956564819967", 10); 86 | //var parameterValues = [val]; 87 | 88 | // Example 11: Largest positive value for type uint256 89 | //var parameterTypes = ['uint256']; 90 | //var val = new BN(" 115792089237316195423570985008687907853269984665640564039457584007913129639935", 10); 91 | //var parameterValues = [val]; 92 | 93 | // Example 12 94 | //parameterTypes = ['uint8[]']; 95 | //var parameterValues = [[1]]; 96 | 97 | // Example 13: Chinese 你, Unicode: U-4F60 98 | //parameterTypes = ['string']; 99 | //var parameterValues = "你"; 100 | 101 | 102 | var parameterTypes = ['address']; 103 | // storage address 104 | var parameterValues = ['0xdbf01f25066c2a6c6d311f047917ebed72d8ca42']; 105 | 106 | // =========================================================================== 107 | var encoded = abi.rawEncode(parameterTypes, parameterValues); 108 | console.log("Encoded: \n",encoded.toString('hex')); 109 | 110 | // returns the decoded array of arguments 111 | var decoded = abi.rawDecode(parameterTypes, encoded); 112 | console.log("Decoded: \n",decoded); 113 | -------------------------------------------------------------------------------- /data/trees_countries/BS.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "k": { 4 | "4": { 5 | "w": {}, 6 | "n": {}, 7 | "s": {}, 8 | "g": {}, 9 | "m": {}, 10 | "j": {}, 11 | "y": {}, 12 | "e": {}, 13 | "f": {}, 14 | "t": {}, 15 | "x": {}, 16 | "d": {}, 17 | "q": {} 18 | }, 19 | "2": { 20 | "y": {}, 21 | "8": {}, 22 | "q": {}, 23 | "s": {}, 24 | "b": {}, 25 | "d": {}, 26 | "h": {}, 27 | "x": {}, 28 | "6": {}, 29 | "w": {}, 30 | "9": {}, 31 | "c": {}, 32 | "k": {}, 33 | "5": {}, 34 | "r": {}, 35 | "t": {}, 36 | "7": {}, 37 | "m": {}, 38 | "f": {}, 39 | "e": {} 40 | }, 41 | "8": { 42 | "p": {}, 43 | "u": {}, 44 | "g": {}, 45 | "x": {}, 46 | "d": {}, 47 | "8": {}, 48 | "z": {}, 49 | "r": {}, 50 | "v": {}, 51 | "n": {} 52 | }, 53 | "0": { 54 | "x": {}, 55 | "y": {}, 56 | "z": {} 57 | }, 58 | "9": { 59 | "2": {}, 60 | "3": {}, 61 | "j": {}, 62 | "h": {}, 63 | "p": {}, 64 | "5": {}, 65 | "n": {}, 66 | "8": {} 67 | }, 68 | "b": { 69 | "8": {}, 70 | "9": {}, 71 | "2": {}, 72 | "b": {}, 73 | "0": {}, 74 | "c": {} 75 | }, 76 | "7": { 77 | "0": {}, 78 | "1": {} 79 | }, 80 | "5": { 81 | "8": {}, 82 | "0": {}, 83 | "2": {}, 84 | "1": {}, 85 | "e": {}, 86 | "b": {}, 87 | "3": {} 88 | }, 89 | "3": { 90 | "x": {}, 91 | "t": {}, 92 | "z": {}, 93 | "u": {}, 94 | "9": {}, 95 | "n": {}, 96 | "v": {}, 97 | "y": {}, 98 | "7": {}, 99 | "s": {}, 100 | "8": {}, 101 | "d": {} 102 | }, 103 | "6": { 104 | "7": {}, 105 | "b": {}, 106 | "h": {}, 107 | "3": {}, 108 | "6": {}, 109 | "5": {} 110 | }, 111 | "c": { 112 | "0": {} 113 | }, 114 | "1": { 115 | "y": {} 116 | } 117 | }, 118 | "7": { 119 | "e": { 120 | "z": {}, 121 | "x": {}, 122 | "w": {} 123 | }, 124 | "s": { 125 | "p": {} 126 | }, 127 | "f": { 128 | "n": {}, 129 | "p": {} 130 | }, 131 | "g": { 132 | "8": {}, 133 | "z": {}, 134 | "r": {}, 135 | "n": {}, 136 | "b": {}, 137 | "q": {} 138 | }, 139 | "u": { 140 | "n": {}, 141 | "r": {}, 142 | "1": {}, 143 | "q": {}, 144 | "p": {}, 145 | "0": {}, 146 | "4": {} 147 | } 148 | }, 149 | "h": { 150 | "x": { 151 | "y": {}, 152 | "d": {}, 153 | "9": {}, 154 | "z": {} 155 | }, 156 | "p": { 157 | "m": {}, 158 | "q": {} 159 | } 160 | } 161 | } 162 | } --------------------------------------------------------------------------------