Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
wuminzhe committed Nov 15, 2023
1 parent be18dfa commit b267d51
Show file tree
Hide file tree
Showing 3 changed files with 642 additions and 0 deletions.
55 changes: 55 additions & 0 deletions public/abi.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<title>ABI Encode/Decode</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/browser.script.iife.js"></script>
<script type="text/ruby" src="./abi.rb"></script>
<script type="text/ruby">
require "js"
require "json"
module ABI
extend AbiCoderRb
end

document = JS.global[:document]
search_button = document.getElementById "btnEncode"
search_button.addEventListener "click" do
types = JSON.parse(document.getElementById("types")[:value].to_s)
values = JSON.parse(document.getElementById("values")[:value].to_s)
result = ABI.encode(types, values)
document.getElementById("result")[:innerHTML] = ABI.bin_to_hex(result)
end
</script>

<style type="text/css">
* {
box-sizing: border-box;
}
pre {
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
</style>
</head>
<body>
<form>
<p>
<div>types: </div>
<input type="text" id="types" name="types" value="[&quot;uint256&quot;, &quot;(uint256,string)&quot;]" style="width: 100%"></input>

</p>
<p>
<div>values: </div>
<input type="text" id="values" name="values" value="[1234, [1234, &quot;Hello World&quot;]]" style="width: 100%">
</p>
<p>
<button type="button" id="btnEncode">encode</button>
</p>
</form>
<pre style="width: 100%;" id="result"></pre>

</body>
</html>
Loading

0 comments on commit b267d51

Please sign in to comment.