提交 74581363 编写于 作者: D Daniel Larimer

fix Name to string conversion, add new WASM hooks to test for notify and auth

上级 2729536b
......@@ -607,7 +607,7 @@ void chain_controller::process_message( const Transaction& trx, const Message& m
apply_message(apply_ctx);
for (const auto& recipient : message.recipients) {
if( recipient == message.code ) continue; /// we already ran it above
FC_ASSERT( recipient != message.code, "message::code handler is always called and shouldn't be included in recipient list" );
try {
apply_context recipient_ctx(*this,_db, trx, message, recipient);
validate_message_precondition(recipient_ctx);
......
......@@ -30,6 +30,8 @@ public:
void require_authorization(const types::AccountName& account);
void require_scope(const types::AccountName& account)const;
void require_recipient(const types::AccountName& account)const;
bool has_recipient( const types::AccountName& account )const;
bool has_authorization( const types::AccountName& account )const;
bool all_authorizations_used() const;
const chain_controller& controller;
......
......@@ -8,6 +8,15 @@
namespace eos { namespace chain {
bool message_validate_context::has_authorization(const types::AccountName& account)const {
auto itr = boost::find_if(msg.authorization, [&account](const types::AccountPermission& ap) {
return ap.account == account;
});
return itr != msg.authorization.end();
}
void message_validate_context::require_authorization(const types::AccountName& account) {
auto itr = boost::find_if(msg.authorization, [&account](const types::AccountPermission& ap) {
......@@ -29,12 +38,19 @@ void message_validate_context::require_scope(const types::AccountName& account)c
"Required scope ${scope} not declared by transaction", ("scope",account) );
}
void message_validate_context::require_recipient(const types::AccountName& account)const {
bool message_validate_context::has_recipient( const types::AccountName& account )const {
if( msg.code == account ) return true;
auto itr = boost::find_if(msg.recipients, [&account](const auto& recipient) {
return recipient == account;
});
EOS_ASSERT( itr != msg.recipients.end(), tx_missing_recipient,
return itr != msg.recipients.end();
}
void message_validate_context::require_recipient(const types::AccountName& account)const {
EOS_ASSERT( has_recipient( account ), tx_missing_recipient,
"Required recipient ${recipient} not declared by message", ("recipient",account)("recipients",msg.recipients) );
}
......
......@@ -149,6 +149,13 @@ DEFINE_INTRINSIC_FUNCTION1(env,requireNotice,requireNotice,none,i64,account) {
wasm_interface::get().current_validate_context->require_recipient( account );
}
DEFINE_INTRINSIC_FUNCTION1(env,hasRecipient,hasRecipient,i32,i64,account) {
return wasm_interface::get().current_validate_context->has_recipient( account );
}
DEFINE_INTRINSIC_FUNCTION1(env,hasAuth,hasAuth,i32,i64,account) {
return wasm_interface::get().current_validate_context->has_authorization( account );
}
DEFINE_INTRINSIC_FUNCTION1(env,requireScope,requireScope,none,i64,scope) {
wasm_interface::get().current_validate_context->require_scope( scope );
}
......
......@@ -62,7 +62,7 @@ namespace eos { namespace types {
if( c >= 'a' && c <= 'z' )
return (c - 'a') + 1;
if( c >= '1' && c <= '5' )
return (c - '1') + 26;
return (c - '1') + 27;
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册