Skip to content
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

Removed ghcjs specific code #736

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
Removed ghcjs specific code
ohri-anurag committed Feb 10, 2022
commit 67febc0a94397ac2875e408554b93f18ccd47c1e
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)
7 changes: 7 additions & 0 deletions dep/qrcode/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"owner": "obsidiansystems",
"repo": "qrcode",
"private": false,
"rev": "91e6bb9954af52a422ff9a5d9cf45cb9601aece6",
"sha256": "01ynclz6vpih37j8hbjdsf57s3pddps44zp2f90hjihf8sg7pa4f"
}
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
@@ -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
6 changes: 1 addition & 5 deletions frontend/src/Frontend/UI/Dialogs/KeyDetails.hs
Original file line number Diff line number Diff line change
@@ -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)
@@ -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"
12 changes: 2 additions & 10 deletions frontend/src/Frontend/UI/Transfer.hs
Original file line number Diff line number Diff line change
@@ -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
@@ -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."
@@ -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 ()

1 change: 1 addition & 0 deletions obApp.nix
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ 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;
qrcode-juicypixels = hackGet ./dep/qrcode + "/qrcode-juicypixels";

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