@dxdao/aqua-sc
Version:
Utility pack from aqua-smartcontracts
41 lines (31 loc) • 1.3 kB
text/typescript
/*eslint-disable */
// @ts-nocheck
// Inspired by https://github.com/0xProject/protocol/tree/main/packages/contract-addresses
import * as addresses from './addresses.json';
export * from './typechain/index';
export * from './encoders';
export interface ContractAddresses {
aquaFactory: string;
participantListLauncher: string;
saleLauncher: string;
templateLauncher: string;
}
export enum ChainId {
rinkeby = 4,
xdai = 100,
}
/**
* Used to get addresses of contracts that have been deployed to either the
* Ethereum mainnet or a supported testnet. Throws if there are no known
* contracts deployed on the corresponding chain.
* @param chainId The desired chainId.
* @returns The set of addresses for contracts which have been deployed on the
* given chainId.
*/
export function getContractAddressesForChainOrThrow(chainId: ChainId): ContractAddresses {
const chainToAddresses: { [chainId: number]: ContractAddresses } = addresses;
if (chainToAddresses[chainId] === undefined) {
throw new Error(`Unknown chain id (${chainId}). No known aqua contracts have been deployed on this chain.`);
}
return chainToAddresses[chainId];
}