Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 112x 207x 112x 210x 199x | import { makeExo } from '@endo/exo';
import type { Methods } from '@endo/exo';
import { M } from '@endo/patterns';
import type { InterfaceGuard } from '@endo/patterns';
/**
* Shorthand for creating a named `@endo/patterns.InterfaceGuard` with default guards
* set to 'passable'.
*
* @param name - The name of the interface.
* @returns An interface with default guards set to 'passable'.
*/
export const makeDefaultInterface = (name: string): InterfaceGuard =>
M.interface(name, {}, { defaultGuards: 'passable' });
/**
* Shorthand for creating an `@endo/exo` remotable with default guards set to 'passable'.
*
* @param name - The name of the exo.
* @param methods - The methods of the exo (i.e. the object to be made remotable).
* @param interfaceGuard - The `@endo/patterns` interface guard to use for the exo.
* @returns A named exo with default guards set to 'passable'.
*/
export const makeDefaultExo = <Interface extends Methods>(
name: string,
methods: Interface,
interfaceGuard: InterfaceGuard = makeDefaultInterface(name),
): ReturnType<typeof makeExo<Interface>> =>
// @ts-expect-error We're intentionally not specifying method-specific interface guards.
makeExo(name, interfaceGuard, methods);
|