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

Commit

Permalink
add preactivate and reqactivated actions to eosio.bios (related to PR…
Browse files Browse the repository at this point in the history
…EACTIVATE_FEATURE protocol feature)
  • Loading branch information
arhag committed Mar 12, 2019
1 parent 1faf4b7 commit 4d20b1e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
42 changes: 41 additions & 1 deletion contracts/eosio.bios/include/eosio.bios/eosio.bios.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,35 @@
#include <eosiolib/eosio.hpp>
#include <eosiolib/privileged.hpp>
#include <eosiolib/producer_schedule.hpp>
#include <eosiolib/fixed_bytes.hpp>

namespace eosio {
namespace internal_use_do_not_use {
extern "C" {
__attribute__((eosio_wasm_import))
bool is_feature_activated( const ::capi_checksum256* feature_digest );

__attribute__((eosio_wasm_import))
void preactivate_feature( const ::capi_checksum256* feature_digest );
}
}
}

namespace eosio {
bool is_feature_activated( const eosio::checksum256& feature_digest ) {
auto feature_digest_data = feature_digest.extract_as_byte_array();
return internal_use_do_not_use::is_feature_activated(
reinterpret_cast<const ::capi_checksum256*>( feature_digest_data.data() )
);
}

void preactivate_feature( const eosio::checksum256& feature_digest ) {
auto feature_digest_data = feature_digest.extract_as_byte_array();
internal_use_do_not_use::preactivate_feature(
reinterpret_cast<const ::capi_checksum256*>( feature_digest_data.data() )
);
}
}

namespace eosio {
using eosio::permission_level;
Expand Down Expand Up @@ -140,6 +169,17 @@ namespace eosio {
require_auth( from );
}

[[eosio::action]]
void preactivate( const eosio::checksum256& feature_digest ) {
require_auth( get_self() );
preactivate_feature( feature_digest );
}

[[eosio::action]]
void reqactivated( const eosio::checksum256& feature_digest ) {
check( is_feature_activated( feature_digest ), "protocol feature is not activated" );
}

[[eosio::action]]
void setabi( name account, const std::vector<char>& abi ) {
abi_hash_table table(_self, _self.value);
Expand All @@ -165,7 +205,7 @@ namespace eosio {
};

typedef eosio::multi_index< "abihash"_n, abi_hash > abi_hash_table;

using newaccount_action = action_wrapper<"newaccount"_n, &bios::newaccount>;
using updateauth_action = action_wrapper<"updateauth"_n, &bios::updateauth>;
using deleteauth_action = action_wrapper<"deleteauth"_n, &bios::deleteauth>;
Expand Down
2 changes: 1 addition & 1 deletion contracts/eosio.bios/src/eosio.bios.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include <eosio.bios/eosio.bios.hpp>

EOSIO_DISPATCH( eosio::bios, (setpriv)(setalimits)(setglimits)(setprods)(setparams)(reqauth)(setabi) )
EOSIO_DISPATCH( eosio::bios, (setpriv)(setalimits)(setglimits)(setprods)(setparams)(reqauth)(setabi)(preactivate)(reqactivated) )

0 comments on commit 4d20b1e

Please sign in to comment.