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

Commit 00fe0d5

Browse files
author
Victor Wiebe
committed
feat: 🎸 manualApprovalTM comments. remove lint warning
1 parent 09b4f20 commit 00fe0d5

File tree

3 files changed

+131
-8
lines changed

3 files changed

+131
-8
lines changed

‎src/contract_wrappers/modules/checkpoint/__tests__/dividend_checkpoint_wrapper.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import ContractFactory from '../../../../factories/contractFactory';
1212
import {
1313
bytes32ToString,
1414
dateToBigNumber,
15-
numberToBigNumber,
1615
stringToBytes32,
1716
valueArrayToWeiArray,
1817
weiToValue,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ describe('ManualApprovalTransferManagerWrapper', () => {
950950
// Real call
951951
const result = await target.getTotalApprovalsLength();
952952
// Result expectation
953-
expect(result).toBe(expectedResult);
953+
expect(result).toBe(expectedResult.toNumber());
954954
// Verifications
955955
verify(mockedContract.getTotalApprovalsLength).once();
956956
verify(mockedMethod.callAsync()).once();

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

Lines changed: 130 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,33 @@ interface GetManualApprovalTransferManagerLogsAsyncParams extends GetLogs {
105105
(params: GetUnpauseLogsAsyncParams): Promise<LogWithDecodedArgs<ManualApprovalTransferManagerUnpauseEventArgs>[]>;
106106
}
107107

108+
/**
109+
* @param index
110+
*/
108111
interface ApprovalsParams {
109112
index: number;
110113
}
111114

115+
/**
116+
* @param from Address of the sender
117+
* @param to Address of the receiver
118+
* @param amount
119+
* @param data
120+
*/
112121
interface VerifyTransferParams {
113122
from: string;
114123
to: string;
115124
amount: BigNumber;
116125
data: string;
117126
}
118127

128+
/**
129+
* @param from is the address from which transfers are approved
130+
* @param to is the address to which transfers are approved
131+
* @param allowance is the approved amount of tokens
132+
* @param expiryTime is the time until which the transfer is allowed
133+
* @param description Description about the manual approval
134+
*/
119135
interface AddManualApprovalParams extends TxParams {
120136
from: string;
121137
to: string;
@@ -124,6 +140,13 @@ interface AddManualApprovalParams extends TxParams {
124140
description: string;
125141
}
126142

143+
/**
144+
* @param from is the address array from which transfers are approved
145+
* @param to is the address array to which transfers are approved
146+
* @param allowances is the array of approved amounts
147+
* @param expiryTimes is the array of the times until which eath transfer is allowed
148+
* @param descriptions is the description array for these manual approvals
149+
*/
127150
interface AddManualApprovalMultiParams extends TxParams {
128151
from: string[];
129152
to: string[];
@@ -132,6 +155,15 @@ interface AddManualApprovalMultiParams extends TxParams {
132155
descriptions: string[];
133156
}
134157

158+
/**
159+
* @param from is the address from which transfers are approved
160+
* @param to is the address to which transfers are approved
161+
* @param expiryTime is the time until which the transfer is allowed
162+
* @param changeInAllowance is the change in allowance
163+
* @param description Description about the manual approval
164+
* @param increase tells whether the allowances will be increased (true) or decreased (false).
165+
* or any value when there is no change in allowances
166+
*/
135167
interface ModifyManualApprovalParams extends TxParams {
136168
from: string;
137169
to: string;
@@ -141,6 +173,15 @@ interface ModifyManualApprovalParams extends TxParams {
141173
increase: boolean;
142174
}
143175

176+
/**
177+
* @param from is the address array from which transfers are approved
178+
* @param to is the address array to which transfers are approved
179+
* @param expiryTimes is the array of the times until which each transfer is allowed
180+
* @param changeInAllowance is the array of change in allowances
181+
* @param descriptions is the description array for these manual approvals
182+
* @param increase Array of bools that tells whether the allowances will be increased (true) or decreased (false).
183+
* or any value when there is no change in allowances
184+
*/
144185
interface ModifyManualApprovalMultiParams extends TxParams {
145186
from: string[];
146187
to: string[];
@@ -150,20 +191,36 @@ interface ModifyManualApprovalMultiParams extends TxParams {
150191
increase: boolean[];
151192
}
152193

194+
/**
195+
* @param from is the address from which transfers are approved
196+
* @param to is the address to which transfers are approved
197+
*/
153198
interface RevokeManualApprovalParams extends TxParams {
154199
from: string;
155200
to: string;
156201
}
157202

203+
/**
204+
* @param from is the address array from which transfers are approved
205+
* @param to is the address array to which transfers are approved
206+
*/
158207
interface RevokeManualApprovalMultiParams extends TxParams {
159208
from: string[];
160209
to: string[];
161210
}
162211

212+
/**
213+
* @param user Address of the holder corresponds to whom list of manual approvals
214+
* need to return
215+
*/
163216
interface GetActiveApprovalsToUserParams {
164217
user: string;
165218
}
166219

220+
/**
221+
* @param from Address of the sender
222+
* @param to Address of the receiver
223+
*/
167224
interface GetApprovalDetailsParams {
168225
from: string;
169226
to: string;
@@ -204,22 +261,36 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
204261
this.contract = contract;
205262
}
206263

264+
/**
265+
* unpause the module
266+
*/
207267
public unpause = async (params: TxParams) => {
208268
assert.assert(await this.paused(), 'Controller not currently paused');
209269
assert.assert(await this.isCallerTheSecurityTokenOwner(params.txData), 'Sender is not owner');
210270
return (await this.contract).unpause.sendTransactionAsync(params.txData, params.safetyFactor);
211271
};
212272

273+
/**
274+
* check if the module is paused
275+
*/
213276
public paused = async () => {
214277
return (await this.contract).paused.callAsync();
215278
};
216279

280+
/**
281+
* pause the module
282+
*/
217283
public pause = async (params: TxParams) => {
218284
assert.assert(!(await this.paused()), 'Controller currently paused');
219285
assert.assert(await this.isCallerTheSecurityTokenOwner(params.txData), 'Sender is not owner');
220286
return (await this.contract).pause.sendTransactionAsync(params.txData, params.safetyFactor);
221287
};
222288

289+
/**
290+
* An array to track all approvals. It is an unbounded array but it's not a problem as
291+
* it is never looped through in an on chain call. It is defined as an Array instead of mapping
292+
* just to make it easier for users to fetch list of all approvals through constant functions.
293+
*/
223294
public approvals = async (params: ApprovalsParams) => {
224295
const result = await (await this.contract).approvals.callAsync(numberToBigNumber(params.index));
225296
const decimals = await (await this.securityTokenContract()).decimals.callAsync();
@@ -233,10 +304,20 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
233304
return typedResult;
234305
};
235306

236-
public getInitFunction = async () => {
307+
/**
308+
* This function returns the signature of configure function
309+
*/
310+
public getInitFunction = async (): Promise<string> => {
237311
return (await this.contract).getInitFunction.callAsync();
238312
};
239313

314+
/**
315+
* Used to verify the transfer transaction (View)
316+
* Restrict the blacklist address to transfer tokens
317+
* if the current time is between the time frame define for the
318+
* blacklist type associated with the from address
319+
* @return Parse transfer result
320+
*/
240321
public verifyTransfer = async (params: VerifyTransferParams) => {
241322
assert.isETHAddressHex('from', params.from);
242323
assert.isETHAddressHex('to', params.to);
@@ -254,6 +335,9 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
254335
};
255336
};
256337

338+
/**
339+
* Adds a pair of addresses to manual approvals
340+
*/
257341
public addManualApproval = async (params: AddManualApprovalParams) => {
258342
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
259343
assert.isETHAddressHex('from', params.from);
@@ -273,6 +357,9 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
273357
);
274358
};
275359

360+
/**
361+
* Adds multiple manual approvals in batch
362+
*/
276363
public addManualApprovalMulti = async (params: AddManualApprovalMultiParams) => {
277364
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
278365
params.from.forEach(address => assert.isETHAddressHex('from', address));
@@ -305,6 +392,9 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
305392
);
306393
};
307394

395+
/**
396+
* Modify the existing manual approvals
397+
*/
308398
public modifyManualApproval = async (params: ModifyManualApprovalParams) => {
309399
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
310400
assert.isETHAddressHex('from', params.from);
@@ -324,6 +414,9 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
324414
);
325415
};
326416

417+
/**
418+
* Adds multiple manual approvals in batch
419+
*/
327420
public modifyManualApprovalMulti = async (params: ModifyManualApprovalMultiParams) => {
328421
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
329422
params.from.forEach(address => assert.isETHAddressHex('from', address));
@@ -354,6 +447,9 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
354447
);
355448
};
356449

450+
/**
451+
* Removes pairs of addresses from manual approvals
452+
*/
357453
public revokeManualApproval = async (params: RevokeManualApprovalParams) => {
358454
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
359455
assert.isETHAddressHex('from', params.from);
@@ -367,6 +463,9 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
367463
);
368464
};
369465

466+
/**
467+
* Removes multiple pairs of addresses from manual approvals
468+
*/
370469
public revokeManualApprovalMulti = async (params: RevokeManualApprovalMultiParams) => {
371470
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
372471
params.from.forEach(address => assert.isETHAddressHex('from', address));
@@ -385,7 +484,15 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
385484
);
386485
};
387486

388-
public getActiveApprovalsToUser = async (params: GetActiveApprovalsToUserParams) => {
487+
/**
488+
* Returns the all active approvals corresponds to an address
489+
* @return addresses from
490+
* @return addresses to
491+
* @return allowances provided to the approvals
492+
* @return expiry times provided to the approvals
493+
* @return descriptions provided to the approvals
494+
*/
495+
public getActiveApprovalsToUser = async (params: GetActiveApprovalsToUserParams): Promise<Approval[]> => {
389496
assert.isETHAddressHex('user', params.user);
390497
const result = await (await this.contract).getActiveApprovalsToUser.callAsync(params.user);
391498
const typedResult: Approval[] = [];
@@ -403,7 +510,13 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
403510
return typedResult;
404511
};
405512

406-
public getApprovalDetails = async (params: GetApprovalDetailsParams) => {
513+
/**
514+
* Get the details of the approval corresponds to from & to addresses
515+
* @return expiryTime of the approval
516+
* @return allowance provided to the approval
517+
* @return Description provided to the approval
518+
*/
519+
public getApprovalDetails = async (params: GetApprovalDetailsParams): Promise<Approval> => {
407520
assert.isETHAddressHex('from', params.from);
408521
assert.isETHAddressHex('to', params.to);
409522
const result = await (await this.contract).getApprovalDetails.callAsync(params.from, params.to);
@@ -418,11 +531,22 @@ export default class ManualApprovalTransferManagerWrapper extends ModuleWrapper
418531
return typedResult;
419532
};
420533

421-
public getTotalApprovalsLength = async () => {
422-
return (await this.contract).getTotalApprovalsLength.callAsync();
534+
/**
535+
* Returns the current number of active approvals
536+
*/
537+
public getTotalApprovalsLength = async (): Promise<number> => {
538+
return (await (await this.contract).getTotalApprovalsLength.callAsync()).toNumber();
423539
};
424540

425-
public getAllApprovals = async () => {
541+
/**
542+
* Get the details of all approvals
543+
* @return addresses from
544+
* @return addresses to
545+
* @return allowances provided to the approvals
546+
* @return expiry times provided to the approvals
547+
* @return descriptions provided to the approvals
548+
*/
549+
public getAllApprovals = async (): Promise<Approval[]> => {
426550
const result = await (await this.contract).getAllApprovals.callAsync();
427551
const decimals = await (await this.securityTokenContract()).decimals.callAsync();
428552
const typedResult: Approval[] = [];

0 commit comments

Comments
 (0)