Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new TransferState that represents a refunded transfer #663

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions connect/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum TransferState {
SourceFinalized, // Source chain transactions are finalized or whenever we have a message id
InReview, // Transfer is in review (e.g. held by governor)
Attested, // VAA or Circle Attestation is available
Refunded, // Transfer failed and was refunded on the source chain
DestinationInitiated, // Attestation is submitted to destination chain
DestinationQueued, // Transfer is queued on destination chain
DestinationFinalized, // Destination transaction is finalized
Expand Down Expand Up @@ -70,6 +71,14 @@ export interface AttestedTransferReceipt<AT, SC extends Chain = Chain, DC extend
attestation: Required<AT>;
}

export interface RefundedTransferReceipt<AT, SC extends Chain = Chain, DC extends Chain = Chain>
extends BaseTransferReceipt<SC, DC> {
state: TransferState.Refunded;
originTxs: TransactionId<SC>[];
refundTxs: TransactionId<SC>[];
attestation: AT;
}

export interface RedeemedTransferReceipt<AT, SC extends Chain = Chain, DC extends Chain = Chain>
extends BaseTransferReceipt<SC, DC> {
state: TransferState.DestinationInitiated;
Expand Down Expand Up @@ -131,6 +140,12 @@ export function isAttested<AT>(
return receipt.state === TransferState.Attested;
}

export function isRefunded<AT>(
receipt: TransferReceipt<AT>,
): receipt is RefundedTransferReceipt<AT> {
return receipt.state === TransferState.Refunded;
}

export function isRedeemed<AT>(
receipt: TransferReceipt<AT>,
): receipt is RedeemedTransferReceipt<AT> {
Expand Down Expand Up @@ -160,6 +175,7 @@ export type TransferReceipt<AT, SC extends Chain = Chain, DC extends Chain = Cha
| SourceFinalizedTransferReceipt<AT, SC, DC>
| InReviewTransferReceipt<AT, SC, DC>
| AttestedTransferReceipt<AT, SC, DC>
| RefundedTransferReceipt<AT, SC, DC>
| RedeemedTransferReceipt<AT, SC, DC>
| DestinationQueuedTransferReceipt<AT, SC, DC>
| CompletedTransferReceipt<AT, SC, DC>;
Expand Down
Loading