Merge pull request #4 from poanetwork/dai-chain

(Feature) Dai chain explorer, coin names
This commit is contained in:
Victor Baranov 2018-10-11 20:42:38 +03:00 committed by GitHub
commit ad186b7604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 4 deletions

View File

@ -51,6 +51,9 @@ function getExplorerPrefix (network) {
console.warn('Do not use etherscan for POA Network')
prefix = 'core'
break
case 100: // Dai chain
prefix = 'dai'
break
default:
prefix = ''
}

View File

@ -20,6 +20,20 @@ function getNetworkDisplayName(network) {
}
}
function getNetworkCoinName(network) {
const netID = parseInt(network)
switch (netID) {
case 77:
case 99:
return 'POA'
case 100:
return 'XDAI'
default:
return 'ETH'
}
}
module.exports = {
getNetworkDisplayName
getNetworkDisplayName,
getNetworkCoinName
}

View File

@ -8,6 +8,7 @@ module.exports = {
getExplorerTokenLinkFor: getExplorerLinks.getExplorerTokenLinkFor,
},
props: {
getNetworkDisplayName: getNetProperties.getNetworkDisplayName
getNetworkDisplayName: getNetProperties.getNetworkDisplayName,
getNetworkCoinName: getNetProperties.getNetworkCoinName,
}
}

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "eth-net-props",
"version": "1.0.4",
"version": "1.0.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "eth-net-props",
"version": "1.0.4",
"version": "1.0.5",
"description": "Get properties of EMV-based network",
"main": "index.js",
"directories": {

View File

@ -17,6 +17,9 @@ describe('eth-net-props', () => {
it('should return correct explorer link for Core POA Network', () => {
assert.equal(explorerLinks.getExplorerAccountLinkFor('0x15c40c6de9f2299680a4522d8635c9b394eded09', 99), 'https://blockscout.com/poa/core/address/0x15c40c6de9f2299680a4522d8635c9b394eded09')
})
it('should return correct explorer link for Dai Chain', () => {
assert.equal(explorerLinks.getExplorerAccountLinkFor('0x15c40c6de9f2299680a4522d8635c9b394eded09', 100), 'https://blockscout.com/poa/dai/address/0x15c40c6de9f2299680a4522d8635c9b394eded09')
})
it('should return correct explorer link for Mainnet', () => {
assert.equal(explorerLinks.getExplorerAccountLinkFor('0x70FDd102DDB03Dc55B1719E76DfeA784916621fd', 1), 'https://etherscan.io/address/0x70FDd102DDB03Dc55B1719E76DfeA784916621fd')
})
@ -38,6 +41,9 @@ describe('eth-net-props', () => {
it('should return correct explorer link for Core POA Network', () => {
assert.equal(explorerLinks.getExplorerTxLinkFor('0xb3b01bcc1a73477cd86de989cc207fa59f87ea601dea298772f4b1b3f6f1407e', 99), 'https://blockscout.com/poa/core/tx/0xb3b01bcc1a73477cd86de989cc207fa59f87ea601dea298772f4b1b3f6f1407e')
})
it('should return correct explorer link for Dai Chain', () => {
assert.equal(explorerLinks.getExplorerTxLinkFor('0xb3b01bcc1a73477cd86de989cc207fa59f87ea601dea298772f4b1b3f6f1407e', 100), 'https://blockscout.com/poa/dai/tx/0xb3b01bcc1a73477cd86de989cc207fa59f87ea601dea298772f4b1b3f6f1407e')
})
it('should return correct explorer link for Mainnet', () => {
assert.equal(explorerLinks.getExplorerTxLinkFor('0x892c825d1ec25b0a1a27aa5dff5b54fc4488a45029d0087fc40d3d733ded7305', 1), 'https://etherscan.io/tx/0x892c825d1ec25b0a1a27aa5dff5b54fc4488a45029d0087fc40d3d733ded7305')
})
@ -59,6 +65,9 @@ describe('eth-net-props', () => {
it('should return correct explorer link for Core POA Network', () => {
assert.equal(explorerLinks.getExplorerTokenLinkFor('0xcf2AEDCfb4ff2c9020fb61c41226A4DfD77D12dE', '0x70FDd102DDB03Dc55B1719E76DfeA784916621fd', 99), 'https://blockscout.com/poa/core/address/0xcf2AEDCfb4ff2c9020fb61c41226A4DfD77D12dE')
})
it('should return correct explorer link for Dai Chain', () => {
assert.equal(explorerLinks.getExplorerTokenLinkFor('0xcf2AEDCfb4ff2c9020fb61c41226A4DfD77D12dE', '0x70FDd102DDB03Dc55B1719E76DfeA784916621fd', 100), 'https://blockscout.com/poa/dai/address/0xcf2AEDCfb4ff2c9020fb61c41226A4DfD77D12dE')
})
it('should return correct explorer link for Mainnet', () => {
assert.equal(explorerLinks.getExplorerTokenLinkFor('0xcf2AEDCfb4ff2c9020fb61c41226A4DfD77D12dE', '0x70FDd102DDB03Dc55B1719E76DfeA784916621fd', 1), 'https://etherscan.io/token/0xcf2AEDCfb4ff2c9020fb61c41226A4DfD77D12dE?a=0x70FDd102DDB03Dc55B1719E76DfeA784916621fd')
})
@ -96,5 +105,27 @@ describe('eth-net-props', () => {
it('should return correct display name for Kovan', () => {
assert.equal(netProps.getNetworkDisplayName(42), 'Kovan Test Network')
})
it('should return correct coin name for Sokol POA Network', () => {
assert.equal(netProps.getNetworkCoinName(77), 'POA')
})
it('should return correct coin name for Core POA Network', () => {
assert.equal(netProps.getNetworkCoinName(99), 'POA')
})
it('should return correct coin name for DAI chain', () => {
assert.equal(netProps.getNetworkCoinName(100), 'XDAI')
})
it('should return correct coin name for Mainnet', () => {
assert.equal(netProps.getNetworkCoinName(1), 'ETH')
})
it('should return correct coin name for Ropsten', () => {
assert.equal(netProps.getNetworkCoinName(3), 'ETH')
})
it('should return correct coin name for Rinkeby', () => {
assert.equal(netProps.getNetworkCoinName(4), 'ETH')
})
it('should return correct coin name for Kovan', () => {
assert.equal(netProps.getNetworkCoinName(42), 'ETH')
})
})
})