Skip to content

Commit

Permalink
refactor: be optimistic to empty reverse result (#10375)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleBill committed Aug 14, 2023
1 parent 6007c73 commit ded15fe
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ HistoryTableRow.displayName = 'HistoryTableRow'
export interface HistoryTableRowUIProps extends HistoryTableRowProps {
selectedChainId: Web3Helper.ChainIdAll
formattedType: string
domain?: string
domain?: string | null
}

export const HistoryTableRowUI = memo<HistoryTableRowUIProps>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ interface WalletStateBarUIProps {
provider?: Web3Helper.ProviderDescriptorAll
name?: string
address?: string
domain?: string
domain?: string | null
openConnectWalletDialog(): void
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export interface WalletInfoUIProps {
onSettingClick: () => void
onEditClick: () => void
hideSettings: boolean
domain?: string
domain?: string | null
formatDomainName?: (domain: string, size?: number) => string | undefined
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createContext, useContext } from 'react'
export interface FeedOwnerOptions {
address: string
/** ENS, RNS or SOL, etc */
name?: string
name?: string | null
ownerDisplay: string
}
export const FeedOwnerContext = createContext<FeedOwnerOptions>(null!)
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-hooks/base/src/useLookupAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useWeb3Others } from './useWeb3Others.js'

export function useLookupAddress<T extends NetworkPluginID>(
pluginID?: T,
domain?: string,
domain?: string | null,
expectedChainId?: Web3Helper.Definition[T]['ChainId'],
) {
const { chainId } = useChainContext({ chainId: expectedChainId })
Expand Down
9 changes: 4 additions & 5 deletions packages/web3-hooks/base/src/useReverseAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { useWeb3State } from './useWeb3State.js'
export function useReverseAddress<T extends NetworkPluginID>(pluginID?: T, address?: string) {
const { NameService } = useWeb3State(pluginID)

const isBad = !address || !NameService
return useQuery<string | undefined>({
return useQuery({
queryKey: ['reverse', address],
enabled: !isBad,
enabled: !!NameService?.reverse,
queryFn: async () => {
if (isBad) return
return NameService.reverse?.(address)
if (!address) return null
return NameService!.reverse!(address) || null
},
})
}
2 changes: 1 addition & 1 deletion packages/web3-providers/src/Web3/Base/apis/OthersAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class OthersAPI_Base<ChainId, SchemaType, ProviderType, NetworkType, Tran
formatTokenId(id?: string | undefined, size?: number | undefined): string {
throw new Error('Method not implemented.')
}
formatDomainName(domain?: string | undefined, size?: number | undefined): string {
formatDomainName(domain?: string | null | undefined, size?: number | undefined): string {
throw new Error('Method not implemented.')
}
formatSchemaType(schema: SchemaType): string {
Expand Down

0 comments on commit ded15fe

Please sign in to comment.