Skip to content

Conversation

@erights
Copy link
Member

@erights erights commented Apr 8, 2025

closes: #XXXX
refs: endojs/endo#2710 #1905 #1913 #1915 #2155 #2156 #2230 #4212 #4217 #10951 #10952

Description

Implements the ERTP part of minimal want patterns, where the only supported pattern is M.containerHas. #10952 then implements the zoe portion.

Security Considerations

none

Scaling Considerations

at the ERTP level, none.

Documentation Considerations

Need to update ERTP docs to explain the use of M.has patterns in AmountMath.isGTE and AmountMath.subtract.

Testing Considerations

ERTP tests already added.

Upgrade Considerations

None

  • Need to update NEWS.md for ERTP

@erights erights self-assigned this Apr 8, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Apr 8, 2025

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: b01e796
Status:🚫  Build failed.

View logs

@erights erights force-pushed the markm-want-patterns-only-ertp branch 2 times, most recently from 2e4d932 to 979da2a Compare April 8, 2025 21:09
*/
const multiplyHelper = (amount, ratio, divideOp) => {
AmountMath.coerce(amount.brand, amount);
amount = AmountMath.coerce(amount.brand, amount);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A drive-by. coerce only produces a valid output from valid or almost-valid input. It does not validate or modify the input. So either we should use the result of coerce or we should remove it. Not sure yet whether this coerce is actually needed.

@@ -0,0 +1,60 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
import { M, makeCopySet } from '@endo/patterns';

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO do we also need a copyBagBoundMathHelpers.test.js?

@erights erights force-pushed the markm-want-patterns-only-ertp branch from 979da2a to b01e796 Compare July 21, 2025 22:54
@erights erights requested a review from Copilot September 16, 2025 08:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the ERTP portion of minimal want patterns, introducing support for M.containerHas patterns in AmountMath.isGTE and AmountMath.subtract operations. This feature allows pattern-based matching on non-fungible and semi-fungible assets.

Key changes include:

  • Added AmountBound types that extend Amount to support HasBound patterns
  • Implemented pattern matching logic in AmountMath for M.containerHas operations
  • Updated error messages to be more descriptive and consistent
  • Added comprehensive test coverage for the new pattern matching functionality

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/ERTP/src/amountMath.js Core implementation of pattern matching with new amountSplit function and updated isGTE/subtract methods
packages/ERTP/src/types.ts Added HasBound, AmountBound, and related type definitions for pattern matching
packages/ERTP/src/typeGuards.js Added type guards and shapes for the new bound types
packages/ERTP/src/purse.js Updated purse withdraw method to accept AmountBound with placeholder for pattern support
packages/ERTP/test/unitTests/mathHelpers/setBoundMathHelpers.test.js New comprehensive tests for set-based pattern matching
packages/ERTP/test/unitTests/mathHelpers/copySetBoundMathHelpers.test.js New comprehensive tests for copySet-based pattern matching
packages/store/test/borrow-guards.js Updated shapes to use new AmountBound types
Multiple test files Updated error message assertions to match new "AmountValue" terminology

coerceToElements,
elementsCompare,
} from '@agoric/store';
} from '@endo/patterns';
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import source has changed from '@agoric/store' to '@endo/patterns', but some functions like elementsIsSuperset, elementsDisjointUnion, and elementsDisjointSubtract may not be available in '@endo/patterns'. Verify that all imported functions are actually exported from the new module.

Copilot uses AI. Check for mistakes.
setDisjointUnion,
setDisjointSubtract,
} from '@agoric/store';
} from '@endo/patterns';
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import source has changed from '@agoric/store' to '@endo/patterns', but some functions like setIsSuperset, setDisjointUnion, and setDisjointSubtract may not be available in '@endo/patterns'. Verify that all imported functions are actually exported from the new module.

Copilot uses AI. Check for mistakes.
),
{ brand: mockBrand, value: makeCopySet(['b']) },
`['a', 'b'] - ['a'] = ['a']`,
`['a', 'b'] - ['a'] = ['b']`,
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment describes the subtraction operation incorrectly. It should say ['a', 'b'] - ['a'] = ['b'] which matches the expected result in the test assertion above.

Suggested change
`['a', 'b'] - ['a'] = ['b']`,
`['a', 'b'] - ['a'] = ['b']`, // ['a', 'b'] minus ['a'] equals ['b']

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants