diff --git a/modules/common/dap_chain_datum_token.c b/modules/common/dap_chain_datum_token.c index a795125e860eb5d23fda1e3d47cff34901a38b74..f3a442a4189620c66144907d8057be89c22760a2 100644 --- a/modules/common/dap_chain_datum_token.c +++ b/modules/common/dap_chain_datum_token.c @@ -201,9 +201,11 @@ void dap_chain_datum_token_flags_dump_to_json(json_object * json_obj_out, const return; } json_object *l_array_flags = json_object_new_array(); - for (uint16_t i = 0; BIT(i) <= DAP_CHAIN_DATUM_TOKEN_FLAG_MAX; i++) - if (a_flags & BIT(i)) - json_object_array_add(l_array_flags, json_object_new_string(dap_chain_datum_token_flag_to_str(BIT(i)))); + for (uint16_t i = 0; i < sizeof(s_flags_table) / sizeof(struct datum_token_flag_struct); i++) { + if (s_flags_table[i].val == a_flags) { + json_object_array_add(l_array_flags, json_object_new_string(s_flags_table[i].key)); + } + } json_object_object_add(json_obj_out, a_key, l_array_flags); } diff --git a/modules/net/dap_chain_node_cli.c b/modules/net/dap_chain_node_cli.c index d3c31c3f1c35284a83c382684f714c6fff836e8b..3e472f4d4e1fc0a20a18abeda98c8ee41c805107 100644 --- a/modules/net/dap_chain_node_cli.c +++ b/modules/net/dap_chain_node_cli.c @@ -128,24 +128,15 @@ int dap_chain_node_cli_init(dap_config_t * g_config) // Token commands dap_cli_server_cmd_add ("token_update", com_token_update, "Token update", "\nPrivate or CF20 token update\n" - "\nPrivate token update\n" - "token_update -net <net_name> [-chain <chain_name>] -token <existing token_ticker> -type private -total_supply <the same or more> -decimals <18>\n" - "-signs_total <the same total as the token you are updating> -signs_emission <the same total as the token you are updating> -certs <use the certificates of the token you are update>\n" - "-flags_set [<Flag_1>][,<Flag_2>]...[,<Flag_N>]...\n" - "-flag_unset [<Flag_1>][,<Flag_2>]...[,<Flag_N>]...\n" - "\t [-<Param name 1> <Param Value 1>] [-Param name 2> <Param Value 2>] ...[-<Param Name N> <Param Value N>]\n" - "\t Update token for <netname>:<chain name> with ticker <token ticker>, flags <Flag 1>,<Flag2>...<Flag N>\n" - "\t and custom parameters list <Param 1>, <Param 2>...<Param N>.\n" - "\nCF20 token update\n" - "token_update -net <net_name> [-chain <chain_name>] -token <existing token_ticker> -type CF20 -total_supply <the same or more/if 0 = endless> -decimals <18>\n" - "-signs_total <the same total as the token you are updating> -signs_emission <the same total as the token you are updating> -certs <use the certificates of the token you are update>\n" - "-flags_set [<Flag_1>][,<Flag_2>]...[,<Flag_N>]...\n" + "\nPrivate or CF20 token update\n" + "token_update -net <net_name> [-chain <chain_name>] -token <existing_token_ticker> -type CF20|private -total_supply <any_positive_number_or_zero> -decimals <18>\n" + "-signs_total <the_same_total_as_the_token_you_are_updating> -signs_emission <the_same_total_as_the_token_you_are_updating> -certs <use_the_certificates_of_the_token_you_are_update>\n" + "-flag_set [<Flag_1>][,<Flag_2>]...[,<Flag_N>]...\n" "-flag_unset [<Flag_1>][,<Flag_2>]...[,<Flag_N>]...\n" - "\t [-<Param name 1> <Param Value 1>] [-Param name 2> <Param Value 2>] ...[-<Param Name N> <Param Value N>]\n" + "\t [-<Param_name_1> <Param_Value_1>] [-Param_name_2> <Param_Value_2>] ...[-<Param_Name_N> <Param_Value_N>]\n" "\t Update token for <netname>:<chain name> with ticker <token ticker>, flags <Flag 1>,<Flag2>...<Flag N>\n" "\t and custom parameters list <Param 1>, <Param 2>...<Param N>.\n" - "\n" - "==Flags==" + "==Flags==\n" "\t ALL_BLOCKED:\t Blocked all permissions, usefull add it first and then add allows what you want to allow\n" "\t ALL_ALLOWED:\t Allowed all permissions if not blocked them. Be careful with this mode\n" "\t ALL_FROZEN:\t All permissions are temprorary frozen\n" @@ -159,7 +150,8 @@ int dap_chain_node_cli_init(dap_config_t * g_config) "\n" "==Params==\n" "General:\n" - "\t -flags <value>:\t List of flags from <value> to token declaration or update\n" + "\t -flag_set <value>:\t List of flags from <value> to token declaration or update\n" + "\t -flag_unset <value>:\t List of flags from <value> to token declaration or update\n" "\t -total_supply <value>:\t Set total supply - emission's maximum - to the <value>\n" "\t -total_signs_valid <value>:\t Set valid signatures count's minimum\n" "\t -description <value>:\t Updated description for this token\n" @@ -173,6 +165,7 @@ int dap_chain_node_cli_init(dap_config_t * g_config) "\t -tx_sender_allowed <value>:\t Set allowed tx sender(s)\n" "\t -tx_sender_blocked <value>:\t Set allowed tx sender(s)\n" "\n" + " -total_supply Sets the maximum size of supply token, If supply is not limited, it is set to 0.\n" ); diff --git a/modules/net/dap_chain_node_cli_cmd_tx.c b/modules/net/dap_chain_node_cli_cmd_tx.c index ee80895e98eb3eb293762ebb6585a84d83711104..df1ac92b19193450127ebd2385fb6fdf01e7aa07 100644 --- a/modules/net/dap_chain_node_cli_cmd_tx.c +++ b/modules/net/dap_chain_node_cli_cmd_tx.c @@ -844,6 +844,7 @@ static json_object* dap_db_chain_history_token_list(dap_chain_t * a_chain, const json_object_object_add(l_jobj_ticker, "declarations", l_jobj_decls); json_object_object_add(l_jobj_ticker, "updates", l_jobj_updates); json_object_object_add(l_jobj_tickers, l_token->ticker, l_jobj_ticker); + l_token_num++; } else { l_jobj_decls = json_object_object_get(l_jobj_ticker, "declarations"); l_jobj_updates = json_object_object_get(l_jobj_ticker, "updates"); @@ -868,7 +869,6 @@ static json_object* dap_db_chain_history_token_list(dap_chain_t * a_chain, const break; } DAP_DELETE(l_token); - l_token_num++; } a_chain->callback_datum_iter_delete(l_datum_iter); if (a_token_num) @@ -896,7 +896,7 @@ static size_t dap_db_net_history_token_list(dap_chain_net_t * l_net, const char json_obj_tx = dap_db_chain_history_token_list(l_chain_cur, a_token_name, a_hash_out_type, &l_token_num); if(json_obj_tx) json_object_array_add(json_arr_obj_tx, json_obj_tx); - l_token_num_total += l_token_num; + l_token_num_total += l_token_num; } json_object_object_add(a_obj_out, "TOKENS", json_arr_obj_tx); return l_token_num_total; @@ -1111,10 +1111,10 @@ int com_token(int a_argc, char ** a_argv, void **a_str_reply) // token list if(l_cmd == CMD_LIST) { json_object* json_obj_tx = json_object_new_object(); - size_t l_token_num_total = dap_db_net_history_token_list(l_net, NULL, l_hash_out_type, json_obj_tx); + size_t l_total_all_token = dap_db_net_history_token_list(l_net, NULL, l_hash_out_type, json_obj_tx); - //total - json_object_object_add(json_obj_tx, "tokens", json_object_new_uint64(l_token_num_total)); + json_object_object_length(json_obj_tx); + json_object_object_add(json_obj_tx, "tokens", json_object_new_uint64(l_total_all_token)); json_object_array_add(*json_arr_reply, json_obj_tx); return 0; }