diff --git a/connect/src/wormholeTransfer.ts b/connect/src/wormholeTransfer.ts index 60e954e8f9..ee8a73c5ca 100644 --- a/connect/src/wormholeTransfer.ts +++ b/connect/src/wormholeTransfer.ts @@ -45,7 +45,6 @@ interface BaseTransferReceipt; } @@ -54,51 +53,50 @@ export interface SourceInitiatedTransferReceipt< SC extends Chain, DC extends Chain, > extends BaseTransferReceipt { + state: TransferState.SourceInitiated; originTxs: TransactionId[]; } export interface SourceFinalizedTransferReceipt< PN extends ProtocolName, SC extends Chain, DC extends Chain, -> extends SourceInitiatedTransferReceipt { +> extends BaseTransferReceipt { + state: TransferState.SourceFinalized; + originTxs: TransactionId[]; attestation: AttestationReceipt; } export interface AttestedTransferReceipt< PN extends ProtocolName, SC extends Chain, DC extends Chain, -> extends SourceFinalizedTransferReceipt { +> extends BaseTransferReceipt { + state: TransferState.Attested; + originTxs: TransactionId[]; attestation: Required>; } export interface CompletedTransferReceipt< PN extends ProtocolName, SC extends Chain, DC extends Chain, -> extends AttestedTransferReceipt { +> extends BaseTransferReceipt { + state: TransferState.DestinationInitiated; + originTxs: TransactionId[]; + attestation: Required>; destinationTxs: TransactionId[]; } export function hasReachedState( - receipt: TransferReceipt, + receipt: TransferReceipt, state: TS, -): receipt is TransferReceipt { +): boolean { return receipt.state === state; } -export type TransferReceipt< - PN extends ProtocolName, - SC extends Chain = Chain, - DC extends Chain = Chain, - TS extends TransferState = TransferState, -> = TS extends TransferState.DestinationInitiated - ? CompletedTransferReceipt - : TS extends TransferState.Attested - ? AttestedTransferReceipt - : TS extends TransferState.SourceFinalized - ? SourceFinalizedTransferReceipt - : TS extends TransferState.SourceInitiated - ? SourceInitiatedTransferReceipt - : never; +export type TransferReceipt = + | SourceFinalizedTransferReceipt + | SourceFinalizedTransferReceipt + | AttestedTransferReceipt + | CompletedTransferReceipt; // Quote with optional relayer fees if the transfer // is requested to be automatic