forked from cashonize/legacy-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
759 lines (714 loc) · 40.5 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Cashonize | A Bitcoin Cash Wallet</title>
<link rel="icon" type="image/png" href="/images/cashonize-icon.png">
<meta name="thumbnail" content="/images/cashonize-icon.png" />
<meta name="description" content="Cashonize - a Bitcoin Cash Wallet. Cashonize supports CashTokens, WalletConnect and CashConnect.">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/chota@0.8.0/dist/chota.min.css">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="cashconnect.css">
<link rel="stylesheet" href="walletconnect.css">
<link rel="stylesheet" href="switchery/switchery.css" />
<script src="switchery/switchery.js"></script>
<script defer src="https://cdn.mainnet.cash/mainnet-2.3.0.js"></script>
<script src="https://cdn.mainnet.cash/indexeddb-storage/indexeddb-storage-2.3.0.js"></script>
<script>window.exports = {}</script>
<script defer src="https://unpkg.com/@download/blockies@1.0.3/dist/blockies.min.js"></script>
<script src="https://unpkg.com/@bitjson/qr-code@1.0.2/dist/qr-code.js"></script>
<script src="https://unpkg.com/html5-qrcode" type="text/javascript"></script>
<script defer data-domain="cashonize.com" src="https://plausible.io/js/script.js"></script>
</head>
<body>
<div id="banner">
The official url for Cashonize going forward is <a href="https://cashonize.com/">Cashonize.com</a>, please migrate!
</div>
<header>
<img class="cashonize-logo" src="./images/cashonize-logo.png" alt="Cashonize: A Bitcoin Cash Wallet">
<div>
<nav class="nav hide">
<div class="nav-left">
<div class="tabs">
<a id="view0" class="view active" onclick="changeView(0)"></a>
<a id="view1" class="view" onclick="changeView(1)"></a>
<a id="view2" class="view" onclick="changeView(2)"></a>
<a id="view4" class="view" onclick="changeView(4)"></a>
<a id="view3" class="view" onclick="changeView(3)">
<div><img class="icon settingsIcon" src="/images/settings.svg"></div>
</a>
</div>
</div>
</nav>
</div>
</header>
<main>
<div class="container">
<div id="newWalletView" class="hide">
<fieldset style="margin-top: 15px;">
<h4><img class="icon plusIcon" src="/images/plus-square.svg"> Create new wallet</h4>
<input class="button primary" type="button" value="Create" onclick="createNewWallet()">
<br><br>
<hr>
<br>
<h4><img class="icon importIcon" src="/images/log-in.svg"> Import existing wallet</h4>
<div>Enter mnemonic seed phrase</div>
<textarea style="resize: none;" id="enterSeedphrase" rows="3" cols="50" placeholder="word1 word2 ..."></textarea>
<span>Derivation path: </span>
<select name="derivationPath" id="derivationPath" onchange="selectTokenType(event)">
<option value="standard">m/44’/145’/0’ (standard)</option>
<option value="bitcoinfotcom">m/44’/0’/0’ (bitcoin.com wallet)</option>
</select> <br>
<input class="button primary" type="button" style="margin-top:15px" value="Import" onclick="importWallet()">
<br><br>
</fieldset>
</div>
<div id="walletView" class="hide">
<fieldset style="margin-top: 20px; padding-top: 2rem;">
<div id="showsUsdBalance">
<span>USD balance: </span>
<span id="balanceUsd" class="text-primary"></span>
</div>
<div>
BCH balance: <span id="balance" class="text-primary"></span>
<span id="balanceUnit" class="text-primary unit"></span>
</div>
<div>Wallet token balance: <span id="tokenBalance" class="text-primary"></span></div>
<div style="word-break: break-all;">BCH address: <span class="depositAddr" id="depositAddr"></span>
<button type="button" style="background: none; padding: 0;" onclick="copyTextContent('depositAddr')">
<img class="copyIcon icon" src="/images/copy.svg">
</button>
</div>
<div style="word-break: break-all;">Token address: <span class="depositAddr" id="depositTokenAddr"></span>
<button type="button" style="background: none; padding: 0;" onclick="copyTextContent('depositTokenAddr')">
<img class="copyIcon icon" src="/images/copy.svg">
</button>
</div>
<div><img id="placeholderQr" class="placeholderQr" src="./images/qrcode.jpg" /></div>
<qr-code
id="qr1"
contents="loading..."
class="hide"
style="
width: 240px;
height: 240px;
margin: 5px auto 0 auto;
background-color: #fff;
"
>
<img src="/images/bch-icon.png" slot="icon" />
</qr-code>
<qr-code
id="qr2"
contents="loading.."
class="hide"
style="
width: 240px;
height: 240px;
margin: 5px auto 0 auto;
background-color: #fff;
"
>
<img src="/images/tokenicon.png" slot="icon" alt="token icon"/>
</qr-code>
<div class="is-center"><div id="switchAddress" class="icon" onclick="switchAddressType()">⇄</div></div>
</fieldset>
<fieldset style="margin-top: 15px">
<legend>Send BCH to</legend>
<p class="inputGroup">
<span class="addressInput"><input id="sendAddr" placeholder="address"></span>
<span class="sendAmountGroup">
<span style="width: 100%;" class="input-icon input-icon-right">
<input id="sendAmount" type="text" placeholder="amount">
<i id="sendUnit" style="color: black;">BCH</i>
</span>
<button onclick="maxBch(event)" style="color: black;">max</button>
</span>
</p>
<input type="button" class="primaryButton" id="send" value="Send">
</fieldset>
</div>
<div id="tokenView" class="hide tokenView">
<div id="loadingTokenData">Loading token data...</div>
<div id="noTokensFound" class="hide">Currently there are no tokens in this wallet...</div>
<div id="verifiedOnly" class="hide">
<span>Show verified tokens only </span>
<input type="checkbox" class="js-switch js-check-change" id="verifiedOnlySwitch">
</div>
<div id="noVerifiedTokens" class="hide" style="margin: 20px 0px;">No verified tokens in this wallet...</div>
<template id="token-template">
<div class="item">
<fieldset style="position: relative;">
<legend>
<div id="tokenType"></div>
</legend>
<div id="verified" class="verified hide">
<div class="tooltip">
<img class="verifiedIcon" src="./images/check-circle.svg">
<span class="tooltiptext">Verified</span>
</div>
</div>
<div class="tokenInfo">
<div id="tokenIcon" class="tokenIcon"></div>
<div id="tokenIconModal" class="modal">
<span class="close">×</span>
<img class="modal-content" id="imgTokenIcon" style="width: 400px; max-width: 80%;">
<div id="caption"></div>
</div>
<div class="tokenBaseInfo">
<div class="tokenBaseInfo1">
<div id="tokenName"></div>
<div id="tokenIdBox" style="word-break: break-all;">
TokenId: <span id="tokenID" class="tokenID"></span>
<button type="button" style="background: none; padding: 0; " onclick="copyTokenID(event)">
<img class="copyIcon icon" src="/images/copy.svg">
</button>
</div>
<div id="childNftCommitment" style="word-break: break-all;" class="hide"></div>
</div>
<div class="tokenAmount" id="tokenAmount"></div>
<div class="childNfts" id="childNfts" style=" cursor: pointer;">
<span class="nrChildNfts" id="nrChildNfts"></span>
<span class="hide" id="showMore" style="margin-left: 10px;">
<img id="showIcon" class="icon" style="vertical-align: text-bottom;" src="/images/chevron-square-down.svg">
</span>
</div>
</div>
</div>
<div class="actionBar">
<span style="margin-left: 10px;" class="tokenButton" id="sendButton">
<img id="sendIcon" class="icon" src="/images/send.svg"> send </span>
<span class="tokenButton" id="infoButton">
<img id="infoIcon" class="icon" src="/images/info.svg"> info
</span>
<span class="tokenButton hide" id="mintButton">
<img id="mintIcon" class="icon" src="/images/hammer.svg"> mint NFTs
</span>
<span class="tokenButton hide" style="white-space: nowrap;" id="burnButton">
<img id="burnIcon" class="icon" src="/images/fire.svg">
<span class="hidemobile">burn NFT</span>
<span class="showmobile">burn</span>
</span>
<span class="tokenButton hide" style="white-space: nowrap;" id="authButton">
<img id="authIcon" class="icon" src="/images/shield.svg">
<span class="hidemobile">auth transfer</span>
<span class="showmobile">auth</span>
</span>
<div id="tokenInfoDisplay" class="hide" style="margin-top: 10px;">
<div id="tokenBegin"></div>
<div id="tokenDescription"></div>
<div id="tokenDecimals"></div>
<div id="tokenCommitment"></div>
<div id="tokenWebLink"></div>
<div id="onchainTokenInfo" style="white-space: pre-line;"></div>
<details id="showAttributes" class="hide">
<summary>NFT attributes</summary>
<div id="nftAttributes" style="white-space: pre-wrap;"></div>
</details>
</div>
<div id="tokenSend" class="hide" style="margin-top: 10px;">
Send these tokens to
<p class="inputGroup">
<span class="addressInput"><input id="tokenAddress" placeholder="token address"></span>
<span class="sendAmountGroup">
<span style="width: 100%;" class="input-icon input-icon-right">
<input id="sendTokenAmount" placeholder="amount">
<i id="sendUnit" style="color: black; width: min-content; padding-right: 15px;">tokens</i>
</span>
<button id="maxButton" style="color: black;">max</button>
</span>
</p>
<input type="button" id="sendSomeButton" class="primaryButton" value="Send">
</div>
<div id="nftSend" class="hide" style="margin-top: 10px;">
Send this NFT to
<p class="grouped">
<input id="tokenAddress" placeholder="tokenAddress">
<input type="button" class="primaryButton" id="sendNFT" value="Send NFT">
</p>
</div>
<div id="nftMint" class="hide" style="margin-top: 10px;">
Mint a number of (unique) NFTs to a specific address
<div>
<input type="checkbox" checked id="uniqueNFTs" onchange="disableInputfield(event)" style="margin: 0px; vertical-align: text-bottom;">
make each NFT unique by numbering each one in the collection
</div>
<p class="grouped" style="align-items: center; margin-bottom: 5px;">
<input id="amountNFTs" type="number" placeholder="amount NFTs">
<input id="startingNumberNFTs" type="number" placeholder="starting number" style="margin-right: 0px;">
<input id="commitmentNFTs" placeholder="commitment" style="display: none;">
</p>
<span class="grouped">
<input id="destinationAddr" placeholder="destinationAddress">
<input type="button" id="mintNFTs" value="Mint NFTs">
</span>
</div>
<div id="nftBurn" class="hide" style="margin-top: 10px;">
Burn this NFT so no new NFTs of this category can be minted
<br>
<input type="button" id="burnNFT" value="burn NFT" class="button error">
</div>
<div id="authTransfer" class="hide" style="margin-top: 10px;">
Transfer the authority to change the token's metadata <br>
You can either transfer the Auth to a dedicated wallet or to the <a href="https://cashtokens.studio/" target="_blank">CashTokens Studio</a>.
<div id="authInfoFungible">
Token supply kept at the Auth UTXO will be marked as reserved supply, not yet in circulation. <br>
</div>
<details>
<summary>Managing your Token's Auth</summary>
<p>
With the CashTokens Studio managing your token's Auth is easy for regular users.
The alternative, using a dedicated wallet, is more complex but gives you more control.
For this it's recommended to use Electron Cash on pc to label and freeze the AuthUTXO.
Then, to update metadata on-chain<span id="authInfoReserved"> or manage the reserved supply</span>,
use the <a href="https://github.com/mr-zwets/AuthUpdate" target="_blank">AuthUpdate</a> program.<br>
</p>
</details>
<span class="inputGroup grouped">
<input id="destinationAddr" placeholder="destinationAddress">
<input id="reservedSupply" placeholder="reservedSupply">
<input type="button" id="transferAuth" value="Transfer Auth">
</span>
</div>
</div>
</fieldset>
</div>
</template>
<div id="Placeholder"></div>
</div>
<div id="createTokensView" class="hide">
<fieldset class="item">
<legend>Create new tokens</legend>
<div style="color: red;" id="warningNoBCH" class="hide">Need BCH in wallet to create tokens</div>
<div style="margin-bottom: 1em;">
Planned tokenId:
<span id="plannedTokenId">loading...</span>
<button type="button" style="background: none; padding: 0;" onclick="copyTokenID(event,'plannedTokenId')">
<img class="copyIcon icon" src="/images/copy.svg">
</button>
</div>
<label for="newtokens">Select token-type:</label>
<select name="newtokens" id="newtokens" onchange="selectTokenType(event)">
<option autocomplete="off" selected value="-select-">-select-</option>
<option autocomplete="off" value="fungibles">Fungible Tokens</option>
<option autocomplete="off" value="mintingNFT">Minting NFT</option>
<option autocomplete="off" value="immutableNFT">Immutable NFT</option>
</select>
<br>
<div id="infoTokenTypes">
<b>Fungible Tokens</b> is used to create interchangeable tokens. The total supply of fungible tokens needs to be determined at creation. <br>
<b>Minting NFT</b> is used to create an NFT collection. The minting NFT has the ability to mint new NFTs with the same tokenId. <br>
<b>Immutable NFT</b> is used to create a one-off NFT. There is no option to create more NFTs of the same kind. <br><br>
</div>
<div id="createTokenType" class="hide">
<div style="margin-bottom: 1em;">
Choose the total supply of fungible tokens<br>
<input id="tokenSupply" placeholder="total supply">
If you set decimals in the metadata, take the amount of the smallest unit <br>
<i>(for 100 A-tokens with 2 decimals this means 10,000 units)</i>
</div>
<div class="hide" style="margin-bottom: 1em;">
Add immutable commitment data to add to this NFT (hexadecimals only)
<input id="inputNftCommitment" placeholder="commitment">
</div>
<details style="margin-bottom: 0.5em;">
<summary>Optionally link metadata to this token</summary>
You can add metadata to your Cashtokens using the <a href="https://github.com/bitjson/chip-bcmr" target="_blank">BCMR-standard</a>. <br>
You create a BCMR JSON file either with the <a href="https://bcmr-generator.netlify.app/" target="_blank">BCMR generator</a> form or
with a code-editor by using the <a href="https://github.com/bitjson/chip-bcmr/blob/master/bcmr-v2.schema.ts" target="_blank">BCMR-schema</a>
and the <a href="https://github.com/bitjson/chip-bcmr/tree/master/examples" target="_blank">official examples</a>. <br>
You will need to upload the image(s) for your token and this BCMR file to HTTPS or to IPFS.
The different methods are listed below with more steps for each one. (IPFS recommended) <br><br>
<label for="selectUri">Select which method to use: </label>
<select name="selectUri" id="selectUri" onchange="selectUri(event)">
<option value="select">- select -</option>
<option value="github">HTTPS: github gist</option>
<option value="website">HTTPS: own website</option>
<option value="IPFS">IPFS</option>
</select><br>
<div id="githubInfo" class="hide">
If you have a GitHub account and know how to use git, you can easily host your BCMR on Github Gist, similar to
<a href="https://gist.github.com/mr-zwets/84b0057808af20df392815fb27d4a661" target="_blank">DogeCash</a>. <br>
You can add an icon image to your gist by following <a href="https://gist.github.com/mroderick/1afdd71aa69f6b29601d335751a1a9be" target="_blank">these steps</a>
or to put your icon on IPFS, you can use <a href="https://nft.storage/" target="_blank">nft.storage</a> for a single icon or the <a href="https://nft.storage/docs/how-to/nftup/" target="_blank">NFT UP</a> tool for a folders of images. <br>
Then on Github Gists, press "raw" button and copy the url until <code>/raw</code> in the input field below. <br>
Your BCMR url together with the hash of its content will be stored on the blockchain.
<input id="bcmrUrlGithub" placeholder="gist.githubusercontent.com/mr-zwets/323c7786e2acf01e3c04a440d7cf6c2c/raw">
</div>
<div id="websiteInfo" class="hide">
You can also host the BCMR json file on your own website, the recommended location for it is <code>/.well-known/bitcoin-cash-metadata-registry.json</code>
like <a href="https://otr.cash/.well-known/bitcoin-cash-metadata-registry.json" target="_blank">the OTR registry</a> does. <br>
Using this, you only need to enter the base url 'yourtokenwebsite.com' below. <br>
Your website url together with the hash of the BCMR file will be stored on the blockchain.
<input id="bcmrUrlWebsite" placeholder="yourtokenwebsite.com">
</div>
<div id="ipfsInfo" class="hide">
You can easily upload (pin) your BCMR on IPFS with <a href="https://nft.storage/" target="_blank">nft.storage</a>. <br>
Uploading multiple images grouped together on IPFS can be done with the <a href="https://nft.storage/docs/how-to/nftup/" target="_blank">NFT UP</a> tool. <br>
Enter the IPFS location of your BCMR json file (version 1 CID starting with <code>baf...</code>) below. <br>
The BCMR location together with the hash of its content will be stored on the blockchain.
<input id="bcmrIpfs" placeholder="bafkreiaqpmlrtsdf5cvwgh46mpyric2r44ikqzqgtevny74qdmrjc5dkxy">
</div>
<br>
</details>
<b>Note:</b> Token metadata can still be added/updated later with the token's
<a href="https://github.com/bitjson/chip-bcmr#zeroth-descendant-transaction-chains" target="_blank">AuthUTXO</a>. <br>
This authority to update the metadata (AuthUTXO) should be transferred to a dedicated wallet or to the <a href="https://cashtokens.studio/" target="_blank">CashTokens Studio</a> right after creation.<br><br>
Process might take a few seconds...
<input type="button" class="primaryButton" id="createTokens" value="Create">
</div>
</fieldset>
</div>
<div id="settingsView" class="hide">
<fieldset class="item">
<legend>Settings</legend>
<span style="margin-top: 15px;">Dark mode </span>
<input type="checkbox" class="js-switch js-check-change" id="darkmode">
<div style="margin-top:15px">
<label for="selectUnit">Select default unit:</label>
<select name="selectUnit" id="selectUnit" onchange="selectUnit(event)">
<option value="BCH">BCH</option>
<option value="satoshis">satoshis</option>
</select>
</div>
<div style="margin-top:15px">
<label for="selectNetwork">Change network:</label>
<select name="selectNetwork" id="selectNetwork" onchange="changeNetwork(event)">
<option value="mainnet">mainnet</option>
<option value="chipnet">chipnet</option>
</select>
</div>
<div style="margin-top:15px">Make backup of seed phrase (mnemonic)</div>
<input class="button primary" type="button" style="padding: 1rem 1.5rem; display: block;" value="Show seed phrase" onclick="toggleSeedphrase(event)">
<div id="seedphrase" class="hide"></div><br>
<span style="margin-top:15px">Derivation path of this wallet is</span> <span id="walletDerivationPath"></span>
<div style="margin-top:15px">Remove wallet data from browser</div>
<input type="button" id="burnNFT" value="Delete wallet" class="button error" style="display: block;" onclick="confirmDeleteWallet(event)">
</fieldset>
</div>
<div id="walletConnectView" class="hide">
<fieldset style="display: block; margin-top: 15px;">
<legend>Connect</legend>
<p class="inputGroup">
<span style="width: 100%;" class="addressInput"><input id="wcUri" placeholder="Wallet Connect URI"></span>
</p>
<div style="display: flex; flex-wrap: wrap; justify-content: center; gap: 2rem; margin-bottom: 1rem;">
<input type="button" class="primaryButton" id="connect-button" value="Connect New dApp">
<input type="button" class="primaryButton" id="scan-button" value="Scan QR Code">
</div>
</fieldset>
<!-- WalletConnect -->
<fieldset id="sessions" style="display: block; margin-top: 15px">
<legend>WalletConnect Sessions</legend>
<div id="wc-sessions" style="display: flex; flex-direction: column;">
</div>
</fieldset>
<!-- CashConnect (Vue Container) -->
<div id="cashconnect-sessions-vue">
<!-- Sessions -->
<fieldset style="display: block; margin-top: 15px">
<legend>CashConnect Sessions (Pre-Alpha)</legend>
<div class="cc-session-items-container">
<!-- Iterate over active sessions -->
<template v-for="(session, topic) of sessions" :key="topic">
<div class="cc-session-item">
<div class="cc-session-item-app-icon"><img :src="session.peer.metadata.icons[0]"></div>
<div class="cc-session-item-details-container">
<div>{{ session.peer.metadata.name }}</div>
<div><a href="session.peer.metadata.url" target="_blank">{{ session.peer.metadata.url }}</a></div>
<div>{{ session.peer.metadata.description }}</div>
</div>
<div class="cc-session-item-action-container">
<div class="cc-session-item-action-icon" @click="disconnectSession(topic)"><img class="trashIcon icon"></div>
</div>
</div>
</template>
</div>
</fieldset>
</div>
</div>
<br>
<footer class="footer hide" id="githubLink">
<a href="https://github.com/cashonize/wallet" target="_blank" >
<img class="githublogo" src="./images/github.png" alt="Github logo">
</a>
<div style="margin-left: 10px;height: 60px;">
<a href="https://github.com/cashonize/wallet" target="_blank">
<div>
inspect source code
</div>
</a>
<div>
made with mainnet-js
</div>
</div>
</footer>
</div>
<div id="wc-session-approval-modal" style="top: 0; display: none; position: fixed; align-items: center; justify-content: center; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); z-index: 10; width: 100%; height: 100%; padding: 5rem;">
<fieldset id="wc-session-approval-modal-inner" class="modalClass icon" style="padding: 3rem; width: 100%; max-width: 500px; overflow-y: scroll; height: 250px; background-color: white;">
<legend style="font-size: larger;">Approve Session?</legend>
<div id="wc-session-approval" style="display: flex; flex-direction: column; gap: 1rem;">
</div>
<div style="margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 1rem;">
<input id="session-approve-button" class="button primary" type="button" value="Approve">
<input id="session-reject-button" style="margin-left: 0;" class="button" type="button" value="Reject">
</div>
</fieldset>
</div>
<div id="wc-session-history-modal" style="top: 0; display: none; position: fixed; align-items: center; justify-content: center; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); z-index: 10; width: 100%; height: 100%;">
<fieldset id="wc-session-history-modal-inner" class="modalClass icon" style="width: 100%; max-width: 500px; overflow-y: scroll; max-height: 90vh; background-color: white;">
<legend style="font-size: larger;">Session</legend>
<div style="display: flex; flex-direction: column; gap: 3px">
<div style="display: flex; align-items: center;">
<input type="checkbox" id="session-auto">
<label for="session-auto">Auto-approve requests</label>
</div>
<div style="display: flex; align-items: center;">
<input id="session-auto-requests" type="number" min="1" max="999" placeholder="For N requests" oninput="validity.valid||(value='');">
<span id="session-auto-requests-left" style="width: 77px; text-align: end;">∞ left</span>
</div>
<div style="display: flex; align-items: center;">
<select id="session-auto-minutes">
<option disabled selected value="">For N minutes</option>
<option value="10">10 minutes</option>
<option value="30">30 minutes</option>
<option value="60">60 minutes</option>
</select>
<span id="session-auto-minutes-left" style="width: 77px; text-align: end;">∞m left</span>
</div>
</div>
<fieldset id="history" style="display: block; margin-top: 12px">
<legend>Request History</legend>
<div id="wc-history" style="display: flex; flex-direction: column; gap: 1rem;">
</div>
</fieldset>
</fieldset>
</div>
<div id="wc-session-request-modal-container" style="top: 0; display: none; flex-wrap: wrap-reverse; overflow-y: scroll; gap: 5rem; position: fixed; align-items: center; justify-content: center; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); z-index: 10; width: 100%; height: 100%;">
</div>
<div id="wc-session-scan-modal" style="top: 0; display: none; position: fixed; align-items: center; justify-content: center; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); z-index: 10; width: 100%; height: 100%; padding: 5rem;">
<fieldset id="wc-session-scan-modal-inner" class="modalClass icon" style="padding: 3rem; width: 350px; overflow-y: scroll; background-color: white;">
<legend style="font-size: larger;">Scan QR Code</legend>
<div id="reader"></div>
</fieldset>
</div>
<!-- CashConnect Dialogs -->
<div id="cashconnect-dialogs-vue">
<!-- Session Approval Dialog -->
<div v-if="isSessionApprovalVisible" class="cc-modal">
<!-- Iterate over pending session approval dialogs -->
<template v-for="(request, i) of sessionRequests" :key="request.session.topic">
<fieldset class="cc-modal-fieldset">
<legend style="font-size: larger;">Approve Session?</legend>
<div style="display: flex; flex-direction: column; gap: 1rem;">
<!-- App Info -->
<div style="display: flex; align-items: center; flex-direction: row; gap: 10px; padding: 7px;">
<!-- App Icon -->
<div style="display: flex; align-items: center; height: 64px; width: 64px;">
<img :src="request.session.params.proposer.metadata.icons[0]">
</div>
<!-- Metadata -->
<div style="display: flex; flex-direction: column; width: 100%;">
<div>{{ request.session.params.proposer.metadata.name }}</div>
<div><a :href="request.session.params.proposer.metadata.url" target="_blank">{{ request.session.params.proposer.metadata.url }}</a></div>
<div>{{ request.session.params.proposer.metadata.description }}</div>
</div>
</div>
<!-- Namespaces -->
<div class="cc-modal-details">
<!-- Template -->
<div class="cc-modal-section">
<div class="cc-modal-heading">Template</div>
<a @click="viewTemplate(request.session.params.requiredNamespaces?.bch?.template)">{{ request.session.params.requiredNamespaces?.bch?.template.name }}</a> (Untrusted)
</div>
<!-- Methods -->
<div class="cc-modal-section">
<div class="cc-modal-heading">Methods/Events</div>
<ul>
<li v-for="method of request.session.params.requiredNamespaces?.bch?.methods">{{ method }}</li>
<li v-for="event of request.session.params.requiredNamespaces?.bch?.events">{{ event }}</li>
</ul>
</div>
<!-- Allowed Tokens -->
<div class="cc-modal-section">
<div class="cc-modal-heading">Allowed Tokens</div>
<ul>
<li v-for="allowedToken of request.session.params.requiredNamespaces?.bch?.allowedTokens">{{ allowedToken }}</li>
</ul>
</div>
</div>
</div>
<!-- Approve/Reject Buttons -->
<div class="cc-modal-bottom-buttons">
<input class="button primary" type="button" value="Approve" @click="request.accept()">
<input class="button" type="button" value="Reject" @click="request.reject()">
</div>
</fieldset>
</template>
</div>
<!-- End Session Approval Dialog -->
<!-- Request Approval Dialog -->
<div v-if="isRequestApprovalVisible" class="cc-modal">
<!-- Iterate over our session requests and display them. -->
<template v-for="({ method, session, params, response, modalId, accept, reject}, i) of rpcRequests" :key="i">
<!-- bch_signTransaction_V0 -->
<template v-if="method === 'bch_signTransaction_V0'">
<fieldset class="cc-modal-fieldset">
<legend class="cc-modal-fieldset-legend">Sign Transaction</legend>
<!-- Origin -->
<div style="font-size: large; margin-top: 2rem;">Origin:</div>
<div style="display: flex; align-items: center; flex-direction: row; gap: 10px; padding: 7px;">
<div style="display: flex; align-items: center; height: 64px; width: 64px;"><img :src="session.peer.metadata.icons[0]"></div>
<div style="display: flex; flex-direction: column; width: 100%;">
<div>{{ session.peer.metadata.name }}</div>
<div style="overflow-wrap: anywhere;"><a :href="session.peer.metadata.url" target="_blank">{{ session.peer.metadata.url }}</a></div>
<div style="overflow-x: hidden; text-overflow: ellipsis; font-size: smaller;">{{ formatSessionSigner(session) }}</div>
</div>
</div>
<hr style="margin-top:3rem" />
<div v-for="(tx, i) of params" class="cc-modal-details">
<!-- User Prompt -->
<div v-if="tx.userPrompt" style="display: flex; justify-content: center; font-size: larger;">{{ tx.userPrompt }}</div>
<!-- Inputs -->
<div class="cc-modal-heading">Inputs</div>
<table class="cc-data-table">
<tbody v-for="(input, index) of response[i].transaction.inputs">
<tr>
<td>{{ index }}</td>
<td>{{ formatBin(input.outpointTransactionHash) }}:{{ input.outpointIndex }}</td>
<td class="satoshis">
{{ formatSats(response[i].sourceOutputs[index].valueSatoshis) }}
</td>
</tr>
<!-- If there is data available for this input -->
<tr v-if="tx.transaction.inputs?.[index]?.data">
<td colspan="3">
<table class="tx-data-table">
<tbody>
<tr>
<td colspan="2">
<strong>{{ formatScriptName(tx.transaction.inputs[index].script, session.requiredNamespaces.bch.template) }}</strong>
</td>
</tr>
<tr v-for="(value, id) of tx.transaction.inputs?.[index]?.data">
<td>{{ formatDataName(id, session.requiredNamespaces.bch.template) }}</td>
<td>{{ formatDataValue(value, id, session.requiredNamespaces.bch.template) }}</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!-- Outputs -->
<div class="cc-modal-heading">Outputs</div>
<table class="cc-data-table">
<tbody v-for="(output, index) of response[i].transaction.outputs">
<tr>
<td>{{ index }}</td>
<td>{{ formatLockscript(output.lockingBytecode) }}</td>
<td class="satoshis">{{ formatSats(output.valueSatoshis) }}</td>
</tr>
<!-- If there is a token available on this output -->
<tr v-if="output.token">
<td colspan="3">
<table class="tx-data-table">
<tbody>
<tr>
<td>
Token: {{ formatBin(output.token.category) }}
</td>
<td>
Amount: {{ Number(output.token.amount) }}
</td>
</tr>
<tr v-if="output.token?.nft">
<td>Commitment: {{ formatBin(output.token.nft.commitment) }}</td>
<td>Capability: {{ output.token.nft.capability }}</td>
</tr>
</tbody>
</table>
</td>
</tr>
<!-- If there is data available for this output -->
<tr v-if="tx.transaction.outputs?.[index]?.data">
<td colspan="3">
<table class="tx-data-table">
<tbody>
<tr>
<td colspan="2">
<strong>{{ formatScriptName(tx.transaction.outputs[index].script, session.requiredNamespaces.bch.template) }}</strong>
</td>
</tr>
<tr v-for="(value, id) of tx.transaction.outputs?.[index]?.data">
<td>{{ formatDataName(id, session.requiredNamespaces.bch.template) }}</td>
<td>{{ formatDataValue(value, id, session.requiredNamespaces.bch.template) }}</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<hr style="margin-top: 3rem;" />
</div>
<!-- Bottom Buttons -->
<div class="cc-modal-bottom-buttons">
<input class="button primary" type="button" value="Sign" @click="accept(modalId)">
<input class="button" type="button" value="Cancel" @click="reject(modalId)">
</div>
</fieldset>
</template>
<!-- End bch_signTransaction_V0 -->
<!-- Unhandled Method -->
<template v-else>
<fieldset class="cc-modal-fieldset">
<legend class="cc-modal-fieldset-legend">{{ method }}</legend>
<div>Params:</div>
<pre class="cc-pre">{{ params }}</pre>
<div>Response:</div>
<pre class="cc-pre">{{ response }}</pre>
<!-- Bottom Buttons -->
<div class="cc-modal-bottom-buttons">
<input class="button primary" type="button" value="Sign" @click="accept(modalId)">
<input class="button" type="button" value="Cancel" @click="reject(modalId)">
</div>
</fieldset>
</template>
<!-- End Unhandled Method -->
</template>
</div>
<!-- End Request Approval Dialog -->
<!-- Error Dialog -->
<template v-for="({ error, modalId, accept, reject}, i) of errors" :key="i">
<div v-if="isErrorsVisible" class="cc-modal">
<fieldset class="cc-modal-fieldset" style="width:1024px">
<legend class="cc-modal-fieldset-legend">Error</legend>
<div v-if="error.message">{{ error.message }}</div>
<template v-if="error.stackTrace">
<div>Stack Trace:</div>
<pre class="cc-pre">{{ error.stackTrace }}</pre>
</template>
<!-- Bottom Buttons -->
<div class="cc-modal-bottom-buttons">
<input class="button primary" type="button" value="Close" @click="accept(modalId)">
</div>
</fieldset>
</div>
</template>
<!-- End Error Dialog -->
</div>
<!-- End CashConnect Dialogs -->
</main>
<script type="module" src="./script.js"></script>
<script type="module" src="./cash-connect.js"></script>
<script type="module" src="./wallet-connect.js"></script>
<script type="module" src="./queryChainGraph.js"></script>
<script>
document.getElementById('qr1').addEventListener('codeRendered', () => {
document.getElementById('qr1').animateQRCode('MaterializeIn');
});
</script>
</body>
</html>