Skip to content

Commit

Permalink
Merge branch 'master' into eosio_build_fedora_mongo
Browse files Browse the repository at this point in the history
Merging master to avoid conflicts before creating PR for eosio_build_fedora_mongo
  • Loading branch information
Bill Hamilton committed Mar 16, 2018
2 parents b7cd1ab + 3f08d6b commit e4422ed
Show file tree
Hide file tree
Showing 52 changed files with 2,829 additions and 445 deletions.
4 changes: 1 addition & 3 deletions CMakeModules/FindWasm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

# TODO: Check if compiler is able to generate wasm32
if ("${WASM_ROOT}" STREQUAL "")
# if (NOT "$ENV{WASM_ROOT}" STREQUAL "")
# set( WASM_ROOT $ENV{WASM_ROOT} )
if (APPLE)
set( WASM_ROOT "/usr/local/wasm" )
elseif (UNIX AND NOT APPLE)
set( WASM_ROOT "/opt/wasm" )
set( WASM_ROOT "$ENV{HOME}/opt/wasm" )
else()
message(FATAL_ERROR "WASM not found and don't know where to look, please specify WASM_ROOT")
endif()
Expand Down
2 changes: 1 addition & 1 deletion CMakeModules/wasm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ macro(compile_wast)
endif()

set(WASM_COMMAND ${WASM_CLANG} -emit-llvm -O3 ${STDFLAG} --target=wasm32 -ffreestanding
-nostdlib -nostdlibinc -fno-threadsafe-statics -fno-rtti -fno-exceptions
-nostdlib -nostdlibinc -fno-threadsafe-statics -fno-rtti -fno-exceptions
-c ${infile} -o ${outfile}.bc
)
if (${ARG_NOWARNINGS})
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ cd ~/eos/build/programs/eosioc/
./eosioc wallet create # Outputs a password that you need to save to be able to lock/unlock the wallet
```

For the purpose of this walkthrough, import the private key of the `inita` account, a test account included within genesis.json, so that you're able to issue API commands under authority of an existing account. The private key referenced below is found within your `config.ini` and is provided to you for testing purposes.
For the purpose of this walkthrough, import the private key of the `eosio` account, a system account included within genesis.json, so that you're able to issue API commands under authority of an existing account. The private key referenced below is found within your `config.ini` and is provided to you for testing purposes.

```bash
./eosioc wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
Expand All @@ -333,10 +333,10 @@ Public key: EOSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
**Important:**
Save the values for future reference.

Run the `create` command where `inita` is the account authorizing the creation of the `currency` account and `PUBLIC_KEY_1` and `PUBLIC_KEY_2` are the values generated by the `create key` command
Run the `create` command where `eosio` is the account authorizing the creation of the `currency` account and `PUBLIC_KEY_1` and `PUBLIC_KEY_2` are the values generated by the `create key` command

```bash
./eosioc create account inita currency PUBLIC_KEY_1 PUBLIC_KEY_2
./eosioc create account eosio currency PUBLIC_KEY_1 PUBLIC_KEY_2
```

You should then get a JSON response back with a transaction ID confirming it was executed successfully.
Expand Down Expand Up @@ -419,10 +419,10 @@ Next verify the currency contract has the proper initial balance:

Anyone can send any message to any contract at any time, but the contracts may reject messages which are not given necessary permission. Messages are not sent "from" anyone, they are sent "with permission of" one or more accounts and permission levels. The following commands show a "transfer" message being sent to the "currency" contract.

The content of the message is `'{"from":"currency","to":"inita","quantity":"20.0000 CUR","memo":"any string"}'`. In this case we are asking the currency contract to transfer funds from itself to someone else. This requires the permission of the currency contract.
The content of the message is `'{"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"any string"}'`. In this case we are asking the currency contract to transfer funds from itself to someone else. This requires the permission of the currency contract.

```bash
./eosioc push action currency transfer '{"from":"currency","to":"inita","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency@active
./eosioc push action currency transfer '{"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency@active
```

Below is a generalization that shows the `currency` account is only referenced once, to specify which contract to deliver the `transfer` message to.
Expand All @@ -439,7 +439,7 @@ As confirmation of a successfully submitted transaction, you will receive JSON o
So now check the state of both of the accounts involved in the previous transaction.

```bash
./eosioc get table inita currency account
./eosioc get table eosio currency account
{
"rows": [{
"currency": 1381319428,
Expand All @@ -459,7 +459,7 @@ So now check the state of both of the accounts involved in the previous transact
}
```

As expected, the receiving account **inita** now has a balance of **20** tokens, and the sending account now has **20** less tokens than its initial supply.
As expected, the receiving account **eosio** now has a balance of **20** tokens, and the sending account now has **20** less tokens than its initial supply.

<a name="localtestnet"></a>
## Running multi-node local testnet
Expand Down
19 changes: 17 additions & 2 deletions contracts/currency/currency.abi
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@
{"name":"memo", "type":"string"}
]
},{
"name": "create",
"base": "",
"fields": [
{"name":"issuer", "type":"account_name"},
{"name":"maximum_supply", "type":"asset"},
{"name":"can_freeze", "type":"uint8"},
{"name":"can_recall", "type":"uint8"},
{"name":"can_whitelist", "type":"uint8"}
]
},{
"name": "issue",
"base": "",
"fields": [
{"name":"to", "type":"account_name"},
{"name":"quantity", "type":"asset"}
{"name":"quantity", "type":"asset"},
{"name":"memo", "type":"string"}
]
},{
"name": "account",
Expand All @@ -42,7 +53,11 @@
},{
"name": "issue",
"type": "issue"
}, {
"name": "create",
"type": "create"
}

],
"tables": [{
"name": "account",
Expand All @@ -58,4 +73,4 @@
"key_types" : ["uint64"]
}
]
}
}
4 changes: 2 additions & 2 deletions contracts/currency/currency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* @copyright defined in eos/LICENSE.txt
*/

#include <currency/currency.hpp> /// defines transfer struct (abi)
#include <eosiolib/currency.hpp>

extern "C" {
/// The apply method implements the dispatch of events to this contract
void apply( uint64_t code, uint64_t action ) {
currency::contract::apply( code, action );
eosio::currency().apply( code, action );
}
}
7 changes: 0 additions & 7 deletions contracts/currency/currency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,4 @@
*/

#include <eosiolib/eosio.hpp>
#include <eosiolib/token.hpp>
#include <eosiolib/db.hpp>
#include <eosiolib/generic_currency.hpp>


namespace currency {
typedef eosio::generic_currency< eosio::token<N(currency),S(4,CUR)> > contract;
}
11 changes: 8 additions & 3 deletions contracts/eosio.system/eosio.system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ namespace eosiosystem {
typedef eosio::multi_index< N(delband), delegated_bandwidth> del_bandwidth_index_type;


ACTION( SystemAccount, finshundel ) {
ACTION( SystemAccount, finishundel ) {
account_name from;
account_name to;

EOSLIB_SERIALIZE( finishundel, (from)(to) )
};

ACTION( SystemAccount, regproducer ) {
Expand Down Expand Up @@ -252,7 +254,7 @@ namespace eosiosystem {


/**
* This method will create a producr_config and producer_votes object for 'producer'
* This method will create a producer_config and producer_votes object for 'producer'
*
* @pre producer is not already registered
* @pre producer to register is an account
Expand Down Expand Up @@ -382,13 +384,16 @@ namespace eosiosystem {

static void on( const nonce& ) {
}

static void on( const finishundel& ) {
}

static void apply( account_name code, action_name act ) {

if( !eosio::dispatch<contract,
regproducer, regproxy,
delegatebw, undelegatebw,
regproducer, voteproducer, stakevote,
finishundel, voteproducer, stakevote,
nonce>( code, act) ) {
if ( !eosio::dispatch<currency, typename currency::transfer, typename currency::issue>( code, act ) ) {
eosio::print("Unexpected action: ", eosio::name(act), "\n");
Expand Down
1 change: 1 addition & 0 deletions contracts/eosiolib/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ extern "C" {
* @param name - name of the account to be verified
*/
void require_auth( account_name name );
bool has_auth( account_name name );

/**
* Get the account which specifies the code that is being run
Expand Down
12 changes: 12 additions & 0 deletions contracts/eosiolib/action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ namespace eosio {
data = pack(value);
}

/**
* @tparam Action - a type derived from action_meta<Scope,Name>
* @param value - will be serialized via pack into data
*/
template<typename Action>
action( const permission_level& auth, account_name a, action_name n, const Action& value )
:authorization(1,auth) {
account = a;
name = n;
data = pack(value);
}

EOSLIB_SERIALIZE( action, (account)(name)(authorization)(data) )

void send() const {
Expand Down
Loading

0 comments on commit e4422ed

Please sign in to comment.