From 32f13984751a5404aad3e9f3dc72b056292a78a3 Mon Sep 17 00:00:00 2001 From: Chris Hibbert Date: Mon, 16 Dec 2024 14:50:55 -0800 Subject: [PATCH] feat: add an accessor for the vaultDirector's parameters --- .../src/vaultFactory/vaultDirector.js | 6 +++- .../test/vaultFactory/vaultFactory.test.js | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/inter-protocol/src/vaultFactory/vaultDirector.js b/packages/inter-protocol/src/vaultFactory/vaultDirector.js index fdfa8d2f9d9..56e0706f3f1 100644 --- a/packages/inter-protocol/src/vaultFactory/vaultDirector.js +++ b/packages/inter-protocol/src/vaultFactory/vaultDirector.js @@ -325,6 +325,7 @@ const prepareVaultDirector = ( getGovernedParams: M.callWhen({ collateralBrand: BrandShape }).returns( M.record(), ), + getDirectorGovernedParams: M.call().returns(M.promise()), getInvitationAmount: M.call(M.string()).returns(AmountShape), getPublicTopics: M.call().returns(TopicsRecordShape), }), @@ -492,7 +493,7 @@ const prepareVaultDirector = ( }, /** * Note this works only for a collateral manager. For the director use, - * `getElectorateSubscription` + * `getDirectorGovernedParams` * * @param {{ collateralBrand: Brand }} selector */ @@ -500,6 +501,9 @@ const prepareVaultDirector = ( // TODO use named getters of TypedParamManager return vaultParamManagers.get(collateralBrand).getParams(); }, + getDirectorGovernedParams() { + return directorParamManager.getParams(); + }, /** @param {string} name */ getInvitationAmount(name) { return directorParamManager.getInvitationAmount(name); diff --git a/packages/inter-protocol/test/vaultFactory/vaultFactory.test.js b/packages/inter-protocol/test/vaultFactory/vaultFactory.test.js index f285b00bd00..f7d8b8bc296 100644 --- a/packages/inter-protocol/test/vaultFactory/vaultFactory.test.js +++ b/packages/inter-protocol/test/vaultFactory/vaultFactory.test.js @@ -2049,4 +2049,39 @@ test('governance publisher', async t => { LiquidationPenalty: { type: 'ratio' }, MintFee: { type: 'ratio' }, }); + + const params = await E(vfPublic).getDirectorGovernedParams(); + t.like(params, { + ChargingPeriod: { type: 'nat', value: 2n }, + Electorate: { type: 'invitation' }, + MinInitialDebt: { type: 'amount' }, + RecordingPeriod: { type: 'nat' }, + ReferencedUI: { value: 'abracadabra' }, + ShortfallInvitation: { type: 'invitation' }, + }); +}); + +test('access to director params', async t => { + const { aeth } = t.context; + + t.context.referencedUi = 'hocus pocus'; + const services = await setupServices( + t, + [500n, 15n], + aeth.make(900n), + undefined, + undefined, + 500n, + ); + const { vfPublic } = services.vaultFactory; + + const params = await E(vfPublic).getDirectorGovernedParams(); + t.like(params, { + ChargingPeriod: { type: 'nat', value: 2n }, + Electorate: { type: 'invitation' }, + MinInitialDebt: { type: 'amount' }, + RecordingPeriod: { type: 'nat' }, + ReferencedUI: { value: 'hocus pocus' }, + ShortfallInvitation: { type: 'invitation' }, + }); });