Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit 6e9f39d

Browse files
committed
fix: 🐛 disallow SC as a fundraise type for Capped STO
BREAKING CHANGE: `fundRaiseTypes` renamed to `fundRaiseType` and its type changed from `FundRaiseType[]` to `CappedSTOFundRaiseType` in the `data` parameter of `addModule` when attaching a Capped STO
1 parent ce9525b commit 6e9f39d

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/contract_wrappers/tokens/__tests__/security_token_wrapper.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
FULL_DECIMALS,
2828
Partition,
2929
Perm,
30+
CappedSTOFundRaiseType,
3031
} from '../../../types';
3132
import SecurityTokenWrapper from '../security_token_wrapper';
3233
import ContractFactory from '../../../factories/contractFactory';
@@ -4092,7 +4093,7 @@ describe('SecurityTokenWrapper', () => {
40924093
endTime: new Date(2031, 1),
40934094
cap: new BigNumber(1),
40944095
rate: new BigNumber(1),
4095-
fundRaiseTypes: [FundRaiseType.ETH],
4096+
fundRaiseType: CappedSTOFundRaiseType.ETH,
40964097
fundsReceiver: '0x2222222222222222222222222222222222222222',
40974098
};
40984099
const mockedCappedParams = {
@@ -4112,7 +4113,7 @@ describe('SecurityTokenWrapper', () => {
41124113
dateToBigNumber(mockedCappedParams.data.endTime).toNumber(),
41134114
valueToWei(mockedCappedParams.data.cap, expectedDecimalsResult).toString(),
41144115
valueToWei(mockedCappedParams.data.rate, FULL_DECIMALS).toString(),
4115-
mockedCappedParams.data.fundRaiseTypes,
4116+
[mockedCappedParams.data.fundRaiseType],
41164117
mockedCappedParams.data.fundsReceiver,
41174118
]);
41184119

@@ -4139,7 +4140,7 @@ describe('SecurityTokenWrapper', () => {
41394140
endTime: cappedParams.endTime,
41404141
cap: cappedParams.cap,
41414142
rate: cappedParams.rate,
4142-
fundRaiseTypes: cappedParams.fundRaiseTypes,
4143+
fundRaiseType: cappedParams.fundRaiseType,
41434144
fundsReceiver: cappedParams.fundsReceiver,
41444145
},
41454146
txData: mockedCappedParams.txData,

src/contract_wrappers/tokens/security_token_wrapper.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {
7272
Subscribe,
7373
SubscribeAsyncParams,
7474
TxParams,
75+
CappedSTOFundRaiseType,
7576
} from '../../types';
7677
import {
7778
bigNumberToDate,
@@ -791,7 +792,11 @@ interface CappedSTOData {
791792
endTime: Date;
792793
cap: BigNumber;
793794
rate: BigNumber;
794-
fundRaiseTypes: FundRaiseType[];
795+
/**
796+
* In the smart contracts, this parameter is a single-element array.
797+
* It has been abstracted and simplified here
798+
*/
799+
fundRaiseType: CappedSTOFundRaiseType;
795800
fundsReceiver: string;
796801
}
797802

@@ -1818,8 +1823,7 @@ export default class SecurityTokenWrapper extends ERC20TokenWrapper {
18181823
assert.isNonZeroETHAddressHex('Funds Receiver', data.fundsReceiver);
18191824
assert.isFutureDate(data.startTime, 'Start time date not valid');
18201825
assert.assert(data.endTime > data.startTime, 'End time not valid');
1821-
assert.isBigNumberGreaterThanZero(data.cap, 'Cap should be greater than 0');
1822-
assert.assert(data.fundRaiseTypes.length === 1, 'It only selects single fund raise type');
1826+
assert.isBigNumberGreaterThanZero(data.cap, 'Cap should be greater than 0');
18231827
};
18241828

18251829
private usdTieredSTOAssertions = async (data: USDTieredSTOData) => {
@@ -1878,7 +1882,7 @@ export default class SecurityTokenWrapper extends ERC20TokenWrapper {
18781882
dateToBigNumber((params.data as CappedSTOData).endTime).toNumber(),
18791883
valueToWei((params.data as CappedSTOData).cap, decimals).toString(),
18801884
valueToWei((params.data as CappedSTOData).rate, FULL_DECIMALS).toString(),
1881-
(params.data as CappedSTOData).fundRaiseTypes,
1885+
[(params.data as CappedSTOData).fundRaiseType], // the module's configure function expects an array
18821886
(params.data as CappedSTOData).fundsReceiver,
18831887
]);
18841888
break;

src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ export enum FundRaiseType {
103103
StableCoin = 2,
104104
}
105105

106+
export enum CappedSTOFundRaiseType {
107+
ETH = 0,
108+
POLY = 1,
109+
}
110+
106111
export enum FlagsType {
107112
IsAccredited,
108113
CanNotBuyFromSto,

0 commit comments

Comments
 (0)