Skip to content

Commit 7ccd88d

Browse files
authored
Users/richard/724 hex converter (#725)
* 724: Import bech32 <-> hex standalone converter * Obligatory combat with trunk
1 parent 0dd7176 commit 7ccd88d

File tree

8 files changed

+2670
-0
lines changed

8 files changed

+2670
-0
lines changed

.trunk/trunk.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ lint:
3838
paths:
3939
- contracts/audited/burn_zrc2 # eslint barfs on an internal error if you enable it on this directory.
4040
- contracts/reward_control # and again
41+
- products/bech32-hex-converter # eslint chokes.
4142
- linters: [ALL]
4243
paths:
4344
- products/airdrop/**
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*~
2+
\#*
3+
.\#*
4+
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# zil <-> hex format converter
2+
3+
This is a quick demo of an in-browser Bech32 (`zil1...`) to hex (and back) converter.
4+
5+
Run the web server of your choice on the documents in `content/` and point your browser at `index.html`.
6+
7+
If you want server-side, just grab `content/js/chain.js` and use it (`buffer.js` is just a polyfill for node-js `buffer`).
8+
9+
If you are on Linux:
10+
11+
```sh
12+
docker compose up
13+
```
14+
15+
Should get you a copy of nginx on port 3000 which serves the content.
16+
17+
If you have problems please contact your Zilliqa support contact, or [[email protected]](mailto:[email protected]).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<html>
2+
<head>
3+
<title>Sample bech32 <-> hex converter</title>
4+
<script type="text/javascript" src="js/chain.js"></script>
5+
<script type="text/javascript" src="js/buffer.js"></script>
6+
<link rel="stylesheet" href="trivial.css" />
7+
</head>
8+
<body>
9+
<h1>Zil <-> 0x converter</h1>
10+
11+
<p>
12+
Type a `zil1...` or a hex (`0x..`) address into the box below and hit the
13+
convert button to convert to the other format.
14+
</p>
15+
<p>The copy button copies the current contents of the typein</p>
16+
17+
<p>
18+
<tt>js/chain.js</tt> contains the converter code; buttons are registered
19+
using <tt>addEventListener</tt> for purely historical reasons
20+
</p>
21+
<p>
22+
<tt>js/buffer.js</tt> is just a browser-based node polyfill used so we can
23+
use the same code for node and in browser.
24+
</p>
25+
26+
<p>
27+
Some example inputs and outputs - more at
28+
<a href="https://devex.zilliqa.com/">https://devex.zilliqa.com/</a> :
29+
</p>
30+
<div class="example">
31+
0x7bb3b0e8a59f3f61d9bff038f4aeb42cae2ecce8 <->
32+
zil10wemp699nulkrkdl7qu0ft459jhzan8g6r5lh7
33+
</div>
34+
<div class="example">
35+
a198b865e36612e365705b393f2acea37a23d919 <->
36+
zil15xvtse0rvcfwxetstvun72kw5daz8kge0frn3y
37+
</div>
38+
<div class="example">
39+
18a762b2697c0e863f49808bc56036371a3b8272 <->
40+
zil1rznk9vnf0s8gv06fsz9u2cpkxudrhqnjq8les4
41+
</div>
42+
<div>&nbsp;</div>
43+
<input id="address" size="50" />
44+
<button class="hexconverter" style="width: 4em">
45+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
46+
<!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
47+
<path
48+
d="M272 416c17.7 0 32-14.3 32-32s-14.3-32-32-32l-112 0c-17.7 0-32-14.3-32-32l0-128 32 0c12.9 0 24.6-7.8 29.6-19.8s2.2-25.7-6.9-34.9l-64-64c-12.5-12.5-32.8-12.5-45.3 0l-64 64c-9.2 9.2-11.9 22.9-6.9 34.9s16.6 19.8 29.6 19.8l32 0 0 128c0 53 43 96 96 96l112 0zM304 96c-17.7 0-32 14.3-32 32s14.3 32 32 32l112 0c17.7 0 32 14.3 32 32l0 128-32 0c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l64 64c12.5 12.5 32.8 12.5 45.3 0l64-64c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8l-32 0 0-128c0-53-43-96-96-96L304 96z"
49+
/>
50+
</svg>
51+
</button>
52+
<button class="hexcopy" style="width: 4em">
53+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
54+
<!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
55+
<path
56+
d="M208 0L332.1 0c12.7 0 24.9 5.1 33.9 14.1l67.9 67.9c9 9 14.1 21.2 14.1 33.9L448 336c0 26.5-21.5 48-48 48l-192 0c-26.5 0-48-21.5-48-48l0-288c0-26.5 21.5-48 48-48zM48 128l80 0 0 64-64 0 0 256 192 0 0-32 64 0 0 48c0 26.5-21.5 48-48 48L48 512c-26.5 0-48-21.5-48-48L0 176c0-26.5 21.5-48 48-48z"
57+
/>
58+
</svg>
59+
</button>
60+
</body>
61+
<p class="warning">
62+
WARNING! This code just converts address presentation formats. It will not
63+
help you send a transaction for a Zilliqa wallet to an EVM contract, or vice
64+
versa. If you have questions about this, please contact your Zilliqa support
65+
contact or <a href="mailto:[email protected]">[email protected]</a> .
66+
</p>
67+
</html>

0 commit comments

Comments
 (0)