Change all instances of networkId to chainId (#2313)

* abi-gen/test: recompile contract fixtures for 3.0

It seems this hadn't been done since the merge with the 3.0 branch.

* Sync `monorepo$ yarn test` exclusions to CI config

* sra-spec: correct typo

* contract-wrappers: TODO after coord.-server update

* utils: fix typo in comment

* Refactor networkId to chainId everywhere

* Update CHANGELOGs
This commit is contained in:
F. Eugene Aumson
2019-11-06 01:18:55 -05:00
committed by GitHub
parent e61f23d001
commit f51c80adb2
100 changed files with 5341 additions and 5213 deletions

View File

@@ -1,4 +1,13 @@
[
{
"version": "3.0.0-beta.0",
"changes": [
{
"note": "All references to network ID have been removed, and references to chain ID have been introduced instead",
"pr": 2313
}
]
},
{
"version": "2.1.0-beta.0",
"changes": [

View File

@@ -11,12 +11,12 @@ import {
const NULL_BYTES = '0x';
const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
const MAINNET_NETWORK_ID = 1;
const MAINNET_CHAIN_ID = 1;
const ONE_SECOND_MS = 1000;
const DEFAULT_PER_PAGE = 1000;
const DEFAULT_SWAP_QUOTER_OPTS: SwapQuoterOpts = {
networkId: MAINNET_NETWORK_ID,
chainId: MAINNET_CHAIN_ID,
orderRefreshIntervalMs: 10000, // 10 seconds
expiryBufferMs: 120000, // 2 minutes
};
@@ -42,7 +42,7 @@ export const constants = {
NULL_BYTES,
ZERO_AMOUNT: new BigNumber(0),
NULL_ADDRESS,
MAINNET_NETWORK_ID,
MAINNET_CHAIN_ID,
ETHER_TOKEN_DECIMALS: 18,
ONE_AMOUNT: new BigNumber(1),
ONE_SECOND_MS,

View File

@@ -23,19 +23,19 @@ import { utils } from '../utils/utils';
export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumerBase<ExchangeSmartContractParams> {
public readonly provider: ZeroExProvider;
public readonly networkId: number;
public readonly chainId: number;
private readonly _contractWrappers: ContractWrappers;
constructor(supportedProvider: SupportedProvider, options: Partial<SwapQuoteConsumerOpts> = {}) {
const { networkId } = _.merge({}, constants.DEFAULT_SWAP_QUOTER_OPTS, options);
assert.isNumber('networkId', networkId);
const { chainId } = _.merge({}, constants.DEFAULT_SWAP_QUOTER_OPTS, options);
assert.isNumber('chainId', chainId);
const provider = providerUtils.standardizeOrThrow(supportedProvider);
this.provider = provider;
this.networkId = networkId;
this.chainId = chainId;
this._contractWrappers = new ContractWrappers(this.provider, {
networkId,
chainId,
});
}

View File

@@ -25,19 +25,19 @@ import { utils } from '../utils/utils';
export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase<ForwarderSmartContractParams> {
public readonly provider: ZeroExProvider;
public readonly networkId: number;
public readonly chainId: number;
private readonly _contractWrappers: ContractWrappers;
constructor(supportedProvider: SupportedProvider, options: Partial<SwapQuoteConsumerOpts> = {}) {
const { networkId } = _.merge({}, constants.DEFAULT_SWAP_QUOTER_OPTS, options);
assert.isNumber('networkId', networkId);
const { chainId } = _.merge({}, constants.DEFAULT_SWAP_QUOTER_OPTS, options);
assert.isNumber('chainId', chainId);
const provider = providerUtils.standardizeOrThrow(supportedProvider);
this.provider = provider;
this.networkId = networkId;
this.chainId = chainId;
this._contractWrappers = new ContractWrappers(this.provider, {
networkId,
chainId,
});
}

View File

@@ -24,24 +24,24 @@ import { ForwarderSwapQuoteConsumer } from './forwarder_swap_quote_consumer';
export class SwapQuoteConsumer implements SwapQuoteConsumerBase<SmartContractParams> {
public readonly provider: ZeroExProvider;
public readonly networkId: number;
public readonly chainId: number;
private readonly _exchangeConsumer: ExchangeSwapQuoteConsumer;
private readonly _forwarderConsumer: ForwarderSwapQuoteConsumer;
private readonly _contractWrappers: ContractWrappers;
constructor(supportedProvider: SupportedProvider, options: Partial<SwapQuoteConsumerOpts> = {}) {
const { networkId } = _.merge({}, constants.DEFAULT_SWAP_QUOTER_OPTS, options);
assert.isNumber('networkId', networkId);
const { chainId } = _.merge({}, constants.DEFAULT_SWAP_QUOTER_OPTS, options);
assert.isNumber('chainId', chainId);
const provider = providerUtils.standardizeOrThrow(supportedProvider);
this.provider = provider;
this.networkId = networkId;
this.chainId = chainId;
this._exchangeConsumer = new ExchangeSwapQuoteConsumer(supportedProvider, options);
this._forwarderConsumer = new ForwarderSwapQuoteConsumer(supportedProvider, options);
this._contractWrappers = new ContractWrappers(this.provider, {
networkId,
chainId,
});
}

View File

@@ -69,7 +69,7 @@ export class SwapQuoter {
httpEndpoint: sraApiUrl,
pollingIntervalMs:
options.orderRefreshIntervalMs || constants.DEFAULT_SWAP_QUOTER_OPTS.orderRefreshIntervalMs,
networkId: options.networkId || constants.DEFAULT_SWAP_QUOTER_OPTS.networkId,
chainId: options.chainId || constants.DEFAULT_SWAP_QUOTER_OPTS.chainId,
perPage: options.perPage || constants.DEFAULT_PER_PAGE,
});
const swapQuoter = new SwapQuoter(provider, orderbook, options);
@@ -97,7 +97,7 @@ export class SwapQuoter {
const orderbook = Orderbook.getOrderbookForWebsocketProvider({
httpEndpoint: sraApiUrl,
websocketEndpoint: sraWebsocketAPIUrl,
networkId: options.networkId,
chainId: options.chainId,
});
const swapQuoter = new SwapQuoter(provider, orderbook, options);
return swapQuoter;
@@ -134,16 +134,16 @@ export class SwapQuoter {
* @return An instance of SwapQuoter
*/
constructor(supportedProvider: SupportedProvider, orderbook: Orderbook, options: Partial<SwapQuoterOpts> = {}) {
const { networkId, expiryBufferMs } = _.merge({}, constants.DEFAULT_SWAP_QUOTER_OPTS, options);
const { chainId, expiryBufferMs } = _.merge({}, constants.DEFAULT_SWAP_QUOTER_OPTS, options);
const provider = providerUtils.standardizeOrThrow(supportedProvider);
assert.isValidOrderbook('orderbook', orderbook);
assert.isNumber('networkId', networkId);
assert.isNumber('chainId', chainId);
assert.isNumber('expiryBufferMs', expiryBufferMs);
this.provider = provider;
this.orderbook = orderbook;
this.expiryBufferMs = expiryBufferMs;
this._contractWrappers = new ContractWrappers(this.provider, {
networkId,
chainId,
});
}
/**
@@ -394,7 +394,7 @@ export class SwapQuoter {
/**
* Get the assetData that represents the ZRX token.
* Will throw if ZRX does not exist for the current network.
* Will throw if ZRX does not exist for the current chain.
*/
private _getZrxTokenAssetDataOrThrow(): string {
return assetDataUtils.encodeERC20AssetData(this._contractWrappers.contractAddresses.zrxToken);

View File

@@ -5,12 +5,12 @@ import { MethodAbi } from 'ethereum-types';
/**
* makerAssetData: The assetData representing the desired makerAsset.
* takerAssetData: The assetData representing the desired takerAsset.
* networkId: The networkId that the desired orders should be for.
* chainId: The chainId that the desired orders should be for.
*/
export interface OrderProviderRequest {
makerAssetData: string;
takerAssetData: string;
networkId: number;
chainId: number;
}
/**
@@ -148,10 +148,10 @@ export interface SwapQuoteConsumerBase<T> {
}
/**
* networkId: The networkId that the desired orders should be for.
* chainId: The chainId that the desired orders should be for.
*/
export interface SwapQuoteConsumerOpts {
networkId: number;
chainId: number;
}
/**
@@ -271,12 +271,12 @@ export interface SwapQuoteRequestOpts {
}
/**
* networkId: The ethereum network id. Defaults to 1 (mainnet).
* chainId: The ethereum chain id. Defaults to 1 (mainnet).
* orderRefreshIntervalMs: The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s).
* expiryBufferMs: The number of seconds to add when calculating whether an order is expired or not. Defaults to 300s (5m).
*/
export interface SwapQuoterOpts {
networkId: number;
chainId: number;
orderRefreshIntervalMs: number;
expiryBufferMs: number;
}

View File

@@ -27,7 +27,7 @@ const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const ONE_ETH_IN_WEI = new BigNumber(1000000000000000000);
const TESTRPC_NETWORK_ID = 50;
const TESTRPC_CHAIN_ID = 1337;
const FILLABLE_AMOUNTS = [new BigNumber(3), new BigNumber(2), new BigNumber(5)].map(value =>
value.multipliedBy(ONE_ETH_IN_WEI),
);
@@ -48,7 +48,7 @@ describe('ExchangeSwapQuoteConsumer', () => {
let wethAssetData: string;
let contractAddresses: ContractAddresses;
const networkId = TESTRPC_NETWORK_ID;
const chainId = TESTRPC_CHAIN_ID;
let orders: SignedOrder[];
let marketSellSwapQuote: SwapQuote;
@@ -60,7 +60,7 @@ describe('ExchangeSwapQuoteConsumer', () => {
await blockchainLifecycle.startAsync();
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
const config = {
networkId,
chainId,
contractAddresses,
};
contractWrappers = new ContractWrappers(provider, config);
@@ -83,7 +83,7 @@ describe('ExchangeSwapQuoteConsumer', () => {
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(contractAddresses.zrxToken),
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(contractAddresses.zrxToken),
exchangeAddress: contractAddresses.exchange,
chainId: networkId,
chainId,
};
const privateKey = devConstants.TESTRPC_PRIVATE_KEYS[userAddresses.indexOf(makerAddress)];
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
@@ -117,7 +117,7 @@ describe('ExchangeSwapQuoteConsumer', () => {
);
swapQuoteConsumer = new ExchangeSwapQuoteConsumer(provider, {
networkId,
chainId,
});
});
afterEach(async () => {

View File

@@ -25,7 +25,7 @@ const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const ONE_ETH_IN_WEI = new BigNumber(1000000000000000000);
const TESTRPC_NETWORK_ID = 50;
const TESTRPC_CHAIN_ID = 1337;
const MARKET_OPERATION = MarketOperation.Sell;
const FILLABLE_AMOUNTS = [new BigNumber(2), new BigNumber(3), new BigNumber(5)].map(value =>
value.multipliedBy(ONE_ETH_IN_WEI),
@@ -53,13 +53,13 @@ describe('ForwarderSwapQuoteConsumer', () => {
let swapQuoteConsumer: ForwarderSwapQuoteConsumer;
let erc20ProxyAddress: string;
const networkId = TESTRPC_NETWORK_ID;
const chainId = TESTRPC_CHAIN_ID;
before(async () => {
contractAddresses = await migrateOnceAsync();
await blockchainLifecycle.startAsync();
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
const config = {
networkId,
chainId,
contractAddresses,
};
contractWrappers = new ContractWrappers(provider, config);
@@ -117,7 +117,7 @@ describe('ForwarderSwapQuoteConsumer', () => {
);
swapQuoteConsumer = new ForwarderSwapQuoteConsumer(provider, {
networkId,
chainId,
});
});
afterEach(async () => {

View File

@@ -19,7 +19,7 @@ const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const ONE_ETH_IN_WEI = new BigNumber(1000000000000000000);
const TESTRPC_NETWORK_ID = 50;
const TESTRPC_CHAIN_ID = 1337;
const FILLABLE_AMOUNTS = [new BigNumber(3), new BigNumber(2), new BigNumber(5)].map(value =>
value.multipliedBy(ONE_ETH_IN_WEI),
);
@@ -41,7 +41,7 @@ describe('SwapQuoteConsumer', () => {
let wethAssetData: string;
let contractAddresses: ContractAddresses;
const networkId = TESTRPC_NETWORK_ID;
const chainId = TESTRPC_CHAIN_ID;
let orders: SignedOrder[];
let marketSellSwapQuote: SwapQuote;
@@ -53,7 +53,7 @@ describe('SwapQuoteConsumer', () => {
await blockchainLifecycle.startAsync();
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
const config = {
networkId,
chainId,
contractAddresses,
};
contractWrappers = new ContractWrappers(provider, config);
@@ -104,7 +104,7 @@ describe('SwapQuoteConsumer', () => {
);
swapQuoteConsumer = new SwapQuoteConsumer(provider, {
networkId,
chainId,
});
});
afterEach(async () => {

View File

@@ -19,7 +19,7 @@ const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const ONE_ETH_IN_WEI = new BigNumber(1000000000000000000);
const TESTRPC_NETWORK_ID = 50;
const TESTRPC_CHAIN_ID = 1337;
const FILLABLE_AMOUNTS = [new BigNumber(2), new BigNumber(3), new BigNumber(5)].map(value =>
value.multipliedBy(ONE_ETH_IN_WEI),
);
@@ -40,13 +40,13 @@ describe('swapQuoteConsumerUtils', () => {
let contractAddresses: ContractAddresses;
let swapQuoteConsumer: SwapQuoteConsumer;
const networkId = TESTRPC_NETWORK_ID;
const chainId = TESTRPC_CHAIN_ID;
before(async () => {
contractAddresses = await migrateOnceAsync();
await blockchainLifecycle.startAsync();
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
const config = {
networkId,
chainId,
contractAddresses,
};
contractWrappers = new ContractWrappers(provider, config);
@@ -59,7 +59,7 @@ describe('swapQuoteConsumerUtils', () => {
];
swapQuoteConsumer = new SwapQuoteConsumer(provider, {
networkId,
chainId,
});
});
after(async () => {