Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
create_account_subcommand Struct Reference

Public Member Functions

 create_account_subcommand (CLI::App *actionRoot, bool s)
 

Public Attributes

string creator
 
string account_name
 
string owner_key_str
 
string active_key_str
 
string stake_net
 
string stake_cpu
 
uint32_t buy_ram_bytes_in_kbytes = 0
 
uint32_t buy_ram_bytes = 0
 
string buy_ram_eos
 
bool transfer = false
 
bool simple = false
 

Detailed Description

Definition at line 1128 of file main.cpp.

Constructor & Destructor Documentation

◆ create_account_subcommand()

create_account_subcommand::create_account_subcommand ( CLI::App * actionRoot,
bool s )
inline

Definition at line 1141 of file main.cpp.

1141 : simple(s) {
1142 auto createAccount = actionRoot->add_subcommand(
1143 (simple ? "account" : "newaccount"),
1144 (simple ? localized("Create a new account on the blockchain (assumes system contract does not restrict RAM usage)")
1145 : localized("Create a new account on the blockchain with initial resources") )
1146 );
1147 createAccount->add_option("creator", creator, localized("The name of the account creating the new account"))->required();
1148 createAccount->add_option("name", account_name, localized("The name of the new account"))->required();
1149 createAccount->add_option("OwnerKey", owner_key_str, localized("The owner public key or permission level for the new account"))->required();
1150 createAccount->add_option("ActiveKey", active_key_str, localized("The active public key or permission level for the new account"));
1151
1152 if (!simple) {
1153 createAccount->add_option("--stake-net", stake_net,
1154 (localized("The amount of tokens delegated for net bandwidth")))->required();
1155 createAccount->add_option("--stake-cpu", stake_cpu,
1156 (localized("The amount of tokens delegated for CPU bandwidth")))->required();
1157 createAccount->add_option("--buy-ram-kbytes", buy_ram_bytes_in_kbytes,
1158 (localized("The amount of RAM bytes to purchase for the new account in kibibytes (KiB)")));
1159 createAccount->add_option("--buy-ram-bytes", buy_ram_bytes,
1160 (localized("The amount of RAM bytes to purchase for the new account in bytes")));
1161 createAccount->add_option("--buy-ram", buy_ram_eos,
1162 (localized("The amount of RAM bytes to purchase for the new account in tokens")));
1163 createAccount->add_flag("--transfer", transfer,
1164 (localized("Transfer voting power and right to unstake tokens to receiver")));
1165 }
1166
1167 add_standard_transaction_options(createAccount, "creator@active");
1168
1169 createAccount->callback([this] {
1170 auth_type owner, active;
1171
1172 if( owner_key_str.find('@') != string::npos ) {
1173 try {
1175 } SYS_RETHROW_EXCEPTIONS( explained_exception, "Invalid owner permission level: ${permission}", ("permission", owner_key_str) )
1176 } else {
1177 try {
1179 } SYS_RETHROW_EXCEPTIONS( public_key_type_exception, "Invalid owner public key: ${public_key}", ("public_key", owner_key_str) );
1180 }
1181
1182 if( active_key_str.empty() ) {
1183 active = owner;
1184 } else if( active_key_str.find('@') != string::npos ) {
1185 try {
1187 } SYS_RETHROW_EXCEPTIONS( explained_exception, "Invalid active permission level: ${permission}", ("permission", active_key_str) )
1188 } else {
1189 try {
1191 } SYS_RETHROW_EXCEPTIONS( public_key_type_exception, "Invalid active public key: ${public_key}", ("public_key", active_key_str) );
1192 }
1193
1194 auto create = create_newaccount(name(creator), name(account_name), owner, active);
1195 if (!simple) {
1196 SYSC_ASSERT( buy_ram_eos.size() || buy_ram_bytes_in_kbytes || buy_ram_bytes, "ERROR: One of --buy-ram, --buy-ram-kbytes or --buy-ram-bytes should have non-zero value" );
1197 SYSC_ASSERT( !buy_ram_bytes_in_kbytes || !buy_ram_bytes, "ERROR: --buy-ram-kbytes and --buy-ram-bytes cannot be set at the same time" );
1200 auto net = to_asset(stake_net);
1201 auto cpu = to_asset(stake_cpu);
1202 if ( net.get_amount() != 0 || cpu.get_amount() != 0 ) {
1203 action delegate = create_delegate( name(creator), name(account_name), net, cpu, transfer);
1204 send_actions( { create, buyram, delegate } );
1205 } else {
1206 send_actions( { create, buyram } );
1207 }
1208 } else {
1209 send_actions( { create } );
1210 }
1211 });
1212 }
std::string name
#define SYS_RETHROW_EXCEPTIONS(exception_type, FORMAT,...)
App * add_subcommand(std::string subcommand_name="", std::string subcommand_description="")
Add a subcommand. Inherits INHERITABLE and OptionDefaults, and help flag.
Definition CLI11.hpp:5538
Option * add_option(std::string option_name, callback_t option_callback, std::string option_description="", bool defaulted=false, std::function< std::string()> func={})
Definition CLI11.hpp:5099
CRTP * required(bool value=true)
Set the option as required.
Definition CLI11.hpp:3400
#define localized(str,...)
Definition localize.hpp:10
fc::crypto::public_key public_key_type
Definition types.hpp:76
chain::permission_level to_permission_level(const std::string &s)
Definition main.cpp:666
#define SYSC_ASSERT(TEST,...)
Definition main.cpp:134
asset to_asset(account_name code, const string &s)
Definition main.cpp:812
chain::action create_delegate(const name &from, const name &receiver, const asset &net, const asset &cpu, bool transfer)
Definition main.cpp:705
std::variant< public_key_type, permission_level > auth_type
Definition main.cpp:130
chain::action create_buyram(const name &creator, const name &newaccount, const asset &quantity)
Definition main.cpp:687
void add_standard_transaction_options(CLI::App *cmd, string default_permission="")
Definition main.cpp:202
void send_actions(std::vector< chain::action > &&actions, packed_transaction::compression_type compression=packed_transaction::compression_type::none)
Definition main.cpp:616
chain::action create_newaccount(const name &creator, const name &newaccount, auth_type owner, auth_type active)
Definition main.cpp:671
chain::action create_buyrambytes(const name &creator, const name &newaccount, uint32_t numbytes)
Definition main.cpp:696
uint32_t buy_ram_bytes_in_kbytes
Definition main.cpp:1135
Immutable except for fc::from_variant.
Definition name.hpp:43
char * s
Here is the call graph for this function:

Member Data Documentation

◆ account_name

string create_account_subcommand::account_name

Definition at line 1130 of file main.cpp.

◆ active_key_str

string create_account_subcommand::active_key_str

Definition at line 1132 of file main.cpp.

◆ buy_ram_bytes

uint32_t create_account_subcommand::buy_ram_bytes = 0

Definition at line 1136 of file main.cpp.

◆ buy_ram_bytes_in_kbytes

uint32_t create_account_subcommand::buy_ram_bytes_in_kbytes = 0

Definition at line 1135 of file main.cpp.

◆ buy_ram_eos

string create_account_subcommand::buy_ram_eos

Definition at line 1137 of file main.cpp.

◆ creator

string create_account_subcommand::creator

Definition at line 1129 of file main.cpp.

◆ owner_key_str

string create_account_subcommand::owner_key_str

Definition at line 1131 of file main.cpp.

◆ simple

bool create_account_subcommand::simple = false

Definition at line 1139 of file main.cpp.

◆ stake_cpu

string create_account_subcommand::stake_cpu

Definition at line 1134 of file main.cpp.

◆ stake_net

string create_account_subcommand::stake_net

Definition at line 1133 of file main.cpp.

◆ transfer

bool create_account_subcommand::transfer = false

Definition at line 1138 of file main.cpp.


The documentation for this struct was generated from the following file: