diff --git a/packages/fast-usdc/src/exos/status-manager.js b/packages/fast-usdc/src/exos/status-manager.js index b3cfebf151d..84b5766d0b0 100644 --- a/packages/fast-usdc/src/exos/status-manager.js +++ b/packages/fast-usdc/src/exos/status-manager.js @@ -19,9 +19,6 @@ import { PendingTxStatus, TxStatus } from '../constants.js'; /** * @typedef {`pendingTx:${bigint}:${NobleAddress}`} PendingTxKey * The string template is for developer visibility but not meant to ever be parsed. - * - * @typedef {`seenTx:${string}:${EvmHash}`} SeenTxKey - * The string template is for developer visibility but not meant to ever be parsed. */ /** @@ -48,20 +45,6 @@ const pendingTxKeyOf = evidence => { return makePendingTxKey(forwardingAddress, amount); }; -/** - * Get the key for the seenTxs SetStore. - * - * The key is a composite but not meant to be parsable. - * - * @param {CctpTxEvidence} evidence - * @returns {SeenTxKey} - */ -const seenTxKeyOf = evidence => { - const { txHash, chainId } = evidence; - // chainId can't contain colon - return `seenTx:${chainId}:${txHash}`; -}; - /** * @typedef {{ * log?: LogFn; @@ -95,7 +78,7 @@ export const prepareStatusManager = ( valueShape: M.arrayOf(PendingTxShape), }); - /** @type {SetStore} */ + /** @type {SetStore} */ const seenTxs = zone.setStore('SeenTxs', { keyShape: M.string(), }); @@ -120,18 +103,18 @@ export const prepareStatusManager = ( * @param {PendingTxStatus} status */ const initPendingTx = (evidence, status) => { - const seenKey = seenTxKeyOf(evidence); - if (seenTxs.has(seenKey)) { - throw makeError(`Transaction already seen: ${q(seenKey)}`); + const { txHash } = evidence; + if (seenTxs.has(txHash)) { + throw makeError(`Transaction already seen: ${q(txHash)}`); } - seenTxs.add(seenKey); + seenTxs.add(txHash); appendToStoredArray( pendingTxs, pendingTxKeyOf(evidence), harden({ ...evidence, status }), ); - publishStatus(evidence.txHash, status); + publishStatus(txHash, status); }; /** @@ -226,8 +209,7 @@ export const prepareStatusManager = ( * @param {CctpTxEvidence} evidence */ hasBeenObserved(evidence) { - const seenKey = seenTxKeyOf(evidence); - return seenTxs.has(seenKey); + return seenTxs.has(evidence.txHash); }, /** diff --git a/packages/fast-usdc/test/exos/status-manager.test.ts b/packages/fast-usdc/test/exos/status-manager.test.ts index 5b61396fdc8..969af7530d5 100644 --- a/packages/fast-usdc/test/exos/status-manager.test.ts +++ b/packages/fast-usdc/test/exos/status-manager.test.ts @@ -106,18 +106,16 @@ test('cannot process same tx twice', t => { t.throws(() => statusManager.advance(evidence), { message: - 'Transaction already seen: "seenTx:1:0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702"', + 'Transaction already seen: "0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702"', }); t.throws(() => statusManager.observe(evidence), { message: - 'Transaction already seen: "seenTx:1:0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702"', + 'Transaction already seen: "0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702"', }); // new txHash should not throw t.notThrows(() => statusManager.advance({ ...evidence, txHash: '0xtest2' })); - // new chainId with existing txHash should not throw - t.notThrows(() => statusManager.advance({ ...evidence, chainId: 9999 })); }); test('isSeen checks if a tx has been processed', t => {