fix(contract-wrappers): Fix tslint errors that were lingering due to misconfiguration
This commit is contained in:
@@ -28,10 +28,10 @@ export abstract class ContractWrapper {
|
||||
protected _networkId: number;
|
||||
protected _web3Wrapper: Web3Wrapper;
|
||||
private _blockAndLogStreamerIfExists: BlockAndLogStreamer<Block, Log> | undefined;
|
||||
private _blockPollingIntervalMs: number;
|
||||
private readonly _blockPollingIntervalMs: number;
|
||||
private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
|
||||
private _filters: { [filterToken: string]: FilterObject };
|
||||
private _filterCallbacks: {
|
||||
private readonly _filters: { [filterToken: string]: FilterObject };
|
||||
private readonly _filterCallbacks: {
|
||||
[filterToken: string]: EventCallback<ContractEventArgs>;
|
||||
};
|
||||
private _onLogAddedSubscriptionToken: string | undefined;
|
||||
|
||||
@@ -34,6 +34,7 @@ export class ERC20ProxyWrapper extends ContractWrapper {
|
||||
*/
|
||||
public async getProxyIdAsync(): Promise<AssetProxyId> {
|
||||
const ERC20ProxyContractInstance = this._getERC20ProxyContract();
|
||||
/* tslint:disable-next-line:no-unnecessary-type-assertion */
|
||||
const proxyId = (await ERC20ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId;
|
||||
return proxyId;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,11 @@ import {
|
||||
} from '../types';
|
||||
import { assert } from '../utils/assert';
|
||||
import { constants } from '../utils/constants';
|
||||
import { utils } from '../utils/utils';
|
||||
|
||||
import { ContractWrapper } from './contract_wrapper';
|
||||
import { ERC20ProxyWrapper } from './erc20_proxy_wrapper';
|
||||
|
||||
const removeUndefinedProperties = _.pickBy;
|
||||
|
||||
/**
|
||||
* This class includes all the functionality related to interacting with ERC20 token contracts.
|
||||
* All ERC20 method calls are supported, along with some convenience methods for getting/setting allowances
|
||||
@@ -32,8 +31,8 @@ const removeUndefinedProperties = _.pickBy;
|
||||
export class ERC20TokenWrapper extends ContractWrapper {
|
||||
public abi: ContractAbi = ERC20Token.compilerOutput.abi;
|
||||
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
|
||||
private _tokenContractsByAddress: { [address: string]: ERC20TokenContract };
|
||||
private _erc20ProxyWrapper: ERC20ProxyWrapper;
|
||||
private readonly _tokenContractsByAddress: { [address: string]: ERC20TokenContract };
|
||||
private readonly _erc20ProxyWrapper: ERC20ProxyWrapper;
|
||||
/**
|
||||
* Instantiate ERC20TokenWrapper
|
||||
* @param web3Wrapper Web3Wrapper instance to use
|
||||
@@ -108,7 +107,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
||||
const txHash = await tokenContract.approve.sendTransactionAsync(
|
||||
normalizedSpenderAddress,
|
||||
amountInBaseUnits,
|
||||
removeUndefinedProperties({
|
||||
utils.removeUndefinedProperties({
|
||||
from: normalizedOwnerAddress,
|
||||
gas: txOpts.gasLimit,
|
||||
gasPrice: txOpts.gasPrice,
|
||||
@@ -278,7 +277,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
||||
const txHash = await tokenContract.transfer.sendTransactionAsync(
|
||||
normalizedToAddress,
|
||||
amountInBaseUnits,
|
||||
removeUndefinedProperties({
|
||||
utils.removeUndefinedProperties({
|
||||
from: normalizedFromAddress,
|
||||
gas: txOpts.gasLimit,
|
||||
gasPrice: txOpts.gasPrice,
|
||||
@@ -339,7 +338,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
||||
normalizedFromAddress,
|
||||
normalizedToAddress,
|
||||
amountInBaseUnits,
|
||||
removeUndefinedProperties({
|
||||
utils.removeUndefinedProperties({
|
||||
from: normalizedSenderAddress,
|
||||
gas: txOpts.gasLimit,
|
||||
gasPrice: txOpts.gasPrice,
|
||||
|
||||
@@ -34,6 +34,7 @@ export class ERC721ProxyWrapper extends ContractWrapper {
|
||||
*/
|
||||
public async getProxyIdAsync(): Promise<AssetProxyId> {
|
||||
const ERC721ProxyContractInstance = await this._getERC721ProxyContract();
|
||||
/* tslint:disable-next-line:no-unnecessary-type-assertion */
|
||||
const proxyId = (await ERC721ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId;
|
||||
return proxyId;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,11 @@ import {
|
||||
} from '../types';
|
||||
import { assert } from '../utils/assert';
|
||||
import { constants } from '../utils/constants';
|
||||
import { utils } from '../utils/utils';
|
||||
|
||||
import { ContractWrapper } from './contract_wrapper';
|
||||
import { ERC721ProxyWrapper } from './erc721_proxy_wrapper';
|
||||
|
||||
const removeUndefinedProperties = _.pickBy;
|
||||
|
||||
/**
|
||||
* This class includes all the functionality related to interacting with ERC721 token contracts.
|
||||
* All ERC721 method calls are supported, along with some convenience methods for getting/setting allowances
|
||||
@@ -31,8 +30,8 @@ const removeUndefinedProperties = _.pickBy;
|
||||
*/
|
||||
export class ERC721TokenWrapper extends ContractWrapper {
|
||||
public abi: ContractAbi = ERC721Token.compilerOutput.abi;
|
||||
private _tokenContractsByAddress: { [address: string]: ERC721TokenContract };
|
||||
private _erc721ProxyWrapper: ERC721ProxyWrapper;
|
||||
private readonly _tokenContractsByAddress: { [address: string]: ERC721TokenContract };
|
||||
private readonly _erc721ProxyWrapper: ERC721ProxyWrapper;
|
||||
/**
|
||||
* Instantiate ERC721TokenWrapper
|
||||
* @param web3Wrapper Web3Wrapper instance to use
|
||||
@@ -235,7 +234,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
||||
const txHash = await tokenContract.setApprovalForAll.sendTransactionAsync(
|
||||
normalizedOperatorAddress,
|
||||
isApproved,
|
||||
removeUndefinedProperties({
|
||||
utils.removeUndefinedProperties({
|
||||
gas: txOpts.gasLimit,
|
||||
gasPrice: txOpts.gasPrice,
|
||||
from: normalizedOwnerAddress,
|
||||
@@ -295,7 +294,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
||||
const txHash = await tokenContract.approve.sendTransactionAsync(
|
||||
normalizedApprovedAddress,
|
||||
tokenId,
|
||||
removeUndefinedProperties({
|
||||
utils.removeUndefinedProperties({
|
||||
gas: txOpts.gasLimit,
|
||||
gasPrice: txOpts.gasPrice,
|
||||
from: tokenOwnerAddress,
|
||||
@@ -366,7 +365,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
||||
ownerAddress,
|
||||
normalizedReceiverAddress,
|
||||
tokenId,
|
||||
removeUndefinedProperties({
|
||||
utils.removeUndefinedProperties({
|
||||
gas: txOpts.gasLimit,
|
||||
gasPrice: txOpts.gasPrice,
|
||||
from: normalizedSenderAddress,
|
||||
|
||||
@@ -8,22 +8,21 @@ import * as _ from 'lodash';
|
||||
|
||||
import { BlockRange, ContractWrappersError, EventCallback, IndexedFilterValues, TransactionOpts } from '../types';
|
||||
import { assert } from '../utils/assert';
|
||||
import { utils } from '../utils/utils';
|
||||
|
||||
import { ContractWrapper } from './contract_wrapper';
|
||||
import { ERC20TokenWrapper } from './erc20_token_wrapper';
|
||||
|
||||
const removeUndefinedProperties = _.pickBy;
|
||||
|
||||
/**
|
||||
* This class includes all the functionality related to interacting with a wrapped Ether ERC20 token contract.
|
||||
* The caller can convert ETH into the equivalent number of wrapped ETH ERC20 tokens and back.
|
||||
*/
|
||||
export class EtherTokenWrapper extends ContractWrapper {
|
||||
public abi: ContractAbi = WETH9.compilerOutput.abi;
|
||||
private _etherTokenContractsByAddress: {
|
||||
private readonly _etherTokenContractsByAddress: {
|
||||
[address: string]: WETH9Contract;
|
||||
} = {};
|
||||
private _erc20TokenWrapper: ERC20TokenWrapper;
|
||||
private readonly _erc20TokenWrapper: ERC20TokenWrapper;
|
||||
/**
|
||||
* Instantiate EtherTokenWrapper.
|
||||
* @param web3Wrapper Web3Wrapper instance to use
|
||||
@@ -67,7 +66,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
||||
|
||||
const wethContract = await this._getEtherTokenContractAsync(normalizedEtherTokenAddress);
|
||||
const txHash = await wethContract.deposit.sendTransactionAsync(
|
||||
removeUndefinedProperties({
|
||||
utils.removeUndefinedProperties({
|
||||
from: normalizedDepositorAddress,
|
||||
value: amountInWei,
|
||||
gas: txOpts.gasLimit,
|
||||
@@ -109,7 +108,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
||||
const wethContract = await this._getEtherTokenContractAsync(normalizedEtherTokenAddress);
|
||||
const txHash = await wethContract.withdraw.sendTransactionAsync(
|
||||
amountInWei,
|
||||
removeUndefinedProperties({
|
||||
utils.removeUndefinedProperties({
|
||||
from: normalizedWithdrawerAddress,
|
||||
gas: txOpts.gasLimit,
|
||||
gasPrice: txOpts.gasPrice,
|
||||
|
||||
@@ -46,8 +46,8 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
public address: string;
|
||||
public zrxTokenAddress: string;
|
||||
private _exchangeContractIfExists?: ExchangeContract;
|
||||
private _erc721TokenWrapper: ERC721TokenWrapper;
|
||||
private _erc20TokenWrapper: ERC20TokenWrapper;
|
||||
private readonly _erc721TokenWrapper: ERC721TokenWrapper;
|
||||
private readonly _erc20TokenWrapper: ERC20TokenWrapper;
|
||||
/**
|
||||
* Instantiate ExchangeWrapper
|
||||
* @param web3Wrapper Web3Wrapper instance to use.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ForwarderContract } from '@0x/abi-gen-wrappers';
|
||||
import { Forwarder } from '@0x/contract-artifacts';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import { AssetProxyId, SignedOrder } from '@0x/types';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { ContractAbi } from 'ethereum-types';
|
||||
@@ -118,7 +118,7 @@ export class ForwarderWrapper extends ContractWrapper {
|
||||
optimizedFeeOrders,
|
||||
feeSignatures,
|
||||
formattedFeePercentage,
|
||||
feeRecipientAddress,
|
||||
normalizedFeeRecipientAddress,
|
||||
{
|
||||
value: ethAmount,
|
||||
from: normalizedTakerAddress,
|
||||
@@ -207,7 +207,7 @@ export class ForwarderWrapper extends ContractWrapper {
|
||||
optimizedFeeOrders,
|
||||
feeSignatures,
|
||||
formattedFeePercentage,
|
||||
feeRecipientAddress,
|
||||
normalizedFeeRecipientAddress,
|
||||
{
|
||||
value: ethAmount,
|
||||
from: normalizedTakerAddress,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { constants } from './constants';
|
||||
|
||||
@@ -14,4 +15,7 @@ export const utils = {
|
||||
numberPercentageToEtherTokenAmountPercentage(percentage: number): BigNumber {
|
||||
return Web3Wrapper.toBaseUnitAmount(constants.ONE_AMOUNT, constants.ETHER_TOKEN_DECIMALS).mul(percentage);
|
||||
},
|
||||
removeUndefinedProperties<T extends object>(obj: T): Partial<T> {
|
||||
return _.pickBy(obj);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user