Skip to content
Permalink
Browse files

Merge pull request #7 from tomochain/develop

Merge latest changes
  • Loading branch information...
piavgh committed Feb 26, 2019
2 parents f1c6958 + fc51ca9 commit 7af14cc41b3ed05ce057a95214ea764da14f143e
Showing with 398 additions and 7,083 deletions.
  1. +5 −3 .env.sample
  2. +43 −95 Deployment_step_by_step.md
  3. +0 −3 README.md
  4. +0 −1 config/contractAddresses.json
  5. +65 −96 config/index.js
  6. +19 −0 config/secret.js
  7. +0 −561 contracts/Exchange.sol
  8. +0 −33 contracts/RewardCollector.sol
  9. +0 −164 contracts/RewardPools.sol
  10. +0 −30 contracts/interfaces/RELA.sol
  11. +0 −6 contracts/interfaces/RewardCollectorInterface.sol
  12. +180 −0 contracts/tokens/ETH.sol
  13. +0 −321 contracts/tokens/RELA.sol
  14. +0 −5 contracts/utils/ApproveAndCallReceiver.sol
  15. +0 −56 contracts/utils/SetupAccount.sol
  16. +0 −28 index.js
  17. +0 −23 migrations/11_setup_accounts.js
  18. +0 −7 migrations/2_deploy_relayer_token.js
  19. 0 migrations/{6_deploy_tokens.js → 2_deploy_tokens.js}
  20. +0 −8 migrations/3_deploy_weth.js
  21. +5 −0 migrations/{10_transfer_tokens.js → 3_transfer_tokens.js}
  22. +0 −22 migrations/4_deploy_rewards.js
  23. +0 −17 migrations/5_deploy_exchange.js
  24. +0 −26 migrations/7_deposit_weth.js
  25. +0 −46 migrations/8_approve_tokens.js
  26. +0 −23 migrations/9_approve_weths.js
  27. +2 −4 package.json
  28. +0 −39 scripts/approve_tokens.js
  29. +0 −49 scripts/exchange_events.js
  30. +0 −28 scripts/generateExchangeGo.js
  31. +0 −25 scripts/misc/batch_transfer_rinkeby_ether.js
  32. 0 scripts/misc/index.js
  33. +0 −40 scripts/misc/query_rinkeby_token_balances.js
  34. +0 −25 scripts/misc/transfer_mainnet_ether.js
  35. +0 −27 scripts/misc/transfer_rinkeby_ether.js
  36. +0 −38 scripts/misc/transfer_rinkeby_tokens.js
  37. +0 −34 scripts/query_token_balances.js
  38. +0 −37 scripts/register_operators.js
  39. +0 −52 scripts/register_pairs.js
  40. +0 −35 scripts/register_reward_account.js
  41. +0 −36 scripts/register_reward_tokens.js
  42. +0 −3 scripts/setup_rinkeby_contract.sh
  43. +0 −14 scripts/show_contract_addresses.js
  44. +0 −53 scripts/show_contract_setup.js
  45. +0 −25 scripts/show_operator_balances.js
  46. +0 −232 scripts/test_exchange.js
  47. +0 −9 scripts/update_contract_addresses.js
  48. +0 −16 secret-config.js
  49. +0 −20 start-ganache.sh
  50. +0 −2,043 test/exchange.js
  51. +0 −224 test/rewards.js
  52. +0 −58 test/utils/exchange.js
  53. +28 −43 truffle.js
  54. +0 −2,037 utils/abis.js
  55. +0 −154 utils/helpers.js
  56. +51 −109 yarn.lock
@@ -1,3 +1,5 @@
TOMO__MAINNET_PRIVATE_KEY=3411b45169aa5a8312e51357db68621031020dcf46011d7431db1bbb6d3922ce
TOMO__RINKEBY_PRIVATE_KEY=3411b45169aa5a8312e51357db68621031020dcf46011d7431db1bbb6d3922ce
TOMO__LOCAL_PRIVATE_KEY=7f4c1bacba63f05827f6d8fc0e22cf68c42005775a7f73abff7d819986bae77c
ETHEREUM_MNEMONIC=Your Ethereum mnemonic here
ROPSTEN_MNEMONIC=Your Ropsten mnemonic here
RINKEBY_MNEMONIC=Your Rinkeby mnemonic here
TOMOCHAIN_MNEMONIC=Your Tomochain mainnet mnemonic here
TOMOCHAIN_TESTNET_MNEMONIC=Your Tomochain testnet mnemonic here
@@ -4,39 +4,15 @@
https://golang.org/doc/install
```

0.2. Install go-ethereum from source code
0.2. Download go-ethereum source code
```
https://geth.ethereum.org/install/#build-it-from-source-code
```
----------------
## II. dex-protocol
1. Clone it:
```
git clone git@github.com:tomochain/dex-protocol.git
```
2. Install necessary golang packages:
```
yarn install-requirements
```
3.
```
cd OrderBook
mkdir $GOPATH/src/github.com/tomochain
ln -sF $PWD $GOPATH/src/github.com/tomochain/orderbook
```
4. Reset go-ethereum repository to a specific commit in order to work (temporary):
```
cd $GOPATH/src/github.com/ethereum/go-ethereum
git reset --hard 880de230b44e20282abdef0f1f9a3294ce68e5d8
```
5. By default, we use POA consensus for demo
Assume you are in `dex-protocol` folder:
```
Run Node1: `yarn node1 -mining true`
Run Node2: `yarn node2 -mining true`
Run Backend: `yarn backend` (optional)
```
----------------
## II. Blockchain

You can use Ganache for development or the testnet of your own

## III. dex-smart-contract
1. Clone it:
```
@@ -46,68 +22,32 @@ git clone git@github.com:tomochain/dex-smart-contract.git
```
yarn global add truffle
```
3. Run `yarn`
4. Deploy contracts to blockchain:
3. Run `yarn install`

4. Update .env file with your mnemonic words (You can check file `.env.sample` for more information)

5. Deploy smart contracts to blockchain:
```
yarn deploy-contracts
```
5. Update contract addresses in file `config/contractAddresses.json`
```
node scripts/update_contract_addresses.js
```
6. Generate Exchange in Golang
```
yarn generate-exchange-go
```
7. Create .env file
```
cp .env.sample .env
```
8. Update .env file with your parameters (if needed)
```
For example, change TOMO__MAINNET_PRIVATE_KEY to your Ethereum client's private key
```
9. Register operators on smart contract
```
node scripts/register_operators.js {network}
```
network can be `mainnet`, `homestead`, `rinkeby` or `local`.
This command will deploy smart contract to your local blockchain (--network development)

OR

We should choose `local` for current deployment
10. Register reward account on smart contract
```
node scripts/register_reward_account.js {network}
truffle migrate --network tomochainTestnet
```
network can be `mainnet`, `homestead`, `rinkeby` or `local`.
This command will deploy smart contract to Tomochain Testnet

We should choose `local` for current deployment
OR

----------------
## IV. dex-client
1. Clone it:
```
git clone git@github.com:tomochain/dex-client.git
```
2. Install dependencies
```
yarn
truffle migrate --network tomochain
```
3. Install `sass`:
```
https://sass-lang.com/install
```
4. Copy token addresses into file `src/config/addresses.json`:
```
yarn query-tokens
```
5. Start the development server
```
yarn start
```
This command will also compile sass files
This command will deploy smart contract to Tomochain Mainnet (but don't use for now)

----------------
## V. dex-server
## IV. dex-server
1. Clone it:
```
git clone git@github.com:tomochain/dex-server.git
@@ -117,11 +57,7 @@ git clone git@github.com:tomochain/dex-server.git
```
yarn install-requirements
```
4. Go to `dex-server` directory, run this command:
```
ln -sF $PWD $GOPATH/src/github.com/tomochain/backend-matching-engine
```
5. Run docker environment
4. Run docker environment
```
yarn start-env
```
@@ -130,6 +66,14 @@ OR
yarn reset-env
```
in case you want to reset MongoDB, Redis, RabbitMQ data

5. Update file `seed-data.sh`
```
Update line 2. NETWORK="development" with your network of choice
It can be "development", "tomochainTestnet" or "tomochain"
```

6. Generate seed and import seed data into mongo
```
yarn seeds
@@ -140,24 +84,28 @@ yarn start
```

----------------
# DONE

## Reset in case something went wrong
1. Manually delete 2 folders `.data_30100` and `.data_30101` inside folder `dex-protocol` (these 2 folders are hidden)
## V. dex-client
1. Clone it:
```
cd dex-protocol
rm -rf .data_*
git clone git@github.com:tomochain/dex-client.git
```
2. Do everything from point II. dex-protocol except some commands such as:
2. Install dependencies
```
git clone ...
yarn
```
3. Install `sass`:
```
ln -sF ...
https://sass-lang.com/install
```
4. Copy token addresses into file `src/config/addresses.json`:
```
git reset ...
yarn query-tokens
```
5. Start the development server
```
yarn install-requirements
yarn start
```
This command will also compile sass files

----------------
## DONE
@@ -7,9 +7,6 @@ If you have already put smart contracts in genesis block, just change the code f
`truffle migrate -f 3 --to 3 --network development`
Otherwise just run `truffle deploy --network development`

## Update code for server
`truffle compile && node scripts/generateExchangeGo.js ../dex-server/contracts/contractsinterfaces/exchange.go`

## Architecture

The smart contract samples used to deploy in creation block. The tokens contracts for selling and buying, and the Exchange contract used to allows two users to interact with. There is no matching engine logic inside the exchange contract, it is supposed to have trade logic only.

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 7af14cc

Please sign in to comment.
You can’t perform that action at this time.