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

Bcd 160 create page global constant #431

Merged
merged 15 commits into from
Jul 7, 2022
75 changes: 44 additions & 31 deletions src/api/bcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,19 @@ export class BetterCallApi {
}
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
})
}
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 = {}
Expand Down Expand Up @@ -589,6 +591,15 @@ export class BetterCallApi {
return res.data
})
}
getProjects() {
return getCancellable(this.api, `/projects`, {})
.then((res) => {
if (res.status != 200) {
throw new RequestFailedError(res);
}
return res.data
})
}

getImplicitOperation(network, counter) {
return getCancellable(this.api, `/implicit/${network}/${counter}`, {})
Expand Down Expand Up @@ -624,16 +635,18 @@ export class BetterCallApi {
})
}

getStats() {
return getCancellable(this.api, `/stats`, {})
.then((res) => {
if (!res) { return res; }
if (res.status != 200) {
throw new RequestFailedError(res);
}
return res.data
})
}
getStats() {
return getCancellable(this.api, `/stats`, {})
.then((res) => {
if (!res) {
return res;
}
if (res.status != 200) {
throw new RequestFailedError(res);
}
return res.data
})
}

getNetworkStats(network) {
return getCancellable(this.api, `/stats/${network}`, {})
Expand Down Expand Up @@ -672,16 +685,16 @@ export class BetterCallApi {
})
}

getErrorLocation(network, operationId) {
return getCancellable(this.api, `/operation/${network}/${operationId}/error_location`, {})
.then((res) => {
if (!res) { return res; }
if (res.status != 200) {
throw new RequestFailedError(res);
}
return res.data
})
}
getErrorLocation(network, operationId) {
return getCancellable(this.api, `/operation/${network}/${operationId}/error_location`, {})
.then((res) => {
if (!res) { return res; }
if (res.status != 200) {
throw new RequestFailedError(res);
}
return res.data
})
}

getContractBySlug(slug) {
return getCancellable(this.api, `/slug/${slug}`, {})
Expand Down
12 changes: 11 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ Vue.directive('pastHtml', {
}
})


Vue.directive('pastHtml', {
inserted(el, binding) {
el.innerHTML = binding.value;
},
update(el, binding,) {
el.innerHTML = binding.value;
}
})

let config = {
API_URI: process.env.VUE_APP_API_URI || `${window.location.protocol}//${window.location.host}/v1`,
HOME_PAGE: 'home',
Expand Down Expand Up @@ -159,7 +169,7 @@ api.getConfig().then(response => {
store.dispatch('hideError');
next();
});

router.addRoutes([
{
path: '/@:slug([a-zA-Z0-9_.:-]*)',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tz.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function formatDatetime(timestamp, minDate = {val: 1, unit: "day"}) {
let d = dayjs(timestamp);
if (timestamp) {
if (d.year() < dayjs().year()) return d.format("D MMM'YY HH:mm");
if (d.add(minDate.val, minDate.unit).isBefore(dayjs())) return d.format("D MMM HH:mm");
if (d.add(minDate.val, minDate.unit).isBefore(dayjs())) return d.format("D MMM'YY HH:mm");
return d.fromNow();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/constant/ConstantInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</v-list-item-subtitle
>
<v-list-item-title class="body-2">
{{ field.value }}
{{ field.type === 'timestamp' ? helpers.formatDatetime(field.value) : field.value }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
Expand Down
10 changes: 9 additions & 1 deletion src/views/constant/ReferenceContract.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<v-skeleton-loader :loading="loading" type="article" transition="fade-transition">
<v-data-table
:items="contracts"
v-if="contracts.length"
hide-default-header
:class="['ba-1 mt-4 avg-gas-consumption', 'hide-pagination-count']"
hide-default-footer
Expand Down Expand Up @@ -53,7 +54,9 @@
</div>
</template>
</v-data-table>

<span v-else class="not-found-text">
There are no references to this constant
</span>
</v-skeleton-loader>
</v-fade-transition>
</div>
Expand Down Expand Up @@ -99,3 +102,8 @@ export default {
}
}
</script>
<style scoped>
.not-found-text {
color: rgba(255, 255, 255, 0.5);
}
</style>