aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/contract_wrappers
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-23 05:43:17 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-24 05:13:37 +0800
commitdb2917b01caa49d74c9ebcae2d36e9c3946b94d8 (patch)
tree88aa341cb4dc02f1bfbc7d0d00d21966e1bbde20 /packages/0x.js/src/contract_wrappers
parent87d34f9c7f3ccf22e01798c27c4a4d5d4f943816 (diff)
downloaddexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar
dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.gz
dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.bz2
dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.lz
dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.xz
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')
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts8
-rw-r--r--packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts30
2 files changed, 19 insertions, 19 deletions
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index 97ea54362..b35219b24 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -559,7 +559,7 @@ export class ExchangeWrapper extends ContractWrapper {
if (shouldValidate) {
const orderHash = utils.getOrderHashHex(order);
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
- this._orderValidationUtils.validateCancelOrderThrowIfInvalid(
+ OrderValidationUtils.validateCancelOrderThrowIfInvalid(
order, cancelTakerTokenAmount, unavailableTakerTokenAmount);
}
@@ -613,7 +613,7 @@ export class ExchangeWrapper extends ContractWrapper {
for (const orderCancellationRequest of orderCancellationRequests) {
const orderHash = utils.getOrderHashHex(orderCancellationRequest.order);
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
- this._orderValidationUtils.validateCancelOrderThrowIfInvalid(
+ OrderValidationUtils.validateCancelOrderThrowIfInvalid(
orderCancellationRequest.order, orderCancellationRequest.takerTokenCancelAmount,
unavailableTakerTokenAmount,
);
@@ -767,7 +767,7 @@ export class ExchangeWrapper extends ContractWrapper {
assert.isValidBaseUnitAmount('cancelTakerTokenAmount', cancelTakerTokenAmount);
const orderHash = utils.getOrderHashHex(order);
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
- this._orderValidationUtils.validateCancelOrderThrowIfInvalid(
+ OrderValidationUtils.validateCancelOrderThrowIfInvalid(
order, cancelTakerTokenAmount, unavailableTakerTokenAmount);
}
/**
@@ -884,4 +884,4 @@ export class ExchangeWrapper extends ContractWrapper {
const tokenTransferProxyAddressLowerCase = tokenTransferProxyAddress.toLowerCase();
return tokenTransferProxyAddressLowerCase;
}
-}
+} // tslint:disable:max-file-line-count
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;
}