Skip to content

Commit

Permalink
broken: use seatHandle rather than zoeSeatAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Jun 23, 2022
1 parent 93b558a commit 6bc46a0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
21 changes: 10 additions & 11 deletions packages/zoe/src/contractFacet/zcfSeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,21 @@ export const createSeatManager = (
const zcfSeatKindHandle = provideKindHandle(zcfBaggage, 'zcfSeat');
const makeZCFSeatInternal = defineDurableKind(
zcfSeatKindHandle,
(proposal, zoeSeatAdmin, notifier) => ({
(proposal, notifier) => ({
proposal,
zoeSeatAdmin,
notifier,
}),
{
getNotifier: ({ state }) => state.notifier,
getProposal: ({ state }) => state.proposal,
exit: ({ state, self }, completion) => {
exit: ({ self }, completion) => {
assertActive(self);
assertNoStagedAllocation(self);
doExitSeat(self);
E(state.zoeSeatAdmin).exit(completion);
E(zoeInstanceAdmin).exitSeat(zcfSeatToSeatHandle.get(self), completion);
},
fail: (
{ state, self },
{ self },
reason = new Error(
'Seat exited with failure. Please check the log for more information.',
),
Expand All @@ -272,7 +271,10 @@ export const createSeatManager = (
}
if (!hasExited(self)) {
doExitSeat(self);
E(state.zoeSeatAdmin).fail(harden(reason));
E(zoeInstanceAdmin).failSeat(
zcfSeatToSeatHandle.get(self),
harden(reason),
);
}
return reason;
},
Expand Down Expand Up @@ -334,11 +336,8 @@ export const createSeatManager = (
hasStagedAllocation: ({ self }) => hasStagedAllocation(self),
},
);
const makeZCFSeat = (
zoeSeatAdmin,
{ proposal, notifier, initialAllocation, seatHandle },
) => {
const zcfSeat = makeZCFSeatInternal(proposal, zoeSeatAdmin, notifier);
const makeZCFSeat = (proposal, notifier, initialAllocation, seatHandle) => {
const zcfSeat = makeZCFSeatInternal(proposal, notifier);
activeZCFSeats.init(zcfSeat, initialAllocation);
zcfSeatToSeatHandle.init(zcfSeat, seatHandle);
return zcfSeat;
Expand Down
12 changes: 4 additions & 8 deletions packages/zoe/src/contractFacet/zcfZygote.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ export const makeZCFZygote = (
const initialAllocation = harden({});
const proposal = cleanProposal(harden({ exit }), getAssetKindByBrand);
const { notifier, updater } = makeNotifierKit();
/** @type {PromiseRecord<ZoeSeatAdmin>} */
const zoeSeatAdminPromiseKit = makePromiseKit();
handlePKitWarning(zoeSeatAdminPromiseKit);
const userSeatPromiseKit = makePromiseKit();
handlePKitWarning(userSeatPromiseKit);
const seatHandle = makeSeatHandle();
Expand All @@ -108,15 +105,14 @@ export const makeZCFZygote = (
notifier,
seatHandle,
});
const zcfSeat = makeZCFSeat(zoeSeatAdminPromiseKit.promise, seatData);
const zcfSeat = makeZCFSeat(seatData);

const exitObj = makeExitObj(seatData.proposal, zcfSeat);

E(zoeInstanceAdmin)
.makeNoEscrowSeat(initialAllocation, proposal, exitObj, seatHandle)
.then(({ zoeSeatAdmin, notifier: zoeNotifier, userSeat }) => {
.then(({ notifier: zoeNotifier, userSeat }) => {
observeNotifier(zoeNotifier, updater);
zoeSeatAdminPromiseKit.resolve(zoeSeatAdmin);
userSeatPromiseKit.resolve(userSeat);
});

Expand Down Expand Up @@ -333,8 +329,8 @@ export const makeZCFZygote = (
// added in offer(). ZCF responds with the exitObj and offerResult.
/** @type {HandleOfferObj} */
const handleOfferObj = Far('handleOfferObj', {
handleOffer: (invitationHandle, zoeSeatAdmin, seatData) => {
const zcfSeat = makeZCFSeat(zoeSeatAdmin, seatData);
handleOffer: (invitationHandle, seatData) => {
const zcfSeat = makeZCFSeat(seatData);
const offerHandler = takeOfferHandler(invitationHandle);
const offerResultP = E(offerHandler)(zcfSeat, seatData.offerArgs).catch(
reason => {
Expand Down
6 changes: 3 additions & 3 deletions packages/zoe/src/internal-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
*
* @typedef {object} HandleOfferObj
* @property {(invitationHandle: InvitationHandle,
* zoeSeatAdmin: ZoeSeatAdmin,
* seatData: SeatData,
* ) => HandleOfferResult} handleOffer
*/
Expand All @@ -115,6 +114,8 @@
* @property {ReplaceAllocations} replaceAllocations
* @property {(completion: Completion) => void} exitAllSeats
* @property {ShutdownWithFailure} failAllSeats
* @property {(seatHandle: SeatHandle, completion: Completion) => void} exitSeat
* @property {(seatHandle: SeatHandle, reason: Error) => void} failSeat
* @property {() => void} stopAcceptingOffers
*/

Expand Down Expand Up @@ -148,7 +149,7 @@
* @param {ProposalRecord} proposal
* @param {ExitObj} exitObj
* @param {SeatHandle} seatHandle
* @returns {ZoeSeatAdminKit}
* @returns {{userSeat: UserSeat, notifier: Notifier<Allocation>}}
*/

/**
Expand Down Expand Up @@ -248,7 +249,6 @@

/**
* @callback MakeZCFSeat
* @param {ERef<ZoeSeatAdmin>} zoeSeatAdmin
* @param {SeatData} seatData
* @returns {ZCFSeat}
*/
Expand Down
10 changes: 8 additions & 2 deletions packages/zoe/src/zoeService/startInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const makeStartInstance = (
zoeSeatAdmins.add(zoeSeatAdmin);

E(handleOfferObjPromiseKit.promise)
.handleOffer(invitationHandle, zoeSeatAdmin, seatData)
.handleOffer(invitationHandle, seatData)
.then(({ offerResultP, exitObj }) => {
offerResultPromiseKit.resolve(offerResultP);
exitObjPromiseKit.resolve(exitObj);
Expand All @@ -167,7 +167,7 @@ export const makeStartInstance = (
);
zoeSeatAdmins.add(zoeSeatAdmin);
seatHandleToZoeSeatAdmin.init(seatHandle, zoeSeatAdmin);
return { userSeat, notifier, zoeSeatAdmin };
return { userSeat, notifier };
},
});
return instanceAdmin;
Expand All @@ -192,6 +192,12 @@ export const makeStartInstance = (
makeNoEscrowSeat: instanceAdmin.makeNoEscrowSeat,
exitAllSeats: completion => instanceAdmin.exitAllSeats(completion),
failAllSeats: reason => instanceAdmin.failAllSeats(reason),
exitSeat: (seatHandle, completion) => {
seatHandleToZoeSeatAdmin.get(seatHandle).exit(completion);
},
failSeat: (seatHandle, reason) => {
seatHandleToZoeSeatAdmin.get(seatHandle).fail(reason);
},
makeZoeMint: zoeInstanceStorageManager.makeZoeMint,
registerFeeMint: zoeInstanceStorageManager.registerFeeMint,
replaceAllocations: seatHandleAllocations => {
Expand Down

0 comments on commit 6bc46a0

Please sign in to comment.