Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order detail fix for unconnected wallet #964

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { useEffect, useState } from "react";

import { TokenInfo } from "@airswap/utils";
import { Web3Provider, JsonRpcProvider } from "@ethersproject/providers";
import { Web3Provider } from "@ethersproject/providers";
import { useWeb3React } from "@web3-react/core";

import { useAppDispatch, useAppSelector } from "../../../../app/hooks";
import { getAllTokensFromLocalStorage } from "../../../../features/metadata/metadataApi";
import {
addTokenInfo,
selectAllTokenInfo,
selectAllTokens,
} from "../../../../features/metadata/metadataSlice";
import { selectTakeOtcReducer } from "../../../../features/takeOtc/takeOtcSlice";
import findEthOrTokenByAddress from "../../../../helpers/findEthOrTokenByAddress";
import { getRpcUrl } from "../../../../helpers/getRpcUrl";
import scrapeToken from "../../../../helpers/scrapeToken";

// OTC Taker version of useTokenInfo. Look at chainId of the active FullOrderERC20 instead
Expand All @@ -25,7 +24,7 @@ const useTakerTokenInfo = (
const { provider: library } = useWeb3React<Web3Provider>();
const { isActive } = useAppSelector((state) => state.web3);

const allTokens = useAppSelector(selectAllTokenInfo);
const allTokens = useAppSelector(selectAllTokens);
const { activeOrder } = useAppSelector(selectTakeOtcReducer);

const [token, setToken] = useState<TokenInfo>();
Expand Down Expand Up @@ -63,11 +62,8 @@ const useTakerTokenInfo = (
const callScrapeToken = async () => {
setIsCallScrapeTokenLoading(true);

const lib =
library || new JsonRpcProvider(getRpcUrl(activeOrder.chainId));

if (lib) {
const result = await scrapeToken(address, lib);
if (library) {
const result = await scrapeToken(address, library);
if (result) {
setScrapedToken(result);
}
Expand Down
7 changes: 1 addition & 6 deletions src/features/metadata/metadataSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ import { createSelector, createSlice, PayloadAction } from "@reduxjs/toolkit";
import { RootState } from "../../app/store";
import { fetchSupportedTokens } from "../registry/registryActions";
import { walletDisconnected } from "../web3/web3Actions";
import { selectChainId, setWeb3Data } from "../web3/web3Slice";
import { selectChainId } from "../web3/web3Slice";
import {
fetchAllTokens,
fetchProtocolFee,
fetchUnkownTokens,
} from "./metadataActions";
import {
getActiveTokensFromLocalStorage,
getAllTokensFromLocalStorage,
getCustomTokensFromLocalStorage,
} from "./metadataApi";

export interface MetadataTokens {
all: {
Expand Down
Loading