Skip to content

Commit

Permalink
fix: oracle operator value (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
michele-franchi authored Jun 22, 2023
1 parent 05cc185 commit c54ec0e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
10 changes: 3 additions & 7 deletions src/components/OracleDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,14 @@
</th>
<td class="oracle-details-panel__data">
<app-link
v-if="oracleDetails.creator"
:to="`/accounts/${oracleDetails.creator}`">
:to="`/accounts/${oracleDetails.operator}`">
<span class="oracle-details-panel__hash">
{{ oracleDetails.creator }}
{{ oracleDetails.operator }}
</span>
<span class="oracle-details-panel__hash-ellipse">
{{ formatEllipseHash(oracleDetails.creator) }}
{{ formatEllipseHash(oracleDetails.operator) }}
</span>
</app-link>
<template v-else>
N/A
</template>
</td>
</tr>
</tbody>
Expand Down
10 changes: 1 addition & 9 deletions src/stores/oracleDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ export const useOracleDetailsStore = defineStore('oracleDetails', () => {

const oracleId = ref(null)
const rawOracle = ref(null)
const creationTx = ref(null)
const lastExtendedTx = ref(null)
const lastQueryTx = ref(null)
const rawEvents = ref(null)

const oracleDetails = computed(() => rawOracle.value
? adaptOracleDetails(
rawOracle.value,
creationTx.value,
lastExtendedTx.value,
lastQueryTx.value,
blockHeight.value,
Expand All @@ -32,7 +30,7 @@ export const useOracleDetailsStore = defineStore('oracleDetails', () => {
oracleId.value = id

await Promise.allSettled([
fetchOracle().then(() => fetchCreationTx()),
fetchOracle(),
fetchLastQueryTx(),
fetchLastExtendedTx(),
])
Expand All @@ -45,11 +43,6 @@ export const useOracleDetailsStore = defineStore('oracleDetails', () => {
rawOracle.value = data
}

async function fetchCreationTx() {
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/txs/${rawOracle.value.register_tx_hash}`)
creationTx.value = data
}

async function fetchLastQueryTx() {
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/txs?direction=backward&limit=1&type=oracle_query&oracle=${oracleId.value}`)
lastQueryTx.value = data.data?.[0]
Expand Down Expand Up @@ -78,7 +71,6 @@ export const useOracleDetailsStore = defineStore('oracleDetails', () => {
oracleDetails,
oracleId,
rawOracle,
creationTx,
lastExtendedTx,
lastQueryTx,
oracleEvents,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export function adaptOracles(oracles, blockHeight) {
}
}

export function adaptOracleDetails(oracle, creationTx, lastExtendedTx, lastQueryTx, blockHeight) {
export function adaptOracleDetails(oracle, lastExtendedTx, lastQueryTx, blockHeight) {
const oracleDetails = {
id: oracle.oracle,
fee: formatAettosToAe(oracle.query_fee),
Expand All @@ -434,7 +434,7 @@ export function adaptOracleDetails(oracle, creationTx, lastExtendedTx, lastQuery
registeredHeight: oracle.active_from,
queryFormat: oracle.format.query,
responseFormat: oracle.format.response,
creator: creationTx?.tx.account_id,
operator: oracle.oracle.replace('ok_', 'ak_'),
lastExtended: lastExtendedTx ? DateTime.fromMillis(lastExtendedTx.micro_time) : null,
lastExtendedHeight: lastExtendedTx?.block_height,
lastQueried: lastQueryTx ? DateTime.fromMillis(lastQueryTx.micro_time) : null,
Expand Down

0 comments on commit c54ec0e

Please sign in to comment.