Skip to content
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

Amount Patterns: Write test cases for the use cases and for each mathKind and mark as test.failing #2355

Open
katelynsills opened this issue Feb 6, 2021 · 1 comment
Labels
enhancement New feature or request ERTP package: ERTP Zoe Contract Contracts within Zoe Zoe package: Zoe

Comments

@katelynsills
Copy link
Contributor

katelynsills commented Feb 6, 2021

Examples for the use cases:

Finding an invitation in the wallet:

const offer = {
 invitationQuery: { instance, description },
};
// Under the hood in findOrMakeInvitation.js in the wallet:

const invitationPattern = r.make(r.specifySome(offer.invitationQuery));
amountMath.matchMin(invitationPurseBalance, invitationPattern);

results in:

r.specifySome({ instance, description })

which is

 {
   '@pattern': '...*',
   instance,
   description,
 }

Buy a ticket for an event with offer safety

An example ticket amount value:

[{
show: 'Steven Universe, the Opera',
start: 1611704689,
id: 1,
}]
The user writes:

const tues3pm = 1611704689; // whatever 3pm is
const tues6pm = 1611704689; // whatever 6pm is
const ticketForThisAfternoon = r.make([
 {
   show: 'Steven Universe, the Opera',
   id: r.any(),
   start: r.and(r.gte(tues3pm), r.lte(tues6pm)),
 },
]);

const proposal = {
 want: ticketForThisAfternoon,
};

Results in:

[{
   show: 'Steven Universe, the Opera',
   id: {
     '@pattern': '*',
   },
   start: {
     '@pattern': 'and',
     subPatterns: [
       {
         '@pattern': '>=',
         rightOperand: 1611704689, // whatever 3pm is
       },
       {
         '@pattern': '<=',
         rightOperand: 1611704689, // whatever 6pm is
       },
     ],
   },
 }]

Buy an option with offer safety

Example option amount value: [{
strikePrice,
expirationDate,
underlyingAmount,
timeAuthority,
description,
handle,
instance,
installation,
}]
User writes:

r.make([
 {
   strikePrice: r.lte(maxStrikePrice),
   expirationDate: r.gte(nextMondayMidnight),
   underlyingAmount: r.gte(minUnderlyingAmount),
   timeAuthority: myTimeAuthority,
   description: 'exerciseOption',
   handle: r.any(),
   instance: r.any(),
   installation: coveredCallInstallation,
 },
]);

Results in:

[
 {
   strikePrice: {
     '@pattern': '<=',
     rightOperand: maxStrikePrice,
   },
   expirationDate: {
     '@pattern': '>=',
     rightOperand: nextMondayMidnight,
   },
   underlyingAmount: {
     '@pattern': '>=',
     rightOperand: minUnderlyingAmount,
   },
   timeAuthority: myTimeAuthority,
   description: 'exerciseOption',
   handle: { '@pattern': '*'},
   instance: { '@pattern': '*'},
   installation: coveredCallInstallation,
 },
]
@katelynsills katelynsills added enhancement New feature or request ERTP package: ERTP Zoe package: Zoe Zoe Contract Contracts within Zoe labels Feb 6, 2021
@katelynsills katelynsills self-assigned this Feb 6, 2021
@katelynsills katelynsills added this to the Beta Launch milestone Feb 9, 2021
@rowgraus
Copy link

Will timebox to 3 and choose most important areas to start

@rowgraus rowgraus removed this from the Beta Initial Launch milestone Mar 23, 2021
@Tartuffo Tartuffo added the MN-2 label Jan 19, 2022
@Tartuffo Tartuffo removed the MN-2 label Feb 7, 2022
@ivanlei ivanlei removed the Beta label Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ERTP package: ERTP Zoe Contract Contracts within Zoe Zoe package: Zoe
Projects
None yet
Development

No branches or pull requests

4 participants