Change all globals in environment variables
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"id": "8dab7221-c8b8-2931-92c8-605f6f4072e1",
|
||||
"name": "Kovan Tokens",
|
||||
"values": [
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "DAI_address",
|
||||
"value": "0xb18845c260f680d5b9d84649638813e342e4f8c9",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "WETH_address",
|
||||
"value": "0xd0a1e359811322d97991e03f863a0c30c2cf029c",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "ZRX_address",
|
||||
"value": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "EXCHANGE_CONTRACT_address",
|
||||
"value": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"timestamp": 1518639440766,
|
||||
"_postman_variable_scope": "environment",
|
||||
"_postman_exported_at": "2018-02-14T22:49:13.162Z",
|
||||
"_postman_exported_using": "Postman/5.5.2"
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"id": "e1087711-9cff-fd54-ba20-990b17a15f80",
|
||||
"name": "Mainnet tokens",
|
||||
"values": [
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "DAI_address",
|
||||
"value": "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "WETH_address",
|
||||
"value": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "ZRX_address",
|
||||
"value": "0xe41d2489571d322189246dafa5ebde1f4699f498",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "EXCHANGE_CONTRACT_address",
|
||||
"value": "0x12459c951127e0c374ff9105dda097662a027093",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"timestamp": 1518561760642,
|
||||
"_postman_variable_scope": "environment",
|
||||
"_postman_exported_at": "2018-02-14T22:48:11.259Z",
|
||||
"_postman_exported_using": "Postman/5.5.2"
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
export const addresses = {
|
||||
'DAI_address': '0xb18845c260f680d5b9d84649638813e342e4f8c9',
|
||||
'WETH_address': '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
||||
'ZRX_address': '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570',
|
||||
'EXCHANGE_CONTRACT_address': '0x90fe2af704b34e0224bf2299c838e04d4dcf1364',
|
||||
};
|
@@ -0,0 +1,6 @@
|
||||
export const addresses = {
|
||||
'DAI_address': '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
||||
'WETH_address': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||
'ZRX_address': '0xe41d2489571d322189246dafa5ebde1f4699f498',
|
||||
'EXCHANGE_CONTRACT_address': '0x12459c951127e0c374ff9105dda097662a027093',
|
||||
};
|
@@ -60,11 +60,6 @@ const mainAsync = async () => {
|
||||
if (_.isUndefined(firstOrder)) {
|
||||
throw new Error('Could not get any orders from /orders endpoint');
|
||||
}
|
||||
const newmanEnvironmentOptions = {
|
||||
collection: sraReportCollectionJSON,
|
||||
globals: postmanEnvironmentFactory.createGlobalEnvironment(args.endpointUrl, firstOrder),
|
||||
environment: postmanEnvironmentFactory.createNetworkEnvironment(args.networkId),
|
||||
};
|
||||
const newmanReporterOptions = !_.isUndefined(args.output)
|
||||
? {
|
||||
reporters: 'json',
|
||||
@@ -78,7 +73,8 @@ const mainAsync = async () => {
|
||||
reporters: 'cli',
|
||||
};
|
||||
const newmanRunOptions = {
|
||||
...newmanEnvironmentOptions,
|
||||
collection: sraReportCollectionJSON,
|
||||
environment: postmanEnvironmentFactory.createPostmanEnvironment(args.endpointUrl, args.networkId, firstOrder),
|
||||
...newmanReporterOptions,
|
||||
};
|
||||
await newmanRunAsync(newmanRunOptions);
|
||||
|
@@ -2,8 +2,8 @@ import { SignedOrder, ZeroEx } from '0x.js';
|
||||
import { Schema, schemas as schemasByName } from '@0xproject/json-schemas';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import * as kovanTokensEnvironmentJSON from '../postman_configs/environments/kovan_tokens.postman_environment.json';
|
||||
import * as mainnetTokensEnvironmentJSON from '../postman_configs/environments/mainnet_tokens.postman_environment.json';
|
||||
import { addresses as kovanAddresses} from './contract_addresses/kovan_addresses';
|
||||
import { addresses as mainnetAddresses} from './contract_addresses/mainnet_addresses';
|
||||
|
||||
interface EnvironmentValue {
|
||||
key: string;
|
||||
@@ -13,7 +13,7 @@ interface EnvironmentValue {
|
||||
}
|
||||
|
||||
export const postmanEnvironmentFactory = {
|
||||
createGlobalEnvironment(url: string, order: SignedOrder) {
|
||||
createPostmanEnvironment(url: string, networkId: number, order: SignedOrder) {
|
||||
const schemas: Schema[] = _.values(schemasByName);
|
||||
const schemaEnvironmentValues = _.compact(
|
||||
_.map(schemas, (schema: Schema) => {
|
||||
@@ -30,8 +30,14 @@ export const postmanEnvironmentFactory = {
|
||||
const schemaKeys = _.map(schemaEnvironmentValues, (environmentValue: EnvironmentValue) => {
|
||||
return environmentValue.key;
|
||||
});
|
||||
const contractAddresses = getContractAddresses(networkId);
|
||||
const contractAddressEnvironmentValues = _.map(_.keys(contractAddresses), (key: string) => {
|
||||
const contractAddress = _.get(contractAddresses, key);
|
||||
return createEnvironmentValue(key, contractAddress);
|
||||
});
|
||||
const allEnvironmentValues = _.concat(
|
||||
schemaEnvironmentValues,
|
||||
contractAddressEnvironmentValues,
|
||||
createEnvironmentValue('schemaKeys', JSON.stringify(schemaKeys)),
|
||||
createEnvironmentValue('url', url),
|
||||
createEnvironmentValue('order', JSON.stringify(order)),
|
||||
@@ -45,17 +51,17 @@ export const postmanEnvironmentFactory = {
|
||||
};
|
||||
return environment;
|
||||
},
|
||||
createNetworkEnvironment(networkId: number) {
|
||||
switch (networkId) {
|
||||
case 1:
|
||||
return mainnetTokensEnvironmentJSON;
|
||||
case 42:
|
||||
return kovanTokensEnvironmentJSON;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
},
|
||||
};
|
||||
function getContractAddresses(networkId: number) {
|
||||
switch (networkId) {
|
||||
case 1:
|
||||
return mainnetAddresses;
|
||||
case 42:
|
||||
return kovanAddresses;
|
||||
default:
|
||||
throw new Error('Unsupported network id');
|
||||
}
|
||||
}
|
||||
function convertSchemaIdToKey(schemaId: string) {
|
||||
let result = schemaId;
|
||||
if (_.startsWith(result, '/')) {
|
||||
|
Reference in New Issue
Block a user