Skip to content

Commit 6f0d65e

Browse files
Merge pull request #497 from PolymathNetwork/chore/whitelist-date-validator
chore(issuer): ensure that the whitelist date is in YYYY format
2 parents 6ec97dc + ed47709 commit 6f0d65e

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ETH Address,Sell Restriction Date,Buy Restriction Date,KYC/AML Expiry Date,Can Buy From STO,Exempt From % Ownership,Is Accredited,Non-Accredited Limit
2-
0x592E80AD45c08aba6C5bBd2d5C5A097BDF35Dee1,1/1/22,6/4/24,1/1/21,TRUE,TRUE,TRUE,
3-
0xd9f346Bf88cA2cb7e11B0106018DE80A0169764D,12/21/30,12/21/30,10/10/24,TRUE,,TRUE,
4-
0xA1833Cd1a3e72335DE0b6945b5d83247F234d6e8,,,12/1/25,,TRUE,,1000
5-
0x07889A89C6854bb4Ec445825E680255b17751192,,,12/1/25,TRUE,TRUE,,
2+
0x592E80AD45c08aba6C5bBd2d5C5A097BDF35Dee1,1/1/2022,6/4/2024,1/1/2021,TRUE,TRUE,TRUE,
3+
0xd9f346Bf88cA2cb7e11B0106018DE80A0169764D,12/21/2030,12/21/2030,10/10/2024,TRUE,,TRUE,
4+
0xA1833Cd1a3e72335DE0b6945b5d83247F234d6e8,,,12/1/2025,,TRUE,,1000
5+
0x07889A89C6854bb4Ec445825E680255b17751192,,,12/1/2025,TRUE,TRUE,,

packages/polymath-issuer/src/utils/parsers/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,8 @@ export function parseWhitelistCsv(file: string) {
131131
return false;
132132
}
133133
if (value.split('/').length === 3) {
134-
let resultDate = moment(value, ['MM/DD/YY', 'MM/DD/YYYY']).toDate();
135-
const year = value.split(/\/|-/)[2];
136-
if (year.length === 2 && resultDate.getFullYear() < 2000) {
137-
resultDate.setFullYear(resultDate.getFullYear() + 100);
138-
}
139-
return resultDate;
134+
const regex = /\d\d?\/\d\d?\/\d{4}/;
135+
return regex.test(value) && moment(value, 'M/D/YYYY').toDate();
140136
}
141137
if (numericalRegex.test(value)) {
142138
return new BigNumber(value);

packages/polymath-issuer/testUtils/fixtures/csvFiles.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export const validWhitelistCsv = `\
22
ETH Address,Sell Restriction Date,Buy Restriction Date,KYC/AML Expiry Date,Can Buy From STO,Exempt From % Ownership,Is Accredited,Non-Accredited Limit
3-
0x592E80AD45c08aba6C5bBd2d5C5A097BDF35Dee1,1/1/22,6/4/24,1/1/21,TRUE,TRUE,FALSE,
4-
0xd9f346Bf88cA2cb7e11B0106018DE80A0169764D,12/21/30,12/21/30,10/10/24,TRUE,,TRUE,
5-
0xA1833Cd1a3e72335DE0b6945b5d83247F234d6e8,,,12/1/25,,TRUE,,1000
6-
0x07889A89C6854bb4Ec445825E680255b17751192,,,12/1/25,TRUE,TRUE,,
3+
0x592E80AD45c08aba6C5bBd2d5C5A097BDF35Dee1,1/1/2022,6/4/2024,1/1/2021,TRUE,TRUE,FALSE,
4+
0xd9f346Bf88cA2cb7e11B0106018DE80A0169764D,12/21/2030,12/21/2030,10/10/2024,TRUE,,TRUE,
5+
0xA1833Cd1a3e72335DE0b6945b5d83247F234d6e8,,,12/1/2025,,TRUE,,1000
6+
0x07889A89C6854bb4Ec445825E680255b17751192,,,12/1/2025,TRUE,TRUE,,
77
`;
88

99
export const invalidWhitelistCsv = `\

0 commit comments

Comments
 (0)