Fix filling orders on Portal

This commit is contained in:
fragosti
2018-06-14 13:56:36 -07:00
parent 0e354e5ea1
commit 4811dfa663
7 changed files with 13 additions and 4 deletions

View File

@@ -35,7 +35,8 @@ const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {
Exchange: ContractWrappersError.ExchangeContractDoesNotExist,
};
export class ContractWrapper {
export abstract class ContractWrapper {
public abstract abi: ContractAbi;
protected _web3Wrapper: Web3Wrapper;
protected _networkId: number;
private _blockAndLogStreamerIfExists?: BlockAndLogStreamer;

View File

@@ -1,5 +1,5 @@
import { schemas } from '@0xproject/json-schemas';
import { LogWithDecodedArgs } from '@0xproject/types';
import { ContractAbi, LogWithDecodedArgs } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
@@ -17,6 +17,7 @@ import { TokenWrapper } from './token_wrapper';
* The caller can convert ETH into the equivalent number of wrapped ETH ERC20 tokens and back.
*/
export class EtherTokenWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.EtherToken.abi;
private _etherTokenContractsByAddress: {
[address: string]: EtherTokenContract;
} = {};

View File

@@ -2,6 +2,7 @@ import { schemas } from '@0xproject/json-schemas';
import { formatters, getOrderHashHex, OrderStateUtils } from '@0xproject/order-utils';
import {
BlockParamLiteral,
ContractAbi
DecodedLogArgs,
ECSignature,
ExchangeContractErrs,
@@ -54,6 +55,7 @@ interface ExchangeContractErrCodesToMsgs {
* events of the 0x Exchange smart contract.
*/
export class ExchangeWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.Exchange.abi;
private _exchangeContractIfExists?: ExchangeContract;
private _orderValidationUtilsIfExists?: OrderValidationUtils;
private _tokenWrapper: TokenWrapper;

View File

@@ -1,4 +1,4 @@
import { Token } from '@0xproject/types';
import { ContractAbi, Token } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
@@ -14,6 +14,7 @@ import { TokenRegistryContract } from './generated/token_registry';
* This class includes all the functionality related to interacting with the 0x Token Registry smart contract.
*/
export class TokenRegistryWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.TokenRegistry.abi;
private _tokenRegistryContractIfExists?: TokenRegistryContract;
private _contractAddressIfExists?: string;
private static _createTokenFromMetadata(metadata: TokenMetadata): Token | undefined {

View File

@@ -1,4 +1,5 @@
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi } from '@0xproject/types';
import * as _ from 'lodash';
import { artifacts } from '../artifacts';
@@ -11,6 +12,7 @@ import { TokenTransferProxyContract } from './generated/token_transfer_proxy';
* This class includes the functionality related to interacting with the TokenTransferProxy contract.
*/
export class TokenTransferProxyWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.TokenTransferProxy.abi;
private _tokenTransferProxyContractIfExists?: TokenTransferProxyContract;
private _contractAddressIfExists?: string;
constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {

View File

@@ -1,5 +1,5 @@
import { schemas } from '@0xproject/json-schemas';
import { LogWithDecodedArgs } from '@0xproject/types';
import { ContractAbi, LogWithDecodedArgs } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
@@ -26,6 +26,7 @@ import { TokenTransferProxyWrapper } from './token_transfer_proxy_wrapper';
* to the 0x Proxy smart contract.
*/
export class TokenWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.Token.abi;
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
private _tokenContractsByAddress: { [address: string]: TokenContract };
private _tokenTransferProxyWrapper: TokenTransferProxyWrapper;

View File

@@ -625,6 +625,7 @@ export class Blockchain {
);
const provider = this._contractWrappers.getProvider();
const web3Wrapper = new Web3Wrapper(provider);
web3Wrapper.abiDecoder.addABI(this._contractWrappers.exchange.abi);
const receipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
return receipt;
}