Skip to content

Commit 563e0ce

Browse files
committed
init lightning-verifier
1 parent c0e8d3b commit 563e0ce

File tree

149 files changed

+27991
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+27991
-0
lines changed

ghcjs/lightning-verifier/.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use nix

ghcjs/lightning-verifier/.ghcid

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--restart=.ghcid
2+
--restart=app.cabal
3+
--restart=cabal.config
4+
--restart=cabal.project
5+
--restart=static
6+
--restart=README.md
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.direnv
2+
result
3+
dist-newstyle
4+
node_modules
5+
dist
6+
android
7+
capacitor-geckoview/capacitor/build

ghcjs/lightning-verifier/.ignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.stack-work
2+
dist-newstyle
3+
capacitor-geckoview
4+
package-lock.json
5+
*\.min\.*

ghcjs/lightning-verifier/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
Copyright (c) 2024 Functora
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21+
OR OTHER DEALINGS IN THE SOFTWARE.
22+

ghcjs/lightning-verifier/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## Sample Miso-JSaddle application
2+
3+
4+
It's possible to build miso applications with `ghcid`, `miso` and `jsaddle`. This can enable a faster workflow due to hot reloading of the code.
5+
6+
This application (sample-app-jsaddle) serves as an example of development w/ GHC, and releases with GHCJS.
7+
8+
To take advantage of the hot reload code features, we recommend running the following command (see below) in a shell. (This will invoke `ghcid` for you).
9+
10+
## Dev
11+
```bash
12+
nix-shell --run reload
13+
```
14+
15+
You should now be able to open your browser to `http://localhost:8080` and see your working application. Subsequent edits of the code should cause a live update of the website at that address.
16+
17+
To build the application w/ GHCJS, execute the below command.
18+
19+
## Build w/ GHCJS
20+
```bash
21+
nix-build -A release
22+
```
23+
24+
## Dev with `stack`
25+
26+
In order to build `miso` w/ `jsaddle` support, it is necessary to remove the existing `miso` package first.
27+
28+
```bash
29+
stack exec -- ghc-pkg unregister --force miso
30+
```
31+
32+
Enable the `jsaddle` flag by adding the following to your project's `package.yaml` file, then call `stack build`.
33+
34+
```yaml
35+
flags:
36+
miso:
37+
jsaddle: true
38+
```
39+
40+
## Add external javascript file
41+
42+
First download the external javascript file (`your-file.js`) to your project directory.
43+
Then add `bytestring` to `build-depends` in `app.cabal`.
44+
In your `Main.hs` you need to change the implementation of `runApp` from this:
45+
```
46+
runApp f =
47+
Warp.runSettings (Warp.setPort 8080 (Warp.setTimeout 3600 Warp.defaultSettings)) =<<
48+
JSaddle.jsaddleOr defaultConnectionOptions (f >> syncPoint) JSaddle.jsaddleApp
49+
```
50+
to this:
51+
```
52+
runApp f = do
53+
bString <- B.readFile "your-file.js"
54+
jSaddle <- JSaddle.jsaddleOr defaultConnectionOptions (f >> syncPoint) (JSaddle.jsaddleAppWithJs (B.append (JSaddle.jsaddleJs False) bString))
55+
Warp.runSettings (Warp.setPort 8081 (Warp.setTimeout 3600 Warp.defaultSettings)) jSaddle
56+
```
57+
Now you should be able to use `your-file.js` in jsaddle.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
with (import ./default.nix); let
2+
pkgs = android-pkgs;
3+
repo = toString ./.;
4+
geckoview = false;
5+
android-sdk =
6+
(pkgs.androidenv.composeAndroidPackages android-sdk-args).androidsdk;
7+
app-keygen-android = pkgs.writeShellApplication {
8+
name = "app-keygen-android";
9+
text = ''
10+
if [ ! -f ~/keys/app-key.jks ]; then
11+
mkdir -p ~/keys
12+
${pkgs.zulu}/bin/keytool -genkey -v \
13+
-keystore ~/keys/app-key.jks \
14+
-keyalg RSA \
15+
-keysize 2048 \
16+
-validity 10000 \
17+
-alias app-key
18+
fi
19+
'';
20+
};
21+
app-sign-apk = pkgs.writeShellApplication {
22+
name = "app-sign-apk";
23+
text = ''
24+
${pkgs.apksigner}/bin/apksigner sign \
25+
--ks ~/keys/app-key.jks \
26+
--out ${repo}/android/app.apk \
27+
${repo}/android/app/build/outputs/apk/release/app-release-unsigned.apk
28+
'';
29+
};
30+
app-sign-aab = pkgs.writeShellApplication {
31+
name = "app-sign-aab";
32+
text = ''
33+
${pkgs.zulu}/bin/jarsigner \
34+
-verbose \
35+
-keystore ~/keys/app-key.jks \
36+
-signedjar ${repo}/android/app.aab \
37+
${repo}/android/app/build/outputs/bundle/release/app-release.aab \
38+
app-key
39+
'';
40+
};
41+
app-prepare-android = pkgs.writeShellApplication rec {
42+
name = "app-prepare-android";
43+
text = ''
44+
(
45+
cd ${repo}
46+
${pkgs.nodejs}/bin/npm i
47+
${pkgs.nodejs}/bin/npm run build
48+
${pkgs.nodejs}/bin/npx cap add android || true
49+
${pkgs.nodejs}/bin/npx cap sync
50+
cp ${repo}/static/android-chrome-512x512.png ${repo}/static/logo.png
51+
${pkgs.nodejs}/bin/npx @capacitor/assets generate \
52+
--android --assetPath static
53+
${pkgs.nodejs}/bin/npx trapeze run trapeze.yaml -y \
54+
--android-project android
55+
${
56+
if geckoview
57+
then ''printf "include ':capacitor-android'\nproject(':capacitor-android').projectDir = new File('../capacitor-geckoview/capacitor')" > ./android/capacitor.settings.gradle''
58+
else ""
59+
}
60+
)
61+
'';
62+
};
63+
app-release-apk = pkgs.writeShellApplication rec {
64+
name = "app-release-apk";
65+
text = ''
66+
(
67+
cd ${repo}
68+
${app-prepare-android}/bin/app-prepare-android
69+
cd ./android
70+
./gradlew assembleRelease
71+
${app-keygen-android}/bin/app-keygen-android
72+
rm ${repo}/android/app.apk || true
73+
${app-sign-apk}/bin/app-sign-apk
74+
ls -la ${repo}/android/app.apk
75+
)
76+
'';
77+
};
78+
app-release-aab = pkgs.writeShellApplication rec {
79+
name = "app-release-aab";
80+
text = ''
81+
(
82+
cd ${repo}
83+
${app-prepare-android}/bin/app-prepare-android
84+
cd ./android
85+
./gradlew bundleRelease
86+
${app-keygen-android}/bin/app-keygen-android
87+
rm ${repo}/android/app.aab || true
88+
${app-sign-aab}/bin/app-sign-aab
89+
ls -la ${repo}/android/app.aab
90+
)
91+
'';
92+
};
93+
in
94+
pkgs.mkShell rec {
95+
buildInputs = with pkgs; [
96+
alejandra
97+
android-sdk
98+
glibc
99+
jdk
100+
zulu
101+
nodejs
102+
app-release-apk
103+
app-release-aab
104+
];
105+
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${android-sdk}/libexec/android-sdk/build-tools/34.0.0/aapt2";
106+
ANDROID_SDK_ROOT = "${android-sdk}/libexec/android-sdk";
107+
ANDROID_NDK_ROOT = "${ANDROID_SDK_ROOT}/ndk-bundle";
108+
}

ghcjs/lightning-verifier/app.cabal

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
cabal-version: 2.2
2+
name: app
3+
version: 0.1.0.9
4+
synopsis: First miso app
5+
category: Web
6+
build-type: Simple
7+
8+
flag ghcid
9+
manual: True
10+
default: False
11+
12+
common pkg
13+
other-modules: Paths_app
14+
autogen-modules: Paths_app
15+
default-language: Haskell2010
16+
hs-source-dirs: src
17+
18+
if impl(ghcjs)
19+
js-sources: static/app.js
20+
21+
else
22+
js-sources:
23+
static/app.js
24+
static/hashable.js
25+
static/material-components-web.min.js
26+
27+
other-modules:
28+
App.Misc
29+
App.Types
30+
App.Widgets.Decrypt
31+
App.Widgets.Fav
32+
App.Widgets.Header
33+
App.Widgets.Main
34+
App.Widgets.Menu
35+
App.Widgets.SwapAmounts
36+
App.Widgets.SwapCurrencies
37+
App.Widgets.Templates
38+
39+
ghc-options:
40+
-Werror -Weverything -Wno-all-missed-specialisations
41+
-Wno-missed-specialisations -Wno-missing-exported-signatures
42+
-Wno-missing-import-lists -Wno-missing-local-signatures -Wno-safe
43+
-Wno-unsafe -fprint-potential-instances -fwarn-tabs
44+
45+
if impl(ghc >=8.10.7)
46+
ghc-options:
47+
-Wno-prepositive-qualified-module -Wno-missing-safe-haskell-mode
48+
49+
if impl(ghc >8.10.7)
50+
ghc-options: -Wno-missing-kind-signatures
51+
52+
if impl(ghc >=9.8)
53+
ghc-options: -Wno-missing-role-annotations
54+
55+
cpp-options: -Wno-trigraphs
56+
default-extensions:
57+
AllowAmbiguousTypes
58+
ConstraintKinds
59+
DataKinds
60+
DefaultSignatures
61+
DeriveDataTypeable
62+
DeriveFunctor
63+
DeriveGeneric
64+
DeriveLift
65+
DerivingStrategies
66+
DerivingVia
67+
EmptyCase
68+
ExistentialQuantification
69+
FlexibleContexts
70+
FlexibleInstances
71+
FunctionalDependencies
72+
GADTs
73+
GeneralizedNewtypeDeriving
74+
InstanceSigs
75+
KindSignatures
76+
LambdaCase
77+
MultiParamTypeClasses
78+
MultiWayIf
79+
NoImplicitPrelude
80+
NumericUnderscores
81+
OverloadedLabels
82+
OverloadedLists
83+
OverloadedStrings
84+
PackageImports
85+
PolyKinds
86+
QuantifiedConstraints
87+
QuasiQuotes
88+
RankNTypes
89+
ScopedTypeVariables
90+
StandaloneDeriving
91+
StrictData
92+
TupleSections
93+
TypeApplications
94+
TypeFamilies
95+
TypeOperators
96+
97+
build-depends:
98+
, async
99+
, barbies
100+
, base
101+
, base64-bytestring
102+
, binary
103+
, bytestring
104+
, containers
105+
, functora-ghcjs
106+
, fuzzy
107+
, jsaddle
108+
, miso
109+
, miso-components
110+
, miso-widgets
111+
, modern-uri
112+
, network-uri
113+
, qrcode-core
114+
, random
115+
, syb
116+
, text
117+
, uglymemo
118+
119+
if os(wasi)
120+
build-depends: jsaddle-wasm
121+
ghc-options:
122+
-no-hs-main -optl-mexec-model=reactor "-optl-Wl,--export=hs_start"
123+
124+
executable app
125+
import: pkg
126+
main-is: Main.hs
127+
ghcjs-options: -dedupe
128+
build-depends: containers
129+
130+
if !((impl(ghcjs) || arch(javascript)) || os(wasi))
131+
build-depends:
132+
, jsaddle-warp
133+
, wai
134+
, wai-app-static
135+
, warp
136+
, websockets
137+
138+
if impl(ghcjs)
139+
ghc-options: -Wno-missing-home-modules
140+
cpp-options: -DGHCJS_BROWSER
141+
142+
if !flag(ghcid)
143+
ghc-options: -O2 -optc-O3 -funfolding-use-threshold=16
144+
145+
if (!flag(ghcid) && !os(wasi))
146+
ghc-options: -threaded -rtsopts -with-rtsopts=-N
147+
148+
if flag(ghcid)
149+
cpp-options: -DGHCID
150+
151+
if (flag(ghcid) && impl(ghc >=8.10.7))
152+
ghc-options: -Wno-unused-packages
153+
154+
test-suite app-test
155+
import: pkg
156+
type: exitcode-stdio-1.0
157+
main-is: Spec.hs
158+
hs-source-dirs: test
159+
other-modules: App.TypesSpec
160+
build-depends:
161+
, aeson
162+
, hspec
163+
, optics-core
164+
, quickcheck-instances

0 commit comments

Comments
 (0)