UNPKG

@nomad-xyz/sdk

Version:
204 lines 6.6 kB
import { Dispatch } from '../messages/types'; import { MessageBackend } from './backend'; import * as config from '@nomad-xyz/configuration'; import { NomadContext } from '..'; /** * Filter that is used to fetch data from GoldSky */ export declare type MessageFilter = { committedRoot: string; messageHash: string; transactionHash: string; }; /** * GoldSky NomadMessage representation */ export declare type GoldSkyMessage = { committed_root: string; destination_and_nonce: string; destination_domain_id: number; destination_domain_name: string; dispatch_block: string; dispatch_tx: string; dispatched_at: string; id: string; leaf_index: string; message: string; message__action__amount: string; message__action__details_hash: string; message__action__to: string; message__action__type: string; message__token__domain: string; message__token__id: string; message_body: string; message_hash: string; message_type: string; new_root: string; nonce: number; old_root: string; origin_domain_id: number; origin_domain_name: string; recipient_address: string; sender_address: string; signature: string; update_block?: string; update_chain_id?: number; update_tx?: string; updated_at?: string; relay_block?: string; relay_chain_id?: number; relay_tx?: string; relayed_at?: string; process_block?: string; process_tx?: string; processed_at?: string; }; /** * GoldSky backend for NomadMessage */ export declare class GoldSkyBackend extends MessageBackend { env: string; protected _secret: string; context: NomadContext; messageCache: Map<string, GoldSkyMessage>; dispatchTxToMessageHash: Map<string, string[]>; constructor(env: string, secret: string, context: NomadContext); /** * Resolves current context used with the backend * @returns Nomad context */ getContext(): NomadContext; /** * Checks whether the backend environment is supported * @param environment name of the environment as string */ static checkEnvironment(environment: string): void; /** * Returns default secret for Goldsky * @returns secret as a string */ static defaultSecret(): string; /** * Default GoldSky backend for the environment * @param environment name of the environment as string * @param context Nomad context to be used with the backend * @returns */ static default(environment?: string | config.NomadConfig, context?: NomadContext): GoldSkyBackend; /** * Fills filter with default values required for fetching a message from backend * * @returns Filled event filter */ static fillFilter(f: Partial<MessageFilter>): MessageFilter; /** * Prepares a URI that is used for fetching messages * * @returns uri */ get uri(): string; /** * Prepares headers for connecting to hasura */ get headers(): { 'content-type': string; 'x-goldsky-secret': string; }; /** * Prepares Dispatch events from backend's internal message representation * * @returns Dispatch events assiciated with transaction (if any) */ getDispatches(tx: string, limit?: number): Promise<Dispatch[] | undefined>; /** * Prepares a Dispatch event from backend's internal message representation * * @returns Dispatch event assiciated with message hash (if any) */ getDispatchByMessageHash(messageHash: string): Promise<Dispatch | undefined>; /** * Stores message into internal cache */ storeMessage(m: GoldSkyMessage): void; /** * Get the message representation associated with this message (if any) * by message hash * * @returns A message representation (if any) */ getMessage(messageHash: string, forceFetch?: boolean): Promise<GoldSkyMessage | undefined>; /** * Get the message representation associated with this message (if any) * by dispatch transaction * * @returns A message representation (if any) */ getMessagesByTx(tx: string, limit?: number, forceFetch?: boolean): Promise<GoldSkyMessage[] | undefined>; /** * Get the `Dispatch` transaction hash associated with this message (if any) * * @returns A dispatch tx (if any) */ dispatchTx(messageHash: string): Promise<string | undefined>; /** * Get the `Relay` transaction hash associated with this message (if any) * * @returns A relay tx (if any) */ relayTx(messageHash: string): Promise<string | undefined>; /** * Get the `Update` transaction hash associated with this message (if any) * * @returns A update tx (if any) */ updateTx(messageHash: string): Promise<string | undefined>; /** * Get the `Process` transaction hash associated with this message (if any) * * @returns A relay tx (if any) */ processTx(messageHash: string): Promise<string | undefined>; /** * Get the `Dispatch` transaction hash associated with this message (if any) * * @returns A dispatch tx (if any) */ dispatchedAt(messageHash: string): Promise<Date | undefined>; /** * Get the `Relay` transaction hash associated with this message (if any) * * @returns A relay tx (if any) */ relayedAt(messageHash: string): Promise<Date | undefined>; /** * Get the `Update` transaction hash associated with this message (if any) * * @returns A update tx (if any) */ updatedAt(messageHash: string): Promise<Date | undefined>; /** * Get the `Process` transaction hash associated with this message (if any) * * @returns A relay tx (if any) */ processedAt(messageHash: string): Promise<Date | undefined>; /** * Gets destination domain for a specific message * @param messageHash message hash identifier * @returns destination domain id */ destinationDomainId(messageHash: string): Promise<number | undefined>; /** * Get message hash associated with this message (if any) * * @returns A message hash (if any) */ getFirstMessageHash(tx: string): Promise<string | undefined>; /** * Fetches internal message from backend * * @returns Internal message representation (if any) */ fetchMessages(f: Partial<MessageFilter>, limit?: number): Promise<GoldSkyMessage[] | undefined>; } //# sourceMappingURL=goldsky.d.ts.map