An AbstractProvider provides a base class for other sub-classes to implement the Provider API by normalizing input arguments and formatting output results as well as tracking events for consistent behaviour on an eventually-consistent network.

Extended by

Type parameters

Type parameterValue
CFetchRequest

Implements

Constructors

new AbstractProvider()

new AbstractProvider<C>(_network?, options?): AbstractProvider<C>

Create a new AbstractProvider connected to network, or use the various network detection capabilities to discover the Network if necessary.

Parameters

ParameterTypeDescription
_network?NetworkishThe network to connect to, or "any" to
options?AbstractProviderOptionsThe options to configure the provider.

Returns

AbstractProvider<C>

Source

providers/abstract-provider.ts:740

Accessors

connect

get connect(): FetchRequest[]

Get the list of connected FetchRequests.

Returns

FetchRequest[]

The list of connected FetchRequests.

Source

providers/abstract-provider.ts:839


destroyed

get destroyed(): boolean

If this provider has been destroyed using the destroy method.

Once destroyed, all resources are reclaimed, internal event loops and timers are cleaned up and no further requests may be sent to the provider.

Returns

boolean

Source

providers/abstract-provider.ts:2158


paused

get paused(): boolean

Whether the provider is currently paused.

A paused provider will not emit any events, and generally should not make any requests to the network, but that is up to sub-classes to manage.

Setting paused = true is identical to calling .pause(false), which will buffer any events that occur while paused until the provider is unpaused.

Returns

boolean

Whether the provider is paused.

Source

providers/abstract-provider.ts:2190


pollingInterval

get pollingInterval(): number

Get the polling interval.

Returns

number

The polling interval.

Source

providers/abstract-provider.ts:996


provider

get provider(): this

Returns this, to allow an AbstractProvider to implement the Contract Runner interface.

Returns

this

The provider instance.

Source

providers/abstract-provider.ts:1006

Methods

_clearTimeout()

_clearTimeout(timerId): void

Clear a timer created using the AbstractProvider._setTimeout | _setTimeout method.

Parameters

ParameterTypeDescription
timerIdnumberThe ID of the timer to clear.

Returns

void

Source

providers/abstract-provider.ts:1861


destroy()

destroy(): void

Sub-classes may use this to shutdown any sockets or release their resources and reject any pending requests.

Sub-classes must call super.destroy().

Returns

void

Implementation of

Provider.destroy

Source

providers/abstract-provider.ts:2167


getActiveRegions()

getActiveRegions(): Promise<Shard[]>

Get the active region shards based on the protocol expansion number.

Returns

Promise<Shard[]>

A promise that resolves to the active shards.

Source

providers/abstract-provider.ts:923


getActiveZones()

getActiveZones(): Promise<Zone[]>

Get the active zones for a shard based on the protocol expansion number.

Returns

Promise<Zone[]>

A promise that resolves to the active zones.

Source

providers/abstract-provider.ts:940


getLatestQiRate()

getLatestQiRate(zone, amt?): Promise<bigint>

Get the latest Qi rate for a zone.

Parameters

ParameterTypeDescription
zoneZoneThe zone to get the rate for.
amt?bigintThe amount to get the rate for. Default is 1

Returns

Promise<bigint>

A promise that resolves to the latest Qi rate.

Implementation of

Provider.getLatestQiRate

Source

providers/abstract-provider.ts:962


getLatestQuaiRate()

getLatestQuaiRate(zone, amt?): Promise<bigint>

Get the latest Quai rate for a zone.

Parameters

ParameterTypeDescription
zoneZoneThe zone to get the rate for.
amt?bigintThe amount in quais to get the rate for. Default is 1

Returns

Promise<bigint>

A promise that resolves to the latest Quai -> Qi rate for the given amount.

Implementation of

Provider.getLatestQuaiRate

Source

providers/abstract-provider.ts:881


getProtocolExpansionNumber()

getProtocolExpansionNumber(): Promise<number>

Get the protocol expansion number.

Returns

Promise<number>

A promise that resolves to the protocol expansion number.

Implementation of

Provider.getProtocolExpansionNumber

Source

providers/abstract-provider.ts:914


getQiRateAtBlock()

getQiRateAtBlock(
   zone, 
   blockTag, 
amt?): Promise<bigint>

Get the Qi rate at a specific block.

Parameters

ParameterTypeDescription
zoneZoneThe zone to get the rate for.
blockTagBlockTagThe block tag to get the rate at.
amt?bigintThe amount to get the rate for. Default is 1

Returns

Promise<bigint>

A promise that resolves to the Qi rate at the specified block.

Implementation of

Provider.getQiRateAtBlock

Source

providers/abstract-provider.ts:975


getQuaiRateAtBlock()

getQuaiRateAtBlock(
   zone, 
   blockTag, 
amt?): Promise<bigint>

Get the Quai rate at a specific block.

Parameters

ParameterTypeDescription
zoneZoneThe zone to get the rate for.
blockTagBlockTagThe block tag to get the rate at.
amt?bigintThe amount to get the rate for. Default is 1

Returns

Promise<bigint>

A promise that resolves to the Quai rate at the specified block.

Implementation of

Provider.getQuaiRateAtBlock

Source

providers/abstract-provider.ts:894


initialize()

initialize<U>(urls): Promise<void>

Initialize the URL map with the provided URLs.

Type parameters

Type parameterValue
Ustring[] | FetchRequest

Parameters

ParameterTypeDescription
urlsUThe URLs to initialize the map with.

Returns

Promise<void>

A promise that resolves when the map is initialized.

Source

providers/abstract-provider.ts:787


pause()

pause(dropWhilePaused?): void

Pause the provider. If dropWhilePaused, any events that occur while paused are dropped, otherwise all events will be emitted once the provider is unpaused.

Parameters

ParameterTypeDescription
dropWhilePaused?booleanWhether to drop events while paused.

Returns

void

Source

providers/abstract-provider.ts:2211


resume()

resume(): void

Resume the provider.

Returns

void

Source

providers/abstract-provider.ts:2240


shardFromHash()

shardFromHash(hash): Shard

Get the shard from a hash.

Parameters

ParameterTypeDescription
hashstringThe hash to get the shard from.

Returns

Shard

The shard.

Source

providers/abstract-provider.ts:860


zoneFromAddress()

zoneFromAddress(_address): Promise<Zone>

Get the zone from an address.

Parameters

ParameterTypeDescription
_addressAddressLikeThe address to get the zone from.

Returns

Promise<Zone>

A promise that resolves to the zone.

Source

providers/abstract-provider.ts:849


zoneFromHash()

zoneFromHash(hash): Zone

Get the zone from a hash.

Parameters

ParameterTypeDescription
hashstringThe hash to get the zone from.

Returns

Zone

The zone.

Source

providers/abstract-provider.ts:870