Apply prettier config
This commit is contained in:
@@ -1,23 +1,19 @@
|
||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
||||
import {BigNumber} from 'bignumber.js';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import { BigNumber } from 'bignumber.js';
|
||||
import * as _ from 'lodash';
|
||||
import * as path from 'path';
|
||||
import * as Web3 from 'web3';
|
||||
import * as yargs from 'yargs';
|
||||
|
||||
import {commands} from './src/commands';
|
||||
import {
|
||||
CliOptions,
|
||||
CompilerOptions,
|
||||
DeployerOptions,
|
||||
} from './src/utils/types';
|
||||
import { commands } from './src/commands';
|
||||
import { CliOptions, CompilerOptions, DeployerOptions } from './src/utils/types';
|
||||
|
||||
const DEFAULT_OPTIMIZER_ENABLED = false;
|
||||
const DEFAULT_CONTRACTS_DIR = path.resolve('contracts');
|
||||
const DEFAULT_ARTIFACTS_DIR = `${path.resolve('build')}/artifacts/`;
|
||||
const DEFAULT_NETWORK_ID = 50;
|
||||
const DEFAULT_JSONRPC_PORT = 8545;
|
||||
const DEFAULT_GAS_PRICE = ((10 ** 9) * 2).toString();
|
||||
const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString();
|
||||
|
||||
/**
|
||||
* Compiles all contracts with options passed in through CLI.
|
||||
@@ -108,8 +104,7 @@ function deployCommandBuilder(yargsInstance: any) {
|
||||
description: 'comma separated list of constructor args to deploy contract with',
|
||||
})
|
||||
.demandOption(['contract', 'args'])
|
||||
.help()
|
||||
.argv;
|
||||
.help().argv;
|
||||
}
|
||||
|
||||
(() => {
|
||||
@@ -149,18 +144,13 @@ function deployCommandBuilder(yargsInstance: any) {
|
||||
type: 'string',
|
||||
description: 'account to use for deploying contracts',
|
||||
})
|
||||
.command('compile',
|
||||
'compile contracts',
|
||||
identityCommandBuilder,
|
||||
onCompileCommand)
|
||||
.command('migrate',
|
||||
'compile and deploy contracts using migration scripts',
|
||||
identityCommandBuilder,
|
||||
onMigrateCommand)
|
||||
.command('deploy',
|
||||
'deploy a single contract with provided arguments',
|
||||
deployCommandBuilder,
|
||||
onDeployCommand)
|
||||
.help()
|
||||
.argv;
|
||||
.command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand)
|
||||
.command(
|
||||
'migrate',
|
||||
'compile and deploy contracts using migration scripts',
|
||||
identityCommandBuilder,
|
||||
onMigrateCommand,
|
||||
)
|
||||
.command('deploy', 'deploy a single contract with provided arguments', deployCommandBuilder, onDeployCommand)
|
||||
.help().argv;
|
||||
})();
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import {constants} from './../../src/utils/constants';
|
||||
import {Token} from './../../src/utils/types';
|
||||
import { constants } from './../../src/utils/constants';
|
||||
import { Token } from './../../src/utils/types';
|
||||
|
||||
export const tokenInfo: Token[] = [
|
||||
{
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
||||
import {BigNumber} from 'bignumber.js';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import { BigNumber } from 'bignumber.js';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import {Deployer} from './../src/deployer';
|
||||
import {constants} from './../src/utils/constants';
|
||||
import {tokenInfo} from './config/token_info';
|
||||
import { Deployer } from './../src/deployer';
|
||||
import { constants } from './../src/utils/constants';
|
||||
import { tokenInfo } from './config/token_info';
|
||||
|
||||
export const migrator = {
|
||||
/**
|
||||
@@ -29,12 +29,13 @@ export const migrator = {
|
||||
const multiSigArgs = [owners, confirmationsRequired, secondsRequired, tokenTransferProxy.address];
|
||||
const exchange = await deployer.deployAndSaveAsync('Exchange', exchangeArgs);
|
||||
const multiSig = await deployer.deployAndSaveAsync(
|
||||
'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', multiSigArgs,
|
||||
'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress',
|
||||
multiSigArgs,
|
||||
);
|
||||
|
||||
const owner = accounts[0];
|
||||
await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {from: owner});
|
||||
await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, {from: owner});
|
||||
await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
|
||||
await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: owner });
|
||||
const addTokenGasEstimate = await tokenReg.addToken.estimateGasAsync(
|
||||
zrxToken.address,
|
||||
tokenInfo[0].name,
|
||||
@@ -42,7 +43,7 @@ export const migrator = {
|
||||
tokenInfo[0].decimals,
|
||||
tokenInfo[0].ipfsHash,
|
||||
tokenInfo[0].swarmHash,
|
||||
{from: owner},
|
||||
{ from: owner },
|
||||
);
|
||||
await tokenReg.addToken.sendTransactionAsync(
|
||||
zrxToken.address,
|
||||
@@ -70,12 +71,7 @@ export const migrator = {
|
||||
);
|
||||
for (const token of tokenInfo) {
|
||||
const totalSupply = new BigNumber(0);
|
||||
const args = [
|
||||
token.name,
|
||||
token.symbol,
|
||||
token.decimals,
|
||||
totalSupply,
|
||||
];
|
||||
const args = [token.name, token.symbol, token.decimals, totalSupply];
|
||||
const dummyToken = await deployer.deployAsync('DummyToken', args);
|
||||
await tokenReg.addToken.sendTransactionAsync(
|
||||
dummyToken.address,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import {migrator} from './../migrations/migrate';
|
||||
import {Compiler} from './compiler';
|
||||
import {Deployer} from './deployer';
|
||||
import {CompilerOptions, DeployerOptions} from './utils/types';
|
||||
import { migrator } from './../migrations/migrate';
|
||||
import { Compiler } from './compiler';
|
||||
import { Deployer } from './deployer';
|
||||
import { CompilerOptions, DeployerOptions } from './utils/types';
|
||||
|
||||
export const commands = {
|
||||
async compileAsync(opts: CompilerOptions): Promise<void> {
|
||||
|
@@ -4,8 +4,8 @@ import * as path from 'path';
|
||||
import solc = require('solc');
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import {binPaths} from './../solc/bin_paths';
|
||||
import {fsWrapper} from './utils/fs_wrapper';
|
||||
import { binPaths } from './../solc/bin_paths';
|
||||
import { fsWrapper } from './utils/fs_wrapper';
|
||||
import {
|
||||
CompilerOptions,
|
||||
ContractArtifact,
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
ContractSources,
|
||||
ImportContents,
|
||||
} from './utils/types';
|
||||
import {utils} from './utils/utils';
|
||||
import { utils } from './utils/utils';
|
||||
|
||||
const SOLIDITY_FILE_EXTENSION = '.sol';
|
||||
|
||||
@@ -150,9 +150,10 @@ export class Compiler {
|
||||
currentArtifact = JSON.parse(currentArtifactString);
|
||||
oldNetworks = currentArtifact.networks;
|
||||
const oldNetwork: ContractData = oldNetworks[this._networkId];
|
||||
shouldCompile = _.isUndefined(oldNetwork) ||
|
||||
oldNetwork.keccak256 !== sourceHash ||
|
||||
oldNetwork.optimizer_enabled !== this._optimizerEnabled;
|
||||
shouldCompile =
|
||||
_.isUndefined(oldNetwork) ||
|
||||
oldNetwork.keccak256 !== sourceHash ||
|
||||
oldNetwork.optimizer_enabled !== this._optimizerEnabled;
|
||||
} catch (err) {
|
||||
shouldCompile = true;
|
||||
}
|
||||
@@ -174,9 +175,11 @@ export class Compiler {
|
||||
const sourcesToCompile = {
|
||||
sources: input,
|
||||
};
|
||||
const compiled = solcInstance.compile(sourcesToCompile,
|
||||
this._optimizerEnabled,
|
||||
this._findImportsIfSourcesExist.bind(this));
|
||||
const compiled = solcInstance.compile(
|
||||
sourcesToCompile,
|
||||
this._optimizerEnabled,
|
||||
this._findImportsIfSourcesExist.bind(this),
|
||||
);
|
||||
|
||||
if (!_.isUndefined(compiled.errors)) {
|
||||
_.each(compiled.errors, errMsg => {
|
||||
|
@@ -1,17 +1,13 @@
|
||||
import {TxData} from '@0xproject/types';
|
||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
||||
import { TxData } from '@0xproject/types';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import {Contract} from './utils/contract';
|
||||
import {encoder} from './utils/encoder';
|
||||
import {fsWrapper} from './utils/fs_wrapper';
|
||||
import {
|
||||
ContractArtifact,
|
||||
ContractData,
|
||||
DeployerOptions,
|
||||
} from './utils/types';
|
||||
import {utils} from './utils/utils';
|
||||
import { Contract } from './utils/contract';
|
||||
import { encoder } from './utils/encoder';
|
||||
import { fsWrapper } from './utils/fs_wrapper';
|
||||
import { ContractArtifact, ContractData, DeployerOptions } from './utils/types';
|
||||
import { utils } from './utils/utils';
|
||||
|
||||
// Gas added to gas estimate to make sure there is sufficient gas for deployment.
|
||||
const EXTRA_GAS = 200000;
|
||||
@@ -99,8 +95,11 @@ export class Deployer {
|
||||
* @param contractAddress Contract address to save to artifact.
|
||||
* @param args Contract constructor arguments that will be encoded and saved to artifact.
|
||||
*/
|
||||
private async _saveContractDataToArtifactAsync(contractName: string,
|
||||
contractAddress: string, args: any[]): Promise<void> {
|
||||
private async _saveContractDataToArtifactAsync(
|
||||
contractName: string,
|
||||
contractAddress: string,
|
||||
args: any[],
|
||||
): Promise<void> {
|
||||
const contractArtifact: ContractArtifact = this._loadContractArtifactIfExists(contractName);
|
||||
const contractData: ContractData = this._getContractDataFromArtifactIfExists(contractArtifact);
|
||||
const abi = contractData.abi;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import {schemas, SchemaValidator} from '@0xproject/json-schemas';
|
||||
import {promisify} from '@0xproject/utils';
|
||||
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
|
||||
import { promisify } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import {AbiType} from './types';
|
||||
import { AbiType } from './types';
|
||||
|
||||
export class Contract implements Web3.ContractInstance {
|
||||
public address: string;
|
||||
|
@@ -2,7 +2,7 @@ import * as _ from 'lodash';
|
||||
import * as Web3 from 'web3';
|
||||
import * as web3Abi from 'web3-eth-abi';
|
||||
|
||||
import {AbiType} from './types';
|
||||
import { AbiType } from './types';
|
||||
|
||||
export const encoder = {
|
||||
encodeConstructorArgsFromAbi(args: any[], abi: Web3.ContractAbi): string {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import {promisify} from '@0xproject/utils';
|
||||
import { promisify } from '@0xproject/utils';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export const fsWrapper = {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import {TxData} from '@0xproject/types';
|
||||
import { TxData } from '@0xproject/types';
|
||||
import * as Web3 from 'web3';
|
||||
import * as yargs from 'yargs';
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
import * as chai from 'chai';
|
||||
import 'mocha';
|
||||
|
||||
import {Compiler} from './../src/compiler';
|
||||
import {Deployer} from './../src/deployer';
|
||||
import {fsWrapper} from './../src/utils/fs_wrapper';
|
||||
import {CompilerOptions, ContractArtifact, ContractData, DoneCallback} from './../src/utils/types';
|
||||
import {constructor_args, exchange_binary} from './fixtures/exchange_bin';
|
||||
import {constants} from './util/constants';
|
||||
import { Compiler } from './../src/compiler';
|
||||
import { Deployer } from './../src/deployer';
|
||||
import { fsWrapper } from './../src/utils/fs_wrapper';
|
||||
import { CompilerOptions, ContractArtifact, ContractData, DoneCallback } from './../src/utils/types';
|
||||
import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
|
||||
import { constants } from './util/constants';
|
||||
|
||||
const expect = chai.expect;
|
||||
const artifactsDir = `${__dirname}/fixtures/artifacts`;
|
||||
|
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
import {BigNumber} from 'bignumber.js';
|
||||
import { BigNumber } from 'bignumber.js';
|
||||
|
||||
export const constants = {
|
||||
networkId: 0,
|
||||
|
Reference in New Issue
Block a user