From 38b146c395429f860f57fa1865e01175eee39e62 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Mon, 15 Oct 2018 14:22:48 -0700 Subject: Add OrThrow suffix to getContractAddressesForNetwork --- packages/contract-addresses/README.md | 5 +++-- packages/contract-addresses/src/index.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'packages/contract-addresses') 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.`); } -- cgit v1.2.3