Skip to content

Commit

Permalink
refactor: attest by operatorId
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 17, 2024
1 parent 11e1691 commit 041cf83
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 32 deletions.
4 changes: 2 additions & 2 deletions packages/fast-usdc/src/exos/operator-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

/**
Expand Down Expand Up @@ -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() {
Expand Down
18 changes: 4 additions & 14 deletions packages/fast-usdc/src/exos/transaction-feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions packages/fast-usdc/test/exos/transaction-feed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
});

0 comments on commit 041cf83

Please sign in to comment.