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

feat: postalSvc contract forwards payments using namesByAddress (prototype) #8547

Closed
wants to merge 44 commits into from

Conversation

dckc
Copy link
Member

@dckc dckc commented Nov 18, 2023

Description

This contract is a reusable component for sending payments using namesByAddress to look up a depositFacet.
A contract such as GiMiX or swaparoo only needs this instance in its terms.

Or an offer can go straight to this contract. The script here starts the contract with the Zoe Fee and Invitation issuers.

It's something of a work-around for the regression in the wallet where this feature wasn't shipped in production.
I'm not sure it should be merged, let alone shipped in production. Maybe it should be moved to an example app.

cc @michaelfig @samsiegart @dtribble

Security Considerations

TODO:

  • add missing pattern guards
  • make upgradeable?
  • integration test on a chain
  • what forms of docs?
  • creatorFacet method to add issuers?
  • governed API to add issuers?

Testing Considerations

currently:

agoric-sdk/packages/zoe$ yarn test test/unitTests/contracts/gimix/test-postalSvc.js 
$ ava --verbose test/unitTests/contracts/gimix/test-postalSvc.js

[bundleTool] bundles/ bundle-gimix.js valid: 121 files bundled at 2023-11-18T00:58:21.248Z with size 1017305 
postalSvc issuers [ 'IST', 'Invitation' ]
  ✔ deliver payment using address (360ms)
    ℹ send IST with public facet to agoric1receiver
    ℹ make offer to send IST, Invitation to agoric1receiver
start-postalSvc postalSvc started


  1 test passed

Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

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

Seems fine. Some requests for mostly minor cleanups or clarification. The for loop issue seems substantive.

packages/zoe/src/contracts/gimix/postalSvc.js Outdated Show resolved Hide resolved
// XXX partial failure?
for await (const pmtP of values(payouts)) {
const pmt = await pmtP;
await sendTo(recipient, pmt);
Copy link
Contributor

Choose a reason for hiding this comment

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

earlier failures will block later attempts. A Promise.all() would try them in parallel, so that they can succeed independently.

packages/zoe/src/contracts/gimix/start-postalSvc.js Outdated Show resolved Hide resolved
*
* @param {ZoeService} zoeMethods
*/
const wrapZoe = zoeMethods => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this helpful?

Copy link
Member Author

Choose a reason for hiding this comment

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

to override installBundleID

p.s. thanks for taking a look.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get it. It looks like it passes installBundleID() through just like it does for all the other methods it supports. In a test, why is this better than just passing zoeMethods through? Did I misread something?

Copy link
Member Author

Choose a reason for hiding this comment

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

the real zoe is an exo, so you can't just go { ...zoe, installBundleID: myMockInstallBundle }. (I should probably document what happens if you try.)

wrapZoe takes the zoe exo and gives you back a plain record/object, where you can override methods using spread expressions like that:

    const zoe = Far('ZoeService', {
      ...wrapZoe(zoeService),
      installBundleID: install1BundleID,
    });

Copy link
Member

Choose a reason for hiding this comment

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

Just so you're aware of bindAllMethods

As it says there, bindAllMethods was only a transitional measure until replaced by code this PR's wrapZoe, so no change suggested. Just FYI.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks; I was only vaguely aware of it. But I'm leery to use stuff from @agoric/internal, because it's a private package, and I was thinking this contract should probably be outside the SDK.

dckc added a commit to agoric-labs/ag-power-tools that referenced this pull request Dec 23, 2023
Agoric/agoric-sdk#8547
2023-11-17 19:10 0040bea4a feat: postalSvc contract forwards payments using namesByAddress
dckc added a commit to agoric-labs/ag-power-tools that referenced this pull request Dec 23, 2023
Agoric/agoric-sdk#8547
2023-11-17 19:10 0040bea4a feat: postalSvc contract forwards payments using namesByAddress
dckc added a commit to agoric-labs/ag-power-tools that referenced this pull request Dec 28, 2023
Agoric/agoric-sdk#8547
2023-11-17 19:10 0040bea4a feat: postalSvc contract forwards payments using namesByAddress
@dckc
Copy link
Member Author

dckc commented Jan 19, 2024

work moved to agoric-labs/ag-power-tools#2

@dckc dckc closed this Jan 19, 2024
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.

6 participants