Skip to content

Commit

Permalink
fix: works again after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Jan 20, 2023
1 parent 0b50061 commit abcd42a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ test.serial('errors', async t => {
error:
'Error: In "pushPrice" method of (OracleAdmin): arg 0: unitPrice: number 1 - Must be a bigint',
// trivially satisfied because the Want is empty
numWantsSatisfied: 1,
numWantsSatisfied: Infinity,
},
);
await eventLoopIteration();
Expand All @@ -289,7 +289,7 @@ test.serial('errors', async t => {
}),
{
error: undefined,
numWantsSatisfied: 1,
numWantsSatisfied: Infinity,
},
);
await eventLoopIteration();
Expand All @@ -302,7 +302,7 @@ test.serial('errors', async t => {
}),
{
error: 'Error: cannot report on previous rounds',
numWantsSatisfied: 1,
numWantsSatisfied: Infinity,
},
);
});
5 changes: 3 additions & 2 deletions packages/zoe/src/cleanProposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ export const scaleAmount = (amount, multiples) => {
return amount;
}
const { brand, value } = amount;
if (typeof value !== 'bigint') {
throw Fail`multiples > 1 not yet implemented for non-fungibles: ${multiples} * ${amount}`;
}
assert(value >= 1n);
typeof value === 'bigint' ||
Fail`multiples > 1 not yet implemented for non-fungibles: ${multiples} * ${amount}`;
return harden({ brand, value: natSafeMath.multiply(value, multiples) });
};
harden(scaleAmount);
13 changes: 5 additions & 8 deletions packages/zoe/src/contractFacet/offerSafety.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ const { Fail } = assert;
const { entries } = Object;

/**
* Helper to perform numWantsSatisfied and satisfiesGive. How many times
* Helper to perform numWantsSatisfied and numGivesSatisfied. How many times
* does the `allocation` satisfy the `giveOrWant`?
*
* To prepare for multiples, numWantsSatisfied and satisfiesGive return 0 or 1.
* isOfferSafe will still be boolean. When we have Multiples, numWantsSatisfied and
* satisfiesGive will tell how many times the offer was matched.
*
* @param {AmountKeywordRecord} giveOrWant
* @param {AmountKeywordRecord} allocation
* @returns {number} If the giveOrWant is empty, then any allocation satisfies
Expand Down Expand Up @@ -70,7 +66,7 @@ harden(numWantsSatisfied);
/**
* For this allocation to count as a full refund, the allocated
* amounts must be greater than or equal to what was originally
* offered (proposal.give).
* offered (proposal.give * proposal.multiples).
*
* @param {ProposalRecord} proposal - the rules that accompanied the
* escrow of payments that dictate what the user expected to get back
Expand All @@ -85,8 +81,9 @@ harden(numWantsSatisfied);
* it an `Infinity` number of times.
*/
// Commented out because not currently used
// const satisfiesGive = (proposal, allocation) =>
// satisfiesInternal(proposal.give, allocation);
// const numGivesSatisfied = (proposal, allocation) =>
// numSatisfied(proposal.give, allocation);
// harden(numGivesSatisfied);

/**
* `isOfferSafe` checks offer safety for a single offer.
Expand Down

0 comments on commit abcd42a

Please sign in to comment.