Skip to content

Removed ghcjs specific code #736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dep/juicy.pixels.ghcjs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
7 changes: 7 additions & 0 deletions dep/juicy.pixels.ghcjs/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"owner": "obsidiansystems",
"repo": "juicy.pixels.ghcjs",
"private": false,
"rev": "a1c516493c674dba64e8eadb8a65b829477f302d",
"sha256": "06dm7kw5p1df0j0mf2wp9yyqxxzx9lih1y3l2ym8dcl1cklrnx57"
}
9 changes: 9 additions & 0 deletions dep/juicy.pixels.ghcjs/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
2 changes: 2 additions & 0 deletions dep/qrcode/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions dep/qrcode/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "obsidiansystems",
"repo": "qrcode",
"branch": "master",
"private": false,
"rev": "f33abef0451982ae7769b24e9031753ef2c4d826",
"sha256": "044bi6fnrzpzam0zyd6yijpkphjnn3z751nnxb3zz2w93wzi6nkd"
}
9 changes: 9 additions & 0 deletions dep/qrcode/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
5 changes: 1 addition & 4 deletions frontend/frontend.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,12 @@ library
, unordered-containers
, vector
, witherable
, qrcode-juicypixels

if impl(ghcjs)
build-depends:
ghcjs-base

if !impl(ghcjs)
build-depends:
qrcode-juicypixels

exposed-modules: Frontend
, Frontend.AppCfg
, Frontend.Log
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/Frontend/UI/Dialogs/KeyDetails.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ module Frontend.UI.Dialogs.KeyDetails
) where

------------------------------------------------------------------------------
#if !defined(ghcjs_HOST_OS)
import qualified Codec.QRCode as QR
import qualified Codec.QRCode.JuicyPixels as QR
#endif
import Control.Error
import Control.Lens
import Control.Monad (join)
Expand Down Expand Up @@ -245,12 +243,10 @@ uiKeyDetails _keyIndex key _onCloseExternal = mdo
Nothing -> blank
Just sig' -> do
uiDetailsCopyButton $ current sig'
#if !defined(ghcjs_HOST_OS)
let qrImage = QR.encodeText (QR.defaultQRCodeOptions QR.L) QR.Iso8859_1OrUtf8WithECI <$> sig'
img = maybe "Error creating QR code" (QR.toPngDataUrlT 4 6) <$> qrImage
img = maybe "Error creating QR code" (QR.toBmpDataUrlT 4 6) <$> qrImage
el "br" blank
elDynAttr "img" (("src" =:) . LT.toStrict <$> img) blank
#endif

modalFooter $ do
onDone <- confirmButton def "Done"
Expand Down
12 changes: 2 additions & 10 deletions frontend/src/Frontend/UI/Transfer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ import Data.These (These(This))
import Data.Traversable
import Data.Time.Clock.POSIX

#if !defined(ghcjs_HOST_OS)
import qualified Codec.QRCode as QR
import qualified Codec.QRCode.JuicyPixels as QR
#endif
import qualified Data.YAML.Aeson as Y

import Pact.Types.SigData
Expand Down Expand Up @@ -1484,11 +1482,10 @@ transferDetails signedCmd = do
& initialAttributes %~ (<> "disabled" =: "" <> "style" =: "width: 100%; height: 18em;")
& textAreaElementConfig_setValue .~ updated preview

#if !defined(ghcjs_HOST_OS)
tabPane mempty curSelection TransferDetails_HashQR $ do
let hashText = hashToText . toUntypedHash . _sigDataHash <$> signedCmd
qrImage = QR.encodeText (QR.defaultQRCodeOptions QR.L) QR.Iso8859_1OrUtf8WithECI <$> hashText
img = maybe "Error creating QR code" (QR.toPngDataUrlT 4 6) <$> qrImage
img = maybe "Error creating QR code" (QR.toBmpDataUrlT 4 6) <$> qrImage
el "div" $ text $ T.unwords
[ "This QR code contains only the request key."
, "It doesn't give any transaction information, so some wallets may not accept it."
Expand All @@ -1499,13 +1496,8 @@ transferDetails signedCmd = do
tabPane mempty curSelection TransferDetails_FullQR $ do
let yamlText = T.decodeUtf8 . Y.encode1Strict <$> signedCmd
qrImage = QR.encodeText (QR.defaultQRCodeOptions QR.L) QR.Iso8859_1OrUtf8WithECI <$> yamlText
img = maybe "Error creating QR code" (QR.toPngDataUrlT 4 4) <$> qrImage
img = maybe "Error creating QR code" (QR.toBmpDataUrlT 4 4) <$> qrImage
elDynAttr "img" (("src" =:) . LT.toStrict <$> img) blank
#else
let notAvailMsg = el "ul" $ text "This feature is not currently available in the browser"
tabPane mempty curSelection TransferDetails_HashQR notAvailMsg
tabPane mempty curSelection TransferDetails_FullQR notAvailMsg
#endif

pure ()

Expand Down
2 changes: 2 additions & 0 deletions obApp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ in with obelisk;
obelisk-oauth-frontend = hackGet ./dep/obelisk-oauth + /frontend;
obelisk-oauth-backend = hackGet ./dep/obelisk-oauth + /backend;
HsYAML-aeson = hackGet ./dep/HsYAML-aeson;
JuicyPixels-ghcjs = hackGet ./dep/juicy.pixels.ghcjs;
qrcode-juicypixels = hackGet ./dep/qrcode + "/qrcode-juicypixels";

# Needed for obelisk-oauth currently (ghcjs support mostly):
entropy = hackGet ./dep/entropy;
Expand Down