From 8e17b4e47fb73df0dba3983dbbea0a86b2b937c7 Mon Sep 17 00:00:00 2001 From: Eduardo Pereira Date: Thu, 17 Oct 2019 11:41:38 -0300 Subject: [PATCH] Added client version to loom provider --- src/loom-provider.ts | 5 +++++ src/tests/e2e/loom-provider-tests.ts | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/loom-provider.ts b/src/loom-provider.ts index f70fb255..17c8ad89 100644 --- a/src/loom-provider.ts +++ b/src/loom-provider.ts @@ -263,6 +263,7 @@ export class LoomProvider { this._ethRPCMethods.set('eth_sendTransaction', this._ethSendTransaction) this._ethRPCMethods.set('eth_sign', this._ethSign) this._ethRPCMethods.set('net_version', this._netVersion) + this._ethRPCMethods.set('web3_clientVersion', this._clientVersion) } /** @@ -709,6 +710,10 @@ export class LoomProvider { return this._netVersionFromChainId } + private _clientVersion() { + return `Loom/loom-js/v${require('../package.json').version}` + } + // PRIVATE FUNCTIONS IMPLEMENTATIONS private async _deployAsync(payload: { from: string; data: string }): Promise { diff --git a/src/tests/e2e/loom-provider-tests.ts b/src/tests/e2e/loom-provider-tests.ts index 4ce1a3bf..657a1399 100644 --- a/src/tests/e2e/loom-provider-tests.ts +++ b/src/tests/e2e/loom-provider-tests.ts @@ -569,6 +569,28 @@ test('LoomProvider method eth_uninstallFilter', async t => { t.end() }) +test('LoomProvider client version', async t => { + const { loomProvider, client } = await newContractAndClient() + + try { + const id = 1 + const clientVersion = await loomProvider.sendAsync({ + id, + method: 'web3_clientVersion' + }) + + t.assert(/Loom\/loom-js\/v/.test(clientVersion.result), 'Client version should be ok') + } catch (err) { + t.error(err, 'Error found') + } + + if (client) { + client.disconnect() + } + + t.end() +}) + test('LoomProvider adding custom method', async t => { const { loomProvider, from, client } = await newContractAndClient()