Update more things to work with both Geth and Ganache
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
			
		||||
import { uniqueVersionIds, Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
@@ -7,11 +7,6 @@ enum NodeType {
 | 
			
		||||
    Ganache = 'GANACHE',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// These are unique identifiers contained in the response of the
 | 
			
		||||
// web3_clientVersion call.
 | 
			
		||||
const GETH_VERSION_ID = 'Geth';
 | 
			
		||||
const GANACHE_VERSION_ID = 'EthereumJS TestRPC';
 | 
			
		||||
 | 
			
		||||
export class BlockchainLifecycle {
 | 
			
		||||
    private _web3Wrapper: Web3Wrapper;
 | 
			
		||||
    private _snapshotIdsStack: number[];
 | 
			
		||||
@@ -54,9 +49,9 @@ export class BlockchainLifecycle {
 | 
			
		||||
    }
 | 
			
		||||
    private async _getNodeTypeAsync(): Promise<NodeType> {
 | 
			
		||||
        const version = await this._web3Wrapper.getNodeVersionAsync();
 | 
			
		||||
        if (_.includes(version, GETH_VERSION_ID)) {
 | 
			
		||||
        if (_.includes(version, uniqueVersionIds.geth)) {
 | 
			
		||||
            return NodeType.Geth;
 | 
			
		||||
        } else if (_.includes(version, GANACHE_VERSION_ID)) {
 | 
			
		||||
        } else if (_.includes(version, uniqueVersionIds.ganache)) {
 | 
			
		||||
            return NodeType.Ganache;
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new Error(`Unknown client version: ${version}`);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user