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

User Story: Find invitation in wallet for offer #2345

Open
katelynsills opened this issue Feb 5, 2021 · 0 comments
Open

User Story: Find invitation in wallet for offer #2345

katelynsills opened this issue Feb 5, 2021 · 0 comments
Labels
enhancement New feature or request ERTP package: ERTP wallet Zoe package: Zoe

Comments

@katelynsills
Copy link
Contributor

katelynsills commented Feb 5, 2021

Story

As a user, I can find an invitation in my wallet to use for an offer, without having to know the details (such as the invitation handle) for that particular invitation. Just knowing the instance and description should be enough to choose an invitation to use.

Status

A user can do this, but they can only try to match the keys and values of invitation details exactly and the search is not very efficient. It might get slow if there are a very large number of invitations in the user's wallet.

Details

As of 2/5/2021, a dapp can specify an invitation to use for a particular proposed offer in the wallet by including the property invitationQuery with the keys and values that they wish to use to match. The included keys and values are matched against exactly, and keys and values that are not included are ignored. This does not allow for general amount patterns, but does allow for this user story to be fulfilled. Additionally, it is not very efficient:

const findByKeyValuePairs = async (invitationPurseBalance, kvs) => {
// TODO: use an AmountMath method instead to improve efficiency
// For every key and value in `query`, return an amount
// with any matches for those exact keys and values. Keys not in
// `query` count as a match
const matches = invitationDetail =>
Object.entries(kvs).every(
([key, value]) => invitationDetail[key] === value,
);
const matchingValue = invitationPurseBalance.value.find(matches);

There is also a deploy-script-support helper findInvitationAmount which is used within the offer helper. It has the same efficiency problems as the wallet method:

const findInvitationAmount = async invitationDetailsCriteria => {
const invitationAmount = await E(zoeInvitationPurse).getCurrentAmount();
// TODO: use a new AmountMath method instead to improve efficiency
// For every key and value in invitationDetailsCriteria, return an amount
// with any matches for those exact keys and values. Keys not in
// invitationDetails count as a match
const matches = invitationDetail =>
Object.entries(invitationDetailsCriteria).every(
([key, value]) => invitationDetail[key] === value,
);
const matchingValue = invitationAmount.value.find(matches);
const value =
matchingValue === undefined ? harden([]) : harden([matchingValue]);
return invitationMath.make(value);

Next Steps

Please see the Amount Patterns Implementation Plan issue

@katelynsills katelynsills added enhancement New feature or request wallet labels Feb 5, 2021
@katelynsills katelynsills self-assigned this Feb 5, 2021
@katelynsills katelynsills added Zoe package: Zoe ERTP package: ERTP Beta labels Feb 9, 2021
@katelynsills katelynsills added this to the Beta Launch milestone Feb 9, 2021
@rowgraus rowgraus removed this from the Beta Initial Launch milestone Mar 29, 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 wallet Zoe package: Zoe
Projects
None yet
Development

No branches or pull requests

4 participants