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

escrowAndAllocateTo tempHandle not getting set before use, maybe #1287

Closed
warner opened this issue Jul 13, 2020 · 1 comment
Closed

escrowAndAllocateTo tempHandle not getting set before use, maybe #1287

warner opened this issue Jul 13, 2020 · 1 comment
Labels
bug Something isn't working Zoe package: Zoe

Comments

@warner
Copy link
Member

warner commented Jul 13, 2020

Describe the bug
I'm not sure exactly how we provoked this, but I have a note in my local copy of zoeHelpers.js in the escrowAndAllocateTo function, that the tempHandle = offerHandle callback here:

    escrowAndAllocateTo: ({ amount, payment, keyword, recipientHandle }) => {
      // We will create a temporary offer to be able to escrow our payment
      // with Zoe.
      let tempHandle; // bug: this is not getting set before use

      // We need to make an invite and store the offerHandle of that
      // invite for future use.
      const contractSelfInvite = zcf.makeInvitation(
        offerHandle => (tempHandle = offerHandle),
        'self invite',
      );

did not happen by the time tempHandle got used later:

      return zcf
        .getZoeService()
        .offer(contractSelfInvite, proposal, payments)
        .then(() => {
          // At this point, the temporary offer has the amount from the
          // payment but nothing else. The recipient offer may have any
          // allocation, so we can't assume the allocation is currently empty for this
          // keyword.

          helpers.trade(
            {
              offerHandle: tempHandle,
              gains: {},
              losses: { Temp: amount },
            },
            {
              offerHandle: recipientHandle,
              gains: { [keyword]: amount },
            },
          );

          // Complete the temporary offerHandle
          zcf.complete([tempHandle]);

          // Now, the temporary offer no longer exists, but the recipient
          // offer is allocated the value of the payment.
        });

@dtribble might remember more, we noticed that this waits for offer()'s Promise to fire, but I think we were doing something wrong (maybe something was wrong with our proposal or payments?) and somehow got past that point without the tempHandle being set.

If Dean can't remember what weirdness we did to provoke this, then I'd say we should just have @katelynsills or @Chris-Hibbert eyeball that code briefly to see if there's any obvious assumption being made that isn't justified, and then close this ticket.

@warner warner added bug Something isn't working Zoe package: Zoe labels Jul 13, 2020
@katelynsills
Copy link
Contributor

Because we are removing makeEmptyOffer (#1442) I think we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Zoe package: Zoe
Projects
None yet
Development

No branches or pull requests

2 participants