Support ZEC
This commit is contained in:
parent
9b51565303
commit
45e6e2b82d
10 changed files with 105 additions and 47 deletions
|
|
@ -1,19 +1,28 @@
|
|||
const coins = {
|
||||
BTC: {unitScale: 8},
|
||||
ETH: {unitScale: 18}
|
||||
ETH: {unitScale: 18},
|
||||
ZEC: {unitScale: 8}
|
||||
}
|
||||
|
||||
const cryptoDisplays = [
|
||||
{cryptoCode: 'BTC', display: 'Bitcoin'},
|
||||
{cryptoCode: 'ETH', display: 'Ethereum'}
|
||||
{cryptoCode: 'ETH', display: 'Ethereum'},
|
||||
{cryptoCode: 'ZEC', display: 'Zcash'}
|
||||
]
|
||||
|
||||
module.exports = {coins, cryptoDisplays, buildUrl}
|
||||
module.exports = {coins, cryptoDisplays, buildUrl, unitScale}
|
||||
|
||||
function buildUrl (cryptoCode, address) {
|
||||
switch (cryptoCode) {
|
||||
case 'BTC': return `bitcoin:${address}`
|
||||
case 'ETH': return `ethereum:${address}`
|
||||
case 'ZEC': return `zcash:${address}`
|
||||
default: throw new Error(`Unsupported crypto: ${cryptoCode}`)
|
||||
}
|
||||
}
|
||||
|
||||
function unitScale (cryptoCode) {
|
||||
const scaleRec = coins[cryptoCode]
|
||||
if (!scaleRec) throw new Error(`Unsupported crypto: ${cryptoCode}`)
|
||||
return scaleRec.unitScale
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue