Skip to content

Commit 1ee64b0

Browse files
Oleg GribWeiwu Zhang
authored andcommitted
added live event update, new event marker, erc20 token props list and lot other improvements
1 parent 0496b4a commit 1ee64b0

File tree

7 files changed

+502
-173
lines changed

7 files changed

+502
-173
lines changed

bootstrap-js/BOOKY.xml

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,202 @@
2424
<ts:address network="3">0x583cbBb8a8443B38aBcC0c956beCe47340ea1367</ts:address>
2525
</ts:contract>
2626
<ts:cards>
27+
<ts:card name="main" type="token">
28+
<ts:item-view xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
29+
<style type="text/css">.ts-count {
30+
font-family: "SourceSansPro";
31+
font-weight: bolder;
32+
font-size: 21px;
33+
color: rgb(117, 185, 67);
34+
}
35+
.ts-category {
36+
font-family: "SourceSansPro";
37+
font-weight: lighter;
38+
font-size: 21px;
39+
color: rgb(67, 67, 67);
40+
}
41+
.ts-venue {
42+
font-family: "SourceSansPro";
43+
font-weight: lighter;
44+
font-size: 16px;
45+
color: rgb(67, 67, 67);
46+
}
47+
.ts-date {
48+
font-family: "SourceSansPro";
49+
font-weight: bold;
50+
font-size: 14px;
51+
color: rgb(112, 112, 112);
52+
margin-left: 7px;
53+
margin-right: 7px;
54+
}
55+
.ts-time {
56+
font-family: "SourceSansPro";
57+
font-weight: lighter;
58+
font-size: 16px;
59+
color: rgb(112, 112, 112);
60+
}
61+
html {
62+
}
63+
64+
body {
65+
padding: 0px;
66+
margin: 0px;
67+
}
68+
69+
div {
70+
margin: 0px;
71+
padding: 0px;
72+
}
73+
74+
.data-icon {
75+
height:16px;
76+
vertical-align: middle
77+
}
78+
79+
.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
 }

80+
81+
82+
</style>
83+
<body>
84+
<div id="mainid"></div>
85+
<script type="text/javascript">//
86+
class Token {
87+
88+
constructor(tokenInstance) {
89+
this.props = tokenInstance;
90+
}
91+
92+
render() {
93+
return`
94+
&lt;div&gt;Symbol: ${this.props.symbol}&lt;/div>
95+
&lt;div>Name: ${this.props.name}&lt;/div>
96+
&lt;div>Balance: ${this.props.ownerBalance}&lt;/div>
97+
&lt;div>Decimals ${this.props.decimals}&lt;/div>
98+
99+
`;
100+
}
101+
}
102+
103+
web3.tokens.dataChanged = (oldTokens, updatedTokens, tokenIdCard) =&gt; {
104+
document.getElementById('mainid').innerHTML = new Token(web3.tokens.data.currentInstance).render();
105+
};
106+
//
107+
</script>
108+
</body>
109+
</ts:item-view>
110+
<ts:view xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
111+
<style type="text/css">.ts-count {
112+
font-family: "SourceSansPro";
113+
font-weight: bolder;
114+
font-size: 21px;
115+
color: rgb(117, 185, 67);
116+
}
117+
.ts-category {
118+
font-family: "SourceSansPro";
119+
font-weight: lighter;
120+
font-size: 21px;
121+
color: rgb(67, 67, 67);
122+
}
123+
.ts-venue {
124+
font-family: "SourceSansPro";
125+
font-weight: lighter;
126+
font-size: 16px;
127+
color: rgb(67, 67, 67);
128+
}
129+
.ts-date {
130+
font-family: "SourceSansPro";
131+
font-weight: bold;
132+
font-size: 14px;
133+
color: rgb(112, 112, 112);
134+
margin-left: 7px;
135+
margin-right: 7px;
136+
}
137+
.ts-time {
138+
font-family: "SourceSansPro";
139+
font-weight: lighter;
140+
font-size: 16px;
141+
color: rgb(112, 112, 112);
142+
}
143+
html {
144+
}
145+
146+
body {
147+
padding: 0px;
148+
margin: 0px;
149+
}
150+
151+
div {
152+
margin: 0px;
153+
padding: 0px;
154+
}
155+
156+
.data-icon {
157+
height:16px;
158+
vertical-align: middle
159+
}
160+
161+
.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
 }

162+
163+
164+
</style>
165+
<script type="text/javascript">//
166+
167+
168+
class Token {
169+
constructor(tokenInstance) {
170+
this.props = tokenInstance;
171+
}
172+
173+
formatGeneralizedTimeToDate(str) {
174+
const d = new GeneralizedTime(str);
175+
return new Date(d.getYear(), d.getMonth(), d.getDay(), d.getHours(), d.getMinutes(), d.getSeconds()).toLocaleDateString();
176+
}
177+
178+
formatGeneralizedTimeToTime(str) {
179+
const d = new GeneralizedTime(str);
180+
return new Date(d.getYear(), d.getMonth(), d.getDay(), d.getHours(), d.getMinutes(), d.getSeconds()).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
181+
}
182+
183+
render() {
184+
let time;
185+
let date;
186+
if (this.props.time == null) {
187+
time = "";
188+
date = "";
189+
} else {
190+
time = this.formatGeneralizedTimeToTime(this.props.time.generalizedTime);
191+
date = this.props.time == null ? "": this.formatGeneralizedTimeToDate(this.props.time.generalizedTime);
192+
}
193+
return `&lt;div&gt;
194+
&lt;div&gt;
195+
&lt;span class="ts-count"&gt;x${this.props._count}&lt;/span&gt; &lt;span class="ts-category"&gt;${this.props.label}&lt;/span&gt;
196+
&lt;/div&gt;
197+
&lt;div&gt;
198+
&lt;span class="ts-venue"&gt;${this.props.building}&lt;/span&gt;
199+
&lt;/div&gt;
200+
&lt;div style="margin: 0px; padding:0px; clear: both; height: 6px"&gt;
201+
&amp;nbsp;
202+
&lt;/div&gt;
203+
&lt;div&gt;
204+
&lt;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+Ejpgs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Uv0sYOXic35z0sUXz5HuJC0AXcNTp8FaXrCy1nXxZ2aWJruGU5P0SU8EdumuodTRzGxqwTT5hOSHPHa675DetRXPhEe4hC/6EU1xUDwUl+jjR0dK8rWx9AGsMN6xKzE90rb8N0tZ+ealmXpccqk9skbW5DnEXEt6slP1Dp7+6xUmR/FQXKqfjo+UZI4DfXANOeyPspLN0jJsxUopZErweN5OckXGi6daRIsrYjFQYxkX8NW9qA6i8D0KDztbtlzDgt5pQqlah0e9bedVe/BkE7aYj0uW6riQq5x3oSIYdyFN+IgE7kLUAajoxl1Ix30I3oWoxTnh0Gd63IWMB+1CetvCi3PCKqniIYdyP3QVT6Q5We6JhcVXSTLsCq0WfaSFh5KptD8AKu2PwMe60v4IvDzwUNsfuLdIBbU/MFTpm6YQ+hJW2L7tD8IVbIvkSrY/3ro0t26RZ6X2x3+x1apl1fM/7N14t5h1kdIVA5FXV4JxgD3gYfudSvujeBNWjKpUPCt2aR8ycOVOPuQLvmLDMVxyF7B3s84dAf/CsoDtod9cfrWdsY+/C/8HVfy/LmN347j8X8FmUoebjG3Aod3lV9sZc1GPq/ifIfhWlT5KPP4N9JQx0JLsoS9Ej1Jibi64qp7ub912rlCsdI2mDuKH3yN4u3eLc9R1WDVnnIMY61W6g5Qgxf0P/UFw0L/BhyIAAAAASUVORK5CYII=" class="data-icon"/&gt;
205+
&lt;span class="ts-date"&gt;${date}&lt;/span&gt;
206+
&lt;/div&gt;
207+
&lt;div&gt;
208+
&lt;span class="ts-time"&gt;${time}, ${this.props.locality}&lt;/span&gt;
209+
&lt;/div&gt;
210+
&lt;/div&gt;`;
211+
}
212+
}
213+
214+
web3.tokens.dataChanged = (oldTokens, updatedTokens, tokenCardId) =&gt; {
215+
const currentTokenInstance = updatedTokens.currentInstance;
216+
document.getElementById(tokenCardId).innerHTML = new Token(currentTokenInstance).render();
217+
};
218+
219+
//
220+
</script>
221+
</ts:view>
222+
</ts:card>
27223

28224
<ts:card name="sent" type="activity">
29225
<ts:origins>

bootstrap-js/active-negotiation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en" class="no-js">
33
<head>
44
<meta charset="UTF-8"/>
5-
<link rel="tokenscript" href="EntryToken.xml"/>
5+
<!-- <link rel="tokenscript" href="EntryToken.xml"/>-->
66
<link rel="tokenscript" href="BOOKY.xml"/>
77
<!-- since we are demonstrating active negotiation here, there is no meta-data declared in this example
88
-->

bootstrap-js/modules/ts_helpers.js

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,21 +288,26 @@ export async function getJSONAbi(ethContract, jsons, path = '', debug = false){
288288

289289
/**
290290
* Convert Contact filter results to readable values and extends it with common token props
291-
* @param resItem
292-
* @param commonProps
291+
* @param resArgs
292+
* @param incomeProps
293293
* @returns {*}
294294
*/
295-
export function filterResultConverter(resItem, commonProps) {
295+
export function filterResultConverter(resArgs, incomeProps) {
296+
// console.log('filterResultConverter input = ');
297+
// console.log(resArgs);
298+
let resultProps = Object.assign({}, incomeProps);
296299
['owner', 'spender', 'from', 'to'].forEach(arg => {
297-
if (resItem.args['_' + arg]) commonProps[arg] = resItem.args['_' + arg];
300+
if (resArgs['_' + arg]) resultProps[arg] = resArgs['_' + arg];
298301
});
299302
['value', 'amount'].forEach(arg => {
300-
if (resItem.args['_' + arg]) commonProps[arg] =
301-
resItem.args['_' + arg]._isBigNumber
302-
? bnStringPrecision(resItem.args['_' + arg], commonProps['decimals'], 8)
303-
: resItem.args['_' + arg];
303+
if (resArgs['_' + arg]) resultProps[arg] =
304+
resArgs['_' + arg]._isBigNumber
305+
? bnStringPrecision(resArgs['_' + arg], resultProps['decimals'], 12)
306+
: resArgs['_' + arg];
304307
})
305-
return commonProps;
308+
// console.log('resultProps');
309+
// console.log(resultProps);
310+
return resultProps;
306311
}
307312

308313
/**
@@ -376,7 +381,7 @@ export function getEthereumCallParams({userAddress, tokenId, chainID , ethereumN
376381
var contract = getContractAddress(xmlDoc, ethCallAttributtes.contract, tokenXmlNode, chainID);
377382

378383
if (!contract.contractAddress) {
379-
tsDebug && console.log('Contract address required. chainID = '+chainID);
384+
debug && console.log('Contract address required. chainID = '+chainID);
380385
return false;
381386
}
382387

@@ -416,6 +421,37 @@ export function getEthereumCallParams({userAddress, tokenId, chainID , ethereumN
416421

417422
}
418423

424+
/**
425+
* Parse ERC20 events and display to console
426+
* @param erc20EventName
427+
* @param xmlDoc
428+
* @param tokenXMLNode
429+
* @returns {boolean}
430+
*/
431+
export function getErc20EventParams(erc20EventName, xmlDoc, tokenXMLNode){
432+
let nsResolver = xmlDoc.createNSResolver( xmlDoc.ownerDocument == null ? xmlDoc.documentElement : xmlDoc.ownerDocument.documentElement);
433+
434+
const eventXmlNodes = xmlDoc.evaluate('asnx:module[@name="ERC20-Events"]/namedType[@name="'+erc20EventName+'"]', tokenXMLNode, nsResolver, XPathResult.ANY_TYPE, null );
435+
436+
437+
438+
let params = {};
439+
440+
let moduleNode;
441+
if (moduleNode = eventXmlNodes.iterateNext()) {
442+
443+
let eventElementsXmlNodes = xmlDoc.evaluate('type/sequence/element', moduleNode, nsResolver, XPathResult.ANY_TYPE, null );
444+
445+
let eventElementsXmlNode; ;
446+
while ( eventElementsXmlNode = eventElementsXmlNodes.iterateNext() ) {
447+
params[eventElementsXmlNode.getAttribute('name')] = null;
448+
}
449+
} else {
450+
return false;
451+
}
452+
453+
return params;
454+
}
419455

420456

421457

bootstrap-js/passive-negotiation.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<!-- this is for token negotiation! -->
99
<!-- OG: meta tag allow only "scheme,name,http-equiv,content,charset". we can use "name,content" to stay document valid-->
1010
<!-- <meta name="token" content="entry-token"/>-->
11-
<meta name="token.filter" content="objectClass=entrytoken"/>
12-
<!-- <meta name="token.filter" content="objectClass=booky"/>-->
11+
<!-- <meta name="token.filter" content="objectClass=entrytoken"/>-->
12+
<meta name="token.filter" content="objectClass=booky"/>
1313
<!-- <meta name="token-expiry" content=">=2018-04-04"/>-->
1414
<!-- if without linked TokenScript, consider a synax like this
1515
<meta tokens-accepted="ethereum:1/0x63cCEF733a093E5Bd773b41C96D3eCE361464942/"/>

0 commit comments

Comments
 (0)