Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Ask for collectible address #2

Merged
merged 1 commit into from
May 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface BuildOptions {
port: number;
makerFee: number;
takerFee: number;
collectibleAddress: string;
}

function getNetworkId(network: Network): number {
Expand Down Expand Up @@ -49,6 +50,7 @@ services:${isGanache ? ganacheService : ''}
REACT_APP_DEFAULT_BASE_PATH: '${basePath}'
REACT_APP_THEME_NAME: '${theme}'
REACT_APP_COLLECTIBLES_SOURCE: '${collectiblesSource}'
REACT_APP_COLLECTIBLE_ADDRESS: '${options.collectibleAddress}'
REACT_APP_RELAYER_URL: 'http://localhost:3000/v2'
command: yarn build
volumes:
Expand Down
17 changes: 16 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { buildDockerComposeYml, BuildOptions, Network } from './build';

const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';

const mockERC721Address = '0x07f96aa816c1f244cbc6ef114bb2b023ba54a2eb';

function getRpcUrl(network: Network): string {
switch (network) {
case 'mainnet':
Expand All @@ -22,6 +24,8 @@ function getRpcUrl(network: Network): string {
}
}

const isAddress = (s: string) => /(0x)?[0-9a-fA-F]{40}/.test(s);

async function main() {
const networkChoices: Array<{ name: string; value: Network }> = [
{
Expand Down Expand Up @@ -71,13 +75,23 @@ async function main() {
},
when: (answers: any) => answers.network !== 'ganache',
},
{
type: 'input',
name: 'collectibleAddress',
message: 'Enter the address of the collectible:',
default: ZERO_ADDRESS,
validate: (answer: string) => {
return isAddress(answer) ? true : 'Please enter a valid address';
},
when: (answers: any) => answers.tokenType === 'ERC721' && answers.network !== 'ganache',
},
{
type: 'input',
name: 'feeRecipient',
message: 'Enter the fee recipient:',
default: ZERO_ADDRESS,
validate: (answer: string) => {
return /(0x)?[0-9a-fA-F]{40}/.test(answer) ? true : 'Please enter a valid address';
return isAddress(answer) ? true : 'Please enter a valid address';
},
},
{
Expand Down Expand Up @@ -131,6 +145,7 @@ async function main() {
port: answers.port,
makerFee: answers.makerFee || 0,
takerFee: answers.takerFee || 0,
collectibleAddress: answers.collectibleAddress || mockERC721Address,
};

const dockerComposeYml = buildDockerComposeYml(options);
Expand Down