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

Commit

Permalink
Merge 21f7ec5 into f4f556e
Browse files Browse the repository at this point in the history
  • Loading branch information
monitz87 committed Jul 23, 2019
2 parents f4f556e + 21f7ec5 commit a8d1e96
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ describe('SecurityTokenRegistryWrapper', () => {
when(mockedMethod.callAsync(ticker)).thenResolve(expectedResult);

// Real call
const result = await target.getTickerDetails({ tokenName: ticker });
const result = await target.getTickerDetails({ ticker });
// Result expectation
expect(result.owner).toBe(expectedResult[0]);
expect(result.registrationDate).toEqual(expectedRegistrationDate);
Expand Down Expand Up @@ -767,7 +767,7 @@ describe('SecurityTokenRegistryWrapper', () => {
when(mockedMethod.callAsync(ticker)).thenResolve(expectedResult);

// Real call
const result = await target.isTickerAvailable({ tokenName: ticker });
const result = await target.isTickerAvailable({ ticker });
// Result expectation
expect(result).toEqual(false);
// Verifications
Expand All @@ -788,7 +788,7 @@ describe('SecurityTokenRegistryWrapper', () => {
when(mockedMethod.callAsync(ticker)).thenResolve(expectedResult);

// Real call
const result = await target.isTickerAvailable({ tokenName: ticker });
const result = await target.isTickerAvailable({ ticker });
// Result expectation
expect(result).toEqual(true);
// Verifications
Expand All @@ -803,7 +803,7 @@ describe('SecurityTokenRegistryWrapper', () => {
test('should call to getTickerDetails and return true', async () => {
const ownerAddress = '0x0123456789012345678901234567890123456789';
const expectedResult = [ownerAddress, new BigNumber(1), new BigNumber(1), 'tokenName', true];
const tokenName = 'TICK';
const ticker = 'TICK';
// Mocked method
const mockedMethod = mock(MockedCallMethod);
// Stub the method
Expand All @@ -813,14 +813,14 @@ describe('SecurityTokenRegistryWrapper', () => {

when(mockedContract.getTickerDetails).thenReturn(instance(mockedMethod));
// Stub the request
when(mockedMethod.callAsync(tokenName)).thenResolve(expectedResult);
when(mockedMethod.callAsync(ticker)).thenResolve(expectedResult);
// Real call
const result = await target.isTickerRegisteredByCurrentIssuer({ tokenName });
const result = await target.isTickerRegisteredByCurrentIssuer({ ticker });
// Result expectation
expect(result).toEqual(true);
// Verifications
verify(mockedContract.getTickerDetails).once();
verify(mockedMethod.callAsync(tokenName)).once();
verify(mockedMethod.callAsync(ticker)).once();
verify(mockedWrapper.getAvailableAddressesAsync()).once();
});

Expand All @@ -833,7 +833,7 @@ describe('SecurityTokenRegistryWrapper', () => {
test('should return false as ticker is registered by a different owner', async () => {
const ownerAddress = '0x0123456789012345678901234567890123456789';
const expectedResult = [ownerAddress, new BigNumber(1), new BigNumber(1), 'tokenName', true];
const tokenName = 'TICK';
const ticker = 'TICK';
// Mocked method
const mockedMethod = mock(MockedCallMethod);
// Stub the method
Expand All @@ -843,14 +843,14 @@ describe('SecurityTokenRegistryWrapper', () => {

when(mockedContract.getTickerDetails).thenReturn(instance(mockedMethod));
// Stub the request
when(mockedMethod.callAsync(tokenName)).thenResolve(expectedResult);
when(mockedMethod.callAsync(ticker)).thenResolve(expectedResult);
// Real call
const result = await target.isTickerRegisteredByCurrentIssuer({ tokenName });
const result = await target.isTickerRegisteredByCurrentIssuer({ ticker });
// Result expectation
expect(result).toEqual(false);
// Verifications
verify(mockedContract.getTickerDetails).once();
verify(mockedMethod.callAsync(tokenName)).once();
verify(mockedMethod.callAsync(ticker)).once();
verify(mockedWrapper.getAvailableAddressesAsync()).once();
});
});
Expand All @@ -873,7 +873,7 @@ describe('SecurityTokenRegistryWrapper', () => {
when(mockedMethod.callAsync(ticker)).thenResolve(expectedSCResult);

// Real call
const result = await target.isTokenLaunched({ tokenName: ticker });
const result = await target.isTokenLaunched({ ticker });
// Result expectation
expect(result).toEqual(true);
// Verifications
Expand All @@ -898,7 +898,7 @@ describe('SecurityTokenRegistryWrapper', () => {
when(mockedMethod.callAsync(ticker)).thenResolve(expectedSCResult);

// Real call
const result = await target.isTokenLaunched({ tokenName: ticker });
const result = await target.isTokenLaunched({ ticker });
// Result expectation
expect(result).toEqual(false);
// Verifications
Expand Down
34 changes: 17 additions & 17 deletions src/contract_wrappers/registries/security_token_registry_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ interface OwnerParams {
}

/**
* @param tokenName is the ticker symbol
* @param ticker is the unique token ticker
*/
interface TokenNameParams {
tokenName: string;
interface TickerParams {
ticker: string;
}

/**
Expand Down Expand Up @@ -406,8 +406,8 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
/**
* @returns Returns the owner and timestamp for a given ticker
*/
public getTickerDetails = async (params: TokenNameParams) => {
return this.getTickerDetailsInternal(params.tokenName);
public getTickerDetails = async (params: TickerParams) => {
return this.getTickerDetailsInternal(params.ticker);
};

/**
Expand All @@ -430,7 +430,7 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
assert.assert(params.ticker.length <= 10, 'Ticker length can not be greater than 10');
assert.assert(
await this.isTickerAvailable({
tokenName: params.ticker,
ticker: params.ticker,
}),
'Ticker is not available',
);
Expand Down Expand Up @@ -458,7 +458,7 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
assert.isNonZeroETHAddressHex('newOwner', params.newOwner);
await this.checkWhenNotPausedOrOwner();
const tickerDetails = await this.getTickerDetails({
tokenName: params.ticker,
ticker: params.ticker,
});
const address = await this.getCallerAddress(params.txData);
assert.assert(functionsUtils.checksumAddressComparision(address, tickerDetails.owner), 'Not authorised');
Expand All @@ -484,7 +484,7 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
assert.assert(params.name.length > 0, 'Name is empty');
await this.checkWhenNotPausedOrOwner();
const tickerDetails = await this.getTickerDetails({
tokenName: params.ticker,
ticker: params.ticker,
});
assert.assert(!tickerDetails.status, 'Ticker already deployed');
const address = (await this.web3Wrapper.getAvailableAddressesAsync())[0];
Expand Down Expand Up @@ -532,17 +532,17 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
* Gets ticker availability
* @return boolean
*/
public isTickerAvailable = async (params: TokenNameParams) => {
const result = await this.getTickerDetailsInternal(params.tokenName);
public isTickerAvailable = async (params: TickerParams) => {
const result = await this.getTickerDetailsInternal(params.ticker);
return this.isTickerAvailableInternal(result.registrationDate, result.expiryDate, result.status);
};

/**
* Knows if the ticker was registered by the user
* @return boolean
*/
public isTickerRegisteredByCurrentIssuer = async (params: TokenNameParams) => {
const result = await this.getTickerDetailsInternal(params.tokenName);
public isTickerRegisteredByCurrentIssuer = async (params: TickerParams) => {
const result = await this.getTickerDetailsInternal(params.ticker);
if (this.isTickerAvailableInternal(result.registrationDate, result.expiryDate, result.status)) {
return false;
}
Expand All @@ -553,8 +553,8 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
* Knows if the ticker was launched
* @return boolean
*/
public isTokenLaunched = async (params: TokenNameParams) => {
const result = await this.getTickerDetailsInternal(params.tokenName);
public isTokenLaunched = async (params: TickerParams) => {
const result = await this.getTickerDetailsInternal(params.ticker);
return result.status;
};

Expand Down Expand Up @@ -592,7 +592,7 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
public removeTicker = async (params: RemoveTickerParams) => {
await this.checkOnlyOwner();
const ticker = await this.getTickerDetails({
tokenName: params.ticker,
ticker: params.ticker,
});
assert.isNonZeroETHAddressHex('owner', ticker.owner);
return (await this.contract).removeTicker.sendTransactionAsync(params.ticker, params.txData, params.safetyFactor);
Expand Down Expand Up @@ -834,8 +834,8 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
return false;
};

private getTickerDetailsInternal = async (tokenName: string) => {
const result = await (await this.contract).getTickerDetails.callAsync(tokenName);
private getTickerDetailsInternal = async (ticker: string) => {
const result = await (await this.contract).getTickerDetails.callAsync(ticker);
const typedResult: TickerDetails = {
owner: result[0],
registrationDate: bigNumberToDate(result[1]),
Expand Down

0 comments on commit a8d1e96

Please sign in to comment.