Skip to content

Commit

Permalink
fix: distributionLimitsEqual between 0 and undefined
Browse files Browse the repository at this point in the history
Fies bug where switching from payouts 0 to infinite wasn't registering as a diff
  • Loading branch information
aeolianeth committed Dec 10, 2024
1 parent 0464a90 commit 1eb1748
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/packages/v2v3/utils/distributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ export function ensureSplitsSumTo100Percent({
return adjustedSplits
}

export function roundSplitPercents({ splits }: { splits: Split[]}) {
return splits.map((split) => {
export function roundSplitPercents({ splits }: { splits: Split[] }) {
return splits.map(split => {
return {
...split,
percent: Math.round(split.percent),
Expand Down Expand Up @@ -183,7 +183,7 @@ export function adjustedSplitPercents({
amount: currentAmount,
distributionLimit: parseFloat(newDistributionLimit),
})

const adjustedSplit = {
beneficiary: split.beneficiary,
percent: newPercent,
Expand Down Expand Up @@ -269,5 +269,18 @@ export function distributionLimitsEqual(
) {
return true
}
return distributionLimit1?.eq(distributionLimit2 ?? 0)

// get around limitation of BigNumber comparison, where one value can't be undefined
if (
(typeof distributionLimit1 === 'undefined' && distributionLimit2) ||
(typeof distributionLimit2 === 'undefined' && distributionLimit1)
) {
return false
}

if (distributionLimit1 && distributionLimit2) {
return distributionLimit1.eq(distributionLimit2 ?? null)
}

return false
}

0 comments on commit 1eb1748

Please sign in to comment.