Skip to content

Commit

Permalink
feat: add an accessor for the vaultDirector's parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Dec 16, 2024
1 parent 140c1be commit 84572e7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/inter-protocol/src/vaultFactory/vaultDirector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}),
Expand Down Expand Up @@ -492,14 +493,17 @@ const prepareVaultDirector = (
},
/**
* Note this works only for a collateral manager. For the director use,
* `getElectorateSubscription`
* `getDirectorGovernedParams`
*
* @param {{ collateralBrand: Brand }} selector
*/
getGovernedParams({ collateralBrand }) {
// TODO use named getters of TypedParamManager
return vaultParamManagers.get(collateralBrand).getParams();
},
getDirectorGovernedParams() {
return directorParamManager.getParams();
},
/** @param {string} name */
getInvitationAmount(name) {
return directorParamManager.getInvitationAmount(name);
Expand Down
35 changes: 35 additions & 0 deletions packages/inter-protocol/test/vaultFactory/vaultFactory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
});
});

0 comments on commit 84572e7

Please sign in to comment.