aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contract-wrappers/src/utils')
-rw-r--r--packages/contract-wrappers/src/utils/contract_addresses.ts15
-rw-r--r--packages/contract-wrappers/src/utils/transaction_encoder.ts4
2 files changed, 17 insertions, 2 deletions
diff --git a/packages/contract-wrappers/src/utils/contract_addresses.ts b/packages/contract-wrappers/src/utils/contract_addresses.ts
new file mode 100644
index 000000000..98967c52d
--- /dev/null
+++ b/packages/contract-wrappers/src/utils/contract_addresses.ts
@@ -0,0 +1,15 @@
+import { ContractAddresses, getContractAddressesForNetworkOrThrow, NetworkId } from '@0xproject/contract-addresses';
+import * as _ from 'lodash';
+
+/**
+ * Returns the default contract addresses for the given networkId or throws with
+ * a context-specific error message if the networkId is not recognized.
+ */
+export function _getDefaultContractAddresses(networkId: number): ContractAddresses {
+ if (!(networkId in NetworkId)) {
+ throw new Error(
+ `No default contract addresses found for the given network id (${networkId}). If you want to use ContractWrappers on this network, you must manually pass in the contract address(es) to the constructor.`,
+ );
+ }
+ return getContractAddressesForNetworkOrThrow(networkId);
+}
diff --git a/packages/contract-wrappers/src/utils/transaction_encoder.ts b/packages/contract-wrappers/src/utils/transaction_encoder.ts
index 33086944b..d179fa07e 100644
--- a/packages/contract-wrappers/src/utils/transaction_encoder.ts
+++ b/packages/contract-wrappers/src/utils/transaction_encoder.ts
@@ -1,11 +1,11 @@
+import { ExchangeContract } from '@0xproject/abi-gen-wrappers';
+
import { schemas } from '@0xproject/json-schemas';
import { eip712Utils } from '@0xproject/order-utils';
import { Order, SignedOrder } from '@0xproject/types';
import { BigNumber, signTypedDataUtils } from '@0xproject/utils';
import _ = require('lodash');
-import { ExchangeContract } from '../contract_wrappers/generated/exchange';
-
import { assert } from './assert';
/**