-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 parent
bff7ed3
commit 0993e6c
Showing
3 changed files
with
75 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { convertPayoutScheduleToBigInt } from '../../lib/batchUtils' | ||
import { convertPayoutScheduleToBigInt } from '../../lib/batchUtils'; | ||
|
||
describe('Batch Mint', () => { | ||
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) | ||
const payoutScheduleString = '[375.0, 375.0, 375.0, 375.0, 750.0, 750.0, 750.0, 750.0, 833.33, 833.33, 833.33]'; | ||
|
||
expect(convertedToBigInt.toString()).toEqual('375000000,375000000,375000000,375000000,750000000,750000000,750000000,750000000,833330000,833330000,833330000'); | ||
const convertedToBigInt = convertPayoutScheduleToBigInt(payoutScheduleString, 6); | ||
|
||
expect(convertedToBigInt.toString()).toEqual( | ||
'375000000,375000000,375000000,375000000,750000000,750000000,750000000,750000000,833330000,833330000,833330000' | ||
); | ||
}); | ||
}); |
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,27 +1,40 @@ | ||
import { ethers } from 'ethers'; | ||
|
||
const convertCsvToJson = (csvData) => { | ||
const headers = csvData[0]; | ||
const rows = csvData.slice(1); | ||
const jsonData = rows.map((row) => { | ||
const jsonObject = {}; | ||
row.forEach((cell, index) => { | ||
jsonObject[headers[index]] = cell; | ||
}); | ||
return jsonObject; | ||
}); | ||
return jsonData; | ||
}; | ||
|
||
const convertPayoutScheduleToBigInt = (payoutSchedule, decimals) => { | ||
const payoutScheduleParsed = payoutSchedule && JSON.parse(payoutSchedule); | ||
const payoutScheduleParsed = payoutSchedule && JSON.parse(payoutSchedule); | ||
|
||
const newPayoutSchedule = payoutScheduleParsed.map((tierVolume) => { | ||
let formattedVolume = tierVolume * 10 ** decimals; | ||
return ethers.BigNumber.from(formattedVolume.toLocaleString('fullwide', { useGrouping: false })); | ||
}); | ||
const newPayoutSchedule = payoutScheduleParsed.map((tierVolume) => { | ||
let formattedVolume = tierVolume * 10 ** decimals; | ||
return ethers.BigNumber.from(formattedVolume.toLocaleString('fullwide', { useGrouping: false })); | ||
}); | ||
|
||
return newPayoutSchedule; | ||
} | ||
return newPayoutSchedule; | ||
}; | ||
|
||
const convertCsvToJson = (csvData) => { | ||
const headers = csvData[0]; | ||
const rows = csvData.slice(1); | ||
const jsonData = rows.map((row) => { | ||
const jsonObject = {}; | ||
row.forEach((cell, index) => { | ||
jsonObject[headers[index]] = cell; | ||
}); | ||
return jsonObject; | ||
}); | ||
return jsonData; | ||
const abiEncodeTieredFixed = (initializationData) => { | ||
let abiCoder = new ethers.utils.AbiCoder(); | ||
const initializationSchema = ['uint256[]', 'address', 'bool', 'bool', 'bool', 'string', 'string', 'string']; | ||
|
||
console.log(initializationData); | ||
|
||
const tieredFixedEncoded = abiCoder.encode(initializationSchema, initializationData); | ||
|
||
let tieredFixed = [3, `\"${tieredFixedEncoded}\"`]; | ||
|
||
return tieredFixed; | ||
}; | ||
|
||
export { convertPayoutScheduleToBigInt, convertCsvToJson } | ||
export { convertPayoutScheduleToBigInt, convertCsvToJson, abiEncodeTieredFixed }; |
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