Skip to content

Commit

Permalink
Bug fixes (#333)
Browse files Browse the repository at this point in the history
* fix(send): show p-chain available amount instead of x-chain

* fix(style): center the NFT card content in history panel

* fix(History): showing p-chain address in the history panel

* fix(style): add border radius to confirmation background

* fix(multisig-wallet): update console handling in the msig section

* chore(locale): update warning message for list loading

* feat(balance): deduct gas fee from native token balance calculation

* fix(validator): Correct uptime calculation to prevent 10000% display
  • Loading branch information
Ayagoumi authored Nov 7, 2023
1 parent 33121ad commit 3f73d40
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 22 deletions.
7 changes: 2 additions & 5 deletions src/components/SidePanels/History/ViewTypes/ImportExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
</div>
</template>
<script lang="ts">
import { bintools } from '@/AVA'
import { chainIdFromAlias, bnToBig } from '@/helpers/helper'
import { aliasFromChainId, bnToBig } from '@/helpers/helper'
import { Vue, Component, Prop } from 'vue-property-decorator'
import { ITransactionData } from '@/store/modules/history/types'
import { ava } from '@/AVA'
import { BN } from '@c4tplatform/caminojs/dist'
import { bnToBig } from '@/helpers/helper'
@Component
export default class ImportExport extends Vue {
Expand Down Expand Up @@ -55,7 +52,7 @@ export default class ImportExport extends Vue {
get chainAlias() {
let chainId = this.isExport ? this.fromChainId : this.destinationChainId
return chainIdFromAlias(chainId)
return aliasFromChainId(chainId)
}
get amt(): BN {
Expand Down
2 changes: 2 additions & 0 deletions src/components/SidePanels/TxHistoryNftFamilyGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ $countW: 18px;
}
.nft_card {
display: flex;
justify-content: center;
height: 35px !important;
width: 35px !important;
background-color: var(--bg-light);
Expand Down
3 changes: 3 additions & 0 deletions src/components/misc/BalancePopup/BalanceDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@select="onselect"
:assets="assetArray"
:disabled-ids="disabledIds"
:chain-id="chainId"
></AvmTokenSelect>
</div>
</template>
Expand All @@ -18,6 +19,7 @@ import { Vue, Component, Prop, Ref, Model } from 'vue-property-decorator'
import BalancePopup from '@/components/misc/BalancePopup/BalancePopup.vue'
import AvaAsset from '@/js/AvaAsset'
import AvmTokenSelect from '@/components/modals/AvmTokenSelect.vue'
import { ChainIdType } from '@/constants'
@Component({
components: {
Expand All @@ -31,6 +33,7 @@ export default class BalanceDropdown extends Vue {
@Prop({ default: () => [] }) disabled_assets!: AvaAsset[]
@Prop({ default: false }) disabled!: boolean
@Model('change', { type: AvaAsset }) readonly asset!: AvaAsset
@Prop() chainId!: ChainIdType
get assetArray(): AvaAsset[] {
return this.$store.getters['Assets/walletAssetsArray']
Expand Down
1 change: 1 addition & 0 deletions src/components/misc/CurrencyInputDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:disabled_assets="disabled_assets"
v-model="asset_now"
:disabled="disabled"
:chain-id="chainId"
></BalanceDropdown>
<div class="col_balance">
<p>
Expand Down
4 changes: 3 additions & 1 deletion src/components/misc/EVMInputDropdown/EVMInputDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ export default class EVMInputDropdown extends Vue {
get balance(): Big {
if (this.token === 'native') {
return this.avaxBalance
let limit = new BN(this.gasLimit)
let fee = limit.mul(this.gasPrice)
return this.avaxBalance.sub(bnToBig(fee, this.denomination))
}
return this.token.balanceBig
}
Expand Down
8 changes: 6 additions & 2 deletions src/components/modals/AvmTokenSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<p>{{ asset.name }}</p>
</div>
<div class="col_balance">
<p>{{ asset | bal }}</p>
<p>{{ asset | bal(chainId) }}</p>
</div>
</div>
</div>
Expand All @@ -35,19 +35,23 @@ import { Vue, Component, Prop } from 'vue-property-decorator'
import Modal from '@/components/modals/Modal.vue'
import AvaAsset from '@/js/AvaAsset'
import { bnToBig } from '@/helpers/helper'
import { ChainIdType } from '@/constants'
@Component({
components: {
Modal,
},
filters: {
bal(asset: AvaAsset) {
bal(asset: AvaAsset, chainId: string) {
if (chainId === 'P')
return bnToBig(asset.amountExtra, asset.denomination).toLocaleString()
return bnToBig(asset.amount, asset.denomination).toLocaleString()
},
},
})
export default class PrivateKey extends Vue {
@Prop() assets!: AvaAsset[]
@Prop() chainId!: ChainIdType
@Prop({ default: () => [] }) disabledIds!: string[] // asset id | if nft the utxo id
open(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/components/wallet/earn/ChainTransfer/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</div>
<div class="confirmation_val" v-else>
<label>{{ $t('earn.transfer.amount') }}</label>
<p>{{ formAmtText }} {{ nativeAssetSymbol }}</p>
<p style="border-radius: 6px">{{ formAmtText }} {{ nativeAssetSymbol }}</p>
</div>
</div>
</template>
Expand Down
88 changes: 84 additions & 4 deletions src/components/wallet/earn/Validate/ValidatorInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<div>
<Tooltip style="display: inline-block" :text="$t('validator.info.up_time')">
<v-icon class="icon-mdi-camino">mdi-arrow-up-bold</v-icon>
<label>{{ upTime.toFixed() }} %</label>
<label v-if="initialized">{{ upTime.toFixed() }} %</label>
<Spinner v-else />
</Tooltip>
</div>
<div>
Expand Down Expand Up @@ -77,14 +78,16 @@
</template>
<script lang="ts">
import 'reflect-metadata'
import { Component, Prop, Vue } from 'vue-property-decorator'
import { Component, Prop, Vue, Watch } from 'vue-property-decorator'
import Spinner from '@/components/misc/Spinner.vue'
import moment from 'moment'
import { ava } from '@/AVA'
import { BN } from '@c4tplatform/caminojs'
import AvaxInput from '@/components/misc/AvaxInput.vue'
import Tooltip from '@/components/misc/Tooltip.vue'
import { ValidatorRaw } from '@/components/misc/ValidatorList/types'
import { AvaNetwork } from '@/js/AvaNetwork'
import axios from 'axios'
@Component({
name: 'validator_info',
Expand All @@ -106,6 +109,8 @@ export default class ValidatorInfo extends Vue {
txID: string = ''
loading: boolean = true
nodeVersion: string = ''
initialized: boolean = false
mounted() {
this.getInformationValidator()
Expand All @@ -120,8 +125,83 @@ export default class ValidatorInfo extends Vue {
return ava.getNetwork().P.minStake
}
getInformationValidator() {
get activeNetwork(): null | AvaNetwork {
return this.$store?.state?.Network?.selectedNetwork
}
async fetchNodeVersion() {
if (this.activeNetwork && this.activeNetwork.url) {
await axios
.post(this.activeNetwork.url + '/ext/info', {
jsonrpc: '2.0',
id: 1,
method: 'info.getNodeVersion',
})
.then((res) => {
const data = res.data
if (data && data.result && data.result.gitVersion) {
this.nodeVersion = data.result.gitVersion.slice(1) // remove v
}
})
.finally(() => {
this.initialized = true
})
}
}
checkNodeVersionFlag(targetVersion: string): boolean {
if (!this.initialized) {
throw new Error('Provider not initialized yet')
}
if (!this.nodeVersion) {
throw new Error('Node version not exists, function uncallable')
}
const versionRegex = /^\d+\.\d+\.\d+(-rc\d+)?$/
if (!versionRegex.test(targetVersion)) {
throw new Error(
`Invalid version format: ${targetVersion}. Correct version is of type major.minor.path e.g 1.2.3-rc2`
)
}
const [coreTargetVersion, targetVariant] = targetVersion.split('-')
const [coreNodeVersion, nodeVariant] = this.nodeVersion.split('-')
const [targetMajor, targetMinor, targetPatch] = coreTargetVersion.split('.').map(Number)
const [nodeMajor, nodeMinor, nodePatch] = coreNodeVersion.split('.').map(Number)
if (targetMajor !== nodeMajor) {
return targetMajor < nodeMajor
}
if (targetMinor !== nodeMinor) {
return targetMinor < nodeMinor
}
if (targetPatch !== nodePatch) {
return targetPatch < nodePatch
}
if (nodeVariant) {
return targetVariant <= nodeVariant
}
return true
}
formatUptime(uptime: string): number {
const versionFlag = this.checkNodeVersionFlag('0.4.10-rc3')
const value = versionFlag
? Math.round(parseFloat(uptime))
: Math.round(parseFloat(uptime) * 100)
return value
}
async getInformationValidator() {
try {
await this.fetchNodeVersion()
this.loading = true
let today = moment()
Expand All @@ -131,7 +211,7 @@ export default class ValidatorInfo extends Vue {
this.endTime = moment(new Date(parseInt(this.nodeInfo.endTime) * 1000)).format(
'MMMM Do YYYY, h:mm:ss a'
)
this.upTime = parseFloat(this.nodeInfo.uptime) * 100
this.upTime = this.formatUptime(this.nodeInfo.uptime)
var reaminingValidationDuration = moment.duration(
moment(new Date(parseInt(this.nodeInfo.endTime) * 1000)).diff(today)
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@
"rewarded": "Rewarded",
"not_rewarded": "Not Rewarded",
"loading": "Loading transaction history..",
"warn_loading": "This list might be incomplete and out of order.",
"warn_loading": "This list might be incomplete and not in the right order.",
"error_api": "Explorer API Not Found",
"error_api_desc": "You must provide an @.project:(0) Explorer API for this network to view transaction history.",
"start": "Stake Start Date",
Expand Down
12 changes: 4 additions & 8 deletions src/views/EditMultisigWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,7 @@ export default class EditMultisigWallet extends Vue {
const msigAlias = this.activeWallet?.getStaticAddress('P')
const localStorageAccountIndex = this.$store.state.Accounts.accountIndex
if (localStorageAccountIndex === null || localStorageAccountIndex === undefined)
throw new Error('account is not set in local storage')
if (localStorageAccountIndex === null || localStorageAccountIndex === undefined) return
let accounts = JSON.parse(localStorage.getItem('accounts') || '[]')
if (accounts[localStorageAccountIndex]) {
Expand Down Expand Up @@ -778,12 +777,9 @@ export default class EditMultisigWallet extends Vue {
accounts[localStorageAccountIndex].multisignatures = targetMultisignatures
localStorage.setItem('accounts', JSON.stringify(accounts))
} else console.error(`Account with index ${localStorageAccountIndex} does not exist.`)
} catch (error) {
console.error(
'An error occurred while updating multisig account in local storage: ',
error
)
} else console.warn(`Account with index ${localStorageAccountIndex} does not exist.`)
} catch (err) {
console.warn('Error:', err)
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/views/wallet/Validator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ import { AddressState } from '@c4tplatform/caminojs/dist/apis/platformvm'
import Big from 'big.js'
import 'reflect-metadata'
import { Component, Vue, Watch } from 'vue-property-decorator'
import { AvaNetwork } from '@/js/AvaNetwork'
@Component({
name: 'validator',
Expand Down Expand Up @@ -157,6 +158,10 @@ export default class Validator extends Vue {
)
}
get activeNetwork(): null | AvaNetwork {
return this.$store?.state?.Network?.selectedNetwork
}
verifyValidatorIsReady(val: ValidatorRaw) {
this.nodeInfo = val
}
Expand All @@ -182,6 +187,7 @@ export default class Validator extends Vue {
clearInterval(this.intervalID)
}
@Watch('activeNetwork')
@Watch('$store.state.networkName')
@Watch('$store.state.activeWallet')
async evaluateCanRegisterNode() {
Expand Down

0 comments on commit 3f73d40

Please sign in to comment.