From 148b387d40fd6897b0bf2f962d47f7d47d3502c3 Mon Sep 17 00:00:00 2001 From: GussevPM Date: Mon, 2 Oct 2023 20:01:04 +0400 Subject: [PATCH 1/7] Remove useless code + refactoring network's tables --- .env.development | 2 +- src/api/bcd.js | 46 ------------------ .../Tables/GlobalConstantsRegistry.vue | 47 ++++++++++++------- .../Tables/RecentlyCalledContracts.vue | 37 ++++++--------- src/views/network/ConstantsTab.vue | 17 +++++-- src/views/network/RecentlyCalledTab.vue | 18 ++++--- 6 files changed, 71 insertions(+), 96 deletions(-) diff --git a/.env.development b/.env.development index f4a0f3cf..6a19a711 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,5 @@ NODE_ENV=development -VUE_APP_API_URI=https://sharm.better-call.dev/v1 +VUE_APP_API_URI=https://hope.better-call.dev/v1 VUE_APP_IPFS_NODE=https://cloudflare-ipfs.com/ VUE_APP_SEARCH_SERVICE_URI=https://search.dipdup.net VUE_APP_TOKEN_METADATA_API=https://metadata.dipdup.net diff --git a/src/api/bcd.js b/src/api/bcd.js index b036ead4..8478c950 100644 --- a/src/api/bcd.js +++ b/src/api/bcd.js @@ -90,39 +90,6 @@ export class BetterCallApi { }) } - getContractOperations(network, address, last_id = "", from = 0, to = 0, statuses = [], entrypoints = [], with_storage_diff = true) { - let params = {} - if (last_id != "") { - params.last_id = last_id - } - if (from !== 0) { - params.from = from - } - if (to !== 0) { - params.to = to - } - if (statuses.length > 0 && statuses.length < 4) { - params.status = statuses.join(',') - } - if (entrypoints.length > 0) { - params.entrypoints = entrypoints.join(',') - } - params.with_storage_diff = with_storage_diff - - return getCancellable(this.api, `/contract/${network}/${address}/operations`, { - params: params, - }) - .then((res) => { - if (!res) { - return res; - } - if (res.status !== 200) { - throw new RequestFailedError(res); - } - return res.data - }) - } - getAccountOperationGroups(network, address, last_id = 0, size = 10) { let params = {} if (last_id > 0) { @@ -408,19 +375,6 @@ export class BetterCallApi { }); } - getContractsCount(network) { - return getCancellable(this.api, `/stats/${network}/contracts_count`, {}) - .then((res) => { - if (!res) { - return res; - } - if (res.status !== 200) { - throw new RequestFailedError(res); - } - return res.data - }); - } - getContractBigMapDiffsCount(network, ptr) { return getCancellable(this.api, `/bigmap/${network}/${ptr}/count`, {}) .then((res) => { diff --git a/src/components/Tables/GlobalConstantsRegistry.vue b/src/components/Tables/GlobalConstantsRegistry.vue index 597ed74f..888cb573 100644 --- a/src/components/Tables/GlobalConstantsRegistry.vue +++ b/src/components/Tables/GlobalConstantsRegistry.vue @@ -8,9 +8,12 @@ hide-default-footer :page.sync="page" :options="{itemsPerPage}" + no-data-text="No global constants found" + no-results-text="No global constants found" + :server-items-length="constantsNumber" :footer-props="{ itemsPerPageOptions: [] - }" + }" > @@ -14,11 +14,17 @@ import RecentlyCalledContracts from '../../components/Tables/RecentlyCalledContr export default { name: "RecentlyCalledTab", - props: { - network: String - }, components: { RecentlyCalledContracts - } + }, + props: { + network: String, + state: Object, + }, + computed: { + contractsNumber() { + return this.state.stats ? this.state.stats.contracts_count : 0; + }, + }, } - \ No newline at end of file + From 8aec95689a358a7125c2b8565bfae62e7a7d5f35 Mon Sep 17 00:00:00 2001 From: GussevPM Date: Mon, 2 Oct 2023 21:23:44 +0400 Subject: [PATCH 2/7] Contract model changes --- src/views/contract/Contract.vue | 2 +- src/views/contract/MenuToolbar.vue | 8 ++++---- src/views/extended_search/cards/Account.vue | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/views/contract/Contract.vue b/src/views/contract/Contract.vue index 243d5aec..cc8247ea 100644 --- a/src/views/contract/Contract.vue +++ b/src/views/contract/Contract.vue @@ -236,7 +236,7 @@ export default { .getContract(this.network, this.address) .then((res) => { if (!res) return; - this.contract = res; + this.contract = {...this.contractInfo, ...res}; }) .catch((err) => { if (err.code === 204) { diff --git a/src/views/contract/MenuToolbar.vue b/src/views/contract/MenuToolbar.vue index 920b84f5..1baa79aa 100644 --- a/src/views/contract/MenuToolbar.vue +++ b/src/views/contract/MenuToolbar.vue @@ -6,9 +6,9 @@ background-color="transparent" slider-color="primary" > - + mdi-swap-horizontaloperations - ({{ contract.tx_count || 0 | numberToCompactSIFormat }}) + ({{ contract.operations_count || 0 | numberToCompactSIFormat }}) {{ tab.icon }}{{ tab.text }} @@ -41,7 +41,7 @@ export default { } }, watch: { - 'contract.tx_count'() { + 'contract.operations_count'() { this.componentKey += 1; } }, @@ -83,7 +83,7 @@ export default { }) } - if (this.contract.has_ticket_updates) { + if (this.contract.ticket_updates_count && this.contract.ticket_updates_count > 0) { tabs.push({ to: this.pushTo({ name: 'ticket_updates' }), icon: 'mdi-ticket-outline', diff --git a/src/views/extended_search/cards/Account.vue b/src/views/extended_search/cards/Account.vue index 3172a375..51754469 100644 --- a/src/views/extended_search/cards/Account.vue +++ b/src/views/extended_search/cards/Account.vue @@ -47,7 +47,7 @@ Operations count - {{ info.tx_count }} + {{ info.operations_count }} From 5cabed66a8c70da594977ae853a1727df1a76428 Mon Sep 17 00:00:00 2001 From: GussevPM Date: Mon, 2 Oct 2023 21:46:03 +0400 Subject: [PATCH 3/7] Change opg requests --- src/api/bcd.js | 11 ++--------- src/views/extended_search/cards/Operation.vue | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/api/bcd.js b/src/api/bcd.js index 8478c950..5b19b4a7 100644 --- a/src/api/bcd.js +++ b/src/api/bcd.js @@ -473,10 +473,7 @@ export class BetterCallApi { if (with_storage_diff) { params.with_storage_diff = with_storage_diff; } - if (network) { - params.network = network - } - return getCancellable(this.api, `/opg/${hash}`, { + return getCancellable(this.api, `/opg/${network}/${hash}`, { params: params, }) .then((res) => { @@ -508,11 +505,7 @@ export class BetterCallApi { } getOperationsByHashAndCounter(hash, counter, network=null) { - let params = {}; - if (network) { - params['network'] = network; - } - return getCancellable(this.api, `/opg/${hash}/${counter}`, params) + return getCancellable(this.api, `/opg/${network}/${hash}/${counter}`, {}) .then((res) => { if (res.status != 200) { throw new RequestFailedError(res); diff --git a/src/views/extended_search/cards/Operation.vue b/src/views/extended_search/cards/Operation.vue index 09171340..d1a1a4c8 100644 --- a/src/views/extended_search/cards/Operation.vue +++ b/src/views/extended_search/cards/Operation.vue @@ -80,7 +80,7 @@ export default { if (this.loading) return; this.loading = true; - this.api.getOPG(item.body.Hash) + this.api.getOPG(item.body.Hash, true, false, item.body.Network) .then(opg => { if (opg.length > 0){ this.info = opg[0]; From 38fd4061f3169bc470b7451b6ff40fb6bb3634c8 Mon Sep 17 00:00:00 2001 From: GussevPM Date: Mon, 2 Oct 2023 22:16:21 +0400 Subject: [PATCH 4/7] Refactoring MenuToolbar + fix code smell --- src/views/contract/MenuToolbar.vue | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/views/contract/MenuToolbar.vue b/src/views/contract/MenuToolbar.vue index 1baa79aa..31b86d49 100644 --- a/src/views/contract/MenuToolbar.vue +++ b/src/views/contract/MenuToolbar.vue @@ -47,7 +47,7 @@ export default { }, computed: { isContract() { - return this.address.startsWith("KT"); + return this.contract.account_type === 'contract'; }, hasOffChainViews() { return this.metadata && this.metadata.metadata && this.metadata.metadata.views && this.metadata.metadata.views.length > 0; @@ -83,24 +83,14 @@ export default { }) } - if (this.contract.ticket_updates_count && this.contract.ticket_updates_count > 0) { + if (this.contract.ticket_updates_count > 0) { tabs.push({ to: this.pushTo({ name: 'ticket_updates' }), icon: 'mdi-ticket-outline', text: 'Tickets', }) } - } - - if (this.metadata) { - tabs.push({ - to: this.pushTo({ name: 'metadata' }), - icon: 'mdi-puzzle-outline', - text: 'Metadata', - }) - } - if (this.isContract) { tabs.push({ to: this.pushTo({ name: 'fork' }), icon: 'mdi-source-fork', @@ -115,7 +105,7 @@ export default { }) } - if (this.contract.events_count && this.contract.events_count > 0) { + if (this.contract.events_count > 0) { tabs.push({ to: this.pushTo({ name: 'events' }), icon: 'mdi-bell-outline', @@ -138,6 +128,15 @@ export default { }) } + + if (this.metadata) { + tabs.push({ + to: this.pushTo({ name: 'metadata' }), + icon: 'mdi-puzzle-outline', + text: 'Metadata', + }) + } + return tabs; } }, From e779225eef663a13ec15df460beb16bf182b8589 Mon Sep 17 00:00:00 2001 From: GussevPM Date: Sun, 8 Oct 2023 23:46:05 +0400 Subject: [PATCH 5/7] Review fixes --- src/components/Tables/GlobalConstantsRegistry.vue | 2 +- src/components/Tables/RecentlyCalledContracts.vue | 2 +- src/views/contract/MenuToolbar.vue | 11 ----------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/components/Tables/GlobalConstantsRegistry.vue b/src/components/Tables/GlobalConstantsRegistry.vue index 888cb573..f95234fa 100644 --- a/src/components/Tables/GlobalConstantsRegistry.vue +++ b/src/components/Tables/GlobalConstantsRegistry.vue @@ -43,7 +43,7 @@ mdi-chevron-left - + mdi-chevron-right diff --git a/src/components/Tables/RecentlyCalledContracts.vue b/src/components/Tables/RecentlyCalledContracts.vue index 61434409..050058c4 100644 --- a/src/components/Tables/RecentlyCalledContracts.vue +++ b/src/components/Tables/RecentlyCalledContracts.vue @@ -52,7 +52,7 @@ mdi-chevron-left - + mdi-chevron-right diff --git a/src/views/contract/MenuToolbar.vue b/src/views/contract/MenuToolbar.vue index 31b86d49..ffccda2e 100644 --- a/src/views/contract/MenuToolbar.vue +++ b/src/views/contract/MenuToolbar.vue @@ -1,7 +1,6 @@