Skip to content

Commit 352c21a

Browse files
committed
TIP-3 specification
1 parent eb77f9e commit 352c21a

File tree

1 file changed

+96
-2
lines changed

1 file changed

+96
-2
lines changed

TIPS/tip-3.md

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,100 @@ DOOAR DEX.
1414

1515
## Motivation
1616

17-
We have previously used TokenScript template.
17+
We have previously used TokenScript templates via a launchpad API, however these are limited to providing simple functions
18+
for tokens that do not have a TokenScript associated with them. In many circumstances, it makes sense to have these cards
19+
enabled for all tokens by default. Transfer functions are the perfect example of this. In other scenarios these cards
20+
should be disabled by default and enabled by TokenScript developers that want to add some pre-bundled cards to their
21+
project.
1822

19-
## Specification
23+
## Specification
24+
25+
To support this EIP we introduce two main concepts into the TokenScript engine:
26+
27+
- Bundled Cards
28+
- Virtual TokenScripts
29+
30+
### Bundled Cards
31+
32+
Bundled cards are based on TokenScript templates. They are pre-compiled .tsml files with cards that can be combined
33+
with any tokenscript. Due to name collisions, these cards should be self-contained, and only reference the host TokenScripts
34+
origin contracts. This imposes additional requirements, including tokenscript XML schema changes to allow `ts:selections` and named `ts:transactions` to be placed inside `ts:card`.
35+
36+
A set of bundled TokenScript cards might look like this:
37+
```xml
38+
<ts:cards>
39+
<ts:webContent>
40+
<ts:include type="html" src="./dist/index.html"/>
41+
<ts:include type="css" src="./src/styles.css"/>
42+
</ts:webContent>
43+
<ts:card name="inbuilt_erc20Transfer" type="action" origins="Token" exclude="notERC20">
44+
<ts:label>
45+
<ts:string xml:lang="en">Play Morchi</ts:string>
46+
</ts:label>
47+
<ts:selections name="notERC20" filter="tokenType!=erc20">
48+
<ts:label>
49+
<ts:string xml:lang="en">Cat already adopted</ts:string>
50+
</ts:label>
51+
</ts:selections>
52+
<ts:attribute name="toAddress">
53+
<ts:label>
54+
<ts:string xml:lang="en">To</ts:string>
55+
</ts:label>
56+
<ts:origins>
57+
<ts:user-entry as="address"/>
58+
</ts:origins>
59+
</ts:attribute>
60+
<ts:attribute name="redeemAmt">
61+
<ts:label>
62+
<ts:string xml:lang="en">Amount</ts:string>
63+
</ts:label>
64+
<ts:origins>
65+
<ts:user-entry as="uint"/>
66+
</ts:origins>
67+
</ts:attribute>
68+
<ts:view xmlns="http://www.w3.org/1999/xhtml" urlFragment="erc20Transfer">
69+
<ts:viewContent name="common"/>
70+
</ts:view>
71+
</ts:card>
72+
<!-- Other cards for er721 & erc1155 transfers -->
73+
</ts:cards>
74+
```
75+
76+
An alternative pattern would be to treat a these additional cards as a completely different TokenScript instance.
77+
i.e. `tokenScript.getBundledTokenScriptInstance() => TokenScript`
78+
The bundled cards from this separate instance can be merged with the current instance and displayed in the UI with minimal
79+
changes to the code and no changes to the XML schema.
80+
81+
This may be a better approach as it requires additional research to determine the best method.
82+
83+
Some transformation of the bundled cards .tsml is required to set the correct contract, token origins and the correct
84+
origin attribute for the `ts:card` element.
85+
86+
#### Feature flags
87+
88+
The host TokenScript developer can enable OR disable specific cards based on a simple syntax:
89+
90+
```xml
91+
<ts:features>
92+
<ts:feature name="erc20Transfer" enable="false"/>
93+
<ts:feature name="erc20Messaging" enable="true"/>
94+
</ts:features>
95+
```
96+
97+
In this scenario the developer chooses to disable the bundled transfer card and implement his own.
98+
He also enables the erc-20 messaging card which is disabled by default.
99+
100+
In this way the TokenScript can contain no cards within itself but still use these flags to enable built-in
101+
cards.
102+
103+
### Virtual TokenScripts
104+
105+
Since we now have a way to provide a small amount of TokenScript XML markup to enable built-in cards, we can create
106+
the concept of "virtual TokenScripts". This enables us to use bundles cards for tokens that don't even have a
107+
TokenScript published for them yet.
108+
109+
When a token fails to resolve a TokenScript for itself, we provide a small XML snippet that enables bundled cards.
110+
111+
## Considerations
112+
113+
## Summary

0 commit comments

Comments
 (0)