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

Commit f1d8209

Browse files
author
Victor Wiebe
committed
fix: remove duplicated methods from erc20Detailed included in erc20
1 parent 9ef5c15 commit f1d8209

File tree

2 files changed

+1
-99
lines changed

2 files changed

+1
-99
lines changed

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

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// PolymathRegistryWrapper test
2-
import { mock, instance, reset, when, verify } from 'ts-mockito';
2+
import { mock, instance, reset } from 'ts-mockito';
33
import { Web3Wrapper } from '@0x/web3-wrapper';
44
import { ERC20DetailedContract, SecurityTokenRegistryEvents } from '@polymathnetwork/abi-wrappers';
5-
import { BigNumber } from '@0x/utils';
65
import ERC20TokenWrapper from '../erc20_wrapper';
76
import ERC20DetailedTokenWrapper from '../erc20_detailed_wrapper';
8-
import { MockedCallMethod } from '../../../test_utils/mocked_methods';
97

108
describe('ERC20DetailedTokenWrapper', () => {
119
// Declare ERC20DetailedTokenWrapper object
@@ -32,73 +30,6 @@ describe('ERC20DetailedTokenWrapper', () => {
3230
});
3331
});
3432

35-
describe('name', () => {
36-
test('should call to name', async () => {
37-
const expectedResult = 'string';
38-
// Mocked method
39-
const mockedMethod = mock(MockedCallMethod);
40-
// Stub the method
41-
when(mockedContract.name).thenReturn(instance(mockedMethod));
42-
// Stub the request
43-
when(mockedMethod.callAsync()).thenResolve(expectedResult);
44-
45-
// Real call
46-
const result = await target.name();
47-
// Result expectation
48-
expect(result).toBe(expectedResult);
49-
// Verifications
50-
verify(mockedContract.name).once();
51-
verify(mockedMethod.callAsync()).once();
52-
});
53-
});
54-
55-
describe('symbol', () => {
56-
test('should call to symbol', async () => {
57-
const expectedResult = 'string';
58-
// Mocked method
59-
const mockedMethod = mock(MockedCallMethod);
60-
// Stub the method
61-
when(mockedContract.symbol).thenReturn(instance(mockedMethod));
62-
// Stub the request
63-
when(mockedMethod.callAsync()).thenResolve(expectedResult);
64-
65-
// Real call
66-
const result = await target.symbol();
67-
// Result expectation
68-
expect(result).toBe(expectedResult);
69-
// Verifications
70-
verify(mockedContract.symbol).once();
71-
verify(mockedMethod.callAsync()).once();
72-
});
73-
});
74-
75-
describe('isValidContract', () => {
76-
test('should call to isValidContract', async () => {
77-
const expectedBNResult = new BigNumber(1);
78-
const expectedStringResult = 'string';
79-
80-
const mockedTotalSupplyMethod = mock(MockedCallMethod);
81-
when(mockedContract.totalSupply).thenReturn(instance(mockedTotalSupplyMethod));
82-
when(mockedTotalSupplyMethod.callAsync()).thenResolve(expectedBNResult);
83-
84-
const mockedSymbolMethod = mock(MockedCallMethod);
85-
when(mockedContract.symbol).thenReturn(instance(mockedSymbolMethod));
86-
when(mockedSymbolMethod.callAsync()).thenResolve(expectedStringResult);
87-
88-
const mockedNameMethod = mock(MockedCallMethod);
89-
when(mockedContract.name).thenReturn(instance(mockedNameMethod));
90-
when(mockedSymbolMethod.callAsync()).thenResolve(expectedStringResult);
91-
92-
const expectedIsValidResult = true;
93-
const result = await target.isValidContract();
94-
expect(result).toBe(expectedIsValidResult);
95-
96-
verify(mockedContract.totalSupply).once();
97-
verify(mockedContract.symbol).once();
98-
verify(mockedContract.name).once();
99-
});
100-
});
101-
10233
describe('SubscribeAsync', () => {
10334
test('should throw as eventName does not belong to SecurityTokenRegistryEvents', async () => {
10435
// Mocked parameters

src/contract_wrappers/tokens/erc20_detailed_wrapper.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,6 @@ export default class ERC20DetailedWrapper extends ERC20TokenWrapper {
2929
this.contract = contract;
3030
}
3131

32-
/**
33-
* Returns the token name
34-
*/
35-
public name = async () => {
36-
return (await this.contract).name.callAsync();
37-
};
38-
39-
/**
40-
* Returns the token symbol
41-
*/
42-
public symbol = async () => {
43-
return (await this.contract).symbol.callAsync();
44-
};
45-
46-
public async isValidContract() {
47-
try {
48-
const contract = await this.contract;
49-
const totalSupply = await contract.totalSupply.callAsync();
50-
const symbol = await contract.symbol.callAsync();
51-
const name = await contract.name.callAsync();
52-
if (symbol === '' || name === '' || totalSupply.isZero()) {
53-
return false;
54-
}
55-
return true;
56-
} catch (error) {
57-
return false;
58-
}
59-
}
60-
6132
public subscribeAsync: Subscribe = async <ArgsType extends ERC20DetailedEventArgs>(
6233
params: SubscribeAsyncParams,
6334
): Promise<string> => {

0 commit comments

Comments
 (0)