diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-23 05:43:17 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-24 05:13:37 +0800 |
commit | db2917b01caa49d74c9ebcae2d36e9c3946b94d8 (patch) | |
tree | 88aa341cb4dc02f1bfbc7d0d00d21966e1bbde20 /packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts | |
parent | 87d34f9c7f3ccf22e01798c27c4a4d5d4f943816 (diff) | |
download | dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.gz dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.zst dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.zip |
Enable some new linter rules and fix the issues
Diffstat (limited to 'packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts')
-rw-r--r-- | packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts index 60fe7f33a..468e58350 100644 --- a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts @@ -14,6 +14,18 @@ import {ContractWrapper} from './contract_wrapper'; export class TokenRegistryWrapper extends ContractWrapper { private _tokenRegistryContractIfExists?: TokenRegistryContract; private _contractAddressIfExists?: string; + private static _createTokenFromMetadata(metadata: TokenMetadata): Token|undefined { + if (metadata[0] === constants.NULL_ADDRESS) { + return undefined; + } + const token = { + address: metadata[0], + name: metadata[1], + symbol: metadata[2], + decimals: metadata[3].toNumber(), + }; + return token; + } constructor(web3Wrapper: Web3Wrapper, contractAddressIfExists?: string) { super(web3Wrapper); this._contractAddressIfExists = contractAddressIfExists; @@ -51,7 +63,7 @@ export class TokenRegistryWrapper extends ContractWrapper { const tokenRegistryContract = await this._getTokenRegistryContractAsync(); const metadata = await tokenRegistryContract.getTokenMetaData.callAsync(address); - const token = this._createTokenFromMetadata(metadata); + const token = TokenRegistryWrapper._createTokenFromMetadata(metadata); return token; } public async getTokenAddressBySymbolIfExistsAsync(symbol: string): Promise<string|undefined> { @@ -76,14 +88,14 @@ export class TokenRegistryWrapper extends ContractWrapper { assert.isString('symbol', symbol); const tokenRegistryContract = await this._getTokenRegistryContractAsync(); const metadata = await tokenRegistryContract.getTokenBySymbol.callAsync(symbol); - const token = this._createTokenFromMetadata(metadata); + const token = TokenRegistryWrapper._createTokenFromMetadata(metadata); return token; } public async getTokenByNameIfExistsAsync(name: string): Promise<Token|undefined> { assert.isString('name', name); const tokenRegistryContract = await this._getTokenRegistryContractAsync(); const metadata = await tokenRegistryContract.getTokenByName.callAsync(name); - const token = this._createTokenFromMetadata(metadata); + const token = TokenRegistryWrapper._createTokenFromMetadata(metadata); return token; } /** @@ -103,18 +115,6 @@ export class TokenRegistryWrapper extends ContractWrapper { return this._contractAddressIfExists; } } - private _createTokenFromMetadata(metadata: TokenMetadata): Token|undefined { - if (metadata[0] === constants.NULL_ADDRESS) { - return undefined; - } - const token = { - address: metadata[0], - name: metadata[1], - symbol: metadata[2], - decimals: metadata[3].toNumber(), - }; - return token; - } private _invalidateContractInstance(): void { delete this._tokenRegistryContractIfExists; } |