提交 c66156f3 编写于 作者: D Daniel Larimer 提交者: GitHub

Merge pull request #424 from brianjohnson5972/215_native_abi_serialization

Native ABI Serialization Unit Tests
......@@ -19,6 +19,8 @@ public:
virtual void register_types(chain::chain_controller& chain, chainbase::database& db) override;
virtual std::vector<chain::Message> prepare_database(chain::chain_controller& chain,
chainbase::database& db) override;
static types::Abi eos_contract_abi();
};
} } // namespace eos::native_contract
......
......@@ -54,22 +54,11 @@ void native_contract_chain_initializer::register_types(chain_controller& chain,
SET_APP_HANDLER( eos, eos, unlinkauth );
}
std::vector<chain::Message> native_contract_chain_initializer::prepare_database(chain_controller& chain,
chainbase::database& db) {
std::vector<chain::Message> messages_to_process;
// Create the singleton object, ProducerScheduleObject
db.create<native::eos::ProducerScheduleObject>([](const auto&){});
/// Create the native contract accounts manually; sadly, we can't run their contracts to make them create themselves
auto CreateNativeAccount = [this, &db](Name name, auto liquidBalance) {
db.create<account_object>([this, &name](account_object& a) {
a.name = name;
a.creation_date = genesis.initial_timestamp;
if( name == config::EosContractName ) {
types::Abi native_contract_chain_initializer::eos_contract_abi()
{
types::Abi eos_abi;
eos_abi.types.push_back( types::TypeDef{"AccountName","Name"} );
eos_abi.types.push_back( types::TypeDef{"ShareType","Int64"} );
eos_abi.actions.push_back( types::Action{Name("transfer"), "transfer"} );
eos_abi.actions.push_back( types::Action{Name("lock"), "lock"} );
eos_abi.actions.push_back( types::Action{Name("unlock"), "unlock"} );
......@@ -94,7 +83,25 @@ std::vector<chain::Message> native_contract_chain_initializer::prepare_database(
eos_abi.structs.push_back( eos::types::GetStruct<eos::types::unlinkauth>::type() );
eos_abi.structs.push_back( eos::types::GetStruct<eos::types::deleteauth>::type() );
eos_abi.structs.push_back( eos::types::GetStruct<eos::types::newaccount>::type() );
a.set_abi(eos_abi);
return eos_abi;
}
std::vector<chain::Message> native_contract_chain_initializer::prepare_database(chain_controller& chain,
chainbase::database& db) {
std::vector<chain::Message> messages_to_process;
// Create the singleton object, ProducerScheduleObject
db.create<native::eos::ProducerScheduleObject>([](const auto&){});
/// Create the native contract accounts manually; sadly, we can't run their contracts to make them create themselves
auto CreateNativeAccount = [this, &db](Name name, auto liquidBalance) {
db.create<account_object>([this, &name](account_object& a) {
a.name = name;
a.creation_date = genesis.initial_timestamp;
if( name == config::EosContractName ) {
a.set_abi(eos_contract_abi());
}
});
db.create<native::eos::BalanceObject>([&name, liquidBalance]( auto& b) {
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册