diff options
author | Hsuan Lee <boczeratul@gmail.com> | 2018-10-23 20:58:14 +0800 |
---|---|---|
committer | Hsuan Lee <hsuan@cobinhood.com> | 2018-12-10 18:21:11 +0800 |
commit | a8e68e5d1be7ccece7e5451c89c170b4f2efccee (patch) | |
tree | 4a09e908b7e6988e4eceb6f3a6827412e66020c4 /app | |
parent | ed2a63a4a3cc4ece4e2535a3d2e8cf6d00b24039 (diff) | |
download | dexon-wallet-a8e68e5d1be7ccece7e5451c89c170b4f2efccee.tar.gz dexon-wallet-a8e68e5d1be7ccece7e5451c89c170b4f2efccee.tar.zst dexon-wallet-a8e68e5d1be7ccece7e5451c89c170b4f2efccee.zip |
Add testnet config
Diffstat (limited to 'app')
-rw-r--r-- | app/_locales/en/messages.json | 14 | ||||
-rw-r--r-- | app/_locales/fr/messages.json | 2 | ||||
-rw-r--r-- | app/_locales/ht/messages.json | 2 | ||||
-rw-r--r-- | app/_locales/it/messages.json | 2 | ||||
-rw-r--r-- | app/_locales/ja/messages.json | 2 | ||||
-rw-r--r-- | app/_locales/ko/messages.json | 2 | ||||
-rw-r--r-- | app/_locales/pl/messages.json | 2 | ||||
-rw-r--r-- | app/scripts/controllers/detect-tokens.js | 4 | ||||
-rw-r--r-- | app/scripts/controllers/network/enums.js | 5 | ||||
-rw-r--r-- | app/scripts/controllers/network/network.js | 20 |
10 files changed, 29 insertions, 26 deletions
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 129bec25..be3e014a 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -241,17 +241,11 @@ "connecting": { "message": "Connecting..." }, - "connectingToKovan": { - "message": "Connecting to Kovan Test Network" - }, "connectingToMainnet": { - "message": "Connecting to Main Ethereum Network" - }, - "connectingToRopsten": { - "message": "Connecting to Ropsten Test Network" + "message": "Connecting to Main DEXON Network" }, - "connectingToRinkeby": { - "message": "Connecting to Rinkeby Test Network" + "connectingToTestnet": { + "message": "Connecting to DEXON Test Network" }, "connectingToUnknown": { "message": "Connecting to Unknown Network" @@ -1425,7 +1419,7 @@ "viewAccount": { "message": "View Account" }, - "viewOnEtherscan": { + "viewOnDexScan": { "message": "View on DEXscan" }, "visitWebSite": { diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json index 8ef4953a..fef03766 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -1288,7 +1288,7 @@ "viewAccount": { "message": "Afficher le compte" }, - "viewOnEtherscan": { + "viewOnDexScan": { "message": "Voir sur Etherscan" }, "visitWebSite": { diff --git a/app/_locales/ht/messages.json b/app/_locales/ht/messages.json index 9252b718..78888c63 100644 --- a/app/_locales/ht/messages.json +++ b/app/_locales/ht/messages.json @@ -1243,7 +1243,7 @@ "viewAccount": { "message": "Wè Kont" }, - "viewOnEtherscan": { + "viewOnDexScan": { "message": "Wè sou DEXscan" }, "visitWebSite": { diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index 1998d34d..52ac2413 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -1288,7 +1288,7 @@ "viewAccount": { "message": "Vedi Account" }, - "viewOnEtherscan": { + "viewOnDexScan": { "message": "Vedi su Etherscan" }, "visitWebSite": { diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json index acc1d0f2..b62465a1 100644 --- a/app/_locales/ja/messages.json +++ b/app/_locales/ja/messages.json @@ -784,7 +784,7 @@ "viewAccount": { "message": "アカウントを見る" }, - "viewOnEtherscan": { + "viewOnDexScan": { "message": "Etherscan で見る" }, "warning": { diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index 714e2e6b..c7d7c65e 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -1261,7 +1261,7 @@ "viewAccount": { "message": "계정 보기" }, - "viewOnEtherscan": { + "viewOnDexScan": { "message": "이더스캔에서 보기" }, "visitWebSite": { diff --git a/app/_locales/pl/messages.json b/app/_locales/pl/messages.json index 026f4b3e..f2599913 100644 --- a/app/_locales/pl/messages.json +++ b/app/_locales/pl/messages.json @@ -1189,7 +1189,7 @@ "viewAccount": { "message": "Zobacz konto" }, - "viewOnEtherscan": { + "viewOnDexScan": { "message": "Zobacz na Etherscan" }, "visitWebSite": { diff --git a/app/scripts/controllers/detect-tokens.js b/app/scripts/controllers/detect-tokens.js index fcf07bd5..4aedc198 100644 --- a/app/scripts/controllers/detect-tokens.js +++ b/app/scripts/controllers/detect-tokens.js @@ -1,7 +1,7 @@ const Web3 = require('web3') const contracts = require('eth-contract-metadata') const { warn } = require('loglevel') -const { MAINNET } = require('./network/enums') +const { TESTNET } = require('./network/enums') // By default, poll every 3 minutes const DEFAULT_INTERVAL = 180 * 1000 const ERC20_ABI = [{'constant': true, 'inputs': [{'name': '_owner', 'type': 'address'}], 'name': 'balanceOf', 'outputs': [{'name': 'balance', 'type': 'uint256'}], 'payable': false, 'type': 'function'}] @@ -29,7 +29,7 @@ class DetectTokensController { */ async detectNewTokens () { if (!this.isActive) { return } - if (this._network.store.getState().provider.type !== MAINNET) { return } + if (this._network.store.getState().provider.type !== TESTNET) { return } this.web3.setProvider(this._network._provider) for (const contractAddress in contracts) { if (contracts[contractAddress].erc20 && !(this.tokenAddresses.includes(contractAddress.toLowerCase()))) { diff --git a/app/scripts/controllers/network/enums.js b/app/scripts/controllers/network/enums.js index 586c0119..5ac90085 100644 --- a/app/scripts/controllers/network/enums.js +++ b/app/scripts/controllers/network/enums.js @@ -2,7 +2,7 @@ const ROPSTEN = 'ropsten' const RINKEBY = 'rinkeby' const KOVAN = 'kovan' const MAINNET = 'mainnet' -const TESTNET = 'rinkeby' +const TESTNET = 'testnet' const LOCALHOST = 'localhost' const MAINNET_CODE = 1 @@ -17,6 +17,8 @@ const KOVAN_DISPLAY_NAME = 'Kovan' const MAINNET_DISPLAY_NAME = 'Main DEXON Network' const TESTNET_DISPLAY_NAME = 'DEXON Test Network' +const TESTNET_RPC_URL = 'http://testnet.dexon.org:8545' + module.exports = { ROPSTEN, RINKEBY, @@ -34,4 +36,5 @@ module.exports = { KOVAN_DISPLAY_NAME, MAINNET_DISPLAY_NAME, TESTNET_DISPLAY_NAME, + TESTNET_RPC_URL, } diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index a9defca9..af1a5f94 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -21,8 +21,9 @@ const { MAINNET, TESTNET, LOCALHOST, + TESTNET_RPC_URL, } = require('./enums') -const INFURA_PROVIDER_TYPES = [MAINNET, TESTNET] +const DEXON_PROVIDER_TYPES = [MAINNET, TESTNET] // const env = process.env.METAMASK_ENV // const METAMASK_DEBUG = process.env.METAMASK_DEBUG @@ -30,7 +31,7 @@ const INFURA_PROVIDER_TYPES = [MAINNET, TESTNET] const defaultProviderConfig = { // type: testMode ? TESTNET : MAINNET, - type: MAINNET, + type: TESTNET, } const defaultNetworkConfig = { @@ -135,7 +136,7 @@ module.exports = class NetworkController extends EventEmitter { async setProviderType (type) { assert.notEqual(type, 'rpc', `NetworkController - cannot call "setProviderType" with type 'rpc'. use "setRpcTarget"`) - assert(INFURA_PROVIDER_TYPES.includes(type) || type === LOCALHOST, `NetworkController - Unknown rpc type "${type}"`) + assert(DEXON_PROVIDER_TYPES.includes(type) || type === LOCALHOST, `NetworkController - Unknown rpc type "${type}"`) const providerConfig = { type } this.providerConfig = providerConfig } @@ -165,10 +166,9 @@ module.exports = class NetworkController extends EventEmitter { _configureProvider (opts) { const { type, rpcTarget, chainId, ticker, nickname } = opts - // infura type-based endpoints - const isInfura = INFURA_PROVIDER_TYPES.includes(type) - if (isInfura) { - this._configureInfuraProvider(opts) + // DEXON endpoints + if (DEXON_PROVIDER_TYPES.includes(type)) { + this._configureDexonProvider(opts) // other type-based rpc endpoints } else if (type === LOCALHOST) { this._configureLocalhostProvider() @@ -191,6 +191,12 @@ module.exports = class NetworkController extends EventEmitter { this.networkConfig.putState(settings) } + _configureDexonProvider ({ type }) { + log.info('NetworkController - configureDexonProvider', type) + const networkClient = createJsonRpcClient({ rpcUrl: TESTNET_RPC_URL }) + this._setNetworkClient(networkClient) + } + _configureLocalhostProvider () { log.info('NetworkController - configureLocalhostProvider') const networkClient = createLocalhostClient() |