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