Merge branch 'ping-pub:master' into master

This commit is contained in:
Erialos 2022-10-28 08:43:15 -06:00 committed by GitHub
commit ca2d2314d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 23 deletions

View File

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

View File

@ -1,8 +1,8 @@
{ {
"chain_name": "jackal", "chain_name": "jackal",
"coingecko": "", "coingecko": "",
"api": "https://api.jackalprotocol.com", "api": ["https://api.jackalprotocol.com", "https://jackal-api.polkachu.com","https://api.jackal.nodestake.top"],
"rpc": "https://rpc.jackalprotocol.com", "rpc": ["https://rpc.jackalprotocol.com", "https://jackal-rpc.polkachu.com","https://rpc.jackal.nodestake.top"],
"snapshot_provider": "", "snapshot_provider": "",
"coin_type": "118", "coin_type": "118",
"sdk_version": "0.45.9", "sdk_version": "0.45.9",

View File

@ -185,7 +185,19 @@ export default class ChainFetch {
async getValidatorList(config = null) { async getValidatorList(config = null) {
return this.get('/cosmos/staking/v1beta1/validators?pagination.limit=200&status=BOND_STATUS_BONDED', config).then(data => { 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)) const vals = commonProcess(data.validators).map(i => new Validator().init(i))
try {
localStorage.setItem(`validators-${this.config.chain_name}`, JSON.stringify(vals)) 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 return vals
}) })
} }

View File

@ -10,7 +10,7 @@ import { sha256 } from '@cosmjs/crypto'
import { toHex } from '@cosmjs/encoding' import { toHex } from '@cosmjs/encoding'
let chains = {} let chains = {}
const coingecko = {}
let configs = require.context('../../chains/mainnet', false, /\.json$/) let configs = require.context('../../chains/mainnet', false, /\.json$/)
if (isTestnet()) { if (isTestnet()) {
configs = require.context('../../chains/testnet', false, /\.json$/) configs = require.context('../../chains/testnet', false, /\.json$/)
@ -21,6 +21,9 @@ configs.keys().forEach(k => {
const c = configs(k) const c = configs(k)
c.chain_name = String(c.chain_name).toLowerCase() c.chain_name = String(c.chain_name).toLowerCase()
update[c.chain_name] = c 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 chains = update
@ -83,9 +86,21 @@ export default {
}, },
actions: { actions: {
async getQuotes(context) { async getQuotes(context) {
fetch('https://price.ping.pub/quotes').then(data => data.json()).then(data => { // fetch('https://price.ping.pub/quotes').then(data => data.json()).then(data => {
context.commit('setQuotes', 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) { async getAllIBCDenoms(context, _this) {

View File

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

View File

@ -118,8 +118,33 @@
<h4>#{{ height }}</h4> <h4>#{{ height }}</h4>
</b-col> </b-col>
<b-col <b-col
md="3"
sm="12" 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 <b-input-group
prepend="Qty of absent validators" prepend="Qty of absent validators"
@ -144,7 +169,12 @@
class="text-truncate" class="text-truncate"
> >
{{ x.name }} {{ 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 }} {{ x.counter }} / {{ x.proposed }}
</b-badge> </b-badge>
</b-col> </b-col>
@ -157,7 +187,7 @@
<script> <script>
import { 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, BRow, BCol, VBTooltip, BFormInput, BCard, BAlert, BFormCheckbox, BButton, BBadge, BInputGroup, BInputGroupPrepend,
} from 'bootstrap-vue' } from 'bootstrap-vue'
@ -177,6 +207,8 @@ export default {
BButton, BButton,
BBadge, BBadge,
BFormCheckbox, BFormCheckbox,
BFormSelect,
BFormSelectOption,
BInputGroup, BInputGroup,
BSkeleton, BSkeleton,
BSkeletonWrapper, BSkeletonWrapper,
@ -208,6 +240,7 @@ export default {
absentValsInBlock: {}, absentValsInBlock: {},
numOfBlock: 1000, numOfBlock: 1000,
temp: 0, temp: 0,
frequency: 6000,
} }
}, },
computed: { computed: {
@ -302,7 +335,7 @@ export default {
blocks.push({ sigs, height }) blocks.push({ sigs, height })
this.blocks = blocks this.blocks = blocks
this.timer = setInterval(this.fetch_latest, 6000) this.timer = setInterval(this.fetch_latest, this.frequency)
this.loading = false this.loading = false
}) })
}, },
@ -313,6 +346,10 @@ export default {
}) })
return sigs return sigs
}, },
onFrequencyChange() {
clearInterval(this.timer)
this.timer = setInterval(this.fetch_latest, this.frequency)
},
hex2base64(v) { hex2base64(v) {
return toBase64(fromHex(v)) return toBase64(fromHex(v))
}, },

View File

@ -673,14 +673,6 @@ export default {
initial() { initial() {
this.$http.getBankAccountBalance(this.address).then(bal => { this.$http.getBankAccountBalance(this.address).then(bal => {
this.assets = 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.$http.getStakingReward(this.address).then(res => {
this.reward = res this.reward = res