endojs / endo

Endo is a distributed secure JavaScript sandbox, based on SES
Apache License 2.0
829 stars 72 forks source link

feat(patterns): New `M.tagged` pattern maker #2091

Closed erights closed 8 months ago

erights commented 8 months ago

closes: #XXXX refs: https://github.com/Agoric/agoric-sdk/pull/8742 https://github.com/Agoric/agoric-sdk/pull/8958

Description

@dckc encountered the need to express a Vow pattern. The Vow abstraction is currently only defined by agoric-sdk. But it is encoded into a Tagged object, where that Tagged is not a recognized kind at the @endo/patterns level. This caused us to notice the inability to express patterns over Tagged objects. This PR adds that. Using it, a VowShape should be expressible as

const VowShape = M.tagged(
  'Vow',
  harden({
    vowV0: M.remotable('VowV0'),
  }),
);

We include a test case that is similar in all the relevant ways.

Security Considerations

none

Scaling Considerations

none

Documentation Considerations

We include doccomments in the PatternMatchers type, that should show up next time we regenerate https://endojs.github.io/endo/interfaces/_endo_patterns.PatternMatchers.html

Btw, when does that get regenerated? What causes it to get regenerated?

Testing Considerations

included tests should be adequate

Compatibility Considerations

The matcher made by M.tagged(...) will not be recognized as a matcher by versions of @endo/patterns that precede this PR.

Upgrade Considerations

Nothing breaking.