diff --git a/tauri-wallet/src/context/main.tsx b/tauri-wallet/src/context/main.tsx index 347240edbc..d5ed5001dc 100644 --- a/tauri-wallet/src/context/main.tsx +++ b/tauri-wallet/src/context/main.tsx @@ -1,9 +1,11 @@ +import { invoke } from '@tauri-apps/api' import React, { createContext, useCallback, useEffect, useState } from 'react' import { useHistory } from 'react-router-dom' -import { TClientDetails } from '../types' +import { Coin, TClientDetails } from '../types' type TClientContext = { clientDetails?: TClientDetails + gasPrice?: Coin logIn: (clientDetails: TClientDetails) => void logOut: () => void } @@ -16,6 +18,7 @@ export const ClientContextProvider = ({ children: React.ReactNode }) => { const [clientDetails, setClientDetails] = useState() + const [gasPrice, setGasPrice] = useState() const history = useHistory() @@ -23,8 +26,12 @@ export const ClientContextProvider = ({ !clientDetails ? history.push('/signin') : history.push('/bond') }, [clientDetails]) - const logIn = (clientDetails: TClientDetails) => + const logIn = async (clientDetails: TClientDetails) => { + await invoke('get_gas_price') + .then((res) => setGasPrice(res as Coin)) + .catch((e) => console.log(e)) setClientDetails(clientDetails) + } const logOut = () => setClientDetails(undefined) @@ -32,6 +39,7 @@ export const ClientContextProvider = ({ { + const { gasPrice } = useContext(ClientContext) const { getValues } = useFormContext() - const values: TFormData = getValues() + const values = getValues() const theme: Theme = useTheme() return ( @@ -32,6 +37,15 @@ export const SendReview = () => { + + + + + + ) @@ -42,7 +56,7 @@ export const SendReviewField = ({ subtitle, }: { title: string - subtitle: string + subtitle?: string }) => { const theme: Theme = useTheme() return ( diff --git a/tauri-wallet/src/routes/send/SendWizard.tsx b/tauri-wallet/src/routes/send/SendWizard.tsx index 3e1b7429cb..1e65862425 100644 --- a/tauri-wallet/src/routes/send/SendWizard.tsx +++ b/tauri-wallet/src/routes/send/SendWizard.tsx @@ -3,12 +3,12 @@ import { useForm, FormProvider } from 'react-hook-form' import { yupResolver } from '@hookform/resolvers/yup' import { Button, Step, StepLabel, Stepper, Theme } from '@material-ui/core' import { useTheme } from '@material-ui/styles' +import { invoke } from '@tauri-apps/api' import { SendForm } from './SendForm' import { SendReview } from './SendReview' import { SendConfirmation } from './SendConfirmation' import { ClientContext } from '../../context/main' import { validationSchema } from './validationSchema' -import { invoke } from '@tauri-apps/api' import { TauriTxResult } from '../../types/rust/tauritxresult' const defaultValues = { diff --git a/tauri-wallet/src/routes/send/index.tsx b/tauri-wallet/src/routes/send/index.tsx index fdbcb884ae..eed0b844fa 100644 --- a/tauri-wallet/src/routes/send/index.tsx +++ b/tauri-wallet/src/routes/send/index.tsx @@ -6,7 +6,7 @@ import { Layout } from '../../layouts' export const Send = () => { return ( - +