Skip to content

Commit

Permalink
Merge pull request #131 from MonsterEOS/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
leordev authored Oct 5, 2018
2 parents 3e95676 + 7772c08 commit 6d3218b
Show file tree
Hide file tree
Showing 18 changed files with 67,457 additions and 19,396 deletions.
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,21 @@ cd monstereos

We structured everything in microservices and it can be automagically initialized by docker! Don't be afraid of docker, a lot of people hear docker and run away but we already did the hard part (configuration) for you. You will just need to install docker in your computer (a simple installer that you will press next next next finish lol).

After you installed docker just run the following single command:
After you installed docker just run the following commands:

**Start docker container**
```
docker-compose up -d
docker-compose run demux yarn _migrate # credentials: user // pass (for three steps)
docker restart monstereos_demux_1
```

docker exec -it monstereos_eosiodev_1 /bin/sh
**Create postgres database and init chain and monster data**
```
./setup.sh
```

cd /opt/application/scripts
./0000_init-chain.sh
./0010_load-elements.sh
./0020_load-pet-types.sh
./0030_load-data.sh
**Restart docker container**
```
docker-compose restart
```

Open Kitematic (a nice UI for docker containers management that comes by default on docker installation) and you will see all the containers running:
Expand All @@ -113,7 +114,10 @@ Open Kitematic (a nice UI for docker containers management that comes by default
- fullnode: this is a node that will simulate your mainnet fullnode that will listen for the blockchain and persist data in mongo with mongodb_plugin
- mongo: this is our chain database, fed by fullnode
- postgres: this is our database, the chain is the source of truth, and this is just a cache layer to help our application to query nice and fast reports
- demux: this is the blockchain watcher, demux is a tool from Block.one that allows us to watch the blockchain data through MongoDB, manage state saving records to database and also any side effects as submit emails, notifications, external apis etc <3 - we serve data with GraphQL out-of-the-box through postgraphile under port 3030
- demux: The backend for monstereosio, it consists of the following node services (using pm2):
- demux: this is the blockchain watcher, demux is a tool from Block.one that allows us to watch the blockchain data through MongoDB, manage state saving records to database and also any side effects as submit emails, notifications, external apis etc <3
- postgraphile: we serve data with GraphQL out-of-the-box through postgraphile under port 3030
- data-cleaner: updates data about monsters and battle arenas according to our business rules

### Frontend App: UI

Expand All @@ -130,3 +134,10 @@ Feel free to build any other apps and/or dockerize it. We didn't create a docker
### EOS Dream Stack

You can build any Dapp using the above structure. Tweak the structure a little bit to satisfy all your needs, i.e.: you can change the postgres for other database as mongo or mysql; you might not need demux and the backend if your app is very basic, allowing the frontend to read directly from the chain; change the frontend to whatever framework you want to use as Vue or Angular, not only this but your frontend can be a mobile native app, why not?

### Notes
* mongo and postgres data is stored in parent folder of this git repo under `.monstereos`
* eos data is stored in the docker volume `monstereos_eosiodevapp`
* to compile the contract you need to use `eosio.cdt` and build it using `make`
* to change postgres schema run `yarn migrate` from console (outside docker) in folder `services/demux`.

1 change: 1 addition & 0 deletions services/eos-dev/scripts/0010_load-elements.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
/opt/application/scripts/init_wallet.sh

ROOT_DIR="/opt/eosio/bin"
cd $ROOT_DIR
Expand Down
1 change: 1 addition & 0 deletions services/eos-dev/scripts/0020_load-pet-types.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
/opt/application/scripts/init_wallet.sh

# add pets types
cleos -u http://eosiodev:8888 push action monstereosio addpettype '{ "elements": [0,6] }' -p monstereosio
Expand Down
1 change: 1 addition & 0 deletions services/eos-dev/scripts/0030_load-data.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
/opt/application/scripts/init_wallet.sh

# monsters creation
echo "\ncreating few monsters"
Expand Down
44 changes: 0 additions & 44 deletions services/eos-dev/scripts/0040_init-market.sh

This file was deleted.

51 changes: 51 additions & 0 deletions services/eos-dev/scripts/init_wallet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

CONFIG_DIR="/opt/application/config"

EOSIO_PRIVATE_KEY="5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
EOSIO_PUBLIC_KEY="EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"

EOSIO_SYS_PUBKEY="EOS8VJybqtm41PMmXL1QUUDSfCrs9umYN4U1ZNa34JhPZ9mU5r2Cm"
EOSIO_SYS_PVTKEY="5JGxnezvp3N4V1NxBo8LPBvCrdR85bZqZUFvBZ8ACrbRC3ZWNYv"

MONSTERS_ACCOUNT_PRIVATE_OWNER_KEY="5J5t5MuUmMgNcrFWiXyeBZEsCfHvgYE7Lec4W2wCaV5SiSoEqQr"
MONSTERS_ACCOUNT_PUBLIC_OWNER_KEY="EOS6P62N6D14ShhUnM7taEQHLTMmS7ohCyfikwAi46U7AT6jmUHyM"

MONSTERS_ACCOUNT_PRIVATE_ACTIVE_KEY="5JhTPDSe9ugHomFnhMgAdzzE2HniuR8rG3SyzzqvQrgJNPC4685"
MONSTERS_ACCOUNT_PUBLIC_ACTIVE_KEY="EOS5X6m7mxcKRsKvHDyCVp1DE5YAy5dEsb5TwFqG4F2xRvRYAAdZx"

MONSTERS_USERA_ACCOUNT="monsterusera"
MONSTERS_USERA_PVTKEY="5K4MHQN7sPdEURaxzjCnbynUwkEKRJzs8zVUf24ofaFiZNK815J"
MONSTERS_USERA_PUBKEY="EOS5k6Jht1epqZ2mnRLFVDXDTosaTneR6xFhvenVLiFfz5Ue125dL"

MONSTERS_USERB_ACCOUNT="monsteruserb"
MONSTERS_USERB_PVTKEY="5JHCQDi7jsbnQnWdyxteRjT2DdNZHePiEG1DTaPQQDDP2X6aor6"
MONSTERS_USERB_PUBKEY="EOS6TVQ6EmphCWavUuYiZMmDNYMRgbb96wgqWDncjrkvFPcpokgdD"

MONSTERS_USERC_ACCOUNT="monsteruserc"
MONSTERS_USERC_PVTKEY="5JXCt633pzYaUysn7exDHeVXwhwMjX2L231b37CdsSb7y1uvDH7"
MONSTERS_USERC_PUBKEY="EOS7CB47VMLWp49QhajE3uTuHuf9qoSeR6scUHMKGCD6LXYufRUDc"

MONSTERS_USERD_ACCOUNT="monsteruserd"
MONSTERS_USERD_PVTKEY="5JdRgeRBriBDdxb3r76sLJaQmwGgXkMU8GReTAmy8xYppMSAAoZ"
MONSTERS_USERD_PUBKEY="EOS6Jv4RykLZQQopCBdBHSwaGoMyFxyaxFNXimqFPdEXNWqgWbG1a"

MONSTERS_USERE_ACCOUNT="monsterusere"
MONSTERS_USERE_PVTKEY="5Jdwjwto9wxy5ZNPnWSn965eb8ZtSrK1uRKUxhviLpr9gK79hmM"
MONSTERS_USERE_PUBKEY="EOS5VdFvRRTtVQAPUJZQCYvpBekYV4nc1cFe7og9aYPTBMXZ38Koy"

# start wallet
wallet_password=$(./cleos wallet create --to-console | awk 'FNR > 3 { print $1 }' | tr -d '"')
echo $wallet_password > "$CONFIG_DIR"/keys/default_wallet_password.txt

# import wallet keys
sleep 2s
./cleos wallet import -n default --private-key $EOSIO_PRIVATE_KEY
./cleos wallet import -n default --private-key $EOSIO_SYS_PVTKEY
./cleos wallet import -n default --private-key $MONSTERS_ACCOUNT_PRIVATE_OWNER_KEY
./cleos wallet import -n default --private-key $MONSTERS_ACCOUNT_PRIVATE_ACTIVE_KEY
./cleos wallet import -n default --private-key $MONSTERS_USERA_PVTKEY
./cleos wallet import -n default --private-key $MONSTERS_USERB_PVTKEY
./cleos wallet import -n default --private-key $MONSTERS_USERC_PVTKEY
./cleos wallet import -n default --private-key $MONSTERS_USERD_PVTKEY
./cleos wallet import -n default --private-key $MONSTERS_USERE_PVTKEY
33 changes: 18 additions & 15 deletions services/eos-dev/scripts/tests-market.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,42 @@

MONSTERS_USERA_ACCOUNT="monsterusera"

# unlock wallet
cleos wallet unlock < ../config/keys/default_wallet_password.txt

echo "make offer and remove it"
cleos -u http://eosiodev:8888 push action monstereosmt offerpet '[1, "", "1.0000 EOS"]' -p monsterusera
cleos -u http://eosiodev:8888 get table monstereosmt monstereosmt offers -l 100
cleos -u http://eosiodev:8888 push action monstereosio orderask '[1, "", "1.0000 EOS"]' -p monsterusera
cleos -u http://eosiodev:8888 get table monstereosio monstereosio orders -l 100
cleos -u http://eosiodev:8888 get table monstereosio monstereosio pets -l 100

cleos -u http://eosiodev:8888 push action monstereosmt removeoffer '["monsterusera", 1]' -p monsterusera
cleos -u http://eosiodev:8888 get table monstereosmt monstereosmt offers -l 100
cleos -u http://eosiodev:8888 push action monstereosio removeask '["monsterusera", 1]' -p monsterusera
cleos -u http://eosiodev:8888 get table monstereosio monstereosio orders -l 100

sleep .5

# offer pet and claim pet
echo "make offer and claim it and reverse it"
echo "monster 1 offered by monsterusera claimed by monsteruserb"
cleos -u http://eosiodev:8888 get table monstereosio monstereosio pets -l 1
cleos -u http://eosiodev:8888 push action monstereosmt offerpet '[1, "monsteruserb", "0.0000 EOS", 0]' -p monsterusera
cleos -u http://eosiodev:8888 push action monstereosmt claimpet '["monsterusera", 1, "monsteruserb"]' -p monsteruserb
cleos -u http://eosiodev:8888 push action monstereosio orderask '[1, "monsteruserb", "0.0000 EOS", 0]' -p monsterusera
cleos -u http://eosiodev:8888 push action monstereosio claimpet '["monsterusera", 1, "monsteruserb"]' -p monsteruserb

echo "monster 1 belongs to monsteruserb"
cleos -u http://eosiodev:8888 get table monstereosio monstereosio pets -l 1

echo "monster 1 offered by monsteruserb, claimed by monsterusera"
cleos -u http://eosiodev:8888 push action monstereosmt offerpet '[1, "monsterusera", "0.0000 EOS", 0]' -p monsteruserb
cleos -u http://eosiodev:8888 push action monstereosmt claimpet '["monsteruserb", 1, "monsterusera"]' -p monsterusera
cleos -u http://eosiodev:8888 push action monstereosio orderask '[1, "monsterusera", "0.0000 EOS", 0]' -p monsteruserb
cleos -u http://eosiodev:8888 push action monstereosio claimpet '["monsteruserb", 1, "monsterusera"]' -p monsterusera

echo "no offers left"
cleos -u http://eosiodev:8888 get table monstereosmt monstereosmt offers -l 1
echo "no orders left"
cleos -u http://eosiodev:8888 get table monstereosio monstereosio orders -l 1
echo "monster 1 back to monsterusera"
cleos -u http://eosiodev:8888 get table monstereosio monstereosio pets -l 1

sleep .5
cleos -u http://eosiodev:8888 push action monstereosmt offerpet '[1, "monsteruserb", "1.0000 EOS", 0]' -p monsterusera
cleos -u http://eosiodev:8888 push action monstereosio orderask '[1, "monsteruserb", "1.0000 EOS", 0]' -p monsterusera
echo "one offers for monsteruserb"
cleos -u http://eosiodev:8888 get table monstereosmt monstereosmt offers -l 1
cleos -u http://eosiodev:8888 get table monstereosio monstereosio orders -l 1

# add some money for buying monsters
cleos -u http://eosiodev:8888 transfer eosio monsterusera "1000.0000 EOS"
Expand All @@ -47,11 +50,11 @@ sleep .5
cleos -u http://eosiodev:8888 push action eosio.token transfer '["monsteruserb", "monstereosio", "1.0000 EOS", "MTT0"]' -p monsteruserb
echo "monster 1 to monsteruserb"
cleos -u http://eosiodev:8888 get table monstereosio monstereosio pets -l 1
echo "no offers left"
cleos -u http://eosiodev:8888 get table monstereosmt monstereosmt offers -l 1
echo "no orders left"
cleos -u http://eosiodev:8888 get table monstereosio monstereosio orders -l 1

echo "and reverse"
cleos -u http://eosiodev:8888 push action monstereosmt offerpet '[1, "monsterusera", "1.0000 EOS", 0]' -p monsteruserb
cleos -u http://eosiodev:8888 push action monstereosio orderask '[1, "monsterusera", "1.0000 EOS", 0]' -p monsteruserb
cleos -u http://eosiodev:8888 push action eosio.token transfer '["monsterusera", "monstereosio", "1.0000 EOS", "MTT1"]' -p monsterusera

echo "monster 1 to monsterusera"
Expand Down
8 changes: 0 additions & 8 deletions services/eos-node/Dockerfile

This file was deleted.

Loading

0 comments on commit 6d3218b

Please sign in to comment.