diff --git a/src/@core/layouts/components/Coffee.vue b/src/@core/layouts/components/Coffee.vue index c03800f5..09835bb9 100644 --- a/src/@core/layouts/components/Coffee.vue +++ b/src/@core/layouts/components/Coffee.vue @@ -21,9 +21,6 @@ - @@ -36,7 +33,6 @@ import Ripple from 'vue-ripple-directive' import { addressEnCode, addressDecode, } from '@/libs/utils' -import OperationTransferComponent from '@/views/OperationTransferComponent.vue' export default { name: 'AppFooter', @@ -47,7 +43,6 @@ export default { BFormInput, BInputGroupPrepend, BInputGroup, - OperationTransferComponent, }, directives: { Ripple, diff --git a/src/layouts/components/Navbar.vue b/src/layouts/components/Navbar.vue index 18ea463e..e5f4bba1 100644 --- a/src/layouts/components/Navbar.vue +++ b/src/layouts/components/Navbar.vue @@ -106,16 +106,26 @@ - +
+ {{ item.wallet }} + + + + + {{ item.address ? formatAddr(item.address.addr) : `Not available for ${selected_chain.chain_name}` }} +
+ + import { BLink, BNavbarNav, BMedia, BMediaAside, BAvatar, BMediaBody, VBTooltip, BButton, - BDropdown, BDropdownItem, + BDropdown, BDropdownItem, BDropdownDivider, } from 'bootstrap-vue' import Ripple from 'vue-ripple-directive' import DarkToggler from '@core/layouts/components/app-navbar/components/DarkToggler.vue' @@ -176,6 +186,7 @@ export default { BButton, BDropdown, BDropdownItem, + BDropdownDivider, // Navbar Components DarkToggler, @@ -224,14 +235,26 @@ export default { } return [conf.api] }, + accounts() { + let accounts = getLocalAccounts() || {} + accounts = Object.entries(accounts).map(v => ({ wallet: v[0], address: v[1].address.find(x => x.chain === this.selected_chain.chain_name) })) + + if (!this.$store.state.chains.defaultWallet && this.accounts.length > 0) { + this.updateDefaultWallet(this.accounts[0].wallet) + } + return accounts + }, }, mounted() { - const accounts = Object.keys(getLocalAccounts() || {}) - if (!this.$store.state.chains.defaultWallet && accounts.length > 0) { - this.$store.commit('setDefaultWallet', accounts[0]) - } + }, methods: { + formatAddr(v) { + return v.substring(0, 10).concat('...', v.substring(v.length - 10)) + }, + updateDefaultWallet(v) { + this.$store.commit('setDefaultWallet', v) + }, change(v) { this.index = v const conf = this.$store.state.chains.selected diff --git a/src/libs/fetch.js b/src/libs/fetch.js index bc17ec8f..83457768 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -60,7 +60,7 @@ export default class ChainFetch { if (conf.chain_name === 'injective') { return ChainFetch.fetch('https://tm.injective.network', '/block').then(data => Block.create(commonProcess(data))) } - return this.get('/blocks/latest', config).then(data => Block.create(data)) + return this.get(`/blocks/latest?${new Date().getTime()}`, config).then(data => Block.create(data)) } async getBlockByHeight(height, config = null) { @@ -386,6 +386,19 @@ export default class ChainFetch { return ChainFetch.fetchCoinMarketCap(`/quote/${symbol}`) } + // Simulate Execution of tx + async simulate(tx, config = null) { + return this.post('/cosmos/tx/v1beta1/simulate', tx, config).then(res => { + if (res.code && res.code !== 0) { + throw new Error(res.message) + } + if (res.tx_response && res.tx_response.code !== 0) { + throw new Error(res.tx_response.raw_log) + } + return res + }) + } + // Tx Submit async broadcastTx(bodyBytes, config = null) { const txString = toBase64(TxRaw.encode(bodyBytes).finish()) diff --git a/src/views/Governance.vue b/src/views/Governance.vue index 288a0d2d..945b0c59 100644 --- a/src/views/Governance.vue +++ b/src/views/Governance.vue @@ -157,19 +157,19 @@ {{ $t('btn_deposit') }} {{ $t('btn_vote') }} @@ -177,13 +177,10 @@ - - @@ -196,8 +193,7 @@ import Ripple from 'vue-ripple-directive' import { Proposal } from '@/libs/data' import { percent, tokenFormatter } from '@/libs/utils' import dayjs from 'dayjs' -import OperationVoteComponent from './OperationVoteComponent.vue' -import OperationGovDepositComponent from './OperationGovDepositComponent.vue' +import OperationModal from '@/views/components/OperationModal/index.vue' export default { components: { @@ -212,8 +208,7 @@ export default { BCardBody, BRow, BCol, - OperationVoteComponent, - OperationGovDepositComponent, + OperationModal, }, directives: { 'b-modal': VBModal, @@ -225,6 +220,7 @@ export default { selectedTitle: '', proposals: [new Proposal()], max: 1, + operationModalType: '', } }, mounted() { @@ -234,7 +230,8 @@ export default { percent: v => percent(v), formatDate: v => dayjs(v).format('YYYY-MM-DD'), formatToken: v => tokenFormatter(v, {}), - selectProposal(pid, title) { + selectProposal(modal, pid, title) { + this.operationModalType = modal this.selectedProposalId = Number(pid) this.selectedTitle = title }, diff --git a/src/views/GovernanceProposalView.vue b/src/views/GovernanceProposalView.vue index 47083020..bc66b81e 100644 --- a/src/views/GovernanceProposalView.vue +++ b/src/views/GovernanceProposalView.vue @@ -109,10 +109,11 @@ {{ $t('btn_vote') }} @@ -232,30 +233,29 @@ {{ $t('btn_deposit') }} {{ $t('btn_vote') }} - - @@ -273,9 +273,9 @@ import { } from '@/libs/utils' import { Proposal, Proposer } from '@/libs/data' import dayjs from 'dayjs' +import OperationModal from '@/views/components/OperationModal/index.vue' import ObjectFieldComponent from './ObjectFieldComponent.vue' -import OperationVoteComponent from './OperationVoteComponent.vue' -import OperationGovDepositComponent from './OperationGovDepositComponent.vue' + // import { formatToken } from '@/libs/data/data' export default { @@ -295,9 +295,8 @@ export default { BTooltip, BBadge, ObjectFieldComponent, - OperationVoteComponent, - OperationGovDepositComponent, FlipCountdown, + OperationModal, }, data() { return { @@ -307,6 +306,7 @@ export default { proposer: new Proposer(), deposits: [], votes: [], + operationModalType: '', votes_fields: [ { key: 'voter', @@ -411,6 +411,9 @@ export default { formatAddress(v) { return getStakingValidatorByAccount(this.$http.config.chain_name, v) }, + openModal(type) { + this.operationModalType = type + }, }, } diff --git a/src/views/Staking.vue b/src/views/Staking.vue index ccc250fc..b36ca436 100644 --- a/src/views/Staking.vue +++ b/src/views/Staking.vue @@ -78,7 +78,7 @@ @@ -222,9 +225,9 @@ import { percent, StakingParameters, formatToken, } from '@/libs/utils' import { keybase } from '@/libs/fetch' +import OperationModal from '@/views/components/OperationModal/index.vue' // import { toHex } from '@cosmjs/encoding' // import fetch from 'node-fetch' -import OperationDelegateComponent from './OperationDelegateComponent.vue' export default { components: { @@ -237,32 +240,15 @@ export default { BCardTitle, BCardBody, BButton, - OperationDelegateComponent, BFormRadioGroup, BFormGroup, + OperationModal, }, directives: { 'b-tooltip': VBTooltip, }, data() { return { - keys: [ - 'bitsongvaloper1jxv0u20scum4trha72c7ltfgfqef6nscl86wxa', - 'akashvaloper1vgstlgtsx4w80gphwgre0fcvc04lcnaelukvll', - 'certikvaloper1jxv0u20scum4trha72c7ltfgfqef6nsczkvcu7', - 'cosmosvaloper1jxv0u20scum4trha72c7ltfgfqef6nsch7q6cu', - 'iva16plp8cmfkjssp222taq6pv6mkm8c5pa9lcktta', - 'junovaloper1jxv0u20scum4trha72c7ltfgfqef6nscm9pmg2', - 'kavavaloper1xftqdxvq0xkv2mu8c5y0jrsc578tak4m9u0s44', - 'kivaloper1jxv0u20scum4trha72c7ltfgfqef6nschqtan9', - 'osmovaloper1jxv0u20scum4trha72c7ltfgfqef6nscqx0u46', - 'persistencevaloper1jxv0u20scum4trha72c7ltfgfqef6nsc4zjpnj', - 'starsvaloper1jxv0u20scum4trha72c7ltfgfqef6nscdghxyx', - 'digvaloper1jxv0u20scum4trha72c7ltfgfqef6nsc4s577p', - 'bcnavaloper1jxv0u20scum4trha72c7ltfgfqef6nsc384wxf', - 'pbvaloper1jxv0u20scum4trha72c7ltfgfqef6nsc5nn6cf', - 'rizonvaloper1jxv0u20scum4trha72c7ltfgfqef6nsczn2l68', - ], islive: true, validator_address: null, mintInflation: 0, @@ -314,7 +300,7 @@ export default { }, computed: { pingVals() { - return this.list.filter(x => this.keys.includes(x.operator_address)) + return this.list.filter(x => x.description.identity === '6783E9F948541962') }, list() { return this.validators.map(x => { diff --git a/src/views/StakingRewardComponent.vue b/src/views/StakingRewardComponent.vue index 6ac11107..e90bba72 100644 --- a/src/views/StakingRewardComponent.vue +++ b/src/views/StakingRewardComponent.vue @@ -6,7 +6,7 @@ Outstanding Rewards - @@ -98,7 +100,7 @@ import { import { sha256 } from '@cosmjs/crypto' import { toHex } from '@cosmjs/encoding' import { formatToken, numberWithCommas } from '@/libs/utils' -import OperationWithdrawCommissionComponent from './OperationWithdrawCommissionComponent.vue' +import OperationModal from '@/views/components/OperationModal/index.vue' export default { components: { @@ -111,7 +113,7 @@ export default { BMedia, BMediaAside, BAvatar, - OperationWithdrawCommissionComponent, + OperationModal, }, props: { data: { diff --git a/src/views/StakingValidator.vue b/src/views/StakingValidator.vue index db29c7f7..fe08d8c6 100644 --- a/src/views/StakingValidator.vue +++ b/src/views/StakingValidator.vue @@ -25,7 +25,7 @@
@@ -268,7 +268,10 @@ - +
@@ -281,10 +284,10 @@ import { percent, formatToken, StakingParameters, Validator, operatorAddressToAccount, consensusPubkeyToHexAddress, toDay, abbrMessage, abbrAddress, } from '@/libs/utils' import { keybase } from '@/libs/fetch' +import OperationModal from '@/views/components/OperationModal/index.vue' import StakingAddressComponent from './StakingAddressComponent.vue' import StakingCommissionComponent from './StakingCommissionComponent.vue' import StakingRewardComponent from './StakingRewardComponent.vue' -import OperationDelegateComponent from './OperationDelegateComponent.vue' export default { components: { @@ -300,7 +303,7 @@ export default { StakingAddressComponent, StakingCommissionComponent, StakingRewardComponent, - OperationDelegateComponent, + OperationModal, }, directives: { 'b-modal': VBModal, diff --git a/src/views/WalletAccountDetail.vue b/src/views/WalletAccountDetail.vue index a603fd7b..9aa2db5e 100644 --- a/src/views/WalletAccountDetail.vue +++ b/src/views/WalletAccountDetail.vue @@ -39,26 +39,28 @@ Assets
- Transfer + @click="setOperationModalType('Transfer')" + > + Transfer - IBC Transfer - + IBC Transfer +
@@ -160,10 +162,11 @@ Delegation
@@ -374,20 +378,10 @@ - - - - - -
@@ -410,13 +404,8 @@ import { } from '@/libs/utils' import { sha256 } from '@cosmjs/crypto' import { toHex } from '@cosmjs/encoding' +import OperationModal from '@/views/components/OperationModal/index.vue' import ObjectFieldComponent from './ObjectFieldComponent.vue' -import OperationTransferComponent from './OperationTransferComponent.vue' -import OperationWithdrawComponent from './OperationWithdrawComponent.vue' -import OperationUnbondComponent from './OperationUnbondComponent.vue' -import OperationDelegateComponent from './OperationDelegateComponent.vue' -import OperationRedelegateComponent from './OperationRedelegateComponent.vue' -import OperationTransfer2Component from './OperationTransfer2Component.vue' import ChartComponentDoughnut from './ChartComponentDoughnut.vue' export default { @@ -442,13 +431,8 @@ export default { // eslint-disable-next-line vue/no-unused-components ToastificationContent, ObjectFieldComponent, - OperationTransferComponent, - OperationWithdrawComponent, - OperationDelegateComponent, - OperationRedelegateComponent, - OperationUnbondComponent, - OperationTransfer2Component, ChartComponentDoughnut, + OperationModal, }, directives: { 'b-modal': VBModal, @@ -472,6 +456,7 @@ export default { quotes: {}, transactions: [], stakingParameters: {}, + operationModalType: '', } }, computed: { @@ -662,8 +647,12 @@ export default { this.transactions = res }) }, - selectValue(v) { + selectValue(v, type) { this.selectedValidator = v + this.setOperationModalType(type) + }, + setOperationModalType(type) { + this.operationModalType = type }, formatHash: abbrAddress, formatDenom(v) { diff --git a/src/views/WalletAccounts.vue b/src/views/WalletAccounts.vue index c3977ada..8bd37b63 100644 --- a/src/views/WalletAccounts.vue +++ b/src/views/WalletAccounts.vue @@ -153,15 +153,15 @@ /> Transfer IBC Transfer @@ -265,10 +265,10 @@ Connect Wallet - - @@ -287,8 +287,7 @@ import { import ToastificationContent from '@core/components/toastification/ToastificationContent.vue' import AppCollapse from '@core/components/app-collapse/AppCollapse.vue' import AppCollapseItem from '@core/components/app-collapse/AppCollapseItem.vue' -import OperationTransferComponent from './OperationTransferComponent.vue' -import OperationTransfer2Component from './OperationTransfer2Component.vue' +import OperationModal from '@/views/components/OperationModal/index.vue' import ChartComponentDoughnut from './ChartComponentDoughnut.vue' import EchartScatter from './components/charts/EchartScatter.vue' @@ -309,14 +308,13 @@ export default { // eslint-disable-next-line vue/no-unused-components VBTooltip, FeatherIcon, - OperationTransferComponent, // eslint-disable-next-line vue/no-unused-components ToastificationContent, - OperationTransfer2Component, ChartComponentDoughnut, AppCollapse, AppCollapseItem, EchartScatter, + OperationModal, }, directives: { 'b-tooltip': VBTooltip, @@ -335,6 +333,7 @@ export default { delegations: {}, ibcDenom: {}, quotes: {}, + operationModalType: '', options: { maintainAspectRatio: false, legend: { @@ -533,7 +532,8 @@ export default { this.currency2 = c this.currency = getUserCurrencySign() }, - transfer(addr) { + transfer(type, addr) { + this.operationModalType = type this.selectedAddress = addr }, completeAdd() { diff --git a/src/views/WalletDelegations.vue b/src/views/WalletDelegations.vue index b2911619..f446ad33 100644 --- a/src/views/WalletDelegations.vue +++ b/src/views/WalletDelegations.vue @@ -42,29 +42,29 @@ size="sm" > @@ -74,18 +74,10 @@ - - - - @@ -99,11 +91,7 @@ import { formatToken, getCachedValidators, getLocalAccounts, getLocalChains, tokenFormatter, } from '@/libs/utils' import FeatherIcon from '@/@core/components/feather-icon/FeatherIcon.vue' - -import OperationWithdrawComponent from './OperationWithdrawComponent.vue' -import OperationUnbondComponent from './OperationUnbondComponent.vue' -import OperationDelegateComponent from './OperationDelegateComponent.vue' -import OperationRedelegateComponent from './OperationRedelegateComponent.vue' +import OperationModal from '@/views/components/OperationModal/index.vue' export default { components: { @@ -113,11 +101,7 @@ export default { BTable, BCard, FeatherIcon, - - OperationWithdrawComponent, - OperationDelegateComponent, - OperationRedelegateComponent, - OperationUnbondComponent, + OperationModal, }, directives: { 'b-tooltip': VBTooltip, @@ -153,6 +137,7 @@ export default { accounts: [], delegations: [], rewards: {}, + operationModalType: '', } }, computed: { @@ -200,7 +185,8 @@ export default { this.init() }, methods: { - selectValue(v) { + selectValue(type, v) { + this.operationModalType = type this.address = v.delegator_address this.selectedValidator = v.validator.validator return v diff --git a/src/views/components/OperationModal/TransactionResult.vue b/src/views/components/OperationModal/TransactionResult.vue new file mode 100644 index 00000000..12c2fa27 --- /dev/null +++ b/src/views/components/OperationModal/TransactionResult.vue @@ -0,0 +1,214 @@ + + + + + diff --git a/src/views/components/OperationModal/components/Delegate.vue b/src/views/components/OperationModal/components/Delegate.vue new file mode 100644 index 00000000..f806d552 --- /dev/null +++ b/src/views/components/OperationModal/components/Delegate.vue @@ -0,0 +1,240 @@ + + + + + diff --git a/src/views/components/OperationModal/components/GovDeposit.vue b/src/views/components/OperationModal/components/GovDeposit.vue new file mode 100644 index 00000000..8bdf23eb --- /dev/null +++ b/src/views/components/OperationModal/components/GovDeposit.vue @@ -0,0 +1,194 @@ + + + + + diff --git a/src/views/components/OperationModal/components/IBCTransfer.vue b/src/views/components/OperationModal/components/IBCTransfer.vue new file mode 100644 index 00000000..99b5d4ea --- /dev/null +++ b/src/views/components/OperationModal/components/IBCTransfer.vue @@ -0,0 +1,307 @@ + + + + diff --git a/src/views/components/OperationModal/components/Redelegate.vue b/src/views/components/OperationModal/components/Redelegate.vue new file mode 100644 index 00000000..921636e5 --- /dev/null +++ b/src/views/components/OperationModal/components/Redelegate.vue @@ -0,0 +1,239 @@ + + + + diff --git a/src/views/components/OperationModal/components/Transfer.vue b/src/views/components/OperationModal/components/Transfer.vue new file mode 100644 index 00000000..53bc5d4c --- /dev/null +++ b/src/views/components/OperationModal/components/Transfer.vue @@ -0,0 +1,204 @@ + + + diff --git a/src/views/components/OperationModal/components/Unbond.vue b/src/views/components/OperationModal/components/Unbond.vue new file mode 100644 index 00000000..2882a100 --- /dev/null +++ b/src/views/components/OperationModal/components/Unbond.vue @@ -0,0 +1,197 @@ + + + + diff --git a/src/views/components/OperationModal/components/Vote.vue b/src/views/components/OperationModal/components/Vote.vue new file mode 100644 index 00000000..f25e0029 --- /dev/null +++ b/src/views/components/OperationModal/components/Vote.vue @@ -0,0 +1,166 @@ + + + + + diff --git a/src/views/components/OperationModal/components/Withdraw.vue b/src/views/components/OperationModal/components/Withdraw.vue new file mode 100644 index 00000000..331748c5 --- /dev/null +++ b/src/views/components/OperationModal/components/Withdraw.vue @@ -0,0 +1,80 @@ + + + diff --git a/src/views/components/OperationModal/components/WithdrawCommission.vue b/src/views/components/OperationModal/components/WithdrawCommission.vue new file mode 100644 index 00000000..487a8a65 --- /dev/null +++ b/src/views/components/OperationModal/components/WithdrawCommission.vue @@ -0,0 +1,84 @@ + + + diff --git a/src/views/components/OperationModal/index.vue b/src/views/components/OperationModal/index.vue new file mode 100644 index 00000000..279d860a --- /dev/null +++ b/src/views/components/OperationModal/index.vue @@ -0,0 +1,431 @@ + + + +