Fix up missing Provider interfaces and refactor providerUtils.standardizeOrThrow()
This commit is contained in:
parent
fe1e8575ea
commit
1fa82c1077
@ -1,8 +1,7 @@
|
||||
import { constants, ERC20BalancesByOwner, txDefaults } from '@0x/contracts-test-utils';
|
||||
import { constants, ERC20BalancesByOwner, txDefaults, Web3ProviderEngine } from '@0x/contracts-test-utils';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts, DummyERC20TokenContract, ERC20ProxyContract } from '../../src';
|
||||
@ -11,7 +10,7 @@ export class ERC20Wrapper {
|
||||
private readonly _tokenOwnerAddresses: string[];
|
||||
private readonly _contractOwnerAddress: string;
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _provider: Provider;
|
||||
private readonly _provider: Web3ProviderEngine;
|
||||
private readonly _dummyTokenContracts: DummyERC20TokenContract[];
|
||||
private _proxyContract?: ERC20ProxyContract;
|
||||
private _proxyIdIfExists?: string;
|
||||
@ -22,7 +21,7 @@ export class ERC20Wrapper {
|
||||
* @param contractOwnerAddress Desired owner of the contract
|
||||
* Instance of ERC20Wrapper
|
||||
*/
|
||||
constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
|
||||
constructor(provider: Web3ProviderEngine, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
|
||||
this._dummyTokenContracts = [];
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._provider = provider;
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { constants, ERC721TokenIdsByOwner, txDefaults } from '@0x/contracts-test-utils';
|
||||
import { constants, ERC721TokenIdsByOwner, txDefaults, Web3ProviderEngine} from '@0x/contracts-test-utils';
|
||||
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts, DummyERC721TokenContract, ERC721ProxyContract } from '../../src';
|
||||
@ -11,12 +10,12 @@ export class ERC721Wrapper {
|
||||
private readonly _tokenOwnerAddresses: string[];
|
||||
private readonly _contractOwnerAddress: string;
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _provider: Provider;
|
||||
private readonly _provider: Web3ProviderEngine;
|
||||
private readonly _dummyTokenContracts: DummyERC721TokenContract[];
|
||||
private _proxyContract?: ERC721ProxyContract;
|
||||
private _proxyIdIfExists?: string;
|
||||
private _initialTokenIdsByOwner: ERC721TokenIdsByOwner = {};
|
||||
constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
|
||||
constructor(provider: Web3ProviderEngine, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._provider = provider;
|
||||
this._dummyTokenContracts = [];
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { constants, formatters, LogDecoder, MarketSellOrders } from '@0x/contracts-test-utils';
|
||||
import { constants, formatters, LogDecoder, MarketSellOrders, Web3ProviderEngine } from '@0x/contracts-test-utils';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs, TxDataPayable } from 'ethereum-types';
|
||||
import { TransactionReceiptWithDecodedLogs, TxDataPayable } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { ForwarderContract } from '../../generated-wrappers/forwarder';
|
||||
@ -55,7 +55,7 @@ export class ForwarderWrapper {
|
||||
const params = formatters.createMarketSellOrders(signedOrders, constants.ZERO_AMOUNT);
|
||||
return params;
|
||||
}
|
||||
constructor(contractInstance: ForwarderContract, provider: Provider) {
|
||||
constructor(contractInstance: ForwarderContract, provider: Web3ProviderEngine) {
|
||||
this._forwarderContract = contractInstance;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { FillResults, formatters, LogDecoder, OrderInfo, orderUtils } from '@0x/contracts-test-utils';
|
||||
import { FillResults, formatters, LogDecoder, OrderInfo, orderUtils, Web3ProviderEngine } from '@0x/contracts-test-utils';
|
||||
import { SignedOrder, SignedZeroExTransaction } from '@0x/types';
|
||||
import { AbiEncoder, BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { MethodAbi, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import { MethodAbi, TransactionReceiptWithDecodedLogs, ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts, ExchangeContract } from '../../src';
|
||||
@ -13,7 +13,7 @@ export class ExchangeWrapper {
|
||||
private readonly _exchange: ExchangeContract;
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _logDecoder: LogDecoder;
|
||||
constructor(exchangeContract: ExchangeContract, provider: Provider) {
|
||||
constructor(exchangeContract: ExchangeContract, provider: Web3ProviderEngine | ZeroExProvider) {
|
||||
this._exchange = exchangeContract;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
TakerAssetFillAmountScenario,
|
||||
TakerScenario,
|
||||
TraderStateScenario,
|
||||
Web3ProviderEngine,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import {
|
||||
assetDataUtils,
|
||||
@ -28,7 +29,7 @@ import { AssetProxyId, RevertReason, SignatureType, SignedOrder } from '@0x/type
|
||||
import { BigNumber, errorUtils, logUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as chai from 'chai';
|
||||
import { LogWithDecodedArgs, Provider, TxData } from 'ethereum-types';
|
||||
import { LogWithDecodedArgs, TxData } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
import 'make-promises-safe';
|
||||
|
||||
@ -59,7 +60,7 @@ export async function fillOrderCombinatorialUtilsFactoryAsync(
|
||||
const [ownerAddress, makerAddress, takerAddress] = userAddresses;
|
||||
const makerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[userAddresses.indexOf(makerAddress)];
|
||||
|
||||
const provider = web3Wrapper.getProvider();
|
||||
const provider = web3Wrapper.getZeroExProvider();
|
||||
const erc20Wrapper = new ERC20Wrapper(provider, userAddresses, ownerAddress);
|
||||
const erc721Wrapper = new ERC721Wrapper(provider, userAddresses, ownerAddress);
|
||||
|
||||
@ -351,7 +352,7 @@ export class FillOrderCombinatorialUtils {
|
||||
this.testLibsContract = testLibsContract;
|
||||
}
|
||||
public async testFillOrderScenarioAsync(
|
||||
provider: Provider,
|
||||
provider: Web3ProviderEngine,
|
||||
fillScenario: FillScenario,
|
||||
isVerbose: boolean = false,
|
||||
): Promise<void> {
|
||||
|
@ -5,11 +5,12 @@ import {
|
||||
OrderInfo,
|
||||
orderUtils,
|
||||
TransactionFactory,
|
||||
Web3ProviderEngine,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts, BalanceThresholdFilterContract, ExchangeContract } from '../../src';
|
||||
@ -24,7 +25,7 @@ export class BalanceThresholdWrapper {
|
||||
balanceThresholdFilter: BalanceThresholdFilterContract,
|
||||
exchangeContract: ExchangeContract,
|
||||
signerTransactionFactory: TransactionFactory,
|
||||
provider: Provider,
|
||||
provider: Web3ProviderEngine,
|
||||
) {
|
||||
this._balanceThresholdFilter = balanceThresholdFilter;
|
||||
this._exchange = exchangeContract;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { LogDecoder } from '@0x/contracts-test-utils';
|
||||
import { LogDecoder, Web3ProviderEngine } from '@0x/contracts-test-utils';
|
||||
import { DutchAuctionDetails, SignedOrder } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction';
|
||||
@ -12,7 +12,7 @@ export class DutchAuctionTestWrapper {
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _logDecoder: LogDecoder;
|
||||
|
||||
constructor(contractInstance: DutchAuctionContract, provider: Provider) {
|
||||
constructor(contractInstance: DutchAuctionContract, provider: Web3ProviderEngine) {
|
||||
this._dutchAuctionContract = contractInstance;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { LogDecoder } from '@0x/contracts-test-utils';
|
||||
import { LogDecoder, Web3ProviderEngine } from '@0x/contracts-test-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { AssetProxyOwnerContract } from '../../generated-wrappers/asset_proxy_owner';
|
||||
@ -11,7 +11,7 @@ export class AssetProxyOwnerWrapper {
|
||||
private readonly _assetProxyOwner: AssetProxyOwnerContract;
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _logDecoder: LogDecoder;
|
||||
constructor(assetproxyOwnerContract: AssetProxyOwnerContract, provider: Provider) {
|
||||
constructor(assetproxyOwnerContract: AssetProxyOwnerContract, provider: Web3ProviderEngine) {
|
||||
this._assetProxyOwner = assetproxyOwnerContract;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { LogDecoder } from '@0x/contracts-test-utils';
|
||||
import { LogDecoder, Web3ProviderEngine } from '@0x/contracts-test-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { MultiSigWalletContract } from '../../generated-wrappers/multi_sig_wallet';
|
||||
@ -11,7 +11,7 @@ export class MultiSigWrapper {
|
||||
private readonly _multiSig: MultiSigWalletContract;
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _logDecoder: LogDecoder;
|
||||
constructor(multiSigContract: MultiSigWalletContract, provider: Provider) {
|
||||
constructor(multiSigContract: MultiSigWalletContract, provider: Web3ProviderEngine) {
|
||||
this._multiSig = multiSigContract;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
|
||||
|
@ -22,6 +22,7 @@ export { orderUtils } from './order_utils';
|
||||
export { typeEncodingUtils } from './type_encoding_utils';
|
||||
export { profiler } from './profiler';
|
||||
export { coverage } from './coverage';
|
||||
export { Web3ProviderEngine } from '@0x/subproviders';
|
||||
export { addressUtils } from './address_utils';
|
||||
export { OrderFactory } from './order_factory';
|
||||
export { bytes32Values, testCombinatoriallyWithReferenceFuncAsync, uint256Values } from './combinatorial_utils';
|
||||
|
@ -86,7 +86,7 @@ export class {{contractName}}Contract extends BaseContract {
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('{{contractName}}', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
super('{{contractName}}', abi, address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -1419,7 +1419,7 @@ export class AssetProxyOwnerContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_owners: string[],
|
||||
_assetProxyContracts: string[],
|
||||
@ -1429,6 +1429,7 @@ export class AssetProxyOwnerContract extends BaseContract {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return AssetProxyOwnerContract.deployAsync(bytecode, abi, provider, txDefaults, _owners,
|
||||
@ -1440,13 +1441,14 @@ _secondsTimeLocked
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_owners: string[],
|
||||
_assetProxyContracts: string[],
|
||||
_required: BigNumber,
|
||||
_secondsTimeLocked: BigNumber,
|
||||
): Promise<AssetProxyOwnerContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[_owners,
|
||||
_assetProxyContracts,
|
||||
@ -1486,8 +1488,8 @@ _secondsTimeLocked
|
||||
];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('AssetProxyOwner', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('AssetProxyOwner', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -753,7 +753,7 @@ export class DummyERC20TokenContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_name: string,
|
||||
_symbol: string,
|
||||
@ -763,6 +763,7 @@ export class DummyERC20TokenContract extends BaseContract {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return DummyERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults, _name,
|
||||
@ -774,13 +775,14 @@ _totalSupply
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_name: string,
|
||||
_symbol: string,
|
||||
_decimals: BigNumber,
|
||||
_totalSupply: BigNumber,
|
||||
): Promise<DummyERC20TokenContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[_name,
|
||||
_symbol,
|
||||
@ -820,8 +822,8 @@ _totalSupply
|
||||
];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('DummyERC20Token', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('DummyERC20Token', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -945,7 +945,7 @@ export class DummyERC721TokenContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_name: string,
|
||||
_symbol: string,
|
||||
@ -953,6 +953,7 @@ export class DummyERC721TokenContract extends BaseContract {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return DummyERC721TokenContract.deployAsync(bytecode, abi, provider, txDefaults, _name,
|
||||
@ -962,11 +963,12 @@ _symbol
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_name: string,
|
||||
_symbol: string,
|
||||
): Promise<DummyERC721TokenContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[_name,
|
||||
_symbol
|
||||
@ -998,8 +1000,8 @@ _symbol
|
||||
];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('DummyERC721Token', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('DummyERC721Token', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -196,13 +196,14 @@ export class DutchAuctionContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_exchange: string,
|
||||
): Promise<DutchAuctionContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return DutchAuctionContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange
|
||||
@ -211,10 +212,11 @@ export class DutchAuctionContract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_exchange: string,
|
||||
): Promise<DutchAuctionContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[_exchange
|
||||
] = BaseContract._formatABIDataItemList(
|
||||
@ -242,8 +244,8 @@ export class DutchAuctionContract extends BaseContract {
|
||||
];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('DutchAuction', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('DutchAuction', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -483,12 +483,13 @@ export class ERC20ProxyContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC20ProxyContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return ERC20ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
@ -496,9 +497,10 @@ export class ERC20ProxyContract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC20ProxyContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
@ -522,8 +524,8 @@ export class ERC20ProxyContract extends BaseContract {
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('ERC20Proxy', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('ERC20Proxy', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -386,12 +386,13 @@ export class ERC20TokenContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC20TokenContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return ERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
@ -399,9 +400,10 @@ export class ERC20TokenContract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC20TokenContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
@ -425,8 +427,8 @@ export class ERC20TokenContract extends BaseContract {
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('ERC20Token', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('ERC20Token', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -483,12 +483,13 @@ export class ERC721ProxyContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC721ProxyContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return ERC721ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
@ -496,9 +497,10 @@ export class ERC721ProxyContract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC721ProxyContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
@ -522,8 +524,8 @@ export class ERC721ProxyContract extends BaseContract {
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('ERC721Proxy', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('ERC721Proxy', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -621,12 +621,13 @@ export class ERC721TokenContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC721TokenContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return ERC721TokenContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
@ -634,9 +635,10 @@ export class ERC721TokenContract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC721TokenContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
@ -660,8 +662,8 @@ export class ERC721TokenContract extends BaseContract {
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('ERC721Token', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('ERC721Token', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -2225,13 +2225,14 @@ export class ExchangeContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_zrxAssetData: string,
|
||||
): Promise<ExchangeContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return ExchangeContract.deployAsync(bytecode, abi, provider, txDefaults, _zrxAssetData
|
||||
@ -2240,10 +2241,11 @@ export class ExchangeContract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_zrxAssetData: string,
|
||||
): Promise<ExchangeContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[_zrxAssetData
|
||||
] = BaseContract._formatABIDataItemList(
|
||||
@ -2271,8 +2273,8 @@ export class ExchangeContract extends BaseContract {
|
||||
];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('Exchange', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('Exchange', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -455,7 +455,7 @@ export class ForwarderContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_exchange: string,
|
||||
_zrxAssetData: string,
|
||||
@ -464,6 +464,7 @@ export class ForwarderContract extends BaseContract {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return ForwarderContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange,
|
||||
@ -474,12 +475,13 @@ _wethAssetData
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_exchange: string,
|
||||
_zrxAssetData: string,
|
||||
_wethAssetData: string,
|
||||
): Promise<ForwarderContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[_exchange,
|
||||
_zrxAssetData,
|
||||
@ -515,8 +517,8 @@ _wethAssetData
|
||||
];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('Forwarder', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('Forwarder', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -49,12 +49,13 @@ export class IValidatorContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<IValidatorContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return IValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
@ -62,9 +63,10 @@ export class IValidatorContract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<IValidatorContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
@ -88,8 +90,8 @@ export class IValidatorContract extends BaseContract {
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('IValidator', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('IValidator', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -47,12 +47,13 @@ export class IWalletContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<IWalletContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return IWalletContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
@ -60,9 +61,10 @@ export class IWalletContract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<IWalletContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
@ -86,8 +88,8 @@ export class IWalletContract extends BaseContract {
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('IWallet', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('IWallet', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -622,12 +622,13 @@ export class MultiAssetProxyContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<MultiAssetProxyContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return MultiAssetProxyContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
@ -635,9 +636,10 @@ export class MultiAssetProxyContract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<MultiAssetProxyContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
@ -661,8 +663,8 @@ export class MultiAssetProxyContract extends BaseContract {
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('MultiAssetProxy', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('MultiAssetProxy', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -227,7 +227,7 @@ export class OrderValidatorContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_exchange: string,
|
||||
_zrxAssetData: string,
|
||||
@ -235,6 +235,7 @@ export class OrderValidatorContract extends BaseContract {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return OrderValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange,
|
||||
@ -244,11 +245,12 @@ _zrxAssetData
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_exchange: string,
|
||||
_zrxAssetData: string,
|
||||
): Promise<OrderValidatorContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[_exchange,
|
||||
_zrxAssetData
|
||||
@ -280,8 +282,8 @@ _zrxAssetData
|
||||
];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('OrderValidator', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('OrderValidator', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -621,12 +621,13 @@ export class WETH9Contract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<WETH9Contract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return WETH9Contract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
@ -634,9 +635,10 @@ export class WETH9Contract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<WETH9Contract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
@ -660,8 +662,8 @@ export class WETH9Contract extends BaseContract {
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('WETH9', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('WETH9', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -2,8 +2,8 @@
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
@ -464,12 +464,13 @@ export class ZRXTokenContract extends BaseContract {
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ZRXTokenContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return ZRXTokenContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
@ -477,9 +478,10 @@ export class ZRXTokenContract extends BaseContract {
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ZRXTokenContract> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
@ -503,8 +505,8 @@ export class ZRXTokenContract extends BaseContract {
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('ZRXToken', abi, address, provider, txDefaults);
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('ZRXToken', abi, address, providerUtils.standardizeOrThrow(supportedProvider), txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@ -4,7 +4,7 @@ import { SignedOrder } from '@0x/order-utils';
|
||||
import { ObjectMap } from '@0x/types';
|
||||
import { BigNumber, providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, SupportedProvider } from 'ethereum-types';
|
||||
import { SupportedProvider, ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { constants } from './constants';
|
||||
@ -34,7 +34,7 @@ interface OrdersEntry {
|
||||
}
|
||||
|
||||
export class AssetBuyer {
|
||||
public readonly provider: Provider;
|
||||
public readonly provider: ZeroExProvider;
|
||||
public readonly orderProvider: OrderProvider;
|
||||
public readonly networkId: number;
|
||||
public readonly orderRefreshIntervalMs: number;
|
||||
|
@ -3,7 +3,7 @@ export {
|
||||
JSONRPCResponsePayload,
|
||||
JSONRPCResponseError,
|
||||
JSONRPCErrorCallback,
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
} from 'ethereum-types';
|
||||
export { SignedOrder } from '@0x/types';
|
||||
export { BigNumber } from '@0x/utils';
|
||||
|
@ -167,7 +167,7 @@ export class ContractWrappers {
|
||||
* Get the provider instance currently used by contract-wrappers
|
||||
* @return Web3 provider instance
|
||||
*/
|
||||
public getProvider(): Provider {
|
||||
public getProvider(): SupportedProvider {
|
||||
return this._web3Wrapper.getProvider();
|
||||
}
|
||||
/**
|
||||
|
@ -77,7 +77,7 @@ export {
|
||||
BlockParamLiteral,
|
||||
BlockParam,
|
||||
ContractEventArg,
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
ContractAbi,
|
||||
JSONRPCRequestPayload,
|
||||
JSONRPCResponsePayload,
|
||||
|
@ -4,7 +4,6 @@ import { EmptyWalletSubprovider, Web3ProviderEngine } from '@0x/subproviders';
|
||||
import { DoneCallback } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import 'mocha';
|
||||
|
||||
import {
|
||||
@ -622,7 +621,7 @@ describe('ERC20Wrapper', () => {
|
||||
});
|
||||
// tslint:disable:max-file-line-count
|
||||
|
||||
function addEmptyWalletSubprovider(p: Provider): Provider {
|
||||
function addEmptyWalletSubprovider(p: Web3ProviderEngine): Web3ProviderEngine {
|
||||
const providerEngine = new Web3ProviderEngine();
|
||||
providerEngine.addProvider(new EmptyWalletSubprovider());
|
||||
const currentSubproviders = (p as any)._providers;
|
||||
|
@ -3,7 +3,6 @@ import { EmptyWalletSubprovider, Web3ProviderEngine } from '@0x/subproviders';
|
||||
import { DoneCallback } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import 'mocha';
|
||||
|
||||
import {
|
||||
@ -454,7 +453,7 @@ describe('ERC721Wrapper', () => {
|
||||
});
|
||||
// tslint:disable:max-file-line-count
|
||||
|
||||
function addEmptyWalletSubprovider(p: Provider): Provider {
|
||||
function addEmptyWalletSubprovider(p: Web3ProviderEngine): Web3ProviderEngine {
|
||||
const providerEngine = new Web3ProviderEngine();
|
||||
providerEngine.addProvider(new EmptyWalletSubprovider());
|
||||
const currentSubproviders = (p as any)._providers;
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { devConstants, web3Factory } from '@0x/dev-utils';
|
||||
import { Web3ProviderEngine } from '@0x/subproviders';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
|
||||
const txDefaults = {
|
||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||
gas: devConstants.GAS_LIMIT,
|
||||
};
|
||||
const provider: Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const provider: Web3ProviderEngine = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
|
||||
export { provider, web3Wrapper, txDefaults };
|
||||
|
@ -6,19 +6,32 @@ export type JSONRPCErrorCallback = (err: Error | null, result?: JSONRPCResponseP
|
||||
* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library
|
||||
* Read more about Providers in the 0x wiki.
|
||||
*/
|
||||
export type SupportedProvider = Web3JsProvider | Provider | EIP1193Provider;
|
||||
export type SupportedProvider = Web3JsProvider | GanacheProvider | EIP1193Provider | ZeroExProvider;
|
||||
|
||||
export type Web3JsProvider = Web3JsV1Provider | Web3JsV2Provider | Web3JsV3Provider;
|
||||
|
||||
/**
|
||||
* The interface for the provider used by @0x/web3-wrapper
|
||||
*/
|
||||
export interface GanacheProvider {
|
||||
sendAsync(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void;
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
export interface Provider {
|
||||
sendAsync(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void;
|
||||
}
|
||||
|
||||
export type GanacheProvider = Provider;
|
||||
export type ProviderEngineProvider = Provider;
|
||||
/**
|
||||
* The interface for the provider used internally by 0x libraries
|
||||
* Any property we use from any SupportedProvider should we explicitly
|
||||
* add here
|
||||
*/
|
||||
export interface ZeroExProvider {
|
||||
isZeroExProvider?: boolean;
|
||||
isMetaMask?: boolean;
|
||||
isParity?: boolean;
|
||||
stop?: () => void;
|
||||
enable?: () => Promise<void>;
|
||||
sendAsync(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Web3.js version 1 provider interface
|
||||
|
@ -26,8 +26,7 @@ export class FillScenarios {
|
||||
erc20ProxyAddress: string,
|
||||
erc721ProxyAddress: string,
|
||||
) {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._web3Wrapper = new Web3Wrapper(supportedProvider);
|
||||
this._userAddresses = userAddresses;
|
||||
this._coinbase = userAddresses[0];
|
||||
this._zrxTokenAddress = zrxTokenAddress;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { AssetBuyer, BigNumber } from '@0x/asset-buyer';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { providerUtils } from '@0x/utils';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { SupportedProvider, ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
@ -24,7 +24,7 @@ import { util } from './util/util';
|
||||
|
||||
const isInstantRendered = (): boolean => !!document.getElementById(INJECTED_DIV_ID);
|
||||
|
||||
const validateInstantRenderConfig = (config: ZeroExInstantConfig, selector: string) => {
|
||||
const validateInstantRenderConfigAsync = async (config: ZeroExInstantConfig, selector: string) => {
|
||||
assert.isValidOrderSource('orderSource', config.orderSource);
|
||||
if (!_.isUndefined(config.defaultSelectedAssetData)) {
|
||||
assert.isHexString('defaultSelectedAssetData', config.defaultSelectedAssetData);
|
||||
@ -102,7 +102,7 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z
|
||||
: config.orderSource,
|
||||
});
|
||||
|
||||
validateInstantRenderConfig(coercedConfig, selector);
|
||||
validateInstantRenderConfigAsync(coercedConfig, selector);
|
||||
|
||||
if (coercedConfig.shouldDisablePushToHistory) {
|
||||
if (!isInstantRendered()) {
|
||||
@ -152,17 +152,18 @@ export const hasLiquidityForAssetDataAsync = async (
|
||||
assetData: string,
|
||||
orderSource: OrderSource,
|
||||
networkId: Network = Network.Mainnet,
|
||||
provider?: Provider,
|
||||
supportedProvider?: SupportedProvider,
|
||||
): Promise<boolean> => {
|
||||
assert.isHexString('assetData', assetData);
|
||||
assert.isValidOrderSource('orderSource', orderSource);
|
||||
assert.isNumber('networkId', networkId);
|
||||
|
||||
let provider = supportedProvider;
|
||||
if (provider !== undefined) {
|
||||
providerUtils.standardizeOrThrow(provider);
|
||||
provider = providerUtils.standardizeOrThrow(provider);
|
||||
}
|
||||
|
||||
const bestProvider: Provider = provider || providerFactory.getFallbackNoSigningProvider(networkId);
|
||||
const bestProvider: ZeroExProvider = provider || providerFactory.getFallbackNoSigningProvider(networkId);
|
||||
|
||||
const assetBuyerOptions = { networkId };
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { AssetBuyer, BigNumber } from '@0x/asset-buyer';
|
||||
import { AssetProxyId, ObjectMap, SignedOrder } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, SupportedProvider } from 'ethereum-types';
|
||||
import { SupportedProvider, ZeroExProvider } from 'ethereum-types';
|
||||
|
||||
// Reusable
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
@ -109,7 +109,7 @@ export interface AffiliateInfo {
|
||||
export interface ProviderState {
|
||||
name: string;
|
||||
displayName: string;
|
||||
provider: Provider;
|
||||
provider: ZeroExProvider;
|
||||
assetBuyer: AssetBuyer;
|
||||
web3Wrapper: Web3Wrapper;
|
||||
account: Account;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as bowser from 'bowser';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { PROVIDER_TYPE_TO_NAME } from '../constants';
|
||||
@ -41,7 +41,7 @@ export const envUtil = {
|
||||
return OperatingSystem.Other;
|
||||
}
|
||||
},
|
||||
getProviderType(provider: Provider): ProviderType | undefined {
|
||||
getProviderType(provider: ZeroExProvider): ProviderType | undefined {
|
||||
const anyProvider = provider as any;
|
||||
if (provider.constructor.name === 'EthereumProvider') {
|
||||
return ProviderType.Mist;
|
||||
@ -60,14 +60,14 @@ export const envUtil = {
|
||||
}
|
||||
return;
|
||||
},
|
||||
getProviderName(provider: Provider): string {
|
||||
getProviderName(provider: ZeroExProvider): string {
|
||||
const providerTypeIfExists = envUtil.getProviderType(provider);
|
||||
if (_.isUndefined(providerTypeIfExists)) {
|
||||
return provider.constructor.name;
|
||||
}
|
||||
return PROVIDER_TYPE_TO_NAME[providerTypeIfExists];
|
||||
},
|
||||
getProviderDisplayName(provider: Provider): string {
|
||||
getProviderDisplayName(provider: ZeroExProvider): string {
|
||||
const providerTypeIfExists = envUtil.getProviderType(provider);
|
||||
if (_.isUndefined(providerTypeIfExists)) {
|
||||
return 'Wallet';
|
||||
|
@ -1,23 +1,27 @@
|
||||
import { EmptyWalletSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { providerUtils } from '@0x/utils';
|
||||
import { SupportedProvider, ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { BLOCK_POLLING_INTERVAL_MS, ETHEREUM_NODE_URL_BY_NETWORK } from '../constants';
|
||||
import { Maybe, Network } from '../types';
|
||||
|
||||
export const providerFactory = {
|
||||
getInjectedProviderIfExists: (): Maybe<Provider> => {
|
||||
getInjectedProviderIfExists: (): Maybe<ZeroExProvider> => {
|
||||
const injectedProviderIfExists = (window as any).ethereum;
|
||||
if (!_.isUndefined(injectedProviderIfExists)) {
|
||||
return injectedProviderIfExists;
|
||||
const provider = providerUtils.standardizeOrThrow(injectedProviderIfExists);
|
||||
return provider;
|
||||
}
|
||||
const injectedWeb3IfExists = (window as any).web3;
|
||||
if (!_.isUndefined(injectedWeb3IfExists) && !_.isUndefined(injectedWeb3IfExists.currentProvider)) {
|
||||
return injectedWeb3IfExists.currentProvider;
|
||||
const currentProvider = injectedWeb3IfExists.currentProvider;
|
||||
const provider = providerUtils.standardizeOrThrow(currentProvider);
|
||||
return provider;
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
getFallbackNoSigningProvider: (network: Network): Provider => {
|
||||
getFallbackNoSigningProvider: (network: Network): Web3ProviderEngine => {
|
||||
const providerEngine = new Web3ProviderEngine({
|
||||
pollingInterval: BLOCK_POLLING_INTERVAL_MS,
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, SupportedProvider } from 'ethereum-types';
|
||||
import { SupportedProvider, ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { LOADING_ACCOUNT, NO_ACCOUNT } from '../constants';
|
||||
@ -40,7 +40,7 @@ export const providerStateFactory = {
|
||||
getInitialProviderStateFromProvider: (
|
||||
orderSource: OrderSource,
|
||||
network: Network,
|
||||
provider: Provider,
|
||||
provider: ZeroExProvider,
|
||||
walletDisplayName?: string,
|
||||
): ProviderState => {
|
||||
const providerState: ProviderState = {
|
||||
|
@ -1,5 +1,4 @@
|
||||
export {
|
||||
Provider,
|
||||
TxData,
|
||||
JSONRPCRequestPayload,
|
||||
JSONRPCErrorCallback,
|
||||
|
@ -1,13 +1,13 @@
|
||||
#!/usr/bin/env node
|
||||
import { devConstants, web3Factory } from '@0x/dev-utils';
|
||||
import { Web3ProviderEngine } from '@0x/subproviders';
|
||||
import { logUtils } from '@0x/utils';
|
||||
import { Provider } from 'ethereum-types';
|
||||
|
||||
import { runMigrationsAsync } from './migration';
|
||||
|
||||
(async () => {
|
||||
let providerConfigs;
|
||||
let provider: Provider;
|
||||
let provider: Web3ProviderEngine;
|
||||
let txDefaults;
|
||||
|
||||
providerConfigs = { shouldUseInProcessGanache: false };
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
import { devConstants, web3Factory } from '@0x/dev-utils';
|
||||
import { Web3ProviderEngine } from '@0x/subproviders';
|
||||
import { logUtils } from '@0x/utils';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import * as fs from 'fs';
|
||||
import * as _ from 'lodash';
|
||||
import * as path from 'path';
|
||||
@ -10,7 +10,7 @@ import { runMigrationsAsync } from './migration';
|
||||
|
||||
(async () => {
|
||||
let providerConfigs;
|
||||
let provider: Provider;
|
||||
let provider: Web3ProviderEngine;
|
||||
let txDefaults;
|
||||
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
||||
const packageJsonString = fs.readFileSync(packageJsonPath, 'utf8');
|
||||
|
@ -2,9 +2,10 @@ import * as wrappers from '@0x/abi-gen-wrappers';
|
||||
import { ContractAddresses } from '@0x/contract-addresses';
|
||||
import * as artifacts from '@0x/contract-artifacts';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { Web3ProviderEngine } from '@0x/subproviders';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, TxData } from 'ethereum-types';
|
||||
import { TxData } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info';
|
||||
@ -16,7 +17,7 @@ import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info';
|
||||
* @param txDefaults Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter).
|
||||
* @returns The addresses of the contracts that were deployed.
|
||||
*/
|
||||
export async function runMigrationsAsync(provider: Provider, txDefaults: TxData): Promise<ContractAddresses> {
|
||||
export async function runMigrationsAsync(provider: Web3ProviderEngine, txDefaults: TxData): Promise<ContractAddresses> {
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
|
||||
// Proxies
|
||||
@ -203,7 +204,7 @@ let _cachedContractAddresses: ContractAddresses;
|
||||
* @param txDefaults Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter).
|
||||
* @returns The addresses of the contracts that were deployed.
|
||||
*/
|
||||
export async function runMigrationsOnceAsync(provider: Provider, txDefaults: TxData): Promise<ContractAddresses> {
|
||||
export async function runMigrationsOnceAsync(provider: Web3ProviderEngine, txDefaults: TxData): Promise<ContractAddresses> {
|
||||
if (!_.isUndefined(_cachedContractAddresses)) {
|
||||
return _cachedContractAddresses;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
"@0x/tslint-config": "^3.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/web3-provider-engine": "^14.0.0",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-bignumber": "^3.0.0",
|
||||
@ -50,7 +51,8 @@
|
||||
"sinon": "^4.0.0",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "0.13.0",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "3.0.1",
|
||||
"web3-provider-engine": "^14.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/abi-gen-wrappers": "^3.0.3",
|
||||
|
@ -22,7 +22,7 @@ export { OrderFilledCancelledLazyStore } from './store/order_filled_cancelled_la
|
||||
export { eip712Utils } from './eip712_utils';
|
||||
|
||||
export {
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
JSONRPCRequestPayload,
|
||||
JSONRPCErrorCallback,
|
||||
JSONRPCResponsePayload,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ExchangeContractErrs, RevertReason, SignedOrder } from '@0x/types';
|
||||
import { BigNumber, providerUtils } from '@0x/utils';
|
||||
import { Provider, SupportedProvider } from 'ethereum-types';
|
||||
import { SupportedProvider, ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { OrderError, TradeSide, TransferType } from './types';
|
||||
@ -17,7 +17,7 @@ import { utils } from './utils';
|
||||
*/
|
||||
export class OrderValidationUtils {
|
||||
private readonly _orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher;
|
||||
private readonly _provider: Provider;
|
||||
private readonly _provider: ZeroExProvider;
|
||||
/**
|
||||
* A Typescript implementation mirroring the implementation of isRoundingError in the
|
||||
* Exchange smart contract
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { web3Factory } from '@0x/dev-utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import Web3ProviderEngine = require('web3-provider-engine');
|
||||
|
||||
const provider: Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const provider: Web3ProviderEngine = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
|
||||
export { provider, web3Wrapper };
|
||||
|
@ -19,7 +19,7 @@ export { SignedOrder } from '@0x/types';
|
||||
export {
|
||||
JSONRPCRequestPayload,
|
||||
JSONRPCErrorCallback,
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
JSONRPCResponsePayload,
|
||||
JSONRPCResponseError,
|
||||
} from 'ethereum-types';
|
||||
|
@ -34,7 +34,7 @@ import {
|
||||
} from '@0x/order-utils';
|
||||
import { AssetProxyId, ExchangeContractErrs, OrderState, SignedOrder, Stats } from '@0x/types';
|
||||
import { errorUtils, intervalUtils, providerUtils } from '@0x/utils';
|
||||
import { BlockParamLiteral, LogEntryEvent, LogWithDecodedArgs, Provider, SupportedProvider } from 'ethereum-types';
|
||||
import { BlockParamLiteral, LogEntryEvent, LogWithDecodedArgs, SupportedProvider, ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { orderWatcherPartialConfigSchema } from '../schemas/order_watcher_partial_config_schema';
|
||||
@ -79,7 +79,7 @@ export class OrderWatcher {
|
||||
private readonly _orderStateByOrderHashCache: OrderStateByOrderHash = {};
|
||||
private readonly _orderByOrderHash: OrderByOrderHash = {};
|
||||
private readonly _eventWatcher: EventWatcher;
|
||||
private readonly _provider: Provider;
|
||||
private readonly _provider: ZeroExProvider;
|
||||
private readonly _collisionResistantAbiDecoder: CollisionResistanceAbiDecoder;
|
||||
private readonly _expirationWatcher: ExpirationWatcher;
|
||||
private readonly _orderStateUtils: OrderStateUtils;
|
||||
|
@ -5,19 +5,19 @@ import { Schema } from '@0x/json-schemas';
|
||||
import { ECSignature } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
// tslint:enable:no-unused-variable
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { SupportedProvider } from 'ethereum-types';
|
||||
|
||||
import { signatureUtils } from '@0x/order-utils';
|
||||
|
||||
export const assert = {
|
||||
...sharedAssert,
|
||||
async isValidSignatureAsync(
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
orderHash: string,
|
||||
signature: string,
|
||||
signerAddress: string,
|
||||
): Promise<void> {
|
||||
const isValid = await signatureUtils.isValidSignatureAsync(provider, orderHash, signature, signerAddress);
|
||||
const isValid = await signatureUtils.isValidSignatureAsync(supportedProvider, orderHash, signature, signerAddress);
|
||||
assert.assert(isValid, `Expected order with hash '${orderHash}' to have a valid signature`);
|
||||
},
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { web3Factory } from '@0x/dev-utils';
|
||||
import { Web3ProviderEngine } from '@0x/subproviders';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
|
||||
const provider: Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const provider: Web3ProviderEngine = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
|
||||
export { provider, web3Wrapper };
|
||||
|
@ -49,6 +49,7 @@
|
||||
"@types/pluralize": "^0.0.29",
|
||||
"@types/require-from-string": "^1.2.0",
|
||||
"@types/semver": "5.5.0",
|
||||
"@types/web3-provider-engine": "^14.0.0",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-bignumber": "^3.0.0",
|
||||
@ -64,7 +65,8 @@
|
||||
"types-bn": "^0.0.1",
|
||||
"typescript": "3.0.1",
|
||||
"web3-typescript-typings": "^0.10.2",
|
||||
"zeppelin-solidity": "1.8.0"
|
||||
"zeppelin-solidity": "1.8.0",
|
||||
"web3-provider-engine": "^14.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/assert": "^2.0.3",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { web3Factory } from '@0x/dev-utils';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import Web3ProviderEngine = require('web3-provider-engine');
|
||||
|
||||
const providerConfigs = { shouldUseInProcessGanache: true };
|
||||
const provider: Provider = web3Factory.getRpcProvider(providerConfigs);
|
||||
const provider: Web3ProviderEngine = web3Factory.getRpcProvider(providerConfigs);
|
||||
|
||||
export { provider };
|
||||
|
@ -10,7 +10,7 @@ export {
|
||||
|
||||
export {
|
||||
JSONRPCRequestPayload,
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
JSONRPCErrorCallback,
|
||||
JSONRPCResponsePayload,
|
||||
JSONRPCResponseError,
|
||||
|
@ -12,7 +12,7 @@ export { ProfilerSubprovider } from './profiler_subprovider';
|
||||
|
||||
export {
|
||||
JSONRPCRequestPayload,
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
JSONRPCErrorCallback,
|
||||
JSONRPCResponsePayload,
|
||||
JSONRPCResponseError,
|
||||
|
@ -11,7 +11,7 @@ export { RevertTraceSubprovider } from './revert_trace_subprovider';
|
||||
|
||||
export {
|
||||
JSONRPCRequestPayload,
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
JSONRPCErrorCallback,
|
||||
JSONRPCResponsePayload,
|
||||
JSONRPCResponseError,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { Callback, ErrorCallback, NextCallback, Subprovider } from '@0x/subproviders';
|
||||
import { Callback, ErrorCallback, NextCallback, Subprovider, Web3ProviderEngine } from '@0x/subproviders';
|
||||
import { logUtils } from '@0x/utils';
|
||||
import { CallDataRPC, marshaller, Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { JSONRPCRequestPayload, ProviderEngineProvider, TxData } from 'ethereum-types';
|
||||
import { JSONRPCRequestPayload, TxData } from 'ethereum-types';
|
||||
import { utils } from 'ethers';
|
||||
import * as _ from 'lodash';
|
||||
import { Lock } from 'semaphore-async-await';
|
||||
@ -142,7 +142,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider {
|
||||
* directly.
|
||||
* @param engine The ProviderEngine this subprovider is added to
|
||||
*/
|
||||
public setEngine(engine: ProviderEngineProvider): void {
|
||||
public setEngine(engine: Web3ProviderEngine): void {
|
||||
super.setEngine(engine);
|
||||
this._web3Wrapper = new Web3Wrapper(engine);
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ export { ECSignature, EIP712Object, EIP712ObjectValue, EIP712TypedData, EIP712Ty
|
||||
|
||||
export {
|
||||
JSONRPCRequestPayload,
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
JSONRPCResponsePayload,
|
||||
JSONRPCErrorCallback,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { providerUtils } from '@0x/utils';
|
||||
import { marshaller, Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { JSONRPCRequestPayload, Provider, SupportedProvider } from 'ethereum-types';
|
||||
import { JSONRPCRequestPayload, SupportedProvider, ZeroExProvider } from 'ethereum-types';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
|
||||
import { Callback, ErrorCallback } from '../types';
|
||||
@ -17,7 +17,7 @@ import { Subprovider } from './subprovider';
|
||||
*/
|
||||
export class MetamaskSubprovider extends Subprovider {
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _provider: Provider;
|
||||
private readonly _provider: ZeroExProvider;
|
||||
/**
|
||||
* Instantiates a new MetamaskSubprovider
|
||||
* @param supportedProvider Web3 provider that should handle all user account related requests
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { promisify } from '@0x/utils';
|
||||
import { JSONRPCRequestPayload, JSONRPCResponsePayload, ProviderEngineProvider } from 'ethereum-types';
|
||||
import { JSONRPCRequestPayload, JSONRPCResponsePayload } from 'ethereum-types';
|
||||
import Web3ProviderEngine = require('web3-provider-engine');
|
||||
|
||||
import { Callback, ErrorCallback, JSONRPCRequestPayloadWithMethod } from '../types';
|
||||
/**
|
||||
@ -8,7 +9,7 @@ import { Callback, ErrorCallback, JSONRPCRequestPayloadWithMethod } from '../typ
|
||||
*/
|
||||
export abstract class Subprovider {
|
||||
// tslint:disable-next-line:underscore-private-and-protected
|
||||
private engine!: ProviderEngineProvider;
|
||||
private engine!: Web3ProviderEngine;
|
||||
protected static _createFinalPayload(
|
||||
payload: Partial<JSONRPCRequestPayloadWithMethod>,
|
||||
): Partial<JSONRPCRequestPayloadWithMethod> {
|
||||
@ -64,7 +65,7 @@ export abstract class Subprovider {
|
||||
* directly.
|
||||
* @param engine The ProviderEngine this subprovider is added to
|
||||
*/
|
||||
public setEngine(engine: ProviderEngineProvider): void {
|
||||
public setEngine(engine: Web3ProviderEngine): void {
|
||||
this.engine = engine;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import {
|
||||
generatePseudoRandomSalt,
|
||||
Order,
|
||||
orderHashUtils,
|
||||
Provider,
|
||||
RPCSubprovider,
|
||||
signatureUtils,
|
||||
SignedOrder,
|
||||
@ -48,7 +47,7 @@ const ASSET_AMOUNT = new BigNumber(0.1);
|
||||
|
||||
export class Handler {
|
||||
private readonly _networkConfigByNetworkId: ItemByNetworkId<NetworkConfig> = {};
|
||||
private static _createProviderEngine(rpcUrl: string): Provider {
|
||||
private static _createProviderEngine(rpcUrl: string): Web3ProviderEngine {
|
||||
if (_.isUndefined(configs.DISPENSER_PRIVATE_KEY)) {
|
||||
throw new Error('Dispenser Private key not found');
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ import {
|
||||
EIP1193Provider,
|
||||
JSONRPCErrorCallback,
|
||||
JSONRPCRequestPayload,
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
ZeroExProvider,
|
||||
} from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
@ -14,9 +14,23 @@ export const providerUtils = {
|
||||
* @param supportedProvider Potentially supported provider instance
|
||||
* @return Provider that conforms of our internal provider interface
|
||||
*/
|
||||
standardizeOrThrow(supportedProvider: SupportedProvider): Provider {
|
||||
if ((supportedProvider as EIP1193Provider).isEIP1193) {
|
||||
const provider = supportedProvider as Provider;
|
||||
standardizeOrThrow(supportedProvider: SupportedProvider): ZeroExProvider {
|
||||
if (supportedProvider === undefined) {
|
||||
throw new Error(`supportedProvider cannot be 'undefined'`);
|
||||
}
|
||||
const provider = {
|
||||
isStandardizedProvider: true,
|
||||
isMetaMask: (supportedProvider as any).isMetaMask,
|
||||
isParity: (supportedProvider as any).isParity,
|
||||
stop: (supportedProvider as any).stop,
|
||||
enable: (supportedProvider as any).enable,
|
||||
sendAsync: _.noop, // Will be replaced
|
||||
};
|
||||
// Case 1: We've already converted to our ZeroExProvider so noop.
|
||||
if ((supportedProvider as any).isStandardizedProvider) {
|
||||
return supportedProvider as ZeroExProvider;
|
||||
// Case 2: It's a compliant EIP 1193 Provider
|
||||
} else if ((supportedProvider as EIP1193Provider).isEIP1193) {
|
||||
provider.sendAsync = (payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback) => {
|
||||
const method = payload.method;
|
||||
const params = payload.params;
|
||||
@ -30,20 +44,14 @@ export const providerUtils = {
|
||||
});
|
||||
};
|
||||
return provider;
|
||||
} else if (_.isUndefined((supportedProvider as any).sendAsync)) {
|
||||
// An early version of Web3@1.0 Beta provider only has an async `send` method so
|
||||
// we re-assign the send method so that early Web3@1.0 Beta providers work with @0x/web3-wrapper
|
||||
const provider = supportedProvider as Provider;
|
||||
provider.sendAsync = (supportedProvider as any).send;
|
||||
return provider;
|
||||
// Case 3: The provider has a `sendAsync` method, so we use it.
|
||||
} else if (!_.isUndefined((supportedProvider as any).sendAsync)) {
|
||||
return supportedProvider as Provider;
|
||||
} else if ((supportedProvider as any).host) {
|
||||
// HACK(fabio): Later Web3@1.0 Beta modified their `send` method to comply with EIP1193 but did not add the
|
||||
// `isEIP1193` flag. The only common identifier across Web3.js providers is that they all have
|
||||
// a `host` property, so we check for it's existence. We put this check last to make it less likely
|
||||
// that this condition is hit for other providers that also expose a `host` property.
|
||||
const provider = supportedProvider as Provider;
|
||||
provider.sendAsync = (supportedProvider as any).sendAsync.bind(supportedProvider);
|
||||
return provider;
|
||||
// Case 4: The provider does not have a `sendAsync` method but does have a `send` method
|
||||
// It is most likely a Web3.js provider so we remap it to `sendAsync`. We only support
|
||||
// Web3.js@1.0.0-beta.38 and above.
|
||||
} else if (!_.isUndefined((supportedProvider as any).send)) {
|
||||
provider.sendAsync = (payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback) => {
|
||||
const method = payload.method;
|
||||
const params = payload.params;
|
||||
|
@ -6,7 +6,7 @@ export { AbiDecoder, DecodedCalldata } from '@0x/utils';
|
||||
export {
|
||||
BlockParam,
|
||||
TxData,
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
TransactionReceipt,
|
||||
Transaction,
|
||||
TraceParams,
|
||||
|
@ -11,7 +11,6 @@ import {
|
||||
JSONRPCRequestPayload,
|
||||
JSONRPCResponsePayload,
|
||||
LogEntry,
|
||||
Provider,
|
||||
RawLogEntry,
|
||||
SupportedProvider,
|
||||
TraceParams,
|
||||
@ -20,6 +19,7 @@ import {
|
||||
TransactionReceiptWithDecodedLogs,
|
||||
TransactionTrace,
|
||||
TxData,
|
||||
ZeroExProvider,
|
||||
} from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
@ -52,7 +52,9 @@ export class Web3Wrapper {
|
||||
*/
|
||||
public isZeroExWeb3Wrapper = true;
|
||||
public abiDecoder: AbiDecoder;
|
||||
private _provider: Provider;
|
||||
private _provider: ZeroExProvider;
|
||||
// Raw provider passed in. Do not use. Only here to return the unmodified provider passed in via `getProvider()`
|
||||
private _supportedProvider: SupportedProvider;
|
||||
private readonly _txDefaults: Partial<TxData>;
|
||||
private _jsonRpcRequestId: number;
|
||||
/**
|
||||
@ -149,9 +151,9 @@ export class Web3Wrapper {
|
||||
* @return An instance of the Web3Wrapper class.
|
||||
*/
|
||||
constructor(supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
this.abiDecoder = new AbiDecoder([]);
|
||||
this._provider = provider;
|
||||
this._supportedProvider = supportedProvider;
|
||||
this._provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
this._txDefaults = txDefaults || {};
|
||||
this._jsonRpcRequestId = 1;
|
||||
}
|
||||
@ -166,7 +168,14 @@ export class Web3Wrapper {
|
||||
* Retrieve the Web3 provider
|
||||
* @return Web3 provider instance
|
||||
*/
|
||||
public getProvider(): Provider {
|
||||
public getProvider(): SupportedProvider {
|
||||
return this._supportedProvider;
|
||||
}
|
||||
/**
|
||||
* Retrieve the Web3 provider
|
||||
* @return Web3 provider instance
|
||||
*/
|
||||
public getZeroExProvider(): ZeroExProvider {
|
||||
return this._provider;
|
||||
}
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
import { SignedOrder, Token as ZeroExToken } from '@0x/types';
|
||||
import { BigNumber, intervalUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { BlockParam, LogWithDecodedArgs, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import { BlockParam, LogWithDecodedArgs, Provider, TransactionReceiptWithDecodedLogs, ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
import * as moment from 'moment';
|
||||
import * as React from 'react';
|
||||
@ -84,7 +84,7 @@ export class Blockchain {
|
||||
private _defaultGasPrice: BigNumber;
|
||||
private _watchGasPriceIntervalId: NodeJS.Timer;
|
||||
private _injectedProviderIfExists?: InjectedProvider;
|
||||
private static _getNameGivenProvider(provider: Provider): string {
|
||||
private static _getNameGivenProvider(provider: ZeroExProvider): string {
|
||||
const providerType = utils.getProviderType(provider);
|
||||
const providerNameIfExists = providerToName[providerType];
|
||||
if (_.isUndefined(providerNameIfExists)) {
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import '@reach/dialog/styles.css';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
import * as React from 'react';
|
||||
import styled from 'styled-components';
|
||||
@ -42,7 +42,7 @@ export interface WalletConnectedProps {
|
||||
currentBalance: BigNumber;
|
||||
contractWrappers?: ContractWrappers;
|
||||
injectedProviderIfExists?: InjectedProvider;
|
||||
providerEngine?: Provider;
|
||||
providerEngine?: ZeroExProvider;
|
||||
ledgerSubproviderIfExists?: LedgerSubprovider;
|
||||
isLedger?: boolean;
|
||||
web3Wrapper?: Web3Wrapper;
|
||||
@ -97,7 +97,7 @@ export class ConnectForm extends React.Component<Props, State> {
|
||||
private _contractWrappers: ContractWrappers;
|
||||
private _injectedProviderIfExists?: InjectedProvider;
|
||||
private _web3Wrapper?: Web3Wrapper;
|
||||
private _providerEngine?: Provider;
|
||||
private _providerEngine?: ZeroExProvider;
|
||||
private _ledgerSubprovider: LedgerSubprovider;
|
||||
public constructor(props: Props) {
|
||||
super(props);
|
||||
@ -365,7 +365,7 @@ export class ConnectForm extends React.Component<Props, State> {
|
||||
const shouldUserLedgerProvider = true;
|
||||
await this._resetOrInitializeAsync(networkId, shouldUserLedgerProvider);
|
||||
}
|
||||
private _getNameGivenProvider(provider: Provider): string {
|
||||
private _getNameGivenProvider(provider: ZeroExProvider): string {
|
||||
const providerType = utils.getProviderType(provider);
|
||||
const providerNameIfExists = providerToName[providerType];
|
||||
if (_.isUndefined(providerNameIfExists)) {
|
||||
|
@ -4,7 +4,7 @@ import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { DialogContent, DialogOverlay } from '@reach/dialog';
|
||||
import '@reach/dialog/styles.css';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { ZeroExProvider } from 'ethereum-types';
|
||||
import * as React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
@ -45,7 +45,7 @@ interface State {
|
||||
errors: ErrorProps;
|
||||
web3Wrapper?: Web3Wrapper;
|
||||
contractWrappers?: ContractWrappers;
|
||||
providerEngine?: Provider;
|
||||
providerEngine?: ZeroExProvider;
|
||||
web3?: any;
|
||||
selectedAddress?: string;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import { ECSignature, SignatureType } from '@0x/types';
|
||||
import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import '@reach/dialog/styles.css';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { ZeroExProvider } from 'ethereum-types';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
import * as React from 'react';
|
||||
@ -43,7 +43,7 @@ interface Props {
|
||||
isLedger: boolean;
|
||||
injectedProvider?: InjectedProvider;
|
||||
ledgerSubproviderIfExists?: LedgerSubprovider;
|
||||
provider?: Provider;
|
||||
provider?: ZeroExProvider;
|
||||
}
|
||||
|
||||
interface State {
|
||||
|
@ -10,7 +10,7 @@ import * as _ from 'lodash';
|
||||
import * as moment from 'moment';
|
||||
import * as numeral from 'numeral';
|
||||
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { ZeroExProvider } from 'ethereum-types';
|
||||
import {
|
||||
AccountState,
|
||||
BlockchainCallErrs,
|
||||
@ -301,7 +301,7 @@ export const utils = {
|
||||
}
|
||||
window.onload = () => resolve();
|
||||
}),
|
||||
getProviderType(provider: Provider): Providers | string {
|
||||
getProviderType(provider: ZeroExProvider): Providers | string {
|
||||
const constructorName = provider.constructor.name;
|
||||
let parsedProviderName = constructorName;
|
||||
// https://ethereum.stackexchange.com/questions/24266/elegant-way-to-detect-current-provider-int-web3-js
|
||||
|
27
yarn.lock
27
yarn.lock
@ -13472,6 +13472,15 @@ react-dom@^16.3.2:
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.0"
|
||||
|
||||
react-dom@^16.4.2:
|
||||
version "16.8.2"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.2.tgz#7c8a69545dd554d45d66442230ba04a6a0a3c3d3"
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.2"
|
||||
scheduler "^0.13.2"
|
||||
|
||||
react-dom@^16.5.2:
|
||||
version "16.5.2"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.5.2.tgz#b69ee47aa20bab5327b2b9d7c1fe2a30f2cfa9d7"
|
||||
@ -13775,6 +13784,15 @@ react@^16.3.2:
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.0"
|
||||
|
||||
react@^16.4.2:
|
||||
version "16.8.2"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-16.8.2.tgz#83064596feaa98d9c2857c4deae1848b542c9c0c"
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.2"
|
||||
scheduler "^0.13.2"
|
||||
|
||||
react@^16.5.2:
|
||||
version "16.5.2"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42"
|
||||
@ -14646,6 +14664,13 @@ schedule@^0.5.0:
|
||||
dependencies:
|
||||
object-assign "^4.1.1"
|
||||
|
||||
scheduler@^0.13.2:
|
||||
version "0.13.2"
|
||||
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.2.tgz#969eaee2764a51d2e97b20a60963b2546beff8fa"
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
|
||||
schema-utils@^0.4.4:
|
||||
version "0.4.7"
|
||||
resolved "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"
|
||||
@ -17314,7 +17339,7 @@ web3-provider-engine@14.0.6:
|
||||
xhr "^2.2.0"
|
||||
xtend "^4.0.1"
|
||||
|
||||
web3-provider-engine@14.1.0:
|
||||
web3-provider-engine@14.1.0, web3-provider-engine@^14.0.6:
|
||||
version "14.1.0"
|
||||
resolved "https://registry.yarnpkg.com/web3-provider-engine/-/web3-provider-engine-14.1.0.tgz#91590020f8b8c1b65846321310cbfdb039090fc6"
|
||||
dependencies:
|
||||
|
Loading…
x
Reference in New Issue
Block a user