Skip to content

Commit

Permalink
Merge pull request #7445 from Agoric/markm-more-stateShapes
Browse files Browse the repository at this point in the history
refactor: More exoClasses have stateShape metadata
  • Loading branch information
mergify[bot] authored Apr 18, 2023
2 parents 1b2a03f + 50c9fe4 commit 5685735
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/inter-protocol/src/auction/auctionBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,25 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
const makeScaledBidBook = prepareScaledBidBook(baggage);
const makePriceBook = preparePriceBook(baggage);

const AuctionBookStateShape = harden({
collateralBrand: M.any(),
collateralSeat: M.any(),
collateralAmountShape: M.any(),
currencyBrand: M.any(),
currencySeat: M.any(),
currencyAmountShape: M.any(),
priceAuthority: M.any(),
updatingOracleQuote: M.any(),
bookDataKit: M.any(),
priceBook: M.any(),
scaledBidBook: M.any(),
startCollateral: M.any(),
startProceedsGoal: M.any(),
lockedPriceForRound: M.any(),
curAuctionPrice: M.any(),
remainingProceedsGoal: M.any(),
});

const makeAuctionBookKit = prepareExoClassKit(
baggage,
'AuctionBook',
Expand Down Expand Up @@ -732,6 +751,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
},
);
},
stateShape: AuctionBookStateShape,
},
);

Expand Down
18 changes: 18 additions & 0 deletions packages/inter-protocol/src/auction/offerBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const nextSequenceNumber = () => {
* } BidderRecord
*/

const ScaledBidBookStateShape = harden({
bidScalingPattern: M.any(),
collateralBrand: M.any(),
records: M.any(),
});

/**
* Prices in this book are expressed as percentage of the full oracle price
* snapshot taken when the auction started. .4 is 60% off. 1.1 is 10% above par.
Expand Down Expand Up @@ -116,8 +122,17 @@ export const prepareScaledBidBook = baggage =>
}
},
},
{
stateShape: ScaledBidBookStateShape,
},
);

const PriceBookStateShape = harden({
priceRatioPattern: M.any(),
collateralBrand: M.any(),
records: M.any(),
});

/**
* Prices in this book are actual prices expressed in terms of currency amount
* and collateral amount.
Expand Down Expand Up @@ -200,4 +215,7 @@ export const preparePriceBook = baggage =>
}
},
},
{
stateShape: PriceBookStateShape,
},
);
14 changes: 14 additions & 0 deletions packages/inter-protocol/src/vaultFactory/vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ export const VaultI = M.interface('Vault', {
abortLiquidation: M.call().returns(M.string()),
});

const VaultStateShape = harden({
idInManager: M.any(),
manager: M.any(),
outerUpdater: M.any(),
phase: M.any(),
storageNode: M.any(),
vaultSeat: M.any(),
interestSnapshot: M.any(),
debtSnapshot: M.any(),
});

/**
* @param {import('@agoric/ertp').Baggage} baggage
* @param {import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit} makeRecorderKit
Expand Down Expand Up @@ -944,6 +955,9 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
},
},
},
{
stateShape: VaultStateShape,
},
);
return maker;
};
Expand Down
11 changes: 11 additions & 0 deletions packages/notifier/src/publish-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ export const makePublishKit = () => {
};
harden(makePublishKit);

const DurablePublishKitStateShape = harden({
valueDurability: M.any(),
publishCount: M.any(),
status: M.any(),
hasValue: M.any(),
value: M.any(),
});

// TODO: Move durable publish kit to a new file?

/**
Expand Down Expand Up @@ -416,6 +424,9 @@ export const prepareDurablePublishKit = (baggage, kindName) => {
},
},
},
{
stateShape: DurablePublishKitStateShape,
},
);
};
harden(prepareDurablePublishKit);
Expand Down
5 changes: 5 additions & 0 deletions packages/zoe/src/contractFacet/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export const makeMakeExiter = baggage => {
state.zcfSeat.exit();
},
},
{
stateShape: harden({
zcfSeat: M.any(),
}),
},
);
const makeWaived = prepareExoClass(
baggage,
Expand Down
10 changes: 10 additions & 0 deletions packages/zoe/src/zoeService/startInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ export const makeStartInstance = (
seatHandleToZoeSeatAdmin,
);

const InstanceAdminStateShape = harden({
instanceStorage: M.any(),
instanceAdmin: M.any(),
seatHandleToSeatAdmin: M.any(),
adminNode: M.any(),
});

const makeZoeInstanceAdmin = prepareExoClass(
zoeBaggage,
'zoeInstanceAdmin',
Expand Down Expand Up @@ -147,6 +154,9 @@ export const makeStartInstance = (
return state.instanceAdmin.isBlocked(string);
},
},
{
stateShape: InstanceAdminStateShape,
},
);

const prepareEmptyFacet = facetName =>
Expand Down

0 comments on commit 5685735

Please sign in to comment.