diff --git a/connect/src/protocols/cctpTransfer.ts b/connect/src/protocols/cctpTransfer.ts index b2a0c1c18..b9c2ce396 100644 --- a/connect/src/protocols/cctpTransfer.ts +++ b/connect/src/protocols/cctpTransfer.ts @@ -553,12 +553,11 @@ export class CircleTransfer const initTx = receipt.originTxs[receipt.originTxs.length - 1]!; const xfermsg = await CircleTransfer.getTransferMessage(_fromChain, initTx.txid); - receipt = { + yield { ...receipt, attestation: { id: xfermsg }, state: TransferState.SourceFinalized, } as SourceFinalizedTransferReceipt; - yield receipt; } if (isSourceFinalized(receipt)) { @@ -575,12 +574,11 @@ export class CircleTransfer receipt.attestation.id as WormholeMessageId, leftover(start, timeout), ); - receipt = { + yield { ...receipt, attestation: { id: receipt.attestation.id, attestation: vaa }, state: TransferState.Attested, } as AttestedTransferReceipt; - yield receipt; } } } @@ -598,18 +596,17 @@ export class CircleTransfer if (txStatus && txStatus.globalTx?.destinationTx?.txHash) { const { chainId, txHash } = txStatus.globalTx.destinationTx; - receipt = { + yield { ...receipt, destinationTxs: [{ chain: toChain(chainId) as DC, txid: txHash }], state: TransferState.DestinationFinalized, } as CompletedTransferReceipt; - yield receipt; } // Fall back to asking the destination chain if this VAA has been redeemed // assuming we have the full attestation if (isAttested(receipt)) { - receipt = { + yield { ...receipt, state: (await CircleTransfer.isTransferComplete( _toChain, @@ -618,7 +615,6 @@ export class CircleTransfer ? TransferState.DestinationFinalized : TransferState.Attested, } as AttestedTransferReceipt; - yield receipt; } } } diff --git a/connect/src/protocols/tokenTransfer.ts b/connect/src/protocols/tokenTransfer.ts index b83ce24c7..875b6afc4 100644 --- a/connect/src/protocols/tokenTransfer.ts +++ b/connect/src/protocols/tokenTransfer.ts @@ -595,8 +595,7 @@ export class TokenTransfer txid, leftover(start, timeout), ); - receipt = { ...receipt, state: TransferState.SourceFinalized, attestation: { id: msg } }; - yield receipt; + yield { ...receipt, state: TransferState.SourceFinalized, attestation: { id: msg } }; } // If the source is finalized, we need to fetch the signed attestation @@ -606,8 +605,7 @@ export class TokenTransfer if (!receipt.attestation.id) throw "Attestation id required to fetch attestation"; const { id } = receipt.attestation; const attestation = await TokenTransfer.getTransferVaa(wh, id, leftover(start, timeout)); - receipt = { ...receipt, attestation: { id, attestation }, state: TransferState.Attested }; - yield receipt; + yield { ...receipt, attestation: { id, attestation }, state: TransferState.Attested }; } // First try to grab the tx status from the API