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

Commit

Permalink
Merge pull request #27 from 0xProject/v3
Browse files Browse the repository at this point in the history
V3 with Mesh
  • Loading branch information
dekz authored Dec 4, 2019
2 parents be0b895 + d3ec3a2 commit bb1950f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0x/launch-kit-wizard",
"version": "0.0.4",
"version": "1.0.0",
"description": "",
"bin": {
"create-launch-kit-app": "./lib/index.js"
Expand Down
46 changes: 41 additions & 5 deletions src/build.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export type Network = 'mainnet' | 'kovan' | 'ropsten' | 'ganache' | 'custom';
export type Network = 'mainnet' | 'kovan' | 'ropsten' | 'rinkeby' | 'ganache' | 'custom';

export interface BuildOptions {
tokenType: 'ERC20' | 'ERC721';
network: Network;
rpcUrl: string;
relayerUrl: string;
relayerWebsocketUrl: string;
feeRecipient: string;
theme: 'light' | 'dark';
port: number;
Expand All @@ -23,12 +24,27 @@ function getNetworkId(network: Network): number {
return 42;
case 'ropsten':
return 3;
case 'rinkeby':
return 4;
case 'ganache':
case 'custom':
return 50;
}
}

function getChainId(network: Network): number {
switch (network) {
case 'mainnet':
case 'kovan':
case 'rinkeby':
case 'ropsten':
return getNetworkId(network);
case 'ganache':
case 'custom':
return 1337;
}
}

export const buildDockerComposeYml = (options: BuildOptions) => {
const basePath = options.tokenType === 'ERC20' ? '/erc20' : '/erc721';
const theme = options.theme === 'light' ? 'LIGHT_THEME' : 'DARK_THEME';
Expand All @@ -37,6 +53,7 @@ export const buildDockerComposeYml = (options: BuildOptions) => {
const collectiblesSource = isGanache ? 'mocked' : 'opensea';

const networkId = getNetworkId(options.network);
const chainId = getChainId(options.network);

const ganacheService = `
ganache:
Expand All @@ -54,28 +71,47 @@ export const buildDockerComposeYml = (options: BuildOptions) => {
version: "3"
services:${isGanache ? ganacheService : ''}
frontend:
image: 0xorg/launch-kit-frontend
image: 0xorg/launch-kit-frontend:latest
environment:
REACT_APP_RELAYER_URL: '${options.relayerUrl}'
REACT_APP_RELAYER_WS_URL: '${options.relayerWebsocketUrl}'
REACT_APP_DEFAULT_BASE_PATH: '${basePath}'
REACT_APP_THEME_NAME: '${theme}'
REACT_APP_NETWORK_ID: ${networkId}
REACT_APP_CHAIN_ID: ${chainId}
${options.tokenType === 'ERC20' ? '' : collectibleEnv}
command: yarn build
volumes:
- frontend-assets:/app/build
backend:
image: 0xorg/launch-kit-backend
image: 0xorg/launch-kit-backend:latest
environment:
HTTP_PORT: '3000'
RPC_URL: '${options.rpcUrl}'
NETWORK_ID: '${networkId}'
CHAIN_ID: '${chainId}'
WHITELIST_ALL_TOKENS: 'true'
FEE_RECIPIENT: '${options.feeRecipient}'
MAKER_FEE_ZRX_UNIT_AMOUNT: '${options.makerFee}'
TAKER_FEE_ZRX_UNIT_AMOUNT: '${options.takerFee}'
MAKER_FEE_UNIT_AMOUNT: '${options.makerFee}'
TAKER_FEE_UNIT_AMOUNT: '${options.takerFee}'
MESH_ENDPOINT: 'ws://mesh:60557'
ports:
- '3000:3000'
mesh:
image: 0xorg/mesh:0xV3
restart: always
environment:
ETHEREUM_RPC_URL: '${options.rpcUrl}'
ETHEREUM_CHAIN_ID: '${chainId}'
ETHEREUM_NETWORK_ID: '${networkId}'
USE_BOOTSTRAP_LIST: 'true'
VERBOSITY: 3
PRIVATE_KEY_PATH: ''
BLOCK_POLLING_INTERVAL: '5s'
P2P_LISTEN_PORT: '60557'
RPC_ADDR: 0.0.0.0:60557
ports:
- '60557:60557'
nginx:
image: nginx
ports:
Expand Down
19 changes: 18 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ function getRpcUrl(network: Network): string {
return 'https://kovan.infura.io/';
case 'ropsten':
return 'https://ropsten.infura.io/';
case 'rinkeby':
return 'https://rinkeby.infura.io/';
case 'ganache':
return 'http://ganache:8545/';
case 'custom':
Expand All @@ -82,6 +84,10 @@ async function main() {
name: 'Ropsten',
value: 'ropsten',
},
{
name: 'Rinkeby',
value: 'rinkeby',
},
{
name: 'Ganache',
value: 'ganache',
Expand Down Expand Up @@ -130,11 +136,21 @@ async function main() {
name: 'relayerUrl',
message:
'Launch Kit will create a backend Relayer. Enter the public URL for the backend Relayer or leave default:',
default: 'http://localhost:3000/v2',
default: 'http://localhost:3000/v3',
validate: (rpcUrl: string) => {
return /https?:\/\/.+/.test(rpcUrl) ? true : 'Please enter a valid URL';
},
},
{
type: 'input',
name: 'relayerWebsocketUrl',
message:
'Launch Kit will create a backend Relayer. Enter the public URL for the backend websocket or leave default:',
default: 'ws://localhost:3000/',
validate: (rpcUrl: string) => {
return /wss?:\/\/.+/.test(rpcUrl) ? true : 'Please enter a valid Websocket URL';
},
},
{
type: 'input',
name: 'collectibleAddress',
Expand Down Expand Up @@ -227,6 +243,7 @@ async function main() {
network: answers.network,
rpcUrl,
relayerUrl: answers.relayerUrl,
relayerWebsocketUrl: answers.relayerWebsocketUrl,
feeRecipient: answers.feeRecipient || ZERO_ADDRESS,
theme: answers.theme,
port: answers.port,
Expand Down

0 comments on commit bb1950f

Please sign in to comment.