Skip to main content

EVMChainEventsBrowser

Defined in: atomiq-chain-evm/src/evm/events/EVMChainEventsBrowser.ts:47

EVM on-chain event handler for front-end systems without access to fs, uses WS or long-polling to subscribe, might lose out on some events if the network is unreliable, front-end systems should take this into consideration and not rely purely on events

Extended by​

Implements​

Constructors​

Constructor​

new EVMChainEventsBrowser(
chainInterface,
evmSwapContract,
evmSpvVaultContract,
pollIntervalSeconds): EVMChainEventsBrowser;

Defined in: atomiq-chain-evm/src/evm/events/EVMChainEventsBrowser.ts:110

Parameters​

ParameterTypeDefault value
chainInterfaceEVMChainInterfaceundefined
evmSwapContractEVMSwapContractundefined
evmSpvVaultContractEVMSpvVaultContract<any>undefined
pollIntervalSecondsnumber5

Returns​

EVMChainEventsBrowser

Methods​

init()​

init(noAutomaticPoll?): Promise<void>;

Defined in: atomiq-chain-evm/src/evm/events/EVMChainEventsBrowser.ts:617

Initializes the chains event listener, by default this initiates a websocket events subscription or HTTP polling for new events.

Parameters​

ParameterTypeDescription
noAutomaticPoll?booleanWhen this flag is passed the listener doesn't initiate the websocket events subscription or HTTP polling, instead it relies on the implementor calling the ChainEvents.poll to fetch new events

Returns​

Promise<void>

Implementation of​

ChainEvents.init


poll()​

poll(lastState?): Promise<object[]>;

Defined in: atomiq-chain-evm/src/evm/events/EVMChainEventsBrowser.ts:433

Triggers a single poll on the events instance, usually ran automatically, but should be called manually when initiated with noAutomaticPoll=true

Parameters​

ParameterTypeDescription
lastState?object[]The current state of the chain events

Returns​

Promise<object[]>

The new state that should be saved, persisted and passed to the subsequent poll() call

Implementation of​

ChainEvents.poll


registerListener()​

registerListener(cbk): void;

Defined in: atomiq-chain-evm/src/evm/events/EVMChainEventsBrowser.ts:646

Registers a new listener to listen for on-chain events

Parameters​

ParameterTypeDescription
cbkEventListener<EVMSwapData>

Returns​

void

Implementation of​

ChainEvents.registerListener


stop()​

stop(): Promise<void>;

Defined in: atomiq-chain-evm/src/evm/events/EVMChainEventsBrowser.ts:631

Stops the event listener's polling and websocket subscription

Returns​

Promise<void>

Implementation of​

ChainEvents.stop


unregisterListener()​

unregisterListener(cbk): boolean;

Defined in: atomiq-chain-evm/src/evm/events/EVMChainEventsBrowser.ts:653

Unregisters a previously registered events listener, returning true if success, false if failed

Parameters​

ParameterTypeDescription
cbkEventListener<EVMSwapData>

Returns​

boolean

Implementation of​

ChainEvents.unregisterListener


processEvents()​

protected processEvents(events, currentBlock?): Promise<void>;

Defined in: atomiq-chain-evm/src/evm/events/EVMChainEventsBrowser.ts:274

Processes event as received from the chain, parses it & calls event listeners

Parameters​

ParameterTypeDescription
events( | TypedEventLog< | TypedContractEvent<InputTuple, OutputTuple, OutputObject> | TypedContractEvent<InputTuple, OutputTuple, OutputObject> | TypedContractEvent<InputTuple, OutputTuple, OutputObject>> | TypedEventLog< | TypedContractEvent<InputTuple, OutputTuple, OutputObject> | TypedContractEvent<InputTuple, OutputTuple, OutputObject> | TypedContractEvent<InputTuple, OutputTuple, OutputObject> | TypedContractEvent<InputTuple, OutputTuple, OutputObject> | TypedContractEvent<InputTuple, OutputTuple, OutputObject>>)[]
currentBlock?Block

Returns​

Promise<void>