提交 72b670fe 编写于 作者: K Kevin Heifner 提交者: Bart Wyatt

Merge pull request #738 from EOSIO/get-table-account-702

Get table account
......@@ -10,13 +10,13 @@
"fields": {
"from": "account_name",
"to": "account_name",
"amount": "uint64"
"quantity": "uint64"
}
},{
"name": "account",
"base": "",
"fields": {
"account": "name",
"key": "name",
"balance": "uint64"
}
}
......
......@@ -58,7 +58,7 @@ namespace TOKEN_NAME {
};
/**
* @brief row in Account table stored within each scope
* @brief row in account table stored within each scope
* @abi table
*/
struct account {
......@@ -92,7 +92,7 @@ namespace TOKEN_NAME {
/**
Defines the database table for account information
**/
using accounts = table<N(currency),N(currency),N(account),account,uint64_t>;
using accounts = table<N(defaultscope),N(currency),N(account),account,uint64_t>;
/**
* accounts information for owner is stored:
......
......@@ -49,7 +49,7 @@
void apply( uint64_t code, uint64_t action ) {
if( code == N(currency) ) {
if( action == N(transfer) )
currency::apply_currency_transfer( currentAction< currency::Transfer >() );
currency::apply_currency_transfer( current_action< currency::transfer >() );
} else {
assert( false, "rejecting unexpected event" );
}
......
......@@ -523,13 +523,13 @@
"fields": {
"from": "account_name",
"to": "account_name",
"amount": "uint64"
"quantity": "uint64"
}
},{
"name": "account",
"base": "",
"fields": {
"account": "name",
"key": "name",
"balance": "uint64"
}
}
......@@ -543,7 +543,7 @@
"name": "account",
"index_type": "i64",
"key_names": [
"account"
"key"
],
"key_types": [],
"type": "account"
......@@ -555,7 +555,7 @@
From the above abi, we can see that `currency` contract accepts an action called `transfer` that accepts action with fields `from`, `to`, and `amount`.
```
$ ./eosioc push action currency transfer '{"from":"currency","to":"tester","amount":50}' -S currency -S tester -p currency@active
$ ./eosioc push action currency transfer '{"from":"currency","to":"tester","quantity":50}' -S currency -S tester -p currency@active
1589302ms thread-0 main.cpp:271 operator() ] Converting argument to binary...
1589304ms thread-0 main.cpp:290 operator() ] Transaction result:
{
......@@ -606,7 +606,7 @@
Now we can transfer it from `tester` to `inita` and require the permission of `tester`. This should drain the balance of `tester` to 0.
```
$ ./eosioc push action currency transfer '{"from":"tester","to":"inita","amount":50}' -S inita -S tester -p tester@active
$ ./eosioc push action currency transfer '{"from":"tester","to":"inita","quantity":50}' -S inita -S tester -p tester@active
3116153ms thread-0 main.cpp:271 operator() ] Converting argument to binary...
3116154ms thread-0 main.cpp:290 operator() ] Transaction result:
{
......@@ -680,7 +680,7 @@
After doing the transfer action on `currency` contract, we can verify the amount of token held by each account by looking at `currency`'s `account` table.
This table is stored on the scope of each account instead of on `currency` scope.
This table is stored on the scope of each account instead of on `currency` scope. The key of "account" is hard coded since retrieved by scope.
```
$./eosioc get table tester currency account
......@@ -691,7 +691,7 @@
$./eosioc get table inita currency account
{
"rows": [{
"account": "account",
"key": "account",
"balance": 50
}
],
......
......@@ -377,7 +377,7 @@ if [ $count == 0 ]; then
fi
# push message to currency contract
INFO="$(programs/eosc/eosc --wallet-port 8899 push message currency transfer '{"from":"currency","to":"inita","amount":50}' --scope currency,inita --permission currency@active)"
INFO="$(programs/eosc/eosc --wallet-port 8899 push message currency transfer '{"from":"currency","to":"inita","quantity":50}' --scope currency,inita --permission currency@active)"
verifyErrorCode "eosc push message currency transfer"
getTransactionId "$INFO"
......
......@@ -416,7 +416,7 @@ fi
# push message to currency contract
INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 push message currency transfer '{"from":"currency","to":"inita","amount":50}' --scope currency,inita --permission currency@active)"
INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 push message currency transfer '{"from":"currency","to":"inita","quantity":50}' --scope currency,inita --permission currency@active)"
verifyErrorCode "eosc push message currency transfer"
getTransactionId "$INFO"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册