-
Notifications
You must be signed in to change notification settings - Fork 0
/
101_debug.html
106 lines (87 loc) · 3.41 KB
/
101_debug.html
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
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0">
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous">
<script src="symbol-sdk-0.17.3.js"></script>
<script>
const nem = require("/node_modules/symbol-sdk");
console.log(nem);
console.log(new nem.UInt64([27174,0]).compact());
console.log(new nem.UInt64([853116887,2007078553]).toHex());
console.log(new Date(new nem.UInt64([1241926107,24]).compact() + Date.UTC(2016, 3, 1, 0, 0, 0, 0)));
console.log(nem.UInt64.fromUint(27174).toDTO());
console.log(nem.UInt64.fromHex("77A1969932D987D7").toDTO());
o="";
r=nem.Convert.rstr2utf8("日本語でも大丈夫");
for (i in r){
o+=r.charCodeAt(i).toString(16);
}
console.log(o);
o="";
hex="e697a5e69cace8aa9ee381a7e38282e5a4a7e4b888e5a4ab";
for(var i=0;i<hex.length;i+=2){
o+= String.fromCharCode(parseInt(hex.substr(i,2),16));
}
console.log(decodeURIComponent(escape(o)));
console.log(nem.Deadline.timestampNemesisBlock);
console.log(nem.UInt64.fromUint((new Date()).getTime() - nem.Deadline.timestampNemesisBlock * 1000).toDTO());
console.log(nem.Address.createFromPublicKey("FF6E61F2A0440FB09CA7A530C0C64A275ADA3A13F60D1EC916D7F1543D7F0574", nem.NetworkType.MIJIN_TEST).address);
console.log(nem.Address.createFromEncoded("9019CC9DFFB37ED9142E7937CA375FB65BF1349ED563503D67").address);
console.log(nem.Convert.uint8ToHex(nem.RawAddress.stringToAddress("SAM4ZHP7WN7NSFBOPE34UN27WZN7CNE62VRVAPLH")));
//ネームスペース
ns = new nem.NamespaceId('nem.xem')
console.log(ns);
console.log(ns.id);
console.log(ns.id.toString());
console.log(ns.id.toHex());
console.log(ns.id.toDTO());
console.log(ns.id.toDTO().toString());
const NODE = 'https://sym-test.opening-line.jp:3001';
const nsHttp = new nem.NamespaceHttp(NODE);
//ネームスペースから
nsHttp.getNamespace(ns)
.subscribe(_ => {
console.log("ネームスペース");
console.log(_.levels);
console.log("モザイク");
ms = _.alias.mosaicId;
console.log(ms.id);
console.log(ms.id.toString());
console.log(ms.id.toHex());
console.log(ms.id.toDTO());
console.log(ms.id.toDTO().toString());
const mosaicHttp = new nem.MosaicHttp(NODE);
console.log("モザイクIDからネームスペースを取得");
nsHttp.getMosaicsNames([ms])
.subscribe(_ => {
console.log(_[0].names);
}, err => console.error(err));
console.log("モザイクIDから作成者アカウントを取得");
mosaicHttp.getMosaics([ms])
.subscribe(__ => {
const accountHttp = new nem.AccountHttp(NODE);
//作成者のアカウント情報を取得
accountHttp.getAccountsInfo([__[0].owner.address])
.subscribe(___ => {
console.log("アカウント");
console.log(___);
}, err => console.error(err));
}, err => console.error(err));
}, err => console.error(err));
</script>
</head>
<body>
<div class="container">
<h1>3.3 開発環境の準備</h1>
<h3>ブラウザを使ったデバッグ手法</h3>
<p>F12キーを押してConsoleタブを確認し"nem"と入力してください。nem2-sdkが提供するすべてのライブラリを利用できます。</p>
<hr>
<a href="https://nizveyl.booth.pm/items/1549217" target="_blank">次世代NEMではじめるブロックチェーンアプリケーション開発</a>
</div>
</body>
</html>