Skip to content

Commit

Permalink
refactor(inter): require storageNode and marshaller
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jul 14, 2022
1 parent 4bb4ebd commit d7c5b6c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
5 changes: 3 additions & 2 deletions packages/run-protocol/src/contractSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ export const checkDebtLimit = (debtLimit, totalDebt, toMint) => {

/**
* @template T
* @param {ERef<StorageNode>} [storageNode]
* @param {ERef<Marshaller>} [marshaller]
* @param {ERef<StorageNode>} storageNode
* @param {ERef<Marshaller>} marshaller
* @returns {MetricsPublisherKit<T>}
*/
export const makeMetricsPublisherKit = (storageNode, marshaller) => {
assert(storageNode && marshaller, 'Missing storageNode or marshaller');
/** @type {import('@agoric/notifier').StoredPublisherKit<T>} */
const kit = makeStoredPublisherKit(storageNode, marshaller, 'metrics');
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/run-protocol/src/reserve/assetReserve.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const nonalphanumeric = /[^A-Za-z0-9]/g;
* @param {{
* feeMintAccess: FeeMintAccess,
* initialPoserInvitation: Payment,
* marshaller?: ERef<Marshaller>,
* storageNode?: ERef<StorageNode>,
* marshaller: ERef<Marshaller>,
* storageNode: ERef<StorageNode>,
* }} privateArgs
*/
const start = async (zcf, privateArgs) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/run-protocol/src/runStake/runStake.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ const { values } = Object;
* feeMintAccess: FeeMintAccess,
* initialPoserInvitation: Invitation,
* lienBridge: ERef<StakingAuthority>,
* storageNode?: StorageNode,
* marshaller?: Marshaller,
* storageNode: StorageNode,
* marshaller: Marshaller,
* }} RunStakePrivateArgs
*
* The creator facet can make an `AttestationMaker` for each account, which
Expand Down Expand Up @@ -98,6 +98,7 @@ export const start = async (
} = zcf.getTerms();
assert.typeof(chargingPeriod, 'bigint', 'chargingPeriod must be a bigint');
assert.typeof(recordingPeriod, 'bigint', 'recordingPeriod must be a bigint');
assert(storageNode && marshaller, 'missing storageNode or marshaller');

/** @type {ZCFMint<'nat'>} */
const debtMint = await zcf.registerFeeMint(KW.Debt, feeMintAccess);
Expand Down
8 changes: 4 additions & 4 deletions packages/run-protocol/src/vaultFactory/vaultDirector.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const { details: X, quote: q } = assert;
* zcf: import('./vaultFactory.js').VaultFactoryZCF,
* shortfallInvitation: Invitation,
* shortfallReporter: import('../reserve/assetReserve.js').ShortfallReporter,
* storageNode?: ERef<StorageNode>,
* marshaller?: ERef<Marshaller>,
* storageNode: ERef<StorageNode>,
* marshaller: ERef<Marshaller>,
* }>} ImmutableState
*
* @typedef {{
Expand Down Expand Up @@ -117,8 +117,8 @@ const metricsOf = state => {
* @param {State['zcf']} zcf
* @param {State['directorParamManager']} directorParamManager
* @param {State['debtMint']} debtMint
* @param {ERef<StorageNode>} [storageNode]
* @param {ERef<Marshaller>} [marshaller]
* @param {ERef<StorageNode>} storageNode
* @param {ERef<Marshaller>} marshaller
* @returns {State}
*/
const initState = (
Expand Down
4 changes: 2 additions & 2 deletions packages/run-protocol/src/vaultFactory/vaultFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ import { makeVaultDirector } from './vaultDirector.js';
* feeMintAccess: FeeMintAccess,
* initialPoserInvitation: Invitation,
* initialShortfallInvitation: Invitation,
* storageNode?: ERef<StorageNode>,
* marshaller?: ERef<Marshaller>,
* storageNode: ERef<StorageNode>,
* marshaller: ERef<Marshaller>,
* }} privateArgs
*/
export const start = async (zcf, privateArgs) => {
Expand Down
12 changes: 8 additions & 4 deletions packages/run-protocol/src/vaultFactory/vaultManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ const trace = makeTracer('VM');
* debtBrand: Brand<'nat'>,
* debtMint: ZCFMint<'nat'>,
* factoryPowers: import('./vaultDirector.js').FactoryPowersFacet,
* marshaller?: ERef<Marshaller>,
* marshaller: ERef<Marshaller>,
* metricsPublication: IterationObserver<MetricsNotification>,
* metricsSubscription: StoredSubscription<MetricsNotification>,
* periodNotifier: ERef<Notifier<bigint>>,
* poolIncrementSeat: ZCFSeat,
* priceAuthority: ERef<PriceAuthority>,
* prioritizedVaults: ReturnType<typeof makePrioritizedVaults>,
* storageNode?: ERef<StorageNode>,
* storageNode: ERef<StorageNode>,
* zcf: import('./vaultFactory.js').VaultFactoryZCF,
* }>} ImmutableState
*/
Expand Down Expand Up @@ -155,8 +155,8 @@ const provideEphemera = makeEphemeraProvider(() => ({
* @param {import('./vaultDirector.js').FactoryPowersFacet} factoryPowers
* @param {ERef<TimerService>} timerService
* @param {Timestamp} startTimeStamp
* @param {ERef<StorageNode>} [storageNode]
* @param {ERef<Marshaller>} [marshaller]
* @param {ERef<StorageNode>} storageNode
* @param {ERef<Marshaller>} marshaller
*/
const initState = (
zcf,
Expand All @@ -169,6 +169,8 @@ const initState = (
storageNode,
marshaller,
) => {
assert(storageNode && marshaller, 'Missing storageNode or marshaller');

const periodNotifier = E(timerService).makeNotifier(
0n,
factoryPowers.getGovernedParams().getChargingPeriod(),
Expand All @@ -195,6 +197,7 @@ const initState = (
debtBrand,
debtMint,
factoryPowers,
marshaller,
metricsSubscription,
metricsPublication,
periodNotifier,
Expand All @@ -204,6 +207,7 @@ const initState = (
* A store for vaultKits prioritized by their collaterization ratio.
*/
prioritizedVaults: makePrioritizedVaults(),
storageNode,
zcf,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ const trace = makeTracer('XykAmm', false);
* @param {ZCF<AMMTerms>} zcf
* @param {{
* initialPoserInvitation: Invitation,
* storageNode?: ERef<StorageNode>,
* marshaller?: ERef<Marshaller>,
* storageNode: ERef<StorageNode>,
* marshaller: ERef<Marshaller>,
* }} privateArgs
*/
const start = async (zcf, privateArgs) => {
Expand Down

0 comments on commit d7c5b6c

Please sign in to comment.