diff --git a/src/App.tsx b/src/App.tsx index f003057..60a69f5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -229,19 +229,7 @@ const App = (): React.JSX.Element => { component={HomeScreen} options={{ // eslint-disable-next-line react/no-unstable-nested-components - header: () => ( - - Laconic Wallet - - ), + header: () =>
, }} /> { component={SignMessage} options={{ // eslint-disable-next-line react/no-unstable-nested-components - headerTitle: () => Sign Message, + header: () =>
, }} /> { component={SignRequest} options={{ // eslint-disable-next-line react/no-unstable-nested-components - headerTitle: () => Sign Request, + header: () =>
, }} /> { name="AddSession" component={AddSession} options={{ - title: "New session", + header: () =>
, }} /> { name="ApproveTransfer" component={ApproveTransfer} options={{ - title: "Approve transfer", + header: () =>
, }} />
, }} /> { name="ApproveTransaction" component={ApproveTransaction} options={{ - title: "Approve Transaction", + header: () =>
, }} /> diff --git a/src/components/CreateWallet.tsx b/src/components/CreateWallet.tsx index 3ac0303..e07e6d2 100644 --- a/src/components/CreateWallet.tsx +++ b/src/components/CreateWallet.tsx @@ -1,9 +1,8 @@ -import { View } from 'react-native'; -import React from 'react'; -import { LoadingButton } from '@mui/lab'; +import { View } from "react-native"; +import React from "react"; +import { LoadingButton } from "@mui/lab"; -import { CreateWalletProps } from '../types'; -import styles from '../styles/stylesheet'; +import { CreateWalletProps } from "../types"; const CreateWallet = ({ isWalletCreating, @@ -16,8 +15,9 @@ const CreateWallet = ({ variant="contained" loading={isWalletCreating} disabled={isWalletCreating} - onClick={createWalletHandler}> - {isWalletCreating ? 'Creating' : 'CREATE WALLET'} + onClick={createWalletHandler} + > + {isWalletCreating ? "Creating" : "CREATE WALLET"} diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 15a9be0..9c2fba3 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,6 +1,5 @@ import { Divider, Stack, SvgIcon, Typography } from "@mui/material"; import React from "react"; -import { Text } from "react-native-paper"; export const Header: React.FC<{ title: string }> = ({ title }) => ( { setValue, reset, } = useForm>({ - mode: 'onChange', + mode: "onChange", resolver: zodResolver(networksFormDataSchema), }); const watchChainId = useWatch({ control, - name: 'chainId', + name: "chainId", }); const updateNetworkType = (newNetworkType: string) => { @@ -101,16 +103,16 @@ const AddNetwork = () => { const fetchChainDetails = useDebouncedCallback((chainId: string) => { if (namespace === EIP155) { const ethChainDetails = ETH_CHAINS.find( - chain => chain.chainId === Number(chainId), + (chain) => chain.chainId === Number(chainId), ); if (!ethChainDetails) { return; } - setValue('networkName', ethChainDetails.name); - setValue('rpcUrl', ethChainDetails.rpc[0]); - setValue('blockExplorerUrl', ethChainDetails.explorers?.[0].url || ''); - setValue('coinType', String(ethChainDetails.slip44 ?? '60')); - setValue('currencySymbol', ethChainDetails.nativeCurrency.symbol); + setValue("networkName", ethChainDetails.name); + setValue("rpcUrl", ethChainDetails.rpc[0]); + setValue("blockExplorerUrl", ethChainDetails.explorers?.[0].url || ""); + setValue("coinType", String(ethChainDetails.slip44 ?? "60")); + setValue("currencySymbol", ethChainDetails.nativeCurrency.symbol); return; } const cosmosChainDetails = chains.find( @@ -119,14 +121,14 @@ const AddNetwork = () => { if (!cosmosChainDetails) { return; } - setValue('networkName', cosmosChainDetails.pretty_name); - setValue('rpcUrl', cosmosChainDetails.apis?.rpc?.[0]?.address || ''); - setValue('blockExplorerUrl', cosmosChainDetails.explorers?.[0].url || ''); - setValue('addressPrefix', cosmosChainDetails.bech32_prefix); - setValue('coinType', String(cosmosChainDetails.slip44 ?? '118')); - setValue('nativeDenom', cosmosChainDetails.fees?.fee_tokens[0].denom || ''); + setValue("networkName", cosmosChainDetails.pretty_name); + setValue("rpcUrl", cosmosChainDetails.apis?.rpc?.[0]?.address || ""); + setValue("blockExplorerUrl", cosmosChainDetails.explorers?.[0].url || ""); + setValue("addressPrefix", cosmosChainDetails.bech32_prefix); + setValue("coinType", String(cosmosChainDetails.slip44 ?? "118")); + setValue("nativeDenom", cosmosChainDetails.fees?.fee_tokens[0].denom || ""); setValue( - 'gasPrice', + "gasPrice", String( cosmosChainDetails.fees?.fee_tokens[0].average_gas_price || String(process.env.DEFAULT_GAS_PRICE), @@ -142,11 +144,11 @@ const AddNetwork = () => { isDefault: false, }; - const mnemonicServer = await getInternetCredentials('mnemonicServer'); + const mnemonicServer = await getInternetCredentials("mnemonicServer"); const mnemonic = mnemonicServer; if (!mnemonic) { - throw new Error('Mnemonic not found'); + throw new Error("Mnemonic not found"); } const hdNode = HDNode.fromMnemonic(mnemonic); @@ -172,7 +174,7 @@ const AddNetwork = () => { break; default: - throw new Error('Unsupported namespace'); + throw new Error("Unsupported namespace"); } const accountInfo = `${hdPath},${node.privateKey},${node.publicKey},${address}`; @@ -183,22 +185,22 @@ const AddNetwork = () => { await Promise.all([ setInternetCredentials( `accounts/${newNetworkData.namespace}:${newNetworkData.chainId}/0`, - '_', + "_", accountInfo, ), setInternetCredentials( `addAccountCounter/${newNetworkData.namespace}:${newNetworkData.chainId}`, - '_', - '1', + "_", + "1", ), setInternetCredentials( `accountIndices/${newNetworkData.namespace}:${newNetworkData.chainId}`, - '_', - '0', + "_", + "0", ), ]); - navigation.navigate('Home'); + navigation.navigate("Home"); }, [navigation, namespace, setNetworksData], ); @@ -212,208 +214,254 @@ const AddNetwork = () => { }, [namespace, reset]); return ( - - + + + + Add Network + + + + - ( - <> - onChange(textValue)} + + + ( + <> + onChange(textValue)} + /> + + {errors.chainId?.message} + + + )} /> - {errors.chainId?.message} - - )} - /> - ( - <> - onChange(textValue)} - /> - {errors.networkName?.message} - - )} - /> - ( - <> - onChange(textValue)} - /> - {errors.rpcUrl?.message} - - )} - /> + - ( - <> - onChange(textValue)} + + ( + <> + onChange(textValue)} + /> + + {errors.networkName?.message} + + + )} /> - - {errors.blockExplorerUrl?.message} - - - )} - /> - ( - <> - + + + ( + <> + onChange(textValue)} + /> + {errors.rpcUrl?.message} + + )} /> - {errors.coinType?.message} - - )} - /> - {namespace === EIP155 ? ( - ( - <> - onChange(textValue)} + + + + ( + <> + onChange(textValue)} + /> + + {errors.blockExplorerUrl?.message} + + + )} + /> + + + ( + <> + + + {errors.coinType?.message} + + + )} + /> + + {namespace === EIP155 ? ( + + ( + <> + onChange(textValue)} + /> + + { + ( + errors as FieldErrors< + z.infer + > + ).currencySymbol?.message + } + + + )} /> - - { - (errors as FieldErrors>) - .currencySymbol?.message - } - + + ) : ( + <> + + ( + <> + onChange(textValue)} + /> + + { + ( + errors as FieldErrors< + z.infer + > + ).nativeDenom?.message + } + + + )} + /> + + + ( + <> + onChange(textValue)} + /> + + { + ( + errors as FieldErrors< + z.infer + > + ).addressPrefix?.message + } + + + )} + /> + + + ( + <> + + + { + ( + errors as FieldErrors< + z.infer + > + ).gasPrice?.message + } + + + )} + /> + )} - /> - ) : ( - <> - ( - <> - onChange(textValue)} - /> - - { - ( - errors as FieldErrors< - z.infer - > - ).nativeDenom?.message - } - - - )} - /> - ( - <> - onChange(textValue)} - /> - - { - ( - errors as FieldErrors< - z.infer - > - ).addressPrefix?.message - } - - - )} - /> - ( - <> - - - { - ( - errors as FieldErrors< - z.infer - > - ).gasPrice?.message - } - - - )} - /> - - )} - - + + + {isSubmitting ? "Adding" : "Submit"} + + + ); }; diff --git a/src/screens/EditNetwork.tsx b/src/screens/EditNetwork.tsx index 1e5f315..2cf11bd 100644 --- a/src/screens/EditNetwork.tsx +++ b/src/screens/EditNetwork.tsx @@ -12,7 +12,6 @@ import { useNavigation } from "@react-navigation/native"; import { setInternetCredentials } from "../utils/key-store"; import { StackParamsList } from "../types"; -import styles from "../styles/stylesheet"; import { retrieveNetworksData } from "../utils/accounts"; import { useNetworks } from "../context/NetworksContext"; import { @@ -214,9 +213,8 @@ const EditNetwork = ({ route }: EditNetworkProps) => { variant="contained" loading={isSubmitting} disabled={isSubmitting} - style={styles.networksButton} onClick={handleSubmit(submit)} - sx={{ minWidth: "200px", px: 4, py: 1 }} + sx={{ minWidth: "200px", px: 4, py: 1, mt: 2 }} > {isSubmitting ? "Adding" : "Submit"}