Rename type
This commit is contained in:
parent
b8eea08f4d
commit
60ead1ba49
|
@ -3,7 +3,7 @@ import { IAddressResolver } from "./address-resolver";
|
||||||
import { CompositeAddressResolver } from "./CompositeAddressResolver";
|
import { CompositeAddressResolver } from "./CompositeAddressResolver";
|
||||||
import { ENSAddressResolver } from "./ENSAddressResolver";
|
import { ENSAddressResolver } from "./ENSAddressResolver";
|
||||||
|
|
||||||
export type ENSReverseCache = Record<string, string>;
|
export type ResolvedAddresses = Record<string, string>;
|
||||||
|
|
||||||
// Create and configure the main resolver
|
// Create and configure the main resolver
|
||||||
const _mainResolver = new CompositeAddressResolver();
|
const _mainResolver = new CompositeAddressResolver();
|
||||||
|
@ -14,14 +14,14 @@ export const mainResolver: IAddressResolver = _mainResolver;
|
||||||
export const batchPopulate = async (
|
export const batchPopulate = async (
|
||||||
provider: BaseProvider,
|
provider: BaseProvider,
|
||||||
addresses: string[]
|
addresses: string[]
|
||||||
): Promise<ENSReverseCache> => {
|
): Promise<ResolvedAddresses> => {
|
||||||
const solvers: Promise<string | undefined>[] = [];
|
const solvers: Promise<string | undefined>[] = [];
|
||||||
for (const a of addresses) {
|
for (const a of addresses) {
|
||||||
solvers.push(mainResolver.resolveAddress(provider, a));
|
solvers.push(mainResolver.resolveAddress(provider, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
const results = await Promise.all(solvers);
|
const results = await Promise.all(solvers);
|
||||||
const cache: ENSReverseCache = {};
|
const cache: ResolvedAddresses = {};
|
||||||
for (let i = 0; i < results.length; i++) {
|
for (let i = 0; i < results.length; i++) {
|
||||||
const r = results[i];
|
const r = results[i];
|
||||||
if (r === undefined) {
|
if (r === undefined) {
|
||||||
|
|
|
@ -18,11 +18,11 @@ import { ProcessedTransaction } from "../types";
|
||||||
import { FeeDisplay } from "./useFeeToggler";
|
import { FeeDisplay } from "./useFeeToggler";
|
||||||
import { formatValue } from "../components/formatter";
|
import { formatValue } from "../components/formatter";
|
||||||
import ETH2USDValue from "../components/ETH2USDValue";
|
import ETH2USDValue from "../components/ETH2USDValue";
|
||||||
import { ENSReverseCache } from "../api/address-resolver";
|
import { ResolvedAddresses } from "../api/address-resolver";
|
||||||
|
|
||||||
type TransactionItemProps = {
|
type TransactionItemProps = {
|
||||||
tx: ProcessedTransaction;
|
tx: ProcessedTransaction;
|
||||||
ensCache?: ENSReverseCache;
|
ensCache?: ResolvedAddresses;
|
||||||
selectedAddress?: string;
|
selectedAddress?: string;
|
||||||
feeDisplay: FeeDisplay;
|
feeDisplay: FeeDisplay;
|
||||||
priceMap: Record<BlockTag, BigNumber>;
|
priceMap: Record<BlockTag, BigNumber>;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { JsonRpcProvider } from "@ethersproject/providers";
|
import { JsonRpcProvider } from "@ethersproject/providers";
|
||||||
import { ProcessedTransaction } from "./types";
|
import { ProcessedTransaction } from "./types";
|
||||||
import { batchPopulate, ENSReverseCache } from "./api/address-resolver";
|
import { batchPopulate, ResolvedAddresses } from "./api/address-resolver";
|
||||||
|
|
||||||
export const useENSCache = (
|
export const useENSCache = (
|
||||||
provider?: JsonRpcProvider,
|
provider?: JsonRpcProvider,
|
||||||
page?: ProcessedTransaction[]
|
page?: ProcessedTransaction[]
|
||||||
) => {
|
) => {
|
||||||
const [reverseCache, setReverseCache] = useState<ENSReverseCache>();
|
const [reverseCache, setReverseCache] = useState<ResolvedAddresses>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!provider || !page) {
|
if (!provider || !page) {
|
||||||
|
|
Loading…
Reference in New Issue