From 041cf831c8c3df06adc20b52ee92ac70896b7b7c Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 17 Dec 2024 11:51:16 -0800 Subject: [PATCH] refactor: attest by operatorId --- packages/fast-usdc/src/exos/operator-kit.js | 4 ++-- .../fast-usdc/src/exos/transaction-feed.js | 18 ++++-------------- .../test/exos/transaction-feed.test.ts | 16 ---------------- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/packages/fast-usdc/src/exos/operator-kit.js b/packages/fast-usdc/src/exos/operator-kit.js index 310b10ad0a9..7a98af3da5a 100644 --- a/packages/fast-usdc/src/exos/operator-kit.js +++ b/packages/fast-usdc/src/exos/operator-kit.js @@ -12,7 +12,7 @@ const trace = makeTracer('TxOperator'); /** * @typedef {object} OperatorPowers - * @property {(evidence: CctpTxEvidence, operatorKit: OperatorKit) => void} attest + * @property {(evidence: CctpTxEvidence, operatorId: string) => void} attest */ /** @@ -103,7 +103,7 @@ export const prepareOperatorKit = (zone, staticPowers) => submitEvidence(evidence) { const { state } = this; !state.disabled || Fail`submitEvidence for disabled operator`; - state.powers.attest(evidence, this.facets); + state.powers.attest(evidence, state.operatorId); }, /** @returns {OperatorStatus} */ getStatus() { diff --git a/packages/fast-usdc/src/exos/transaction-feed.js b/packages/fast-usdc/src/exos/transaction-feed.js index 40d456ef9ea..b991c570022 100644 --- a/packages/fast-usdc/src/exos/transaction-feed.js +++ b/packages/fast-usdc/src/exos/transaction-feed.js @@ -18,7 +18,7 @@ export const INVITATION_MAKERS_DESC = 'oracle operator invitation'; const TransactionFeedKitI = harden({ operatorPowers: M.interface('Transaction Feed Admin', { - attest: M.call(CctpTxEvidenceShape, M.any()).returns(), + attest: M.call(CctpTxEvidenceShape, M.string()).returns(), }), creator: M.interface('Transaction Feed Creator', { // TODO narrow the return shape to OperatorKit @@ -121,21 +121,11 @@ export const prepareTransactionFeedKit = (zone, zcf) => { * NB: the operatorKit is responsible for * * @param {CctpTxEvidence} evidence - * @param {OperatorKit} operatorKit + * @param {string} operatorId */ - attest(evidence, operatorKit) { + attest(evidence, operatorId) { const { pending } = this.state; - trace( - 'submitEvidence', - operatorKit.operator.getStatus().operatorId, - evidence, - ); - const { operatorId } = operatorKit.operator.getStatus(); - - // TODO should this verify that the operator is one made by this exo? - // This doesn't work... - // operatorKit === operators.get(operatorId) || - // Fail`operatorKit mismatch`; + trace('submitEvidence', operatorId, evidence); // TODO validate that it's a valid for Fast USDC before accepting // E.g. that the `recipientAddress` is the FU settlement account and that diff --git a/packages/fast-usdc/test/exos/transaction-feed.test.ts b/packages/fast-usdc/test/exos/transaction-feed.test.ts index 9f1c902aaae..8e3b04f9271 100644 --- a/packages/fast-usdc/test/exos/transaction-feed.test.ts +++ b/packages/fast-usdc/test/exos/transaction-feed.test.ts @@ -89,19 +89,3 @@ test('disabled operator', async t => { message: 'submitEvidence for disabled operator', }); }); - -// TODO: find a way to get this working -test.skip('forged source', async t => { - const feedKit = makeFeedKit(); - const { op1 } = await makeOperators(feedKit); - const evidence = MockCctpTxEvidences.AGORIC_PLUS_OSMO(); - - // op1 is different than the facets object the evidence must come from - t.throws(() => - feedKit.operatorPowers.attest( - evidence, - // @ts-expect-error XXX Types of property '[GET_INTERFACE_GUARD]' are incompatible. - op1, - ), - ); -});