Skip to content

Commit

Permalink
Fix: don't receive total_size for empty big maps (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored Oct 21, 2023
1 parent 7065b48 commit 16b8f70
Showing 1 changed file with 19 additions and 29 deletions.
48 changes: 19 additions & 29 deletions src/views/big_map/BigMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,32 +101,34 @@ export default {
}),
created() {
this.getBigMap();
this.getBigMapActions();
this.getTotalBytes();
},
methods: {
...mapActions(["showError"]),
shortcutOnly,
getBigMap() {
this.api
if (this.loading) return;
this.loading = true;
return this.api
.getContractBigMap(this.network, this.ptr)
.then(res => {
if (!res) return;
this.bigmap = res;
.then(bigMap => {
if (!bigMap) return;
this.bigmap = bigMap;
return this.api
.getContractBigMapActions(this.network, this.ptr)
})
.then((actions) => {
if (!actions) return;
if (!actions.items) return;
this.actions = actions.items;
if (this.bigmap.total_keys)
return this.rpc
.getBigMapTotalBytes(this.network, "head", this.ptr)
})
.catch(err => {
console.log(err);
this.showError(err);
});
},
getBigMapActions() {
this.loading = true;
this.api
.getContractBigMapActions(this.network, this.ptr)
.then((res) => {
if (!res) return;
if (!res.items) return;
this.actions = res.items;
this.totalBytes = parseInt(res.data, 10);
})
.catch((err) => {
console.log(err);
Expand All @@ -138,18 +140,6 @@ export default {
this.loading = false;
});
},
getTotalBytes() {
this.rpc
.getBigMapTotalBytes(this.network, "head", this.ptr)
.then((res) => {
if (!res) return;
this.totalBytes = parseInt(res.data, 10);
})
.catch((err) => {
console.log(err);
this.showError(err);
});
},
},
watch: {
ptr: 'getBigMap'
Expand Down

0 comments on commit 16b8f70

Please sign in to comment.