I see a difference between the new DAI example schema and the "TokenScript-Wizard" example schema - namely that selections isn't present in DAI example and cards is doing the work. Is that just different usage or is DAI the intended kind of use? I'm not totally clear on the intended use of selections though I see it in the schema (view definition maybe?)
Thank you very much for checking up TokenScript! I apologize for the late reply - we have been focusing on releasing the 2019-05 Schema support which is pretty basic for any practical use of TokenScript.
As to your question:
I'm not totally clear on the intended use of selections though I see it in the schema (view definition maybe?)
Selection is used for:
It allows actions to be applicable only if toke satisfies criteria. In XDAI example†, the transfer action can't happen if the balance is lower than 1GW, which is the default gas fee. Similarly, the transfer action isn't available for a ticket token if the ticket has expired.
It allows actions to be applicable for a set of tokens. Let's say you have 10 cryptokitties, and 5 of them have hats. The "Buy Hat" action is only available for the 5 kitties that don't have a hat.
† DAI example
<ts:exclude> <ts:selection> <ts:token filter="balance<=1000000000"/> </ts:selection> <ts:message> <ts:string xml:lang="en">Not enough balance.</ts:string> </ts:message> </ts:exclude>
Second, in the case of atomic protocol or transactions, all actions must be successful for the transaction to be successful. For example, a user buys 100DAI token in order to buy a kitty whose seller only accepts DAI. The user decides to do a multi-action transaction, so he won't be left with 100DAI hanging balance if the kitten purchase fails for some reason. In such a case, the check on whether or not the actions can be performed should be done outside of any actions. If the kitten is not transferable, the user should not be able to assemble such a transaction. Therefore selection is defined outside actions.
I see a difference between the new DAI example schema and the "TokenScript-Wizard" example schema - namely that selections isn't present in DAI example and cards is doing the work. Is that just different usage or is DAI the intended kind of use?
We have down-scoped what DAI example and XDAI example contains to make sure we can reach a May release where DAI and XDAI TokenScripts run correctly. You can see '' is commented out in the current XDAI TokenScript. We will return
<selection> in all examples in June!