Skip to content

Commit bffdec5

Browse files
committed
fixup! amountMat
1 parent 20b287d commit bffdec5

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

packages/ERTP/src/amountMath.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import { copyBagMathHelpers } from './mathHelpers/copyBagMathHelpers.js';
99
import { AmountShape } from './typeGuards.js';
1010

1111
/**
12-
* @import {Passable} from '@endo/pass-style'
1312
* @import {Key, CopyBag, CopySet} from '@endo/patterns';
14-
* @import {Amount, AmountBound, AmountHasBound, AmountValue, AssetValueForKind, Brand, CopyBagAmount, CopySetAmount, MathHelpers, NatAmount, NatValue, SetAmount, SetValue} from './types.js';
13+
* @import {Amount, AmountBound, AssetValueForKind, Brand, CopyBagAmount, CopySetAmount, MathHelpers, NatAmount, NatValue, SetAmount, SetValue, HasBound} from './types.js';
1514
*/
1615

1716
// NB: AssetKind is both a constant for enumerated values and a type for those values.
@@ -198,15 +197,13 @@ const coerceLR = (h, leftAmount, rightAmount) => {
198197
* @returns {boolean}
199198
*/
200199
const isGTE = (leftAmount, rightAmountBound, brand = undefined) => {
201-
if (kindOf(rightAmountBound) === 'match:containerHas') {
200+
const { brand: rightBrand, value: rightValueBound } = rightAmountBound;
201+
if (kindOf(rightValueBound) === 'match:containerHas') {
202202
mustMatch(leftAmount, AmountShape, 'left amount');
203203
const { brand: leftBrand, value: leftValue } = leftAmount;
204204
const {
205-
brand: rightBrand,
206-
value: {
207-
payload: [elementPatt, bound],
208-
},
209-
} = /** @type {AmountHasBound} */ (rightAmountBound);
205+
payload: [elementPatt, bound],
206+
} = /** @type {HasBound} */ (rightValueBound);
210207
optionalBrandCheck(leftBrand, brand);
211208
optionalBrandCheck(rightBrand, brand);
212209
leftBrand === rightBrand ||
@@ -392,15 +389,13 @@ export const AmountMath = {
392389
* @returns {L}
393390
*/
394391
subtract: (leftAmount, rightAmountBound, brand = undefined) => {
395-
if (kindOf(rightAmountBound) === 'match:containerHas') {
392+
const { brand: rightBrand, value: rightValueBound } = rightAmountBound;
393+
if (kindOf(rightValueBound) === 'match:containerHas') {
396394
mustMatch(leftAmount, AmountShape, 'left amount');
397395
const { brand: leftBrand, value: leftValue } = leftAmount;
398396
const {
399-
brand: rightBrand,
400-
value: {
401-
payload: [elementPatt, bound],
402-
},
403-
} = /** @type {AmountHasBound} */ (rightAmountBound);
397+
payload: [elementPatt, bound],
398+
} = /** @type {HasBound} */ (rightValueBound);
404399
optionalBrandCheck(leftBrand, brand);
405400
optionalBrandCheck(rightBrand, brand);
406401
leftBrand === rightBrand ||

0 commit comments

Comments
 (0)