Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

fix networkOrDefault type and typo #1528

Merged
merged 2 commits into from
Oct 13, 2020
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
2 changes: 1 addition & 1 deletion src/api/wallet/WalletApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface WalletApi {
export interface WalletInfo {
isConnected: boolean
userAddress?: string
networkId?: number
networkId?: Network
blockNumber?: number
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/TradeWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const TradeWidgetContainer: React.FC = () => {
const sellTokenSymbol = decodeSymbol(encodedSellTokenSymbol || '')
const receiveTokenSymbol = decodeSymbol(decodeReceiveTokenSymbol || '')

const { sellToken: initialSellTokenDefaultNetwork, buyToken: initialReceiveTokenDefaultNetwork } =
const { sellToken: initialSellTokenDefaultNetwork, receiveToken: initialReceiveTokenDefaultNetwork } =
initialTokenSelection.networks[networkIdOrDefault] || {}

const sellTokenWithFallback = useMemo(
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useWalletConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BlockchainUpdatePrompt, WalletInfo } from 'api/wallet/WalletApi'

interface PendingStateObject extends WalletInfo {
pending: true
networkIdOrDefault: number
networkIdOrDefault: Network
Copy link
Contributor

@anxolin anxolin Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this true @W3stside @Velenir ?

Being network a enum, we assume that this value won't ever be any other network.
Or the logic is setting mainnet if we are in an Unknown network?

export enum Network {
  Mainnet = 1,
  Ropsten = 3,
  Rinkeby = 4,
  Goerli = 5,
  Kovan = 42,
  xDAI = 100,
}

}

const PendingState: PendingStateObject = {
Expand All @@ -33,7 +33,7 @@ const constructPendingState = ({ chainId, account, blockHeader }: BlockchainUpda
}

export const useWalletConnection = ():
| (WalletInfo & { pending: false; networkIdOrDefault: number })
| (WalletInfo & { pending: false; networkIdOrDefault: Network })
| PendingStateObject => {
const [walletInfo, setWalletInfo] = useSafeState<WalletInfo | null>(null)

Expand Down