f-o-a-m / purescript-web3

a purescript library for the web3 api
Apache License 2.0
127 stars 24 forks source link

Make eth_call polymorphic for TransactionOptions #136

Closed charlescrain closed 4 years ago

charlescrain commented 4 years ago

Purpose

eth_call can run a transaction to see whether a transaction will succeed or did succeed and return the result of the transaction which can include the reason for the revert if a solidity developer specifies a reason.

Example

function test() payable public {
  require(msg.value > 0, "msg.value too small");
  require(false, "this failed cuz this is always false");
}

Say I call test() with a transaction where I sent 2 eth. It would fail with message this failed cuz this is always false. However, if I want to use eth_call to get the reason, I'm restricted to only transactions with an empty value field. When if I attempt without any eth in transaction options so the message will always be msg.value too small, so I essentially tested a different transaction.

I made the TransactionOptions NoPay to be forall. TransactionOptions a. Maybe this is too flexible so would appreciate feedback.

Cheers! Charles

martyall commented 4 years ago

:taco: