-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
157 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
client/src/components/Allocation/AllocationItem/utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getAdjustedValue } from './utils'; | ||
|
||
describe('getAdjustedValue', () => { | ||
describe('multiply', () => { | ||
it('properly handles 0.0000001 ETH => 100 GWEI', () => { | ||
expect(getAdjustedValue('0.0000001', true, 'multiply')).toEqual('100'); | ||
}); | ||
|
||
it('properly handles 0.00000005 ETH => 50 GWEI', () => { | ||
expect(getAdjustedValue('0.00000005', true, 'multiply')).toEqual('50'); | ||
}); | ||
|
||
it('properly handles 0.00000003 ETH => 30 GWEI', () => { | ||
expect(getAdjustedValue('0.00000003', true, 'multiply')).toEqual('30'); | ||
}); | ||
}); | ||
|
||
describe('divide', () => { | ||
it('properly handles 100 GWEI => 0.0000001 ETH', () => { | ||
expect(getAdjustedValue('100', true, 'divide')).toEqual('0.0000001'); | ||
}); | ||
|
||
it('properly handles 50 GWEI => 0.00000005 ETH', () => { | ||
expect(getAdjustedValue('50', true, 'divide')).toEqual('0.00000005'); | ||
}); | ||
|
||
it('properly handles 30 GWEI => 0.00000003 ETH', () => { | ||
expect(getAdjustedValue('30', true, 'divide')).toEqual('0.00000003'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { formatUnitsBigInt } from 'utils/formatUnitsBigInt'; | ||
import { parseUnitsBigInt } from 'utils/parseUnitsBigInt'; | ||
import { comma } from 'utils/regExp'; | ||
|
||
export function getAdjustedValue( | ||
newValue: string, | ||
isGweiRange: boolean, | ||
operation: 'multiply' | 'divide', | ||
): string { | ||
if (isGweiRange && newValue) { | ||
const adjustedValueBigInt = | ||
operation === 'multiply' | ||
? parseUnitsBigInt(newValue) * 1000000000n | ||
: parseUnitsBigInt(newValue) / 1000000000n; | ||
return ( | ||
formatUnitsBigInt(adjustedValueBigInt) | ||
// @ts-expect-error TS method collision. | ||
.toLocaleString('fullwide', { | ||
maximumSignificantDigits: 18, | ||
useGrouping: false, | ||
}) | ||
.replace(comma, '.') | ||
); | ||
} | ||
return newValue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
client/src/components/Metrics/MetricsEpoch/MetricsEpochGridBelowThreshold/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export default interface MetricsEpochGridBelowThresholdProps { | ||
className?: string; | ||
ethBelowThreshold: bigint; | ||
isLoading: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...c/components/Metrics/MetricsEpoch/MetricsEpochGridDonationsVsPersonalAllocations/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export default interface MetricsEpochGridDonationsVsPersonalAllocationsProps { | ||
className?: string; | ||
isLoading: boolean; | ||
totalDonations: bigint; | ||
totalPersonal: bigint; | ||
totalUserDonationsWithPatronRewards: bigint; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
client/src/components/Metrics/MetricsEpoch/MetricsEpochGridFundsUsage/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export default interface MetricsEpochGridFundsUsageProps { | ||
className?: string; | ||
ethBelowThreshold: bigint; | ||
isLoading: boolean; | ||
totalUserDonationsWithPatronRewards: bigint; | ||
unusedRewards: bigint; | ||
} |
Oops, something went wrong.