I am exploring an FA2 implementation where the storage and the business logic are in different smart contracts (a pattern for upgradability)
This case could see instance of both updating the item in external storage and checking it via view multiple times in the same call– e.g. where a transfer
call has a batch of transfer instructions, you would be calling the on-chain view and updating its underlying data (the ledger
) multiple times.
For this to be safe, it would be critical that the view is receiving the "new" data that is being updated during execution.
e.g.
- Alice has balance of 1 on token_id 0
- Alice submits a "double-spend" sending token_id 0 to Bob and Carol
- view checks that Alice's balance = 1
- transfer to Bob is can be processed
- view checks that Alice's balance = 0
- transfer to Carol cannot be processed and entire transaction is reverted.
What I am unsure about in the mechanics of the VM is whether the view call in step 5 actually fetches the data that is updated during execution, or the data before the execution