Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added client version to loom provider #321

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/loom-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand Down Expand Up @@ -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<any> {
Expand Down
22 changes: 22 additions & 0 deletions src/tests/e2e/loom-provider-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down