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

Commit 34fb65c

Browse files
author
Victor Wiebe
committed
feat: 🎸 blacklists method and test
1 parent 08a6e12 commit 34fb65c

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,46 @@ describe('BlacklistTransferManagerWrapper', () => {
264264
});
265265
});
266266

267+
describe('blacklists', () => {
268+
test.todo('should fail as blacklists name is an empty string');
269+
270+
test('should call to blacklists', async () => {
271+
const startTime = new Date(2030, 1);
272+
const expectedStartTime = dateToBigNumber(startTime);
273+
const endTime = new Date(2031, 1);
274+
const expectedEndTime = dateToBigNumber(endTime);
275+
const expectedRepeatPeriodTime = new BigNumber(3600);
276+
const expectedResult = [
277+
expectedStartTime,
278+
expectedEndTime,
279+
expectedRepeatPeriodTime,
280+
];
281+
const mockedParams = {
282+
blacklistName: 'Blacklist',
283+
};
284+
285+
// Mocked method
286+
const mockedMethod = mock(MockedCallMethod);
287+
// Stub the method
288+
when(mockedContract.blacklists).thenReturn(instance(mockedMethod));
289+
// Stub the request
290+
when(mockedMethod.callAsync(objectContaining(stringToBytes32(mockedParams.blacklistName)))).thenResolve(
291+
expectedResult,
292+
);
293+
294+
// Real call
295+
const result = await target.blacklists(mockedParams);
296+
// Result expectation
297+
expect(result.startTime).toEqual(startTime);
298+
expect(result.endTime).toEqual(endTime);
299+
expect(result.repeatPeriodTime).toBe(expectedResult[2]);
300+
301+
// Verifications
302+
verify(mockedContract.blacklists).once();
303+
verify(mockedMethod.callAsync(objectContaining(stringToBytes32(mockedParams.blacklistName)))).once();
304+
});
305+
});
306+
267307
describe('getListOfAddresses', () => {
268308
test.todo('should fail as blacklist name is an empty string');
269309

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ interface VerifyTransfer {
159159
address: string;
160160
}
161161

162+
interface BlacklistsDetails {
163+
startTime: Date;
164+
endTime: Date;
165+
repeatPeriodTime: BigNumber;
166+
}
162167
/**
163168
* This class includes the functionality related to interacting with the Blacklist Transfer Manager contract.
164169
*/
@@ -198,6 +203,19 @@ export default class BlacklistTransferManagerWrapper extends ModuleWrapper {
198203
return (await this.contract).pause.sendTransactionAsync(params.txData, params.safetyFactor);
199204
};
200205

206+
/**
207+
* Return the blacklists
208+
*/
209+
public blacklists = async (params: BlacklistParams): Promise<BlacklistsDetails> => {
210+
assert.assert(params.blacklistName.length > 0, 'LockUp Details must not be an empty string');
211+
const result = await (await this.contract).blacklists.callAsync(stringToBytes32(params.blacklistName));
212+
return {
213+
startTime: bigNumberToDate(result[0]),
214+
endTime: bigNumberToDate(result[1]),
215+
repeatPeriodTime: result[2],
216+
};
217+
};
218+
201219
/**
202220
* getListOfAddresses
203221
*/

0 commit comments

Comments
 (0)