Skip to content

Commit

Permalink
Bcd 269 ticket transfer handling (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
GusevPM authored Aug 26, 2023
1 parent c43814c commit 3b30a1c
Show file tree
Hide file tree
Showing 14 changed files with 639 additions and 233 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "4.5.2",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"serve": "vue-cli-service serve --open",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
Expand Down
27 changes: 26 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 Expand Up @@ -751,4 +763,17 @@ export class BetterCallApi {
return this.api.get(`/contract/${network}/${address}/ticket_updates`, {params})
.then(this.returnResponseData);
}

getTickectUpdatesByOperation(network, operationId) {
return getCancellable(this.api, `/operation/${network}/${operationId}/ticket_updates`, {})
.then((res) => {
if (!res) {
return null;
}
if (res.status !== 200) {
throw new RequestFailedError(res);
}
return res.data
})
}
}
70 changes: 70 additions & 0 deletions src/components/Dialogs/LongBox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<template>
<v-dialog
v-model="show"
width="800"
@keydown.esc="show = false"
ref="box"
>
<template v-slot:activator="{ on }">
<v-list-item v-on="on" selectable class="link" >
<v-list-item-content>
<v-list-item-subtitle class="overline">
{{ title }}
</v-list-item-subtitle>
<v-list-item-title class="body-2">
{{ text }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</template>
<v-card>
<v-card-title class="py-3 px-6 align-center sidebar">
<span class="body-1 font-weight-medium text-uppercase text--secondary mr-2">
{{ title }}
</span>
</v-card-title>
<v-card-text class="pt-7">
<v-row no-gutters>
<v-col cols="12">
<ValueInspector
prim="string"
:value="text"
:network="network"
:label="title">
</ValueInspector>
</v-col>
</v-row>
</v-card-text>
</v-card>
</v-dialog>
</template>

<script>
import ValueInspector from "@/components/ValueInspector.vue"
export default {
name: "LongBox",
props: {
network: String,
title: String,
text: String
},
components: {
ValueInspector
},
data: () => ({
show: false
}),
updated() {
if (this.show) {
this.$refs.box.show();
}
}
}
</script>

<style scoped>
.link.v-list-item--link:hover::before, .link.v-list-item--link:focus::before {
opacity: 0;
}
</style>
49 changes: 41 additions & 8 deletions src/components/InternalOperation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,42 @@
</v-col>
</v-row>
<v-row no-gutters class="px-4 pt-4" style="font-size: 16px;">
<v-col cols="11">
<v-col cols="10">
<span v-if="data.tag" class="hash accent--text">event {{ data.tag }}</span>
<span v-else>
<span v-if="data.internal" class="mr-2 hash font-weight-thin">internal</span>
<span v-if="data.entrypoint" class="hash secondary--text">{{ data.entrypoint }}</span>
<span v-else class="hash accent--text">{{ data.kind }}</span>
<span v-if="!data.entrypoint || data.kind === 'transfer_ticket'" class="hash accent--text">{{ data.kind }}</span>
<span v-else class="hash secondary--text">{{ data.entrypoint }}</span>
</span>
<v-chip class="ml-3 overline" :color="statusColor" small outlined label>{{ data.status }}</v-chip>
</v-col>
<v-col cols="1" class="text-right">
<v-tooltip top v-if="data.ticket_updates_count > 0">
<template v-slot:activator="{ on }">
<v-btn
v-on="on"
icon
class="mr-7 text--secondary"
small
@click="openTicketCard"
>
<v-icon small>mdi-ticket-confirmation</v-icon>
</v-btn>
</template>
<span>{{ helpers.plural(data.ticket_updates_count, "ticket update") }}</span>
</v-tooltip>
<v-dialog v-model="showTicketUpdates" width="auto" @keydown.esc="showTicketUpdates = false">
<v-card class="bcd-table">
<v-card-title class="py-3 px-7">Ticket updates</v-card-title>
<v-card-text class="pa-0">
<TicketTab
:network="data.network"
:operationId="data.id"
/>
</v-card-text>
</v-card>
</v-dialog>
</v-col>
<v-col
cols="1"
class="py-0 d-flex justify-end align-center"
Expand Down Expand Up @@ -216,7 +243,7 @@
>
<v-col :cols="expanded ? 12 : 6">
<span class="overline ml-3">Payload</span>
<MiguelTreeView :miguel="data.event" :network="data.network" openAll />
<MiguelTreeView :miguel="data.payload" :network="data.network" openAll />
</v-col>
</v-row>
</div>
Expand All @@ -239,6 +266,7 @@ import OperationAlert from "@/components/OperationAlert.vue";
import AccountBox from "@/components/Dialogs/AccountBox.vue";
import RawJsonViewer from "@/components/Dialogs/RawJsonViewer.vue";
import MiguelTreeView from "@/components/MiguelTreeView.vue";
import TicketTab from "../views/contract/TicketTab/TicketTab.vue";
export default {
props: {
Expand All @@ -253,10 +281,12 @@ export default {
OperationAlert,
AccountBox,
MiguelTreeView,
TicketTab,
},
data: () => ({
showRaw: false,
showParams: false,
showTicketUpdates: false,
expanded: false,
loadingDiffs: false,
diffs: null
Expand Down Expand Up @@ -360,8 +390,8 @@ export default {
return (
this.data != null &&
this.data !== undefined &&
this.data.event != null &&
this.data.event !== undefined
this.data.payload != null &&
this.data.payload !== undefined
);
},
showDetails() {
Expand Down Expand Up @@ -400,7 +430,7 @@ export default {
this.data.destination &&
this.data.entrypoint &&
this.data.status === 'applied';
}
},
},
methods: {
...mapActions(["showClipboardOK", "showError"]),
Expand All @@ -424,7 +454,10 @@ export default {
finally(() => {
this.loadingDiffs = false;
})
}
},
openTicketCard() {
this.showTicketUpdates = true;
},
},
watch: {
showParams(newValue) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ValueInspector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import {mapActions} from "vuex";
import isIpfs from "is-ipfs";
import Michelson from "@/components/Michelson.vue";
import { copyToClipboard } from "@/utils/clipboard";
import { checkAddress, matchAddress, isSrAddress } from "@/utils/tz.js";
import { checkAddress, matchAddress } from "@/utils/tz.js";
export default {
name: "ValueInspector",
Expand Down Expand Up @@ -125,7 +125,7 @@ export default {
checkAddress(this.value.slice("tezos-storage://".length));
},
isAddress() {
return (this.prim === "address" || this.prim === "contract") && !isSrAddress(this.value) ;
return (this.prim === "address" || this.prim === "contract");
},
},
methods: {
Expand Down
6 changes: 3 additions & 3 deletions src/views/contract/ContentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ export default {
Shortcut,
},
created() {
this.value = Object.assign({}, this.data);
this.value = {...this.data};
},
computed: {
text() {
if (this.value == null) return "";
if (this.value.entrypoint) {
if (this.value.entrypoint && this.data.kind !== 'transfer_ticket') {
let all = this.value.entrypoint.split(',');
if (all.length == 1) {
return all[0];
Expand All @@ -161,7 +161,7 @@ export default {
...mapActions(["showError"]),
onPanelStateChange() {
if (!this.value) return;
if (this.value.mempool) this.internal = [Object.assign({}, this.value)];
if (this.value.mempool) this.internal = [{...this.value}];
if (this.internal.length > 0) return;
if (this.loading) return;
Expand Down
22 changes: 16 additions & 6 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,8 +110,10 @@ export default {
address: String,
},
data: () => ({
accountType: '',
contractLoading: true,
contract: {},
contractInfo: {},
balance: 0,
metadata: null,
tokensTotal: 0,
Expand Down Expand Up @@ -146,7 +149,7 @@ export default {
return this.isOnChainsLoading;
},
isContract() {
return this.address.startsWith("KT");
return this.accountType === 'contract';
},
breadcrumbsItems() {
return [
Expand All @@ -171,6 +174,9 @@ export default {
];
},
},
created() {
this.getInfo();
},
destroyed() {
this.hideError();
},
Expand Down Expand Up @@ -214,7 +220,6 @@ export default {
async init() {
this.tokensTotal = 0;
this.metadata = null;
this.contract = {};
this.alias = await this.getAlias(this.network, this.address);
if (this.isContract) {
Expand All @@ -223,7 +228,7 @@ export default {
this.getContract();
this.loadOnChainViews();
} else {
this.getInfo();
this.contract = this.contractInfo;
}
this.getMetadata();
},
Expand Down Expand Up @@ -258,9 +263,8 @@ export default {
.getAccountInfo(this.network, this.address)
.then((res) => {
if (!res) return;
if (!this.isContract) {
this.contract = res;
}
this.contractInfo = res;
this.accountType = res.account_type;
if (res.balance !== undefined) {
this.balance = res.balance || 0;
return;
Expand Down Expand Up @@ -327,6 +331,12 @@ export default {
},
},
watch: {
accountType: {
immediate: true,
handler() {
this.init();
}
},
address: {
immediate: true,
handler() {
Expand Down
Loading

0 comments on commit 3b30a1c

Please sign in to comment.