-
Notifications
You must be signed in to change notification settings - Fork 69
WIP add basic edcon draft TokenScript #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,38 @@ | ||
XMLSECTOOL=xmlsectool | ||
KEYSTORE= | ||
KEY=1 | ||
KEYPASSWORD= | ||
SIGNATURE_ALGORITHM=rsa-sha256 | ||
|
||
help: | ||
# Needs a target, example: $$ make EntryToken.canonicalized.xml | ||
# | ||
# Let's say you have a TokenScript "EntryToken.xml" | ||
#- to validate and canonicalize, add 'canonicalized' in the filename | ||
@echo $$ make EntryToken.canonicalized.xml | ||
# - to sign, use tsml as file extension: | ||
@echo $$ make EntryToken.tsml | ||
|
||
%.canonicalized.xml : %.xml | ||
# xmlsectool canonicalises automatically when needed, but leaving an xml:base attribute which creates trouble later. | ||
# xmlstarlet does it neatly | ||
# XML Canonicalization | ||
xmlstarlet c14n $^ > $@ | ||
# xmlsectool validates too, albeit adding xml:base with breaks schema. Example: | ||
# JVMOPTS=-Djavax.xml.accessExternalDTD=all /opt/xmlsectool-2.0.0/xmlsectool.sh --validateSchema --xsd --schemaDirectory ../../schema --inFile $^ | ||
# XML Validation | ||
# if INVALID, run validation again with xmllint to get meaningful error | ||
# then delete the canonicalized file | ||
-xmlstarlet val --xsd http://tokenscript.org/2019/10/tokenscript/tokenscript.xsd $@ || (mv $@ $@.INVALID; xmllint --noout --schema http://tokenscript.org/2019/10/tokenscript/tokenscript.xsd $@.INVALID) | ||
|
||
%.tsml: %.canonicalized.xml | ||
ifeq (,$(KEYSTORE)) | ||
@echo ---------------- Keystore missing. Try this ---------------- | ||
@echo $$ make KEYSTORE=shong.wang.p12 KEYPASSWORD=shong.wang $@ | ||
@echo replace it with your .p12 file and your password | ||
rm $^ | ||
else | ||
$(XMLSECTOOL) --sign --keyInfoKeyName 'Shong Wang' --digest SHA-256 --signatureAlgorithm http://www.w3.org/2001/04/xmldsig-more#$(SIGNATURE_ALGORITHM) --inFile $^ --outFile $@ --keystore $(KEYSTORE) --keystoreType PKCS12 --key $(KEY) --keyPassword $(KEYPASSWORD) --signaturePosition LAST | ||
# removing the canonicalized created for validation | ||
rm $^ | ||
endif |
This file contains hidden or 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,46 @@ | ||
.tbml-count { | ||
font-family: "SourceSansPro"; | ||
font-weight: bolder; | ||
font-size: 21px; | ||
color: rgb(117, 185, 67); | ||
} | ||
.tbml-category { | ||
font-family: "SourceSansPro"; | ||
font-weight: lighter; | ||
font-size: 21px; | ||
color: rgb(67, 67, 67); | ||
} | ||
.tbml-venue { | ||
font-family: "SourceSansPro"; | ||
font-weight: lighter; | ||
font-size: 16px; | ||
color: rgb(67, 67, 67); | ||
} | ||
.tbml-date { | ||
font-family: "SourceSansPro"; | ||
font-weight: bold; | ||
font-size: 14px; | ||
color: rgb(112, 112, 112); | ||
margin-left: 7px; | ||
margin-right: 7px; | ||
} | ||
.tbml-time { | ||
font-family: "SourceSansPro"; | ||
font-weight: lighter; | ||
font-size: 16px; | ||
color: rgb(112, 112, 112); | ||
} | ||
html { | ||
} | ||
body { | ||
padding: 0px; | ||
margin: 0px; | ||
} | ||
div { | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
.data-icon { | ||
height:16px; | ||
vertical-align: middle | ||
} |
This file contains hidden or 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,145 @@ | ||
<script type="text/javascript"> | ||
(function() { | ||
'use strict' | ||
|
||
function GeneralizedTime(generalizedTime) { | ||
this.rawData = generalizedTime; | ||
} | ||
|
||
GeneralizedTime.prototype.getYear = function () { | ||
return parseInt(this.rawData.substring(0, 4), 10); | ||
} | ||
|
||
GeneralizedTime.prototype.getMonth = function () { | ||
return parseInt(this.rawData.substring(4, 6), 10) - 1; | ||
} | ||
|
||
GeneralizedTime.prototype.getDay = function () { | ||
return parseInt(this.rawData.substring(6, 8), 10) | ||
}, | ||
|
||
GeneralizedTime.prototype.getHours = function () { | ||
return parseInt(this.rawData.substring(8, 10), 10) | ||
}, | ||
|
||
GeneralizedTime.prototype.getMinutes = function () { | ||
var minutes = parseInt(this.rawData.substring(10, 12), 10) | ||
if (minutes) return minutes | ||
return 0 | ||
}, | ||
|
||
GeneralizedTime.prototype.getSeconds = function () { | ||
var seconds = parseInt(this.rawData.substring(12, 14), 10) | ||
if (seconds) return seconds | ||
return 0 | ||
}, | ||
|
||
GeneralizedTime.prototype.getMilliseconds = function () { | ||
var startIdx | ||
if (time.indexOf('.') !== -1) { | ||
startIdx = this.rawData.indexOf('.') + 1 | ||
} else if (time.indexOf(',') !== -1) { | ||
startIdx = this.rawData.indexOf(',') + 1 | ||
} else { | ||
return 0 | ||
} | ||
|
||
var stopIdx = time.length - 1 | ||
var fraction = '0' + '.' + time.substring(startIdx, stopIdx) | ||
var ms = parseFloat(fraction) * 1000 | ||
return ms | ||
}, | ||
|
||
GeneralizedTime.prototype.getTimeZone = function () { | ||
let time = this.rawData; | ||
var length = time.length | ||
var symbolIdx | ||
if (time.charAt(length - 1 ) === 'Z') return 0 | ||
if (time.indexOf('+') !== -1) { | ||
symbolIdx = time.indexOf('+') | ||
} else if (time.indexOf('-') !== -1) { | ||
symbolIdx = time.indexOf('-') | ||
} else { | ||
return NaN | ||
} | ||
|
||
var minutes = time.substring(symbolIdx + 2) | ||
var hours = time.substring(symbolIdx + 1, symbolIdx + 2) | ||
var one = (time.charAt(symbolIdx) === '+') ? 1 : -1 | ||
|
||
var intHr = one * parseInt(hours, 10) * 60 * 60 * 1000 | ||
var intMin = one * parseInt(minutes, 10) * 60 * 1000 | ||
var ms = minutes ? intHr + intMin : intHr | ||
return ms | ||
} | ||
|
||
if (typeof exports === 'object') { | ||
module.exports = GeneralizedTime | ||
} else if (typeof define === 'function' && define.amd) { | ||
define(GeneralizedTime) | ||
} else { | ||
window.GeneralizedTime = GeneralizedTime | ||
} | ||
}()) | ||
</script> | ||
<script type="text/javascript"><![CDATA[ | ||
class Token { | ||
constructor(tokenInstance) { | ||
this.props = tokenInstance | ||
} | ||
|
||
formatGeneralizedTimeToDate(str) { | ||
const d = new GeneralizedTime(str) | ||
return new Date(d.getYear(), d.getMonth(), d.getDay(), d.getHours(), d.getMinutes(), d.getSeconds()).toLocaleDateString() | ||
} | ||
formatGeneralizedTimeToTime(str) { | ||
const d = new GeneralizedTime(str) | ||
return new Date(d.getYear(), d.getMonth(), d.getDay(), d.getHours(), d.getMinutes(), d.getSeconds()).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'}) | ||
} | ||
|
||
render() { | ||
let time; | ||
let date; | ||
if (this.props.time == null) { | ||
time = "" | ||
date = "" | ||
} else { | ||
time = this.formatGeneralizedTimeToTime(this.props.time.generalizedTime) | ||
date = this.props.time == null ? "": this.formatGeneralizedTimeToDate(this.props.time.generalizedTime) | ||
} | ||
let redeemedMessage = ""; | ||
//might not have loaded so only set if actually loaded | ||
if(this.props.redeemed === "1") { | ||
redeemedMessage = "(Redeemed)" | ||
} else if(this.props.redeemed === "0") { | ||
redeemedMessage = "(Not redeemed)" | ||
} | ||
return `<div> | ||
<div> | ||
<span class="tbml-count">x${this.props._count}</span> | ||
<span class="tbml-category">${this.props.category}</span> | ||
<span class="tbml-category">${redeemedMessage}</span> | ||
</div> | ||
<div> | ||
<span class="tbml-venue">${this.props.venue}</span> | ||
</div> | ||
<div style="margin: 0px; padding:0px; clear: both; height: 6px"> | ||
| ||
</div> | ||
<div> | ||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAYAAACMGIOFAAAABGdBTUEAALGPC/xhBQAABw9JREFUaAXtWt1vFFUUP3d224JVqHyVXTSCjzYVBFMx/eTJJ1tQ+yA+iBLEIDGa+CBP4h+gMcYXYgR8sDxUacs/YD8DkgjWBB+lpHa3hbZQpNDdzs71nNmZ3Xvv3PlYk+IWd5LNnM/fPWdm7p1zzyyDEo8DYzMvW2buFAB/Gl17qtuSH/YylguD6b58c2t2yTwLHJqBwVj1mvih3qYt06F+nMeyw6mv0e4gAJs04rGjfc31F8P8RL0hMmE055xZOfNHDryRA9Th79jyaPpwmB/pM0vml+j/Cvo+Tmfio/gRPo2TH4832uNjHFF8XZuSknz9l/ltnEPSdaazBdAk8n40RiXZqbyfn4pP41McfvY6eUlJWjwb94Bw8Mo8RrZAtVN5vZcGXxuH3ts7cPc1Xp1ZuNVg5HLrRR/D4NfPNydviDIdvX8k3SHKGRi3+1rrx0WZjt4/dnMXWLk6UdffmhgUeR29/2J6O5iwXdRZsdhCzfrN13obWNaV21ezc/TWE8xa/iI7l3obF4ZqfESkwwLjJAo+l4QaxrKsn0UxY3wQ+X2iTEfjPPsKOG9XdEzhvWzWOoSxfiYpLAswj2znUOosxKo+udCy+W+D7h5Y2VFcDI7g814tOZQ5Y+Ejpgsxnwd/D/MaofyMzPz0Cbx7z+uMV72Mw87s3PSnBuP81VWfTGACvBPnJG8UbRiwCW6ws6IsxmFQ5H1pw567BbVhwUSBCSBinJ3JGUyazwHmBRXFhc+rtFZwxg7h1HumYIT5xT3zkMHEhdaE5Fh0CKb+rV9fe+L7YGS9tq8tMYQa+hWOzuFUBzKFJCm/kt6ThoUuysFwWVREehZLHUmh8pKyyOjwdXEUPbxUSUnG6hJphF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i8D0KDztbtlzDgt5pQqlah0e9bedVe/BkE7aYj0uW6riQq5x3oSIYdyFN+IgE7kLUAajoxl1Ix30I3oWoxTnh0Gd63IWMB+1CetvCi3PCKqniIYdyP3QVT6Q5We6JhcVXSTLsCq0WfaSFh5KptD8AKu2PwMe60v4IvDzwUNsfuLdIBbU/MFTpm6YQ+hJW2L7tD8IVbIvkSrY/3ro0t26RZ6X2x3+x1apl1fM/7N14t5h1kdIVA5FXV4JxgD3gYfudSvujeBNWjKpUPCt2aR8ycOVOPuQLvmLDMVxyF7B3s84dAf/CsoDtod9cfrWdsY+/C/8HVfy/LmN347j8X8FmUoebjG3Aod3lV9sZc1GPq/ifIfhWlT5KPP4N9JQx0JLsoS9Ej1Jibi64qp7ub912rlCsdI2mDuKH3yN4u3eLc9R1WDVnnIMY61W6g5Qgxf0P/UFw0L/BhyIAAAAASUVORK5CYII=" class="data-icon"/> | ||
<span class="tbml-date">${date}</span> | ||
</div> | ||
<div> | ||
<span class="tbml-time">${time}, ${this.props.locality}</span> | ||
</div> | ||
</div>`; | ||
} | ||
} | ||
|
||
web3.tokens.dataChanged = (oldTokens, updatedTokens) => { | ||
const currentTokenInstance = web3.tokens.data.currentInstance; | ||
document.getElementById('root').innerHTML = new Token(currentTokenInstance).render(); | ||
}; | ||
]]></script> | ||
<div id="root"></div> |
This file contains hidden or 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,137 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<!DOCTYPE token [ | ||
<!ENTITY unicon.en SYSTEM "unicon.en.shtml"> | ||
<!ENTITY style SYSTEM "shared.css"> | ||
]> | ||
<ts:token xmlns:ts="http://tokenscript.org/2019/10/tokenscript" | ||
xmlns="http://www.w3.org/1999/xhtml" | ||
xmlns:xml="http://www.w3.org/XML/1998/namespace" | ||
xsi:schemaLocation="http://tokenscript.org/2019/10/tokenscript http://tokenscript.org/2019/10/tokenscript.xsd" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
custodian="false" | ||
> | ||
<ts:name> | ||
<ts:plurals xml:lang="en"> | ||
<ts:string quantity="one">Ticket</ts:string> | ||
<ts:string quantity="other">Tickets</ts:string> | ||
</ts:plurals> | ||
</ts:name> | ||
|
||
<ts:contract name="unicon" interface="erc721"> | ||
<ts:address network="100">0xF6b8DD8Ba9996bEaE6Ad0eE3481F1E9cF080A9eB</ts:address> | ||
</ts:contract> | ||
|
||
<ts:origins> | ||
<!-- Define the contract which holds the token that the user will use --> | ||
<ts:ethereum contract="unicon"> | ||
</ts:ethereum> | ||
</ts:origins> | ||
|
||
<ts:cards> | ||
<ts:token-card> | ||
<style type="text/css">&style;</style> | ||
<ts:view-iconified xml:lang="en"> | ||
&unicon.en; | ||
</ts:view-iconified> | ||
<ts:view xml:lang="en"> | ||
&unicon.en; | ||
</ts:view> | ||
</ts:token-card> | ||
</ts:cards> | ||
|
||
<ts:attribute-types> | ||
|
||
<ts:attribute-type id="time" syntax="1.3.6.1.4.1.1466.115.121.1.24"> | ||
<ts:name> | ||
<ts:string xml:lang="en">Time</ts:string> | ||
</ts:name> | ||
<ts:origins> | ||
<ts:token-id bitmask="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000" as="utf8"> | ||
</ts:token-id> | ||
</ts:origins> | ||
</ts:attribute-type> | ||
|
||
<!-- TODO get location & venue, if only one then remove this attribute and hardcode it into the UI --> | ||
<ts:attribute-type id="locality" oid="2.5.4.7" syntax="1.3.6.1.4.1.1466.115.121.1.15"> | ||
<ts:name> | ||
<ts:string xml:lang="en">City</ts:string> | ||
</ts:name> | ||
<ts:origins> | ||
<ts:token-id bitmask="000000000000000000000000000000000000FF00000000000000000000000000" as="uint"> | ||
<ts:mapping> | ||
<ts:option key="1"> | ||
<ts:value xml:lang="en">Vienna</ts:value> | ||
</ts:option> | ||
</ts:mapping> | ||
</ts:token-id> | ||
</ts:origins> | ||
</ts:attribute-type> | ||
|
||
<ts:attribute-type id="venue" syntax="1.3.6.1.4.1.1466.115.121.1.15"> | ||
<ts:name> | ||
<ts:string xml:lang="en">Venue</ts:string> | ||
</ts:name> | ||
<ts:origins> | ||
<ts:token-id bitmask="00000000000000000000000000000000000000FF000000000000000000000000" as="uint"> | ||
<ts:mapping> | ||
<ts:option key="1"> | ||
<ts:value xml:lang="en">Blockchain Plaza, Vienna</ts:value> | ||
</ts:option> | ||
</ts:mapping> | ||
</ts:token-id> | ||
</ts:origins> | ||
</ts:attribute-type> | ||
|
||
<ts:attribute-type id="category" syntax="1.3.6.1.4.1.1466.115.121.1.15"> | ||
<ts:name> | ||
<ts:string xml:lang="en">Cat</ts:string> | ||
<ts:string xml:lang="zh">等级</ts:string> | ||
<ts:string xml:lang="es">Cat</ts:string> | ||
</ts:name> | ||
<ts:origins> | ||
<ts:token-id bitmask="000000000000000000000000000000000000000000000000000000FF00000000" as="uint"> | ||
<ts:mapping> | ||
<ts:option key="1"> | ||
<ts:value xml:lang="en">A</ts:value> | ||
</ts:option> | ||
<ts:option key="2"> | ||
<ts:value xml:lang="en">B</ts:value> | ||
</ts:option> | ||
<ts:option key="3"> | ||
<ts:value xml:lang="en">C</ts:value> | ||
</ts:option> | ||
<ts:option key="4"> | ||
<ts:value xml:lang="en">D</ts:value> | ||
</ts:option> | ||
<ts:option key="5"> | ||
<ts:value xml:lang="en">E</ts:value> | ||
</ts:option> | ||
</ts:mapping> | ||
</ts:token-id> | ||
</ts:origins> | ||
</ts:attribute-type> | ||
|
||
<ts:attribute-type id="numero" syntax="1.3.6.1.4.1.1466.115.121.1.27"> | ||
<ts:name> | ||
<ts:string>№</ts:string> | ||
</ts:name> | ||
<ts:origins> | ||
<ts:token-id bitmask="00000000000000000000000000000000000000000000000000000000FFFF00" as="uint"/> | ||
</ts:origins> | ||
</ts:attribute-type> | ||
|
||
<ts:attribute-type id="redeemed" syntax="1.3.6.1.4.1.1466.115.121.1.27"> | ||
<ts:name> | ||
<ts:string>Redeemed</ts:string> | ||
</ts:name> | ||
<ts:origins> | ||
<ts:ethereum function="redeemed" contract="unicon" as="bool"> | ||
<ts:data> | ||
<ts:uint256 ref="tokenId"/> | ||
</ts:data> | ||
</ts:ethereum> | ||
</ts:origins> | ||
</ts:attribute-type> | ||
|
||
</ts:attribute-types> | ||
</ts:token> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhangzhongnan928 if you know the location, let me know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBC,
They haven't paid to the venue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is
Vienna University of Economics and Business
Welthandelspl. 1, 1020 Wien, Austria