Skip to content

Commit

Permalink
Release EVT 2.2
Browse files Browse the repository at this point in the history
Merge branch 'master' into mainnet
  • Loading branch information
harrywong committed Nov 12, 2018
2 parents 5f10e61 + 50cd517 commit 7b0124b
Show file tree
Hide file tree
Showing 104 changed files with 5,210 additions and 2,856 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
[submodule "libraries/rocksdb"]
path = libraries/rocksdb
url = https://github.com/facebook/rocksdb.git
branch = 5.14.fb
branch = 5.15.fb
[submodule "libraries/safeint"]
path = libraries/safeint
url = https://github.com/dcleblanc/SafeInt.git
[submodule "libraries/rapidjson"]
path = libraries/rapidjson
url = https://github.com/everitoken/rapidjson.git
[submodule "libraries/fmt"]
path = libraries/fmt
url = https://github.com/fmtlib/fmt.git
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_EXTENSIONS ON )
set( CXX_STANDARD_REQUIRED ON)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_PATCH 1)
set(VERSION_MAJOR 2)
set(VERSION_MINOR 2)
set(VERSION_PATCH 0)

set( CLI_CLIENT_EXECUTABLE_NAME evtc )
set( GUI_CLIENT_EXECUTABLE_NAME evt )
Expand Down
43 changes: 21 additions & 22 deletions bind/libevt/evt_abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
#include <fc/variant.hpp>
#include <fc/io/json.hpp>

using evt::chain::contracts::abi_serializer;
using evt::chain::contracts::abi_def;
using fc::sha256;
using evt::chain::bytes;
using evt::chain::transaction;
using evt::chain::chain_id_type;
using fc::sha256;
using evt::chain::transaction;
using evt::chain::contracts::abi_serializer;
using evt::chain::contracts::abi_def;

template <>
evt_data_t*
Expand All @@ -44,14 +44,13 @@ extern "C" {

void*
evt_abi() {
abi_serializer::set_max_serialization_time(fc::hours(1));
auto abi = new abi_def(evt::chain::contracts::evt_contract_abi());
auto abi = new abi_serializer(evt::chain::contracts::evt_contract_abi(), fc::hours(1));
return (void*)abi;
}

void
evt_free_abi(void* abi) {
delete (abi_def*)abi;
delete (abi_serializer*)abi;
}

int
Expand All @@ -68,8 +67,8 @@ evt_abi_json_to_bin(void* evt_abi, const char* action, const char* json, evt_bin
if(bin == nullptr) {
return EVT_INVALID_ARGUMENT;
}
auto abi = abi_serializer(*(abi_def*)evt_abi);
fc::variant var;
auto& abi = *(abi_serializer*)evt_abi;
auto var = fc::variant();
try {
var = fc::json::from_string(json);
if(!var.is_object()) {
Expand All @@ -78,12 +77,12 @@ evt_abi_json_to_bin(void* evt_abi, const char* action, const char* json, evt_bin
}
CATCH_AND_RETURN(EVT_INVALID_JSON)

auto action_type = abi.get_action_type(action);
if(action_type.empty()) {
auto type = abi.get_action_type(action);
if(type.empty()) {
return EVT_INVALID_ACTION;
}
try {
auto b = abi.variant_to_binary(action_type, var);
auto b = abi.variant_to_binary(type, var);
if(b.empty()) {
return EVT_INVALID_JSON;
}
Expand All @@ -109,17 +108,17 @@ evt_abi_bin_to_json(void* evt_abi, const char* action, evt_bin_t* bin, char** js
if(json == nullptr) {
return EVT_INVALID_ARGUMENT;
}
auto abi = abi_serializer(*(abi_def*)evt_abi);
auto action_type = abi.get_action_type(action);
if(action_type.empty()) {
auto& abi = *(abi_serializer*)evt_abi;
auto type = abi.get_action_type(action);
if(type.empty()) {
return EVT_INVALID_ACTION;
}
try {
bytes b;
if(extract_data(bin, b) != EVT_OK) {
return EVT_INVALID_BINARY;
}
auto var = abi.binary_to_variant(action_type, b);
auto var = abi.binary_to_variant(type, b);
auto str = fc::json::to_string(var);
*json = strdup(str);
}
Expand All @@ -144,14 +143,14 @@ evt_trx_json_to_digest(void* evt_abi, const char* json, evt_chain_id_t* chain_i
return EVT_INVALID_HASH;
}

auto abi = abi_serializer(*(abi_def*)evt_abi);
auto trx = transaction();
auto& abi = *(abi_serializer*)evt_abi;
auto trx = transaction();
try {
auto var = fc::json::from_string(json);
abi.from_variant(var, trx, [&abi]() -> const abi_serializer& { return abi; });
auto d = trx.sig_digest(chain_id_type(idhash));
auto data = get_evt_data(d);
*digest = data;
abi.from_variant(var, trx);

auto d = trx.sig_digest(chain_id_type(idhash));
*digest = get_evt_data(d);
}
CATCH_AND_RETURN(EVT_INTERNAL_ERROR)

Expand Down
2 changes: 1 addition & 1 deletion bind/libevt/include/libevt/evt_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ typedef evt_data_t evt_chain_id_t;
typedef evt_data_t evt_block_id_t;

void* evt_abi();
void evt_free_abi(void* abi);
void evt_free_abi(void* abi);

int evt_abi_json_to_bin(void* evt_abi, const char* action, const char* json, evt_bin_t** bin /* out */);
int evt_abi_bin_to_json(void* evt_abi, const char* action, evt_bin_t* bin, char** json /* out */);
Expand Down
6 changes: 4 additions & 2 deletions bind/libevt/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
add_executable( libevt_tests libevt_tests.cpp )
target_link_libraries( libevt_tests libevt evt_chain_lite ${Boost_LIBRARIES} )
target_include_directories( libevt_tests PUBLIC ${Boost_INCLUDE_DIR} )
target_link_libraries( libevt_tests libevt evt_chain_lite )
target_include_directories(libevt_tests
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../libraries/catch/include
)

add_test(NAME libevt_tests
COMMAND bind/libevt/test/libevt_tests
Expand Down
Loading

0 comments on commit 7b0124b

Please sign in to comment.