Skip to content

Commit

Permalink
Add info for smart rollups
Browse files Browse the repository at this point in the history
  • Loading branch information
GusevPM committed Aug 20, 2023
1 parent 8f8ff23 commit ff94667
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 95 deletions.
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
14 changes: 13 additions & 1 deletion src/api/bcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export class BetterCallApi {
})
}


getSameContracts(network, address, offset = 0) {
let params = {}
if (offset > 0) params.offset = offset;
Expand Down Expand Up @@ -489,6 +488,19 @@ export class BetterCallApi {
})
}

getSmartRollupInfo(network, address) {
return getCancellable(this.api, `/smart_rollups/${network}/${address}`, {})
.then((res) => {
if (!res) {
return res;
}
if (res.status != 200) {
throw new RequestFailedError(res);
}
return res.data
})
}

getDiff(query) {
return this.api.post(`/diff`, query)
.then((res) => {
Expand Down
14 changes: 7 additions & 7 deletions src/views/contract/Contract.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@

<VContainer fluid class="pt-0">
<router-view
:accountType="accountType"
:address="address"
:network="network"
:alias="alias"
Expand Down Expand Up @@ -109,6 +110,7 @@ export default {
address: String,
},
data: () => ({
accountType: '',
contractLoading: true,
contract: {},
balance: 0,
Expand Down Expand Up @@ -146,7 +148,7 @@ export default {
return this.isOnChainsLoading;
},
isContract() {
return this.address.startsWith("KT");
return this.accountType === 'contract';
},
breadcrumbsItems() {
return [
Expand Down Expand Up @@ -212,18 +214,17 @@ export default {
this.isComboBoxExpanded = false;
},
async init() {
this.getInfo();
this.tokensTotal = 0;
this.metadata = null;
this.contract = {};
this.alias = await this.getAlias(this.network, this.address);
if (this.isContract) {
this.contract = {};
this.bookmarks.registerObserver(this.onBookmarkStateChanged);
this.detectBookmark();
this.getContract();
this.loadOnChainViews();
} else {
this.getInfo();
}
this.getMetadata();
},
Expand Down Expand Up @@ -258,9 +259,8 @@ export default {
.getAccountInfo(this.network, this.address)
.then((res) => {
if (!res) return;
if (!this.isContract) {
this.contract = res;
}
this.contract = res;
this.accountType = res.account_type;
if (res.balance !== undefined) {
this.balance = res.balance || 0;
return;
Expand Down
187 changes: 101 additions & 86 deletions src/views/contract/OperationsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,85 +71,94 @@
</v-row>
</v-col>
<v-col cols="3">
<v-list class="contract-list">
<v-list-item style="height: 74px">
<v-list-item-content two-line>
<v-list-item-title class="headline">
<v-tooltip bottom :disabled="alias && alias.length < 25">
<template v-slot:activator="{ on, attrs }">
<span v-bind="attrs" v-on="on" style="cursor: inherit;">{{ alias ? alias : address }}</span>
</template>
<span>{{ alias ? alias : address }}</span>
</v-tooltip>
</v-list-item-title>
<v-list-item-subtitle>
<span
class="overline"
:class="network === 'mainnet' ? 'secondary--text' : ''"
>{{ network }}</span
>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content>
<v-list-item-subtitle class="overline"
>Was active</v-list-item-subtitle
>
<v-list-item-title class="body-2" v-if="isContract">
{{ helpers.formatDatetime(contract.timestamp) }}
<span v-if="contract.last_action > contract.timestamp">—
{{ helpers.formatDatetime(contract.last_action) }}</span
<template v-if="!isSmartRollup">
<v-list class="contract-list">
<v-list-item style="height: 74px">
<v-list-item-content two-line>
<v-list-item-title class="headline">
<v-tooltip bottom :disabled="alias && alias.length < 25">
<template v-slot:activator="{ on, attrs }">
<span v-bind="attrs" v-on="on" style="cursor: inherit;">{{ alias ? alias : address }}</span>
</template>
<span>{{ alias ? alias : address }}</span>
</v-tooltip>
</v-list-item-title>
<v-list-item-subtitle>
<span
class="overline"
:class="network === 'mainnet' ? 'secondary--text' : ''"
>{{ network }}</span
>
</v-list-item-title>
<v-list-item-title class="body-2" v-else>
{{ helpers.formatDatetime(contract.last_action) }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item v-if="balance">
<v-list-item-content>
<v-list-item-subtitle class="overline"
>Balance</v-list-item-subtitle
>
<v-list-item-title class="body-2">
<span>{{ balance | uxtz }}</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<AccountBox
v-if="contract.manager"
title="Deployed by"
:address="contract.manager"
:network="contract.network"
gutters
/>
<AccountBox
v-if="contract.delegate"
title="Delegated to"
:address="contract.delegate"
:network="contract.network"
gutters
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content>
<v-list-item-subtitle class="overline"
>Was active</v-list-item-subtitle
>
<v-list-item-title class="body-2" v-if="isContract">
{{ helpers.formatDatetime(contract.timestamp) }}
<span v-if="contract.last_action > contract.timestamp">—
{{ helpers.formatDatetime(contract.last_action) }}</span
>
</v-list-item-title>
<v-list-item-title class="body-2" v-else>
{{ helpers.formatDatetime(contract.last_action) }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item v-if="balance">
<v-list-item-content>
<v-list-item-subtitle class="overline"
>Balance</v-list-item-subtitle
>
<v-list-item-title class="body-2">
<span>{{ balance | uxtz }}</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<AccountBox
v-if="contract.manager"
title="Deployed by"
:address="contract.manager"
:network="contract.network"
gutters
/>
<AccountBox
v-if="contract.delegate"
title="Delegated to"
:address="contract.delegate"
:network="contract.network"
gutters
/>
<v-list-item v-if="usedBytes">
<v-list-item-content>
<v-list-item-subtitle class="overline">Storage used</v-list-item-subtitle>
<v-list-item-title class="body-2">
<span>{{ parseInt(usedBytes).toLocaleString('en-US') }} bytes</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item v-if="paidUsed">
<v-list-item-content>
<v-list-item-subtitle class="overline"
>Storage paid</v-list-item-subtitle
>
<v-list-item-title class="body-2">
<span>{{ parseInt(paidUsed).toLocaleString('en-US') }} bytes</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</template>
<template v-else>
<SmartRollupInfo
:address="address"
:network="network"
:alias="alias"
/>
<v-list-item v-if="usedBytes">
<v-list-item-content>
<v-list-item-subtitle class="overline">Storage used</v-list-item-subtitle>
<v-list-item-title class="body-2">
<span>{{ parseInt(usedBytes).toLocaleString('en-US') }} bytes</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item v-if="paidUsed">
<v-list-item-content>
<v-list-item-subtitle class="overline"
>Storage paid</v-list-item-subtitle
>
<v-list-item-title class="body-2">
<span>{{ parseInt(paidUsed).toLocaleString('en-US') }} bytes</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</template>
</v-col>
</v-row>
</v-container>
Expand All @@ -161,12 +170,13 @@ import OperationFilters from "@/views/contract/OperationFilters.vue";
import ContentItem from "@/views/contract/ContentItem.vue";
import EmptyState from "@/components/Cards/EmptyState.vue";
import dayjs from "dayjs";
import AccountBox from "../../components/Dialogs/AccountBox";
import { isKT1Address } from '@/utils/tz.js';
import AccountBox from "../../components/Dialogs/AccountBox.vue";
import SmartRollupInfo from "./SmartRollupInfo.vue";
export default {
name: "OperationsTab",
props: {
accountType: String,
address: String,
network: String,
alias: String,
Expand All @@ -177,7 +187,8 @@ export default {
AccountBox,
ContentItem,
EmptyState,
OperationFilters
OperationFilters,
SmartRollupInfo,
},
data: () => ({
openFilters: false,
Expand All @@ -198,11 +209,6 @@ export default {
}),
created() {
this.fetchOperations();
if (isKT1Address(this.address)){
this.getUsedBytes();
this.getPaidUsed();
}
},
computed: {
searchable() {
Expand All @@ -227,7 +233,10 @@ export default {
return operations;
},
isContract() {
return this.address.startsWith("KT");
return this.accountType === 'contract';
},
isSmartRollup() {
return this.accountType === 'smart_rollup';
},
isEmptyFilters() {
return this.filters.dates.length == 0 &&
Expand Down Expand Up @@ -448,6 +457,12 @@ export default {
}
},
watch: {
accountType() {
if (this.isContract) {
this.getUsedBytes();
this.getPaidUsed();
}
},
address: "fetchOperations",
search() {
this.applyFilter(true);
Expand Down
Loading

0 comments on commit ff94667

Please sign in to comment.