Skip to content

Commit

Permalink
chore: types clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Sep 20, 2024
1 parent 64440c9 commit 1f9acb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
18 changes: 5 additions & 13 deletions packages/orchestration/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,9 @@ export type * from './vat-orchestration.js';

/**
* ({@link ZCF})-like tools for use in {@link OrchestrationFlow}s.
*
* @interface
*/
export type ZcfTools<CT = Record<string, unknown>> = Pick<
ZCF<CT>,
'atomicRearrange' | 'assertUniqueKeyword'
> & {
makeInvitation: <R, A = undefined>(
offerHandler: OfferHandler<ERef<R>, A>,
description: string,
customDetails?: object,
proposalShape?: Pattern,
) => Promise<Invitation<R, A>>;
};
export interface ZcfTools {
assertUniqueKeyword: ZCF['assertUniqueKeyword'];
atomicRearrange: ZCF['atomicRearrange'];
makeInvitation: ZCF['makeInvitation'];
}
14 changes: 4 additions & 10 deletions packages/orchestration/src/utils/zcf-tools.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @import {HostInterface, HostOf} from '@agoric/async-flow';
* @import {HostInterface} from '@agoric/async-flow';
* @import {VowTools} from '@agoric/vow';
* @import {ZcfTools} from '../types.js';
*/
Expand All @@ -11,11 +11,10 @@ const HandlerShape = M.remotable('OfferHandler');
/**
* @param {ZCF} zcf
* @param {VowTools} vowTools
* @returns {HostInterface<ZcfTools>}
*/
export const makeZcfTools = (zcf, vowTools) => {
/** @satisfies {HostInterface<ZcfTools>} */
const zcfForFlows = harden({
/** @type {HostOf<ZCF['makeInvitation']>} */
export const makeZcfTools = (zcf, vowTools) =>
harden({
makeInvitation(offerHandler, description, customDetails, proposalShape) {
mustMatch(offerHandler, HandlerShape);
return vowTools.watch(
Expand All @@ -27,15 +26,10 @@ export const makeZcfTools = (zcf, vowTools) => {
),
);
},
/** @type {ZCF['atomicRearrange']} */
atomicRearrange(transfers) {
zcf.atomicRearrange(transfers);
},
/** @type {ZCF['assertUniqueKeyword']} */
assertUniqueKeyword(keyword) {
zcf.assertUniqueKeyword(keyword);
},
});

return zcfForFlows;
};

0 comments on commit 1f9acb0

Please sign in to comment.