Skip to content

Commit

Permalink
Merge pull request #6165 from Agoric/4489-walletFactory-virtual
Browse files Browse the repository at this point in the history
4489 walletFactory virtual
  • Loading branch information
mergify[bot] authored Sep 9, 2022
2 parents 664850e + 65c6bab commit 6f402a0
Show file tree
Hide file tree
Showing 11 changed files with 509 additions and 323 deletions.
3 changes: 1 addition & 2 deletions packages/smart-wallet/src/invitations.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const makeInvitationsHelper = (
invitationsPurse,
getInvitationContinuation,
) => {
// TODO(6062) validate params with patterns
const invitationGetters = /** @type {const} */ ({
/** @type {(spec: ContractInvitationSpec) => Promise<Invitation>} */
contract(spec) {
Expand All @@ -72,7 +71,7 @@ export const makeInvitationsHelper = (
details =>
details.description === description && details.instance === instance,
);
assert(match, `no matching purse for ${{ instance, description }}`);
assert(match, `invitation not found: ${description}`);
const toWithDraw = AmountMath.make(invitationBrand, harden([match]));
console.log('.... ', { toWithDraw });

Expand Down
22 changes: 6 additions & 16 deletions packages/smart-wallet/src/offers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// @ts-check

import { fit } from '@agoric/store';
import { E, Far, passStyleOf } from '@endo/far';
import { E, passStyleOf } from '@endo/far';
import { makePaymentsHelper } from './payments.js';
import { shape } from './typeGuards.js';

/**
* @typedef {{
Expand Down Expand Up @@ -37,25 +35,23 @@ export const UNPUBLISHED_RESULT = 'UNPUBLISHED';
* @param {(status: OfferStatus) => void} opts.onStatusChange
* @param {(offerId: number, continuation: import('./types').RemoteInvitationMakers) => void} opts.onNewContinuingOffer
*/
export const makeOffersFacet = ({
export const makeOfferExecutor = ({
zoe,
powers,
onStatusChange,
onNewContinuingOffer,
}) => {
const { invitationFromSpec, lastOfferId, purseForBrand } = powers;

return Far('offers facet', {
return {
/**
* Take an offer description provided in capData, augment it with payments and call zoe.offer()
*
* @param {OfferSpec} offerSpec
* @returns {Promise<void>} when the offer has been sent to Zoe; payouts go into this wallet's purses
* @throws if any parts of the offer can be determined synchronously to be invalid
*/
executeOffer: async offerSpec => {
fit(harden(offerSpec), shape.OfferSpec);

async executeOffer(offerSpec) {
const paymentsManager = makePaymentsHelper(purseForBrand);

/** @type {OfferStatus} */
Expand Down Expand Up @@ -157,12 +153,6 @@ export const makeOffersFacet = ({
handleError(err);
}
},

/**
* Contracts can use this to generate a valid (monotonic) offer ID by incrementing.
* In most cases it will be faster to get this from RPC query.
*/
getLastOfferId: lastOfferId.get,
});
};
};
harden(makeOffersFacet);
harden(makeOfferExecutor);
Loading

0 comments on commit 6f402a0

Please sign in to comment.