Feature request: Improve API to retrieve transactions
#1594 opened on Jan 23, 2020
Description
A common mistake in our scripts has this pattern:
contract = create[....]
contract.f1(..)
contract.f1(..) // we want to return value here
contract.f1(..)
contract.f1(..)
for state in m.ready_states:
second_f1_call_transaction = state.platform.transactions[1]
Here state.platform.transactions[1] will not be the second call to f1, but the first. Because the first transactions of the platform will be the contract's deployement.
For complex scripts, that are split through multiple files, it's also more complex to determine what index should be given to state.platform.transactions.
An alternative would be to return an object after the functions calls, like
first_tx = contract.f1(..)
And be able to access the state's related transaction later, either through something like
transaction = state.platform.get_transaction(first_tx)
or
transaction = first_tx.get_transaction(state | state_id)
I see one caveat though, for contract's creation, m.solidity_create_contract already returns an object. I see two solutions:
- Return a tuple, but that might just overcomplexity the API
- Not return the tx-object, but have it accessible through the contract (like
contract.tx_creation).
Note that here tx is maybe not a good name, as the object will, in fact, refers to the set of transactions for all the states
Any thoughts?