diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-24 05:20:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-24 05:20:28 +0800 |
commit | 10c0c0b6d2fce2a08858cd7ec280ed72d3da0b32 (patch) | |
tree | db5b0c66958d8ea6f77e0bdcf0e1bae2fdb13af1 /packages/0x.js/src/schemas | |
parent | 3d2c5d67afb6a754ed7a0b883ff93bf330660eff (diff) | |
parent | 3120d854f855a01ad7bce3427a64d931de1879d3 (diff) | |
download | dexon-sol-tools-10c0c0b6d2fce2a08858cd7ec280ed72d3da0b32.tar dexon-sol-tools-10c0c0b6d2fce2a08858cd7ec280ed72d3da0b32.tar.gz dexon-sol-tools-10c0c0b6d2fce2a08858cd7ec280ed72d3da0b32.tar.bz2 dexon-sol-tools-10c0c0b6d2fce2a08858cd7ec280ed72d3da0b32.tar.lz dexon-sol-tools-10c0c0b6d2fce2a08858cd7ec280ed72d3da0b32.tar.xz dexon-sol-tools-10c0c0b6d2fce2a08858cd7ec280ed72d3da0b32.tar.zst dexon-sol-tools-10c0c0b6d2fce2a08858cd7ec280ed72d3da0b32.zip |
Merge pull request #385 from 0xProject/feature/0x_config_validation
Better validate ZeroExConfig on private networks
Diffstat (limited to 'packages/0x.js/src/schemas')
3 files changed, 65 insertions, 23 deletions
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'], +}; |