@@ -8,6 +8,21 @@ import { validateAddress } from "../../utils/validation";
88
99const { trace } = getLogger ( "deploy:title-escrow" ) ;
1010
11+ const CREATOR_CONTRACTS : { [ network : string ] : string } = {
12+ mainnet : "0x907A4D491A09D59Bcb5dC38eeb9d121ac47237F1" ,
13+ ropsten : "0xB0dE5E22bAc12820b6dbF6f63287B1ec44026c83" ,
14+ rinkeby : "0xa51B8dAC076d5aC80507041146AC769542aAe195" ,
15+ } ;
16+
17+ export const getDefaultEscrowFactory = ( network : string ) : string => {
18+ const address = CREATOR_CONTRACTS [ network ] ;
19+ if ( ! address )
20+ throw new Error (
21+ "Title escrow creator not found on this network, please deploy one onto this network and specify the address with the -c flag"
22+ ) ;
23+ return address ;
24+ } ;
25+
1126export const deployTitleEscrow = async ( {
1227 tokenRegistry,
1328 beneficiary,
@@ -19,16 +34,17 @@ export const deployTitleEscrow = async ({
1934 gasPriceScale,
2035 encryptedWalletPath,
2136} : DeployTitleEscrowCommand ) : Promise < TransactionReceipt > => {
37+ const titleEscrowFactoryAddress = titleEscrowFactory || getDefaultEscrowFactory ( network ) ;
2238 validateAddress ( tokenRegistry ) ;
2339 validateAddress ( beneficiary ) ;
2440 validateAddress ( holder ) ;
25- validateAddress ( titleEscrowFactory ) ;
41+ validateAddress ( titleEscrowFactoryAddress ) ;
2642 const wallet = await getWallet ( { key, keyFile, network, encryptedWalletPath } ) ;
2743 const gasPrice = await wallet . provider . getGasPrice ( ) ;
2844
2945 const factory = new TitleEscrowFactory ( wallet ) ;
3046 signale . await ( `Sending transaction to pool` ) ;
31- const transaction = await factory . deploy ( tokenRegistry , beneficiary , holder , titleEscrowFactory , {
47+ const transaction = await factory . deploy ( tokenRegistry , beneficiary , holder , titleEscrowFactoryAddress , {
3248 gasPrice : gasPrice . mul ( gasPriceScale ) ,
3349 } ) ;
3450 trace ( `Tx hash: ${ transaction . deployTransaction . hash } ` ) ;
0 commit comments