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

Commit 50b326f

Browse files
author
Victor Wiebe
committed
feat: add isCompatibleModule in moduleRegistry and associated test
1 parent fb0d174 commit 50b326f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/contract_wrappers/registries/__tests__/module_registry_wrapper.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,31 @@ describe('ModuleRegistryWrapper', () => {
5353
});
5454
});
5555

56+
describe('IsCompatibleModule', () => {
57+
test('should call to isCompatibleModule', async () => {
58+
// Address expected
59+
const expectedResult = true;
60+
const params = {
61+
moduleFactory: '0x4444444444444444444444444444444444444444',
62+
securityToken: '0x5555555555555555555555555555555555555555',
63+
};
64+
// Mocked method
65+
const mockedMethod = mock(MockedCallMethod);
66+
// Stub the method
67+
when(mockedContract.isCompatibleModule).thenReturn(instance(mockedMethod));
68+
// Stub the request
69+
when(mockedMethod.callAsync(params.moduleFactory, params.securityToken)).thenResolve(expectedResult);
70+
// Real call
71+
const result = await target.isCompatibleModule(params);
72+
// Result expectation
73+
expect(result).toBe(expectedResult);
74+
// Verifications
75+
verify(mockedContract.isCompatibleModule).once();
76+
verify(mockedMethod.callAsync(params.moduleFactory, params.securityToken)).once();
77+
});
78+
});
79+
80+
5681
describe('RegisterModule', () => {
5782
test.todo('should fail as moduleFactory is not an Eth address');
5883

src/contract_wrappers/registries/module_registry_wrapper.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ interface ModuleTypeParams {
156156
moduleType: ModuleType;
157157
}
158158

159+
interface IsCompatibleModuleParams {
160+
moduleFactory: string;
161+
securityToken: string;
162+
}
163+
159164
interface ReclaimERC20Params extends TxParams {
160165
tokenContract: string;
161166
}
@@ -209,6 +214,10 @@ export default class ModuleRegistryWrapper extends ContractWrapper {
209214
this.contractFactory = contractFactory;
210215
}
211216

217+
public isCompatibleModule = async (params: IsCompatibleModuleParams): Promise<boolean> => {
218+
return (await this.contract).isCompatibleModule.callAsync(params.moduleFactory, params.securityToken);
219+
};
220+
212221
public registerModule = async (params: ModuleFactoryParams) => {
213222
assert.isETHAddressHex('moduleFactory', params.moduleFactory);
214223
await this.checkModuleNotPausedOrOwner();

0 commit comments

Comments
 (0)