TokenScript icon indicating copy to clipboard operation
TokenScript copied to clipboard

Volatility hint for Tokenscript engine optimisation

Open JamesSmartCell opened this issue 6 years ago • 1 comments
trafficstars

Compare:

<ts:ethereum function="balanceOf" contract="dai" as="uint">

vs

<ts:ethereum function="getStreet" contract="EntryToken" as="utf8">

The balanceOf is expected to be more volatile than the getStreet value. Adding a volatile attribute will help to give a hint for wallet run speed optimisation.

This would be a good start:

<ts:ethereum function="balanceOf" contract="dai" as="uint" volatile="true">

or

<ts:ethereum function="balanceOf" contract="dai" as="uint" volatility="high">

<ts:ethereum function="getStreet" contract="EntryToken" as="utf8" volatility="low">

JamesSmartCell avatar May 17 '19 07:05 JamesSmartCell

Ok we have refined this down to two values to begin with:

<ts:ethereum function="balanceOf" contract="dai" as="uint" volatility="immediate">

and

<ts:ethereum function="getStreet" contract="EntryToken" as="utf8" volatility="default">

The second default volatility is handled by the client as appropriate, it is the default behaviour so there is no need to declare it. The immediate flag indicates that the value should be fetched before usage.

JamesSmartCell avatar May 20 '19 00:05 JamesSmartCell