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 287ea01 commit d759c8c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 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
4 changes: 2 additions & 2 deletions packages/fast-usdc/src/exos/transaction-feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export const stateShape = {

/**
* transaction-feed receives attestations from Oracles, records their
* evidence, and when enough oracles agree, (if no risks are identified)
* publishes the results for the advancer to act on.
* evidence, and when enough oracles agree, publishes the results for the
* advancer to act on.
*
* @param {Zone} zone
* @param {ZCF} zcf
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 @@ -303,7 +303,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 @@ -370,7 +370,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 @@ -445,7 +445,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 @@ -520,7 +520,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 @@ -574,7 +574,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 @@ -638,7 +638,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 @@ -688,7 +688,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 @@ -626,7 +626,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 @@ -835,7 +835,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 @@ -1019,7 +1019,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 @@ -1058,7 +1058,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 d759c8c

Please sign in to comment.