Skip to content

Commit

Permalink
upgrade: update from cryptogarageinc/v0.3.8 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
ko-matsu authored Sep 27, 2021
1 parent cb97b59 commit e597926
Show file tree
Hide file tree
Showing 36 changed files with 1,999 additions and 275 deletions.
29 changes: 11 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
FROM ubuntu:20.04 as cfd_wasm_base
FROM ghcr.io/cryptogarageinc/elements-testing:v0.1.0 as cfd_wasm_base

ARG EMSDK_VERSION=2.0.12
ARG NODE_VERSION=12.18.1
ARG NODE_VERSION=14.15.5

# install tzdata before git
RUN apt-get update && apt-get install -y tzdata
ENV TZ=Asia/Tokyo

RUN apt-get install -y \
gpg \
wget \
RUN apt-get update && apt-get install -y \
csh \
cmake \
clang \
clang-format \
python \
nodejs \
npm \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir /emscripten && chmod 777 /emscripten
RUN mkdir /emscripten && chmod 777 /emscripten && \
n $NODE_VERSION

WORKDIR /emscripten
RUN npm install -g npm n && \
n $NODE_VERSION

RUN git clone https://github.com/emscripten-core/emsdk.git && \
cd /emscripten/emsdk && \
Expand All @@ -33,17 +26,17 @@ RUN git clone https://github.com/emscripten-core/emsdk.git && \

FROM cfd_wasm_base as cfd_wasm_builder

ENV PATH /usr/local/bin:/emscripten/emsdk:/emscripten/emsdk/upstream/emscripten:/emscripten/emsdk/node/12.18.1_64bit/bin:$PATH
ENV PATH /usr/local/bin:/emscripten/emsdk:/emscripten/emsdk/upstream/emscripten:/emscripten/emsdk/node/$NODE_VERSION_64bit/bin:$PATH
ENV EMSDK /emscripten/emsdk
ENV EM_CONFIG /emscripten/emsdk/.emscripten
ENV EM_CACHE /emscripten/emsdk/upstream/emscripten/cache
ENV EMSDK_NODE /emscripten/emsdk/node/12.18.1_64bit/bin/node
ENV EMSDK_NODE /emscripten/emsdk/node/$NODE_VERSION_64bit/bin/node

WORKDIR /emscripten

RUN chmod 755 /emscripten/emsdk/emsdk_env.sh && chmod 755 /emscripten/emsdk

RUN node --version && cmake --version && clang --version && em++ --version && env
RUN chmod 755 /emscripten/emsdk/emsdk_env.sh && \
chmod 755 /emscripten/emsdk && \
node --version && cmake --version && clang --version && em++ --version && env

# RUN /emscripten/emsdk/emsdk_env.sh

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ Copy cfdjs_wasm_jsonapi.js if necessary.

Add github's cfd-js-wasm path on caller app's package.json:
```
"cfd-js-wasm": "github:p2pderivatives/cfd-js-wasm#semver:^0.3.0",
"cfd-js-wasm": "github:p2pderivatives/cfd-js-wasm#semver:^0.3.2",
```

If you use old npm or yarn, describe as follows:
```
"cfd-js-wasm": "git+https://github.com/p2pderivatives/cfd-js-wasm#semver:^0.3.0",
"cfd-js-wasm": "git+https://github.com/p2pderivatives/cfd-js-wasm#semver:^0.3.2",
```

---
Expand Down
11 changes: 11 additions & 0 deletions cmake/Cpp11Setting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ if(${USE_EMSCRIPTEN})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0")
endif()

if(${STD_CPP_VERSION})
set(CMAKE_CXX_STANDARD ${STD_CPP_VERSION})
message(STATUS "[STD_CPP_VERSION] ${STD_CPP_VERSION}")
if(${STD_CPP_VERSION} STREQUAL "11")
set(ENABLE_LOGGING FALSE)
else()
set(ENABLE_LOGGING TRUE)
endif()
else()
set(CMAKE_CXX_STANDARD 11)
set(ENABLE_LOGGING FALSE)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
2 changes: 1 addition & 1 deletion dist/cfdjs_wasm.js

Large diffs are not rendered by default.

Binary file modified dist/cfdjs_wasm.wasm
Binary file not shown.
16 changes: 15 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.5'
version: '3.8'

services:
wasm-build:
Expand All @@ -15,3 +15,17 @@ services:
- /private/work
- .:/private/cfd-js-wasm
entrypoint: /private/cfd-js-wasm/tools/build_for_release.sh

wasm-test:
image: ghcr.io/cryptogarageinc/elements-testing:v0.1.0
volumes:
- ./:/workspace
working_dir: /workspace
command: /bin/bash -c "npm install && npm run test_example"

wasm-update-package-lock:
image: ghcr.io/cryptogarageinc/elements-testing:v0.1.0
volumes:
- ./:/workspace
working_dir: /workspace
command: /bin/bash -c "./tools/update_package.sh"
121 changes: 121 additions & 0 deletions example/createtx.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Create Raw Transaction</title>
<style>
#main {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 120vh;
font-family: sans-serif;
}
.decoderawtxInput {
width: 99%;
}
.input {
width: 99%;
}
.createOutput {
width: 99%;
}
.create-output {
vertical-align: top;
margin-top: 13px;
}
h1 {
font-size: 32px;
}
h2 {
font-size: 20px;
font-weight: bold;
}
h3 {
font-size: 16px;
margin-bottom: 0px;
padding-bottom: 0px;
}
.xpubkey-label {
font-size: 12px;
display: inline-block;
width: 8em;
}
</style>
</head>
<body>
<div class="decode">
<h3 class="decode-title">Create Raw Transaction</h3>
<div class="decode-input">
<div>
network: <select name="network" id="network">
<option value="mainnet">mainnet</option>
<option value="testnet">testnet</option>
<option value="regtest">regtest</option>
<option value="liquidv1">liquidv1</option>
<option value="elementsregtest">elementsRegTest</option>
</select><br>
<input type="checkbox" name="blind" id="blind" value="1" /> Blind (Elements Only) <br>

<hr>
<div class="tx-header">
tx version: <input type="number" name="version" id="version" value="2" min="0" max="2147483647" step="1" /><br>
lock time: <input type="number" name="locktime" id="locktime" value="0" min="0" max="4294967295" step="1" /><br>
</div>

<hr>
<div>
Vin: <input type="button" name="addInput" id="addInput" value="Add" />
<ol class="tx-input" id="tx-input">
<li>
txid:<br>
<textarea rows="1" name="txid1" id="txid1" class="input"></textarea><br>
vout: <input type="number" name="vout1" id="vout1" value="0" min="0" max="536870911" step="1" /><br>
sequence number: <input type="number" name="sequence1" id="sequence1" value="4294967295" min="0" max="4294967295" step="1" /><br>
amount: <input type="number" name="amount1" id="amount1" value="0" min="0" max="2100000000000000" step="1" /><br>
<div id="elementsInput1" style="display:none">
asset:<br>
<textarea rows="1" name="asset1" id="asset1" class="input"></textarea><br>
amount blinder:<br>
<textarea rows="1" name="vbf1" id="vbf1" class="input"></textarea><br>
asset blinder:<br>
<textarea rows="1" name="abf1" id="abf1" class="input"></textarea><br>
</div>
</ol>
</div>

<hr>
<div>
Vout: <input type="button" name="addOutput" id="addOutput" value="Add" />
<ol class="tx-output" id="tx-output">
<li>
address:<br>
<textarea rows="2" name="out_address1" id="out_address1" class="input"></textarea><br>
amount: <input type="number" name="out_amount1" id="out_amount1" value="0" min="0" max="2100000000000000" step="1" /><br>
<div id="elementsOutput1" style="display:none">
asset:<br>
<textarea rows="1" name="out_asset1" id="out_asset1" class="input"></textarea><br>
nonce:<br>
<textarea rows="1" name="out_nonce1" id="out_nonce1" class="input"></textarea><br>
</div>
(locking script):<br>
<textarea rows="1" name="out_script1" id="out_script1" class="input"></textarea><br>
</ol>
</div>
<hr>
<input type="button" name="create" id="execCreate" value="Create" />
</div>
<div class="create-output">
<div class="create-label">Result:</div>
<textarea rows="7" id="created" class="createOutput" readonly></textarea>
</div>
</div>
</div>

<script src="/cfd-js-wasm/dist/cfdjs_wasm.js"></script>
<script src="/cfd-js-wasm/cfdjs_wasm_jsonapi.js"></script>
<script src="createtx.js"></script>
<p><a href="index.html">back</a></p>
</body>
</html>
Loading

0 comments on commit e597926

Please sign in to comment.