Stop hardcoding contract addresses (#2461)
* stop hardcoding contract addresses * update changelog * export ContractAddresses for docs
This commit is contained in:
parent
400fb5a5bb
commit
919fc66b9d
@ -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": [
|
||||
|
@ -1,3 +1,4 @@
|
||||
export { ContractAddresses } from '@0x/contract-addresses';
|
||||
export { WSOpts } from '@0x/mesh-rpc-client';
|
||||
export {
|
||||
AcceptedRejectedOrders,
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user