1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

another web3 fix, add @types-web3, config options destructuring

This commit is contained in:
Matthias Kretschmann 2019-04-18 12:01:17 +02:00
parent fb7914478d
commit 3b5e3b30c0
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 54 additions and 21 deletions

View File

@ -419,6 +419,15 @@
"@babel/types": "^7.3.0" "@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": { "@types/body-parser": {
"version": "1.17.0", "version": "1.17.0",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz", "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==", "integrity": "sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==",
"dev": true "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": { "@types/yargs": {
"version": "12.0.12", "version": "12.0.12",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-12.0.12.tgz", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-12.0.12.tgz",

View File

@ -36,6 +36,7 @@
"@types/morgan": "^1.7.35", "@types/morgan": "^1.7.35",
"@types/node": "^11.13.4", "@types/node": "^11.13.4",
"@types/request": "^2.48.1", "@types/request": "^2.48.1",
"@types/web3": "^1.0.18",
"jasmine": "^3.4.0", "jasmine": "^3.4.0",
"jest": "^24.7.1", "jest": "^24.7.1",
"nodemon": "^1.18.11", "nodemon": "^1.18.11",

View File

@ -2,38 +2,45 @@ import Web3 from 'web3'
import { Ocean } from '@oceanprotocol/squid' import { Ocean } from '@oceanprotocol/squid'
import config from './config/config' 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() { export function getProviders() {
return new Promise<any>(async (resolve, reject) => { return new Promise<any>(async (resolve, reject) => {
const nodeUri = `${config.app.nodeScheme}://${config.app.nodeHost}:${ const nodeUri = `${nodeScheme}://${nodeHost}:${nodePort}`
config.app.nodePort const aquariusUri = `${aquariusScheme}://${aquariusHost}:${aquariusPort}`
}` const brizoUri = `${brizoScheme}://${brizoHost}:${brizoPort}`
const aquariusUri = `${config.app.aquariusScheme}://${ const parityUri = `${parityScheme}://${parityHost}:${parityPort}`
config.app.aquariusHost const secretStoreUri = `${secretStoreScheme}://${secretStoreHost}:${secretStorePort}`
}:${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 web3 = new Web3(nodeUri) const web3 = new Web3(nodeUri)
const oceanConfig = { const oceanConfig = {
web3Provider: web3, web3Provider: web3,
nodeUri, nodeUri,
aquariusUri, aquariusUri,
brizoUri, brizoUri,
brizoAddress: config.app.brizoAddress, brizoAddress,
parityUri, parityUri,
secretStoreUri, secretStoreUri,
verbose: config.app.verbose verbose
} }
const ocean = await Ocean.getInstance(oceanConfig) const ocean = await Ocean.getInstance(oceanConfig)
resolve({ resolve({ ocean, web3 })
ocean,
web3
})
}) })
} }