Skip to content

Commit

Permalink
Merge pull request EOSIO#129 from enumivo/staging
Browse files Browse the repository at this point in the history
rename eos
  • Loading branch information
Enumivo authored May 18, 2018
2 parents 8743be5 + 69630cb commit e985cd8
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 91 deletions.
8 changes: 4 additions & 4 deletions contracts/dice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ enucli get table dice dice account
{
"rows": [{
"owner": "alice",
"eos_balance": "97.0000 EOS",
"enu_balance": "97.0000 EOS",
"open_offers": 0,
"open_games": 1
},{
"owner": "bob",
"eos_balance": "97.0000 EOS",
"enu_balance": "97.0000 EOS",
"open_offers": 0,
"open_games": 1
}
Expand Down Expand Up @@ -242,12 +242,12 @@ enucli get table dice dice account
{
"rows": [{
"owner": "alice",
"eos_balance": "103.0000 EOS",
"enu_balance": "103.0000 EOS",
"open_offers": 0,
"open_games": 0
},{
"owner": "bob",
"eos_balance": "97.0000 EOS",
"enu_balance": "97.0000 EOS",
"open_offers": 0,
"open_games": 0
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/dice/dice.abi
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"name": "owner",
"type": "account_name"
},{
"name": "eos_balance",
"name": "enu_balance",
"type": "asset"
},{
"name": "open_offers",
Expand Down
24 changes: 12 additions & 12 deletions contracts/dice/dice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class dice : public enumivo::contract {

// No matching bet found, update player's account
accounts.modify( cur_player_itr, 0, [&](auto& acnt) {
enumivo_assert( acnt.eos_balance >= bet, "insufficient balance" );
acnt.eos_balance -= bet;
enumivo_assert( acnt.enu_balance >= bet, "insufficient balance" );
acnt.enu_balance -= bet;
acnt.open_offers++;
});

Expand Down Expand Up @@ -114,8 +114,8 @@ class dice : public enumivo::contract {
});

accounts.modify( cur_player_itr, 0, [&](auto& acnt) {
enumivo_assert( acnt.eos_balance >= bet, "insufficient balance" );
acnt.eos_balance -= bet;
enumivo_assert( acnt.enu_balance >= bet, "insufficient balance" );
acnt.enu_balance -= bet;
acnt.open_games++;
});
}
Expand All @@ -134,7 +134,7 @@ class dice : public enumivo::contract {
auto acnt_itr = accounts.find(offer_itr->owner);
accounts.modify(acnt_itr, 0, [&](auto& acnt){
acnt.open_offers--;
acnt.eos_balance += offer_itr->bet;
acnt.enu_balance += offer_itr->bet;
});

idx.erase(offer_itr);
Expand Down Expand Up @@ -232,7 +232,7 @@ class dice : public enumivo::contract {
).send();

accounts.modify( itr, 0, [&]( auto& acnt ) {
acnt.eos_balance += quantity;
acnt.enu_balance += quantity;
});
}

Expand All @@ -247,8 +247,8 @@ class dice : public enumivo::contract {
enumivo_assert(itr != accounts.end(), "unknown account");

accounts.modify( itr, 0, [&]( auto& acnt ) {
enumivo_assert( acnt.eos_balance >= quantity, "insufficient balance" );
acnt.eos_balance -= quantity;
enumivo_assert( acnt.enu_balance >= quantity, "insufficient balance" );
acnt.enu_balance -= quantity;
});

action(
Expand Down Expand Up @@ -329,15 +329,15 @@ class dice : public enumivo::contract {
account( account_name o = account_name() ):owner(o){}

account_name owner;
asset eos_balance;
asset enu_balance;
uint32_t open_offers = 0;
uint32_t open_games = 0;

bool is_empty()const { return !( eos_balance.amount | open_offers | open_games ); }
bool is_empty()const { return !( enu_balance.amount | open_offers | open_games ); }

uint64_t primary_key()const { return owner; }

ENULIB_SERIALIZE( account, (owner)(eos_balance)(open_offers)(open_games) )
ENULIB_SERIALIZE( account, (owner)(enu_balance)(open_offers)(open_games) )
};

typedef enumivo::multi_index< N(account), account> account_index;
Expand Down Expand Up @@ -368,7 +368,7 @@ class dice : public enumivo::contract {
// Update winner account balance and game count
auto winner_account = accounts.find(winner_offer.owner);
accounts.modify( winner_account, 0, [&]( auto& acnt ) {
acnt.eos_balance += 2*g.bet;
acnt.enu_balance += 2*g.bet;
acnt.open_games--;
});

Expand Down
6 changes: 3 additions & 3 deletions contracts/enumivolib/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void assert_sha256( char* data, uint32_t length, const checksum256* hash );
*
* checksum calc_hash;
* sha1( data, length, &calc_hash );
* eos_assert( calc_hash == hash, "invalid hash" );
* enu_assert( calc_hash == hash, "invalid hash" );
*
* This method is optimized to a NO-OP when in fast evaluation mode
*/
Expand All @@ -32,7 +32,7 @@ void assert_sha1( char* data, uint32_t length, const checksum160* hash );
*
* checksum calc_hash;
* sha512( data, length, &calc_hash );
* eos_assert( calc_hash == hash, "invalid hash" );
* enu_assert( calc_hash == hash, "invalid hash" );
*
* This method is optimized to a NO-OP when in fast evaluation mode
*/
Expand All @@ -43,7 +43,7 @@ void assert_sha512( char* data, uint32_t length, const checksum512* hash );
*
* checksum calc_hash;
* ripemd160( data, length, &calc_hash );
* eos_assert( calc_hash == hash, "invalid hash" );
* enu_assert( calc_hash == hash, "invalid hash" );
*
* This method is optimized to a NO-OP when in fast evaluation mode
*/
Expand Down
2 changes: 1 addition & 1 deletion contracts/enumivolib/rpc.dox
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ $ curl http://127.0.0.1:8888/v1/chain/get_account -X POST -d '{"account_name":"
```
{
"name": "inita",
"eos_balance": "999998.9574 EOS",
"enu_balance": "999998.9574 EOS",
"staked_balance": "0.0000 EOS",
"unstaking_balance": "0.0000 EOS",
"last_unstaking_time": "2106-02-07T06:28:15",
Expand Down
88 changes: 44 additions & 44 deletions libraries/chain/enumivo_contract_abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ namespace enumivo { namespace chain {

abi_def enumivo_contract_abi(const abi_def& enumivo_system_abi)
{
abi_def eos_abi(enumivo_system_abi);
abi_def enu_abi(enumivo_system_abi);

if( eos_abi.version.size() == 0 ) {
eos_abi.version = "enumivo::abi/1.0";
if( enu_abi.version.size() == 0 ) {
enu_abi.version = "enumivo::abi/1.0";
}

eos_abi.types.push_back( type_def{"account_name", "name"} );
eos_abi.types.push_back( type_def{"permission_name", "name"} );
eos_abi.types.push_back( type_def{"action_name", "name"} );
eos_abi.types.push_back( type_def{"table_name", "name"} );
eos_abi.types.push_back( type_def{"transaction_id_type", "checksum256"} );
eos_abi.types.push_back( type_def{"block_id_type", "checksum256"} );
eos_abi.types.push_back( type_def{"weight_type", "uint16"} );
enu_abi.types.push_back( type_def{"account_name", "name"} );
enu_abi.types.push_back( type_def{"permission_name", "name"} );
enu_abi.types.push_back( type_def{"action_name", "name"} );
enu_abi.types.push_back( type_def{"table_name", "name"} );
enu_abi.types.push_back( type_def{"transaction_id_type", "checksum256"} );
enu_abi.types.push_back( type_def{"block_id_type", "checksum256"} );
enu_abi.types.push_back( type_def{"weight_type", "uint16"} );

// transaction
eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"permission_level", "", {
{"actor", "account_name"},
{"permission", "permission_name"}
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"action", "", {
{"account", "account_name"},
{"name", "action_name"},
Expand All @@ -35,14 +35,14 @@ abi_def enumivo_contract_abi(const abi_def& enumivo_system_abi)
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"extension", "", {
{"type", "uint16"},
{"data", "bytes"}
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"transaction_header", "", {
{"expiration", "time_point_sec"},
{"ref_block_num", "uint16"},
Expand All @@ -53,7 +53,7 @@ abi_def enumivo_contract_abi(const abi_def& enumivo_system_abi)
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"transaction", "transaction_header", {
{"context_free_actions", "action[]"},
{"actions", "action[]"},
Expand All @@ -63,21 +63,21 @@ abi_def enumivo_contract_abi(const abi_def& enumivo_system_abi)

// block_header

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"producer_key", "", {
{"producer_name", "account_name"},
{"block_signing_key", "public_key"}
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"producer_schedule", "", {
{"version", "uint32"},
{"producers", "producer_key[]"}
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"block_header", "", {
{"timestamp", "uint32"},
{"producer", "account_name"},
Expand All @@ -92,28 +92,28 @@ abi_def enumivo_contract_abi(const abi_def& enumivo_system_abi)
});

// authority
eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"key_weight", "", {
{"key", "public_key"},
{"weight", "weight_type"}
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"permission_level_weight", "", {
{"permission", "permission_level"},
{"weight", "weight_type"}
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"wait_weight", "", {
{"wait_sec", "uint32"},
{"weight", "weight_type"}
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"authority", "", {
{"threshold", "uint32"},
{"keys", "key_weight[]"},
Expand All @@ -126,7 +126,7 @@ abi_def enumivo_contract_abi(const abi_def& enumivo_system_abi)
//
// ACTION PAYLOADS

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"newaccount", "", {
{"creator", "account_name"},
{"name", "account_name"},
Expand All @@ -135,7 +135,7 @@ abi_def enumivo_contract_abi(const abi_def& enumivo_system_abi)
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"setcode", "", {
{"account", "account_name"},
{"vmtype", "uint8"},
Expand All @@ -144,14 +144,14 @@ abi_def enumivo_contract_abi(const abi_def& enumivo_system_abi)
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"setabi", "", {
{"account", "account_name"},
{"abi", "bytes"}
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"updateauth", "", {
{"account", "account_name"},
{"permission", "permission_name"},
Expand All @@ -160,14 +160,14 @@ abi_def enumivo_contract_abi(const abi_def& enumivo_system_abi)
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"deleteauth", "", {
{"account", "account_name"},
{"permission", "permission_name"},
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"linkauth", "", {
{"account", "account_name"},
{"code", "account_name"},
Expand All @@ -176,47 +176,47 @@ abi_def enumivo_contract_abi(const abi_def& enumivo_system_abi)
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"unlinkauth", "", {
{"account", "account_name"},
{"code", "account_name"},
{"type", "action_name"},
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"canceldelay", "", {
{"canceling_auth", "permission_level"},
{"trx_id", "transaction_id_type"},
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"onerror", "", {
{"sender_id", "uint128"},
{"sent_trx", "bytes"}
}
});

eos_abi.structs.emplace_back( struct_def {
enu_abi.structs.emplace_back( struct_def {
"onblock", "", {
{"header", "block_header"}
}
});

// TODO add ricardian contracts
eos_abi.actions.push_back( action_def{name("newaccount"), "newaccount",""} );
eos_abi.actions.push_back( action_def{name("setcode"), "setcode",""} );
eos_abi.actions.push_back( action_def{name("setabi"), "setabi",""} );
eos_abi.actions.push_back( action_def{name("updateauth"), "updateauth",""} );
eos_abi.actions.push_back( action_def{name("deleteauth"), "deleteauth",""} );
eos_abi.actions.push_back( action_def{name("linkauth"), "linkauth",""} );
eos_abi.actions.push_back( action_def{name("unlinkauth"), "unlinkauth",""} );
eos_abi.actions.push_back( action_def{name("canceldelay"), "canceldelay",""} );
eos_abi.actions.push_back( action_def{name("onerror"), "onerror",""} );
eos_abi.actions.push_back( action_def{name("onblock"), "onblock",""} );

return eos_abi;
enu_abi.actions.push_back( action_def{name("newaccount"), "newaccount",""} );
enu_abi.actions.push_back( action_def{name("setcode"), "setcode",""} );
enu_abi.actions.push_back( action_def{name("setabi"), "setabi",""} );
enu_abi.actions.push_back( action_def{name("updateauth"), "updateauth",""} );
enu_abi.actions.push_back( action_def{name("deleteauth"), "deleteauth",""} );
enu_abi.actions.push_back( action_def{name("linkauth"), "linkauth",""} );
enu_abi.actions.push_back( action_def{name("unlinkauth"), "unlinkauth",""} );
enu_abi.actions.push_back( action_def{name("canceldelay"), "canceldelay",""} );
enu_abi.actions.push_back( action_def{name("onerror"), "onerror",""} );
enu_abi.actions.push_back( action_def{name("onblock"), "onblock",""} );

return enu_abi;
}

} } /// enumivo::chain
Loading

0 comments on commit e985cd8

Please sign in to comment.