Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Commit e7ba74e

Browse files
authored
feat: default title escrow creator contracts (#75)
Co-authored-by: Raymond Yeh <ray@geek.sg>
1 parent 99d92ff commit e7ba74e

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/commands/deploy/deploy.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export interface DeployTitleEscrowCommand extends NetworkAndKeyOption, GasOption
1515
tokenRegistry: string;
1616
beneficiary: string;
1717
holder: string;
18-
titleEscrowFactory: string;
18+
titleEscrowFactory?: string;
1919
}

src/commands/deploy/title-escrow.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const builder = (yargs: Argv): Argv =>
3838
alias: "c",
3939
description: "Address of title escrow creator/factory",
4040
normalize: true,
41-
required: true,
4241
})
4342
)
4443
);

src/implementations/deploy/title-escrow/title-escrow.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ import { validateAddress } from "../../utils/validation";
88

99
const { 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+
1126
export 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

Comments
 (0)