rvv001 - Add Privacy Policy to TUI

This commit is contained in:
Rene Vergara A. 2024-09-23 21:30:05 -04:00
parent 7189ddcb2a
commit 212c1f2867
7 changed files with 140 additions and 5 deletions

Binary file not shown.

View file

@ -0,0 +1,43 @@
#!/bin/bash
ZFOLDER=~/Zenith
IMAGE_NAME=zenithrpc-docker:0.7.0.0
for i in "$@"
do case $i in
-e=*|--expert=*)
EXPERTMODE="1"
;;
*)
EXPERTMODE="0"
;;
esac
done
# Check if docker engine is running
if ! systemctl is-active --quiet docker ; then
echo "Docker is not active/installed, "
echo "Please activate docker before proceeding!!."
echo "Aborting process..."
exit
fi
# Check if data folder exists
if [ ! -d "$ZFOLDER" ]; then
echo "Error starting Zenith RPC server image"
echo "Zenith configurtion and data folder ($ZFOLDER) does not exists."
echo "Aborting process..."
exit
fi
# Check if the image exists locally
if [[ "$(docker images -q $IMAGE_NAME 2> /dev/null)" == "" ]]; then
echo "Error starting Zenith RPC server image"
echo "Image $IMAGE_NAME not found locally."
echo "Aborting process..."
exit
fi
# Start image in detached mode
docker run --rm -d --mount src=$ZFOLDER,target=/home/zenusr/Zenith,type=bind --net=host --env EXPERT_MODE=$EXPERTMODE $IMAGE_NAME
# End

View file

@ -0,0 +1,5 @@
nodeUser = "user"
nodePwd = "superSecret"
dbFileName = "zenith.db"
zebraHost = "127.0.0.1"
zebraPort = 18232

View file

@ -0,0 +1,70 @@
#!/bin/bash
ZVERSION="0.7.0.0"
echo
echo "Zenith RPC Server Image Setup"
echo
echo "... testing if docker service is active.."
if systemctl is-active --quiet docker; then
echo "... Docker service active"
echo
if [ -d $HOME"/Zenith" ]; then
echo "Warning: Zenith Server configuration already exist, this procedure will create"
echo " a new configuration file. Your previous configurarion "
echo " will be saved as 'previous-zenith.cfg'. (a Backup is recommended)."
echo
read -r -p "Do you want to proceed ? [Y/n] " response
case "$response" in
[yY])
if [ -f $HOME/Zenith/previous-zenith.cfg ]; then
rm $HOME/Zenith/previous-zenith.cfg
fi
mv $HOME/Zenith/zenith.cfg $HOME/Zenith/previous-zenith.cfg
;;
*)
echo "... Zenith docker image setup not completed."
exit
;;
esac
else
echo
echo "... creating Zenith folder"
mkdir -p $HOME/Zenith/assets
fi
if docker image ls | grep -q "zenithrpc-docker" ; then
echo "... removing previous docker image"
docker rmi -f "zenithrpc-docker:"$ZVERSION
fi
echo "... loading zenithrpc-docker:"$ZVERSION" image"
docker load < zenithrpc-docker_$ZVERSION.tar
echo "... docker image zenithrpc-docker:"$ZVERSION" loaded."
echo "... creating default configuration"
cp cfg/zenith.cfg $HOME/Zenith/
echo "... copying zenith assets to Zenith folder."
cp -r cfg/assets $HOME/Zenith/assets
if ! [ -d $HOME/.local/bin ]; then
echo "... creating $HOME/.local/bin folder"
mkdir -p $HOME/.local/bin
else
echo "... $HOME/.local/bin exists"
fi
if [ -f $HOME/.local/bin/runzenithrpc ]; then
rm $HOME/.local/bin/runzenithrpc
fi
echo "... copying runzenithrpc to $HOME/.local/bin"
cp cfg/runzenithrpc $HOME/.local/bin/
if ! echo $PATH | grep -q $HOME/.local/bin ; then
echo PATH=$PATH:$HOME/.local/bin | tee -a $HOME/.bashrc
echo "... reloading configuration ...."
source $HOME/.bashrc
else
echo "... PATH=$PATH"
fi
echo
echo "To start Zenith RPC server execute 'runzenithrpc' from the command line."
else
echo "... Docker service is not active"
echo "... Please activate Docker service first."
fi
echo
echo "Done"
echo

View file

@ -10,7 +10,7 @@ import qualified Brick.BChan as BC
import qualified Brick.Focus as F
import Brick.Forms
( Form(..)
, (@@=)
, radioField
, allFieldsValid
, editShowableFieldWithValidate
, editTextField
@ -21,6 +21,7 @@ import Brick.Forms
, renderForm
, setFieldValid
, updateFormState
, (@@=)
)
import qualified Brick.Main as M
import qualified Brick.Types as BT
@ -94,6 +95,7 @@ import Zenith.Types
, PhraseDB(..)
, UnifiedAddressDB(..)
, ZcashNetDB(..)
, PrivacyPolicy(..)
)
import Zenith.Utils
( displayTaz
@ -119,6 +121,10 @@ data Name
| ABList
| DescripField
| AddressField
| PrivacyNoneField
| PrivacyLowField
| PrivacyMediumField
| PrivacyFullField
deriving (Eq, Show, Ord)
data DialogInput = DialogInput
@ -131,6 +137,7 @@ data SendInput = SendInput
{ _sendTo :: !T.Text
, _sendAmt :: !Float
, _sendMemo :: !T.Text
, _policyField :: !PrivacyPolicy
} deriving (Show)
makeLenses ''SendInput
@ -171,6 +178,8 @@ data Tick
| TickMsg !String
| TickTx !HexString
data DropDownItem = DropdownItem String
data State = State
{ _network :: !ZcashNet
, _wallets :: !(L.List Name (Entity ZcashWallet))
@ -607,6 +616,12 @@ mkSendForm bal =
, label "Amount: " @@=
editShowableFieldWithValidate sendAmt AmtField (isAmountValid bal)
, label "Memo: " @@= editTextField sendMemo MemoField (Just 1)
, label "Privacy Level :" @@=
radioField policyField [ (None, PrivacyNoneField, "None")
, (Low, PrivacyLowField, "Low")
, (Medium, PrivacyMediumField, "Medium")
, (Full, PrivacyFullField, "Full")
]
]
where
isAmountValid :: Integer -> Float -> Bool
@ -1125,7 +1140,8 @@ appEvent (BT.VtyEvent e) = do
(SendInput
(addressBookAbaddress (entityVal a))
0.0
"")
""
None)
BT.modify $ set dialogBox SendTx
_ -> do
BT.modify $
@ -1297,7 +1313,7 @@ appEvent (BT.VtyEvent e) = do
V.EvKey (V.KChar 's') [] -> do
BT.modify $
set txForm $
mkSendForm (s ^. balance) (SendInput "" 0.0 "")
mkSendForm (s ^. balance) (SendInput "" 0.0 "" None)
BT.modify $ set dialogBox SendTx
V.EvKey (V.KChar 'b') [] ->
BT.modify $ set dialogBox AdrBook
@ -1432,7 +1448,7 @@ runZenithTUI config = do
1.0
eventChan
0
(mkSendForm 0 $ SendInput "" 0.0 "")
(mkSendForm 0 $ SendInput "" 0.0 "" None)
(L.list ABList (Vec.fromList abookList) 1)
(mkNewABForm (AdrBookEntry "" ""))
""

View file

@ -203,7 +203,8 @@ data PrivacyPolicy
| Medium
| Low
| None
deriving (Eq, Show, Read, Ord)
$(deriveJSON defaultOptions ''PrivacyPolicy)
-- ** `zebrad`