diff --git a/packages/fast-usdc/src/fast-usdc.contract.js b/packages/fast-usdc/src/fast-usdc.contract.js index 78bfd03f48f..51f46a6ab6d 100644 --- a/packages/fast-usdc/src/fast-usdc.contract.js +++ b/packages/fast-usdc/src/fast-usdc.contract.js @@ -11,6 +11,7 @@ import { prepareLiquidityPoolKit } from './exos/liquidity-pool.js'; import { prepareSettler } from './exos/settler.js'; import { prepareStatusManager } from './exos/status-manager.js'; import { prepareTransactionFeedKit } from './exos/transaction-feed.js'; +import { defineInertInvitation } from './utils/zoe.js'; const trace = makeTracer('FastUsdc'); @@ -86,6 +87,11 @@ export const contract = async (zcf, privateArgs, zone, tools) => { { makeRecorderKit }, ); + const makeTestSubmissionInvitation = defineInertInvitation( + zcf, + 'test of submitting evidence', + ); + const creatorFacet = zone.exo('Fast USDC Creator', undefined, { simulateFeesFromAdvance(amount, payment) { console.log('🚧🚧 UNTIL: advance fees are implemented 🚧🚧'); @@ -109,11 +115,7 @@ export const contract = async (zcf, privateArgs, zone, tools) => { // TODO(bootstrap integration): force this to throw and confirm that it // shows up in the the smart-wallet UpdateRecord `error` property feedKit.admin.submitEvidence(evidence); - return zcf.makeInvitation(async cSeat => { - trace('Offer made on noop invitation'); - cSeat.exit(); - return 'noop; evidence was pushed in the invitation maker call'; - }, 'noop invitation'); + return makeTestSubmissionInvitation(); }, makeDepositInvitation() { // eslint-disable-next-line no-use-before-define diff --git a/packages/fast-usdc/src/utils/zoe.js b/packages/fast-usdc/src/utils/zoe.js new file mode 100644 index 00000000000..d951bbef865 --- /dev/null +++ b/packages/fast-usdc/src/utils/zoe.js @@ -0,0 +1,28 @@ +import { makeTracer } from '@agoric/internal'; + +const trace = makeTracer('ZoeUtils'); + +/** + * Used for "continuing offer" invitations in which the caller does not need + * anything in return. In those cases there is no Zoe offer safety and the + * invitation making function can perform the request itself. + * + * But smart-wallet expects an invitation maker to make an invitation, so this + * function abstracts making such an inert invitation and logs consistently when + * it is used. + * + * When this is used by an invitation maker that performs the operation, receiving + * one of these invitations is evidence that the operation took place. + * + * @param {ZCF} zcf + * @param {string} description @see {@link ZCF.makeInvitation} + * @returns {() => Promise} an arg-less invitation maker + */ +export const defineInertInvitation = (zcf, description) => { + return () => + zcf.makeInvitation(seat => { + trace(`ℹī¸ An offer was made on an inert invitation for ${description}`); + seat.exit(); + return 'inert; nothing should be expected from this offer'; + }, description); +}; diff --git a/packages/fast-usdc/test/fast-usdc.contract.test.ts b/packages/fast-usdc/test/fast-usdc.contract.test.ts index 124f808e527..48a86e0c899 100644 --- a/packages/fast-usdc/test/fast-usdc.contract.test.ts +++ b/packages/fast-usdc/test/fast-usdc.contract.test.ts @@ -56,7 +56,7 @@ test('start', async t => { const seat = await E(zoe).offer(inv); t.is( await E(seat).getOfferResult(), - 'noop; evidence was pushed in the invitation maker call', + 'inert; nothing should be expected from this offer', ); });