Skip to content

Commit

Permalink
Merge pull request #61 from GadzeFinance/feature/sign-mac
Browse files Browse the repository at this point in the history
Feature/sign mac
  • Loading branch information
Nicky-2000 committed Apr 4, 2023
2 parents 3fadadf + 93b6848 commit 44201c1
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 45 deletions.
22 changes: 22 additions & 0 deletions notarize-app-mac.sh
@@ -0,0 +1,22 @@
#!/bin/bash

DIST_PATH="dist/mac"
APP_NAME="etherfi-desktop.app"
PYTHON_EXECUTABLE_PATH="Contents/build/bin/eth2deposit_proxy"
IDENTITY="Developer ID Application: Nicholas Khorasani (X8SBW73X92)"

yarn dist --x64

echo Enter THESE:
echo com.etherfi.etherfi-desktop
echo usdx-hwwf-pdbp-karx
xcrun notarytool store-credentials --apple-id "nckhorasani@icloud.com" --team-id "X8SBW73X92"

ditto -c -k --sequesterRsrc --keepParent "$DIST_PATH/$APP_NAME" "$DIST_PATH/etherfi-desktop.zip"
echo "101"
xcrun notarytool submit "$DIST_PATH/etherfi-desktop.zip" --keychain-profile "com.etherfi.etherfi-desktop" --wait
echo "102"
stapler staple "$DIST_PATH/$APP_NAME"
echo "103"
spctl --assess -vv --type install "$DIST_PATH/$APP_NAME"
echo "104"
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -11,6 +11,7 @@
"postinstall": "electron-builder install-app-deps",
"buildNode": "webpack --config webpack.react.config.js --config webpack.electron.config.js",
"buildcli": "src/scripts/bundle_proxy_linux.sh",
"buildclimac": "src/scripts/bundle_proxy_mac.sh",
"buildcliwin": "src/scripts/bundle_proxy_win.bat",
"prod": "cross-env NODE_ENV=production electron ./build/electron/main.js",
"pack": "electron-builder --dir",
Expand Down Expand Up @@ -52,13 +53,11 @@
"target": "tar.gz",
"category": "public.app-category.utilities",
"icon": "resources/icon.png",
"hardenedRuntime": false,
"hardenedRuntime": true,
"entitlements": "AppleSetUp/entitlements.mac.plist",
"entitlementsInherit": "AppleSetUp/entitlements.mac.plist",
"gatekeeperAssess": false,
"x64ArchFiles": "Contents/build/bin/eth2deposit_proxy",
"binaries": [
"Contents/build/bin/eth2deposit_proxy",
"Contents/build/word_lists/english.txt"
]
},
Expand Down
92 changes: 50 additions & 42 deletions src/react/components/NodeOperatorComponents/GenerateKeysWidget.tsx
Expand Up @@ -10,12 +10,13 @@ import darkBoxWithBorderStyle from '../../styleClasses/darkBoxWithBorderStyle';
import { COLORS } from '../../styleClasses/constants';
import SavedFileBox from '../SavedFileBox'
import PasswordInput from '../PasswordInput'
import EtherFiSpinner from '../EtherFiSpinner';


const MAX_KEYS = "10000"
const MAX_KEYS = "7500"

const GenerateKeysWidget: React.FC = () => {
const [numKeys, setNumKeys] = useState<string>("500");
const [numKeys, setNumKeys] = useState<string>(MAX_KEYS);
const [savePath, setSavePath] = useState<string>("")
const [keysGenerated, setKeysGenerated] = useState<boolean>(false)
const [keysGenerating, setKeysGenerating] = useState<boolean>(false)
Expand All @@ -29,6 +30,7 @@ const GenerateKeysWidget: React.FC = () => {
const generateKeys = () => {
window.encryptionApi.receiveNOKeysConfirmation(
(event: Electron.IpcMainEvent, result: number, pubKeysFilePath: string, privKeysFilePath: string, errorMessage: string) => {
setKeysGenerating(false)
if (result === 0) {
setPubKeysFilePath(pubKeysFilePath)
setPrivKeysFilePath(privKeysFilePath)
Expand All @@ -37,7 +39,6 @@ const GenerateKeysWidget: React.FC = () => {
console.error("Error generating keys")
console.error(errorMessage)
}
setKeysGenerating(false)
})
// Send request to backend to make the public and private key files
window.encryptionApi.reqGenNodeOperatorKeys(numKeys, savePath, privKeysPassword);
Expand All @@ -63,29 +64,27 @@ const GenerateKeysWidget: React.FC = () => {

return (
<Center>
{!keysGenerated && (
{!keysGenerated && !keysGenerating && (
<Box sx={raisedWidgetStyle} bg="#2b2852">
<VStack
spacing={4}
align='stretch'
>
<Box>
<HStack spacing='10px'>
<Text fontSize='18px' as='b' color="white">Generate Keys</Text>
<Text fontSize='14px' color={COLORS.textSecondary}>Can be done once per wallet</Text>
</HStack>
<Text mb="5px" fontSize='18px' as='b' color="white">Generate Encryption Keys</Text>
<Text fontSize='14px' color={COLORS.textSecondary}>Please generate keys and upload the 'Public' file to the DApp.</Text>
</Box>

<Box sx={darkBoxWithBorderStyle} bg="#2b2852">
<HStack spacing='5px' mb="5px">
<Text fontSize='14px' as='b' color="white">Number of Keys</Text>
<Text fontSize='11px' color={COLORS.textSecondary}>(10000 max)</Text>
<Text fontSize='11px' color={COLORS.textSecondary}>(7500 max)</Text>
</HStack>

<InputGroup>
<NumberInput borderColor={COLORS.lightPurple} color="white" placeholder="Enter Amount"
min={1} max={10000} value={numKeys}
onChange={(newValStr, newValuNum) => setNumKeys(newValStr)}
min={1} max={7500} value={numKeys}
onChange={(newValStr: React.SetStateAction<string>, _newValuNum: any) => setNumKeys(newValStr)}
keepWithinRange={false}
clampValueOnBlur={false}
>
Expand Down Expand Up @@ -118,40 +117,49 @@ const GenerateKeysWidget: React.FC = () => {
</Center>
</Box>
</VStack>
</Box>
</Box >

)}
{keysGenerated && (
<Box sx={successBoxStyle} bg="#2b2852">
<VStack
spacing={3}
align='stretch'
>
<Box p='10px'>
<HStack spacing='10px'>
<Text fontSize='18px' as='b' color="white">Saved</Text>
<Text fontSize='14px' color={COLORS.textSecondary}>The key files have been saved to your machine</Text>
</HStack>
</Box>

<Box sx={darkBoxWithBorderStyle} bg="#2b2852">
<HStack spacing='5px' mb="5px">
<Text fontSize='14px' as='b' color="white">Folder: </Text>
<Text fontSize='11px' color={COLORS.textSecondary}>{savePath}</Text>
</HStack>
<SavedFileBox filePath={pubKeysFilePath} />
<SavedFileBox filePath={privKeysFilePath} />
</Box>
<Box>
<Center>
<Button variant="white-button" onClick={clearState}>Finish</Button>
</Center>
</Box>
</VStack>
</Box>
{
keysGenerating && (
<Box sx={raisedWidgetStyle} bg="#2b2852">
<EtherFiSpinner text="Generating Encryption Keys" loading={keysGenerating} />
</Box>
)
}
{
keysGenerated && (
<Box sx={successBoxStyle} bg="#2b2852">
<VStack
spacing={3}
align='stretch'
>
<Box p='10px'>
<HStack spacing='10px'>
<Text fontSize='18px' as='b' color="white">Saved</Text>
<Text fontSize='14px' color={COLORS.textSecondary}>The key files have been saved to your machine</Text>
</HStack>
</Box>

)}
</Center>
<Box sx={darkBoxWithBorderStyle} bg="#2b2852">
<HStack spacing='5px' mb="5px">
<Text fontSize='14px' as='b' color="white">Folder: </Text>
<Text fontSize='11px' color={COLORS.textSecondary}>{savePath}</Text>
</HStack>
<SavedFileBox filePath={pubKeysFilePath} />
<SavedFileBox filePath={privKeysFilePath} />
</Box>
<Box>
<Center>
<Button variant="white-button" onClick={clearState}>Finish</Button>
</Center>
</Box>
</VStack>
</Box>

)
}
</Center >
)
}

Expand Down
45 changes: 45 additions & 0 deletions src/scripts/bundle_proxy_mac.sh
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

# Bash script to bundle the eth2deposit_proxy application and the associated required files on
# Linux and macOS.

if [ -f ~/.bash_aliases ]; then
shopt -s expand_aliases
source ~/.bash_aliases
fi

SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
echo $SCRIPTPATH
EDCDIR=staking-deposit-cli-2.4.0

TARGETPACKAGESPATH=$SCRIPTPATH/../../dist/packages
ETH2DEPOSITCLIPATH=$SCRIPTPATH/../vendors/$EDCDIR
ETH2REQUIREMENTSPATH=$ETH2DEPOSITCLIPATH/requirements.txt

PYTHONPATH=$TARGETPACKAGESPATH:$ETH2DEPOSITCLIPATH:$(python3 -c "import sys;print(':'.join(sys.path))")
DISTBINPATH=$SCRIPTPATH/../../build/bin
DISTWORDSPATH=$SCRIPTPATH/../../build/word_lists
SRCWORDSPATH=$SCRIPTPATH/../vendors/$EDCDIR/staking_deposit/key_handling/key_derivation/word_lists
SRCINTLPATH=$SCRIPTPATH/../vendors/$EDCDIR/staking_deposit/intl

mkdir -p $DISTBINPATH
mkdir -p $DISTWORDSPATH
mkdir -p $TARGETPACKAGESPATH

# Getting all the requirements
python3 -m pip install -r $ETH2REQUIREMENTSPATH --target $TARGETPACKAGESPATH

# Bundling Python eth2deposit_proxy
PYTHONPATH=$PYTHONPATH pyinstaller \
--onefile \
--distpath $DISTBINPATH \
--add-data "$SRCINTLPATH:staking_deposit/intl" \
--target-architecture x86_64 \
--codesign-identity "Developer ID Application: Nicholas Khorasani (X8SBW73X92)" \
--osx-entitlements-file $SCRIPTPATH/../../AppleSetUp/entitlements.mac.plist \
-p $PYTHONPATH \
--hidden-import=os \
$SCRIPTPATH/eth2deposit_proxy.py

# Adding word list
cp $SRCWORDSPATH/* $DISTWORDSPATH

0 comments on commit 44201c1

Please sign in to comment.