Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Ref #123: Define/Implement unlinkauth
Browse files Browse the repository at this point in the history
Add an unlinkauth message type which removes a link from a message type
to a required authority
  • Loading branch information
nathanielhourt committed Aug 3, 2017
1 parent 80b0181 commit 07c5ca7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libraries/native_contract/eos_contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void apply_eos_linkauth(apply_context& context) {

if (link) {
EOS_ASSERT(link->required_permission != requirement.requirement, message_precondition_exception,
"Attempting to update required authority, but new requirement is same as old.");
"Attempting to update required authority, but new requirement is same as old");
db.modify(*link, [requirement = requirement.requirement](permission_link_object& link) {
link.required_permission = requirement;
});
Expand All @@ -392,5 +392,14 @@ void apply_eos_linkauth(apply_context& context) {
}
}

void apply_eos_unlinkauth(apply_context& context) {
auto& db = context.mutable_db;
auto unlink = context.msg.as<types::unlinkauth>();
auto linkKey = boost::make_tuple(unlink.account, unlink.code, unlink.type);
auto link = db.find<permission_link_object, by_message_type>(linkKey);
EOS_ASSERT(link != nullptr, message_precondition_exception, "Attempting to unlink authority, but no link found");
db.remove(*link);
}

} // namespace eos
} // namespace native
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void apply_eos_setproducer(chain::apply_context&);
void apply_eos_setproxy(chain::apply_context&);
void apply_eos_setcode(chain::apply_context&);
void apply_eos_linkauth(chain::apply_context&);
void apply_eos_unlinkauth(chain::apply_context&);

} // namespace eos
} // namespace native
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void native_contract_chain_initializer::register_types(chain_controller& chain,
SET_APP_HANDLER( eos, eos, setproxy );
SET_APP_HANDLER( eos, eos, setcode );
SET_APP_HANDLER( eos, eos, linkauth );
SET_APP_HANDLER( eos, eos, unlinkauth );
}

std::vector<chain::Message> native_contract_chain_initializer::prepare_database(chain_controller& chain,
Expand Down
5 changes: 5 additions & 0 deletions libraries/types/types.eos
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,8 @@ struct linkauth
code AccountName # The contract to require permissions to invoke
type FuncName
requirement PermissionName # The permission name to require

struct unlinkauth
account AccountName # The account to require permissions for
code AccountName # The contract to require permissions to invoke
type FuncName

0 comments on commit 07c5ca7

Please sign in to comment.