-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Want Patterns Implementation Plan #2230
Labels
Comments
katelynsills
added
enhancement
New feature or request
ERTP
package: ERTP
Zoe
package: Zoe
wallet
labels
Jan 21, 2021
Hi @katelynsills I took the liberty of editing the whitespace of your code example in place above. |
This was referenced Feb 5, 2021
Open
Closed
Merged
erights
changed the title
Amount Patterns Implementation Plan
Want Patterns Implementation Plan
Mar 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
User Stories
expirationDate
greater than or equal to some timestamp: As a user, I want to buy an option and have my purchase be protected by offer safety. I want to be able to specify things that are important to me, such as that the option will not expire until after a specific timestamp. I don't want to have to specify things that are not important to me, such as the invitation handle for a particular option. (This use case also pertains to staking derivatives.)Expected Behavior
There will be (at least) three additions to
amountMath
methods (actual names TBD):undefined
undefined
.any
, likely{ '@pattern': '*' }
MathKind.NAT
matchFirst
Return the second argument if the first is greater than the second, otherwise return undefined.
[Insert code examples here]
matchAll
Return the first argument if the first is greater than the second, otherwise return undefined.
[Insert code examples here]
MathKind.STRING_SET
matchFirst
Return an amount with a value of the first string that matches. Otherwise return undefined. Should be the match that is alphabetically first of all matches. We'd like to specify something that gives us an order-independent deterministic answer (which mine [Mark] does not) and we're not sure that alphabetic (or lexicographic) is the best choice. But cannot think of anything better or less surprising. If the amountPattern has more than one element in the value array, the elements after the first are only used if the first was unsuccessful at finding a match.
matchAll
Return an amount with a value of all strings that match. Otherwise return undefined.
[Insert code examples here]
MathKind.SET (and MathKind.INVITATION, if it exists)
matchFirst
Find the first amount that matches, i.e. the amount for one invitation, if any. The amount for one ticket, if any. Return undefined otherwise. If the amountPattern has more than one element in the value array, the elements after the first are only used if the first was unsuccessful at finding a match
[Insert code examples here]
matchAll
Find all the invitations that match. Find all the tickets that match. Deduplicate any matches that are found by different elements of the amount pattern. Return undefined otherwise.
[Insert code examples here]
Implementation Plan
test.failing
#2355)https://github.com/Agoric/agoric-sdk/blob/fungible-derivs/packages/ERTP/src/mathHelpers/strSetMathHelpers.js
SetMathHelpers is incredibly ill-designed for Zoe invitations currently, as it creates buckets based on keys that are strings concatenated with values that are strings. Since most keys are the same for all invitations, and most values are not strings, this means that the buckets are nearly entirely determined by the invitation description. It’s efficient if the invitation descriptions are all different, but if they are the same and few string customProperties are used, we would expect to see a lot of comparisons made because all the invitations are in the same bucket.
wanted
, not what the contract hadavailable
and what waswanted
.matchFirst
makes sense to use within offerSafety.js (or amountMath.satisfies, however we come down on this).Relevant PRs
cc @erights
The text was updated successfully, but these errors were encountered: