Find transaction in transaction group by id
Without this change txn GroupIndex can inappropriately return -1 despite all fields of tx being the same as all fields of gtxns[x]. Apparently, the reason is that either tx or gtxns can be overwritten at some point by the same content but stored in a different memory location (indexOf uses === which compares objects by reference).
I had this problem when providing liquidity twice in a row in Pact smart contract
This change looks pretty safe, but I don't know if the root cause (change of memory locations) should be found and eliminated in addition or instead of this commit.
Oh, actually it doesn't work for contract-to-contract calls (or inner txs in general) because they don't have ids. Not sure if they should though
We should definitely look based on tx id. However yes - we probably need more inspection into that. Thanks for the update!
I've updated the PR by using gtxns.find instead of map + indexOf
it seams this breaks our tests.
I've updated the PR by using
gtxns.findinstead ofmap + indexOf
But find returns an element, not index. So it doesn't work after this change.