@gear-js/api
Version:
A JavaScript library that provides functionality to connect GEAR Component APIs.
97 lines (96 loc) • 3.71 kB
TypeScript
import type { Struct, U256, u8, Vec } from '@polkadot/types';
import type { H256 } from '@polkadot/types/interfaces';
import type { GearApi } from '../../GearApi';
import type { HexString } from '../../types';
/**
* The Message from GearEthBridge.MessageQueued event
*/
declare class GearEthBridgeMessage {
/** Unique identifier for the message */
readonly nonce: bigint;
/** Source address where the message originated */
readonly source: `0x${string}`;
/** Destination address where the message should be delivered */
readonly destination: `0x${string}`;
/** The actual message data as hex-encoded bytes */
readonly payload: `0x${string}`;
constructor(msg: GearEthBridgeMessageQueuedMessageCodec);
}
interface GearEthBridgeMessageQueuedMessageCodec extends Struct {
readonly nonce: U256;
readonly source: H256;
readonly destination: H256;
readonly payload: Vec<u8>;
}
/**
* Type mapping for all Gear-Ethereum bridge events and their parameters.
*
* Each event type maps to an array of its parameter types for type safety.
*/
interface GearEthBridgeEventNames {
/** Grandpa validator's keys set was hashed and set in storage at first block of the last session in the era. */
AuthoritySetHashChanged: [HexString];
/** Authority set hash was reset. */
AuthoritySetReset: [];
/** Optimistically, single-time called event defining that pallet got initialized */
BridgeInitialized: [];
/** Bridge was paused and temporary doesn't process any incoming requests. */
BridgePaused: [];
/** Bridge was unpaused and from now on processes any incoming requests. */
BridgeUnpaused: [];
/** A new message was queued for bridging. */
MessageQueued: {
/** Enqueued message. */
message: GearEthBridgeMessage;
/** Hash of the enqueued message. */
hash: HexString;
};
/** Merkle root of the queue changed: new messages queued within the block. */
QueueMerkleRootChanged: {
/** Queue identifier. */
queueId: bigint;
/** Merkle root of the queue. */
root: HexString;
};
/** Queue was reset. */
QueueReset: [];
}
/**
* Arguments for finding a bridge message by its nonce.
*/
interface FindByNonceArgs {
/** The nonce of the message to search for */
nonce: bigint;
/** The block number to start searching from */
fromBlock: number;
/** Optional block number to stop searching at */
toBlock?: number;
}
/**
* Event monitoring and filtering utilities for GearEthBridge pallet.
*/
export declare class GearEthBridgeEvents {
private _api;
constructor(_api: GearApi);
/**
* Subscribe to a specific bridge event type.
*
* @param name - The name of the event to subscribe to
* @param callback - Function called when the event occurs
* @returns Unsubscribe function to stop listening for events
*/
on<K extends keyof GearEthBridgeEventNames>(name: K, callback: (...args: unknown[]) => void | Promise<void>): () => Promise<void>;
/**
* Find a bridge message by its nonce within a specified block range.
*
* This method subscribes to blocks starting from the specified block and searches
* for a message with the given nonce. It will continue searching until either:
* - The message is found
* - The toBlock limit is reached (if specified)
*
* @param args - Search parameters including nonce and block range
* @returns The found message or null if not found within the range
*/
findGearEthBridgeMessageByNonce({ nonce, fromBlock, toBlock, }: FindByNonceArgs): Promise<GearEthBridgeMessage | null>;
}
export {};