From 274fe87da754ac45cecd6c19123a1c144d4c4080 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 31 May 2017 10:32:59 +0200 Subject: Add full stop to comments --- src/contract_wrappers/token_wrapper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 59dfc0667..9e496b648 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -20,7 +20,7 @@ export class TokenWrapper extends ContractWrapper { this.tokenContractsByAddress = {}; } /** - * Returns an owner's ERC20 token balance + * Returns an owner's ERC20 token balance. */ public async getBalanceAsync(tokenAddress: string, ownerAddress: string): Promise { assert.isETHAddressHex('ownerAddress', ownerAddress); @@ -35,7 +35,7 @@ export class TokenWrapper extends ContractWrapper { } /** * Retrieves the allowance in baseUnits of the ERC20 token set to the 0x proxy contract - * by an owner address + * by an owner address. */ public async getProxyAllowanceAsync(tokenAddress: string, ownerAddress: string) { assert.isETHAddressHex('ownerAddress', ownerAddress); -- cgit v1.2.3 From d1d66f563581c7f56d4956903cfb1b23d149cf18 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 31 May 2017 10:33:22 +0200 Subject: Remove superfluous undefined check --- src/contract_wrappers/token_wrapper.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 9e496b648..928b67a03 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -30,7 +30,7 @@ export class TokenWrapper extends ContractWrapper { let balance = await tokenContract.balanceOf.call(ownerAddress); // The BigNumber instance returned by Web3 is of a much older version then our own, we therefore // should always re-instantiate the returned BigNumber after retrieval. - balance = _.isUndefined(balance) ? new BigNumber(0) : new BigNumber(balance); + balance = new BigNumber(balance); return balance; } /** @@ -44,9 +44,7 @@ export class TokenWrapper extends ContractWrapper { const tokenContract = await this.getTokenContractAsync(tokenAddress); const proxyAddress = await this.getProxyAddressAsync(); let allowanceInBaseUnits = await tokenContract.allowance.call(ownerAddress, proxyAddress); - allowanceInBaseUnits = _.isUndefined(allowanceInBaseUnits) ? - new BigNumber(0) : - new BigNumber(allowanceInBaseUnits); + allowanceInBaseUnits = new BigNumber(allowanceInBaseUnits); return allowanceInBaseUnits; } /** -- cgit v1.2.3 From 03072049d67f460e2420ed5e05a91ab1c06972ac Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 31 May 2017 10:35:40 +0200 Subject: remove InternalError type since this error could surface through the public interface --- src/contract_wrappers/token_wrapper.ts | 4 ++-- src/types.ts | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 928b67a03..35e008905 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -6,7 +6,7 @@ import {constants} from '../utils/constants'; import {ContractWrapper} from './contract_wrapper'; import * as TokenArtifacts from '../artifacts/Token.json'; import * as ProxyArtifacts from '../artifacts/Proxy.json'; -import {TokenContract, InternalError} from '../types'; +import {TokenContract, ZeroExError} from '../types'; const ALLOWANCE_TO_ZERO_GAS_AMOUNT = 45730; @@ -85,7 +85,7 @@ export class TokenWrapper extends ContractWrapper { undefined : (ProxyArtifacts as any).networks[networkIdIfExists]; if (_.isUndefined(proxyNetworkConfigsIfExists)) { - throw new Error(InternalError.PROXY_ADDRESS_NOT_FOUND); + throw new Error(ZeroExError.CONTRACT_NOT_DEPLOYED_ON_NETWORK); } const proxyAddress = proxyNetworkConfigsIfExists.address; return proxyAddress; diff --git a/src/types.ts b/src/types.ts index bf0a1d8b4..caef50993 100644 --- a/src/types.ts +++ b/src/types.ts @@ -14,14 +14,10 @@ export const ZeroExError = strEnum([ 'UNHANDLED_ERROR', 'USER_HAS_NO_ASSOCIATED_ADDRESSES', 'INVALID_SIGNATURE', + 'CONTRACT_NOT_DEPLOYED_ON_NETWORK', ]); export type ZeroExError = keyof typeof ZeroExError; -export const InternalError = strEnum([ - 'PROXY_ADDRESS_NOT_FOUND', -]); -export type InternalError = keyof typeof InternalError; - /** * Elliptic Curve signature */ -- cgit v1.2.3 From 2acdc627e2eaa1d562de6243045c701caa9468c8 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 31 May 2017 10:43:09 +0200 Subject: Add TxOpts type --- src/types.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/types.ts b/src/types.ts index caef50993..3619c800f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -38,7 +38,7 @@ export interface TokenContract { allowance: { call: (ownerAddress: string, allowedAddress: string) => Promise; }; - approve: (proxyAddress: string, amountInBaseUnits: BigNumber.BigNumber, opts: any) => void; + approve: (proxyAddress: string, amountInBaseUnits: BigNumber.BigNumber, txOpts: TxOpts) => void; } export interface TokenRegistryContract { @@ -66,3 +66,8 @@ export interface Token { decimals: number; url: string; }; + +export interface TxOpts { + from: string; + gas?: number; +}; -- cgit v1.2.3