Export LedgerEthereumClient type in subproviders
This commit is contained in:
@@ -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}`);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -20,6 +20,7 @@ export {
|
||||
ErrorCallback,
|
||||
NextCallback,
|
||||
LedgerCommunicationClient,
|
||||
LedgerEthereumClient,
|
||||
NonceSubproviderErrors,
|
||||
LedgerSubproviderConfigs,
|
||||
} from './types';
|
||||
|
||||
Reference in New Issue
Block a user