-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
429 lines (429 loc) · 11.3 KB
/
index.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
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
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://unpkg.com/vue@2"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js"></script>
<script src="web3.js?a=1"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-dark@5/dark.css">
<title>Navcoin Web3 dApp - Sample Project</title>
</head>
<body>
<div class="container mt-3" id="app">
<div class="row">
<div class="col-md-6">
<div class="card card-primary">
<div class="card-header">
Check Extension
</div>
<div class="card-body">
<div class="form-group">
Extension Installed : {{is_extension_installed}}
</div>
<div class="form-group">
Extension Version : {{version}}
</div>
<div class="form-group">
Connected : {{is_connected}}
</div>
<div class="form-group">
Address : {{address}}
</div>
<div class="form-group mt-3" v-if='!is_connected'>
<a class="btn btn-primary" v-on:click="ConnectWallet()">Connect</a>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card card-primary">
<div class="card-header">
NFT
</div>
<div class="card-body">
<div v-if="is_connected">
<div class="form-group mt-3">
<a class="btn btn-primary" v-on:click="CreateNFTCollection()">Create NFT Collection</a>
</div>
<div class="form-group mt-3">
<a class="btn btn-primary" v-on:click="CreateNFT()">Create NFT</a>
</div>
<div class="form-group mt-3">
<a class="btn btn-primary" v-on:click="ListNFTCollections()">List NFT Collections</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-md-12">
<div class="card card-primary">
<div class="card-header">
NFT Collections
</div>
<div class="card-body">
<code>
{{collections}}
</code>
</div>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-md-6">
<div class="card card-primary">
<div class="card-header">
Crate Private Token
</div>
<div class="card-body">
<div v-if="is_connected">
<div class="form-group mt-3">
<a class="btn btn-primary" v-on:click="CreatePrivateToken()">Create Private Token</a>
</div>
<div class="form-group" v-if="tx">
<h5>Transaction Hash</h5>
{{private_token_tx.hashes[0]}}
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card card-primary">
<div class="card-header">
Mint Private Token
</div>
<div class="card-body">
<div v-if="is_connected">
<div class="form-group mt-3">
Token ID : <input type="text" class="form-control" v-model="token_id"/>
</div>
<div class="form-group mt-3">
<a class="btn btn-primary" v-on:click="MintPrivateToken()">Mint Private Token</a>
</div>
<div class="form-group" v-if="tx">
<h5>Transaction Hash</h5>
{{private_token_tx.hashes[0]}}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-md-6">
<div class="card card-primary">
<div class="card-header">
Transaction
</div>
<div class="card-body">
<div v-if="is_connected">
<div class="form-group mt-3">
<a class="btn btn-primary" v-on:click="CreateTransaction()">Create Transaction</a>
</div>
<div class="form-group" v-if="tx">
<h5>Transaction Hash</h5>
{{tx.hashes[0]}}
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card card-primary">
<div class="card-header">
Message
</div>
<div class="card-body">
<div v-if="is_connected">
<div class="form-group mt-3">
<a class="btn btn-primary" v-on:click="SignMessage()">Sign Message</a>
</div>
<div class="form-group" v-if="signed_message">
<h5>Signed Message</h5>
<code>{{signed_message}}</code>
<h5>Address</h5>
<code>{{signed_address}}</code>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
var Web3 = new Web3SDK({
"network":"testnet",
"log":true
});
var app = new Vue({
el: '#app',
data:
{
is_extension_installed:false,
is_connected:false,
version:'',
address:undefined,
signed_message:undefined,
signed_address:undefined,
tx:undefined,
private_token_tx:undefined,
token_id:'',
collections:{}
},
methods:
{
ConnectWallet: function()
{
Web3.Connect();
},
CreateNFTCollection: function()
{
let scheme=JSON.stringify({
"version": 1,
"category": "",
"description": "Collection Description",
"image": "ipfs://QmUkqNpMQ5PX84YwMEhVArhfeiwajyihseXoEMh2K8b1PC",
"external_url": "https://www.url.com",
"attributes":
{
"thumbnail_url": "ipfs://QmUkqNpMQ5PX84YwMEhVArhfeiwajyihseXoEMh2K8b1PC",
"content_type": "image/png"
}
});
Web3.CreateNftCollection({
name:"Collection Name",
scheme:scheme,
max_supply:100
});
},
CreateNFT: function()
{
let scheme=JSON.stringify({
"version": 1,
"category": "art",
"sub_category": null,
"name": "NFT Name",
"description": "NFT Description",
"image": "ipfs://QmVVPLdohygxBfRmAuFgRsdDoCCWjG7L9w3pMmYrzkubcA",
"external_url": "https://www.url.com/0",
"attributes":
{
"thumbnail_url": "ipfs://QmVVPLdohygxBfRmAuFgRsdDoCCWjG7L9w3pMmYrzkubcA",
"content_type": "image/png",
"family_id": "0"
}
});
Web3.CreateNft({
token_id:"f0006b0eb29b3b7e6306212ad6b105d4a362300d98f68613139a97bcde90ac42",
nft_id:0,
scheme:scheme
});
},
CreateTransaction:function()
{
let address="xNTVnRrBYbkYABv4kXN6CsYkdQFSDZdMvFXPcPTG3AYwYB1CR45iuiDgHYtNBXPjHdpYA4CMtAsuJh9SDU1SDQAeMWuUYsPM9eFfD9KhMDwastyeGZiBQw9ZcdKb18hHMvC2Z97mwa4";
let amount=1;
Web3.CreateTransaction({address:address,amount:amount});
},
CreatePrivateToken:function()
{
let name="XSI Token";
let symbol="XSI";
let max_supply=100000000;
Web3.CreatePrivateToken({name:name,symbol:symbol,max_supply:max_supply});
},
MintPrivateToken:function()
{
let token_id=this.token_id;
let amount="1000";
Web3.MintPrivateToken({token_id:token_id,amount:amount});
},
SignMessage:function()
{
let message="this is the message!";
Web3.SignMessage({message:message});
},
ListNFTCollections:function()
{
Web3.ListNftCollections();
}
}
});
window.addEventListener("sdk_loaded", function(e)
{
console.log("Navcoin Web3 SDK loaded on ", e.detail.network);
});
window.addEventListener("extension_found", function(e)
{
console.log("Extension version : ", e.detail.version);
console.log("Is connected : ", e.detail.connected);
console.log("Address : ", e.detail.address);
app.is_extension_installed=true;
app.version=e.detail.version;
app.is_connected=e.detail.connected;
app.address=e.detail.address;
});
function accept_connection(address)
{
console.log("accept connection -> " + address);
app.address=address;
app.is_connected=true;
Swal.fire({
position: 'top-end',
icon: 'success',
title: "Wallet Connect",
text: "Connection request has been accepted",
showConfirmButton: false,
timer: 3000
})
}
function reject_connection()
{
console.log("connection request rejected");
Swal.fire({
position: 'top-end',
icon: 'warning',
title: "Wallet Connect",
text: "Connection request has been rejected by wallet",
showConfirmButton: false,
timer: 3000
})
}
function create_nft_collection(result)
{
console.log("create nft collection -> " + result);
Swal.fire({
position: 'top-end',
icon: 'warning',
title: "Create NFT Collection",
text: (result?"Success":"Rejected"),
showConfirmButton: false,
timer: 3000
})
}
function create_nft(result)
{
console.log("create nft -> " + result);
Swal.fire({
position: 'top-end',
icon: 'warning',
title: "Create NFT",
text: (result?"Success":"Rejected"),
showConfirmButton: false,
timer: 3000
})
}
function list_nft_collections(collections)
{
app.collections=collections;
}
function accept_create_transaction(tx)
{
console.log("accept create transaction");
console.log(tx);
app.tx=tx;
Swal.fire({
position: 'top-end',
icon: 'success',
title: "Transaction",
text: "Transaction request accepted",
showConfirmButton: false,
timer: 3000
})
}
function reject_create_transaction()
{
console.log("transaction request rejected");
Swal.fire({
position: 'top-end',
icon: 'warning',
title: "Transaction",
text: "Transaction request rejected",
showConfirmButton: false,
timer: 3000
})
}
function accept_create_private_token(private_token_tx)
{
console.log("accept create private token");
console.log(private_token_tx);
app.private_token_tx=private_token_tx;
Swal.fire({
position: 'top-end',
icon: 'success',
title: "Create Private Token",
text: "Create private token request accepted",
showConfirmButton: false,
timer: 3000
})
}
function reject_create_private_token()
{
console.log("create private token request rejected");
Swal.fire({
position: 'top-end',
icon: 'warning',
title: "Create Private Token",
text: "Create private token request rejected",
showConfirmButton: false,
timer: 3000
})
}
function accept_mint_private_token(private_token_tx)
{
console.log("mint create private token");
console.log(private_token_tx);
app.private_token_tx=private_token_tx;
Swal.fire({
position: 'top-end',
icon: 'success',
title: "Mint Private Token",
text: "Mint private token request accepted",
showConfirmButton: false,
timer: 3000
})
}
function reject_mint_private_token()
{
console.log("mint private token request rejected");
Swal.fire({
position: 'top-end',
icon: 'warning',
title: "Mint Private Token",
text: "Mint private token request rejected",
showConfirmButton: false,
timer: 3000
})
}
function accept_sign_message(signed_message,address)
{
console.log("accept sign message");
console.log(signed_message);
console.log(address);
app.signed_message=signed_message;
app.signed_address=address;
Swal.fire({
position: 'top-end',
icon: 'success',
title: "Sign Message",
text: "Sign message request accepted",
showConfirmButton: false,
timer: 3000
})
}
function reject_sign_message()
{
console.log("sign message request rejected");
Swal.fire({
position: 'top-end',
icon: 'warning',
title: "Sign Message",
text: "Sign message request rejected",
showConfirmButton: false,
timer: 3000
})
}
</script>
</html>