Skip to content

Handle errors when gas_limit is calculated#110

Open
somoza wants to merge 1 commit intoizelnakri:mainfrom
somoza:main
Open

Handle errors when gas_limit is calculated#110
somoza wants to merge 1 commit intoizelnakri:mainfrom
somoza:main

Conversation

@somoza
Copy link

@somoza somoza commented Jun 13, 2023

When I have some guard on my contract like is_owner this throws an unhandled exception on the gas_limit calculation. I added a simple error tuple to be able to capture the event and don't kill my genserver while sending transactions.

Example of error I got before the change:

** (MatchError) no match of right hand side value: {:error, %{"code" => -32000, "data" => %{"hash" => nil, "message" => "revert", "programCounter" => 3727, "reason" => "Sender no autorizado.", "result" => "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001553656e646572206e6f206175746f72697a61646f2e0000000000000000000000"}, "message" => "VM Exception while processing transaction: revert Sender no autorizado.", "name" => "RuntimeError", "stack" => "RuntimeError: VM Exception while processing transaction: revert Sender no autorizado.\n    at exactimate (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache/dist/node/1.js:2:182136)"}}
    (eth 0.6.7) lib/eth/query.ex:166: ETH.Query.estimate_gas!/2
    (eth 0.6.7) lib/eth/transaction/builder.ex:120: ETH.Transaction.Builder.build_params_from_map/1
    (eth 0.6.7) lib/eth/transaction/builder.ex:19: ETH.Transaction.Builder.build/1
    (eth 0.6.7) lib/eth/transaction.ex:28: ETH.Transaction.send_transaction/2
    ```

@somoza somoza changed the title Handle event Handle errors when gas_limit is calculated Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant