Stop hardcoding contract addresses (#2461)

* stop hardcoding contract addresses

* update changelog

* export ContractAddresses for docs
This commit is contained in:
Xianny 2020-02-04 15:49:45 +08:00 committed by GitHub
parent 400fb5a5bb
commit 919fc66b9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,13 @@
[
{
"version": "4.0.2",
"changes": [
{
"note": "Allow contract addresses to be passed as optional constructor ags instead of hardcoding",
"pr": 2461
}
]
},
{
"version": "4.0.1",
"changes": [

View File

@ -1,3 +1,4 @@
export { ContractAddresses } from '@0x/contract-addresses';
export { WSOpts } from '@0x/mesh-rpc-client';
export {
AcceptedRejectedOrders,

View File

@ -42,7 +42,7 @@ export class SwapQuoteConsumer implements SwapQuoteConsumerBase {
const provider = providerUtils.standardizeOrThrow(supportedProvider);
this.provider = provider;
this.chainId = chainId;
this._contractAddresses = getContractAddressesForChainOrThrow(chainId);
this._contractAddresses = options.contractAddresses || getContractAddressesForChainOrThrow(chainId);
this._exchangeConsumer = new ExchangeSwapQuoteConsumer(supportedProvider, this._contractAddresses, options);
this._forwarderConsumer = new ForwarderSwapQuoteConsumer(supportedProvider, this._contractAddresses, options);
}

View File

@ -159,7 +159,7 @@ export class SwapQuoter {
this.orderbook = orderbook;
this.expiryBufferMs = expiryBufferMs;
this.permittedOrderFeeTypes = permittedOrderFeeTypes;
this._contractAddresses = getContractAddressesForChainOrThrow(chainId);
this._contractAddresses = options.contractAddresses || getContractAddressesForChainOrThrow(chainId);
this._devUtilsContract = new DevUtilsContract(this._contractAddresses.devUtils, provider);
this._protocolFeeUtils = new ProtocolFeeUtils(constants.PROTOCOL_FEE_UTILS_POLLING_INTERVAL_IN_MS);
this._orderStateUtils = new OrderStateUtils(this._devUtilsContract);

View File

@ -1,3 +1,4 @@
import { ContractAddresses } from '@0x/migrations';
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
@ -87,6 +88,7 @@ export interface SwapQuoteConsumerBase {
*/
export interface SwapQuoteConsumerOpts {
chainId: number;
contractAddresses?: ContractAddresses;
}
/**
@ -198,6 +200,7 @@ export interface SwapQuoterOpts extends OrderPrunerOpts {
chainId: number;
orderRefreshIntervalMs: number;
expiryBufferMs: number;
contractAddresses?: ContractAddresses;
}
/**