Skip to content

Commit 63639e3

Browse files
dbransmcmire
authored andcommitted
docs: document TransactionStatus enum (#4380)
## Explanation Met with @matthewwalsh0 who took the time to explain each status. ## References ## Changelog ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate
1 parent e2b05d9 commit 63639e3

File tree

1 file changed

+57
-13
lines changed
  • packages/transaction-controller/src

1 file changed

+57
-13
lines changed

packages/transaction-controller/src/types.ts

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -450,39 +450,83 @@ export type SendFlowHistoryEntry = {
450450
};
451451

452452
/**
453-
* The status of the transaction. Each status represents the state of the transaction internally
454-
* in the wallet. Some of these correspond with the state of the transaction on the network, but
455-
* some are wallet-specific.
453+
* Represents the status of a transaction within the wallet.
454+
* Each status reflects the state of the transaction internally,
455+
* with some statuses corresponding to the transaction's state on the network.
456+
*
457+
* The typical transaction lifecycle follows this state machine:
458+
* unapproved -> approved -> signed -> submitted -> FINAL_STATE
459+
* where FINAL_STATE is one of: confirmed, failed, dropped, or rejected.
456460
*/
457461
export enum TransactionStatus {
462+
/**
463+
* The initial state of a transaction before user approval.
464+
*/
458465
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
459466
// eslint-disable-next-line @typescript-eslint/naming-convention
460-
approved = 'approved',
461-
/** @deprecated Determined by the clients using the transaction type. No longer used. */
467+
unapproved = 'unapproved',
468+
469+
/**
470+
* The transaction has been approved by the user but is not yet signed.
471+
* This status is usually brief but may be longer for scenarios like hardware wallet usage.
472+
*/
462473
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
463474
// eslint-disable-next-line @typescript-eslint/naming-convention
464-
cancelled = 'cancelled',
475+
approved = 'approved',
476+
477+
/**
478+
* The transaction is signed and in the process of being submitted to the network.
479+
* This status is typically short-lived but can be longer for certain cases, such as smart transactions.
480+
*/
465481
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
466482
// eslint-disable-next-line @typescript-eslint/naming-convention
467-
confirmed = 'confirmed',
483+
signed = 'signed',
484+
485+
/**
486+
* The transaction has been submitted to the network and is awaiting confirmation.
487+
*/
468488
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
469489
// eslint-disable-next-line @typescript-eslint/naming-convention
470-
dropped = 'dropped',
490+
submitted = 'submitted',
491+
492+
/**
493+
* The transaction has been successfully executed and confirmed on the blockchain.
494+
* This is a final state.
495+
*/
471496
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
472497
// eslint-disable-next-line @typescript-eslint/naming-convention
473-
failed = 'failed',
498+
confirmed = 'confirmed',
499+
500+
/**
501+
* The transaction encountered an error during execution on the blockchain and failed.
502+
* This is a final state.
503+
*/
474504
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
475505
// eslint-disable-next-line @typescript-eslint/naming-convention
476-
rejected = 'rejected',
506+
failed = 'failed',
507+
508+
/**
509+
* The transaction was superseded by another transaction, resulting in its dismissal.
510+
* This is a final state.
511+
*/
477512
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
478513
// eslint-disable-next-line @typescript-eslint/naming-convention
479-
signed = 'signed',
514+
dropped = 'dropped',
515+
516+
/**
517+
* The transaction was rejected by the user and not processed further.
518+
* This is a final state.
519+
*/
480520
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
481521
// eslint-disable-next-line @typescript-eslint/naming-convention
482-
submitted = 'submitted',
522+
rejected = 'rejected',
523+
524+
/**
525+
* @deprecated This status is no longer used.
526+
*/
483527
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
484528
// eslint-disable-next-line @typescript-eslint/naming-convention
485-
unapproved = 'unapproved',
529+
cancelled = 'cancelled',
486530
}
487531

488532
/**

0 commit comments

Comments
 (0)