diff --git a/CMakeLists.txt b/CMakeLists.txt index 3919ce0..c779481 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(evm_bridge_contracts) +if(NOT DEFINED eosevm_DIR) + message(FATAL_ERROR "The `eosevm_DIR` argument was not provided!") +endif() + set(EXTERNAL_DIR ${CMAKE_SOURCE_DIR}/external) set(SOLIDITY_BYTECODES_DIR ${CMAKE_BINARY_DIR}/solidity_contracts/bytecodes) diff --git a/antelope_contracts/contracts/CMakeLists.txt b/antelope_contracts/contracts/CMakeLists.txt index 0f223aa..85977c3 100644 --- a/antelope_contracts/contracts/CMakeLists.txt +++ b/antelope_contracts/contracts/CMakeLists.txt @@ -3,6 +3,8 @@ project(evm_bridge_antelope_contracts) find_package(cdt REQUIRED) +add_compile_definitions(ANTELOPE) + add_subdirectory(erc20) add_subdirectory(stubs) add_subdirectory(deposit_proxy) diff --git a/antelope_contracts/contracts/deposit_proxy/CMakeLists.txt b/antelope_contracts/contracts/deposit_proxy/CMakeLists.txt index 7455240..69dcd28 100644 --- a/antelope_contracts/contracts/deposit_proxy/CMakeLists.txt +++ b/antelope_contracts/contracts/deposit_proxy/CMakeLists.txt @@ -1,4 +1,3 @@ add_contract( deposit_proxy deposit_proxy src/deposit_proxy.cpp ) target_include_directories( deposit_proxy PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ) -target_ricardian_directory( deposit_proxy ${CMAKE_CURRENT_SOURCE_DIR}/ricardian ) target_compile_options(deposit_proxy PUBLIC --no-missing-ricardian-clause) \ No newline at end of file diff --git a/antelope_contracts/contracts/deposit_proxy/README.txt b/antelope_contracts/contracts/deposit_proxy/README.txt deleted file mode 100644 index beb26e8..0000000 --- a/antelope_contracts/contracts/deposit_proxy/README.txt +++ /dev/null @@ -1,12 +0,0 @@ ---- deposit_proxy Project --- - - - How to Build - - - cd to 'build' directory - - run the command 'cmake ..' - - run the command 'make' - - - After build - - - The built smart contract is under the 'deposit_proxy' directory in the 'build' directory - - You can then do a 'set contract' action with 'cleos' and point in to the './build/deposit_proxy' directory - - - Additions to CMake should be done to the CMakeLists.txt in the './src' directory and not in the top level CMakeLists.txt \ No newline at end of file diff --git a/antelope_contracts/contracts/deposit_proxy/include/deposit_proxy.hpp b/antelope_contracts/contracts/deposit_proxy/include/deposit_proxy/deposit_proxy.hpp similarity index 100% rename from antelope_contracts/contracts/deposit_proxy/include/deposit_proxy.hpp rename to antelope_contracts/contracts/deposit_proxy/include/deposit_proxy/deposit_proxy.hpp diff --git a/antelope_contracts/contracts/deposit_proxy/src/deposit_proxy.cpp b/antelope_contracts/contracts/deposit_proxy/src/deposit_proxy.cpp index aea5559..8e8a37a 100644 --- a/antelope_contracts/contracts/deposit_proxy/src/deposit_proxy.cpp +++ b/antelope_contracts/contracts/deposit_proxy/src/deposit_proxy.cpp @@ -1,16 +1,10 @@ #include -#include +#include void deposit_proxy::transfer(eosio::name from, eosio::name to, eosio::asset quantity, const std::string& memo) { if (to != get_self() || from == get_self()) return; - constexpr extended_symbol EOS = eosio::extended_symbol{eosio::symbol{"EOS",4}, "eosio.token"_n}; - constexpr extended_symbol USDT = eosio::extended_symbol{eosio::symbol{"USDT",4}, "tethertether"_n}; - - const auto s = eosio::extended_symbol{quantity.symbol, get_first_receiver()}; - eosio::check(s == EOS || s == USDT, "unregistered token"); - bool memo_has_evm_address = false; if (memo.size() == 42 && memo[0] == '0' && memo[1] == 'x') { memo_has_evm_address = std::all_of(memo.begin() + 2, memo.end(), [](char c) { @@ -22,6 +16,9 @@ void deposit_proxy::transfer(eosio::name from, eosio::name to, eosio::asset quan eosio::check(memo_has_evm_address, "memo must be a valid EVM address"); + constexpr extended_symbol EOS = eosio::extended_symbol{eosio::symbol{"EOS",4}, "eosio.token"_n}; + const auto s = eosio::extended_symbol{quantity.symbol, get_first_receiver()}; + auto destination = s == EOS ? "eosio.evm"_n : "eosio.erc2o"_n; action(std::vector{{get_self(), "active"_n}}, s.get_contract(), "transfer"_n, std::make_tuple(get_self(), destination, quantity, memo) diff --git a/antelope_contracts/contracts/erc20/CMakeLists.txt b/antelope_contracts/contracts/erc20/CMakeLists.txt index b7aa581..ce35f6f 100644 --- a/antelope_contracts/contracts/erc20/CMakeLists.txt +++ b/antelope_contracts/contracts/erc20/CMakeLists.txt @@ -20,7 +20,6 @@ list(APPEND SOURCES ${EXTERNAL_DIR}/silkworm/silkworm/core/rlp/decode.cpp ) -add_compile_definitions(ANTELOPE) add_contract( erc20 erc20 ${SOURCES} ) target_include_directories( erc20 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include diff --git a/antelope_contracts/tests/erc20/contracts.hpp.in b/antelope_contracts/tests/erc20/contracts.hpp.in index cbed015..c2b5ba9 100644 --- a/antelope_contracts/tests/erc20/contracts.hpp.in +++ b/antelope_contracts/tests/erc20/contracts.hpp.in @@ -35,7 +35,9 @@ struct contracts { static std::vector evm_wasm() { return read_wasm("${eosevm_DIR}/evm_runtime/evm_runtime.wasm"); } static std::vector evm_abi() { return read_abi("${eosevm_DIR}/evm_runtime/evm_runtime.abi"); } - static std::vector evm_depoit_proxy_wasm() { return read_wasm("${ANTELOPE_CONTRACTS_BINARY_DIR}/deposit_proxy/deposit_proxy.wasm"); } + + static std::vector evm_deposit_proxy_wasm() { return read_wasm("${ANTELOPE_CONTRACTS_BINARY_DIR}/deposit_proxy/deposit_proxy.wasm"); } + static std::vector evm_deposit_proxy_abi() { return read_abi("${ANTELOPE_CONTRACTS_BINARY_DIR}/deposit_proxy/deposit_proxy.abi"); } }; } // namespace testing -} // namespace eosio \ No newline at end of file +} // namespace eosio diff --git a/antelope_contracts/tests/erc20/erc20_tester.cpp b/antelope_contracts/tests/erc20/erc20_tester.cpp index e8f0d58..c72a1f8 100644 --- a/antelope_contracts/tests/erc20/erc20_tester.cpp +++ b/antelope_contracts/tests/erc20/erc20_tester.cpp @@ -163,7 +163,7 @@ erc20_tester::erc20_tester(bool use_real_evm, std::string native_symbol_str) : n token_account, mvo()("to", faucet_account_name)("quantity", asset(1'000'000'000'0000, symbol::from_string("4,USDT")))("memo", "")); - set_code(evmin_account, testing::contracts::evm_depoit_proxy_wasm()); + set_code(evmin_account, testing::contracts::evm_deposit_proxy_wasm()); produce_block(); diff --git a/antelope_contracts/tests/erc20/erc20_tester.hpp b/antelope_contracts/tests/erc20/erc20_tester.hpp index e4d4c99..fb9ee9b 100644 --- a/antelope_contracts/tests/erc20/erc20_tester.hpp +++ b/antelope_contracts/tests/erc20/erc20_tester.hpp @@ -158,8 +158,6 @@ class erc20_tester : public eosio::testing::base_tester { prepare_deploy_contract_tx(const unsigned char* contract, size_t size, uint64_t gas_limit) const; transaction_trace_ptr pushtx(const silkworm::Transaction& trx, name miner = evm_account); - std::string getSolidityContractAddress(); - eosio::chain::abi_serializer abi_ser; eosio::chain::abi_serializer token_abi_ser; diff --git a/antelope_contracts/tests/erc20/transfer_tests.cpp b/antelope_contracts/tests/erc20/transfer_tests.cpp index a75de20..dc778b5 100644 --- a/antelope_contracts/tests/erc20/transfer_tests.cpp +++ b/antelope_contracts/tests/erc20/transfer_tests.cpp @@ -134,7 +134,7 @@ try { mvo()("to", dummy_token_account)("quantity", asset(1'000'000'000'0000, eosio::chain::symbol{4,"EOS"}))("memo", "")); BOOST_REQUIRE_EXCEPTION(transfer_token(dummy_token_account, dummy_token_account, evmin_account, make_asset(10000), "0x0000000000000000000000000000000000000000"), - eosio_assert_message_exception, eosio_assert_message_is("unregistered token")); + eosio_assert_message_exception, eosio_assert_message_is("received unregistered token")); BOOST_REQUIRE_EXCEPTION(transfer_token(eos_token_account, "alice"_n, evmin_account, make_asset(10000), "0x000000000000000000000000000000000000000Z"), eosio_assert_message_exception, eosio_assert_message_is("memo must be a valid EVM address")); @@ -251,8 +251,6 @@ try { mvo()("token_contract", token_account)("token_symbol_code", "USDT")("egress_fee", make_asset(1000))), missing_auth_exception, eosio::testing::fc_exception_message_starts_with("missing authority of eosio.erc2o")); - - produce_block(); } FC_LOG_AND_RETHROW() diff --git a/external/silkworm b/external/silkworm index d661be9..8a3b69e 160000 --- a/external/silkworm +++ b/external/silkworm @@ -1 +1 @@ -Subproject commit d661be9a624505fb769e9c964ab5ba995e56c94a +Subproject commit 8a3b69ea81ff567dadbf98db4f86652782acd6b4