aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHsuan Lee <boczeratul@gmail.com>2018-10-23 20:58:14 +0800
committerHsuan Lee <hsuan@cobinhood.com>2018-12-10 18:21:11 +0800
commita8e68e5d1be7ccece7e5451c89c170b4f2efccee (patch)
tree4a09e908b7e6988e4eceb6f3a6827412e66020c4
parented2a63a4a3cc4ece4e2535a3d2e8cf6d00b24039 (diff)
downloaddexon-wallet-a8e68e5d1be7ccece7e5451c89c170b4f2efccee.tar.gz
dexon-wallet-a8e68e5d1be7ccece7e5451c89c170b4f2efccee.tar.zst
dexon-wallet-a8e68e5d1be7ccece7e5451c89c170b4f2efccee.zip
Add testnet config
-rw-r--r--app/_locales/en/messages.json14
-rw-r--r--app/_locales/fr/messages.json2
-rw-r--r--app/_locales/ht/messages.json2
-rw-r--r--app/_locales/it/messages.json2
-rw-r--r--app/_locales/ja/messages.json2
-rw-r--r--app/_locales/ko/messages.json2
-rw-r--r--app/_locales/pl/messages.json2
-rw-r--r--app/scripts/controllers/detect-tokens.js4
-rw-r--r--app/scripts/controllers/network/enums.js5
-rw-r--r--app/scripts/controllers/network/network.js20
-rw-r--r--ui/app/components/dropdowns/account-details-dropdown.js8
-rw-r--r--ui/app/components/dropdowns/network-dropdown.js46
-rw-r--r--ui/app/components/dropdowns/token-menu-dropdown.js2
-rw-r--r--ui/app/components/transaction-list-item-details/transaction-list-item-details.component.js2
-rw-r--r--ui/app/css/itcss/components/network.scss6
-rw-r--r--ui/app/reducers/metamask.js4
-rw-r--r--ui/lib/account-link.js4
-rw-r--r--ui/lib/etherscan-prefix-for-network.js7
18 files changed, 72 insertions, 62 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()
diff --git a/ui/app/components/dropdowns/account-details-dropdown.js b/ui/app/components/dropdowns/account-details-dropdown.js
index 7476cfdd..c4eed8a2 100644
--- a/ui/app/components/dropdowns/account-details-dropdown.js
+++ b/ui/app/components/dropdowns/account-details-dropdown.js
@@ -27,7 +27,7 @@ function mapDispatchToProps (dispatch) {
showAccountDetailModal: () => {
dispatch(actions.showModal({ name: 'ACCOUNT_DETAILS' }))
},
- viewOnEtherscan: (address, network) => {
+ viewOnDexScan: (address, network) => {
global.platform.openWindow({ url: genAccountLink(address, network) })
},
showRemoveAccountConfirmationModal: (identity) => {
@@ -54,7 +54,7 @@ AccountDetailsDropdown.prototype.render = function () {
network,
keyrings,
showAccountDetailModal,
- viewOnEtherscan,
+ viewOnDexScan,
showRemoveAccountConfirmationModal } = this.props
const address = selectedIdentity.address
@@ -90,10 +90,10 @@ AccountDetailsDropdown.prototype.render = function () {
h(Item, {
onClick: (e) => {
e.stopPropagation()
- viewOnEtherscan(address, network)
+ viewOnDexScan(address, network)
this.props.onClose()
},
- text: this.context.t('viewOnEtherscan'),
+ text: this.context.t('viewOnDexScan'),
icon: h(`img`, { src: 'images/open-etherscan.svg', style: { height: '15px' } }),
}),
isRemovable ? h(Item, {
diff --git a/ui/app/components/dropdowns/network-dropdown.js b/ui/app/components/dropdowns/network-dropdown.js
index 28e3a5cf..61ea59fa 100644
--- a/ui/app/components/dropdowns/network-dropdown.js
+++ b/ui/app/components/dropdowns/network-dropdown.js
@@ -115,27 +115,27 @@ NetworkDropdown.prototype.render = function () {
),
]),
- h(
- DropdownMenuItem,
- {
- key: 'main',
- closeMenu: () => this.props.hideNetworkDropdown(),
- onClick: () => props.setProviderType('mainnet'),
- style: { ...dropdownMenuItemStyle, borderColor: '#038789' },
- },
- [
- providerType === 'mainnet' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
- h(NetworkDropdownIcon, {
- backgroundColor: '#954A97', // $dexon-purple
- isSelected: providerType === 'mainnet',
- }),
- h('span.network-name-item', {
- style: {
- color: providerType === 'mainnet' ? '#ffffff' : '#9b9b9b',
- },
- }, this.context.t('mainnet')),
- ]
- ),
+ // h(
+ // DropdownMenuItem,
+ // {
+ // key: 'main',
+ // closeMenu: () => this.props.hideNetworkDropdown(),
+ // onClick: () => props.setProviderType('mainnet'),
+ // style: { ...dropdownMenuItemStyle, borderColor: '#038789' },
+ // },
+ // [
+ // providerType === 'mainnet' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
+ // h(NetworkDropdownIcon, {
+ // backgroundColor: '#aeaeae', // $silver-chalice
+ // isSelected: providerType === 'mainnet',
+ // }),
+ // h('span.network-name-item', {
+ // style: {
+ // color: providerType === 'mainnet' ? '#ffffff' : '#9b9b9b',
+ // },
+ // }, this.context.t('mainnet')),
+ // ]
+ // ),
h(
DropdownMenuItem,
@@ -146,9 +146,9 @@ NetworkDropdown.prototype.render = function () {
style: dropdownMenuItemStyle,
},
[
- providerType === 'ropsten' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
+ providerType === 'testnet' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
h(NetworkDropdownIcon, {
- backgroundColor: '#aeaeae', // $silver-chalice
+ backgroundColor: '#954A97', // $dexon-purple
isSelected: providerType === 'testnet',
}),
h('span.network-name-item', {
diff --git a/ui/app/components/dropdowns/token-menu-dropdown.js b/ui/app/components/dropdowns/token-menu-dropdown.js
index 8a072b1b..e1db4776 100644
--- a/ui/app/components/dropdowns/token-menu-dropdown.js
+++ b/ui/app/components/dropdowns/token-menu-dropdown.js
@@ -62,7 +62,7 @@ TokenMenuDropdown.prototype.render = function () {
global.platform.openWindow({ url })
this.props.onClose()
},
- text: this.context.t('viewOnEtherscan'),
+ text: this.context.t('viewOnDexScan'),
}),
])
}
diff --git a/ui/app/components/transaction-list-item-details/transaction-list-item-details.component.js b/ui/app/components/transaction-list-item-details/transaction-list-item-details.component.js
index cc2c4529..c658ecf9 100644
--- a/ui/app/components/transaction-list-item-details/transaction-list-item-details.component.js
+++ b/ui/app/components/transaction-list-item-details/transaction-list-item-details.component.js
@@ -78,7 +78,7 @@ export default class TransactionListItemDetails extends PureComponent {
</Button>
)
}
- <Tooltip title={t('viewOnEtherscan')}>
+ <Tooltip title={t('viewOnDexScan')}>
<Button
type="raised"
onClick={this.handleEtherscanClick}
diff --git a/ui/app/css/itcss/components/network.scss b/ui/app/css/itcss/components/network.scss
index 8ae2fba9..fe54295c 100644
--- a/ui/app/css/itcss/components/network.scss
+++ b/ui/app/css/itcss/components/network.scss
@@ -18,8 +18,12 @@
background-color: rgba(149, 74, 151, 0.7) !important;
}
+ // &.dexon-test-network .menu-icon-circle div {
+ // background-color: rgba(174, 174, 174, 0.7) !important;
+ // }
+
&.dexon-test-network .menu-icon-circle div {
- background-color: rgba(174, 174, 174, 0.7) !important;
+ background-color: rgba(149, 74, 151, 0.7) !important;
}
}
diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js
index 3dc60e64..06b3afdb 100644
--- a/ui/app/reducers/metamask.js
+++ b/ui/app/reducers/metamask.js
@@ -3,7 +3,7 @@ const actions = require('../actions')
const MetamascaraPlatform = require('../../../app/scripts/platforms/window')
const { getEnvironmentType } = require('../../../app/scripts/lib/util')
const { ENVIRONMENT_TYPE_POPUP } = require('../../../app/scripts/lib/enums')
-const { MAINNET } = require('../../../app/scripts/controllers/network/enums')
+const { TESTNET } = require('../../../app/scripts/controllers/network/enums')
module.exports = reduceMetamask
@@ -47,7 +47,7 @@ function reduceMetamask (state, action) {
coinOptions: {},
useBlockie: false,
featureFlags: {},
- networkEndpointType: MAINNET,
+ networkEndpointType: TESTNET,
isRevealingSeedWords: false,
welcomeScreenSeen: false,
currentLocale: '',
diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js
index 93697b13..82d3010a 100644
--- a/ui/lib/account-link.js
+++ b/ui/lib/account-link.js
@@ -3,10 +3,10 @@ module.exports = function (address, network) {
let link
switch (net) {
case 1: // main net
- link = `https://etherscan.io/address/${address}`
+ link = `https://dexscan.org/address/${address}`
break
case 2: // test net
- link = `https://morden.etherscan.io/address/${address}`
+ link = `https://testnet.dexscan.org/address/${address}`
break
default:
link = ''
diff --git a/ui/lib/etherscan-prefix-for-network.js b/ui/lib/etherscan-prefix-for-network.js
index 2c1904f1..cfe3b0c5 100644
--- a/ui/lib/etherscan-prefix-for-network.js
+++ b/ui/lib/etherscan-prefix-for-network.js
@@ -5,11 +5,14 @@ module.exports = function (network) {
case 1: // main net
prefix = ''
break
+ case 2: // test net
+ prefix = 'testnet.'
+ break
case 3: // ropsten test net
prefix = 'ropsten.'
break
- case 4: // rinkeby test net
- prefix = 'rinkeby.'
+ case 4: // test net
+ prefix = 'testnet.'
break
case 42: // kovan test net
prefix = 'kovan.'