Skip to content
This repository was archived by the owner on Dec 10, 2020. It is now read-only.

Commit d74c2ac

Browse files
PhilippLghholgerd77
authored andcommitted
refactor: move to utils getClientVersion
1 parent d1906bd commit d74c2ac

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/rpc/modules/web3.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { middleware, validators } from '../validation'
22
import { addHexPrefix, keccak, toBuffer } from 'ethereumjs-util'
33
import { platform } from 'os'
4+
import { getClientVersion } from '../../util'
45

56
/**
67
* web3_* RPC module
@@ -29,9 +30,7 @@ export class Web3 {
2930
* client version as the second argument
3031
*/
3132
clientVersion(_params = [], cb: (err: null, version: string) => void) {
32-
const packageVersion = require('../../../package.json').version
33-
const { version } = process
34-
const ethJsVersion = `EthereumJS/${packageVersion}/${platform()}/node${version.substring(1)}`
33+
const ethJsVersion = getClientVersion()
3534
cb(null, ethJsVersion)
3635
}
3736

lib/util/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
/**
22
* @module util
33
*/
4+
import { platform } from 'os'
5+
import { version as packageVersion } from '../../package.json'
46

57
export * from './parse'
68

79
export function short(buffer: Buffer): string {
810
return buffer.toString('hex').slice(0, 8) + '...'
911
}
12+
13+
export function getClientVersion() {
14+
const { version } = process
15+
return `EthereumJS/${packageVersion}/${platform()}/node${version.substring(1)}`
16+
}

0 commit comments

Comments
 (0)