diff --git a/src/components/json-rpc-sign/json-rpc-sign.tsx b/src/components/json-rpc-sign/json-rpc-sign.tsx index 0bbc12c41..56a61341c 100644 --- a/src/components/json-rpc-sign/json-rpc-sign.tsx +++ b/src/components/json-rpc-sign/json-rpc-sign.tsx @@ -13,11 +13,7 @@ import {EthereumSignInMessage} from '@app/helpers/ethereum-message-checker'; import {I18N} from '@app/i18n'; import {Fee} from '@app/models/fee'; import {Wallet} from '@app/models/wallet'; -import { - JsonRpcMetadata, - PartialJsonRpcRequest, - VerifyAddressResponse, -} from '@app/types'; +import {IContract, JsonRpcMetadata, PartialJsonRpcRequest} from '@app/types'; export interface JsonRpcSignProps { isTransaction: boolean; @@ -26,7 +22,7 @@ export interface JsonRpcSignProps { request: PartialJsonRpcRequest; metadata: JsonRpcMetadata; wallet: Wallet; - verifyAddressResponse: VerifyAddressResponse | null; + verifyAddressResponse: IContract | null; chainId?: number; hideContractAttention?: boolean; isAllowedDomain: boolean; diff --git a/src/components/json-rpc-sign/json-rpc-swap-transaction.tsx b/src/components/json-rpc-sign/json-rpc-swap-transaction.tsx index 25e5d3da4..63df6eea9 100644 --- a/src/components/json-rpc-sign/json-rpc-swap-transaction.tsx +++ b/src/components/json-rpc-sign/json-rpc-swap-transaction.tsx @@ -35,9 +35,9 @@ import {Wallet} from '@app/models/wallet'; import {Balance} from '@app/services/balance'; import {Indexer, SushiPoolEstimateResponse} from '@app/services/indexer'; import { + IContract, JsonRpcMetadata, JsonRpcTransactionRequest, - VerifyAddressResponse, } from '@app/types'; import {formatNumberString, openInAppBrowser, sleep} from '@app/utils'; import {STRINGS} from '@app/variables/common'; @@ -57,7 +57,7 @@ export interface JsonRpcSwapTransactionProps { tx: Partial | undefined; parsedInput: ethers.utils.TransactionDescription | undefined; chainId: string | number; - verifyAddressResponse: VerifyAddressResponse | null; + verifyAddressResponse: IContract | null; onFeePress: () => void; onError: () => void; diff --git a/src/components/json-rpc-sign/json-rpc-transaction-info.tsx b/src/components/json-rpc-sign/json-rpc-transaction-info.tsx index 17a552bff..8c0adad83 100644 --- a/src/components/json-rpc-sign/json-rpc-transaction-info.tsx +++ b/src/components/json-rpc-sign/json-rpc-transaction-info.tsx @@ -12,9 +12,9 @@ import {EthNetwork} from '@app/services'; import {Balance} from '@app/services/balance'; import { AddressType, + IContract, JsonRpcMetadata, PartialJsonRpcRequest, - VerifyAddressResponse, } from '@app/types'; import { getTransactionFromJsonRpcRequest, @@ -30,7 +30,7 @@ import {First} from '../ui'; interface JsonRpcTransactionInfoProps { request: PartialJsonRpcRequest; metadata: JsonRpcMetadata; - verifyAddressResponse: VerifyAddressResponse | null; + verifyAddressResponse: IContract | null; chainId?: number; hideContractAttention?: boolean; fee?: Fee | null; diff --git a/src/components/swap/swap-route-path-icons.tsx b/src/components/swap/swap-route-path-icons.tsx index 87ab01733..396b46382 100644 --- a/src/components/swap/swap-route-path-icons.tsx +++ b/src/components/swap/swap-route-path-icons.tsx @@ -64,6 +64,7 @@ export const SwapRoutePathIcons = observer( if (!contract) { return null; } + return ( AddressUtils.equals(wallet.address, address), ); @@ -77,7 +81,7 @@ export class Whitelist { return { address_type: AddressType.wallet, id: AddressUtils.toHaqq(address), - } as VerifyAddressResponse; + } as IContract; } if (!provider.indexer || !address) { @@ -88,7 +92,7 @@ export class Whitelist { return Token.generateNativeTokenContracts()[0]; } - const key = `${CACHE_KEY}:${JSON.stringify(address)}:${provider.id}`; + const key = `${CACHE_KEY}:${JSON.stringify(address)}`; let responseFromCache: CachedVerifyAddressResponse | null = null; if (!force) { try { @@ -101,7 +105,7 @@ export class Whitelist { responseFromCache?.cachedAt && responseFromCache.cachedAt + CACHE_LIFE_TIME > Date.now() ) { - return responseFromCache; + return responseFromCache.address[chainId]; } } } catch (err) { @@ -112,7 +116,7 @@ export class Whitelist { try { const params: any[] = getParsedAddressList(address); if (!Provider.isAllNetworks) { - params.push(Provider.selectedProvider.ethChainId); + params.push(provider.ethChainId); } const response = await jsonrpcRequest( @@ -129,7 +133,7 @@ export class Whitelist { VariablesString.set(key, responseForCache); } - return response; + return response?.address[chainId] ?? null; } catch (err) { if (err instanceof JSONRPCError) { Logger.captureException(err, 'Whitelist:verifyAddress', err.meta); @@ -137,7 +141,7 @@ export class Whitelist { logger.error('verifyAddress', err); if (responseFromCache) { - return responseFromCache; + return responseFromCache.address[chainId]; } return null; diff --git a/src/screens/HomeStack/JsonRpcSignPopupStack/json-rpc-sign-screen.tsx b/src/screens/HomeStack/JsonRpcSignPopupStack/json-rpc-sign-screen.tsx index 3560e5c03..ec0ed85de 100644 --- a/src/screens/HomeStack/JsonRpcSignPopupStack/json-rpc-sign-screen.tsx +++ b/src/screens/HomeStack/JsonRpcSignPopupStack/json-rpc-sign-screen.tsx @@ -25,7 +25,7 @@ import {Balance} from '@app/services/balance'; import {EthSignErrorDataDetails} from '@app/services/eth-sign'; import {Indexer} from '@app/services/indexer'; import {SignJsonRpcRequest} from '@app/services/sign-json-rpc-request'; -import {ModalType, VerifyAddressResponse} from '@app/types'; +import {IContract, ModalType} from '@app/types'; import { getTransactionFromJsonRpcRequest, getUserAddressFromJRPCRequest, @@ -37,7 +37,7 @@ export const JsonRpcSignScreen = memo(() => { const [rejectLoading, setRejectLoading] = useState(false); const [signLoading, setSignLoading] = useState(false); const [verifyAddressResponse, setVerifyAddressResponse] = - useState(null); + useState(null); const [isLoading, setIsLoading] = useState(true); const [phishingTxRequest, setPhisingTxRequest] = useState(null); diff --git a/src/types.ts b/src/types.ts index f25350fef..4d15f62a9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1407,7 +1407,9 @@ export enum AddressType { unknown = 'unknown', } -export type VerifyAddressResponse = IContract; +export type VerifyAddressResponse = { + address: Record; +}; export interface MobXStoreFromRealm { realmSchemaName: string;