-
Notifications
You must be signed in to change notification settings - Fork 16
/
pages.py
822 lines (598 loc) · 39.6 KB
/
pages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
# -*- coding: utf-8 -*-
# MultiChain Explorer 2 (c) Coin Sciences Ltd
# All rights reserved under BSD 3-clause license
import cfg
from urllib import parse
DEFAULT_REFRESH=5000
HIDDEN_REFRESH=5000000
DEFAULT_NATIVE_CURRENCY_ID='0-0-0'
DEFAULT_TEMPLATE = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<base href="%(base)s">
<title>%(title)s</title>
<!-- Bootstrap and Theme -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<link href="mce.css" rel="stylesheet">
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-1.11.3.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script src="mce.js"></script>
%(myheader)s
</head>
<body>
<div class="container">
<table class="header-table"><tr><td class="header-logo">
<a title="Back to home" href=""><img src="logo32.png" alt="MultiChain logo" height="40" /></a>
</td><td class="header-title">
<h1>%(h1)s</h1>
</td><td class="header-search">
%(search)s
</td></tr></table>
%(body)s
<br><br>
<p style="font-size: smaller">
<span style="font-style: italic">
Powered by <a href="https://github.com/MultiChain/multichain-explorer-2">MultiChain Explorer %(version)s</a>
</span>
</p>
</div>
</body>
</html>
"""
DEFAULT_TEMPVARS={
"title":"",
"myheader":"",
"h1":"",
"body":"",
"base":"",
"search":"",
"version":cfg.version,
}
DEFAULT_HEADERS=[("Content-type", "text/html")]
DEFAULT_LOADING_HTML="Loading..."
class MCEPageHandler():
def __init__(self):
self.template=DEFAULT_TEMPLATE
self.template_vars=DEFAULT_TEMPVARS.copy()
self.headers=DEFAULT_HEADERS
self.status=200
self.refresh=DEFAULT_REFRESH
self.objects=[]
self.template_vars["base"]=cfg.settings['main']['base']
return
def standard_response(self,tvars):
base_page=cfg.settings['main']['base']
if len(self.objects) > 0:
refresh_script='<script>var timer=0;function getdata(){'
for obj in self.objects:
nparams_str=''
if 'params' in obj:
if len(obj['params']) > 0:
nparams=[]
for k,v in obj['params'].items():
nparams.append(str(k) + '=' + str(v))
nparams_str='?' + '&'.join(nparams)
refresh_script += 'const xhr_' + obj['id'] + ' = new XMLHttpRequest();'
refresh_script += 'xhr_' + obj['id'] + '.open("GET","' + base_page + '/'.join(obj['path']) + nparams_str + '" , true);'
refresh_script += 'xhr_' + obj['id'] + '.onreadystatechange = function () {'
refresh_script += 'if (this.readyState == 4 && this.status == 200) {'
refresh_script += ' document.getElementById("' + obj['id'] + '").innerHTML=this.responseText;'
refresh_script += '$(\'[data-toggle="popover"]\').popover();'
# refresh_script += ' document.getElementById("' + obj['id'] + '").scrollIntoView();'
refresh_script += '}'
refresh_script += '};'
refresh_script += 'xhr_' + obj['id'] + '.send();'
refresh_script += '}; '
# refresh_script += '$(document).ready(function(){getdata();});</script>'
refresh_script += '$(document).ready(function(){getdata();timer=setInterval(function(){getdata()}, ' + str(self.refresh) + ');'
refresh_script += 'if(document.addEventListener) document.addEventListener("visibilitychange", visibilityChanged);});'
refresh_script += 'function visibilityChanged() {clearTimeout(timer);if(!document.hidden)getdata();timer = setInterval(function(){getdata()}, (document.hidden) ? '+ str(HIDDEN_REFRESH) + ' : ' + str(self.refresh) + ');}</script>'
tvars['myheader']=refresh_script
# print(refresh_script)
return (self.status, self.headers, bytes(self.template % tvars,"utf-8"))
def handle_chains(self,chain,params,nparams):
tvars=self.template_vars.copy();
body = '<div id="chains">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['title']="MultiChain Explorer"
tvars['h1']="MultiChain Explorer"
# List of divs to be updated and elements of the path which should retreive data for this div
self.objects=[]
self.objects.append({"id":"chains","path":["chains-data"]});
return self.standard_response(tvars)
def chain_search_form(self,chain):
form_html='<form method="POST" name="search" action="' + chain.config['path-name'] + '/search">'
form_html+='<input name="search_value" type="text" value="" size="32" /> <input type="submit" name="search" value="Search"/></form> '
return form_html;
def handle_chain(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = ''
if len(params) > 0:
body += '<div class="error-wrapper">'
body += 'No asset, stream, address or transaction to match '
body += '"' + str(parse.unquote_plus(params[0])) + '"'
body += ' could be found.'
body += '</div>'
body += '<div>'
body += '<div class="row">'
body += '<div class="col-md-6" id="summary">'
body += '</div>'
body += '<div class="col-md-6" id="parameters">'
body += '</div>'
body += '</div>'
body += '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name']
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>'
self.objects=[]
self.objects.append({"id":"summary","path":[chain.config['path-name'],"chainsummary-data"]});
self.objects.append({"id":"parameters","path":[chain.config['path-name'],"chainparameters-data"]});
## self.template_vars=tvars
return self.standard_response(tvars)
def handle_stream(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = ''
body += '<div id="summary">' + DEFAULT_LOADING_HTML + '</div>'
body += '<h3>Recently Published <a href="'+chain.config['path-name']+"/streamitems/"+entity_quoted+'">Items</a></h3>'
body += '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
# body += '<h3>Recently Created <a href="'+chain.config['path-name']+"/streamkeys/"+entity_quoted+'">Keys</a></h3>'
# body += '<div id="keys">' + DEFAULT_LOADING_HTML + '</div>'
# body += '<h3><a href="'+chain.config['path-name']+"/streampublishers/"+entity_quoted+'">Publishers</a></h3>'
# body += '<div id="publishers">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
title=" - stream: " + entity_name
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + title
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + title
# List of divs to be updated and elements of the path which should retreive data for this div
self.objects=[]
self.objects.append({"id":"summary","path":[chain.config['path-name'],"streamsummary-data",entity_quoted]});
self.objects.append({"id":"items","path":[chain.config['path-name'],"streamitems-data",entity_quoted],"params":{"onlylast":1}});
self.objects.append({"id":"keys","path":[chain.config['path-name'],"streamkeys-data",entity_quoted],"params":{"onlylast":1}});
self.objects.append({"id":"publishers","path":[chain.config['path-name'],"streampublishers-data",entity_quoted],"params":{"onlylast":1}});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_asset(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = ''
body += '<div id="summary">' + DEFAULT_LOADING_HTML + '</div>'
body += '<h3>Latest <a href="'+chain.config['path-name']+"/assettransactions/"+entity_quoted+'">Transactions</a></h3>'
body += '<div id="transactions">' + DEFAULT_LOADING_HTML + '</div>'
# body += '<h3>Asset <a href="'+chain.config['path-name']+"/assetissues/"+entity_quoted+'">Issues</a></h3>'
# body += '<div id="issues">' + DEFAULT_LOADING_HTML + '</div>'
# body += '<h3>Asset <a href="'+chain.config['path-name']+"/assetholders/"+entity_quoted+'">Holders</a></h3>'
# body += '<div id="holders">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
title=" - asset: " + entity_name
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + title
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + title
self.objects=[]
self.objects.append({"id":"summary","path":[chain.config['path-name'],"assetsummary-data",entity_quoted]});
self.objects.append({"id":"transactions","path":[chain.config['path-name'],"assettransactions-data",entity_quoted],"params":{"onlylast":1}});
# self.objects.append({"id":"issues","path":[chain.config['path-name'],"assetissues-data",entity_quoted],"params":{"onlylast":1}});
self.objects.append({"id":"holders","path":[chain.config['path-name'],"assetholders-data",entity_quoted],"params":{"onlylast":1}});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_address(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = ''
body += '<div id="summary">' + DEFAULT_LOADING_HTML + '</div>'
body += '<h3>Latest <a href="'+chain.config['path-name']+"/addresstransactions/"+str(params[0])+'">Transactions</a></h3>'
body += '<div id="transactions">' + DEFAULT_LOADING_HTML + '</div>'
# body = ''
# body += '<h3>Permissions</h3>'
# body += '<div id="permissions">' + DEFAULT_LOADING_HTML + '</div>'
# body += '<h3>Latest <a href="'+chain.config['path-name']+"/addresstransactions/"+str(params[0])+'">Transactions</a></h3>'
# body += '<div id="transactions">' + DEFAULT_LOADING_HTML + '</div>'
# body += '<h3>Latest <a href="'+chain.config['path-name']+"/addressassets/"+str(params[0])+'">Asset Balances</a></h3>'
# body += '<div id="assets">' + DEFAULT_LOADING_HTML + '</div>'
# body += '<h3><a href="'+chain.config['path-name']+"/addressstreams/"+str(params[0])+'">Published in Streams</a></h3>'
# body += '<div id="streams">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
title=" - address: " + str(params[0])
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + title
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - address: " + str(params[0][0:10]) + "..."
self.objects=[]
self.objects.append({"id":"summary","path":[chain.config['path-name'],"addresssummary-data",str(params[0])]});
self.objects.append({"id":"transactions","path":[chain.config['path-name'],"addresstransactions-data",str(params[0])],"params":{"onlylast":1}});
# self.objects.append({"id":"permissions","path":[chain.config['path-name'],"addresspermissions-data",str(params[0])]});
# self.objects.append({"id":"transactions","path":[chain.config['path-name'],"addresstransactions-data",str(params[0])],"params":{"onlylast":1}});
# self.objects.append({"id":"assets","path":[chain.config['path-name'],"addressassets-data",str(params[0])],"params":{"onlylast":1}});
# self.objects.append({"id":"streams","path":[chain.config['path-name'],"addressstreams-data",str(params[0])],"params":{"onlylast":1}});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_streams(self,chain,params,nparams):
return self.do_entities(chain,params,nparams,"streams","Streams")
def handle_assets(self,chain,params,nparams):
return self.do_entities(chain,params,nparams,"assets","Assets")
def handle_blocks(self,chain,params,nparams):
return self.do_entities(chain,params,nparams,"blocks","Blocks")
def handle_transactions(self,chain,params,nparams):
return self.do_entities(chain,params,nparams,"transactions","Transactions")
def handle_addresses(self,chain,params,nparams):
return self.do_entities(chain,params,nparams,"addresses","Addresses")
def handle_peers(self,chain,params,nparams):
return self.do_entities(chain,params,nparams,"peers","Peers")
def handle_miners(self,chain,params,nparams):
return self.do_entities(chain,params,nparams,"miners","Miners")
def do_entities(self,chain,params,nparams,name,display_name):
if chain is None:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = '<div id="'+name+'">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
title=" - " + display_name
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + title
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + title
# List of divs to be updated and elements of the path which should retreive data for this div
self.objects=[]
self.objects.append({"id":name,"path":[chain.config['path-name'],name+"-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_assetissues(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + entity_name + " - asset issues"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/asset/"+entity_quoted+'">' + entity_name + '</a>' + " - asset issues"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"assetissues-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_addressstreams(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + str(params[0]) + " - address streams"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/address/"+str(params[0])+'">' + str(params[0]) + '</a>' + " - address streams"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"addressstreams-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_addressassets(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + str(params[0]) + " - address assets"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/address/"+str(params[0])+'">' + str(params[0]) + '</a>' + " - address assets"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"addressassets-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_addresstransactions(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + str(params[0]) + " - address transactions"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/address/"+str(params[0])+'">' + str(params[0]) + '</a>' + " - address transactions"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"addresstransactions-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_blocktransactions(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - block " + str(params[0]) + " - transactions"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - block " + '<a href="'+chain.config['path-name']+"/block/"+str(params[0])+'">' + str(params[0]) + '</a>' + " - transactions"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"blocktransactions-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_assettransactions(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + entity_name + " - asset transactions"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/asset/"+entity_quoted+'">' + entity_name + '</a>' + " - asset transactions"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"assettransactions-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_assetholders(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
if entity_quoted != DEFAULT_NATIVE_CURRENCY_ID:
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + entity_name + " - asset holders"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/asset/"+entity_quoted+'">' + entity_name + '</a>' + " - asset holders"
else:
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - Native Currency holders"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - Native Currency holders"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"assetholders-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_assetholdertransactions(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
if entity_quoted != DEFAULT_NATIVE_CURRENCY_ID:
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + str(params[1]) + " - transactions for asset " + entity_name
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/address/"+str(params[1])+'">' + str(params[1]) + '</a>' + " - transactions for asset " + '<a href="'+chain.config['path-name']+"/asset/"+entity_quoted+'">' + entity_name + '</a>'
else:
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + str(params[1]) + " - Native Currency transactions"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/address/"+str(params[1])+'">' + str(params[1]) + '</a>' + " - Native Currency transactions"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"assetholdertransactions-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_globalpermissions(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - global permissions"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - global permissions"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"globalpermissions-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_assetpermissions(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + entity_name + " - asset permissions"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/asset/"+entity_quoted+'">' + entity_name + '</a>' + " - asset permissions"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"assetpermissions-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_streampermissions(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + entity_name + " - stream permissions"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/stream/"+entity_quoted+'">' + entity_name + '</a>' + " - stream permissions"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"streampermissions-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_streamitems(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + entity_name+ " - stream items"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/stream/"+entity_quoted+'">' + entity_name + '</a>' + " - stream items"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"streamitems-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_streamkeys(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + entity_name + " - stream keys"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/stream/"+entity_quoted+'">' + entity_name + '</a>' + " - stream keys"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"streamkeys-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_streampublishers(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + entity_name + " - stream publishers"
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/stream/"+entity_quoted+'">' + entity_name + '</a>' + " - stream publishers"
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"streampublishers-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_keyitems(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 2:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + entity_name + " - items for key " + parse.unquote_plus(str(params[1]))
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/stream/"+entity_quoted+'">' + entity_name + '</a>' + " - items for key " + parse.unquote_plus(str(params[1]))
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"keyitems-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_publisheritems(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 2:
return self.handle_notfound(chain,params,nparams)
entity_quoted=params[0]
entity_name=parse.unquote_plus(entity_quoted)
tvars=self.template_vars.copy();
body = '<div id="items">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + " - " + entity_name + " - items published by " + str(params[1])
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - " + '<a href="'+chain.config['path-name']+"/stream/"+entity_quoted+'">' + entity_name + '</a>' + " - items published by " + '<a href="'+chain.config['path-name']+"/address/"+str(params[1])+'">' + str(params[1])[0:10] + '...' + '</a>'
self.objects=[]
self.objects.append({"id":"items","path":[chain.config['path-name'],"publisheritems-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_block(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
# body = '<div id="block">' + DEFAULT_LOADING_HTML + '</div>'
body = ''
body += '<div id="summary">' + DEFAULT_LOADING_HTML + '</div>'
# body += '<h3><a href="'+chain.config['path-name']+"/blocktransactions/"+str(params[0])+'">Transactions</a></h3>'
# body += '<div id="transactions">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
title=" - block " + params[0]
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + title
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + title
# List of divs to be updated and elements of the path which should retreive data for this div
self.objects=[]
self.objects.append({"id":"summary","path":[chain.config['path-name'],"blocksummary-data",str(params[0])]});
# self.objects.append({"id":"transactions","path":[chain.config['path-name'],"blocktransactions-data",str(params[0])],"params":nparams});
# self.objects.append({"id":"transactions","path":[chain.config['path-name'],"blocktransactions-data",str(params[0])],"params":{"onlylast":1}});
# self.objects.append({"id":"block","path":[chain.config['path-name'],"block-data"]+params});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_transaction(self,chain,params,nparams):
if chain is None:
return self.handle_notfound(chain,params,nparams)
if len(params) < 1:
return self.handle_notfound(chain,params,nparams)
tvars=self.template_vars.copy();
body = '<div id="transaction">' + DEFAULT_LOADING_HTML + '</div>'
tvars['body']=body
tvars['search']=self.chain_search_form(chain);
title=" - transaction: " + params[0]
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + title
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + " - transaction: " + params[0][0:10] + "..."
# List of divs to be updated and elements of the path which should retreive data for this div
self.objects=[]
self.objects.append({"id":"transaction","path":[chain.config['path-name'],"transaction-data"]+params,"params":nparams});
# self.template_vars=tvars
return self.standard_response(tvars)
def handle_notfound(self,chain=None,params=None,nparams=None):
tvars=self.template_vars.copy();
tvars['body']='<p class="error">Sorry, page does not exist on this server.</p>';
title=" - Page Not Found"
if chain is None:
tvars['title']="MultiChain Explorer" + title
tvars['h1']='<a href="">' + title + '</a>'
else:
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + title
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + title
# self.template_vars=tvars
self.status=404
self.objects=[]
return self.standard_response(tvars)
def handle_connerror(self,chain=None,params=None,nparams=None):
tvars=self.template_vars.copy();
tvars['body']='<p class="error"></p>';
title=""
if chain is None:
tvars['title']="MultiChain Explorer" + title
tvars['h1']='<a href="">' + title + '</a>'
else:
tvars['title']="MultiChain Explorer - " + chain.config['display-name'] + title
tvars['h1']='<a href="'+chain.config['path-name']+'">' + chain.config['display-name'] + '</a>' + title
# self.template_vars=tvars
self.status=404
self.objects=[]
return self.standard_response(tvars)