Skip to content

Commit

Permalink
GH-788 Remove abi_json_to_bin
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Mar 9, 2023
1 parent d680c62 commit 7baee72
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 102 deletions.
33 changes: 0 additions & 33 deletions plugins/chain_api_plugin/chain.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -548,39 +548,6 @@ paths:
type: array
items: {}

/abi_json_to_bin:
post:
description: Returns an object containing the serialized action data.
operationId: abi_json_to_bin
requestBody:
content:
application/json:
schema:
type: object
title: AbiJsonToBinRequest
- code
- action
- args
properties:
code:
$ref: "https://docs.eosnetwork.com/openapi/v2.0/Name.yaml"
action:
$ref: "https://docs.eosnetwork.com/openapi/v2.0/Name.yaml"
args:
type: object
description: json object of the action parameters that will be serialized.

responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
binargs:
$ref: "https://docs.eosnetwork.com/openapi/v2.0/Hex.yaml"

/get_code:
post:
description: Returns an object containing the smart contract WASM code.
Expand Down
1 change: 0 additions & 1 deletion plugins/chain_api_plugin/chain_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ void chain_api_plugin::plugin_startup() {
CHAIN_RO_CALL(get_producers, 200, http_params_types::params_required),
CHAIN_RO_CALL(get_producer_schedule, 200, http_params_types::no_params),
CHAIN_RO_CALL(get_scheduled_transactions, 200, http_params_types::params_required),
CHAIN_RO_CALL(abi_json_to_bin, 200, http_params_types::params_required),
CHAIN_RO_CALL(get_required_keys, 200, http_params_types::params_required),
CHAIN_RO_CALL(get_transaction_id, 200, http_params_types::params_required),
CHAIN_RO_CALL_ASYNC(compute_transaction, chain_apis::read_only::compute_transaction_results, 200, http_params_types::params_required),
Expand Down
31 changes: 0 additions & 31 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2502,37 +2502,6 @@ read_only::get_account_results read_only::get_account( const get_account_params&
return result;
}

static fc::variant action_abi_to_variant( const account_object* code_account, type_name action_type ) {
fc::variant v;
if( abi_def abi; abi_serializer::to_abi(code_account->abi, abi) ) {
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 fc::time_point& deadline )const try {
abi_json_to_bin_result result;
const auto code_account = db.db().find<account_object,by_name>( params.code );
EOS_ASSERT(code_account != nullptr, contract_query_exception, "Contract can't be found ${contract}", ("contract", params.code));

if( abi_def abi; abi_serializer::to_abi(code_account->abi, abi) ) {
abi_serializer abis( std::move(abi), abi_serializer::create_yield_function( abi_serializer_max_time ) );
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( action_type, params.args, abi_serializer::create_yield_function( abi_serializer_max_time ), shorten_abi_errors );
} EOS_RETHROW_EXCEPTIONS(chain::invalid_action_args_exception,
"'${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(code_account, action_type)))
} else {
EOS_ASSERT(false, abi_not_found_exception, "No ABI found for ${contract}", ("contract", params.code));
}
return result;
} FC_RETHROW_EXCEPTIONS( warn, "code: ${code}, action: ${action}, args: ${args}",
("code", params.code)( "action", params.action )( "args", params.args ))

read_only::get_required_keys_result read_only::get_required_keys( const get_required_keys_params& params, const fc::time_point& deadline )const {
transaction pretty_input;
auto resolver = make_resolver(db, abi_serializer::create_yield_function( abi_serializer_max_time ));
Expand Down
15 changes: 0 additions & 15 deletions plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,6 @@ class read_only {
get_raw_abi_results get_raw_abi( const get_raw_abi_params& params, const fc::time_point& deadline)const;



struct abi_json_to_bin_params {
name code;
name action;
fc::variant args;
};
struct abi_json_to_bin_result {
vector<char> binargs;
};

abi_json_to_bin_result abi_json_to_bin( const abi_json_to_bin_params& params, const fc::time_point& deadline )const;


struct get_required_keys_params {
fc::variant transaction;
flat_set<public_key_type> available_keys;
Expand Down Expand Up @@ -954,8 +941,6 @@ FC_REFLECT( eosio::chain_apis::read_only::get_raw_code_and_abi_results, (account
FC_REFLECT( eosio::chain_apis::read_only::get_raw_abi_params, (account_name)(abi_hash) )
FC_REFLECT( eosio::chain_apis::read_only::get_raw_abi_results, (account_name)(code_hash)(abi_hash)(abi) )
FC_REFLECT( eosio::chain_apis::read_only::producer_info, (producer_name) )
FC_REFLECT( eosio::chain_apis::read_only::abi_json_to_bin_params, (code)(action)(args) )
FC_REFLECT( eosio::chain_apis::read_only::abi_json_to_bin_result, (binargs) )
FC_REFLECT( eosio::chain_apis::read_only::get_required_keys_params, (transaction)(available_keys) )
FC_REFLECT( eosio::chain_apis::read_only::get_required_keys_result, (required_keys) )
FC_REFLECT( eosio::chain_apis::read_only::compute_transaction_params, (transaction))
Expand Down
1 change: 0 additions & 1 deletion programs/cleos/help_text.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const std::vector<std::pair<const char*, std::vector<const char *>>> error_help_
{"Error\n: 3030008[^\\x00]*\\{\"scope\":\"([^\"]*)\"\\}", {transaction_help_text_header, missing_scope_help_text}},
{"Account not found: ([\\S]*)", {transaction_help_text_header, tx_unknown_account_help_text, unknown_account_help_text}},
{"Error\n: 303", {transaction_help_text_header}},
{"unknown key[^\\x00]*abi_json_to_bin.*code\":\"([^\"]*)\".*action\":\"([^\"]*)\"", {missing_abi_help_text}},
{"unknown key[^\\x00]*chain/get_code.*name\":\"([^\"]*)\"", {unknown_account_help_text}},
{"Unable to open file[^\\x00]*wallet/open.*postdata\":\"([^\"]*)\"", {unknown_wallet_help_text}},
{"AES error[^\\x00]*wallet/unlock.*postdata\":\\[\"([^\"]*)\"", {bad_wallet_password_help_text}},
Expand Down
1 change: 0 additions & 1 deletion programs/cleos/httpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace eosio { namespace client { namespace http {
const string send_read_only_txn_func = chain_func_base + "/send_read_only_transaction";
const string compute_txn_func = chain_func_base + "/compute_transaction";
const string push_txns_func = chain_func_base + "/push_transactions";
const string json_to_bin_func = chain_func_base + "/abi_json_to_bin";
const string get_block_func = chain_func_base + "/get_block";
const string get_block_info_func = chain_func_base + "/get_block_info";
const string get_block_header_state_func = chain_func_base + "/get_block_header_state";
Expand Down
20 changes: 0 additions & 20 deletions tests/plugin_http_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,26 +530,6 @@ def test_ChainApi(self) :
ret_json = self.nodeos.processUrllibRequest(resource, command, payload)
self.assertEqual(type(ret_json["payload"]["transactions"]), list)

# abi_json_to_bin with empty parameter
command = "abi_json_to_bin"
ret_json = self.nodeos.processUrllibRequest(resource, command)
self.assertEqual(ret_json["code"], 400)
self.assertEqual(ret_json["error"]["code"], 3200006)
# abi_json_to_bin with empty content parameter
ret_json = self.nodeos.processUrllibRequest(resource, command, self.empty_content_dict)
self.assertEqual(ret_json["code"], 400)
self.assertEqual(ret_json["error"]["code"], 3200006)
# abi_json_to_bin with invalid parameter
ret_json = self.nodeos.processUrllibRequest(resource, command, self.http_post_invalid_param)
self.assertEqual(ret_json["code"], 400)
self.assertEqual(ret_json["error"]["code"], 3200006)
# abi_json_to_bin with valid parameter
payload = {"code":"eosio.token",
"action":"issue",
"args":{"to":"eosio.token", "quantity":"1.0000\%20EOS","memo":"m"}}
ret_json = self.nodeos.processUrllibRequest(resource, command, payload)
self.assertEqual(ret_json["code"], 500)

# get_required_keys with empty parameter
command = "get_required_keys"
ret_json = self.nodeos.processUrllibRequest(resource, command)
Expand Down

0 comments on commit 7baee72

Please sign in to comment.