This commit is contained in:
Yohan Graterol 2020-03-29 23:55:46 +02:00 committed by GitHub
commit d1380a8b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 6 deletions

View File

@ -10,8 +10,9 @@ const networkIDs = {
XDAI_CODE: 100,
RSK_CODE: 30,
RSK_TESTNET_CODE: 31,
CALLISTO_NETWORK_CODE: 820
}
module.exports = {
networkIDs
}
}

View File

@ -11,11 +11,13 @@ const {
RSK_CODE,
RSK_TESTNET_CODE,
CLASSIC_CODE,
CALLISTO_NETWORK_CODE
} = networkIDs
const blockScoutLink = (net, prefix) => `https://blockscout.com/${net}/${prefix}`
const etherscanLink = (prefix) => `https://${prefix}.etherscan.io`
const rskTestnetExplorerLink = 'https://explorer.testnet.rsk.co'
const cloExplorerLink = 'https://explorer2.callisto.network'
const explorerLink = (networkCode, net, prefix) => {
switch (networkCode) {
@ -28,6 +30,8 @@ const explorerLink = (networkCode, net, prefix) => {
return blockScoutLink(net, prefix)
case RSK_TESTNET_CODE: // RSK testnet
return rskTestnetExplorerLink
case CALLISTO_NETWORK_CODE:
return cloExplorerLink
case ROPSTEN_CODE: // ropsten testnet
case RINKEBY_CODE: // rinkeby testnet
case KOVAN_CODE: // kovan testnet
@ -42,6 +46,7 @@ const tokenLink = (networkCode, chain, prefix, tokenAddress, holderAddress) => {
const blockscoutLinkStr = `${blockScoutLink(chain, prefix)}/address/${holderAddress}/tokens/${tokenAddress}/token_transfers`
const etherscanLinkStr = `${etherscanLink(prefix)}/token/${tokenAddress}?a=${holderAddress}`
const rskTestnetExplorerLinkStr = `${rskTestnetExplorerLink}/address/${tokenAddress}`
const cloExplorerLinkStr = `${cloExplorerLink}/addr/${tokenAddress}`
switch (networkCode) {
case MAINNET_CODE: // main net
case SOKOL_CODE: // POA Sokol testnet
@ -52,6 +57,8 @@ const tokenLink = (networkCode, chain, prefix, tokenAddress, holderAddress) => {
return blockscoutLinkStr
case RSK_TESTNET_CODE: // RSK testnet
return rskTestnetExplorerLinkStr
case CALLISTO_NETWORK_CODE:
return cloExplorerLinkStr
case ROPSTEN_CODE: // ropsten testnet
case RINKEBY_CODE: // rinkeby testnet
case KOVAN_CODE: // kovan testnet
@ -99,6 +106,9 @@ function getExplorerChain (networkCode) {
case CLASSIC_CODE: // ETC mainnet
chain = 'etc'
break
case CALLISTO_NETWORK_CODE:
chain = 'clo'
break
case RSK_CODE: // RSK mainnet
chain = 'rsk'
break

View File

@ -11,6 +11,7 @@ const {
RSK_CODE,
RSK_TESTNET_CODE,
CLASSIC_CODE,
CALLISTO_NETWORK_CODE
} = networkIDs
function getNetworkDisplayName(network) {
@ -38,6 +39,8 @@ function getNetworkDisplayName(network) {
return 'RSK Testnet'
case CLASSIC_CODE:
return 'Ethereum Classic'
case CALLISTO_NETWORK_CODE:
return 'Callisto Network'
default:
return 'Unknown Private Network'
}
@ -58,6 +61,8 @@ function getNetworkCoinName(network) {
return 'GöETH'
case CLASSIC_CODE:
return 'ETC'
case CALLISTO_NETWORK_CODE:
return 'CLO'
default:
return 'ETH'
}
@ -71,6 +76,7 @@ function isTestnet(network) {
case XDAI_CODE:
case RSK_CODE:
case CLASSIC_CODE:
case CALLISTO_NETWORK_CODE:
return false
default:
return true
@ -81,4 +87,4 @@ module.exports = {
getNetworkDisplayName,
getNetworkCoinName,
isTestnet
}
}

View File

@ -11,6 +11,7 @@ const {
RSK_CODE,
RSK_TESTNET_CODE,
CLASSIC_CODE,
CALLISTO_NETWORK_CODE
} = networkIDs
function getRPCEndpoints(network) {
@ -38,6 +39,8 @@ function getRPCEndpoints(network) {
return ['https://public-node.testnet.rsk.co']
case CLASSIC_CODE:
return ['https://www.ethercluster.com/etc']
case CALLISTO_NETWORK_CODE:
return ['https://clo-geth.0xinfra.com']
default:
return []
}
@ -45,4 +48,4 @@ function getRPCEndpoints(network) {
module.exports = {
getRPCEndpoints
}
}

View File

@ -44,8 +44,8 @@ describe('eth-net-props', () => {
it(`${claimPrefix} Ethereum Classic`, () => {
assert.equal(explorerLinks.getExplorerAccountLinkFor('0xd8fe15886d2dcbc5d7c06394beb417aadaf1eee0', 61), 'https://blockscout.com/etc/mainnet/address/0xd8fe15886d2dcbc5d7c06394beb417aadaf1eee0')
})
it(`${claimPrefix} Ethereum Classic`, () => {
assert.equal(explorerLinks.getExplorerAccountLinkFor('0xd8fe15886d2dcbc5d7c06394beb417aadaf1eee0', '61'), 'https://blockscout.com/etc/mainnet/address/0xd8fe15886d2dcbc5d7c06394beb417aadaf1eee0')
it(`${claimPrefix} Callisto Network`, () => {
assert.equal(explorerLinks.getExplorerAccountLinkFor('0xd8fe15886d2dcbc5d7c06394beb417aadaf1eee0', 820), 'https://explorer2.callisto.network/address/0xd8fe15886d2dcbc5d7c06394beb417aadaf1eee0')
})
})
@ -83,6 +83,9 @@ describe('eth-net-props', () => {
it(`${claimPrefix} Ethereum Classic`, () => {
assert.equal(explorerLinks.getExplorerTxLinkFor('0x430c90335b32fdcd92e54991668023d58b72bce836e204a81c6d97506c7137e5', 61), 'https://blockscout.com/etc/mainnet/tx/0x430c90335b32fdcd92e54991668023d58b72bce836e204a81c6d97506c7137e5')
})
it(`${claimPrefix} Callisto Network`, () => {
assert.equal(explorerLinks.getExplorerTxLinkFor('0x430c90335b32fdcd92e54991668023d58b72bce836e204a81c6d97506c7137e5', 820), 'https://explorer2.callisto.network/tx/0x430c90335b32fdcd92e54991668023d58b72bce836e204a81c6d97506c7137e5')
})
})
describe ('getExplorerTokenLinkFor()', () => {
@ -119,6 +122,9 @@ describe('eth-net-props', () => {
it(`${claimPrefix} Ethereum Classic`, () => {
assert.equal(explorerLinks.getExplorerTokenLinkFor('0x1ac1c8b874c7b889113a036ba443b082554be5d0', '0xdb23145b64D0E1e15dedf47abd77cCaf3F2327d7', 61), 'https://blockscout.com/etc/mainnet/address/0xdb23145b64D0E1e15dedf47abd77cCaf3F2327d7/tokens/0x1ac1c8b874c7b889113a036ba443b082554be5d0/token_transfers')
})
it(`${claimPrefix} Callisto Network`, () => {
assert.equal(explorerLinks.getExplorerTokenLinkFor('0x1ac1c8b874c7b889113a036ba443b082554be5d0', '0xdb23145b64D0E1e15dedf47abd77cCaf3F2327d7', 820), 'https://explorer2.callisto.network/address/0x1ac1c8b874c7b889113a036ba443b082554be5d0')
})
})
})
@ -254,6 +260,13 @@ describe('eth-net-props', () => {
assert.equal(ETCRPCEndpoints[0], 'https://www.ethercluster.com/etc')
}
})
it(`${claimPrefix} Callisto Network`, () => {
const CLORPCEndpoints = RPCEndpoints.getRPCEndpoints(820)
assert.equal(CLORPCEndpoints.length, 1)
if (CLORPCEndpoints.length > 0) {
assert.equal(CLORPCEndpoints[0], 'https://clo-geth.0xinfra.com')
}
})
})
claimPrefix = 'should return correct display name for'
@ -291,6 +304,9 @@ describe('eth-net-props', () => {
it(`${claimPrefix} Ethereum Classic`, () => {
assert.equal(netProps.getNetworkDisplayName(61), 'Ethereum Classic')
})
it(`${claimPrefix} Callisto Network`, () => {
assert.equal(netProps.getNetworkDisplayName(820), 'Callisto Network')
})
it(`${claimPrefix} Sokol Testnet`, () => {
assert.equal(netProps.getNetworkDisplayName('77'), 'Sokol Testnet')
})
@ -329,6 +345,9 @@ describe('eth-net-props', () => {
it(`${claimPrefix} Ethereum Classic`, () => {
assert.equal(netProps.getNetworkCoinName(61), 'ETC')
})
it(`${claimPrefix} Callisto Network`, () => {
assert.equal(netProps.getNetworkCoinName(820), 'CLO')
})
it('Sokol is a testnet', () => {
assert.equal(netProps.isTestnet(77), true)
@ -363,5 +382,8 @@ describe('eth-net-props', () => {
it('Ethereum Classic is a mainnet', () => {
assert.equal(netProps.isTestnet(61), false)
})
it('Callisto Network is a mainnet', () => {
assert.equal(netProps.isTestnet(820), false)
})
})
})
})