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

Commit 09b4f20

Browse files
author
Victor Wiebe
committed
feat: 🎸 adding more comments to generalTM and countTM. fix test
1 parent 67061d4 commit 09b4f20

File tree

3 files changed

+136
-13
lines changed

3 files changed

+136
-13
lines changed

‎src/contract_wrappers/modules/transfer_manager/__tests__/count_transfer_manager_wrapper.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ describe('CountTransferManagerWrapper', () => {
208208
// Real call
209209
const result = await target.maxHolderCount();
210210
// Result expectation
211-
expect(result).toBe(expectedResult);
211+
expect(result).toBe(expectedResult.toNumber());
212212
// Verifications
213213
verify(mockedContract.maxHolderCount).once();
214214
verify(mockedMethod.callAsync()).once();

‎src/contract_wrappers/modules/transfer_manager/count_transfer_manager_wrapper.ts‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,22 @@ interface GetCountTransferManagerLogsAsyncParams extends GetLogs {
6565
(params: GetUnpauseLogsAsyncParams): Promise<LogWithDecodedArgs<CountTransferManagerUnpauseEventArgs>[]>;
6666
}
6767

68+
/**
69+
* @param from Address of the sender
70+
* @param to Address of the receiver
71+
* @param amount Amount to send
72+
* @param data Data value
73+
*/
6874
interface VerifyTransferParams {
6975
from: string;
7076
to: string;
7177
amount: BigNumber;
7278
data: string;
7379
}
7480

81+
/**
82+
* @param maxHolderCount is the new maximum amount of token holders
83+
*/
7584
interface ChangeHolderCountParams extends TxParams {
7685
maxHolderCount: number;
7786
}
@@ -97,26 +106,47 @@ export default class CountTransferManagerWrapper extends ModuleWrapper {
97106
this.contract = contract;
98107
}
99108

109+
/**
110+
* unpause the module
111+
*/
100112
public unpause = async (params: TxParams) => {
101113
assert.assert(await this.paused(), 'Controller not currently paused');
102114
assert.assert(await this.isCallerTheSecurityTokenOwner(params.txData), 'Sender is not owner');
103115
return (await this.contract).unpause.sendTransactionAsync(params.txData, params.safetyFactor);
104116
};
105117

118+
/**
119+
* check if module paused
120+
*/
106121
public paused = async () => {
107122
return (await this.contract).paused.callAsync();
108123
};
109124

125+
/**
126+
* pause the module
127+
*/
110128
public pause = async (params: TxParams) => {
111129
assert.assert(!(await this.paused()), 'Controller currently paused');
112130
assert.assert(await this.isCallerTheSecurityTokenOwner(params.txData), 'Sender is not owner');
113131
return (await this.contract).pause.sendTransactionAsync(params.txData, params.safetyFactor);
114132
};
115133

116-
public maxHolderCount = async () => {
117-
return (await this.contract).maxHolderCount.callAsync();
134+
/**
135+
*The maximum number of concurrent token holders
136+
*/
137+
public maxHolderCount = async (): Promise<number> => {
138+
return (await (await this.contract).maxHolderCount.callAsync()).toNumber();
118139
};
119140

141+
/**
142+
*Used to verify the transfer transaction and prevent a transfer if it passes the allowed amount of token holders
143+
* @dev module.verifyTransfer is called by SecToken.canTransfer and does not receive the updated holderCount therefore
144+
* verifyTransfer has to manually account for pot. tokenholder changes (by mimicking TokenLib.adjustInvestorCount).
145+
* module.executeTransfer is called by SecToken.transfer|issue|others and receives an updated holderCount
146+
* as sectoken calls TokenLib.adjustInvestorCount before executeTransfer.
147+
* @return boolean transfer result
148+
* @return address
149+
*/
120150
public verifyTransfer = async (params: VerifyTransferParams) => {
121151
assert.isETHAddressHex('from', params.from);
122152
assert.isETHAddressHex('to', params.to);
@@ -134,6 +164,9 @@ export default class CountTransferManagerWrapper extends ModuleWrapper {
134164
};
135165
};
136166

167+
/**
168+
* Sets the cap for the amount of token holders there can be
169+
*/
137170
public changeHolderCount = async (params: ChangeHolderCountParams) => {
138171
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
139172
return (await this.contract).changeHolderCount.sendTransactionAsync(

‎src/contract_wrappers/modules/transfer_manager/general_transfer_manager_wrapper.ts‎

Lines changed: 100 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,37 @@ interface GetGeneralTransferManagerLogsAsyncParams extends GetLogs {
134134
>;
135135
}
136136

137+
/**
138+
* @param address Address noncemap related to
139+
* @param nonce Nonce of the signature
140+
*/
137141
interface NonceMapParams {
138142
address: string;
139143
nonce: number;
140144
}
141145

146+
/**
147+
* @param defaultCanSendAfter default for zero canSendAfter
148+
* @param defaultCanReceiveAfter default for zero canReceiveAfter
149+
*/
142150
interface ChangeDefaultsParams extends TxParams {
143151
defaultFromTime: Date;
144152
defaultToTime: Date;
145153
}
146154

155+
/**
156+
* @param issuanceAddress new address for the issuance
157+
*/
147158
interface ChangeIssuanceAddressParams extends TxParams {
148159
issuanceAddress: string;
149160
}
150161

162+
/**
163+
* @param investor is the address to whitelist
164+
* @param canSendAfter is the moment when the sale lockup period ends and the investor can freely sell or transfer their tokens
165+
* @param canReceiveAfter is the moment when the purchase lockup period ends and the investor can freely purchase or receive tokens from others
166+
* @param expiryTime is the moment till investors KYC will be validated. After that investor need to do re-KYC
167+
*/
151168
interface ModifyKYCDataParams extends TxParams {
152169
investor: string;
153170
canSendAfter: Date;
@@ -176,15 +193,25 @@ interface ModifyKYCDataSignedParams extends TxParams {
176193
signature: string;
177194
}
178195

196+
/**
197+
* @param investor Address
198+
* @param flag FlagsType
199+
*/
179200
interface GetInvestorFlag {
180201
investor: string;
181202
flag: FlagsType;
182203
}
183204

205+
/**
206+
* @param investor Address
207+
*/
184208
interface GetInvestorFlags {
185209
investor: string;
186210
}
187211

212+
/**
213+
* @param investors Address array
214+
*/
188215
interface GetKYCDataParams {
189216
investors: string[];
190217
}
@@ -214,6 +241,7 @@ interface ModifyInvestorFlagMulti extends TxParams {
214241
/**
215242
* @param from Address of the sender
216243
* @param to Address of the receiver
244+
* @param data Data value
217245
*/
218246
interface ExecuteTransfer extends TxParams {
219247
from: string;
@@ -285,6 +313,10 @@ interface ModifyKYCDataSignedMulti extends TxParams {
285313
signature: string;
286314
}
287315

316+
/**
317+
* @param fromIndex From index in range
318+
* @param toIndex To index in range
319+
*/
288320
interface GetInvestors {
289321
fromIndex: number;
290322
toIndex: number;
@@ -339,32 +371,53 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
339371
this.contract = contract;
340372
}
341373

374+
/**
375+
* unpause the module
376+
*/
342377
public unpause = async (params: TxParams) => {
343378
assert.assert(await this.paused(), 'Controller not currently paused');
344379
assert.assert(await this.isCallerTheSecurityTokenOwner(params.txData), 'Sender is not owner');
345380
return (await this.contract).unpause.sendTransactionAsync(params.txData, params.safetyFactor);
346381
};
347382

383+
/**
384+
* check if the module is paused
385+
*/
348386
public paused = async (): Promise<boolean> => {
349387
return (await this.contract).paused.callAsync();
350388
};
351389

390+
/**
391+
* pause the module
392+
*/
352393
public pause = async (params: TxParams) => {
353394
assert.assert(!(await this.paused()), 'Controller currently paused');
354395
assert.assert(await this.isCallerTheSecurityTokenOwner(params.txData), 'Sender is not owner');
355396
return (await this.contract).pause.sendTransactionAsync(params.txData, params.safetyFactor);
356397
};
357398

358-
public nonceMap = async (params: NonceMapParams) => {
399+
/**
400+
* Map of used nonces by customer
401+
* @return boolean result
402+
*/
403+
public nonceMap = async (params: NonceMapParams): Promise<boolean> => {
359404
assert.isETHAddressHex('address', params.address);
360405
return (await this.contract).nonceMap.callAsync(params.address, numberToBigNumber(params.nonce));
361406
};
362407

363-
public issuanceAddress = async () => {
408+
/**
409+
* Address from which issuances arrive
410+
*/
411+
public issuanceAddress = async (): Promise<string> => {
364412
return (await this.contract).issuanceAddress.callAsync();
365413
};
366414

367-
public defaults = async () => {
415+
/**
416+
* Offset to be applied to all timings (except KYC expiry)
417+
* @return canSendAfter
418+
* @return canReceiveAfter
419+
*/
420+
public defaults = async (): Promise<Defaults> => {
368421
const result = await (await this.contract).defaults.callAsync();
369422
const typedResult: Defaults = {
370423
canSendAfter: bigNumberToDate(result[0]),
@@ -373,6 +426,9 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
373426
return typedResult;
374427
};
375428

429+
/**
430+
* Used to change the default times used when canSendAfter / canReceiveAfter are zero
431+
*/
376432
public changeDefaults = async (params: ChangeDefaultsParams) => {
377433
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
378434
return (await this.contract).changeDefaults.sendTransactionAsync(
@@ -383,6 +439,9 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
383439
);
384440
};
385441

442+
/**
443+
* Used to change the Issuance Address
444+
*/
386445
public changeIssuanceAddress = async (params: ChangeIssuanceAddressParams) => {
387446
assert.isETHAddressHex('issuanceAddress', params.issuanceAddress);
388447
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
@@ -393,6 +452,9 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
393452
);
394453
};
395454

455+
/**
456+
* Add or remove KYC info of an investor.
457+
*/
396458
public modifyKYCData = async (params: ModifyKYCDataParams) => {
397459
assert.isNonZeroETHAddressHex('investor', params.investor);
398460
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
@@ -409,7 +471,10 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
409471
);
410472
};
411473

412-
public getInvestorFlag = async (params: GetInvestorFlag) => {
474+
/**
475+
* Gets the investor flag
476+
*/
477+
public getInvestorFlag = async (params: GetInvestorFlag): Promise<boolean> => {
413478
const result = await (await this.contract).getInvestorFlag.callAsync(params.investor, params.flag);
414479
return result;
415480
};
@@ -462,6 +527,9 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
462527
};
463528
};
464529

530+
/**
531+
* Get all investor flags
532+
*/
465533
public getAllInvestorFlags = async () => {
466534
const result = await (await this.contract).getAllInvestorFlags.callAsync();
467535
const [investors, flags] = result;
@@ -472,13 +540,19 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
472540
return investorFlags;
473541
};
474542

543+
/**
544+
* Gets the investor flags
545+
*/
475546
public getInvestorFlags = async (params: GetInvestorFlags) => {
476547
const { investor } = params;
477548
const flags = await (await this.contract).getInvestorFlags.callAsync(investor);
478549
return this.unpackFlags(investor, flags);
479550
};
480551

481-
public getAllKYCData = async () => {
552+
/**
553+
* Returns list of all investors data
554+
*/
555+
public getAllKYCData = async (): Promise<KYCDataWithInvestor[]> => {
482556
const result = await (await this.contract).getAllKYCData.callAsync();
483557
const typedResult: KYCDataWithInvestor[] = [];
484558
for (let i = 0; i < result[0].length; i += 1) {
@@ -493,7 +567,13 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
493567
return typedResult;
494568
};
495569

496-
public getKYCData = async (params: GetKYCDataParams) => {
570+
/**
571+
* Returns list of specified investors data
572+
* @returns canSendAfter array
573+
* @returns canReceiveAfter array
574+
* @returns expiryTime array
575+
*/
576+
public getKYCData = async (params: GetKYCDataParams): Promise<KYCData[]> => {
497577
const result = await (await this.contract).getKYCData.callAsync(params.investors);
498578
const typedResult: KYCData[] = [];
499579
for (let i = 0; i < result[0].length; i += 1) {
@@ -520,6 +600,9 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
520600
return weiToValue(result, decimals);
521601
};
522602

603+
/**
604+
* Adds or removes addresses from the whitelist - can be called by anyone with a valid signature
605+
*/
523606
public modifyKYCDataSigned = async (params: ModifyKYCDataSignedParams) => {
524607
assert.isNonZeroETHAddressHex('investor', params.investor);
525608
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
@@ -700,16 +783,18 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
700783

701784
/**
702785
* Returns list of all investors
786+
* @return investor array
703787
*/
704-
public getAllInvestors = async () => {
788+
public getAllInvestors = async (): Promise<string[]> => {
705789
const result = await (await this.contract).getAllInvestors.callAsync();
706790
return result;
707791
};
708792

709793
/**
710794
* Returns list of investors in a range
795+
* @return investor array
711796
*/
712-
public getInvestors = async (params: GetInvestors) => {
797+
public getInvestors = async (params: GetInvestors): Promise<string[]> => {
713798
const result = await (await this.contract).getInvestors.callAsync(
714799
new BigNumber(params.fromIndex),
715800
new BigNumber(params.toIndex),
@@ -719,8 +804,9 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
719804

720805
/**
721806
* Return the permissions flags that are associated with general transfer manager
807+
* @return array of Perm type
722808
*/
723-
public getPermissions = async () => {
809+
public getPermissions = async (): Promise<Perm[]> => {
724810
const call = await (await this.contract).getPermissions.callAsync();
725811
const result: Perm[] = [];
726812
for (let i = 0; i < call.length; i += 1) {
@@ -741,7 +827,11 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
741827
return result;
742828
};
743829

744-
public getAddressBytes32 = async () => {
830+
/**
831+
* Get Address bytes32 string value
832+
* @return bytes32 to string representation
833+
*/
834+
public getAddressBytes32 = async (): Promise<string> => {
745835
const result = await (await this.contract).getAddressBytes32.callAsync();
746836
return bytes32ToString(result);
747837
};

0 commit comments

Comments
 (0)