forked from cerc-io/laconic-wallet
Fix Edit network form (#108)
* Make block explorer url optional * Make review changes * Remove log
This commit is contained in:
parent
6d80f64a10
commit
ad202f46fc
@ -62,14 +62,13 @@ const AddNetwork = () => {
|
||||
const { setNetworksData } = useNetworks();
|
||||
|
||||
const [namespace, setNamespace] = useState<string>(EIP155);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const networksFormDataSchema =
|
||||
namespace === EIP155 ? ethNetworkDataSchema : cosmosNetworkDataSchema;
|
||||
|
||||
const {
|
||||
control,
|
||||
formState: { errors },
|
||||
formState: { errors, isSubmitting },
|
||||
handleSubmit,
|
||||
setValue,
|
||||
reset,
|
||||
@ -118,7 +117,6 @@ const AddNetwork = () => {
|
||||
|
||||
const submit = useCallback(
|
||||
async (data: z.infer<typeof networksFormDataSchema>) => {
|
||||
setIsLoading(true);
|
||||
const newNetworkData = {
|
||||
...data,
|
||||
namespace,
|
||||
@ -181,7 +179,6 @@ const AddNetwork = () => {
|
||||
),
|
||||
]);
|
||||
|
||||
setIsLoading(false);
|
||||
navigation.navigate('Laconic');
|
||||
},
|
||||
[navigation, namespace, setNetworksData],
|
||||
@ -366,10 +363,10 @@ const AddNetwork = () => {
|
||||
)}
|
||||
<Button
|
||||
mode="contained"
|
||||
loading={isLoading}
|
||||
disabled={isLoading}
|
||||
loading={isSubmitting}
|
||||
disabled={isSubmitting}
|
||||
onPress={handleSubmit(submit)}>
|
||||
{isLoading ? 'Adding' : 'Submit'}
|
||||
{isSubmitting ? 'Adding' : 'Submit'}
|
||||
</Button>
|
||||
</ScrollView>
|
||||
);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import React, { useCallback } from 'react';
|
||||
import { ScrollView, View } from 'react-native';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { TextInput, Button, HelperText, Text } from 'react-native-paper';
|
||||
@ -30,15 +30,13 @@ const networksFormDataSchema = z.object({
|
||||
type EditNetworkProps = NativeStackScreenProps<StackParamsList, 'EditNetwork'>;
|
||||
|
||||
const EditNetwork = ({ route }: EditNetworkProps) => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const { setNetworksData } = useNetworks();
|
||||
const navigation =
|
||||
useNavigation<NativeStackNavigationProp<StackParamsList>>();
|
||||
|
||||
const {
|
||||
control,
|
||||
formState: { errors },
|
||||
formState: { errors, isSubmitting },
|
||||
handleSubmit,
|
||||
} = useForm<z.infer<typeof networksFormDataSchema>>({
|
||||
mode: 'onChange',
|
||||
@ -48,8 +46,6 @@ const EditNetwork = ({ route }: EditNetworkProps) => {
|
||||
|
||||
const submit = useCallback(
|
||||
async (data: z.infer<typeof networksFormDataSchema>) => {
|
||||
setIsLoading(true);
|
||||
|
||||
const retrievedNetworksData = await retrieveNetworksData();
|
||||
|
||||
const newNetworkData = { ...networkData, ...data };
|
||||
@ -67,7 +63,6 @@ const EditNetwork = ({ route }: EditNetworkProps) => {
|
||||
|
||||
setNetworksData(retrievedNetworksData);
|
||||
|
||||
setIsLoading(false);
|
||||
navigation.navigate('Laconic');
|
||||
},
|
||||
[networkData, navigation, setNetworksData],
|
||||
@ -136,10 +131,10 @@ const EditNetwork = ({ route }: EditNetworkProps) => {
|
||||
/>
|
||||
<Button
|
||||
mode="contained"
|
||||
loading={isLoading}
|
||||
disabled={isLoading}
|
||||
loading={isSubmitting}
|
||||
disabled={isSubmitting}
|
||||
onPress={handleSubmit(submit)}>
|
||||
{isLoading ? 'Adding' : 'Submit'}
|
||||
{isSubmitting ? 'Adding' : 'Submit'}
|
||||
</Button>
|
||||
</ScrollView>
|
||||
);
|
||||
|
@ -9,6 +9,7 @@ export const DEFAULT_NETWORKS = [
|
||||
networkName: EIP155_CHAINS['eip155:1'].name,
|
||||
namespace: EIP155,
|
||||
rpcUrl: EIP155_CHAINS['eip155:1'].rpc,
|
||||
blockExplorerUrl: '',
|
||||
currencySymbol: 'ETH',
|
||||
coinType: '60',
|
||||
isDefault: true,
|
||||
@ -18,6 +19,7 @@ export const DEFAULT_NETWORKS = [
|
||||
networkName: COSMOS_TESTNET_CHAINS['cosmos:theta-testnet-001'].name,
|
||||
namespace: COSMOS,
|
||||
rpcUrl: COSMOS_TESTNET_CHAINS['cosmos:theta-testnet-001'].rpc,
|
||||
blockExplorerUrl: '',
|
||||
nativeDenom: 'uatom',
|
||||
addressPrefix: 'cosmos',
|
||||
coinType: '118',
|
||||
|
Loading…
Reference in New Issue
Block a user