read tx fee from config

This commit is contained in:
liangping 2022-01-12 18:58:32 +08:00
parent feea9009cb
commit 4f398739fe
11 changed files with 75 additions and 76 deletions

View File

@ -4,7 +4,7 @@
"api": "https://api.genesisl1.org", "api": "https://api.genesisl1.org",
"sdk_version": "0.42.4", "sdk_version": "0.42.4",
"coin_type": "118", "coin_type": "118",
"min_tx_fee": "800", "min_tx_fee": "300000000000000",
"addr_prefix": "genesis", "addr_prefix": "genesis",
"logo": "/logos/genesisl1.png", "logo": "/logos/genesisl1.png",
"assets": [{ "assets": [{

View File

@ -125,6 +125,22 @@ export function chartColors() {
return Object.values($themeColors).concat(colors) return Object.values($themeColors).concat(colors)
} }
export function extractAccountNumberAndSequence(ret) {
let account = ret.value
if (ret.value && ret.value.base_vesting_account) { // vesting account
account = ret.value.base_vesting_account?.base_account
} else if (ret.value && ret.value.base_account) { // evmos based account
account = ret.value.base_account
}
const accountNumber = account.account_number
const sequence = account?.sequence || 0
return {
accountNumber,
sequence,
}
}
export function getUserCurrencySign() { export function getUserCurrencySign() {
let s = '' let s = ''
switch (getUserCurrency()) { switch (getUserCurrency()) {

View File

@ -285,7 +285,7 @@ import {
required, email, url, between, alpha, integer, password, min, digits, alphaDash, length, required, email, url, between, alpha, integer, password, min, digits, alphaDash, length,
} from '@validations' } from '@validations'
import { import {
abbrAddress, formatToken, formatTokenDenom, getLocalAccounts, getUnitAmount, setLocalTxHistory, sign, timeIn, abbrAddress, extractAccountNumberAndSequence, formatToken, formatTokenDenom, getLocalAccounts, getUnitAmount, setLocalTxHistory, sign, timeIn,
} from '@/libs/utils' } from '@/libs/utils'
import vSelect from 'vue-select' import vSelect from 'vue-select'
import ToastificationContent from '@core/components/toastification/ToastificationContent.vue' import ToastificationContent from '@core/components/toastification/ToastificationContent.vue'
@ -343,7 +343,7 @@ export default {
delegations: [], delegations: [],
IBCDenom: {}, IBCDenom: {},
memo: '', memo: '',
fee: '800', fee: '900',
feeDenom: '', feeDenom: '',
wallet: 'ledgerUSB', wallet: 'ledgerUSB',
error: null, error: null,
@ -408,15 +408,12 @@ export default {
} }
}) })
this.$http.getAuthAccount(this.selectedAddress).then(ret => { this.$http.getAuthAccount(this.selectedAddress).then(ret => {
if (ret.value.base_vesting_account) { const account = extractAccountNumberAndSequence(ret)
this.accountNumber = ret.value.base_vesting_account.base_account.account_number this.accountNumber = account.accountNumber
this.sequence = ret.value.base_vesting_account.base_account.sequence this.sequence = account.sequence
if (!this.sequence) this.sequence = 0
} else {
this.accountNumber = ret.value.account_number
this.sequence = ret.value.sequence ? ret.value.sequence : 0
}
}) })
this.fee = this.$store.state.chains.selected?.min_tx_fee || '1000'
this.feeDenom = this.$store.state.chains.selected?.assets[0]?.base || ''
} }
// this.$http.getStakingDelegations(this.selectedAddress).then(res => { // this.$http.getStakingDelegations(this.selectedAddress).then(res => {
// this.delegations = res.delegation_responses // this.delegations = res.delegation_responses

View File

@ -254,6 +254,7 @@ import {
} from '@validations' } from '@validations'
import { import {
abbrAddress, abbrAddress,
extractAccountNumberAndSequence,
formatToken, formatTokenDenom, getLocalAccounts, getUnitAmount, setLocalTxHistory, sign, timeIn, formatToken, formatTokenDenom, getLocalAccounts, getUnitAmount, setLocalTxHistory, sign, timeIn,
} from '@/libs/utils' } from '@/libs/utils'
import ToastificationContent from '@core/components/toastification/ToastificationContent.vue' import ToastificationContent from '@core/components/toastification/ToastificationContent.vue'
@ -349,6 +350,8 @@ export default {
return array return array
}, },
onChange() { onChange() {
this.fee = this.$store.state.chains.selected?.min_tx_fee || '1000'
this.feeDenom = this.$store.state.chains.selected?.assets[0]?.base || ''
if (this.voter) { if (this.voter) {
this.$http.getBankBalances(this.voter).then(res => { this.$http.getBankBalances(this.voter).then(res => {
if (res && res.length > 0) { if (res && res.length > 0) {
@ -370,15 +373,12 @@ export default {
} }
}) })
this.$http.getAuthAccount(this.voter).then(ret => { this.$http.getAuthAccount(this.voter).then(ret => {
if (ret.value.base_vesting_account) { const account = extractAccountNumberAndSequence(ret)
this.accountNumber = ret.value.base_vesting_account.base_account.account_number this.accountNumber = account.accountNumber
this.sequence = ret.value.base_vesting_account.base_account.sequence this.sequence = account.sequence
if (!this.sequence) this.sequence = 0
} else {
this.accountNumber = ret.value.account_number
this.sequence = ret.value.sequence ? ret.value.sequence : 0
}
}) })
this.fee = this.$store.state.chains.selected?.min_tx_fee || '1000'
this.feeDenom = this.$store.state.chains.selected?.assets[0]?.base || ''
} }
}, },
loadBalance() { loadBalance() {

View File

@ -253,6 +253,7 @@ import {
required, email, url, between, alpha, integer, password, min, digits, alphaDash, length, required, email, url, between, alpha, integer, password, min, digits, alphaDash, length,
} from '@validations' } from '@validations'
import { import {
extractAccountNumberAndSequence,
formatToken, formatTokenDenom, getUnitAmount, setLocalTxHistory, sign, timeIn, formatToken, formatTokenDenom, getUnitAmount, setLocalTxHistory, sign, timeIn,
} from '@/libs/utils' } from '@/libs/utils'
import vSelect from 'vue-select' import vSelect from 'vue-select'
@ -364,16 +365,14 @@ export default {
this.error = null this.error = null
} }
}) })
this.$http.getAuthAccount(this.address).then(ret => { this.$http.getAuthAccount(this.address).then(ret => {
if (ret.value.base_vesting_account) { const account = extractAccountNumberAndSequence(ret)
this.accountNumber = ret.value.base_vesting_account.base_account.account_number this.accountNumber = account.accountNumber
this.sequence = ret.value.base_vesting_account.base_account.sequence this.sequence = account.sequence
if (!this.sequence) this.sequence = 0
} else {
this.accountNumber = ret.value.account_number
this.sequence = ret.value.sequence ? ret.value.sequence : 0
}
}) })
this.fee = this.$store.state.chains.selected?.min_tx_fee || '1000'
this.feeDenom = this.$store.state.chains.selected?.assets[0]?.base || ''
this.$http.getStakingDelegations(this.address).then(res => { this.$http.getStakingDelegations(this.address).then(res => {
this.delegations = res.delegation_responses this.delegations = res.delegation_responses
this.delegations.forEach(x => { this.delegations.forEach(x => {

View File

@ -300,6 +300,7 @@ import {
required, email, url, between, alpha, integer, password, min, digits, alphaDash, length, required, email, url, between, alpha, integer, password, min, digits, alphaDash, length,
} from '@validations' } from '@validations'
import { import {
extractAccountNumberAndSequence,
formatToken, formatTokenDenom, getLocalAccounts, getLocalChains, getUnitAmount, setLocalTxHistory, sign, timeIn, formatToken, formatTokenDenom, getLocalAccounts, getLocalChains, getUnitAmount, setLocalTxHistory, sign, timeIn,
} from '@/libs/utils' } from '@/libs/utils'
import { Cosmos } from '@cosmostation/cosmosjs' import { Cosmos } from '@cosmostation/cosmosjs'
@ -456,15 +457,12 @@ export default {
} }
}) })
this.$http.getAuthAccount(this.address, this.selectedChain).then(ret => { this.$http.getAuthAccount(this.address, this.selectedChain).then(ret => {
if (ret.value.base_vesting_account) { const account = extractAccountNumberAndSequence(ret)
this.accountNumber = ret.value.base_vesting_account.base_account.account_number this.accountNumber = account.accountNumber
this.sequence = ret.value.base_vesting_account.base_account.sequence this.sequence = account.sequence
if (!this.sequence) this.sequence = 0
} else {
this.accountNumber = ret.value.account_number
this.sequence = ret.value.sequence ? ret.value.sequence : 0
}
}) })
this.fee = this.selectedChain?.min_tx_fee || '1000'
this.feeDenom = this.selectedChain?.assets[0]?.base || ''
const channels = this.$store.state.chains.ibcChannels[this.selectedChain.chain_name] const channels = this.$store.state.chains.ibcChannels[this.selectedChain.chain_name]
if (!channels) { if (!channels) {

View File

@ -256,6 +256,7 @@ import {
required, email, url, between, alpha, integer, password, min, digits, alphaDash, length, required, email, url, between, alpha, integer, password, min, digits, alphaDash, length,
} from '@validations' } from '@validations'
import { import {
extractAccountNumberAndSequence,
formatToken, formatTokenDenom, getLocalAccounts, getLocalChains, getUnitAmount, setLocalTxHistory, sign, timeIn, formatToken, formatTokenDenom, getLocalAccounts, getLocalChains, getUnitAmount, setLocalTxHistory, sign, timeIn,
} from '@/libs/utils' } from '@/libs/utils'
import { Cosmos } from '@cosmostation/cosmosjs' import { Cosmos } from '@cosmostation/cosmosjs'
@ -383,15 +384,12 @@ export default {
} }
}) })
this.$http.getAuthAccount(this.address, this.selectedChain).then(ret => { this.$http.getAuthAccount(this.address, this.selectedChain).then(ret => {
if (ret.value.base_vesting_account) { const account = extractAccountNumberAndSequence(ret)
this.accountNumber = ret.value.base_vesting_account.base_account.account_number this.accountNumber = account.accountNumber
this.sequence = ret.value.base_vesting_account.base_account.sequence this.sequence = account.sequence
if (!this.sequence) this.sequence = 0
} else {
this.accountNumber = ret.value.account_number
this.sequence = ret.value.sequence ? ret.value.sequence : 0
}
}) })
this.fee = this.selectedChain?.min_tx_fee || '1000'
this.feeDenom = this.selectedChain?.assets[0]?.base || ''
} }
}, },
handleOk(bvModalEvt) { handleOk(bvModalEvt) {

View File

@ -231,6 +231,7 @@ import {
required, email, url, between, alpha, integer, password, min, digits, alphaDash, length, required, email, url, between, alpha, integer, password, min, digits, alphaDash, length,
} from '@validations' } from '@validations'
import { import {
extractAccountNumberAndSequence,
formatToken, formatTokenDenom, getUnitAmount, setLocalTxHistory, sign, timeIn, formatToken, formatTokenDenom, getUnitAmount, setLocalTxHistory, sign, timeIn,
} from '@/libs/utils' } from '@/libs/utils'
import vSelect from 'vue-select' import vSelect from 'vue-select'
@ -344,15 +345,12 @@ export default {
} }
}) })
this.$http.getAuthAccount(this.address).then(ret => { this.$http.getAuthAccount(this.address).then(ret => {
if (ret.value.base_vesting_account) { const account = extractAccountNumberAndSequence(ret)
this.accountNumber = ret.value.base_vesting_account.base_account.account_number this.accountNumber = account.accountNumber
this.sequence = ret.value.base_vesting_account.base_account.sequence this.sequence = account.sequence
if (!this.sequence) this.sequence = 0
} else {
this.accountNumber = ret.value.account_number
this.sequence = ret.value.sequence ? ret.value.sequence : 0
}
}) })
this.fee = this.$store.state.chains.selected?.min_tx_fee || '1000'
this.feeDenom = this.$store.state.chains.selected?.assets[0]?.base || ''
this.$http.getStakingDelegations(this.address).then(res => { this.$http.getStakingDelegations(this.address).then(res => {
this.delegations = res.delegation_responses this.delegations = res.delegation_responses
this.delegations.forEach(x => { this.delegations.forEach(x => {

View File

@ -243,6 +243,7 @@ import {
} from '@validations' } from '@validations'
import { import {
abbrAddress, abbrAddress,
extractAccountNumberAndSequence,
formatToken, getLocalAccounts, setLocalTxHistory, sign, timeIn, formatToken, getLocalAccounts, setLocalTxHistory, sign, timeIn,
} from '@/libs/utils' } from '@/libs/utils'
import ToastificationContent from '@core/components/toastification/ToastificationContent.vue' import ToastificationContent from '@core/components/toastification/ToastificationContent.vue'
@ -350,15 +351,12 @@ export default {
} }
}) })
this.$http.getAuthAccount(this.voter).then(ret => { this.$http.getAuthAccount(this.voter).then(ret => {
if (ret.value.base_vesting_account) { const account = extractAccountNumberAndSequence(ret)
this.accountNumber = ret.value.base_vesting_account.base_account.account_number this.accountNumber = account.accountNumber
this.sequence = ret.value.base_vesting_account.base_account.sequence this.sequence = account.sequence
if (!this.sequence) this.sequence = 0
} else {
this.accountNumber = ret.value.account_number
this.sequence = ret.value.sequence ? ret.value.sequence : 0
}
}) })
this.fee = this.$store.state.chains.selected?.min_tx_fee || '1000'
this.feeDenom = this.$store.state.chains.selected?.assets[0]?.base || ''
} }
}, },
loadBalance() { loadBalance() {

View File

@ -168,6 +168,7 @@ import {
required, email, url, between, alpha, integer, password, min, digits, alphaDash, length, required, email, url, between, alpha, integer, password, min, digits, alphaDash, length,
} from '@validations' } from '@validations'
import { import {
extractAccountNumberAndSequence,
formatToken, setLocalTxHistory, sign, timeIn, formatToken, setLocalTxHistory, sign, timeIn,
} from '@/libs/utils' } from '@/libs/utils'
import ToastificationContent from '@core/components/toastification/ToastificationContent.vue' import ToastificationContent from '@core/components/toastification/ToastificationContent.vue'
@ -259,15 +260,12 @@ export default {
} }
}) })
this.$http.getAuthAccount(this.address).then(ret => { this.$http.getAuthAccount(this.address).then(ret => {
if (ret.value.base_vesting_account) { const account = extractAccountNumberAndSequence(ret)
this.accountNumber = ret.value.base_vesting_account.base_account.account_number this.accountNumber = account.accountNumber
this.sequence = ret.value.base_vesting_account.base_account.sequence this.sequence = account.sequence
if (!this.sequence) this.sequence = 0
} else {
this.accountNumber = ret.value.account_number
this.sequence = ret.value.sequence ? ret.value.sequence : 0
}
}) })
this.fee = this.$store.state.chains.selected?.min_tx_fee || '1000'
this.feeDenom = this.$store.state.chains.selected?.assets[0]?.base || ''
}, },
handleOk(bvModalEvt) { handleOk(bvModalEvt) {
// console.log('send') // console.log('send')

View File

@ -176,7 +176,7 @@ import {
required, email, url, between, alpha, integer, password, min, digits, alphaDash, length, required, email, url, between, alpha, integer, password, min, digits, alphaDash, length,
} from '@validations' } from '@validations'
import { import {
formatToken, getLocalAccounts, getLocalChains, sign, timeIn, setLocalTxHistory, formatToken, getLocalAccounts, getLocalChains, sign, timeIn, setLocalTxHistory, extractAccountNumberAndSequence,
} from '@/libs/utils' } from '@/libs/utils'
import ToastificationContent from '@core/components/toastification/ToastificationContent.vue' import ToastificationContent from '@core/components/toastification/ToastificationContent.vue'
@ -284,15 +284,12 @@ export default {
} }
}) })
this.$http.getAuthAccount(this.address).then(ret => { this.$http.getAuthAccount(this.address).then(ret => {
if (ret.value.base_vesting_account) { const account = extractAccountNumberAndSequence(ret)
this.accountNumber = ret.value.base_vesting_account.base_account.account_number this.accountNumber = account.accountNumber
this.sequence = ret.value.base_vesting_account.base_account.sequence this.sequence = account.sequence
if (!this.sequence) this.sequence = 0
} else {
this.accountNumber = ret.value.account_number
this.sequence = ret.value.sequence ? ret.value.sequence : 0
}
}) })
this.fee = this.$store.state.chains.selected?.min_tx_fee || '1000'
this.feeDenom = this.$store.state.chains.selected?.assets[0]?.base || ''
} }
this.$http.getStakingDelegations(this.address).then(res => { this.$http.getStakingDelegations(this.address).then(res => {
this.delegations = res.delegation_responses this.delegations = res.delegation_responses