Description
This should verify the validity of a Runestone ancestry. It would not be enough to guarantee the rune verification as we would also need to verify the Runestone mint was performed correctly (if minted too late it contains no Runes).
Here is a summary of what needs to be done:
We need a public verify_runestone_ancestry
function which takes a Span of Transactions where the first transaction references the 2nd, the 2nd the third, etc, and returns a boolean indicating the validity of the chain.
Steps
- Match if array is empty (if so, return true, otherwise false), otherwise work with the tx object from pop_front()
- Extract the runestone from this tx or panic
- Match the runestone as a mint or as a transfer (edicts)
- If it's a mint, return a recursive call, otherwise first ensures the edict transfers a correct amount
Advice
Note that this verification is not sufficient to guarantee the Rune mint was performed correctly - additional checks would be needed to confirm whether the Runestone contains valid Runes (for example, checking if it was minted too late).
You might need to wrap the recursive function into another function so you can add helper params (like the total amount that you need to ensure was transferred)