aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/utils/contract_addresses.ts
blob: dc156e01718790058b00fef4d1946063c2b1ca89 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { ContractAddresses, getContractAddressesForNetworkOrThrow, NetworkId } from '@0x/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);
}