Skip to content

Commit

Permalink
Convert assert in create into a warning
Browse files Browse the repository at this point in the history
Turn the assert statement in create into a warning, this restores the
ability to import tokens through Metamask.

Details: When importing tokens, Metamask sends a create call without
sender information, triggering an assert failure.

Signed-off-by: Michael Maurer <maurer.mi@northeastern.edu>
  • Loading branch information
maurermi committed Aug 21, 2024
1 parent 30797cb commit 6923b60
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/parsec/agent/runners/evm/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,15 @@ namespace cbdc::parsec::agent::runner {

auto evm_host::create(const evmc_message& msg) noexcept -> evmc::Result {
auto maybe_sender_acc = get_account(msg.sender, false);
assert(maybe_sender_acc.has_value());
if(!maybe_sender_acc.has_value()) {
m_log->warn("EVM CREATE: sender account not found");
return evmc::Result(
evmc::make_result(evmc_status_code::EVMC_REVERT,
0,
0,
nullptr,
0));
}
auto& sender_acc = maybe_sender_acc.value();

auto new_addr = evmc::address();
Expand Down Expand Up @@ -298,6 +306,11 @@ namespace cbdc::parsec::agent::runner {
}

auto evm_host::call(const evmc_message& msg) noexcept -> evmc::Result {
if(msg.kind == EVMC_CREATE2) {
m_log->info("EVM CREATE2 called");
} else if(msg.kind == EVMC_CREATE) {
m_log->info("EVM CREATE called");
}
if(msg.kind == EVMC_CREATE2 || msg.kind == EVMC_CREATE) {
return create(msg);
}
Expand Down

0 comments on commit 6923b60

Please sign in to comment.