diff --git a/package.json b/package.json index 47ca7073..21bd3de9 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "universal-authenticator-library": "^0.3.0", "vue": "^3.0.0", "vue-class-component": "^7.2.6", - "vue-json-viewer": "3", + "vue-json-viewer": "^3.0.4", "vue-router": "^4.0.0", "vue3-openlayers": "^0.1.63", "vuex": "^4.0.1" diff --git a/src/api/eosio_core.ts b/src/api/eosio_core.ts index b2a3a5cf..c8af814a 100644 --- a/src/api/eosio_core.ts +++ b/src/api/eosio_core.ts @@ -23,7 +23,9 @@ const eosioCore = new APIClient({ export const getAccount = async function ( address: string, ): Promise { - return await eosioCore.v1.chain.get_account(address); + if (address){ + return await eosioCore.v1.chain.get_account(address); + } }; export const getKeyAccounts = async function ( diff --git a/src/components/AccountCard.vue b/src/components/AccountCard.vue index fcf2d72c..87ec9bd6 100644 --- a/src/components/AccountCard.vue +++ b/src/components/AccountCard.vue @@ -16,6 +16,7 @@ import { TableIndexType } from 'src/types/Api'; import { API, UInt64 } from '@greymass/eosio'; import { formatCurrency } from 'src/utils/string-utils'; import ConfigManager from 'src/config/ConfigManager'; +import { isSystemAccount } from 'src/utils/systemAccount'; const chain = getChain(); export default defineComponent({ @@ -43,8 +44,6 @@ export default defineComponent({ const createTime = ref('2019-01-01T00:00:00.000'); const createTransaction = ref(''); const creatingAccount = ref(''); - const system_account = ref('eosio'); - const isLoading = ref(true); const tokensLoading = ref(true); const none = ref(UInt64.from(0)); @@ -177,7 +176,7 @@ export default defineComponent({ const loadResources = () => { let ramDenominator; - if (props.account !== system_account.value) { + if (!isSystemAccount(props.account)) { // display max resource unit value for readability const ramMaxNumber = Number(accountData.value.ram_quota); const ramUnitResult = determineUnit(ramMaxNumber); @@ -443,7 +442,6 @@ export default defineComponent({ rexStaked, rexDeposits, none, - system_account, radius, availableTokens, createTime, @@ -459,6 +457,7 @@ export default defineComponent({ resources, accountExists, loadAccountData, + isSystemAccount, setToken, fixDec, loadSystemToken, @@ -479,13 +478,10 @@ export default defineComponent({
-
-
{{ account }}
-
-
+
{{ account }}
-
+
-
+
0) { diff --git a/src/components/BpVotes.vue b/src/components/BpVotes.vue index c45baf16..0d8911d1 100644 --- a/src/components/BpVotes.vue +++ b/src/components/BpVotes.vue @@ -1,5 +1,5 @@ diff --git a/src/components/ChildrenPanel.vue b/src/components/ChildrenPanel.vue index fe941c37..39bbfdfa 100644 --- a/src/components/ChildrenPanel.vue +++ b/src/components/ChildrenPanel.vue @@ -2,7 +2,7 @@ import { useQuasar } from 'quasar'; import { api } from 'src/api'; import { Action, NewAccountData } from 'src/types'; -import { defineComponent, onMounted, ref } from 'vue'; +import { defineComponent, onMounted, ref, watch } from 'vue'; export default defineComponent({ name: 'ChildrenPanel', components: {}, @@ -29,6 +29,10 @@ export default defineComponent({ formatAccount((el.act.data as NewAccountData).newact, 'account'), ); }; + watch(()=> props.account, async () => { + children.value = []; + await loadAccountData(); + }); // TODO Refactor const formatAccount = ( name: string, diff --git a/src/components/HeaderSearch.vue b/src/components/HeaderSearch.vue index c067ce47..9800f8ce 100644 --- a/src/components/HeaderSearch.vue +++ b/src/components/HeaderSearch.vue @@ -3,8 +3,9 @@ import { defineComponent, ref, watch } from 'vue'; import { useRouter } from 'vue-router'; import { OptionsObj, TableByScope } from 'src/types'; import { api } from 'src/api'; -import { isValidTransactionHex } from 'src/utils/string-utils'; +import { ACCOUNT_LENGTH, TRANSACTION_HASH_LENGTH, isValidTransactionHex } from 'src/utils/string-utils'; import { useQuasar } from 'quasar'; +import { systemAccounts } from 'src/utils/systemAccount'; import { debounce } from 'src/utils/time'; export default defineComponent({ @@ -31,7 +32,14 @@ export default defineComponent({ searchProposals(queryValue), searchTransactions(queryValue), ]).then((results) => { + // flatten search results options.value = ([] as OptionsObj[]).concat.apply([], results); + + // trigger navigation on single result + const filteredResults = options.value.filter(result => !result.isHeader); + if (filteredResults.length === 1){ + void handleGoTo(filteredResults[0].to); + } }); isLoading.value = false; @@ -44,6 +52,9 @@ export default defineComponent({ async function searchAccounts(value: string): Promise { try { const results = [] as OptionsObj[]; + if (value.length > ACCOUNT_LENGTH){ + return results; + } const request = { code: 'eosio', limit: 5, @@ -55,12 +66,17 @@ export default defineComponent({ // get table by scope for userres does not include system account if (value.includes('eosio')) { - accounts.unshift({ - payer: 'eosio', - } as TableByScope); + for (const systemAccount of systemAccounts){ + accounts.push( + { + payer: systemAccount, + } as TableByScope, + ); + } } if (accounts.length > 0) { + results.push({ label: 'Accounts', to: '', @@ -118,14 +134,14 @@ export default defineComponent({ async function searchTransactions(value: string): Promise { const results = [] as OptionsObj[]; - if (value.length !== 64) { + if (value.length !== TRANSACTION_HASH_LENGTH) { return results; } try { const transactions = await api.getTransaction(value); - if (transactions?.actions) { + if (transactions?.trx_id) { results.push({ label: 'Transactions', to: '', diff --git a/src/components/KeysPanel.vue b/src/components/KeysPanel.vue index 278e9178..98aed1f9 100644 --- a/src/components/KeysPanel.vue +++ b/src/components/KeysPanel.vue @@ -1,7 +1,7 @@