Skip to main content

Module: Helpers

Pure functions in eth-hooks

Helpers

asyncSome

asyncSome<T>(arr, predicate): Promise<undefined | T>

Summary

js .some function that can be used with async predicates

Type parameters

Name
T

Parameters

NameType
arrT[]
predicate(item: T) => Promise<boolean>

Returns

Promise<undefined | T>

Defined in

src/functions/asyncHelpers.ts:11


isEthersProvider

isEthersProvider(providerBase): boolean

Summary

Is it a ethers compatable provider, used by EthersModalConnector and useEthersProvider

Parameters

NameType
providerBaseunknown

Returns

boolean

Defined in

src/functions/ethersHelpers.ts:23


parseProviderOrSigner

parseProviderOrSigner(providerOrSigner): Promise<undefined | Readonly<TEthersAdaptor>>

Summary

Parse TEthersProviderOrSigner to TEthersUser Get the TEthersUser from a provider or signer

Parameters

NameTypeDescription
providerOrSignerundefined | TEthersProviderOrSignerTEthersProviderOrSigner

Returns

Promise<undefined | Readonly<TEthersAdaptor>>

TProviderAndSigner

Defined in

src/functions/parseProviderOrSigner.ts:62

Misc

asyncForEach

asyncForEach<T>(array, callback): Promise<void>

Type parameters

Name
T

Parameters

NameType
arrayT[]
callback(item: T, index: number) => Promise<void>

Returns

Promise<void>

Defined in

src/functions/asyncHelpers.ts:18


signerHasNetwork

signerHasNetwork(signer): boolean

Parameters

NameType
signerundefined | Signer

Returns

boolean

Defined in

src/functions/ethersHelpers.ts:35


asEthersAdaptor

asEthersAdaptor(ethersContext): Readonly<TEthersAdaptor>

Parameters

NameType
ethersContextIEthersContext

Returns

Readonly<TEthersAdaptor>

Defined in

src/functions/ethersHelpers.ts:42


isValidEthersContext

isValidEthersContext(ethersContext): boolean

Parameters

NameType
ethersContextundefined | IEthersContext

Returns

boolean

Defined in

src/functions/ethersHelpers.ts:51


isValidEthersAdaptor

isValidEthersAdaptor(ethersAdaptor): boolean

Parameters

NameType
ethersAdaptorundefined | TEthersAdaptor

Returns

boolean

Defined in

src/functions/ethersHelpers.ts:63


isAdaptorEqual

isAdaptorEqual(adaptor1, adaptor2): boolean

Parameters

NameType
adaptor1undefined | TEthersAdaptor
adaptor2undefined | TEthersAdaptor

Returns

boolean

Defined in

src/functions/ethersHelpers.ts:80


ethersOverride

ethersOverride(context, options): Readonly<TEthersAdaptor>

Parameters

NameType
contextIEthersContext
optionsTOverride

Returns

Readonly<TEthersAdaptor>

Defined in

src/functions/hookHelpers.ts:17


checkUpdateOptions

checkUpdateOptions(update): void

Summary

Hook that will verify update options are valid

Parameters

NameTypeDescription
updateTUpdateOptions<any>Options for updating to be verified

Returns

void

Defined in

src/functions/hookHelpers.ts:37


mergeDefaultOverride

mergeDefaultOverride(...overrides): TOverride

Parameters

NameType
...overridesDeepPartial<TOverride>[]

Returns

TOverride

Defined in

src/functions/hookHelpers.ts:55


mergeDefaultUpdateOptions

mergeDefaultUpdateOptions<GResult>(...overrides): TUpdateOptions<GResult>

Type parameters

NameType
GResultany

Parameters

NameType
...overridesDeepPartial<TUpdateOptions<GResult>>[]

Returns

TUpdateOptions<GResult>

Defined in

src/functions/hookHelpers.ts:65


setContextOverride

setContextOverride(adaptor, enabled?): TOverride

Parameters

NameTypeDefault value
adaptorundefined | TEthersAdaptorundefined
enabledbooleantrue

Returns

TOverride

Defined in

src/functions/hookHelpers.ts:83


processQueryOptions

processQueryOptions<GResult>(options): Omit<QueryObserverOptions<GResult, any, GResult, GResult, QueryKey>, "refetchInterval" | "notifyOnChangeProps" | "notifyOnChangePropsExclusions" | "useErrorBoundary" | "refetchOnWindowFocus" | "refetchOnMount" | "refetchOnReconnect"> & { refetchOnWindowFocus?: boolean | "always" ; refetchOnMount?: boolean | "always" ; refetchOnReconnect?: boolean | "always" } & { refetchInterval?: number }

Type parameters

Name
GResult

Parameters

NameType
optionsTUpdateOptions<GResult>

Returns

Omit<QueryObserverOptions<GResult, any, GResult, GResult, QueryKey>, "refetchInterval" | "notifyOnChangeProps" | "notifyOnChangePropsExclusions" | "useErrorBoundary" | "refetchOnWindowFocus" | "refetchOnMount" | "refetchOnReconnect"> & { refetchOnWindowFocus?: boolean | "always" ; refetchOnMount?: boolean | "always" ; refetchOnReconnect?: boolean | "always" } & { refetchInterval?: number }

Defined in

src/functions/hookHelpers.ts:87


TRequiredKeys

Ƭ TRequiredKeys: Object

Type declaration

NameType
namespacestring
keystring

Defined in

src/functions/keyHelpers.ts:10


TKeyTypes

Ƭ TKeyTypes: Object

Type declaration

NameType
provider?string
adaptor?string
contract?string
contractFunc?string

Defined in

src/functions/keyHelpers.ts:15


providerKey

providerKey(providerOrSigner): Record<"signer" | "provider", string>

Get a react-query query key fo ethers provider

Parameters

NameType
providerOrSignerundefined | TEthersProviderOrSigner

Returns

Record<"signer" | "provider", string>

Defined in

src/functions/keyHelpers.ts:27


adaptorKey

adaptorKey(adaptor): Partial<Record<"provider" | "adaptor", string>>

Get a react-query query key

Parameters

NameType
adaptorundefined | TEthersAdaptor

Returns

Partial<Record<"provider" | "adaptor", string>>

Defined in

src/functions/keyHelpers.ts:62


eventKey

eventKey(m): string

Get a react-query query key

Parameters

NameType
mEvent | TypedEvent<Result>

Returns

string

Defined in

src/functions/keyHelpers.ts:79


contractKey

contractKey(contract): Partial<Record<"provider" | "contract", string>>

Get a react-query query key

Parameters

NameType
contractundefined | BaseContract

Returns

Partial<Record<"provider" | "contract", string>>

Defined in

src/functions/keyHelpers.ts:88


contractFuncKey

contractFuncKey(contract, func): Record<"contractFunc", string>

Get a react-query query key

Parameters

NameType
contractundefined | BaseContract
funcundefined | (...args: any[]) => Promise<any>

Returns

Record<"contractFunc", string>

Defined in

src/functions/keyHelpers.ts:115


invalidateCache

invalidateCache(queryClient, namespace, otherKeys?, variables?): void

Parameters

NameType
queryClientQueryClient
namespacestring
otherKeysTKeyTypes & { key?: string }
variablesRecord<string, any>

Returns

void

Defined in

src/functions/keyHelpers.ts:135


logQueryCache

logQueryCache(queryClient, namespace, otherKeys?, variables?): void

Parameters

NameType
queryClientQueryClient
namespacestring
otherKeysTKeyTypes & { key?: string }
variablesRecord<string, any>

Returns

void

Defined in

src/functions/keyHelpers.ts:144


isProvider

isProvider(providerOrSigner): boolean

Parameters

NameType
providerOrSignerundefined | TEthersProviderOrSigner

Returns

boolean

Defined in

src/functions/parseProviderOrSigner.ts:9