My app deployed, tested and worked with GSN fine with web3 0.20.x But now cannot find Provider HTTP connection with web3 v1.2.x. Web3 code was refactored and tested fine however with Truffle testing (which has it’s own internal web3). Right now I’m trying to simply connect to my working VPS deployed Ganache dev chain (v.6.9.) on port 9545 (with RelayHub and Relayer deployed and working with contracts deployed and Initialized with OZ Create)
However, any version of web3 1.2.x result in web console errors. My preference would be to use GSNprovider and web3 v1.2.1 (which seems prevalent in most OZ tooling).
Here,below for comment, are patterns I used followed by a snapshot of my package.json. (they are based on OZ Network.js, GSN and Starter kit Vanilla js documentation.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
GSN:
import Web3 from 'web3'
import GSNProvider from '@openzeppelin/gsn-provider'
const web3 = new Web3(new GSNProvider("http://xxx.xxx.xxx.xxx:9545"))
as shown in GSN docs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
WEB3:
import Web3 from 'web3'
const web3 = new Web3('http://xxx.xxx.xxx.xxx:9545')
or
web3 = new Web3(new Web3.providers.HttpProvider('http://xxx.xxx.xxx.xxx:9545'))
I get error console.log(web3.version) :
_stream_writable.js?dc14:57 Uncaught TypeError: Cannot read property 'slice' of undefined
If I omit import Web3 from 'web3'
console.log(web3.version) —>Object { api: "0.20.7", node: Getter...
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
NETWORK JS:
import { fromInjected, fromConnection } from '@openzeppelin/network'
web3Context = await fromConnection('http://xxx.xxx.xxx.xxx:9545', {
gsn: { signKey: ephemeral() }
});
this.accounts = web3Context.accounts
this.networkId = web3Context.networkId //etc..
web console error:
SyntaxError: missing : after property id....["./node_modules/@openzeppelin/network/lib/context/Web3Context.js"]()
line 46: async poll() {
// TODO: Fiture out elegant way retrive property name dynamically const networkIdName = 'networkId'; const accountsName = 'accounts'; const connectedName = 'connected';....
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Node 10.16.3
Package.json deps:
"dependencies": {
"@openzeppelin/gsn-provider": "^0.1.6",
"@openzeppelin/network": "^0.4.2",
"vue": "^2.5.13",
"vue-router": "^3.0.1",
"vuex": "^3.0.1",
"web3": "^1.2.1"
},
"devDependencies": {
"@openzeppelin/cli": "^2.8.2",
"@openzeppelin/gsn-helpers": "^0.2.3",
etc..