Skip to content

Commit

Permalink
Operations tab (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored Jul 7, 2022
1 parent f1b270a commit a71829f
Show file tree
Hide file tree
Showing 15 changed files with 500 additions and 400 deletions.
6 changes: 4 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
NODE_ENV=development
VUE_APP_API_URI=https://sharm.better-call.dev/
VUE_APP_API_URI=https://sharm.better-call.dev/v1
IPFS_NODE=https://ipfs.io
SEARCH_SERVICE_URI=https://search.dipdup.net
SEARCH_SERVICE_URI=https://search.dipdup.net
TOKEN_METADATA_API=https://metadata.dipdup.net
METADATA_API_URI=https://metadata.dipdup.net
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ NODE_ENV=production
BASE_URL=https://better-call.dev/
VUE_APP_API_URI=https://api.better-call.dev/v1
SEARCH_SERVICE_URI=https://search.dipdup.net
TOKEN_METADATA_API=https://metadata.dipdup.net
METADATA_API_URI=https://metadata.dipdup.net
74 changes: 55 additions & 19 deletions src/api/bcd.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const axios = require('axios').default;
const maxSize = 10;

import { getCancellable, postCancellable, cancelRequests } from '@/utils/cancellation.js';
import { getCancellable, postCancellable } from '@/utils/cancellation.js';

export class RequestFailedError extends Error {
constructor(response) {
Expand Down Expand Up @@ -136,6 +136,28 @@ export class BetterCallApi {
})
}

getAccountOperationGroups(network, address, last_id = 0, size = 10) {
let params = {}
if (last_id > 0) {
params['last_id'] = last_id
}
if (size !== 0) {
params['size'] = size
}
return getCancellable(this.api, `/contract/${network}/${address}/opg`, {
params: params,
})
.then((res) => {
if (!res) {
return null;
}
if (res.status !== 200) {
throw new RequestFailedError(res);
}
return res.data
})
}

getAccountInfo(network, address) {
return getCancellable(this.api, `/account/${network}/${address}`, {})
.then((res) => {
Expand Down Expand Up @@ -474,18 +496,6 @@ export class BetterCallApi {
})
}

getRandomContract(network) {
cancelRequests();
const request_url = network ? `/pick_random?network=${network}` : `/pick_random`;
return getCancellable(this.api, request_url, {})
.then((res) => {
if (res.status !== 200) {
throw new RequestFailedError(res);
}
return res.data
})
}

getContractsStats(network, addresses, period) {
return getCancellable(this.api, `/stats/${network}/contracts?period=${period}&contracts=${addresses.join(',')}`, {})
.then((res) => {
Expand Down Expand Up @@ -524,8 +534,20 @@ export class BetterCallApi {
})
}

getProjects() {
return getCancellable(this.api, `/projects`, {})
getOPG(hash, with_mempool=true, with_storage_diff=false, network=undefined) {
let params = {}
if (with_mempool) {
params.with_mempool = with_mempool;
}
if (with_storage_diff) {
params.with_storage_diff = with_storage_diff;
}
if (network) {
params.network = network
}
return getCancellable(this.api, `/opg/${hash}`, {
params: params,
})
.then((res) => {
if (res.status != 200) {
throw new RequestFailedError(res);
Expand All @@ -534,8 +556,8 @@ export class BetterCallApi {
})
}

getOPG(hash, with_mempool=true) {
return getCancellable(this.api, `/opg/${hash}?with_mempool=${with_mempool}`, {})
getImplicitOperation(network, counter) {
return getCancellable(this.api, `/implicit/${network}/${counter}`, {})
.then((res) => {
if (res.status != 200) {
throw new RequestFailedError(res);
Expand All @@ -554,6 +576,20 @@ export class BetterCallApi {
})
}

getOperationsByHashAndCounter(hash, counter, network=null) {
let params = {};
if (network) {
params['network'] = network;
}
return getCancellable(this.api, `/opg/${hash}/${counter}`, params)
.then((res) => {
if (res.status != 200) {
throw new RequestFailedError(res);
}
return res.data
})
}

getStats() {
return getCancellable(this.api, `/stats`, {})
.then((res) => {
Expand Down Expand Up @@ -598,8 +634,8 @@ export class BetterCallApi {
})
}

getErrorLocation(operationId) {
return getCancellable(this.api, `/operation/${operationId}/error_location`, {})
getErrorLocation(network, operationId) {
return getCancellable(this.api, `/operation/${network}/${operationId}/error_location`, {})
.then((res) => {
if (!res) { return res; }
if (res.status != 200) {
Expand Down
15 changes: 15 additions & 0 deletions src/api/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ export class SearchService {
big_maps: filters,
}
}

).then(this.parseResponse)
}

operations(text, filters, size = 0, offset = 0) {
return this.api.post(
`/v1/search`, {
query: text,
size: size ? size : 10,
offset: offset,
filters: {
operations: filters,
}
}

).then(this.parseResponse)
}

Expand Down
21 changes: 13 additions & 8 deletions src/components/InternalOperation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
</template>
<span>Repeat operation group</span>
</v-tooltip>
<v-tooltip top>
<v-tooltip top v-if="data.hash">
<template v-slot:activator="{ on }">
<v-btn v-on="on" icon class="mr-2 text--secondary" @click="showRaw = true">
<v-icon>mdi-code-json</v-icon>
</v-btn>
</template>
<span>View raw JSON</span>
</v-tooltip>
<v-tooltip top>
<v-tooltip top v-if="data.hash">
<template v-slot:activator="{ on }">
<v-btn
v-on="on"
Expand All @@ -66,7 +66,7 @@
</template>
<span>Copy operation hash</span>
</v-tooltip>
<v-tooltip top>
<v-tooltip top v-if="data.hash">
<template v-slot:activator="{ on }">
<v-btn
v-on="on"
Expand All @@ -92,7 +92,7 @@
<v-col
cols="1"
class="py-0 d-flex justify-end align-center"
v-if="loadingDiffs || hasParameters || hasStorageDiff"
v-if="showDetails"
>
<v-btn
text
Expand Down Expand Up @@ -253,9 +253,7 @@ export default {
}),
created() {
this.showParams =
this.data.errors !== undefined ||
this.data.destination === this.address ||
this.address === undefined;
this.data.errors !== undefined;
},
computed: {
source() {
Expand Down Expand Up @@ -354,6 +352,12 @@ export default {
this.diffs !== undefined
);
},
showDetails() {
return this.data.hash === undefined ||
this.data.kind === 'origination' ||
this.hasParameters ||
this.hasStorageDiff;
},
statusColor() {
if (this.data.status === "applied") return "success";
if (this.data.status === "backtracked") return "warning";
Expand Down Expand Up @@ -388,9 +392,10 @@ export default {
methods: {
...mapActions(["showClipboardOK", "showError"]),
getDiff() {
if (this.data.status !== "applied") return;
if (this.diffs !== null) return;
this.loadingDiffs = true;
this.api.getOperationDiff(this.data.network, this.data.id).
then((res) => {
this.diffs = res;
Expand Down
4 changes: 2 additions & 2 deletions src/components/OperationAlert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import TreeNodeDetails from "@/components/Dialogs/TreeNodeDetails.vue";
export default {
name: "OperationAlert",
props: {
operationId: String,
operationId: Number,
errors: Array,
network: String,
},
Expand All @@ -98,7 +98,7 @@ export default {
getErrorLocation() {
this.errorLocationLoading = true;
this.api
.getErrorLocation(this.operationId)
.getErrorLocation(this.network, this.operationId)
.then((res) => {
this.errorLocation = res;
this.showErrorLocation = true;
Expand Down
1 change: 0 additions & 1 deletion src/components/Shortcut.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default {
computed: {
head() {
if (!this.str) return 0;
if (this.str.startsWith("tz") || this.str.startsWith("KT")) {
return 3;
} else if (this.str.startsWith("o")) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/schema/Schema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default {
],
model: {},
}),
async created() {
created() {
this.setExecuteActions();
this.setFillTypes();
Expand Down Expand Up @@ -335,6 +335,7 @@ export default {
callback: this.beaconClientActionCallback(false)
},
];
console.log(this.executeActions)
this.importActions.push(
{
text: "Wallet",
Expand Down
4 changes: 1 addition & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { NodeRPC } from "@/api/rpc.js";
import { Bookmarks } from "@/utils/bookmarks.js";
import { SearchService } from "@/api/search.js";
import { MetadataAPI } from "@/api/metadata.js";
import { SearchService } from "@/api/search.js";

import { makeVuetify } from '@/plugins/vuetify';

Expand Down Expand Up @@ -111,7 +110,7 @@ Vue.filter('snakeToCamel', (str) => {
let config = {
API_URI: process.env.VUE_APP_API_URI || `${window.location.protocol}//${window.location.host}/v1`,
HOME_PAGE: 'home',
SEARCH_SERVICE_URI: process.env.SEARCH_SERVICE_URI || 'https://search.dipdup.net'
SEARCH_SERVICE_URI: process.env.SEARCH_SERVICE_URI || 'https://search.dipdup.net',
TOKEN_METADATA_API: process.env.TOKEN_METADATA_API || "https://metadata.dipdup.net",
IPFS_NODE: process.env.IPFS_NODE || "https://ipfs.io",
METADATA_API_URI: process.env.METADATA_API_URI || "https://metadata.dipdup.net"
Expand All @@ -122,7 +121,6 @@ let bookmarks = new Bookmarks();
let searchService = new SearchService(config.SEARCH_SERVICE_URI);
let tokenMetadata = new TokenMetadataApi(config.TOKEN_METADATA_API);
let metadataAPI = new MetadataAPI(config.METADATA_API_URI);
let searchService = new SearchService(process.env.SEARCH_SERVICE_URI);

const isDark = localStorage.getItem('dark') ? JSON.parse(localStorage.getItem('dark')) : true;
if (isDark) {
Expand Down
Loading

0 comments on commit a71829f

Please sign in to comment.