You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
contract = create[....]
contract.f1(..)
result_f1_2 = contract.f1(..) // we want to return value here
contract.f1(..)
contract.f1(..)
for state in m.ready_states:
second_f1_call_transaction = result_f1_2(state)
This will need a way to id human_transactions (maybe just the order) so result_f1_2() function knows in which transaction look for the result and all.
longshot:
result_f1_2 could be of a Result class exploiting some python magic to be permisive in the common case.
class Result():
def __init__(self, tx_id, returntype, mcore):
self.mcore=mcore
self.tx_id = tx_id
self.returntype = returntype
def __call__(self, state=None, *args, **kwargs):
# maybe if state is None check if there is a single state and look for it in self.mcore.ready_states
return ABI.deserialize(self.returntype, state.platform.human_transactions[self.tx_id].returndata)
def __str__(self):
if 1 == self.mcore.count_ready_states():
for st in self.mcore.ready_states:
return str(self(st))
return "{symbolic}"
def __iter__(self):
for st in self.mcore.ready_states:
self._current_state=st.id
yield self(st)
def current_state(self):
return self.mcore.load(self._current_state)
def count(self):
return self.mcore.count_ready_states()
contract = create[....]
contract.f1(..)
result_f1_2 = contract.f1(..) // we want to return value here
print (result_f1_2) #is a single result this prints the right thing
contract.f1(..)
contract.f1(..)
A common mistake in our scripts has this pattern:
Here
state.platform.transactions[1]
will not be the second call tof1
, 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
And be able to access the state's related transaction later, either through something like
or
I see one caveat though, for contract's creation,
m.solidity_create_contract
already returns an object. I see two solutions: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 statesAny thoughts?
The text was updated successfully, but these errors were encountered: