Skip to content

Commit

Permalink
Partially implement deployment of contracts from the preload list
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelang committed Aug 5, 2018
1 parent 5a6edac commit 3c20d32
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/hera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,40 @@ bool hasWasmPreamble(vector<uint8_t> const& _input) {
_input[7] == 0;
}

bool deploySystemContract(string & code, evmc_address addr) {
evmc_message create_message;
create_message.input_data = reinterpret_cast<const uint8_t *>(code.c_str());
create_message.destination = addr;

//Prepare message call to deploy system contract

return true;
}

void preloadSystemContracts(hera_instance *hera) {
auto const& list = hera->contract_preload_list;

//Iterate through every entry on the contract preload list and deploy the code at the address from the filepath
for (size_t i = 0; i < list.size(); ++i) {
ifstream path;
path.open(list[i].second, ios::in | ios::binary);

if (path.is_open()) {
#if HERA_DEBUGGING
cerr << "Loading code at " << list[i].second << " into address " << hex << list[i].first.bytes << dec << endl;
#endif
string bytecode((istreambuf_iterator<char>(path)),
istreambuf_iterator<char>());
deploySystemContract(bytecode, list[i].first);
} else {
#if HERA_DEBUGGING
cerr << "Could not open filepath " << list[i].second << endl;
#endif
continue;
}
}
}

vector<uint8_t> callSystemContract(
evmc_context* context,
evmc_address const& address,
Expand Down Expand Up @@ -332,6 +366,8 @@ evmc_result hera_execute(
) noexcept {
hera_instance* hera = static_cast<hera_instance*>(instance);

preloadSystemContracts(hera);

evmc_result ret;
memset(&ret, 0, sizeof(evmc_result));

Expand Down

0 comments on commit 3c20d32

Please sign in to comment.