-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #299 from AlphaWallet/alipay
WIP Alipay Samples
- Loading branch information
Showing
14 changed files
with
2,048 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,152 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<!DOCTYPE token [ | ||
<!ENTITY Airline.en SYSTEM "Airline.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="Airline" interface="erc721"> | ||
<ts:address network="100">0x6060c2bc6bcd71b528e9669ccac0faf17824e3cd</ts:address> | ||
</ts:contract> | ||
|
||
<ts:origins> | ||
<!-- Define the contract which holds the token that the user will use --> | ||
<ts:ethereum contract="Airline"> | ||
</ts:ethereum> | ||
</ts:origins> | ||
|
||
<ts:cards> | ||
<ts:token-card> | ||
<style type="text/css">&style;</style> | ||
<ts:view-iconified xml:lang="en"> | ||
&Airline.en; | ||
</ts:view-iconified> | ||
<ts:view xml:lang="en"> | ||
&Airline.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> | ||
|
||
<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">Shanghai</ts:value> | ||
</ts:option> | ||
<ts:option key="2"> | ||
<ts:value xml:lang="en">London</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">Shanghai Pudong Airport</ts:value> | ||
</ts:option> | ||
<ts:option key="2"> | ||
<ts:value xml:lang="en">London Heathrow Airport</ts:value> | ||
</ts:option> | ||
</ts:mapping> | ||
</ts:token-id> | ||
</ts:origins> | ||
</ts:attribute-type> | ||
|
||
<ts:attribute-type id="countryA" syntax="1.3.6.1.4.1.1466.115.121.1.26"> | ||
<!-- Intentionally avoid using countryName | ||
(SYNTAX 1.3.6.1.4.1.1466.115.121.1.11) per RFC 4519 | ||
CountryName is two-characters long, not 3-characters. | ||
--> | ||
<ts:name> | ||
<ts:string xml:lang="en">From</ts:string> | ||
</ts:name> | ||
<ts:origins> | ||
<ts:token-id bitmask="0000000000000000000000000000000000000000FFFFFF000000000000000000" as="utf8"/> | ||
</ts:origins> | ||
</ts:attribute-type> | ||
|
||
<ts:attribute-type id="countryB" syntax="1.3.6.1.4.1.1466.115.121.1.26"> | ||
<ts:name> | ||
<ts:string xml:lang="en">To</ts:string> | ||
</ts:name> | ||
<ts:origins> | ||
<ts:token-id bitmask="0000000000000000000000000000000000000000000000FFFFFF000000000000" as="utf8"/> | ||
</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">Business Class</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="Airline" as="bool"> | ||
<ts:data> | ||
<ts:uint256 ref="tokenId"/> | ||
</ts:data> | ||
</ts:ethereum> | ||
</ts:origins> | ||
</ts:attribute-type> | ||
|
||
</ts:attribute-types> | ||
</ts:token> |
Large diffs are not rendered by default.
Oops, something went wrong.
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,133 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<!DOCTYPE token [ | ||
<!ENTITY Hotel.en SYSTEM "Hotel.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">Reservation</ts:string> | ||
<ts:string quantity="other">Reservations</ts:string> | ||
</ts:plurals> | ||
</ts:name> | ||
|
||
<ts:contract name="Hotel" interface="erc721"> | ||
<ts:address network="100">0x1391f80f4b7c5e88ae8354b9c1094236f89c8274</ts:address> | ||
</ts:contract> | ||
|
||
<ts:origins> | ||
<!-- Define the contract which holds the token that the user will use --> | ||
<ts:ethereum contract="Hotel"> | ||
</ts:ethereum> | ||
</ts:origins> | ||
|
||
<ts:cards> | ||
<ts:token-card> | ||
<style type="text/css">&style;</style> | ||
<ts:view-iconified xml:lang="en"> | ||
&Hotel.en; | ||
</ts:view-iconified> | ||
<ts:view xml:lang="en"> | ||
&Hotel.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> | ||
|
||
<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">Shanghai</ts:value> | ||
</ts:option> | ||
<ts:option key="2"> | ||
<ts:value xml:lang="en">London</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">Hilton Resorts</ts:value> | ||
</ts:option> | ||
<ts:option key="2"> | ||
<ts:value xml:lang="en">Trump Tower</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">Executive Suite</ts:value> | ||
</ts:option> | ||
<ts:option key="2"> | ||
<ts:value xml:lang="en">Deluxe Suite</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="Hotel" as="bool"> | ||
<ts:data> | ||
<ts:uint256 ref="tokenId"/> | ||
</ts:data> | ||
</ts:ethereum> | ||
</ts:origins> | ||
</ts:attribute-type> | ||
|
||
</ts:attribute-types> | ||
</ts:token> |
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,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 'AliPay' --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 |
Oops, something went wrong.