aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/0x.js/src')
-rw-r--r--packages/0x.js/src/0x.ts7
-rw-r--r--packages/0x.js/src/schemas/zero_ex_config_schema.ts24
-rw-r--r--packages/0x.js/src/schemas/zero_ex_private_network_config_schema.ts35
-rw-r--r--packages/0x.js/src/schemas/zero_ex_public_network_config_schema.ts29
-rw-r--r--packages/0x.js/src/types.ts2
5 files changed, 72 insertions, 25 deletions
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts
index 6cfa65cc2..c578478d8 100644
--- a/packages/0x.js/src/0x.ts
+++ b/packages/0x.js/src/0x.ts
@@ -13,6 +13,8 @@ import { TokenTransferProxyWrapper } from './contract_wrappers/token_transfer_pr
import { TokenWrapper } from './contract_wrappers/token_wrapper';
import { OrderStateWatcher } from './order_watcher/order_state_watcher';
import { zeroExConfigSchema } from './schemas/zero_ex_config_schema';
+import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema';
+import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema';
import { ECSignature, Order, SignedOrder, Web3Provider, ZeroExConfig, ZeroExError } from './types';
import { assert } from './utils/assert';
import { constants } from './utils/constants';
@@ -163,7 +165,10 @@ export class ZeroEx {
*/
constructor(provider: Web3Provider, config: ZeroExConfig) {
assert.isWeb3Provider('provider', provider);
- assert.doesConformToSchema('config', config, zeroExConfigSchema);
+ assert.doesConformToSchema('config', config, zeroExConfigSchema, [
+ zeroExPrivateNetworkConfigSchema,
+ zeroExPublicNetworkConfigSchema,
+ ]);
const artifactJSONs = _.values(artifacts);
const abiArrays = _.map(artifactJSONs, artifact => artifact.abi);
this._abiDecoder = new AbiDecoder(abiArrays);
diff --git a/packages/0x.js/src/schemas/zero_ex_config_schema.ts b/packages/0x.js/src/schemas/zero_ex_config_schema.ts
index 546b1c2d0..a9c3c64fc 100644
--- a/packages/0x.js/src/schemas/zero_ex_config_schema.ts
+++ b/packages/0x.js/src/schemas/zero_ex_config_schema.ts
@@ -1,27 +1,5 @@
export const zeroExConfigSchema = {
id: '/ZeroExConfig',
- properties: {
- networkId: {
- type: 'number',
- minimum: 0,
- },
- gasPrice: { $ref: '/Number' },
- exchangeContractAddress: { $ref: '/Address' },
- tokenRegistryContractAddress: { $ref: '/Address' },
- orderWatcherConfig: {
- type: 'object',
- properties: {
- pollingIntervalMs: {
- type: 'number',
- minimum: 0,
- },
- numConfirmations: {
- type: 'number',
- minimum: 0,
- },
- },
- },
- },
+ oneOf: [{ $ref: '/ZeroExPrivateNetworkConfig' }, { $ref: '/ZeroExPublicNetworkConfig' }],
type: 'object',
- required: ['networkId'],
};
diff --git a/packages/0x.js/src/schemas/zero_ex_private_network_config_schema.ts b/packages/0x.js/src/schemas/zero_ex_private_network_config_schema.ts
new file mode 100644
index 000000000..f7f649a6d
--- /dev/null
+++ b/packages/0x.js/src/schemas/zero_ex_private_network_config_schema.ts
@@ -0,0 +1,35 @@
+export const zeroExPrivateNetworkConfigSchema = {
+ id: '/ZeroExPrivateNetworkConfig',
+ properties: {
+ networkId: {
+ type: 'number',
+ minimum: 1,
+ },
+ gasPrice: { $ref: '/Number' },
+ zrxContractAddress: { $ref: '/Address' },
+ exchangeContractAddress: { $ref: '/Address' },
+ tokenRegistryContractAddress: { $ref: '/Address' },
+ tokenTransferProxyContractAddress: { $ref: '/Address' },
+ orderWatcherConfig: {
+ type: 'object',
+ properties: {
+ pollingIntervalMs: {
+ type: 'number',
+ minimum: 0,
+ },
+ numConfirmations: {
+ type: 'number',
+ minimum: 0,
+ },
+ },
+ },
+ },
+ type: 'object',
+ required: [
+ 'networkId',
+ 'zrxContractAddress',
+ 'exchangeContractAddress',
+ 'tokenRegistryContractAddress',
+ 'tokenTransferProxyContractAddress',
+ ],
+};
diff --git a/packages/0x.js/src/schemas/zero_ex_public_network_config_schema.ts b/packages/0x.js/src/schemas/zero_ex_public_network_config_schema.ts
new file mode 100644
index 000000000..9da31481a
--- /dev/null
+++ b/packages/0x.js/src/schemas/zero_ex_public_network_config_schema.ts
@@ -0,0 +1,29 @@
+export const zeroExPublicNetworkConfigSchema = {
+ id: '/ZeroExPublicNetworkConfig',
+ properties: {
+ networkId: {
+ type: 'number',
+ enum: [1, 3, 4, 42, 50],
+ },
+ gasPrice: { $ref: '/Number' },
+ zrxContractAddress: { $ref: '/Address' },
+ exchangeContractAddress: { $ref: '/Address' },
+ tokenRegistryContractAddress: { $ref: '/Address' },
+ tokenTransferProxyContractAddress: { $ref: '/Address' },
+ orderWatcherConfig: {
+ type: 'object',
+ properties: {
+ pollingIntervalMs: {
+ type: 'number',
+ minimum: 0,
+ },
+ numConfirmations: {
+ type: 'number',
+ minimum: 0,
+ },
+ },
+ },
+ },
+ type: 'object',
+ required: ['networkId'],
+};
diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts
index ab97f7775..0a3037258 100644
--- a/packages/0x.js/src/types.ts
+++ b/packages/0x.js/src/types.ts
@@ -196,7 +196,7 @@ export interface OrderStateWatcherConfig {
}
/*
- * networkId: The id of the underlying ethereum network your provider is connected to. (1-mainnet, 42-kovan, 50-testrpc)
+ * networkId: The id of the underlying ethereum network your provider is connected to. (1-mainnet, 3-ropsten, 4-rinkeby, 42-kovan, 50-testrpc)
* gasPrice: Gas price to use with every transaction
* exchangeContractAddress: The address of an exchange contract to use
* zrxContractAddress: The address of the ZRX contract to use