diff --git a/.env.example b/.env.example index c039d12..9687d13 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,3 @@ WALLET_CONNECT_PROJECT_ID= +DEFAULT_GAS_LIMIT= +DEFAULT_GAS_PRICE= diff --git a/react-native-config.d.ts b/react-native-config.d.ts index db50fa4..8f78aab 100644 --- a/react-native-config.d.ts +++ b/react-native-config.d.ts @@ -2,6 +2,8 @@ declare module 'react-native-config' { export interface NativeConfig { WALLET_CONNECT_PROJECT_ID: string; + DEFAULT_GAS_LIMIT: string; + DEFAULT_GAS_PRICE: string; } export const Config: NativeConfig; diff --git a/src/components/TxErrorDialog.tsx b/src/components/TxErrorDialog.tsx new file mode 100644 index 0000000..e110760 --- /dev/null +++ b/src/components/TxErrorDialog.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import { Button, Dialog, Portal, Text } from 'react-native-paper'; + +const TxErrorDialog = ({ + error, + visible, + hideDialog, +}: { + error: string; + visible: boolean; + hideDialog: () => void; +}) => { + return ( + + + Error sending transaction + + {error} + + + + + + + ); +}; + +export default TxErrorDialog; diff --git a/src/screens/AddNetwork.tsx b/src/screens/AddNetwork.tsx index 0abf8d7..a2b5947 100644 --- a/src/screens/AddNetwork.tsx +++ b/src/screens/AddNetwork.tsx @@ -53,6 +53,10 @@ const cosmosNetworkDataSchema = z.object({ coinType: z.string().nonempty({ message: EMPTY_FIELD_ERROR }).regex(/^\d+$/), nativeDenom: z.string().nonempty({ message: EMPTY_FIELD_ERROR }), addressPrefix: z.string().nonempty({ message: EMPTY_FIELD_ERROR }), + gasPrice: z + .string() + .nonempty({ message: EMPTY_FIELD_ERROR }) + .regex(/^\d+(\.\d+)?$/), }); const AddNetwork = () => { @@ -113,6 +117,13 @@ const AddNetwork = () => { setValue('addressPrefix', cosmosChainDetails.bech32_prefix); setValue('coinType', String(cosmosChainDetails.slip44 ?? '118')); setValue('nativeDenom', cosmosChainDetails.fees?.fee_tokens[0].denom || ''); + setValue( + 'gasPrice', + String( + cosmosChainDetails.fees?.fee_tokens[0].average_gas_price || + String(process.env.DEFAULT_GAS_PRICE), + ), + ); }, CHAINID_DEBOUNCE_DELAY); const submit = useCallback( @@ -359,6 +370,31 @@ const AddNetwork = () => { )} /> + ( + <> + + + { + ( + errors as FieldErrors< + z.infer + > + ).gasPrice?.message + } + + + )} + /> )}