Skip to content

Commit

Permalink
Merge pull request EOSIO#133 from enumivo/staging
Browse files Browse the repository at this point in the history
rename EOS
  • Loading branch information
Enumivo committed May 18, 2018
2 parents b667cf4 + 6714966 commit 563c3f5
Show file tree
Hide file tree
Showing 49 changed files with 604 additions and 604 deletions.
2 changes: 1 addition & 1 deletion Docker/config.ini
Expand Up @@ -79,7 +79,7 @@ required-participation = 33
# producer-name =

# Tuple of [public key, WIF private key] (may specify multiple times)
private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]
private-key = ["ENU6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]

# Plugin(s) to enable, may be specified multiple times
# plugin =
Expand Down
2 changes: 1 addition & 1 deletion Docker/docker-compose-dawn4.0.yaml
Expand Up @@ -11,7 +11,7 @@ services:

nodeosd:
image: enumivo/eos:latest
command: /opt/enumivo/bin/nodeosd.sh --data-dir /opt/enumivo/bin/data-dir --resync --mongodb-uri mongodb://mongo:27017/EOS
command: /opt/enumivo/bin/nodeosd.sh --data-dir /opt/enumivo/bin/data-dir --resync --mongodb-uri mongodb://mongo:27017/ENU
hostname: nodeosd
links:
- mongo
Expand Down
62 changes: 31 additions & 31 deletions EXCHANGE_README.md
Expand Up @@ -51,19 +51,19 @@ a couple of minutes, but either way enunode will keep you posted on the status.

## Initial Condition
```
./enucli get currency balance enumivo.coin scott EOS
900.0000 EOS
./enucli get currency balance enumivo.coin scott ENU
900.0000 ENU
```

We will now deposit some funds to exchange:

```
./enucli transfer scott exchange "1.0000 EOS"
./enucli transfer scott exchange "1.0000 ENU"
executed transaction: 5ec797175dd24612acd8fc5a8685fa44caa8646cec0a87b12568db22a3df02fb 256 bytes 8k cycles
# enumivo.coin <= enumivo.coin::transfer {"from":"scott","to":"exchange","quantity":"1.0000 EOS","memo":""}
# enumivo.coin <= enumivo.coin::transfer {"from":"scott","to":"exchange","quantity":"1.0000 ENU","memo":""}
>> transfer
# scott <= enumivo.coin::transfer {"from":"scott","to":"exchange","quantity":"1.0000 EOS","memo":""}
# exchange <= enumivo.coin::transfer {"from":"scott","to":"exchange","quantity":"1.0000 EOS","memo":""}
# scott <= enumivo.coin::transfer {"from":"scott","to":"exchange","quantity":"1.0000 ENU","memo":""}
# exchange <= enumivo.coin::transfer {"from":"scott","to":"exchange","quantity":"1.0000 ENU","memo":""}
warning: transaction executed locally, but may not be confirmed by the network yet
```

Expand All @@ -83,7 +83,7 @@ can tell whether a transaction is confirmed or not by the first character, '#' f
./enucli get actions exchange
# seq when contract::action => receiver trx id... args
================================================================================================================
# 0 2018-04-29T01:09:45.000 enumivo.coin::transfer => exchange 5ec79717... {"from":"scott","to":"exchange","quantity":"1.0000 EOS","mem...
# 0 2018-04-29T01:09:45.000 enumivo.coin::transfer => exchange 5ec79717... {"from":"scott","to":"exchange","quantity":"1.0000 ENU","mem...
```

Do a few more transfers:
Expand All @@ -92,9 +92,9 @@ Do a few more transfers:
./enucli get actions exchange
# seq when contract::action => receiver trx id... args
================================================================================================================
# 0 2018-04-29T01:09:45.000 enumivo.coin::transfer => exchange 5ec79717... {"from":"scott","to":"exchange","quantity":"1.0000 EOS","mem...
# 1 2018-04-29T01:16:25.000 enumivo.coin::transfer => exchange 2269828c... {"from":"scott","to":"exchange","quantity":"1.0000 EOS","mem...
? 2 2018-04-29T01:19:54.000 enumivo.coin::transfer => exchange 213f3797... {"from":"scott","to":"exchange","quantity":"1.0000 EOS","mem...
# 0 2018-04-29T01:09:45.000 enumivo.coin::transfer => exchange 5ec79717... {"from":"scott","to":"exchange","quantity":"1.0000 ENU","mem...
# 1 2018-04-29T01:16:25.000 enumivo.coin::transfer => exchange 2269828c... {"from":"scott","to":"exchange","quantity":"1.0000 ENU","mem...
? 2 2018-04-29T01:19:54.000 enumivo.coin::transfer => exchange 213f3797... {"from":"scott","to":"exchange","quantity":"1.0000 ENU","mem...
```

The last transfer is still pending, waiting on irreversibility.
Expand Down Expand Up @@ -126,7 +126,7 @@ To get only the last action you would do the following...
./enucli get actions exchange -1 -1
# seq when contract::action => receiver trx id... args
================================================================================================================
# 2 2018-04-29T01:19:54.000 enumivo.coin::transfer => exchange 213f3797... {"from":"scott","to":"exchange","quantity":"1.0000 EOS","mem...
# 2 2018-04-29T01:19:54.000 enumivo.coin::transfer => exchange 213f3797... {"from":"scott","to":"exchange","quantity":"1.0000 ENU","mem...
```

This says go to the last sequence number (indicated by pos = -1) and then fetch "1" item prior to it (offset = -1). This should
Expand All @@ -144,7 +144,7 @@ We pass pos=1 and offset=0 to get the range [1,1+0] or [1,1].
./enucli get actions exchange 1 0
# seq when contract::action => receiver trx id... args
================================================================================================================
# 1 2018-04-29T01:16:25.000 enumivo.coin::transfer => exchange 2269828c... {"from":"scott","to":"exchange","quantity":"1.0000 EOS","mem...
# 1 2018-04-29T01:16:25.000 enumivo.coin::transfer => exchange 2269828c... {"from":"scott","to":"exchange","quantity":"1.0000 ENU","mem...
```

We can call this in a loop procesing each confirmed action (those starting with #) until we either run out of items or
Expand Down Expand Up @@ -194,7 +194,7 @@ Here is the JSON returned when querying sequence 2.
"data": {
"from": "scott",
"to": "exchange",
"quantity": "1.0000 EOS",
"quantity": "1.0000 ENU",
"memo": ""
},
"hex_data": "00000000809c29c20000008a4dd35057102700000000000004454f530000000000"
Expand All @@ -219,7 +219,7 @@ You can identify irreversible deposits by the following:
```
actions[0].action_trace.act.account == "enumivo.coin" &&
actions[0].action_trace.act.name == "transfer" &&
actions[0].action_trace.act.data.quantity == "X.0000 EOS" &&
actions[0].action_trace.act.data.quantity == "X.0000 ENU" &&
actions[0].action_trace.to == "exchange" &&
actions[0].action_trace.memo == "KEY TO IDENTIFY INTERNAL ACCOUNT" &&
actions[0].action_trace.receipt.receiver == "exchange" &&
Expand All @@ -242,30 +242,30 @@ then you may process "false deposits".

### Validating Balance

Now that we have received 3 deposits we should see that the exchange has a balance of 3.0000 EOS.
Now that we have received 3 deposits we should see that the exchange has a balance of 3.0000 ENU.

```
./enucli get currency balance enumivo.coin exchange EOS
3.0000 EOS
./enucli get currency balance enumivo.coin exchange ENU
3.0000 ENU
```

# Processing Withdraws

(note, while generating this tutorial scott deposited another 1.0000 EOS (seq 3) for total exchange balance of 4.0000 EOS.)
(note, while generating this tutorial scott deposited another 1.0000 ENU (seq 3) for total exchange balance of 4.0000 ENU.)

When a user requests a withdraw from your exchange they will need to provide you with their enumivo account name and
the amount to be withdrawn. You can then run the enucli command which will interact with the "unlocked" wallet
running on `enunode` which should only enable localhost connections. More advanced usage would have a separate
key-server (`keos`), but that will be covered later.

Lets assume scott wants to withdraw `1.0000 EOS`:
Lets assume scott wants to withdraw `1.0000 ENU`:
```
./enucli transfer exchange scott "1.0000 EOS"
./enucli transfer exchange scott "1.0000 ENU"
executed transaction: 93e785202e7502bb1383ad10e786cc20f7dd738d3fd3da38712b3fb38fb9af26 256 bytes 8k cycles
# enumivo.coin <= enumivo.coin::transfer {"from":"exchange","to":"scott","quantity":"1.0000 EOS","memo":""}
# enumivo.coin <= enumivo.coin::transfer {"from":"exchange","to":"scott","quantity":"1.0000 ENU","memo":""}
>> transfer
# exchange <= enumivo.coin::transfer {"from":"exchange","to":"scott","quantity":"1.0000 EOS","memo":""}
# scott <= enumivo.coin::transfer {"from":"exchange","to":"scott","quantity":"1.0000 EOS","memo":""}
# exchange <= enumivo.coin::transfer {"from":"exchange","to":"scott","quantity":"1.0000 ENU","memo":""}
# scott <= enumivo.coin::transfer {"from":"exchange","to":"scott","quantity":"1.0000 ENU","memo":""}
warning: transaction executed locally, but may not be confirmed by the network yet
```

Expand All @@ -281,13 +281,13 @@ state transitions based upon the action.
./enucli get actions exchange -1 -8
# seq when contract::action => receiver trx id... args
================================================================================================================
# 0 2018-04-29T01:09:45.000 enumivo.coin::transfer => exchange 5ec79717... {"from":"scott","to":"exchange","quantity":"1.0000 EOS","mem...
# 1 2018-04-29T01:16:25.000 enumivo.coin::transfer => exchange 2269828c... {"from":"scott","to":"exchange","quantity":"1.0000 EOS","mem...
# 2 2018-04-29T01:19:54.000 enumivo.coin::transfer => exchange 213f3797... {"from":"scott","to":"exchange","quantity":"1.0000 EOS","mem...
# 3 2018-04-29T01:53:57.000 enumivo.coin::transfer => exchange 8b7766ac... {"from":"scott","to":"exchange","quantity":"1.0000 EOS","mem...
# 4 2018-04-29T01:54:17.500 enumivo.coin::transfer => enumivo.coin 93e78520... {"from":"exchange","to":"scott","quantity":"1.0000 EOS","mem...
# 5 2018-04-29T01:54:17.500 enumivo.coin::transfer => exchange 93e78520... {"from":"exchange","to":"scott","quantity":"1.0000 EOS","mem...
# 6 2018-04-29T01:54:17.500 enumivo.coin::transfer => scott 93e78520... {"from":"exchange","to":"scott","quantity":"1.0000 EOS","mem...
# 0 2018-04-29T01:09:45.000 enumivo.coin::transfer => exchange 5ec79717... {"from":"scott","to":"exchange","quantity":"1.0000 ENU","mem...
# 1 2018-04-29T01:16:25.000 enumivo.coin::transfer => exchange 2269828c... {"from":"scott","to":"exchange","quantity":"1.0000 ENU","mem...
# 2 2018-04-29T01:19:54.000 enumivo.coin::transfer => exchange 213f3797... {"from":"scott","to":"exchange","quantity":"1.0000 ENU","mem...
# 3 2018-04-29T01:53:57.000 enumivo.coin::transfer => exchange 8b7766ac... {"from":"scott","to":"exchange","quantity":"1.0000 ENU","mem...
# 4 2018-04-29T01:54:17.500 enumivo.coin::transfer => enumivo.coin 93e78520... {"from":"exchange","to":"scott","quantity":"1.0000 ENU","mem...
# 5 2018-04-29T01:54:17.500 enumivo.coin::transfer => exchange 93e78520... {"from":"exchange","to":"scott","quantity":"1.0000 ENU","mem...
# 6 2018-04-29T01:54:17.500 enumivo.coin::transfer => scott 93e78520... {"from":"exchange","to":"scott","quantity":"1.0000 ENU","mem...
```

By processing the history we can also be informed when our transaction was confirmed. In practice it may be useful to embed an exchange-specify memo
Expand All @@ -305,7 +305,7 @@ when you least expect.
By default enucli sets an expiration window of just 2 minutes. This is long enough to allow all 21 producers an opportunity to include the transaction.

```
./enucli transfer exchange scott "1.0000 EOS" -j -d
./enucli transfer exchange scott "1.0000 ENU" -j -d
{
"expiration": "2018-04-29T01:58:12",
"ref_block_num": 37282,
Expand Down
54 changes: 27 additions & 27 deletions contracts/dice/README.md
Expand Up @@ -5,8 +5,8 @@ This contract implements a simple DICE game between two players with 50/50 odds

Before playing all players deposit funds into their @dice account just like the @exchange contract

1. Player 1 proposes to bet 1 EOS and submits SHA256(secret1)
2. Player 2 proposes to bet 1 EOS and submits SHA256(secret2)
1. Player 1 proposes to bet 1 ENU and submits SHA256(secret1)
2. Player 2 proposes to bet 1 ENU and submits SHA256(secret2)

Because Player 1 and 2 bet equal amounts their orders are matched and the game begins.

Expand Down Expand Up @@ -76,9 +76,9 @@ enucli create account enumivo dice EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7
enucli set contract dice build/contracts/dice -p dice
````

##### Create native EOS token
##### Create native ENU token
````bash
enucli push action enumivo.coin create '[ "enumivo", "1000000000.0000 EOS", 0, 0, 0]' -p enumivo.coin
enucli push action enumivo.coin create '[ "enumivo", "1000000000.0000 ENU", 0, 0, 0]' -p enumivo.coin
````

##### Create alice account
Expand All @@ -91,34 +91,34 @@ enucli create account enumivo alice EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq
enucli create account enumivo bob EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
````

##### Issue 1000 EOS to alice
##### Issue 1000 ENU to alice
````bash
enucli push action enumivo.coin issue '[ "alice", "1000.0000 EOS", "" ]' -p enumivo
enucli push action enumivo.coin issue '[ "alice", "1000.0000 ENU", "" ]' -p enumivo
````

##### Issue 1000 EOS to bob
##### Issue 1000 ENU to bob
````bash
enucli push action enumivo.coin issue '[ "bob", "1000.0000 EOS", "" ]' -p enumivo
enucli push action enumivo.coin issue '[ "bob", "1000.0000 ENU", "" ]' -p enumivo
````

##### Allow dice contract to make transfers on alice behalf (deposit)
````bash
enucli set account permission alice active '{"threshold": 1,"keys": [{"key": "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4","weight": 1}],"accounts": [{"permission":{"actor":"dice","permission":"active"},"weight":1}]}' owner -p alice
enucli set account permission alice active '{"threshold": 1,"keys": [{"key": "ENU7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4","weight": 1}],"accounts": [{"permission":{"actor":"dice","permission":"active"},"weight":1}]}' owner -p alice
````

##### Allow dice contract to make transfers on bob behalf (deposit)
````bash
enucli set account permission bob active '{"threshold": 1,"keys": [{"key": "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4","weight": 1}],"accounts": [{"permission":{"actor":"dice","permission":"active"},"weight":1}]}' owner -p bob
enucli set account permission bob active '{"threshold": 1,"keys": [{"key": "ENU7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4","weight": 1}],"accounts": [{"permission":{"actor":"dice","permission":"active"},"weight":1}]}' owner -p bob
````

##### Alice deposits 100 EOS into the dice contract
##### Alice deposits 100 ENU into the dice contract
````bash
enucli push action dice deposit '[ "alice", "100.0000 EOS" ]' -p alice
enucli push action dice deposit '[ "alice", "100.0000 ENU" ]' -p alice
````

##### Bob deposits 100 EOS into the dice contract
##### Bob deposits 100 ENU into the dice contract
````bash
enucli push action dice deposit '[ "bob", "100.0000 EOS" ]' -p bob
enucli push action dice deposit '[ "bob", "100.0000 ENU" ]' -p bob
````

##### Alice generates a secret
Expand All @@ -133,9 +133,9 @@ echo -n '28349b1d4bcdc9905e4ef9719019e55743c84efa0c5e9a0b077f0b54fcd84905' | xxd
d533f24d6f28ddcef3f066474f7b8355383e485681ba8e793e037f5cf36e4883
````

##### Alice bets 3 EOS
##### Alice bets 3 ENU
````bash
enucli push action dice offerbet '[ "3.0000 EOS", "alice", "d533f24d6f28ddcef3f066474f7b8355383e485681ba8e793e037f5cf36e4883" ]' -p alice
enucli push action dice offerbet '[ "3.0000 ENU", "alice", "d533f24d6f28ddcef3f066474f7b8355383e485681ba8e793e037f5cf36e4883" ]' -p alice
````

##### Bob generates a secret
Expand All @@ -150,9 +150,9 @@ echo -n '15fe76d25e124b08feb835f12e00a879bd15666a33786e64b655891fba7d6c12' | xxd
50ed53fcdaf27f88d51ea4e835b1055efe779bb87e6cfdff47d28c88ffb27129
````

##### Bob also bets 3 EOS (a game is started)
##### Bob also bets 3 ENU (a game is started)
````bash
enucli push action dice offerbet '[ "3.0000 EOS", "bob", "50ed53fcdaf27f88d51ea4e835b1055efe779bb87e6cfdff47d28c88ffb27129" ]' -p bob
enucli push action dice offerbet '[ "3.0000 ENU", "bob", "50ed53fcdaf27f88d51ea4e835b1055efe779bb87e6cfdff47d28c88ffb27129" ]' -p bob
````

##### Dice contract tables right after the game started
Expand All @@ -163,12 +163,12 @@ enucli get table dice dice account
{
"rows": [{
"owner": "alice",
"enu_balance": "97.0000 EOS",
"enu_balance": "97.0000 ENU",
"open_offers": 0,
"open_games": 1
},{
"owner": "bob",
"enu_balance": "97.0000 EOS",
"enu_balance": "97.0000 ENU",
"open_offers": 0,
"open_games": 1
}
Expand All @@ -184,7 +184,7 @@ enucli get table dice dice game
{
"rows": [{
"id": 1,
"bet": "3.0000 EOS",
"bet": "3.0000 ENU",
"deadline": "1970-01-01T00:00:00",
"player1": {
"commitment": "d533f24d6f28ddcef3f066474f7b8355383e485681ba8e793e037f5cf36e4883",
Expand Down Expand Up @@ -213,7 +213,7 @@ enucli get table dice dice game
{
"rows": [{
"id": 1,
"bet": "3.0000 EOS",
"bet": "3.0000 ENU",
"deadline": "2018-04-17T07:45:49",
"player1": {
"commitment": "d533f24d6f28ddcef3f066474f7b8355383e485681ba8e793e037f5cf36e4883",
Expand Down Expand Up @@ -242,12 +242,12 @@ enucli get table dice dice account
{
"rows": [{
"owner": "alice",
"enu_balance": "103.0000 EOS",
"enu_balance": "103.0000 ENU",
"open_offers": 0,
"open_games": 0
},{
"owner": "bob",
"enu_balance": "97.0000 EOS",
"enu_balance": "97.0000 ENU",
"open_offers": 0,
"open_games": 0
}
Expand All @@ -256,14 +256,14 @@ enucli get table dice dice account
}
````

##### Alice withdraw from her dice account 103 EOS
##### Alice withdraw from her dice account 103 ENU
````bash
enucli push action dice withdraw '[ "alice", "103.0000 EOS" ]' -p alice
enucli push action dice withdraw '[ "alice", "103.0000 ENU" ]' -p alice
````

##### Balance of alice after withdraw
````bash
enucli get currency balance enumivo.coin alice enu
1003.0000 EOS
1003.0000 ENU
````

2 changes: 1 addition & 1 deletion contracts/dice/dice.cpp
Expand Up @@ -35,7 +35,7 @@ class dice : public enumivo::contract {
//@abi action
void offerbet(const asset& bet, const account_name player, const checksum256& commitment) {

enumivo_assert( bet.symbol == S(4,EOS) , "only EOS token allowed" );
enumivo_assert( bet.symbol == S(4,ENU) , "only ENU token allowed" );
enumivo_assert( bet.is_valid(), "invalid bet" );
enumivo_assert( bet.amount > 0, "must bet positive quantity" );

Expand Down
6 changes: 3 additions & 3 deletions contracts/enumivo.msig/README.md
Expand Up @@ -46,13 +46,13 @@ enucli usage example.

Prerequisites:
- enumivo.coin contract installed to enumivo.coin accountm, enumivo.msig contract installed on enumivo.msig account which is a priviliged account.
- account 'treasury' is the issuer of EOS token.
- account 'treasury' is the issuer of ENU token.
- account 'tester' exists.
- keys to accounts 'treasury' and 'tester' imported into local wallet, the wallet is unlocked.

One user creates a proposal:
````
$ enucli multisig propose test '[{"actor": "treasury", "permission": "active"}]' '[{"actor": "treasury", "permission": "active"}]' enumivo.coin issue '{"to": "tester", "quantity": "1000.0000 EOS", "memo": ""}' -p tester
$ enucli multisig propose test '[{"actor": "treasury", "permission": "active"}]' '[{"actor": "treasury", "permission": "active"}]' enumivo.coin issue '{"to": "tester", "quantity": "1000.0000 ENU", "memo": ""}' -p tester
executed transaction: e26f3a3a7cba524a7b15a0b6c77c7daa73d3ba9bf84e83f9c2cdf27fcb183d61 336 bytes 107520 cycles
# enumivo.msig <= enumivo.msig::propose {"proposer":"tester","proposal_name":"test","requested":[{"actor":"treasury","permission":"active"}]...
````
Expand Down Expand Up @@ -88,7 +88,7 @@ $ enucli multisig review tester test -p treasury
],
"data": {
"to": "tester",
"quantity": "1000.0000 EOS",
"quantity": "1000.0000 ENU",
"memo": ""
},
"hex_data": "000000005c95b1ca809698000000000004454f530000000000"
Expand Down

0 comments on commit 563c3f5

Please sign in to comment.