Convenience accessors#120
Conversation
|
@re-gius Can you give it a check to this. Im not sure about the tests placement. Also, it seems currently there is not implementation on the mock to tests has_code(), how should I deal with that? I didnt touched the contract examples. The use of the accessors on them should be part of this PR? |
It looks like the initial design causes several undesired conflicts, so I came up with a slightly different design in #103 (comment) Can we first agree on that and then change your implementation accordingly?
You don't need to implement has_code on MockHost because it's a default method on HostApi (code_size(addr) > 0), so every host, including the mock, inherits it automatically via code_size. The gap is that
Yes, once they work we should change the example contracts to show how to use them and for benchmarking too. |
Closes #103
Adds convenience accessors (caller, value, timestamp, block_number, chain_id) on the macro-generated contract struct, so contracts can call self.caller() instead of the three-line host buffer pattern. Also adds has_code(addr) as a default method on HostApi, wrapping code_size.