aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-10-16 05:22:48 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-10-16 05:22:48 +0800
commit38b146c395429f860f57fa1865e01175eee39e62 (patch)
tree19fea9dc74f5fb0b1b8212a65f3274b94df31d0a /packages
parente3af06ab107f98d4ca4a195da05d808370b56bb4 (diff)
downloaddexon-sol-tools-38b146c395429f860f57fa1865e01175eee39e62.tar
dexon-sol-tools-38b146c395429f860f57fa1865e01175eee39e62.tar.gz
dexon-sol-tools-38b146c395429f860f57fa1865e01175eee39e62.tar.bz2
dexon-sol-tools-38b146c395429f860f57fa1865e01175eee39e62.tar.lz
dexon-sol-tools-38b146c395429f860f57fa1865e01175eee39e62.tar.xz
dexon-sol-tools-38b146c395429f860f57fa1865e01175eee39e62.tar.zst
dexon-sol-tools-38b146c395429f860f57fa1865e01175eee39e62.zip
Add OrThrow suffix to getContractAddressesForNetwork
Diffstat (limited to 'packages')
-rw-r--r--packages/contract-addresses/README.md5
-rw-r--r--packages/contract-addresses/src/index.ts5
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts1
-rw-r--r--packages/contract-wrappers/src/utils/contract_addresses.ts4
4 files changed, 8 insertions, 7 deletions
diff --git a/packages/contract-addresses/README.md b/packages/contract-addresses/README.md
index 62c062d26..6c615c422 100644
--- a/packages/contract-addresses/README.md
+++ b/packages/contract-addresses/README.md
@@ -12,13 +12,14 @@ yarn add @0xproject/contract-addresses
**Import**
```typescript
-import { getContractAddressesForNetwork } from '@0xproject/contract-addresses';
+import { getContractAddressesForNetworkOrThrow } from '@0xproject/contract-addresses';
```
or
```javascript
-var getContractAddressesForNetwork = require('@0xproject/contract-addresses').getContractAddressesForNetwork;
+var getContractAddressesForNetworkOrThrow = require('@0xproject/contract-addresses')
+ .getContractAddressesForNetworkOrThrow;
```
## Contributing
diff --git a/packages/contract-addresses/src/index.ts b/packages/contract-addresses/src/index.ts
index 80e88c8f9..1ea8c61dd 100644
--- a/packages/contract-addresses/src/index.ts
+++ b/packages/contract-addresses/src/index.ts
@@ -52,12 +52,13 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
/**
* Used to get addresses of contracts that have been deployed to either the
- * Ethereum mainnet or a supported testnet.
+ * Ethereum mainnet or a supported testnet. Throws if there are no known
+ * contracts deployed on the corresponding network.
* @param networkId The desired networkId.
* @returns The set of addresses for contracts which have been deployed on the
* given networkId.
*/
-export function getContractAddressesForNetwork(networkId: NetworkId): ContractAddresses {
+export function getContractAddressesForNetworkOrThrow(networkId: NetworkId): ContractAddresses {
if (_.isUndefined(networkToAddresses[networkId])) {
throw new Error(`Unknown network id (${networkId}). No known 0x contracts have been deployed on this network.`);
}
diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
index 72f5aa629..e03e4188b 100644
--- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
@@ -1,4 +1,3 @@
-import { ContractAddresses, getContractAddressesForNetwork, NetworkId } from '@0xproject/contract-addresses';
import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils';
import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper';
import {
diff --git a/packages/contract-wrappers/src/utils/contract_addresses.ts b/packages/contract-wrappers/src/utils/contract_addresses.ts
index cd0d31308..98967c52d 100644
--- a/packages/contract-wrappers/src/utils/contract_addresses.ts
+++ b/packages/contract-wrappers/src/utils/contract_addresses.ts
@@ -1,4 +1,4 @@
-import { ContractAddresses, getContractAddressesForNetwork, NetworkId } from '@0xproject/contract-addresses';
+import { ContractAddresses, getContractAddressesForNetworkOrThrow, NetworkId } from '@0xproject/contract-addresses';
import * as _ from 'lodash';
/**
@@ -11,5 +11,5 @@ export function _getDefaultContractAddresses(networkId: number): ContractAddress
`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 getContractAddressesForNetwork(networkId);
+ return getContractAddressesForNetworkOrThrow(networkId);
}