aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sra-report/src
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-03-06 08:13:47 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-03-06 08:13:47 +0800
commit38a4ccd9f24cd1cd583c17ebc200238e1770e5f8 (patch)
treed0647ebcb590cf8ec6eb73583d505d5623faa006 /packages/sra-report/src
parentcf342dd00eaae8667984e77eb565040c132f160a (diff)
downloaddexon-sol-tools-38a4ccd9f24cd1cd583c17ebc200238e1770e5f8.tar.gz
dexon-sol-tools-38a4ccd9f24cd1cd583c17ebc200238e1770e5f8.tar.zst
dexon-sol-tools-38a4ccd9f24cd1cd583c17ebc200238e1770e5f8.zip
Change all globals in environment variables
Diffstat (limited to 'packages/sra-report/src')
-rw-r--r--packages/sra-report/src/contract_addresses/kovan_addresses.ts6
-rw-r--r--packages/sra-report/src/contract_addresses/mainnet_addresses.ts6
-rw-r--r--packages/sra-report/src/index.ts8
-rw-r--r--packages/sra-report/src/postman_environment_factory.ts32
4 files changed, 33 insertions, 19 deletions
diff --git a/packages/sra-report/src/contract_addresses/kovan_addresses.ts b/packages/sra-report/src/contract_addresses/kovan_addresses.ts
new file mode 100644
index 000000000..e097bf12a
--- /dev/null
+++ b/packages/sra-report/src/contract_addresses/kovan_addresses.ts
@@ -0,0 +1,6 @@
+export const addresses = {
+ 'DAI_address': '0xb18845c260f680d5b9d84649638813e342e4f8c9',
+ 'WETH_address': '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
+ 'ZRX_address': '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570',
+ 'EXCHANGE_CONTRACT_address': '0x90fe2af704b34e0224bf2299c838e04d4dcf1364',
+};
diff --git a/packages/sra-report/src/contract_addresses/mainnet_addresses.ts b/packages/sra-report/src/contract_addresses/mainnet_addresses.ts
new file mode 100644
index 000000000..cbd79a0e7
--- /dev/null
+++ b/packages/sra-report/src/contract_addresses/mainnet_addresses.ts
@@ -0,0 +1,6 @@
+export const addresses = {
+ 'DAI_address': '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
+ 'WETH_address': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
+ 'ZRX_address': '0xe41d2489571d322189246dafa5ebde1f4699f498',
+ 'EXCHANGE_CONTRACT_address': '0x12459c951127e0c374ff9105dda097662a027093',
+};
diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts
index c74b5cb40..4e93708ee 100644
--- a/packages/sra-report/src/index.ts
+++ b/packages/sra-report/src/index.ts
@@ -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);
diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts
index a8753d9ff..7534baaaf 100644
--- a/packages/sra-report/src/postman_environment_factory.ts
+++ b/packages/sra-report/src/postman_environment_factory.ts
@@ -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, '/')) {