Skip to content

Commit

Permalink
fix: make brand optional in the types of getAmountAllocated (#1760)
Browse files Browse the repository at this point in the history
* fix: make brand optional in the types of `getAmountAllocated`

* fix: add assert to fix the types

* chore: fix error message in test

* chore: change error message in brand assertion

Co-authored-by: Chris Hibbert <Chris-Hibbert@users.noreply.github.com>

* chore: fix error message

Co-authored-by: Chris Hibbert <Chris-Hibbert@users.noreply.github.com>
  • Loading branch information
katelynsills and Chris-Hibbert authored Sep 15, 2020
1 parent 1c8aa00 commit 3a98491
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/zoe/src/contractFacet/seat.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const makeZcfSeatAdminKit = (
if (currentAllocation[keyword] !== undefined) {
return currentAllocation[keyword];
}
assert(brand, `A brand must be supplied when the keyword is not defined`);
return getAmountMath(brand).getEmpty();
},
getCurrentAllocation: () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/contractFacet/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
* @property {() => Notifier<Allocation>} getNotifier
* @property {() => boolean} hasExited
* @property {() => ProposalRecord} getProposal
* @property {(keyword: Keyword, brand: Brand) => Amount} getAmountAllocated
* @property {(keyword: Keyword, brand: Brand=) => Amount} getAmountAllocated
* The brand is used for filling in an empty amount if the `keyword`
* is not present in the allocation
* @property {() => Allocation} getCurrentAllocation
Expand Down
5 changes: 1 addition & 4 deletions packages/zoe/test/unitTests/zcf/test-zcf.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,6 @@ test(`zcfSeat.getAmountAllocated from zcf.makeEmptySeatKit`, async t => {
// Again, mint some gains to change the allocation.
const { brand: brand2 } = await allocateEasy(zcf, 'Stuff2', zcfSeat, 'B', 6);

// TODO: make brand optional
// https://github.com/Agoric/agoric-sdk/issues/1725
t.deepEqual(zcfSeat.getAmountAllocated('B'), {
brand: brand2,
value: 6,
Expand All @@ -807,9 +805,8 @@ test(`zcfSeat.getAmountAllocated from zcf.makeEmptySeatKit`, async t => {
value: 6,
});

// @ts-ignore
t.throws(() => zcfSeat.getAmountAllocated('DoesNotExist'), {
message: `"brand" not found: (an undefined)\nSee console for error data.`,
message: `A brand must be supplied when the keyword is not defined`,
});
});

Expand Down

0 comments on commit 3a98491

Please sign in to comment.