diff --git a/app/rpc/enums/RPCParseAddressStatusEnum.ts b/app/rpc/enums/RPCParseAddressStatusEnum.ts new file mode 100644 index 000000000..c2342d02f --- /dev/null +++ b/app/rpc/enums/RPCParseAddressStatusEnum.ts @@ -0,0 +1,4 @@ +export enum RPCParseAddressStatusEnum { + successAddressParse = 'success', + invalidAddressParse = 'Invalid address', +} diff --git a/app/rpc/enums/RPCParseStatusEnum.ts b/app/rpc/enums/RPCParseStatusEnum.ts deleted file mode 100644 index deb72e9f3..000000000 --- a/app/rpc/enums/RPCParseStatusEnum.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum RPCParseStatusEnum { - successParse = 'success', - InvalidAddressParse = 'Invalid address', -} diff --git a/app/rpc/enums/RPCParseViewKeyStatusEnum.ts b/app/rpc/enums/RPCParseViewKeyStatusEnum.ts new file mode 100644 index 000000000..7240fbf24 --- /dev/null +++ b/app/rpc/enums/RPCParseViewKeyStatusEnum.ts @@ -0,0 +1,4 @@ +export enum RPCParseViewKeyStatusEnum { + successViewKeyParse = 'success', + invalidViewKeyParse = 'Invalid viewkey', +} diff --git a/app/rpc/types/RPCParseAddressType.ts b/app/rpc/types/RPCParseAddressType.ts index ac4ef7b96..5ece2f3c1 100644 --- a/app/rpc/types/RPCParseAddressType.ts +++ b/app/rpc/types/RPCParseAddressType.ts @@ -1,10 +1,10 @@ import { ChainNameEnum } from '../../AppState'; import { RPCAddressKindEnum } from '../enums/RPCAddressKindEnum'; -import { RPCParseStatusEnum } from '../enums/RPCParseStatusEnum'; +import { RPCParseAddressStatusEnum } from '../enums/RPCParseAddressStatusEnum'; import { RPCReceiversEnum } from '../enums/RPCReceiversEnum'; export type RPCParseAddressType = { - status: RPCParseStatusEnum; + status: RPCParseAddressStatusEnum; chain_name?: ChainNameEnum; address_kind?: | RPCAddressKindEnum.unifiedAddressKind diff --git a/app/rpc/types/RPCParseViewKeyType.ts b/app/rpc/types/RPCParseViewKeyType.ts index f383c1486..ae56661f1 100644 --- a/app/rpc/types/RPCParseViewKeyType.ts +++ b/app/rpc/types/RPCParseViewKeyType.ts @@ -1,10 +1,10 @@ import { ChainNameEnum } from '../../AppState'; import { RPCAddressKindEnum } from '../enums/RPCAddressKindEnum'; -import { RPCParseStatusEnum } from '../enums/RPCParseStatusEnum'; +import { RPCParseViewKeyStatusEnum } from '../enums/RPCParseViewKeyStatusEnum'; import { RPCPoolsEnum } from '../enums/RPCPoolsEnum'; export type RPCParseViewKeyType = { - status: RPCParseStatusEnum; + status: RPCParseViewKeyStatusEnum; chain_name?: ChainNameEnum; address_kind?: RPCAddressKindEnum.ufvkAddressKind; pools_available?: RPCPoolsEnum[]; diff --git a/app/utils/Utils.ts b/app/utils/Utils.ts index 9beec253e..f64d1ba8d 100644 --- a/app/utils/Utils.ts +++ b/app/utils/Utils.ts @@ -17,7 +17,7 @@ import randomColor from 'randomcolor'; import RPCModule from '../RPCModule'; import { Buffer } from 'buffer'; import { RPCParseAddressType } from '../rpc/types/RPCParseAddressType'; -import { RPCParseStatusEnum } from '../rpc/enums/RPCParseStatusEnum'; +import { RPCParseAddressStatusEnum } from '../rpc/enums/RPCParseAddressStatusEnum'; import { RPCAddressKindEnum } from '../rpc/enums/RPCAddressKindEnum'; export default class Utils { @@ -310,7 +310,7 @@ export default class Utils { const result: string = await RPCModule.execute(CommandEnum.parseAddress, address); //console.log(result); if (result) { - if (result.toLowerCase().startsWith(GlobalConst.error) || result.toLowerCase() === 'null') { + if (result.toLowerCase().startsWith(GlobalConst.error)) { return false; } } else { @@ -325,14 +325,16 @@ export default class Utils { //console.log('parse-address', address, resultJSON, resultJSON.status === RPCParseStatusEnum.successParse); - return resultJSON.status === RPCParseStatusEnum.successParse && resultJSON.chain_name === serverChainName; + return ( + resultJSON.status === RPCParseAddressStatusEnum.successAddressParse && resultJSON.chain_name === serverChainName + ); } static async isValidOrchardOrSaplingAddress(address: string, serverChainName: string): Promise { const result: string = await RPCModule.execute(CommandEnum.parseAddress, address); //console.log(result); if (result) { - if (result.toLowerCase().startsWith(GlobalConst.error) || result.toLowerCase() === 'null') { + if (result.toLowerCase().startsWith(GlobalConst.error)) { return false; } } else { @@ -348,7 +350,7 @@ export default class Utils { //console.log('parse-memo', address, resultJSON); return ( - resultJSON.status === RPCParseStatusEnum.successParse && + resultJSON.status === RPCParseAddressStatusEnum.successAddressParse && resultJSON.address_kind !== RPCAddressKindEnum.transparentAddressKind && resultJSON.address_kind !== RPCAddressKindEnum.texAddressKind && resultJSON.chain_name === serverChainName diff --git a/components/Send/components/Confirm.tsx b/components/Send/components/Confirm.tsx index 26bcf6a41..758df75bf 100644 --- a/components/Send/components/Confirm.tsx +++ b/components/Send/components/Confirm.tsx @@ -27,7 +27,7 @@ import { ButtonTypeEnum, CommandEnum, PrivacyLevelFromEnum, GlobalConst } from ' import { CurrencyEnum } from '../../../app/AppState'; import { RPCAddressKindEnum } from '../../../app/rpc/enums/RPCAddressKindEnum'; import { RPCReceiversEnum } from '../../../app/rpc/enums/RPCReceiversEnum'; -import { RPCParseStatusEnum } from '../../../app/rpc/enums/RPCParseStatusEnum'; +import { RPCParseAddressStatusEnum } from '../../../app/rpc/enums/RPCParseAddressStatusEnum'; type ConfirmProps = { calculatedFee: number; @@ -127,7 +127,7 @@ const Confirm: React.FunctionComponent = ({ const result: string = await RPCModule.execute(CommandEnum.parseAddress, sendPageState.toaddr.to); if (result) { - if (result.toLowerCase().startsWith(GlobalConst.error) || result.toLowerCase() === 'null') { + if (result.toLowerCase().startsWith(GlobalConst.error)) { return '-'; } } else { @@ -143,7 +143,10 @@ const Confirm: React.FunctionComponent = ({ //console.log('parse-address', sendPageState.toaddr.to, resultJSON.status === RPCParseStatusEnum.successParse); - if (resultJSON.status !== RPCParseStatusEnum.successParse || resultJSON.chain_name !== server.chainName) { + if ( + resultJSON.status !== RPCParseAddressStatusEnum.successAddressParse || + resultJSON.chain_name !== server.chainName + ) { return '-'; } diff --git a/components/Ufvk/ImportUfvk.tsx b/components/Ufvk/ImportUfvk.tsx index 41820acd8..959d678c4 100644 --- a/components/Ufvk/ImportUfvk.tsx +++ b/components/Ufvk/ImportUfvk.tsx @@ -20,7 +20,7 @@ import 'moment/locale/es'; import 'moment/locale/pt'; import 'moment/locale/ru'; import { ButtonTypeEnum, CommandEnum, GlobalConst } from '../../app/AppState'; -import { RPCParseStatusEnum } from '../../app/rpc/enums/RPCParseStatusEnum'; +import { RPCParseViewKeyStatusEnum } from '../../app/rpc/enums/RPCParseViewKeyStatusEnum'; type ImportUfvkProps = { onClickCancel: () => void; @@ -103,7 +103,8 @@ const ImportUfvk: React.FunctionComponent = ({ onClickCancel, o //console.log('parse ufvk', scannedKey, resultJSON); - const valid = resultJSON.status === RPCParseStatusEnum.successParse && resultJSON.chain_name === server.chainName; + const valid = + resultJSON.status === RPCParseViewKeyStatusEnum.successViewKeyParse && resultJSON.chain_name === server.chainName; if (valid) { return true;