Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API version #562

Merged
merged 7 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -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
Expand Down
57 changes: 2 additions & 55 deletions src/api/bcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -519,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) => {
Expand Down Expand Up @@ -554,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);
Expand Down
47 changes: 31 additions & 16 deletions src/components/Tables/GlobalConstantsRegistry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
}"
}"
>
<template v-slot:item="{item}">
<tr class="table-row" :key="item.address">
Expand All @@ -36,10 +39,11 @@
</template>
<template v-slot:footer>
<div class="footer-pagination">
<v-btn icon @click="changePage(page - 1)" :disabled="page === 0">
<span class="caption grey--text mr-2">{{ (page - 1) * itemsPerPage + 1 }} - {{ nextPageCount }} of {{ constantsNumber }}</span>
<v-btn icon @click="changePage(page - 1)" :disabled="page === 1">
<v-icon>mdi-chevron-left</v-icon>
</v-btn>
<v-btn icon @click="changePage(page + 1)" :disabled="isLastPage">
<v-btn icon @click="changePage(page + 1)" :disabled="constantsNumber <= itemsPerPage * page">
<v-icon>mdi-chevron-right</v-icon>
</v-btn>
</div>
Expand All @@ -56,6 +60,7 @@ export default {
name: "GlobalConstantsRegistry",
props: {
network: String,
constantsNumber: Number,
hidePaginationCount: {
type: Boolean,
default: false,
Expand All @@ -71,22 +76,29 @@ export default {
},
methods: {
init() {
this.page = 0
this.globalConstantsItems = [];
if (!this.network)
return;

this.recentlyCalledContracts = [];
this.page = 1;
this.fetchConstants();
},
changePage(newPageNum) {
this.page = newPageNum;
this.fetchConstants();
// previousPage(newPage) {
// const offset = (newPage - 1) * this.itemsPerPage;
// this.changePage(newPage, offset)
// },
// nextPage(newPage) {
// this.changePage(newPage, offset)
// },
changePage(newPage) {
const offset = (newPage - 1) * this.itemsPerPage;
this.page = newPage;
this.fetchConstants(offset);
},
async fetchConstants() {
async fetchConstants(offset = 0) {
this.loadingGlobalConstantsStatus = DATA_LOADING_STATUSES.PROGRESS;

const offset = this.page * this.itemsPerPage;
const constants = await this.api.getGlobalConstants(this.network, offset, this.itemsPerPage);
this.globalConstantsItems = [...constants];

this.isLastPage = this.globalConstantsItems.length < this.itemsPerPage;
this.globalConstantsItems = await this.api.getGlobalConstants(this.network, offset, this.itemsPerPage);

this.loadingGlobalConstantsStatus = DATA_LOADING_STATUSES.SUCCESS;

Expand All @@ -96,6 +108,10 @@ export default {
isGlobalConstantsLoading() {
return this.loadingRecentlyCalledContractsStatus === DATA_LOADING_STATUSES.PROGRESS;
},
nextPageCount() {
const count = this.page * this.itemsPerPage;
return this.constantsNumber > 0 && count < this.constantsNumber ? count : this.constantsNumber;
},
},
watch: {
network: {
Expand All @@ -108,8 +124,7 @@ export default {
data() {
return {
aliasMaxLength: 24,
page: 0,
isLastPage: true,
page: 1,
loadingGlobalConstantsStatus: DATA_LOADING_STATUSES.NOTHING,
globalConstantsTableHeaders: [
{
Expand Down
37 changes: 15 additions & 22 deletions src/components/Tables/RecentlyCalledContracts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
loading-text="Loading recently called contracts... Please wait"
no-data-text="No called contracts found"
no-results-text="No called contracts found"
:server-items-length="totalItems"
:server-items-length="contractsNumber"
:footer-props="{
itemsPerPageOptions: []
}"
Expand All @@ -29,17 +29,17 @@
item.alias.length > aliasMaxLength
? item.alias.slice(0, aliasMaxLength).trim()
: item.alias
}}<em
v-if="item.alias.length > aliasMaxLength"
class="v-icon notranslate mdi mdi-dots-horizontal"
style="font-size: 16px;"
/>
}}
<em v-if="item.alias.length > aliasMaxLength"
class="v-icon notranslate mdi mdi-dots-horizontal"
style="font-size: 16px;"
/>
</span>
<Shortcut v-else :str="item.address"/>
</v-btn>
</td>
<td>
<span class="text--secondary">{{ item.tx_count }}</span>
<span class="text--secondary">{{ item.operations_count }}</span>
</td>
<td>
<span class="text--secondary">{{ helpers.formatDatetime(item.last_action) }}</span>
Expand All @@ -48,11 +48,11 @@
</template>
<template v-slot:footer v-if="pageable">
<div class="footer-pagination">
<span class="caption grey--text mr-2">{{ (page - 1) * itemsPerPage+1 }} - {{ nextPageCount }} of {{ totalItems }}</span>
<v-btn icon @click="changePage(page-1)" :disabled="page === 1">
<span class="caption grey--text mr-2">{{ (page - 1) * itemsPerPage + 1 }} - {{ nextPageCount }} of {{ contractsNumber }}</span>
<v-btn icon @click="changePage(page - 1)" :disabled="page === 1">
<v-icon>mdi-chevron-left</v-icon>
</v-btn>
<v-btn icon @click="changePage(page+1)" :disabled="(totalItems / itemsPerPage) < page">
<v-btn icon @click="changePage(page + 1)" :disabled="contractsNumber <= itemsPerPage * page">
<v-icon>mdi-chevron-right</v-icon>
</v-btn>
</div>
Expand All @@ -67,10 +67,7 @@ export default {
name: "RecentlyCalledContracts",
props: {
network: String,
updateable: {
type: Boolean,
default: true,
},
contractsNumber: Number,
hidePaginationCount: {
type: Boolean,
default: false,
Expand All @@ -90,26 +87,23 @@ export default {
},
nextPageCount() {
const count = this.page * this.itemsPerPage;
return this.totalItems > 0 && count < this.totalItems ? count : this.totalItems;
return this.contractsNumber > 0 && count < this.contractsNumber ? count : this.contractsNumber;
}
},
mounted() {
this.init();
},
methods: {
changePage(page) {
const offset = this.page * this.itemsPerPage;
this.page = page;
changePage(newPage) {
const offset = (newPage - 1) * this.itemsPerPage;
this.page = newPage;
this.requestRecentlyCalledContracts(offset);
},
async init() {
if (!this.network)
return;

this.requestRecentlyCalledContracts();
if (!this.updateable) {
this.totalItems = Number((await this.api.getContractsCount(this.network)));
}
},
requestRecentlyCalledContracts(offset = 0) {
if (this.loading)
Expand Down Expand Up @@ -142,7 +136,6 @@ export default {
return {
aliasMaxLength: 24,
page: 1,
totalItems: -1,
loading: false,
recentlyCalledTableHeaders: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/views/contract/Contract.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
40 changes: 14 additions & 26 deletions src/views/contract/MenuToolbar.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<template>
<v-toolbar flat class color="toolbar" height="48">
<v-tabs
:key="componentKey"
center-active
background-color="transparent"
slider-color="primary"
>
<v-tab :to="pushTo({ name: 'operations' })" :key="0" :title="contract.tx_count" replace style="width: 175px">
<v-tab :to="pushTo({ name: 'operations' })" :key="0" :title="contract.operations_count" replace style="width: 175px">
<v-icon left small>mdi-swap-horizontal</v-icon>operations
<span class="ml-1">({{ contract.tx_count || 0 | numberToCompactSIFormat }})</span>
<span class="ml-1">({{ contract.operations_count || 0 | numberToCompactSIFormat }})</span>
</v-tab>
<v-tab v-for="(tab, idx) in tabs" :key="idx + 1" :to="tab.to">
<v-icon left small>{{ tab.icon }}</v-icon>{{ tab.text }}
Expand All @@ -35,19 +34,9 @@ export default {
network: String,
onChainViews: Array
},
data() {
return {
componentKey: 1
}
},
watch: {
'contract.tx_count'() {
this.componentKey += 1;
}
},
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;
Expand Down Expand Up @@ -83,24 +72,14 @@ export default {
})
}

if (this.contract.has_ticket_updates) {
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',
Expand All @@ -115,7 +94,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',
Expand All @@ -138,6 +117,15 @@ export default {
})
}


if (this.metadata) {
tabs.push({
to: this.pushTo({ name: 'metadata' }),
icon: 'mdi-puzzle-outline',
text: 'Metadata',
})
}

return tabs;
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/extended_search/cards/Account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<span class="overline">Operations count</span>
</v-list-item-title>
<v-list-item-subtitle>
<span class="hash">{{ info.tx_count }}</span>
<span class="hash">{{ info.operations_count }}</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
Expand Down
Loading
Loading