Skip to content

Commit

Permalink
chore: revert OBSERVED states
Browse files Browse the repository at this point in the history
also fix a comment
  • Loading branch information
Chris-Hibbert committed Mar 3, 2025
1 parent 6ece736 commit e6802b2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
4 changes: 4 additions & 0 deletions packages/fast-usdc/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @enum {(typeof TxStatus)[keyof typeof TxStatus]}
*/
export const TxStatus = /** @type {const} */ ({
/** tx was observed but not advanced */
Observed: 'OBSERVED',
/** IBC transfer is initiated */
Advancing: 'ADVANCING',
/** IBC transfer is complete */
Expand Down Expand Up @@ -34,6 +36,8 @@ export const TerminalTxStatus = {
* @enum {(typeof PendingTxStatus)[keyof typeof PendingTxStatus]}
*/
export const PendingTxStatus = /** @type {const} */ ({
/** tx was observed but not advanced */
Observed: 'OBSERVED',
/** IBC transfer is initiated */
Advancing: 'ADVANCING',
/** IBC transfer failed (timed out) */
Expand Down
14 changes: 7 additions & 7 deletions packages/fast-usdc/test/exos/settler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ test('happy path: disburse to LPs; StatusManager removes tx', async t => {
await eventLoopIteration();
const { storage } = t.context;
t.deepEqual(storage.getDeserialized(`fun.txns.${cctpTxEvidence.txHash}`), [
{ evidence: cctpTxEvidence, status: undefined },
{ evidence: cctpTxEvidence, status: 'OBSERVED' },
{ status: 'ADVANCING' },
{ status: 'ADVANCED' },
{ split: expectedSplit, status: 'DISBURSED' },
Expand Down Expand Up @@ -363,7 +363,7 @@ test('slow path: forward to EUD; remove pending tx', async t => {
accounts.settlement.transferVResolver.resolve(undefined);
await eventLoopIteration();
t.deepEqual(storage.getDeserialized(`fun.txns.${cctpTxEvidence.txHash}`), [
{ evidence: cctpTxEvidence, status: undefined },
{ evidence: cctpTxEvidence, status: 'OBSERVED' },
{ risksIdentified: ['TOO_LARGE_AMOUNT'], status: 'ADVANCE_SKIPPED' },
{ status: 'FORWARDED' },
]);
Expand Down Expand Up @@ -439,7 +439,7 @@ test('skip advance: forward to EUD; remove pending tx', async t => {
);
const { storage } = t.context;
t.deepEqual(storage.getDeserialized(`fun.txns.${cctpTxEvidence.txHash}`), [
{ evidence: cctpTxEvidence, status: undefined },
{ evidence: cctpTxEvidence, status: 'OBSERVED' },
{ status: 'ADVANCE_SKIPPED', risksIdentified: ['TOO_LARGE_AMOUNT'] },
{ status: 'FORWARDED' },
]);
Expand Down Expand Up @@ -514,7 +514,7 @@ test('Settlement for unknown transaction (minted early)', async t => {
accounts.settlement.transferVResolver.resolve(undefined);
await eventLoopIteration();
t.deepEqual(storage.getDeserialized(`fun.txns.${evidence.txHash}`), [
{ evidence, status: undefined },
{ evidence, status: 'OBSERVED' },
{ status: 'FORWARDED' },
]);
});
Expand Down Expand Up @@ -681,7 +681,7 @@ test('Settlement for Advancing transaction (advance succeeds)', async t => {
simulate.finishAdvance(cctpTxEvidence, true);
await eventLoopIteration();
t.deepEqual(storage.getDeserialized(`fun.txns.${cctpTxEvidence.txHash}`), [
{ evidence: cctpTxEvidence, status: undefined },
{ evidence: cctpTxEvidence, status: 'OBSERVED' },
{ status: 'ADVANCING' },
{ status: 'ADVANCED' },
{ split: expectedSplit, status: 'DISBURSED' },
Expand Down Expand Up @@ -745,7 +745,7 @@ test('Settlement for Advancing transaction (advance fails)', async t => {
accounts.settlement.transferVResolver.resolve(undefined);
await eventLoopIteration();
t.deepEqual(storage.getDeserialized(`fun.txns.${cctpTxEvidence.txHash}`), [
{ evidence: cctpTxEvidence, status: undefined },
{ evidence: cctpTxEvidence, status: 'OBSERVED' },
{ status: 'ADVANCING' },
{ status: 'ADVANCE_FAILED' },
{ status: 'FORWARDED' },
Expand Down Expand Up @@ -795,7 +795,7 @@ test('slow path, and forward fails (terminal state)', async t => {
]);

t.deepEqual(storage.getDeserialized(`fun.txns.${evidence.txHash}`), [
{ evidence, status: undefined },
{ evidence, status: 'OBSERVED' },
{ status: 'FORWARD_FAILED' },
]);
});
Expand Down
8 changes: 4 additions & 4 deletions packages/fast-usdc/test/exos/status-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test('ADVANCED transactions are published to vstorage', async t => {

const { storage } = t.context;
t.deepEqual(storage.getDeserialized(`fun.txns.${evidence.txHash}`), [
{ evidence, status: undefined },
{ evidence, status: 'OBSERVED' },
{ status: 'ADVANCING' },
]);
});
Expand Down Expand Up @@ -92,7 +92,7 @@ test('ADVANCE_SKIPPED transactions are published to vstorage', async t => {

const { storage } = t.context;
t.deepEqual(storage.getDeserialized(`fun.txns.${evidence.txHash}`), [
{ evidence, status: undefined },
{ evidence, status: 'OBSERVED' },
{ status: 'ADVANCE_SKIPPED', risksIdentified: ['RISK1'] },
]);
});
Expand Down Expand Up @@ -213,7 +213,7 @@ test('advanceOutcome transitions to ADVANCED and ADVANCE_FAILED', async t => {
]);
await eventLoopIteration();
t.deepEqual(storage.getDeserialized(`fun.txns.${e1.txHash}`), [
{ evidence: e1, status: undefined },
{ evidence: e1, status: 'OBSERVED' },
{ status: 'ADVANCING' },
{ status: 'ADVANCED' },
]);
Expand All @@ -227,7 +227,7 @@ test('advanceOutcome transitions to ADVANCED and ADVANCE_FAILED', async t => {
]);
await eventLoopIteration();
t.deepEqual(storage.getDeserialized(`fun.txns.${e2.txHash}`), [
{ evidence: e2, status: undefined },
{ evidence: e2, status: 'OBSERVED' },
{ status: 'ADVANCING' },
{ status: 'ADVANCE_FAILED' },
]);
Expand Down
8 changes: 4 additions & 4 deletions packages/fast-usdc/test/fast-usdc.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ test.serial('STORY01: advancing happy path for 100 USDC', async t => {
const sent1 = await cust1.sendFast(t, 108_000_000n, 'osmo1234advanceHappy');
await transmitTransferAck(); // ack IBC transfer for advance
const expectedTransitions = [
{ evidence: sent1, status: undefined },
{ evidence: sent1, status: 'OBSERVED' },
{ status: 'ADVANCING' },
{ status: 'ADVANCED' },
];
Expand Down Expand Up @@ -841,7 +841,7 @@ test.serial('withdraw all liquidity while ADVANCING', async t => {
await mint(sent);
await utils.transmitTransferAck();
t.like(storage.getDeserialized(`fun.txns.${sent.txHash}`), [
{ evidence: sent, status: undefined },
{ evidence: sent, status: 'OBSERVED' },
{ status: 'ADVANCING' },
{ status: 'ADVANCED' },
{ status: 'DISBURSED' },
Expand Down Expand Up @@ -1025,7 +1025,7 @@ test.serial('Settlement for unknown transaction (operator down)', async t => {
await eventLoopIteration();

t.deepEqual(storage.getDeserialized(`fun.txns.${sent.txHash}`), [
{ evidence: sent, status: undefined },
{ evidence: sent, status: 'OBSERVED' },
{ status: 'FORWARDED' },
]);
});
Expand Down Expand Up @@ -1064,7 +1064,7 @@ test.serial('mint received while ADVANCING', async t => {

const split = makeFeeTools(feeConfig).calculateSplit(usdc.make(5_000_000n));
t.deepEqual(storage.getDeserialized(`fun.txns.${sent.txHash}`), [
{ evidence: sent, status: undefined },
{ evidence: sent, status: 'OBSERVED' },
{ status: 'ADVANCING' },
{ status: 'ADVANCED' },
{ split, status: 'DISBURSED' },
Expand Down

0 comments on commit e6802b2

Please sign in to comment.