Skip to main content

Module: Models

Types and constants to make it easier to interact with ethers.

Interfaces

EthersAppContext

TCreateEthersModalConnector

Ƭ TCreateEthersModalConnector: (id?: string) => TEthersModalConnector | undefined

Type declaration

▸ (id?): TEthersModalConnector | undefined

Summary

A callback type that returns a EthersModalConnector

✏️ Notes
  • can be used by components that need to give a connector to openModal
  • id is the identifier of the provider: See docs
Parameters
NameType
id?string
Returns

TEthersModalConnector | undefined

Defined in

src/models/ethersAppContextTypes.ts:17


Models

TBasicContract

Ƭ TBasicContract: Object

Summary

Describes the basic structure of each contract

Type declaration

NameType
contractNamestring
addressstring
abi?Readonly<Record<string, any>[]>

Defined in

src/models/contractTypes.ts:18


TBasicContractDeployment

Ƭ TBasicContractDeployment: Object

Summary

Describes a basic contract data record. A record of key:chainId. value:{address, chainId}

Index signature

[chainId: number]: { chainId: number ; address: string }

Defined in

src/models/contractTypes.ts:30


TExternalContractsAddressMap

Ƭ TExternalContractsAddressMap: z.infer<typeof externalContractAddressMap>

{chainId: {contract: address}}, contains an record of contracts

Summary

A type for external contracts

  • it is a record of contract names and their deployed address
  • this data type is used by ContractsAppContext to connect to external contracts

Defined in

src/models/contractTypes.ts:118


TDeployedHardhatContractsJson

Ƭ TDeployedHardhatContractsJson: z.infer<typeof deployedHardhatContractsJsonSchema>

Summary

Describes the structure of hardhat_contracts.json

  • {chainIds: { networkNames: {contracts} }}, contains an record of contracts
  • Used by useContractLoader

Defined in

src/models/contractTypesHardhat.ts:11


TNetworkInfo

Ƭ TNetworkInfo: Object

Summary

A type that describes the basics of a network for applications. e.g. mainnet, ropsten, rinkeby, etc.

Type declaration

NameType
namestring
chainIdnumber
rpcUrlstring
faucet?string
blockExplorerstring
price?number
gasPrice?number

Defined in

src/models/networkTypes.ts:7


TEthersProvider

Ƭ TEthersProvider: JsonRpcProvider | Web3Provider | StaticJsonRpcProvider

Summary

A union of various ethers providers for ease of use and maximum flexiblity

✏️ Notes

Used by eth-hooks, eth-components and scaffold-eth-typescript

Defined in

src/models/providerTypes.ts:19


TEthersProviderOrSigner

Ƭ TEthersProviderOrSigner: JsonRpcProvider | Web3Provider | StaticJsonRpcProvider | Signer | JsonRpcSigner | Wallet | VoidSigner

Summary

A union of various providers and signers in ethers to give maximum flexibility

Defined in

src/models/providerTypes.ts:27


TEthersSigner

Ƭ TEthersSigner: Signer | JsonRpcSigner | Wallet | VoidSigner

Summary

A union of various providers in ethers to give maximum flexibility

Defined in

src/models/providerTypes.ts:42


TAbstractProvider

Ƭ TAbstractProvider: Provider

Summary

A union of abstract, non initalizable providers, used by some functions

Defined in

src/models/providerTypes.ts:50


TypedEventFilter

Ƭ TypedEventFilter<_EventArgsArray, _EventArgsObject>: EventFilter

Summary

An generic extension of EventFilter that is used by TypedEvent. It allows for typed events to be returned

Type parameters

NameType
_EventArgsArrayextends any[]
_EventArgsObjectextends Record<string, any>

Defined in

src/models/providerTypes.ts:58


TypedEvent

Ƭ TypedEvent<EventArgs>: Event & { args: EventArgs }

Summary

An generic extension of Event. It types the the arguments and return values of the contract event to be used in typescript.

Type parameters

NameType
EventArgsextends Result

Defined in

src/models/providerTypes.ts:69


DeepPartial

Ƭ DeepPartial<T>: { [P in keyof T]?: DeepPartial<T[P]> }

Summary

Similar to partial int typescript but allows deep partial types.

Type parameters

Name
T

Defined in

src/models/utilityTypes.ts:7

Misc

const_web3DialogClosedByUser

Const const_web3DialogClosedByUser: "Modal closed by user"

Defined in

src/models/constants/common.ts:1


const_web3DialogUserRejected

Const const_web3DialogUserRejected: "Error: User Rejected"

Defined in

src/models/constants/common.ts:2


keyNamespace

Const keyNamespace: Object

Type declaration

NameType
network"network"
signer"signer"
contracts"contracts"
state"state"

Defined in

src/models/constants/keyNamespace.ts:1


TBaseContractExtended

Ƭ TBaseContractExtended<GContractNames>: BaseContract & { contractName: GContractNames }

Summary

ethers.BaseContract extension. This is the exactly the same as ethers.BaseContract, but with a type guard for the contract name: BaseContract & { contractName: 'nameofContract' };

Type parameters

NameType
GContractNamesextends string

Defined in

src/models/contractAppContextTypes.ts:10


TContractConnectFunc

Ƭ TContractConnectFunc<GContract>: (address: string, signerOrProvider: Signer | Provider) => GContract

Type parameters

NameType
GContractextends BaseContract

Type declaration

▸ (address, signerOrProvider): GContract

A function that connects to a contract. Used by TContractConnectorBase. This is usually something generated by typechain and is used to connect to contract on the blockchain.

Parameters
NameType
addressstring
signerOrProviderSigner | Provider
Returns

GContract

Defined in

src/models/contractAppContextTypes.ts:15


TContractConnectorBase

Ƭ TContractConnectorBase<GContract>: Readonly<{ connect: TContractConnectFunc<GContract> ; abi: Readonly<Record<string, any>[]> }>

Summary

This types describes a base for a connnector. A contract connector would be a a conception that is the minimum required to connect to a contract. It has a connector function that returns a typed contract and abi that has contract information.

Type parameters

NameType
GContractextends BaseContract

Defined in

src/models/contractAppContextTypes.ts:24


TContractConnector

Ƭ TContractConnector<GContractNames, GContract>: Readonly<{ contractName: GContractNames ; config: TBasicContractDeployment } & TContractConnectorBase<GContract>>

Summary

This type descripts a connector that has enough information to create a contract in a chain. The contractName is required to use a group of connectors to create a connection of available contracts for the app.

✏️ Notes

Type parameters

NameType
GContractNamesextends string
GContractextends TBaseContractExtended<GContractNames>

Defined in

src/models/contractAppContextTypes.ts:37


TConnectorList

Ƭ TConnectorList<GContractNames, GContracts>: { [contractName in GContractNames]: TContractConnector<GContractNames, GContracts> }

Summary

A Record of typed connectors that can be used to create a contract.

✏️ Notes

Type parameters

NameType
GContractNamesextends string
GContractsextends TBaseContractExtended<GContractNames>

Defined in

src/models/contractAppContextTypes.ts:55


TTypedContract

Ƭ TTypedContract<GContractNames, GAppContractConnectorList>: GAppContractConnectorList extends { [key in GContractNames]: Object } ? TypedContract : never

Summary

A type that infers contract type (extended from BaseContract) based on connectors and contractName. For example DAI from { DAI: { connect: ... } }. If the contractName is not found, it will return a BaseContract

✏️ Notes
  • used by contractsConextFactory

Type parameters

NameType
GContractNamesextends string
GAppContractConnectorListGAppContractConnectorList

Defined in

src/models/contractAppContextTypes.ts:66


TContractsByName

Ƭ TContractsByName<GContractNames, GContracts>: { [contractName in GContractNames]: { [chainId in number]: GContracts | undefined } }

Summary

A utility type for typed contracts by name and then by chain

✏️ Notes

Type parameters

NameType
GContractNamesextends string
GContractsextends TBaseContractExtended<GContractNames>

Defined in

src/models/contractAppContextTypes.ts:82


TContractsByChainId

Ƭ TContractsByChainId<GContractNames, GContracts>: { [chainId in number]: { [contractName in GContractNames]: GContracts | undefined } }

Summary

A utility type for typed contracts by chain and then by name

✏️ Notes

Type parameters

NameType
GContractNamesextends string
GContractsextends TBaseContractExtended<GContractNames>

Defined in

src/models/contractAppContextTypes.ts:94


TAppContractsContext

Ƭ TAppContractsContext<GContractNames, GContracts>: Object

Describes the current ContractsContext for the app used by the context created by contractContextFactory

Type parameters

NameType
GContractNamesextends string
GContractsextends TBaseContractExtended<GContractNames>

Type declaration

NameType
contractConnectorsTConnectorList<GContractNames, GContracts>
contractsByNameTContractsByName<GContractNames, GContracts>
contractsByChainIdTContractsByChainId<GContractNames, GContracts>

Defined in

src/models/contractAppContextTypes.ts:106


TContractDeploymentMap

Ƭ TContractDeploymentMap: Object

Summary

Contracts by contract name

Index signature

[contractName: string]: { config: TBasicContractDeployment }

Defined in

src/models/contractTypes.ts:54


contractDeploymentMapSchema

Const contractDeploymentMapSchema: ZodType<TContractDeploymentMap>

Summary

Zod Schema for TContractDeploymentMap

Defined in

src/models/contractTypes.ts:63


TContractMapWithAbi

Ƭ TContractMapWithAbi: Object

Summary

Contracts by contract name, used by eth-hooks to connect and load contracts

  • A record of key:{contract names}, values: Hardhat contract json
  • includes chain id

Index signature

[contractName: string]: { config: TBasicContractDeployment ; abi: Readonly<Record<string, any>[]> }

Defined in

src/models/contractTypes.ts:83


contractMapWithAbiSchema

Const contractMapWithAbiSchema: ZodType<TContractMapWithAbi>

Summary

Zod Schema for TContractMapWithAbi

Defined in

src/models/contractTypes.ts:95


externalContractAddressMap

Const externalContractAddressMap: ZodRecord<ZodEffects<ZodUnion<[ZodString, ZodNumber]>, number, string | number>, ZodRecord<ZodString, ZodString>>

Summary

Zod Schema for TExternalContractsAddressMap

Defined in

src/models/contractTypes.ts:124


TForgeTransactionData

Ƭ TForgeTransactionData: z.infer<typeof forgeTransactionDataSchema>

Defined in

src/models/contractTypesForge.ts:3


forgeTransactionDataSchema

Const forgeTransactionDataSchema: ZodObject<{ type: ZodString ; from: ZodString ; gas: ZodString ; value: ZodString ; data: ZodString ; nonce: ZodString ; accessList: ZodArray<ZodString, "many"> }, "strip", ZodTypeAny, { type: string ; from: string ; gas: string ; value: string ; data: string ; nonce: string ; accessList: string[] }, { type: string ; from: string ; gas: string ; value: string ; data: string ; nonce: string ; accessList: string[] }>

Defined in

src/models/contractTypesForge.ts:4


TForgeTransaction

Ƭ TForgeTransaction: Object

Type declaration

NameType
hashstring | null
transactionType"CREATE" | Omit<string, "CREATE">
contractNamestring
contractAddressstring
functionstring | null
argumentsstring | null
transactionTForgeTransactionData

Defined in

src/models/contractTypesForge.ts:14


forgeTransactionSchema

Const forgeTransactionSchema: ZodType<TForgeTransaction>

Defined in

src/models/contractTypesForge.ts:24


TForgeBroadcastJson

Ƭ TForgeBroadcastJson: Object

Type declaration

NameType
transactionsTForgeTransaction[]

Defined in

src/models/contractTypesForge.ts:34


TForgeDeploymentBroadcastCollection

Ƭ TForgeDeploymentBroadcastCollection: Object

Index signature

[chainId: number]: TForgeBroadcastJson

Defined in

src/models/contractTypesForge.ts:38


forgeDeploymentBroadcastCollectionSchema

Const forgeDeploymentBroadcastCollectionSchema: ZodType<TForgeDeploymentBroadcastCollection>

Defined in

src/models/contractTypesForge.ts:42


deployedHardhatContractsJsonSchema

Const deployedHardhatContractsJsonSchema: ZodRecord<ZodEffects<ZodUnion<[ZodString, ZodNumber]>, number, string | number>, ZodArray<ZodObject<{ name: ZodString ; chainId: ZodString ; contracts: ZodRecord<ZodString, ZodObject<{ address: ZodString ; abi: ZodOptional<ZodArray<ZodAny, "many">> }, "strip", ZodTypeAny, { address: string ; abi: undefined | any[] }, { address: string ; abi: undefined | any[] }>> }, "strip", ZodTypeAny, { name: string ; chainId: string ; contracts: Record<string, { abi?: any[] | undefined; address: string; }> }, { name: string ; chainId: string ; contracts: Record<string, { abi?: any[] | undefined; address: string; }> }>, "many">>

Summary

Zod Schema for TBasicContractMap

Defined in

src/models/contractTypesHardhat.ts:17


const_blockNumberIntervalShort

Const const_blockNumberIntervalShort: DeepPartial<TUpdateOptions>

Summary

An constant for block number interval of 10 blocks

Defined in

src/models/hookTypes.ts:11


const_blockNumberIntervalMedium

Const const_blockNumberIntervalMedium: DeepPartial<TUpdateOptions>

Summary

An constant for block number interval of 50 blocks

Defined in

src/models/hookTypes.ts:17


const_blockNumberIntervalLong

Const const_blockNumberIntervalLong: DeepPartial<TUpdateOptions>

Summary

An constant for block number interval of 250 blocks

Defined in

src/models/hookTypes.ts:23


TQueryOptions

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

Type parameters

Name
GResult

Defined in

src/models/hookTypes.ts:25


TUpdateOptions

Ƭ TUpdateOptions<GResult>: Object

Summary

Options for hooks that describe the behviour of updates. By default, depending on the hook, it will update every block.

✏️ Notes

The following options are available:

  • interval: interval in blocknumber to update in (default 1) see TUpdateOptions.blockNumberInterval
  • polling: in ms, should be over 10000ms. This is set by TUpdateOptions.query.refetchInterval

Type parameters

NameType
GResultany

Type declaration

NameTypeDescription
blockNumberIntervalnumber | undefinedThe interval in blocknumber for the hook to update in (default 1)
refetchInterval?number-
query?TQueryOptions<GResult>-

Defined in

src/models/hookTypes.ts:50


TOverride

Ƭ TOverride: Object

Summary

Ethers Provider options. By default, the context provider is used by the hook. If you want to use a different provider, you can:

  • pass in an TEthersAdaptor to override the provider
  • give the alternateContextKey for a secondary context provider.
✏️ Notes

Adaptor

  • To create a adaptor from a provider/signer see useGetEthersAdaptorFromSignerOrProvider
  • You need to set adaptorEnabled to true

Alternate Context Key

  • For more info on alternateContextKey, see TEthersAppContextProps and web3-react docs.

Type declaration

NameTypeDescription
adaptorEnabledbooleanAn enable override adaptor (ethers provider) for this hook
adaptorTEthersAdaptor | undefinedThe alternate adaptor to use. See TEthersAdaptor
alternateContextKey?stringThe alternate context key to use. See TEthersAppContextProps

Defined in

src/models/hookTypes.ts:73


defaultOverride

defaultOverride(): TOverride

An helper to create the default override settings for hooks

Returns

TOverride

Defined in

src/models/hookTypes.ts:93


defaultUpdateOptions

defaultUpdateOptions<GResult>(): TUpdateOptions<GResult>

A helper to create default update options for hooks

Type parameters

NameType
GResultany

Returns

TUpdateOptions<GResult>

Defined in

src/models/hookTypes.ts:105


THookResult

Ƭ THookResult<T>: [result: T, update: Function, status: QueryStatus]

Summary

This type describes the tuple that is returned by most hooks

  1. result: the result of the hook
  2. update: a callback will refresh the results of hook manually
  3. status: the status of the query. From react-query: 'idle' | 'loading' | 'error' | 'success'. You can use this for UX purposes, see QueryStatus.

Type parameters

Name
T

Defined in

src/models/hookTypes.ts:124

Type Definition

TEthersAdaptor

Ƭ TEthersAdaptor: Object

Summary

Essentially a object that allows interaction with the network:

  • provider signer,

Type declaration

NameType
signer?TEthersSigner
provider?TEthersProvider
chainId?number
account?string

Defined in

src/models/ethersAppContextTypes.ts:52