提交 8f3f9926 编写于 作者: D Daniel Larimer

Merge branch 'issue3073' of github.com:EOSIO/eos into issue3073

......@@ -249,8 +249,8 @@ namespace eosio { namespace chain {
3110001, "Missing Chain API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_wallet_api_plugin_exception, missing_plugin_exception,
3110002, "Missing Wallet API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_account_history_api_plugin_exception, missing_plugin_exception,
3110003, "Missing Account History API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_history_api_plugin_exception, missing_plugin_exception,
3110003, "Missing History API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_net_api_plugin_exception, missing_plugin_exception,
3110004, "Missing Net API Plugin" )
......
......@@ -577,6 +577,14 @@ read_only::get_account_results read_only::get_account( const get_account_params&
return result;
}
static variant action_abi_to_variant( const abi_def& abi, type_name action_type ) {
variant v;
auto it = std::find_if(abi.structs.begin(), abi.structs.end(), [&](auto& x){return x.name == action_type;});
if( it != abi.structs.end() )
to_variant( it->fields, v );
return v;
};
read_only::abi_json_to_bin_result read_only::abi_json_to_bin( const read_only::abi_json_to_bin_params& params )const try {
abi_json_to_bin_result result;
const auto code_account = db.db().find<account_object,by_name>( params.code );
......@@ -585,11 +593,13 @@ read_only::abi_json_to_bin_result read_only::abi_json_to_bin( const read_only::a
abi_def abi;
if( abi_serializer::to_abi(code_account->abi, abi) ) {
abi_serializer abis( abi );
auto action_type = abis.get_action_type(params.action);
EOS_ASSERT(!action_type.empty(), action_validate_exception, "Unknown action ${action} in contract ${contract}", ("action", params.action)("contract", params.code));
try {
result.binargs = abis.variant_to_binary(abis.get_action_type(params.action), params.args);
result.binargs = abis.variant_to_binary(action_type, params.args);
} EOS_RETHROW_EXCEPTIONS(chain::invalid_action_args_exception,
"'${args}' is invalid args for action '${action}' code '${code}'",
("args", params.args)("action", params.action)("code", params.code))
"'${args}' is invalid args for action '${action}' code '${code}'. expected '${proto}'",
("args", params.args)("action", params.action)("code", params.code)("proto", action_abi_to_variant(abi, action_type)))
}
return result;
} FC_CAPTURE_AND_RETHROW( (params.code)(params.action)(params.args) )
......
......@@ -97,78 +97,15 @@ auto smatch_to_variant(const std::smatch& smatch) {
return result;
};
const char* error_advice_3010001 = "Most likely, the given account/ permission doesn't exist in the blockchain.";
const char* error_advice_3010002 = "Most likely, the given account doesn't exist in the blockchain.";
const char* error_advice_3010003 = "Most likely, the given table doesnt' exist in the blockchain.";
const char* error_advice_3010004 = "Most likely, the given contract doesnt' exist in the blockchain.";
const char* error_advice_3030000 = "Ensure that your transaction satisfy the contract's constraint!";
const char* error_advice_3030001 = R"=====(Ensure that you have the related authority inside your transaction!;
If you are currently using 'cleos push action' command, try to add the relevant authority using -p option.)=====";
const char* error_advice_3030002 = "Ensure that you have the related private keys inside your wallet and your wallet is unlocked.";
const char* error_advice_3030003 = "Please remove the unnecessary authority from your action!";
const char* error_advice_3030004 = "Please remove the unnecessary signature from your transaction!";
const char* error_advice_3030011 = "You can try embedding eosio nonce action inside your transaction to ensure uniqueness.";
const char* error_advice_3030022 = "Please increase the expiration time of your transaction!";
const char* error_advice_3030023 = "Please decrease the expiration time of your transaction!";
const char* error_advice_3030024 = "Ensure that the reference block exist in the blockchain!";
const char* error_advice_3040002 = R"=====(Ensure that your arguments follow the contract abi!
You can check the contract's abi by using 'cleos get code' command.)=====";
const char* error_advice_3120001 = R"=====(Name should be less than 13 characters and only contains the following symbol .12345abcdefghijklmnopqrstuvwxyz)=====";
const char* error_advice_3120002 = R"=====(Public key should be encoded in base58 and starts with EOS prefix)=====";
const char* error_advice_3120003 = R"=====(Private key should be encoded in base58 WIF)=====";
const char* error_advice_3120004 = R"=====(Ensure that your authority JSON follows the following format!
{
"threshold":"uint32_t",
"keys":[{ "key":"public_key", "weight":"uint16_t" }],
"accounts":[{
"permission":{ "actor":"account_name", "permission":"permission_name" },
"weight":"uint16_t"
}]
}
e.g.
{
"threshold":"1",
"keys":[{ "key":"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", "weight":"1" }],
"accounts":[{
"permission":{ "actor":"initb", "permission":"social" },
"weight":"1
}]
})=====";
const char* error_advice_3120005 = R"=====(Ensure that your action JSON follows the contract's abi!)=====";
const char* error_advice_3120006 = R"=====(Ensure that your transaction JSON follows the following format!\n"
{
"ref_block_num":"uint16_t",
"ref_block_prefix":"uint32_t",
"expiration":"YYYY-MM-DDThh:mm",
"region": "uint16_t",
"read_scope":[ "account_name" ],
"write_scope":[ "account_name" ],
"actions":[{
"account":"account_name",
"name":"action_name",
"authorization":[{ "actor":"account_name","permission":"permission_name" }],
"data":"bytes"
}]
}"
e.g.
{
"ref_block_num":"1000",
"ref_block_prefix":"3463702842",
"expiration":"2018-01-23T01:51:05",
"region": "0",
"read_scope":[ "initb", "initc" ],
"write_scope":[ "initb", "initc" ],
"actions":[{
"account":"eosio",
"name":"transfer",
"authorization":[{ "actor":"initb","permission":"active" }],
"data":"000000008093dd74000000000094dd74e80300000000000000"
}]
})=====";
const char* error_advice_3120007 = R"=====(Ensure that your abi JSON follows the following format!
const char* error_advice_3010001 = R"=====(Name should be less than 13 characters and only contains the following symbol .12345abcdefghijklmnopqrstuvwxyz)=====";
const char* error_advice_3010002 = R"=====(Public key should be encoded in base58 and starts with EOS prefix)=====";
const char* error_advice_3010003 = R"=====(Private key should be encoded in base58 WIF)=====";
const char* error_advice_3010004 = R"=====(Ensure that your authority JSON follows the right authority structure!
You can refer to contracts/eosiolib/native.hpp for reference)=====";
const char* error_advice_3010005 = R"=====(Ensure that your action JSON follows the contract's abi!)=====";
const char* error_advice_3010006 = R"=====(Ensure that your transaction JSON follows the right transaction format!
You can refer to contracts/eosiolib/transaction.hpp for reference)=====";
const char* error_advice_3010007 = R"=====(Ensure that your abi JSON follows the following format!
{
"types" : [{ "new_type_name":"type_name", "type":"type_name" }],
"structs" : [{ "name":"type_name", "base":"type_name", "fields": [{ "name":"field_name", "type": "type_name" }] }],
......@@ -179,13 +116,14 @@ const char* error_advice_3120007 = R"=====(Ensure that your abi JSON follows th
"key_names":[ "field_name" ],
"key_types":[ "type_name" ],
"type":"type_name" "
}]
}],
"ricardian_clauses": [{ "id": "string", "body": "string" }]
}
e.g.
{
"types" : [{ "new_type_name":"account_name", "type":"name" }],
"structs" : [
{ "name":"foo", "base":"", "fields": [{ "name":"by", "type": "account_name" }] },\n "
{ "name":"foo", "base":"", "fields": [{ "name":"by", "type": "account_name" }] },
{ "name":"foobar", "base":"", "fields": [{ "name":"by", "type": "account_name" }] }
],
"actions" : [{ "name":"foo","type":"foo"}],
......@@ -194,36 +132,59 @@ e.g.
"index_type":"i64",
"key_names":[ "by" ],
"key_types":[ "account_name" ],
"type":"foobar" "
}]
"type":"foobar"
}],
"ricardian_clauses": [{ "id": "foo", "body": "bar" }]
})=====";
const char* error_advice_3120008 = "Ensure that the block ID is a SHA-256 hexadecimal string!";
const char* error_advice_3120009 = "Ensure that the transaction ID is a SHA-256 hexadecimal string!";
const char* error_advice_3120010 = R"=====(Ensure that your packed transaction JSON follows the following format!
const char* error_advice_3010008 = "Ensure that the block ID is a SHA-256 hexadecimal string!";
const char* error_advice_3010009 = "Ensure that the transaction ID is a SHA-256 hexadecimal string!";
const char* error_advice_3010010 = R"=====(Ensure that your packed transaction JSON follows the following format!
{
"signatures" : [ "signature" ],
"compression" : enum("none", "zlib"),
"hex_transaction" : "bytes"
"packed_context_free_data" : "bytes",
"packed_trx" : "bytes";
}
e.g.
{
"signatures" : [ "SIG_K1_Jze4m1ZHQ4UjuHpBcX6uHPN4Xyggv52raQMTBZJghzDLepaPcSGCNYTxaP2NiaF4yRF5RaYwqsQYAwBwFtfuTJr34Z5GJX" ],
"compression" : "none",
"hex_transaction" : "6c36a25a00002602626c5e7f0000000000010000001e4d75af460000000000a53176010000000000ea305500000000a8ed3232180000001e4d75af4680969800000000000443555200000000"
"packed_context_free_data" : "6c36a25a00002602626c5e7f0000000000010000001e4d75af460000000000a53176010000000000ea305500000000a8ed3232180000001e4d75af4680969800000000000443555200000000",
"packed_trx" : "6c36a25a00002602626c5e7f0000000000010000001e4d75af460000000000a53176010000000000ea305500000000a8ed3232180000001e4d75af4680969800000000000443555200000000"
})=====";
const char* error_advice_3130001 = "Ensure that you have \033[2meosio::chain_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3130002 = "Ensure that you have \033[2meosio::wallet_api_plugin\033[0m\033[32m added to your node's configuration!\n"\
const char* error_advice_3040000 = "Ensure that your transaction satisfy the contract's constraint!";
const char* error_advice_3040005 = "Please increase the expiration time of your transaction!";
const char* error_advice_3040006 = "Please decrease the expiration time of your transaction!";
const char* error_advice_3040007 = "Ensure that the reference block exist in the blockchain!";
const char* error_advice_3040008 = "You can try embedding eosio nonce action inside your transaction to ensure uniqueness.";
const char* error_advice_3050002 = R"=====(Ensure that your arguments follow the contract abi!
You can check the contract's abi by using 'cleos get code' command.)=====";
const char* error_advice_3060001 = "Most likely, the given account/ permission doesn't exist in the blockchain.";
const char* error_advice_3060002 = "Most likely, the given account doesn't exist in the blockchain.";
const char* error_advice_3060003 = "Most likely, the given table doesnt' exist in the blockchain.";
const char* error_advice_3060004 = "Most likely, the given contract doesnt' exist in the blockchain.";
const char* error_advice_3090002 = "Please remove the unnecessary signature from your transaction!";
const char* error_advice_3090003 = "Ensure that you have the related private keys inside your wallet and your wallet is unlocked.";
const char* error_advice_3090004 = R"=====(Ensure that you have the related authority inside your transaction!;
If you are currently using 'cleos push action' command, try to add the relevant authority using -p option.)=====";
const char* error_advice_3090005 = "Please remove the unnecessary authority from your action!";
const char* error_advice_3110001 = "Ensure that you have \033[2meosio::chain_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3110002 = "Ensure that you have \033[2meosio::wallet_api_plugin\033[0m\033[32m added to your node's configuration!\n"\
"Otherwise specify your wallet location with \033[2m--wallet-url\033[0m\033[32m argument!";
const char* error_advice_3130003 = "Ensure that you have \033[2meosio::account_history_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3130004 = "Ensure that you have \033[2meosio::net_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3110003 = "Ensure that you have \033[2meosio::history_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3110004 = "Ensure that you have \033[2meosio::net_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3140001 = "Try to use different wallet name.";
const char* error_advice_3140002 = "Are you sure you typed the wallet name correctly?";
const char* error_advice_3140003 = "Ensure that your wallet is unlocked before using it!";
const char* error_advice_3140004 = "Ensure that you have the relevant private key imported!";
const char* error_advice_3140005 = "Are you sure you are using the right password?";
const char* error_advice_3140006 = "Ensure that you have created a wallet and have it open";
const char* error_advice_3120001 = "Try to use different wallet name.";
const char* error_advice_3120002 = "Are you sure you typed the wallet name correctly?";
const char* error_advice_3120003 = "Ensure that your wallet is unlocked before using it!";
const char* error_advice_3120004 = "Ensure that you have the relevant private key imported!";
const char* error_advice_3120005 = "Are you sure you are using the right password?";
const char* error_advice_3120006 = "Ensure that you have created a wallet and have it open";
const std::map<int64_t, std::string> error_advice = {
......@@ -231,42 +192,42 @@ const std::map<int64_t, std::string> error_advice = {
{ 3010002, error_advice_3010002 },
{ 3010003, error_advice_3010003 },
{ 3010004, error_advice_3010004 },
{ 3030000, error_advice_3030000 },
{ 3030001, error_advice_3030001 },
{ 3030002, error_advice_3030002 },
{ 3030003, error_advice_3030003 },
{ 3030004, error_advice_3030004 },
{ 3030011, error_advice_3030011 },
{ 3030022, error_advice_3030022 },
{ 3030023, error_advice_3030023 },
{ 3030024, error_advice_3030024 },
{ 3040002, error_advice_3040002 },
{ 3010005, error_advice_3010005 },
{ 3010006, error_advice_3010006 },
{ 3010007, error_advice_3010007 },
{ 3010008, error_advice_3010008 },
{ 3010009, error_advice_3010009 },
{ 3010010, error_advice_3010010 },
{ 3040000, error_advice_3040000 },
{ 3040008, error_advice_3040008 },
{ 3040005, error_advice_3040005 },
{ 3040006, error_advice_3040006 },
{ 3040007, error_advice_3040007 },
{ 3050002, error_advice_3050002 },
{ 3060001, error_advice_3060001 },
{ 3060002, error_advice_3060002 },
{ 3060003, error_advice_3060003 },
{ 3060004, error_advice_3060004 },
{ 3090002, error_advice_3090002 },
{ 3090003, error_advice_3090003 },
{ 3090004, error_advice_3090004 },
{ 3090005, error_advice_3090005 },
{ 3110001, error_advice_3110001 },
{ 3110002, error_advice_3110002 },
{ 3110003, error_advice_3110003 },
{ 3110004, error_advice_3110004 },
{ 3120001, error_advice_3120001 },
{ 3120002, error_advice_3120002 },
{ 3120003, error_advice_3120003 },
{ 3120004, error_advice_3120004 },
{ 3120005, error_advice_3120005 },
{ 3120006, error_advice_3120006 },
{ 3120007, error_advice_3120007 },
{ 3120008, error_advice_3120008 },
{ 3120009, error_advice_3120009 },
{ 3120010, error_advice_3120010 },
{ 3130001, error_advice_3130001 },
{ 3130002, error_advice_3130002 },
{ 3130003, error_advice_3130003 },
{ 3130004, error_advice_3130004 },
{ 3140001, error_advice_3140001 },
{ 3140002, error_advice_3140002 },
{ 3140003, error_advice_3140003 },
{ 3140004, error_advice_3140004 },
{ 3140005, error_advice_3140005 },
{ 3140006, error_advice_3140006 }
{ 3120006, error_advice_3120006 }
};
......
......@@ -159,7 +159,7 @@ namespace eosio { namespace client { namespace http {
} else if (path.compare(0, wallet_func_base.size(), wallet_func_base) == 0) {
throw chain::missing_wallet_api_plugin_exception(FC_LOG_MESSAGE(error, "Wallet is not available"));
} else if (path.compare(0, account_history_func_base.size(), account_history_func_base) == 0) {
throw chain::missing_account_history_api_plugin_exception(FC_LOG_MESSAGE(error, "Account History API plugin is not enabled"));
throw chain::missing_history_api_plugin_exception(FC_LOG_MESSAGE(error, "History API plugin is not enabled"));
} else if (path.compare(0, net_func_base.size(), net_func_base) == 0) {
throw chain::missing_net_api_plugin_exception(FC_LOG_MESSAGE(error, "Net API plugin is not enabled"));
}
......
......@@ -502,6 +502,31 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try {
BOOST_REQUIRE_EQUAL( success(), sellram( "alice1111111", bought_bytes ) );
BOOST_REQUIRE_EQUAL( asset::from_string("100000999.9991 EOS"), get_balance( "alice1111111" ) );
newtotal = get_total_stake( "alice1111111" );
auto startbytes = newtotal["ram_bytes"].as_uint64();
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "300000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( asset::from_string("49400999.9991 EOS"), get_balance( "alice1111111" ) );
auto finaltotal = get_total_stake( "alice1111111" );
auto endbytes = finaltotal["ram_bytes"].as_uint64();
bought_bytes = endbytes - startbytes;
wdump((startbytes)(endbytes)(bought_bytes) );
BOOST_REQUIRE_EQUAL( success(), sellram( "alice1111111", bought_bytes ) );
BOOST_REQUIRE_EQUAL( asset::from_string("100000999.9943 EOS"), get_balance( "alice1111111" ) );
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( stake_unstake, eosio_system_tester ) try {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册