Skip to content

Commit

Permalink
adds test for payoutsched
Browse files Browse the repository at this point in the history
  • Loading branch information
FlacoJones committed Mar 20, 2023
1 parent 69277cc commit bff7ed3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 8 additions & 2 deletions __tests__/Batch/batch.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { convertPayoutScheduleToBigInt } from '../../lib/batchUtils'

describe('Batch Mint', () => {
it('should pass', () => {
expect(true).toEqual(true);
it('should pass', async () => {
const payoutScheduleString = '[375.0, 375.0, 375.0, 375.0, 750.0, 750.0, 750.0, 750.0, 833.33, 833.33, 833.33]'

const convertedToBigInt = convertPayoutScheduleToBigInt(payoutScheduleString, 6)

expect(convertedToBigInt.toString()).toEqual('375000000,375000000,375000000,375000000,750000000,750000000,750000000,750000000,833330000,833330000,833330000');
});
});
4 changes: 1 addition & 3 deletions lib/batchUtils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { ethers } from 'ethers';

const convertPayoutScheduleToBigInt = async (payoutSchedule, decimals) => {
const convertPayoutScheduleToBigInt = (payoutSchedule, decimals) => {
const payoutScheduleParsed = payoutSchedule && JSON.parse(payoutSchedule);

let decimals = parseInt(token.decimals) || 18;

const newPayoutSchedule = payoutScheduleParsed.map((tierVolume) => {
let formattedVolume = tierVolume * 10 ** decimals;
return ethers.BigNumber.from(formattedVolume.toLocaleString('fullwide', { useGrouping: false }));
Expand Down

0 comments on commit bff7ed3

Please sign in to comment.