Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethereum Classic Support #1476

Closed
wants to merge 10 commits into from
2 changes: 2 additions & 0 deletions app/scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const MAINET_RPC_URL = 'https://mainnet.infura.io/metamask'
const ROPSTEN_RPC_URL = 'https://ropsten.infura.io/metamask'
const KOVAN_RPC_URL = 'https://kovan.infura.io/metamask'
const RINKEBY_RPC_URL = 'https://rinkeby.infura.io/metamask'
const CLASSIC_RPC_URL = 'http://metamask.epool.io:9999/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RPC providers should use https for privacy.


global.METAMASK_DEBUG = 'GULP_METAMASK_DEBUG'

Expand All @@ -11,5 +12,6 @@ module.exports = {
ropsten: ROPSTEN_RPC_URL,
kovan: KOVAN_RPC_URL,
rinkeby: RINKEBY_RPC_URL,
classic: CLASSIC_RPC_URL,
},
}
7 changes: 6 additions & 1 deletion app/scripts/controllers/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ module.exports = class TransactionManager extends EventEmitter {

getChainId () {
const networkState = this.networkStore.getState()
const getChainId = parseInt(networkState.network)
var getChainId
if (networkState.chain) {
getChainId = networkState.chain
} else {
getChainId = parseInt(networkState.network)
}
if (Number.isNaN(getChainId)) {
return 0
} else {
Expand Down
4 changes: 4 additions & 0 deletions app/scripts/lib/config-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const MAINNET_RPC = MetamaskConfig.network.mainnet
const ROPSTEN_RPC = MetamaskConfig.network.ropsten
const KOVAN_RPC = MetamaskConfig.network.kovan
const RINKEBY_RPC = MetamaskConfig.network.rinkeby
const CLASSIC_RPC = MetamaskConfig.network.classic

/* The config-manager is a convenience object
* wrapping a pojo-migrator.
Expand Down Expand Up @@ -154,6 +155,9 @@ ConfigManager.prototype.getCurrentRpcAddress = function () {
case 'rinkeby':
return RINKEBY_RPC

case 'classic':
return CLASSIC_RPC

default:
return provider && provider.rpcTarget ? provider.rpcTarget : RINKEBY_RPC
}
Expand Down
8 changes: 7 additions & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,13 @@ module.exports = class MetamaskController extends EventEmitter {
}

setNetworkState (network) {
return this.networkStore.updateState({ network })
var provider = this.configManager.getProvider();
if (!provider || provider.type !== 'classic') {
return this.networkStore.updateState({ network })
} else {
return this.networkStore.updateState({ network: network,
chain: 0x3d });
}
}

isNetworkLoading () {
Expand Down
3 changes: 2 additions & 1 deletion ui/app/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,8 @@ function pairUpdate (coin) {
}

function shapeShiftSubview (network) {
var pair = 'btc_eth'
var pair
network === 'classic' ? pair = 'btc_etc' : pair = 'btc_eth'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of having these ternary classic checks all over the place. ETC isn't the only non-ETH EVM blockchain that wants to be MetaMask compatible (Rootstock is another, for example).

Rather than doing this custom coding by hand, it would be nicer to use a general network config file for interpreting chain data into app behavior.


return (dispatch) => {
dispatch(actions.showSubLoadingIndication())
Expand Down
9 changes: 9 additions & 0 deletions ui/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,15 @@ App.prototype.renderNetworkDropdown = function () {
provider: props.provider,
}),

h(DropMenuItem, {
label: 'Ethereum Classic Network',
closeMenu: () => this.setState({ isNetworkMenuOpen: false}),
action: () => props.dispatch(actions.setProviderType('classic')),
icon: h('.menu-icon.hollow-diamond'),
activeNetworkRender: props.network,
provider: props.provider,
}),

h(DropMenuItem, {
label: 'Localhost 8545',
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
Expand Down
3 changes: 3 additions & 0 deletions ui/app/components/drop-menu-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ DropMenuItem.prototype.activeNetworkRender = function () {
case 'Rinkeby Test Network':
if (providerType === 'rinkeby') return h('.check', '✓')
break
case 'Ethereum Classic Network':
if (providerType === 'classic') return h('.check', '✓')
break
case 'Localhost 8545':
if (activeNetwork === 'http://localhost:8545') return h('.check', '✓')
break
Expand Down
12 changes: 12 additions & 0 deletions ui/app/components/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Network.prototype.render = function () {
} else if (providerName === 'rinkeby') {
hoverText = 'Rinkeby Test Network'
iconName = 'rinkeby-test-network'
} else if (providerName === 'classic') {
hoverText = 'Ethereum Classic Network'
iconName = 'classic-network'
} else {
hoverText = 'Unknown Private Network'
iconName = 'unknown-private-network'
Expand Down Expand Up @@ -94,6 +97,15 @@ Network.prototype.render = function () {
}},
'Rinkeby Test Net'),
])
case 'classic-network':
return h('.network-indicator', [
h('.menu-icon.hollow-diamond'),
h('.network-name', {
style: {
color: '#039396',
}},
'Etherum Classic'),
])
default:
return h('.network-indicator', [
h('i.fa.fa-question-circle.fa-lg', {
Expand Down
4 changes: 4 additions & 0 deletions ui/app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ function currentProviderDisplay (metamaskState) {
value = 'Rinkeby Test Network'
break

case 'classic':
title = 'Current Network'
value = 'Ethereum Classic Network'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing break

default:
title = 'Current RPC'
value = metamaskState.provider.rpcTarget
Expand Down