Turn Error into an ADT and add require/assert#389
Conversation
| @@ -80,6 +81,7 @@ export { | |||
| revert, | |||
| revertEmpty, | |||
There was a problem hiding this comment.
Considering removing this, since we can use revert(Error.Empty).
099d8f4 to
7764171
Compare
| function transferFrom(src:address, dst:address, amt:uint256) -> bool { | ||
| let msg_sender = caller(); | ||
| require( balances[src] >= amt /* "token/insufficient-balance" */ | ||
| myrequire( balances[src] >= amt /* "token/insufficient-balance" */ |
There was a problem hiding this comment.
Perhaps it would make sense to exercise the new Error system here - if I understand it correctly then this should be
require( balances[src] >= amt /* "token/insufficient-balance" */
, Error.Error(0x746f6b656e2f696e73756666696369656e742d62616c616e6365)
)
Probably no need to change it in other tests, but miniERC20 is one of our main ones.
There was a problem hiding this comment.
The error encoding follows the ABI, so it is sha256(<errorname>(<arguments>))[:4] (truncating to the first 4 bytes). Since error and function names cannot have forward slashes (/), the original error token/insufficient-balance cannot be represented. This is the reason I haven't changed it.
We need to change it to something like InsufficientBalance() if we follow Solidity's model.
No description provided.