import { BigNumber } from '@ethersproject/bignumber'; import { TransactionReceipt } from '@ethersproject/abstract-provider'; import { core } from 'optics-ts-interface'; import { OpticsContext } from '..'; import { AnnotatedDispatch, AnnotatedUpdate, AnnotatedProcess, AnnotatedLifecycleEvent } from '../events'; export declare type ParsedMessage = { from: number; sender: string; nonce: number; destination: number; recipient: string; body: string; }; export declare type OpticsStatus = { status: MessageStatus; events: AnnotatedLifecycleEvent[]; }; export declare enum MessageStatus { Dispatched = 0, Included = 1, Relayed = 2, Processed = 3 } export declare enum ReplicaMessageStatus { None = 0, Proven = 1, Processed = 2 } export declare type EventCache = { homeUpdate?: AnnotatedUpdate; replicaUpdate?: AnnotatedUpdate; process?: AnnotatedProcess; }; /** * Parse a serialized Optics message from raw bytes. * * @param message * @returns */ export declare function parseMessage(message: string): ParsedMessage; /** * A deserialized Optics message. */ export declare class OpticsMessage { readonly dispatch: AnnotatedDispatch; readonly message: ParsedMessage; readonly home: core.Home; readonly replica: core.Replica; readonly context: OpticsContext; protected cache: EventCache; constructor(context: OpticsContext, dispatch: AnnotatedDispatch); /** * The receipt of the TX that dispatched this message */ get receipt(): TransactionReceipt; /** * Instantiate one or more messages from a receipt. * * @param context the {@link OpticsContext} object to use * @param nameOrDomain the domain on which the receipt was logged * @param receipt the receipt * @returns an array of {@link OpticsMessage} objects */ static fromReceipt(context: OpticsContext, nameOrDomain: string | number, receipt: TransactionReceipt): OpticsMessage[]; /** * Instantiate EXACTLY one message from a receipt. * * @param context the {@link OpticsContext} object to use * @param nameOrDomain the domain on which the receipt was logged * @param receipt the receipt * @returns an array of {@link OpticsMessage} objects * @throws if there is not EXACTLY 1 dispatch in the receipt */ static singleFromReceipt(context: OpticsContext, nameOrDomain: string | number, receipt: TransactionReceipt): OpticsMessage; /** * Instantiate one or more messages from a tx hash. * * @param context the {@link OpticsContext} object to use * @param nameOrDomain the domain on which the receipt was logged * @param receipt the receipt * @returns an array of {@link OpticsMessage} objects * @throws if there is no receipt for the TX */ static fromTransactionHash(context: OpticsContext, nameOrDomain: string | number, transactionHash: string): Promise; /** * Instantiate EXACTLY one message from a transaction has. * * @param context the {@link OpticsContext} object to use * @param nameOrDomain the domain on which the receipt was logged * @param receipt the receipt * @returns an array of {@link OpticsMessage} objects * @throws if there is no receipt for the TX, or if not EXACTLY 1 dispatch in * the receipt */ static singleFromTransactionHash(context: OpticsContext, nameOrDomain: string | number, transactionHash: string): Promise; /** * Get the Home `Update` event associated with this message (if any) * * @returns An {@link AnnotatedUpdate} (if any) */ getHomeUpdate(): Promise; /** * Get the Replica `Update` event associated with this message (if any) * * @returns An {@link AnnotatedUpdate} (if any) */ getReplicaUpdate(): Promise; /** * Get the Replica `Process` event associated with this message (if any) * * @returns An {@link AnnotatedProcess} (if any) */ getProcess(startBlock?: number): Promise; /** * Get all lifecycle events associated with this message * * @returns An array of {@link AnnotatedLifecycleEvent} objects */ events(): Promise; /** * Returns the timestamp after which it is possible to process this message. * * Note: return the timestamp after which it is possible to process messages * within an Update. The timestamp is most relevant during the time AFTER the * Update has been Relayed to the Replica and BEFORE the message in question * has been Processed. * * Considerations: * - the timestamp will be 0 if the Update has not been relayed to the Replica * - after the Update has been relayed to the Replica, the timestamp will be * non-zero forever (even after all messages in the Update have been * processed) * - if the timestamp is in the future, the challenge period has not elapsed * yet; messages in the Update cannot be processed yet * - if the timestamp is in the past, this does not necessarily mean that all * messages in the Update have been processed * * @returns The timestamp at which a message can confirm */ confirmAt(): Promise; /** * Retrieve the replica status of this message. * * @returns The {@link ReplicaMessageStatus} corresponding to the solidity * status of the message. */ replicaStatus(): Promise; /** * Checks whether the message has been delivered. * * @returns true if processed, else false. */ delivered(): Promise; /** * Returns a promise that resolves when the message has been delivered. * * WARNING: May never resolve. Oftern takes hours to resolve. * * @param opts Polling options. */ wait(opts?: { pollTime?: number; }): Promise; /** * The domain from which the message was sent */ get from(): number; /** * The domain from which the message was sent. Alias for `from` */ get origin(): number; /** * The identifier for the sender of this message */ get sender(): string; /** * The domain nonce for this message */ get nonce(): number; /** * The destination domain for this message */ get destination(): number; /** * The identifer for the recipient for this message */ get recipient(): string; /** * The message body */ get body(): string; /** * The keccak256 hash of the message body */ get bodyHash(): string; /** * The hash of the transaction that dispatched this message */ get transactionHash(): string; /** * The messageHash committed to the tree in the Home contract. */ get leaf(): string; /** * The index of the leaf in the contract. */ get leafIndex(): BigNumber; /** * The destination and nonceof this message. */ get destinationAndNonce(): BigNumber; /** * The committed root when this message was dispatched. */ get committedRoot(): string; } //# sourceMappingURL=OpticsMessage.d.ts.map