855 {
856 auto permissions = accountCmd->
add_subcommand(
"permission",
localized(
"Set parameters dealing with account permissions"));
858 permissions->add_option(
"permission", permission,
localized(
"The permission name to set/delete an authority for"))->
required();
859 permissions->add_option(
"authority",
authority_json_or_file,
localized(
"[delete] NULL, [create/update] public key, JSON string or filename defining the authority, [code] contract name"));
860 permissions->add_option(
"parent", parent,
localized(
"[create] The permission name of this parents permission, defaults to 'active'"));
861 permissions->add_flag(
"--add-code",
add_code,
localized(
"[code] add '${code}' permission to specified permission authority", (
"code",
name(config::sysio_code_name))));
862 permissions->add_flag(
"--remove-code",
remove_code,
localized(
"[code] remove '${code}' permission from specified permission authority", (
"code",
name(config::sysio_code_name))));
863
865
866 permissions->callback([this] {
869
871
872 bool need_parent = parent.empty() && (
name(permission) !=
name(
"owner"));
874
877 return;
878 }
879
880 if ( need_parent || need_auth ) {
883 auto itr = std::find_if(res.permissions.begin(), res.permissions.end(), [&](const auto& perm) {
884 return perm.perm_name == name(permission);
885 });
886
887 if ( need_parent ) {
888
889 if ( itr != res.permissions.end() ) {
890 parent = (*itr).parent.to_string();
891 } else {
892
893 parent = config::active_name.to_string();
894 }
895 }
896
897 if ( need_auth ) {
899 auto code_name = config::sysio_code_name;
900
901 if ( itr != res.permissions.end() ) {
902
903 auth = std::move((*itr).required_auth);
904
905 auto code_perm = permission_level { actor, code_name };
906 auto itr2 = std::lower_bound(auth.
accounts.begin(), auth.
accounts.end(), code_perm, [&](
const auto& perm_level,
const auto&
value) {
907 return perm_level.permission < value;
908 });
909
911 if ( itr2 != auth.
accounts.end() && itr2->permission == code_perm ) {
912
914 if ( auth.
threshold > std::numeric_limits<weight_type>::max() ) {
915 std::cerr << "ERROR: Threshold is too high to be satisfied by sole code permission" << std::endl;
916 return;
917 }
918 std::cerr <<
localized(
"The weight of '${actor}@${code}' in '${permission}' permission authority will be increased up to threshold",
919 (
"actor",
actor)(
"code", code_name)(
"permission", permission)) << std::endl;
921 } else {
922 std::cerr <<
localized(
"ERROR: The permission '${permission}' already contains '${actor}@${code}'",
923 (
"permission", permission)(
"actor",
actor)(
"code", code_name)) << std::endl;
925 }
926 } else {
927
928 if ( auth.
threshold > std::numeric_limits<weight_type>::max() ) {
929 std::cerr << "ERROR: Threshold is too high to be satisfied by sole code permission" << std::endl;
930 return;
931 }
933 .permission = {
actor, code_name },
935 });
936 }
937 } else {
938 if ( itr2 != auth.
accounts.end() && itr2->permission == code_perm ) {
939
943 return;
944 }
945 } else {
946
947 std::cerr <<
localized(
"ERROR: '${actor}@${code}' does not exist in '${permission}' permission authority",
948 (
"actor",
actor)(
"code", code_name)(
"permission", permission)) << std::endl;
949 return;
950 }
951 }
952 } else {
954
957 .permission = {
actor, code_name },
958 .weight = 1
959 });
960 } else {
961
962 std::cerr <<
localized(
"ERROR: The permission '${permission}' does not exist", (
"permission", permission)) << std::endl;
963 return;
964 }
965 }
966 }
967 }
968
969 if ( !need_auth ) {
971 }
972
974 });
975 }
App * add_subcommand(std::string subcommand_name="", std::string subcommand_description="")
Add a subcommand. Inherits INHERITABLE and OptionDefaults, and help flag.
Option * add_option(std::string option_name, callback_t option_callback, std::string option_description="", bool defaulted=false, std::function< std::string()> func={})
CRTP * required(bool value=true)
Set the option as required.
An order-preserving dictionary of variants.
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
#define localized(str,...)
const string get_account_func
#define SYSC_ASSERT(TEST,...)
chain::action create_updateauth(const name &account, const name &permission, const name &parent, const authority &auth)
void add_standard_transaction_options(CLI::App *cmd, string default_permission="")
authority parse_json_authority_or_key(const std::string &authorityJsonOrFile)
void send_actions(std::vector< chain::action > &&actions, packed_transaction::compression_type compression=packed_transaction::compression_type::none)
chain::action create_deleteauth(const name &account, const name &permission)
fc::variant call(const std::string &url, const std::string &path, const T &v)
string authority_json_or_file
vector< wait_weight > waits
vector< permission_level_weight > accounts
vector< key_weight > keys
Immutable except for fc::from_variant.