From 3b5e3b30c074be94c8bdc6dc21c66448f4a2f71e Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 18 Apr 2019 12:01:17 +0200 Subject: [PATCH] another web3 fix, add @types-web3, config options destructuring --- server/package-lock.json | 25 ++++++++++++++++++++ server/package.json | 1 + server/src/utils.ts | 49 +++++++++++++++++++++++----------------- 3 files changed, 54 insertions(+), 21 deletions(-) diff --git a/server/package-lock.json b/server/package-lock.json index 5eb6638..9d0a527 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -419,6 +419,15 @@ "@babel/types": "^7.3.0" } }, + "@types/bn.js": { + "version": "4.11.5", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.5.tgz", + "integrity": "sha512-AEAZcIZga0JgVMHNtl1CprA/hXX7/wPt79AgR4XqaDt7jyj3QWYw6LPoOiznPtugDmlubUnAahMs2PFxGcQrng==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/body-parser": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz", @@ -586,6 +595,22 @@ "integrity": "sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==", "dev": true }, + "@types/underscore": { + "version": "1.8.14", + "resolved": "https://registry.npmjs.org/@types/underscore/-/underscore-1.8.14.tgz", + "integrity": "sha512-xbzi6UaATVKupInG3D65/EPQ3qkJCvG2ZAzmlIYt6x93ACOEX2Y0fHW4/e8TF3G7q5KB2l7wTZgzfNjyYDMuZw==", + "dev": true + }, + "@types/web3": { + "version": "1.0.18", + "resolved": "https://registry.npmjs.org/@types/web3/-/web3-1.0.18.tgz", + "integrity": "sha512-uXQL0LDszt2f476LEmYM6AvSv9F4vU4hWQvlUhwfLHNlIB6OyBXoYsCzWAIhhnc5U0HA7ZBcPybxRJ/yfA6THg==", + "dev": true, + "requires": { + "@types/bn.js": "*", + "@types/underscore": "*" + } + }, "@types/yargs": { "version": "12.0.12", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-12.0.12.tgz", diff --git a/server/package.json b/server/package.json index c9233b8..15b26c2 100644 --- a/server/package.json +++ b/server/package.json @@ -36,6 +36,7 @@ "@types/morgan": "^1.7.35", "@types/node": "^11.13.4", "@types/request": "^2.48.1", + "@types/web3": "^1.0.18", "jasmine": "^3.4.0", "jest": "^24.7.1", "nodemon": "^1.18.11", diff --git a/server/src/utils.ts b/server/src/utils.ts index 248c067..d018a50 100644 --- a/server/src/utils.ts +++ b/server/src/utils.ts @@ -2,38 +2,45 @@ import Web3 from 'web3' import { Ocean } from '@oceanprotocol/squid' import config from './config/config' +const { + nodeScheme, + nodeHost, + nodePort, + aquariusScheme, + aquariusHost, + aquariusPort, + brizoScheme, + brizoHost, + brizoPort, + parityScheme, + parityHost, + parityPort, + secretStoreScheme, + secretStoreHost, + secretStorePort, + brizoAddress, + verbose +} = config.app + export function getProviders() { return new Promise(async (resolve, reject) => { - const nodeUri = `${config.app.nodeScheme}://${config.app.nodeHost}:${ - config.app.nodePort - }` - const aquariusUri = `${config.app.aquariusScheme}://${ - config.app.aquariusHost - }:${config.app.aquariusPort}` - const brizoUri = `${config.app.brizoScheme}://${config.app.brizoHost}:${ - config.app.brizoPort - }` - const parityUri = `${config.app.parityScheme}://${ - config.app.parityHost - }:${config.app.parityPort}` - const secretStoreUri = `${config.app.secretStoreScheme}://${ - config.app.secretStoreHost - }:${config.app.secretStorePort}` + const nodeUri = `${nodeScheme}://${nodeHost}:${nodePort}` + const aquariusUri = `${aquariusScheme}://${aquariusHost}:${aquariusPort}` + const brizoUri = `${brizoScheme}://${brizoHost}:${brizoPort}` + const parityUri = `${parityScheme}://${parityHost}:${parityPort}` + const secretStoreUri = `${secretStoreScheme}://${secretStoreHost}:${secretStorePort}` const web3 = new Web3(nodeUri) const oceanConfig = { web3Provider: web3, nodeUri, aquariusUri, brizoUri, - brizoAddress: config.app.brizoAddress, + brizoAddress, parityUri, secretStoreUri, - verbose: config.app.verbose + verbose } const ocean = await Ocean.getInstance(oceanConfig) - resolve({ - ocean, - web3 - }) + resolve({ ocean, web3 }) }) }