Skip to content

Commit

Permalink
feat: TxStatus const for StatusManager states
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Nov 12, 2024
1 parent 3b799b8 commit 1376020
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/fast-usdc/src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Status values for FastUSDC.
*
* @enum {(typeof TxStatus)[keyof typeof TxStatus]}
*/
export const TxStatus = /** @type {const} */ ({
/** tx was observed but not advanced */
Observed: 'OBSERVED',
/** IBC transfer is initiated */
Advanced: 'ADVANCED',
/** settlement for matching advance received and funds dispersed */
Settled: 'SETTLED',
});
harden(TxStatus);

/**
* Status values for the StatusManager.
*
* @enum {(typeof PendingTxStatus)[keyof typeof PendingTxStatus]}
*/
export const PendingTxStatus = /** @type {const} */ ({
/** tx was observed but not advanced */
Observed: 'OBSERVED',
/** IBC transfer is initiated */
Advanced: 'ADVANCED',
});
harden(PendingTxStatus);
12 changes: 12 additions & 0 deletions packages/fast-usdc/test/constants.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { TxStatus, PendingTxStatus } from '../src/constants.js';

const { values } = Object;

test('PendingTxStatus is a subset of TxStatus', t => {
const txStatuses = values(TxStatus);
const difference = values(PendingTxStatus).filter(
status => !txStatuses.includes(status),
);
t.deepEqual(difference, [], 'PendingTxStatus value(s) not in TxStatus');
});

0 comments on commit 1376020

Please sign in to comment.