This commit is contained in:
Erialos 2022-10-28 08:44:11 -06:00
commit f27bbec54c
7 changed files with 79 additions and 23 deletions

View File

@ -15,7 +15,7 @@ jobs:
- name: print
run: echo ${GITHUB_REF#refs/heads/}
- name: Git Checkout Latest
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install
run: yarn install

View File

@ -1,18 +1,18 @@
{
"chain_name": "jackal",
"coingecko": "",
"api": "https://api.jackalprotocol.com",
"rpc": "https://rpc.jackalprotocol.com",
"api": ["https://api.jackalprotocol.com", "https://jackal-api.polkachu.com","https://api.jackal.nodestake.top"],
"rpc": ["https://rpc.jackalprotocol.com", "https://jackal-rpc.polkachu.com","https://rpc.jackal.nodestake.top"],
"snapshot_provider": "",
"coin_type": "118",
"sdk_version": "0.45.9",
"addr_prefix": "jkl",
"addr_prefix": "jkl",
"logo": "/logos/jackal.png",
"assets": [{
"base": "ujkl",
"symbol": "JKL",
"exponent": "6",
"coingecko_id": "jackal",
"coingecko_id": "jackal",
"logo": "/logos/jackal.png"
}]
}

View File

@ -185,7 +185,19 @@ export default class ChainFetch {
async getValidatorList(config = null) {
return this.get('/cosmos/staking/v1beta1/validators?pagination.limit=200&status=BOND_STATUS_BONDED', config).then(data => {
const vals = commonProcess(data.validators).map(i => new Validator().init(i))
localStorage.setItem(`validators-${this.config.chain_name}`, JSON.stringify(vals))
try {
localStorage.setItem(`validators-${this.config.chain_name}`, JSON.stringify(vals))
} catch (err) {
// clear cache
for (let i = 0; i < localStorage.length; i += 1) {
const key = localStorage.key(i)
if (key.startsWith('validators')) {
localStorage.removeItem(key)
}
}
// set again
localStorage.setItem(`validators-${this.config.chain_name}`, JSON.stringify(vals))
}
return vals
})
}

View File

@ -10,7 +10,7 @@ import { sha256 } from '@cosmjs/crypto'
import { toHex } from '@cosmjs/encoding'
let chains = {}
const coingecko = {}
let configs = require.context('../../chains/mainnet', false, /\.json$/)
if (isTestnet()) {
configs = require.context('../../chains/testnet', false, /\.json$/)
@ -21,6 +21,9 @@ configs.keys().forEach(k => {
const c = configs(k)
c.chain_name = String(c.chain_name).toLowerCase()
update[c.chain_name] = c
c.assets.forEach(x => {
if (x.coingecko_id && x.coingecko_id !== '') coingecko[x.coingecko_id] = String(x.symbol).toUpperCase()
})
})
chains = update
@ -83,9 +86,21 @@ export default {
},
actions: {
async getQuotes(context) {
fetch('https://price.ping.pub/quotes').then(data => data.json()).then(data => {
context.commit('setQuotes', data)
})
// fetch('https://price.ping.pub/quotes').then(data => data.json()).then(data => {
// context.commit('setQuotes', data)
// })
const keys = Object.keys(coingecko)
if (keys.length > 0) {
const currencies = 'usd,cny,eur,jpy,krw,sgd,hkd'
fetch(`https://api.coingecko.com/api/v3/simple/price?vs_currencies=${currencies}&ids=${keys.join(',')}`).then(data => data.json()).then(data => {
// use symbol as key instead of coingecko id
const quotes = {}
Object.keys(data).forEach(k => {
quotes[coingecko[k]] = data[k]
})
context.commit('setQuotes', quotes)
})
}
},
async getAllIBCDenoms(context, _this) {

View File

@ -319,7 +319,7 @@
<feather-icon
icon="PlusCircleIcon"
/>
receive
Receive
</b-button>
</b-col>
</b-row>

View File

@ -118,8 +118,33 @@
<h4>#{{ height }}</h4>
</b-col>
<b-col
md="3"
sm="12"
md="9"
>
<b-input-group
prepend="Fetch Frequency"
>
<b-form-select
id="frequency"
v-model="frequency"
placeholder="Frequency to fetch data"
@change="onFrequencyChange()"
>
<b-form-select-option value="6000">
6s
</b-form-select-option>
<b-form-select-option value="2000">
2s
</b-form-select-option>
<b-form-select-option value="1000">
1s
</b-form-select-option>
</b-form-select>
</b-input-group>
</b-col>
<b-col
sm="12"
md="6"
>
<b-input-group
prepend="Qty of absent validators"
@ -144,7 +169,12 @@
class="text-truncate"
>
{{ x.name }}
<b-badge :variant="x.counter > 0 ? 'light-danger': 'light-success'">
<b-badge
v-if="x.proposed > 0"
v-b-tooltip.hover.v-second
:title="x.proposed > 0?`${ Number(x.counter / x.proposed * 100).toFixed(2) } %`:''"
:variant="x.counter > 0 ? 'light-danger': 'light-success'"
>
{{ x.counter }} / {{ x.proposed }}
</b-badge>
</b-col>
@ -157,7 +187,7 @@
<script>
import {
BSkeleton, BSkeletonWrapper, BInputGroupAppend, BTabs, BTab, BFormGroup,
BSkeleton, BSkeletonWrapper, BInputGroupAppend, BTabs, BTab, BFormGroup, BFormSelect, BFormSelectOption,
BRow, BCol, VBTooltip, BFormInput, BCard, BAlert, BFormCheckbox, BButton, BBadge, BInputGroup, BInputGroupPrepend,
} from 'bootstrap-vue'
@ -177,6 +207,8 @@ export default {
BButton,
BBadge,
BFormCheckbox,
BFormSelect,
BFormSelectOption,
BInputGroup,
BSkeleton,
BSkeletonWrapper,
@ -208,6 +240,7 @@ export default {
absentValsInBlock: {},
numOfBlock: 1000,
temp: 0,
frequency: 6000,
}
},
computed: {
@ -302,7 +335,7 @@ export default {
blocks.push({ sigs, height })
this.blocks = blocks
this.timer = setInterval(this.fetch_latest, 6000)
this.timer = setInterval(this.fetch_latest, this.frequency)
this.loading = false
})
},
@ -313,6 +346,10 @@ export default {
})
return sigs
},
onFrequencyChange() {
clearInterval(this.timer)
this.timer = setInterval(this.fetch_latest, this.frequency)
},
hex2base64(v) {
return toBase64(fromHex(v))
},

View File

@ -673,14 +673,6 @@ export default {
initial() {
this.$http.getBankAccountBalance(this.address).then(bal => {
this.assets = bal
bal.forEach(x => {
const symbol = formatTokenDenom(x.denom)
if (!this.quotes[symbol] && symbol.indexOf('/') === -1) {
chainAPI.fetchTokenQuote(symbol).then(quote => {
this.$set(this.quotes, symbol, quote)
})
}
})
})
this.$http.getStakingReward(this.address).then(res => {
this.reward = res