Asset-store data reading & writing
Consider a case of assets exchange with the following algorithm:
Wait for an Asset transfer from an Account
Get information about exchanging assets (base asset ID, target asset ID, exchange rate).
Check that these assets exist and can be exchanged.
Calculate the target currency amount by passing the retrieved exchange rate to the mathematical instruction as an argument
Make a transfer by passing the calculated amount of the target currency, recipient account ID (that is, the user who made the transfer in step 1), and the target asset ID as an argument in the AssetTransfer ISI.
Requirements for this case are the following:
To have the ability to pass exchange-related data like 'exchanging asset ID' and etc. to the algorithm (from asset-store, for example).
To be able to manipulate the given data. For example, to calculate the exchanged currency amount.
To store new data. For example, to store the calculated amount.
To load saved data and pass it as an argument for an ISI. E.g. passing the calculated amount to the `TransferAsset` ISI.
To have a guarantee that all the stored data is consistent, so the user would not have to verify all the data by itself.
Additional requirements for the algorithm:
It should be persisted, so no one could change the order of the instructions.
It should be guaranteed that the creator of the algorithm is not permitted to call these instructions by itself.
can you clarify what means violated?
Also let's try to formalize some terms and things:
"Asset transfer from a user" means `TransferAsset` Iroha Special Instructions submitted on behalf of some account?
Doesn't `TransferAsset` contains information about source and target assets identifications?
Now some short and fast answers to questions:
I will first think about the need to introduce procedures for this case. As was discussed previously, Exchange can be implement via Iroha Special Instructions and Iroha Triggers (Event Listeners).
If you by "storage" you mean Asset, than Composite Iroha Special Instruction should have clean up steps and preconditions.
I think we can address this in Iroha Additional Requirements - related to custom data validation section.
If by "asset-stores" you mean assets - than composite Iroha Special Instruction should execute Iroha Query.
By `MintAsset` Iroha Special Instruction.