wip
This commit is contained in:
parent
0c2e0ca9b3
commit
cc603fc7e3
|
@ -13,8 +13,10 @@ const devid = 'DEVO7QQqPHCK2h3cGXhh2rY'
|
|||
module.exports = createPocketClient
|
||||
|
||||
function createPocketClient ({ network }) {
|
||||
const networkIDs = getNetworkIds({ network })
|
||||
const pocketMiddleware = createPocketMiddleware(devid, {
|
||||
netID: getNetworkIds({ network }).netId,
|
||||
netID: networkIDs.netId,
|
||||
network: networkIDs.ticker,
|
||||
})
|
||||
const pocketProvider = providerFromMiddleware(pocketMiddleware)
|
||||
const blockTracker = new BlockTracker({ provider: pocketProvider })
|
||||
|
@ -34,33 +36,53 @@ function createPocketClient ({ network }) {
|
|||
function getNetworkIds ({ network }) {
|
||||
let chainId
|
||||
let netId
|
||||
|
||||
let ticker
|
||||
switch (network) {
|
||||
case 'mainnet':
|
||||
netId = '1'
|
||||
chainId = '0x01'
|
||||
ticker = "ETH"
|
||||
break
|
||||
case 'ropsten':
|
||||
netId = '3'
|
||||
chainId = '0x03'
|
||||
ticker = "ETH"
|
||||
break
|
||||
case 'rinkeby':
|
||||
netId = '4'
|
||||
chainId = '0x04'
|
||||
ticker = "ETH"
|
||||
break
|
||||
case 'kovan':
|
||||
netId = '42'
|
||||
chainId = '0x2a'
|
||||
ticker = "ETH"
|
||||
break
|
||||
case 'goerli':
|
||||
netId = '5'
|
||||
chainId = '0x05'
|
||||
ticker = "ETH"
|
||||
break
|
||||
case 'poa':
|
||||
netId = '99'
|
||||
chainId = '0x63'
|
||||
ticker = 'POA'
|
||||
break
|
||||
case 'dai':
|
||||
netId = '100'
|
||||
chainId = '0x64'
|
||||
ticker = 'POA'
|
||||
break
|
||||
case 'sokol':
|
||||
netId= '77'
|
||||
chainId = '0x4D'
|
||||
ticker = 'POA'
|
||||
break
|
||||
default:
|
||||
throw new Error(`createPocketClient - unknown network "${network}"`)
|
||||
}
|
||||
return {
|
||||
chainId, netId,
|
||||
chainId, netId, ticker
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -188,13 +188,25 @@ module.exports = class NetworkController extends EventEmitter {
|
|||
}
|
||||
// other type-based rpc endpoints
|
||||
} else if (type === POA) {
|
||||
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(POA_CODE)[0] })
|
||||
if (this.dProviderStore.getState().dProvider) {
|
||||
this._configurePocketProvider(opts)
|
||||
} else {
|
||||
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(POA_CODE)[0] })
|
||||
}
|
||||
} else if (type === DAI) {
|
||||
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(DAI_CODE)[0] })
|
||||
if (this.dProviderStore.getState().dProvider) {
|
||||
this._configurePocketProvider(opts)
|
||||
} else {
|
||||
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(DAI_CODE)[0] })
|
||||
}
|
||||
} else if (type === POA_SOKOL) {
|
||||
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(POA_SOKOL_CODE)[0] })
|
||||
} else if (type === GOERLI_TESTNET) {
|
||||
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(GOERLI_TESTNET_CODE)[0] })
|
||||
if (this.dProviderStore.getState().dProvider) {
|
||||
this._configurePocketProvider(opts)
|
||||
} else {
|
||||
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(GOERLI_TESTNET_CODE)[0] })
|
||||
}
|
||||
} else if (type === CLASSIC) {
|
||||
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(CLASSIC_CODE)[0] })
|
||||
} else if (type === RSK) {
|
||||
|
@ -221,11 +233,6 @@ module.exports = class NetworkController extends EventEmitter {
|
|||
log.info('NetworkController - configurePocketProvider', type)
|
||||
const networkClient = createPocketClient({ network: type })
|
||||
this._setNetworkClient(networkClient)
|
||||
// setup networkConfig
|
||||
var settings = {
|
||||
ticker: 'ETH',
|
||||
}
|
||||
this.networkConfig.putState(settings)
|
||||
}
|
||||
|
||||
_configureLocalhostProvider () {
|
||||
|
|
Loading…
Reference in New Issue