From 654b0486027ed42662bbc907a72806046ec7697e Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Fri, 29 Jun 2018 11:52:15 -0700 Subject: Export LedgerEthereumClient type in subproviders --- packages/migrations/src/migrate.ts | 27 ++++++++++------- packages/migrations/src/types.ts | 36 ----------------------- packages/migrations/src/utils/provider_factory.ts | 4 +-- 3 files changed, 18 insertions(+), 49 deletions(-) (limited to 'packages/migrations') diff --git a/packages/migrations/src/migrate.ts b/packages/migrations/src/migrate.ts index 4661e1ead..c46d3580a 100644 --- a/packages/migrations/src/migrate.ts +++ b/packages/migrations/src/migrate.ts @@ -9,7 +9,6 @@ import { runV1MigrationsAsync } from './1.0.0/migration'; import { runV2TestnetMigrationsAsync } from './2.0.0-beta-testnet/migration'; import { runV2MigrationsAsync } from './2.0.0/migration'; -import { constants } from './utils/constants'; import { providerFactory } from './utils/provider_factory'; enum ContractVersions { @@ -20,29 +19,37 @@ enum ContractVersions { const args = yargs.argv; (async () => { - const providerConfigs = { shouldUseInProcessGanache: false }; - const provider: Provider = web3Factory.getRpcProvider(providerConfigs); - const txDefaults = { - from: devConstants.TESTRPC_FIRST_ADDRESS, - }; const contractsVersion = args.contractsVersion; const artifactsDir = `artifacts/${contractsVersion}`; + let providerConfigs; + let provider: Provider; + let txDefaults; switch (contractsVersion) { case ContractVersions.V1: + providerConfigs = { shouldUseInProcessGanache: false }; + provider = web3Factory.getRpcProvider(providerConfigs); + txDefaults = { + from: devConstants.TESTRPC_FIRST_ADDRESS, + }; await runV1MigrationsAsync(provider, artifactsDir, txDefaults); break; case ContractVersions.V2: + providerConfigs = { shouldUseInProcessGanache: false }; + provider = web3Factory.getRpcProvider(providerConfigs); + txDefaults = { + from: devConstants.TESTRPC_FIRST_ADDRESS, + }; await runV2MigrationsAsync(provider, artifactsDir, txDefaults); break; case ContractVersions.V2Testnet: - const ledgerProvider = await providerFactory.getLedgerProviderAsync(); - const web3Wrapper = new Web3Wrapper(ledgerProvider); + provider = await providerFactory.getLedgerProviderAsync(); + const web3Wrapper = new Web3Wrapper(provider); const accounts = await web3Wrapper.getAvailableAddressesAsync(); - const testnetTxDefaults = { + txDefaults = { from: accounts[0], gas: devConstants.GAS_LIMIT, }; - await runV2TestnetMigrationsAsync(ledgerProvider, artifactsDir, testnetTxDefaults); + await runV2TestnetMigrationsAsync(provider, artifactsDir, txDefaults); break; default: throw new Error(`Unsupported contract version: ${contractsVersion}`); diff --git a/packages/migrations/src/types.ts b/packages/migrations/src/types.ts index 7347f27fe..65f685797 100644 --- a/packages/migrations/src/types.ts +++ b/packages/migrations/src/types.ts @@ -1,4 +1,3 @@ -import { ECSignature } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; export interface ERC20Token { @@ -28,38 +27,3 @@ export enum ContractName { EtherDelta = 'EtherDelta', Arbitrage = 'Arbitrage', } - -export interface LedgerCommunicationClient { - close: () => Promise; -} - -export interface LedgerGetAddressResult { - address: string; - publicKey: string; - chainCode: string; -} - -export interface ECSignatureString { - v: string; - r: string; - s: string; -} - -export interface LedgerGetAddressResult { - address: string; - publicKey: string; - chainCode: string; -} - -export interface LedgerEthereumClient { - // shouldGetChainCode is defined as `true` instead of `boolean` because other types rely on the assumption - // that we get back the chain code and we don't have dependent types to express it properly - getAddress: ( - derivationPath: string, - askForDeviceConfirmation: boolean, - shouldGetChainCode: true, - ) => Promise; - signTransaction: (derivationPath: string, rawTxHex: string) => Promise; - signPersonalMessage: (derivationPath: string, messageHex: string) => Promise; - transport: LedgerCommunicationClient; -} diff --git a/packages/migrations/src/utils/provider_factory.ts b/packages/migrations/src/utils/provider_factory.ts index 6ae2ad41c..fafc55dda 100644 --- a/packages/migrations/src/utils/provider_factory.ts +++ b/packages/migrations/src/utils/provider_factory.ts @@ -1,12 +1,10 @@ -import { LedgerSubprovider } from '@0xproject/subproviders'; +import { LedgerEthereumClient, LedgerSubprovider } from '@0xproject/subproviders'; import Eth from '@ledgerhq/hw-app-eth'; import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'; import { Provider } from 'ethereum-types'; import ProviderEngine = require('web3-provider-engine'); import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); -import { LedgerEthereumClient } from '../types'; - import { constants } from './constants'; async function ledgerEthereumNodeJsClientFactoryAsync(): Promise { -- cgit v1.2.3