diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-06-30 02:52:15 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-06-30 08:25:56 +0800 |
commit | 654b0486027ed42662bbc907a72806046ec7697e (patch) | |
tree | 60a565728c458eca6e424df1c220898c76ef58ec /packages/migrations | |
parent | 3ece72af49fe1042058dadabbc0c4c584b709a17 (diff) | |
download | dexon-sol-tools-654b0486027ed42662bbc907a72806046ec7697e.tar.gz dexon-sol-tools-654b0486027ed42662bbc907a72806046ec7697e.tar.zst dexon-sol-tools-654b0486027ed42662bbc907a72806046ec7697e.zip |
Export LedgerEthereumClient type in subproviders
Diffstat (limited to 'packages/migrations')
-rw-r--r-- | packages/migrations/src/migrate.ts | 27 | ||||
-rw-r--r-- | packages/migrations/src/types.ts | 36 | ||||
-rw-r--r-- | packages/migrations/src/utils/provider_factory.ts | 4 |
3 files changed, 18 insertions, 49 deletions
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<void>; -} - -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<LedgerGetAddressResult>; - signTransaction: (derivationPath: string, rawTxHex: string) => Promise<ECSignatureString>; - signPersonalMessage: (derivationPath: string, messageHex: string) => Promise<ECSignature>; - 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<LedgerEthereumClient> { |