-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Updated TokenScript documentation WIP
- Loading branch information
1 parent
c194ce4
commit 262b4a3
Showing
7 changed files
with
153 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"core-concepts": "Core Concepts", | ||
|
||
"tokenscript-syntax": "XML Syntax", | ||
"card-sdk": "Card SDK" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Card SDK | ||
|
||
The Card SDK provides the glue between the Javascript defined in the TokenScript project and the engine. | ||
It is essentially a 2-way message bus that allows the TokenScript developer to make requests to the engine and to receive updated data. | ||
It also allows the user to access various data including context data, environment variables & contract information. | ||
|
||
## Token Context Data | ||
|
||
## Environment Variables | ||
|
||
## Engine & UX actions | ||
|
||
## Ethereum methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Selections | ||
|
||
A selection defines conditions that filter origin tokens for the TokenScript and are used to control the availability of cards. | ||
These conditions use attribute values as input, just like transactions and other attributes. | ||
|
||
## Defining a selection | ||
|
||
As you can see, defining `ts:selection` is pretty simple: | ||
```xml | ||
<ts:selection name="adopted" filter="level>0"> | ||
<ts:label> | ||
<ts:string xml:lang="en">Cat already adopted</ts:string> | ||
</ts:label> | ||
</ts:selection> | ||
``` | ||
|
||
Just like a lot of tokenscript.xml elements, there is a label included within that can be displayed to the user. | ||
To use this filter to disable cards, reference this selection name in the `excude` attribute of `ts:card` as outlined [here](./cards). | ||
|
||
## Filter syntax | ||
|
||
The filter syntax uses a lexer & parser model that supports complex conditions. | ||
|
||
### Simple conditions | ||
|
||
You can specify an attribute name on the left hand side of the condition, with a static value on the right: | ||
|
||
- `level>0` | ||
- `canLevelUp=FALSE` | ||
|
||
We can then use this selection to disable the card for tokens that are greater than level 0 | ||
|
||
```xml | ||
<ts:card type="action" name="levelUp" origins="ReallyCoolToken" exclude="adopted"> | ||
<!-- Other card elements omitted --> | ||
</ts:card> | ||
``` | ||
|
||
### Available operators | ||
|
||
#### Comparison | ||
- **=** Equals | ||
- **<** Less than | ||
- **>** Greater than | ||
- **<=** Less than or equal | ||
- **>=** Greater than or equal | ||
|
||
#### Logical | ||
- **&** And | ||
- **|** Or | ||
- **!** Not | ||
|
||
### Right-hand-side values | ||
|
||
Attribute values can also be specified on the right hand side by enclosing the attributes like so: `${tokenId}`. | ||
In this way we can compare two attribute values to filter tokens: | ||
|
||
`wallet=${ownerAddress}` | ||
|
||
We can even combine a RHS attribute with some static value: | ||
|
||
`label=prefix-${ownerAddress}-suffix` | ||
|
||
### Complex conditions | ||
|
||
Complex condition can be achieved through the use of brackets and logical operators: | ||
|
||
Both conditions must be true (AND): | ||
`&(level>0)(level<10)` | ||
|
||
At least one condition must be true (OR): | ||
`|(level<10)(level>20)` | ||
|
||
Both conditions must be false (NOT): | ||
|
||
`!(level=0)(level=10)` | ||
|
||
Multiple conditions can be grouped using brackets: | ||
|
||
`&(!(level=0)(level=10))(wallet=${ownerAddress})` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters