Skip to content

Commit

Permalink
Merge pull request #663 from matter-labs/jazzandrock/explorer
Browse files Browse the repository at this point in the history
Next explorer fixes batch
  • Loading branch information
jazzandrock authored Jun 4, 2020
2 parents 3fd164d + 636ad82 commit 230e5a0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion core/storage/src/chain/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl<'a> BlockSchema<'a> {
select * from priority_ops \
) \
select * from everything \
order by created_at \
order by created_at desc \
",
block = block
);
Expand Down
7 changes: 0 additions & 7 deletions js/explorer/src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ export class Client {
url: `${baseUrl()}/search?query=${query}`,
});
}

searchAccount(address) {
return fetch({
method: 'get',
url: `${baseUrl()}/account/${address}`,
});
}

searchTx(txHash) {
return fetch({
Expand Down
4 changes: 2 additions & 2 deletions js/explorer/src/CopyableAddress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<span class="link-html-span mr-1" v-html="linkHtml" />
<i v-if="tooltipRight===true"
@click="clicked"
class="far fa-copy"
class="far fa-copy cursorpointer"
v-b-tooltip.hover.right="hover_title"
v-clipboard="address"
@mouseenter="mouseEntered"
></i>
<i v-else
@click="clicked"
class="far fa-copy"
class="far fa-copy cursorpointer"
v-b-tooltip="hover_title"
v-clipboard="address"
@mouseenter="mouseEntered"
Expand Down
14 changes: 11 additions & 3 deletions js/explorer/src/ReadinessStatus.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<template>
<!-- <img class="loading-image m-0 p-0" src="./assets/loading.gif" /> -->
<b-spinner v-if="getStatus == 0" small label="Small Spinner" />
<img v-else-if="getStatus == 1" small class="readiness-image" src="./assets/2.svg" />
<img v-else-if="getStatus == 2" small class="readiness-image" src="./assets/1.svg" />
<span class="mr-1">
<i v-if="getStatus == -1" class="fas fa-times red"></i>
<b-spinner v-else-if="getStatus == 0" small label="Small Spinner" />
<img v-else-if="getStatus == 1" small class="readiness-image" src="./assets/2.svg" />
<img v-else-if="getStatus == 2" small class="readiness-image" src="./assets/1.svg" />
</span>
</template>

<script>
Expand All @@ -11,6 +14,7 @@ export default {
props: ['status'],
computed: {
getStatus() {
if ([-1].includes(this.status)) return -1;
if ([0].includes(this.status)) return 0;
if ([1].includes(this.status)) return 1;
if ([2].includes(this.status)) return 2;
Expand All @@ -23,5 +27,9 @@ export default {
<style scoped>
.readiness-image {
height: 1.33em;
margin-right: -0.25em;
}
.red {
color: red;
}
</style>
6 changes: 2 additions & 4 deletions js/explorer/src/SearchField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ export default {
let tx = await client.searchTx(query).catch(() => null);
if (tx && tx.tx_type) {
const prefix = tx && tx.tx && tx.tx.priority_op
? '0x'
: 'sync-tx:';
const prefix = '';
this.$router.push('/transactions/' + prefix + query);
this.searching = false;
return;
}
let account = await client.searchAccount(query).catch(() => null);
let account = await client.getAccount('0x' + query).catch(() => null);
if (account && account.id) {
this.$router.push('/accounts/0x' + query);
this.searching = false;
Expand Down
32 changes: 17 additions & 15 deletions js/explorer/src/Transaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
<CopyableAddress class="normalize-text"
v-if="data.item['name'] == 'From'"
:address="txData.from"
:linkHtml="`${data.item['value']} `"
:linkHtml="data.item['value']"
/>
<CopyableAddress class="normalize-text"
v-else-if="data.item['name'] == 'To'"
:address="txData.to"
:linkHtml="`${data.item['value']} `"
:linkHtml="data.item['value']"
/>
<CopyableAddress class="normalize-text"
v-else-if="data.item['name'] == 'Account'"
:address="txData.from"
:linkHtml="`${data.item['value']} `"
:linkHtml="data.item['value']"
/>
<CopyableAddress class="normalize-text"
v-else-if="['zkSync tx hash', 'Tx hash'].includes(data.item['name'])"
v-else-if="['zkSync tx hash', 'ETH Tx hash'].includes(data.item['name'])"
:address="tx_hash"
:linkHtml="`${data.item['value']} `"
:linkHtml="data.item['value']"
/>
<span v-else-if="data.item.name == 'Status'">
<ReadinessStatus :status="readyStateFromString(data.item.value)" />
Expand Down Expand Up @@ -97,6 +97,7 @@ export default {
methods: {
readyStateFromString(s) {
return {
"Failed": -1,
"Initiated": 0,
"Pending": 1,
"Complete": 2,
Expand All @@ -112,11 +113,11 @@ export default {
return;
}
txData.tokenName = (txData.token === -1 || txData.token == 65535) ? "" : tokens[txData.token].syncSymbol;
txData.tokenName = txData.token === -1 ? "" : tokens[txData.token].syncSymbol;
if (txData.tx_type == "Deposit" || txData.tx_type == "FullExit") {
txData.feeTokenName = "ETH";
} else {
txData.feeTokenName = txData.token === -1 || txData.token == 65535? "" : tokens[txData.token].syncSymbol;
txData.feeTokenName = txData.token === -1 ? "" : tokens[txData.token].syncSymbol;
}
txData.amount = txData.amount == "unknown amount" ? "" : txData.amount;
Expand Down Expand Up @@ -182,11 +183,11 @@ export default {
: `${this.routerBase}accounts/${this.txData.to}`;
const onchain_from
= this.txData.tx_type == 'Deposit' ? `<i class="fas fa-external-link-alt"></i>`
= this.txData.tx_type == 'Deposit' ? ` <i class="fas fa-external-link-alt"></i>`
: '';
const onchain_to
= this.txData.tx_type == 'Withdrawal' ? `<i class="fas fa-external-link-alt"></i>`
= this.txData.tx_type == 'Withdrawal' ? ` <i class="fas fa-external-link-alt"></i>`
: '';
const target_from
Expand Down Expand Up @@ -214,25 +215,25 @@ export default {
{ name: 'zkSync tx hash', value: tx_hash},
{ name: "Type", value: `${this.txData.tx_type}` },
{ name: "Status", value: `${this.txData.status}` },
{ name: "Account", value: `<a ${target_from} href="${link_from}">${this.txData.from} ${onchain_from}</a>` },
{ name: "Account", value: `<a ${target_from} href="${link_from}">${this.txData.from}${onchain_from}</a>` },
{ name: "New signer key hash", value: `${this.txData.to.replace('sync:', '')}`},
{ name: "Created at", value: formatDate(this.txData.created_at) },
]
: this.txData.tx_type == "Deposit" || this.txData.tx_type == "FullExit"
? [
{ name: 'Tx hash', value: tx_hash},
{ name: 'ETH Tx hash', value: tx_hash},
{ name: "Type", value: `${this.txData.tx_type}` },
{ name: "Status", value: `${this.txData.status}` },
{ name: "From", value: `${layer_from} <a ${target_from} href="${link_from}"> ${this.txData.from} ${onchain_from}</a>` },
{ name: "To", value: `${layer_to} <a ${target_to} href="${link_to}"> ${this.txData.to} ${onchain_to}</a>` },
{ name: "From", value: `${layer_from} <a ${target_from} href="${link_from}">${this.txData.from}${onchain_from}</a>` },
{ name: "To", value: `${layer_to} <a ${target_to} href="${link_to}">${this.txData.to}${onchain_to}</a>` },
{ name: "Amount", value: `${this.txData.tokenName} ${formatToken(this.txData.amount, this.txData.tokenName)}` },
]
: [
{ name: 'zkSync tx hash', value: tx_hash},
{ name: "Type", value: `${this.txData.tx_type}` },
{ name: "Status", value: `${this.txData.status}` },
{ name: "From", value: `${layer_from} <a ${target_from} href="${link_from}">${this.txData.from} ${onchain_from}</a>` },
{ name: "To", value: `${layer_to} <a ${target_to} href="${link_to}"> ${this.txData.to} ${onchain_to}</a>` },
{ name: "From", value: `${layer_from} <a ${target_from} href="${link_from}">${this.txData.from}${onchain_from}</a>` },
{ name: "To", value: `${layer_to} <a ${target_to} href="${link_to}">${this.txData.to}${onchain_to}</a>` },
{ name: "Amount", value: `${this.txData.tokenName} ${formatToken(this.txData.amount, this.txData.tokenName)}` },
{ name: "fee", value: `${this.txData.feeTokenName} ${formatToken(this.txData.fee, this.txData.tokenName)}` },
{ name: "Created at", value: formatDate(this.txData.created_at) },
Expand All @@ -248,6 +249,7 @@ export default {
if (this.txData.fail_reason) {
rows.push({ name: "Fail reason:", value: `${this.txData.fail_reason}` });
rows.find(r => r.name == 'Status').value = 'Failed'
}
return rows;
Expand Down
4 changes: 4 additions & 0 deletions js/explorer/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
.displaynone {
display: none;
}

.cursorpointer {
cursor: pointer;
}

0 comments on commit 230e5a0

Please sign in to comment.