Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace N macro with operator ""_n #25

Merged
merged 2 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/chain/apply_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void apply_context::exec_one()

if( ( receiver_account->code_hash != digest_type() ) &&
( !( act->account == config::system_account_name
&& act->name == N( setcode )
&& act->name == "setcode"_n
&& receiver == config::system_account_name )
|| control.is_builtin_activated( builtin_protocol_feature_t::forward_setcode )
)
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2422,7 +2422,7 @@ struct controller_impl {
{
action on_block_act;
on_block_act.account = config::system_account_name;
on_block_act.name = N(onblock);
on_block_act.name = "onblock"_n;
on_block_act.authorization = vector<permission_level>{{config::system_account_name, config::active_name}};
on_block_act.data = fc::raw::pack(self.head_block_header());

Expand Down
22 changes: 11 additions & 11 deletions libraries/chain/include/eosio/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ const static auto default_state_size = 1*1024*1024*1024ll;
const static auto default_state_guard_size = 128*1024*1024ll;


const static name system_account_name { N(eosio) };
const static name null_account_name { N(eosio.null) };
const static name producers_account_name { N(eosio.prods) };
const static name system_account_name { "eosio"_n };
const static name null_account_name { "eosio.null"_n };
const static name producers_account_name { "eosio.prods"_n };

// Active permission of producers account requires greater than 2/3 of the producers to authorize
const static name majority_producers_permission_name { N(prod.major) }; // greater than 1/2 of producers needed to authorize
const static name minority_producers_permission_name { N(prod.minor) }; // greater than 1/3 of producers needed to authorize0
const static name majority_producers_permission_name { "prod.major"_n }; // greater than 1/2 of producers needed to authorize
const static name minority_producers_permission_name { "prod.minor"_n }; // greater than 1/3 of producers needed to authorize0

const static name eosio_auth_scope { N(eosio.auth) };
const static name eosio_all_scope { N(eosio.all) };
const static name eosio_auth_scope { "eosio.auth"_n };
const static name eosio_all_scope { "eosio.all"_n };

const static name active_name { N(active) };
const static name owner_name { N(owner) };
const static name eosio_any_name { N(eosio.any) };
const static name eosio_code_name { N(eosio.code) };
const static name active_name { "active"_n };
const static name owner_name { "owner"_n };
const static name eosio_any_name { "eosio.any"_n };
const static name eosio_code_name { "eosio.code"_n };

const static int block_interval_ms = 500;
const static int block_interval_us = block_interval_ms*1000;
Expand Down
18 changes: 9 additions & 9 deletions libraries/chain/include/eosio/chain/contract_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct newaccount {
}

static action_name get_name() {
return N(newaccount);
return "newaccount"_n;
}
};

Expand All @@ -33,7 +33,7 @@ struct setcode {
}

static action_name get_name() {
return N(setcode);
return "setcode"_n;
}
};

Expand All @@ -46,7 +46,7 @@ struct setabi {
}

static action_name get_name() {
return N(setabi);
return "setabi"_n;
}
};

Expand All @@ -62,7 +62,7 @@ struct updateauth {
}

static action_name get_name() {
return N(updateauth);
return "updateauth"_n;
}
};

Expand All @@ -80,7 +80,7 @@ struct deleteauth {
}

static action_name get_name() {
return N(deleteauth);
return "deleteauth"_n;
}
};

Expand All @@ -100,7 +100,7 @@ struct linkauth {
}

static action_name get_name() {
return N(linkauth);
return "linkauth"_n;
}
};

Expand All @@ -119,7 +119,7 @@ struct unlinkauth {
}

static action_name get_name() {
return N(unlinkauth);
return "unlinkauth"_n;
}
};

Expand All @@ -132,7 +132,7 @@ struct canceldelay {
}

static action_name get_name() {
return N(canceldelay);
return "canceldelay"_n;
}
};

Expand All @@ -148,7 +148,7 @@ struct onerror {
}

static action_name get_name() {
return N(onerror);
return "onerror"_n;
}
};

Expand Down
2 changes: 0 additions & 2 deletions libraries/chain/include/eosio/chain/name.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ namespace eosio::chain {
#endif
} // namespace literals

#define N(X) eosio::chain::string_to_name(#X)

} // eosio::chain

namespace std {
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/trace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace eosio { namespace chain {
if (tt.action_traces.empty())
return false;
const auto& act = tt.action_traces[0].act;
if (act.account != eosio::chain::config::system_account_name || act.name != N(onblock) ||
if (act.account != eosio::chain::config::system_account_name || act.name != "onblock"_n ||
act.authorization.size() != 1)
return false;
const auto& auth = act.authorization[0];
Expand Down
10 changes: 8 additions & 2 deletions libraries/state_history/include/eosio/state_history/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ namespace eosio {
* payload
*/

inline uint64_t ship_magic(uint32_t version) { return N(ship).to_uint64_t() | version; }
inline bool is_ship(uint64_t magic) { return (magic & 0xffff'ffff'0000'0000) == N(ship).to_uint64_t(); }
inline uint64_t ship_magic(uint32_t version) {
using namespace eosio::chain::literals;
return "ship"_n.to_uint64_t() | version;
}
inline bool is_ship(uint64_t magic) {
using namespace eosio::chain::literals;
return (magic & 0xffff'ffff'0000'0000) == "ship"_n.to_uint64_t();
}
inline uint32_t get_ship_version(uint64_t magic) { return magic; }
inline bool is_ship_supported_version(uint64_t magic) { return get_ship_version(magic) == 0; }
static const uint32_t ship_current_version = 0;
Expand Down
8 changes: 4 additions & 4 deletions libraries/testing/tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ namespace eosio { namespace testing {
const symbol& asset_symbol,
const account_name& account ) const {
const auto& db = control->db();
const auto* tbl = db.template find<table_id_object, by_code_scope_table>(boost::make_tuple(code, account, N(accounts)));
const auto* tbl = db.template find<table_id_object, by_code_scope_table>(boost::make_tuple(code, account, "accounts"_n));
share_type result = 0;

// the balance is implied to be 0 if either the table or row does not exist
Expand Down Expand Up @@ -1098,7 +1098,7 @@ namespace eosio { namespace testing {
schedule_variant.emplace_back(e.get_abi_variant());
}

return push_action( config::system_account_name, N(setprods), config::system_account_name,
return push_action( config::system_account_name, "setprods"_n, config::system_account_name,
fc::mutable_variant_object()("schedule", schedule_variant));

}
Expand All @@ -1115,7 +1115,7 @@ namespace eosio { namespace testing {
});
}

return push_action( config::system_account_name, N(setprods), config::system_account_name,
return push_action( config::system_account_name, "setprods"_n, config::system_account_name,
fc::mutable_variant_object()("schedule", legacy_keys));

}
Expand All @@ -1136,7 +1136,7 @@ namespace eosio { namespace testing {

void base_tester::preactivate_protocol_features(const vector<digest_type> feature_digests) {
for( const auto& feature_digest: feature_digests ) {
push_action( config::system_account_name, N(activate), config::system_account_name,
push_action( config::system_account_name, "activate"_n, config::system_account_name,
fc::mutable_variant_object()("feature_digest", feature_digest) );
}
}
Expand Down
9 changes: 5 additions & 4 deletions plugins/chain_plugin/account_query_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <shared_mutex>

using namespace eosio;
using namespace eosio::chain::literals;
using namespace boost::multi_index;
using namespace boost::bimaps;

Expand Down Expand Up @@ -68,7 +69,7 @@ namespace {
if (p->action_traces.empty())
return false;
const auto& act = p->action_traces[0].act;
if (act.account != eosio::chain::config::system_account_name || act.name != N(onblock) ||
if (act.account != eosio::chain::config::system_account_name || act.name != "onblock"_n ||
act.authorization.size() != 1)
return false;
const auto& auth = act.authorization[0];
Expand Down Expand Up @@ -327,9 +328,9 @@ namespace eosio::chain_apis {
auto itr = deleted.emplace(chain::permission_level{data.account, data.permission}).first;
updated.erase(*itr);
} else if (at.act.name == chain::newaccount::get_name()) {
auto data = at.act.data_as<chain::newaccount>();
updated.emplace(chain::permission_level{data.name, N(owner)});
updated.emplace(chain::permission_level{data.name, N(active)});
auto data = at.act.data_as<chain::newaccount>();
updated.emplace(chain::permission_level{data.name, "owner"_n});
updated.emplace(chain::permission_level{data.name, "active"_n});
}
}
};
Expand Down
36 changes: 18 additions & 18 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ vector<asset> read_only::get_currency_balance( const read_only::get_currency_bal
(void)get_table_type( abi, name("accounts") );

vector<asset> results;
walk_key_value_table(p.code, p.account, N(accounts), [&](const key_value_object& obj){
walk_key_value_table(p.code, p.account, "accounts"_n, [&](const key_value_object& obj){
EOS_ASSERT( obj.value.size() >= sizeof(asset), chain::asset_type_exception, "Invalid data on table");

asset cursor;
Expand Down Expand Up @@ -1895,7 +1895,7 @@ fc::variant read_only::get_currency_stats( const read_only::get_currency_stats_p

uint64_t scope = ( eosio::chain::string_to_symbol( 0, boost::algorithm::to_upper_copy(p.symbol).c_str() ) >> 8 );

walk_key_value_table(p.code, name(scope), N(stat), [&](const key_value_object& obj){
walk_key_value_table(p.code, name(scope), "stat"_n, [&](const key_value_object& obj){
EOS_ASSERT( obj.value.size() >= sizeof(read_only::get_currency_stats_result), chain::asset_type_exception, "Invalid data on table");

fc::datastream<const char *> ds(obj.value.data(), obj.value.size());
Expand All @@ -1913,24 +1913,24 @@ fc::variant read_only::get_currency_stats( const read_only::get_currency_stats_p
}

fc::variant get_global_row( const database& db, const abi_def& abi, const abi_serializer& abis, const fc::microseconds& abi_serializer_max_time_us, bool shorten_abi_errors ) {
const auto table_type = get_table_type(abi, N(global));
const auto table_type = get_table_type(abi, "global"_n);
EOS_ASSERT(table_type == read_only::KEYi64, chain::contract_table_query_exception, "Invalid table type ${type} for table global", ("type",table_type));

const auto* const table_id = db.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple(config::system_account_name, config::system_account_name, N(global)));
const auto* const table_id = db.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple(config::system_account_name, config::system_account_name, "global"_n));
EOS_ASSERT(table_id, chain::contract_table_query_exception, "Missing table global");

const auto& kv_index = db.get_index<key_value_index, by_scope_primary>();
const auto it = kv_index.find(boost::make_tuple(table_id->id, N(global).to_uint64_t()));
const auto it = kv_index.find(boost::make_tuple(table_id->id, "global"_n.to_uint64_t()));
EOS_ASSERT(it != kv_index.end(), chain::contract_table_query_exception, "Missing row in table global");

vector<char> data;
read_only::copy_inline_row(*it, data);
return abis.binary_to_variant(abis.get_table_type(N(global)), data, abi_serializer::create_yield_function( abi_serializer_max_time_us ), shorten_abi_errors );
return abis.binary_to_variant(abis.get_table_type("global"_n), data, abi_serializer::create_yield_function( abi_serializer_max_time_us ), shorten_abi_errors );
}

read_only::get_producers_result read_only::get_producers( const read_only::get_producers_params& p ) const try {
const abi_def abi = eosio::chain_apis::get_abi(db, config::system_account_name);
const auto table_type = get_table_type(abi, N(producers));
const auto table_type = get_table_type(abi, "producers"_n);
const abi_serializer abis{ abi, abi_serializer::create_yield_function( abi_serializer_max_time ) };
EOS_ASSERT(table_type == KEYi64, chain::contract_table_query_exception, "Invalid table type ${type} for table producers", ("type",table_type));

Expand All @@ -1939,9 +1939,9 @@ read_only::get_producers_result read_only::get_producers( const read_only::get_p

static const uint8_t secondary_index_num = 0;
const auto* const table_id = d.find<chain::table_id_object, chain::by_code_scope_table>(
boost::make_tuple(config::system_account_name, config::system_account_name, N(producers)));
boost::make_tuple(config::system_account_name, config::system_account_name, "producers"_n));
const auto* const secondary_table_id = d.find<chain::table_id_object, chain::by_code_scope_table>(
boost::make_tuple(config::system_account_name, config::system_account_name, name(N(producers).to_uint64_t() | secondary_index_num)));
boost::make_tuple(config::system_account_name, config::system_account_name, name("producers"_n.to_uint64_t() | secondary_index_num)));
EOS_ASSERT(table_id && secondary_table_id, chain::contract_table_query_exception, "Missing producers table");

const auto& kv_index = d.get_index<key_value_index, by_scope_primary>();
Expand Down Expand Up @@ -1970,7 +1970,7 @@ read_only::get_producers_result read_only::get_producers( const read_only::get_p
}
copy_inline_row(*kv_index.find(boost::make_tuple(table_id->id, it->primary_key)), data);
if (p.json)
result.rows.emplace_back( abis.binary_to_variant( abis.get_table_type(N(producers)), data, abi_serializer::create_yield_function( abi_serializer_max_time ), shorten_abi_errors ) );
result.rows.emplace_back( abis.binary_to_variant( abis.get_table_type("producers"_n), data, abi_serializer::create_yield_function( abi_serializer_max_time ), shorten_abi_errors ) );
else
result.rows.emplace_back(fc::variant(data));
}
Expand Down Expand Up @@ -2467,14 +2467,14 @@ read_only::get_account_results read_only::get_account( const get_account_params&
if( abi_serializer::to_abi(code_account.abi, abi) ) {
abi_serializer abis( abi, abi_serializer::create_yield_function( abi_serializer_max_time ) );

const auto token_code = N(eosio.token);
const auto token_code = "eosio.token"_n;

auto core_symbol = extract_core_symbol();

if (params.expected_core_symbol.valid())
core_symbol = *(params.expected_core_symbol);

const auto* t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( token_code, params.account_name, N(accounts) ));
const auto* t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( token_code, params.account_name, "accounts"_n ));
if( t_id != nullptr ) {
const auto &idx = d.get_index<key_value_index, by_scope_primary>();
auto it = idx.find(boost::make_tuple( t_id->id, core_symbol.to_symbol_code() ));
Expand All @@ -2489,7 +2489,7 @@ read_only::get_account_results read_only::get_account( const get_account_params&
}
}

t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, params.account_name, N(userres) ));
t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, params.account_name, "userres"_n ));
if (t_id != nullptr) {
const auto &idx = d.get_index<key_value_index, by_scope_primary>();
auto it = idx.find(boost::make_tuple( t_id->id, params.account_name.to_uint64_t() ));
Expand All @@ -2500,7 +2500,7 @@ read_only::get_account_results read_only::get_account( const get_account_params&
}
}

t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, params.account_name, N(delband) ));
t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, params.account_name, "delband"_n ));
if (t_id != nullptr) {
const auto &idx = d.get_index<key_value_index, by_scope_primary>();
auto it = idx.find(boost::make_tuple( t_id->id, params.account_name.to_uint64_t() ));
Expand All @@ -2511,7 +2511,7 @@ read_only::get_account_results read_only::get_account( const get_account_params&
}
}

t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, params.account_name, N(refunds) ));
t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, params.account_name, "refunds"_n ));
if (t_id != nullptr) {
const auto &idx = d.get_index<key_value_index, by_scope_primary>();
auto it = idx.find(boost::make_tuple( t_id->id, params.account_name.to_uint64_t() ));
Expand All @@ -2522,7 +2522,7 @@ read_only::get_account_results read_only::get_account( const get_account_params&
}
}

t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, config::system_account_name, N(voters) ));
t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, config::system_account_name, "voters"_n ));
if (t_id != nullptr) {
const auto &idx = d.get_index<key_value_index, by_scope_primary>();
auto it = idx.find(boost::make_tuple( t_id->id, params.account_name.to_uint64_t() ));
Expand All @@ -2533,7 +2533,7 @@ read_only::get_account_results read_only::get_account( const get_account_params&
}
}

t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, config::system_account_name, N(rexbal) ));
t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, config::system_account_name, "rexbal"_n ));
if (t_id != nullptr) {
const auto &idx = d.get_index<key_value_index, by_scope_primary>();
auto it = idx.find(boost::make_tuple( t_id->id, params.account_name.to_uint64_t() ));
Expand Down Expand Up @@ -2628,7 +2628,7 @@ chain::symbol read_only::extract_core_symbol()const {

// The following code makes assumptions about the contract deployed on eosio account (i.e. the system contract) and how it stores its data.
const auto& d = db.db();
const auto* t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( N(eosio), N(eosio), N(rammarket) ));
const auto* t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( "eosio"_n, "eosio"_n, "rammarket"_n ));
if( t_id != nullptr ) {
const auto &idx = d.get_index<key_value_index, by_scope_primary>();
auto it = idx.find(boost::make_tuple( t_id->id, eosio::chain::string_to_symbol_c(4,"RAMCORE") ));
Expand Down
Loading