Skip to content

Commit

Permalink
feat: Move time calculation to MDW (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
janmichek committed Oct 23, 2023
1 parent 1bac63d commit bc2d7bd
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 83 deletions.
2 changes: 0 additions & 2 deletions src/components/DashboardStateChannelsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
</template>
<script setup>
import AppPanel from '@/components/AppPanel'
import DashboardStateChannelsSwiper from '@/components/DashboardStateChannelsSwiper'
import DashboardStateChannelsTable from '@/components/DashboardStateChannelsTable'
import { stateChannelsHints } from '@/utils/hints/stateChannelsHints'
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/components/DashboardStateChannelsSwiper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
</app-tooltip>
</th>
<td class="dashboard-state-channels-swiper__data">
{{ channel.updateType }}
{{ channel.lastTxType }}
</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion src/components/DashboardStateChannelsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
:height="channel.updatedHeight"
:datetime="channel.updated"/>
</td>
<td>{{ channel.updateType }}</td>
<td>{{ channel.lastTxType }}</td>
</tr>
</tbody>
</table>
Expand Down
4 changes: 2 additions & 2 deletions src/components/OraclesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
</td>
<td class="oracles-table__data">
<block-time-cell
:height="oracle.activatedHeight"
:datetime="oracle.activated"/>
:height="oracle.registeredHeight"
:datetime="oracle.registered"/>
</td>
<td class="oracles-table__data">
<block-time-cell
Expand Down
4 changes: 2 additions & 2 deletions src/components/OraclesTableCondensed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
</th>
<td class="oracles-table-condensed__data">
<block-time-cell
:height="oracle.activatedHeight"
:datetime="oracle.activated"/>
:height="oracle.registeredHeight"
:datetime="oracle.registered"/>
</td>
</tr>
<tr class="oracles-table-condensed__row">
Expand Down
2 changes: 1 addition & 1 deletion src/components/StateChannelsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
:height="channel.updatedHeight"
:datetime="channel.updated"/>
</td>
<td>{{ channel.updateType }}</td>
<td>{{ channel.lastTxType }}</td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion src/components/StateChannelsTableCondensed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
</app-tooltip>
</th>
<td class="state-channels-table-condensed__data">
{{ channel.updateType }}
{{ channel.lastTxType }}
</td>
</tr>
</tbody>
Expand Down
6 changes: 2 additions & 4 deletions src/stores/contractDetails.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { defineStore, storeToRefs } from 'pinia'
import { defineStore } from 'pinia'
import { useRuntimeConfig } from 'nuxt/app'
import useAxios from '@/composables/useAxios'
import { adaptContractDetails, adaptContractEvents, adaptTransactions } from '@/utils/adapters'
import { useRecentBlocksStore } from '@/stores/recentBlocks'

export const useContractDetailsStore = defineStore('contractDetails', () => {
const { NODE_URL, MIDDLEWARE_URL } = useRuntimeConfig().public
const axios = useAxios()
const { blockHeight } = storeToRefs(useRecentBlocksStore())

const contractId = ref(null)
const contractCallsCount = ref(null)
Expand All @@ -21,7 +19,7 @@ export const useContractDetailsStore = defineStore('contractDetails', () => {

const contractEvents = computed(() => {
return rawContractEvents.value
? adaptContractEvents(rawContractEvents.value, blockHeight.value)
? adaptContractEvents(rawContractEvents.value)
: null
})

Expand Down
6 changes: 2 additions & 4 deletions src/stores/dashboardStateChannels.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { defineStore, storeToRefs } from 'pinia'
import { defineStore } from 'pinia'
import { useRuntimeConfig } from 'nuxt/app'
import useAxios from '@/composables/useAxios'
import { adaptDashboardStateChannels } from '@/utils/adapters'
import { useRecentBlocksStore } from '@/stores/recentBlocks'

export const useDashboardStateChannelsStore = defineStore('dashboardStateChannels', () => {
const { MIDDLEWARE_URL } = useRuntimeConfig().public
const axios = useAxios()
const { blockHeight } = storeToRefs(useRecentBlocksStore())
const rawStateChannels = ref(null)

const stateChannels = computed(() =>
rawStateChannels.value
? adaptDashboardStateChannels(rawStateChannels.value, blockHeight.value)
? adaptDashboardStateChannels(rawStateChannels.value)
: null,
)

Expand Down
2 changes: 1 addition & 1 deletion src/stores/nameDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const useNameDetailsStore = defineStore('nameDetails', () => {
return rawName.value?.hash || rawName.value?.info.lastBid.tx.nameId
})
const nameActions = computed(() => {
return rawNameActions.value ? adaptNameActions(rawNameActions.value, blockHeight.value) : null
return rawNameActions.value ? adaptNameActions(rawNameActions.value) : null
})
const hasNameHistory = computed(() => {
return !!nameHash.value
Expand Down
2 changes: 1 addition & 1 deletion src/stores/names.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const useNamesStore = defineStore('names', () => {
})
const inAuctionNames = computed(() => {
return rawInAuctionNames.value
? adaptInAuctionNames(rawInAuctionNames.value, blockHeight.value)
? adaptInAuctionNames(rawInAuctionNames.value)
: null
})
const auctionsEndingSoon = computed(() => inAuctionNames.value?.data.slice(0, 4))
Expand Down
7 changes: 2 additions & 5 deletions src/stores/oracleDetails.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { defineStore, storeToRefs } from 'pinia'
import { defineStore } from 'pinia'
import { useRuntimeConfig } from 'nuxt/app'
import useAxios from '@/composables/useAxios'
import { adaptOracleDetails, adaptOracleEvents } from '@/utils/adapters'
import { useRecentBlocksStore } from '@/stores/recentBlocks'

export const useOracleDetailsStore = defineStore('oracleDetails', () => {
const { MIDDLEWARE_URL } = useRuntimeConfig().public
const { blockHeight } = storeToRefs(useRecentBlocksStore())
const axios = useAxios()

const oracleId = ref(null)
Expand All @@ -18,7 +16,6 @@ export const useOracleDetailsStore = defineStore('oracleDetails', () => {
? adaptOracleDetails(
rawOracle.value,
lastExtendedTx.value,
blockHeight.value,
lastQueryTx.value,
)
: null,
Expand All @@ -41,7 +38,7 @@ export const useOracleDetailsStore = defineStore('oracleDetails', () => {
}

async function fetchOracle() {
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/oracles/${oracleId.value}`)
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/oracles/${oracleId.value}?tx_hash=true`)
rawOracle.value = data
}

Expand Down
7 changes: 2 additions & 5 deletions src/stores/oracles.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { defineStore, storeToRefs } from 'pinia'
import { defineStore } from 'pinia'
import { useRuntimeConfig } from 'nuxt/app'
import useAxios from '@/composables/useAxios'
import { adaptOracles } from '@/utils/adapters'
import { useRecentBlocksStore } from '@/stores/recentBlocks'

export const useOraclesStore = defineStore('oracles', () => {
const { MIDDLEWARE_URL } = useRuntimeConfig().public
const axios = useAxios()
const recentBlocksStore = useRecentBlocksStore()
const { blockHeight } = storeToRefs(recentBlocksStore)

const rawOracles = ref(null)
const rawOraclesCount = ref(null)
Expand All @@ -22,7 +19,7 @@ export const useOraclesStore = defineStore('oracles', () => {

const oracles = computed(() => {
return rawOracles.value
? adaptOracles(rawOracles.value, blockHeight.value)
? adaptOracles(rawOracles.value)
: null
})

Expand Down
8 changes: 4 additions & 4 deletions src/stores/stateChannelDetails.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { defineStore, storeToRefs } from 'pinia'
import { defineStore } from 'pinia'
import { useRuntimeConfig } from 'nuxt/app'
import useAxios from '@/composables/useAxios'
import { adaptStateChannelDetails, adaptTransactions } from '@/utils/adapters'
import { useRecentBlocksStore } from '@/stores/recentBlocks'

export const useStateChannelDetailsStore = defineStore('stateChannelDetails', () => {
const { MIDDLEWARE_URL } = useRuntimeConfig().public
const axios = useAxios()
const { blockHeight } = storeToRefs(useRecentBlocksStore())

const stateChannelId = ref(null)
const rawStateChannel = ref(null)
Expand All @@ -19,7 +17,6 @@ export const useStateChannelDetailsStore = defineStore('stateChannelDetails', ()
? adaptStateChannelDetails(
rawStateChannel.value,
rawStateChannelCreateTx.value,
blockHeight.value,
)
: null,
)
Expand All @@ -40,14 +37,17 @@ export const useStateChannelDetailsStore = defineStore('stateChannelDetails', ()

return true
}

async function fetchStateChannel() {
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/channels/${stateChannelId.value}`)
rawStateChannel.value = data
}

async function fetchStateChannelCreateTx() {
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/channels/${stateChannelId.value}/updates?direction=forward&limit=1`)
rawStateChannelCreateTx.value = data.data[0]
}

async function fetchStateChannelTransactions({ limit, queryParameters } = {}) {
rawStateChannelTransactions.value = null

Expand Down
6 changes: 2 additions & 4 deletions src/stores/stateChannels.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { useRuntimeConfig } from 'nuxt/app'
import { defineStore, storeToRefs } from 'pinia'
import { defineStore } from 'pinia'
import useAxios from '@/composables/useAxios'
import { adaptStateChannels } from '@/utils/adapters'
import { useRecentBlocksStore } from '@/stores/recentBlocks'

export const useStateChannelsStore = defineStore('stateChannels', () => {
const { MIDDLEWARE_URL } = useRuntimeConfig().public
const axios = useAxios()
const { blockHeight } = storeToRefs(useRecentBlocksStore())

const rawStateChannels = ref(null)
const stateChannelsCount = ref(null)
const stateChannels = computed(() => {
return rawStateChannels.value
? adaptStateChannels(rawStateChannels.value, blockHeight.value)
? adaptStateChannels(rawStateChannels.value)
: null
})

Expand Down
3 changes: 1 addition & 2 deletions src/stores/tokenDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ export const useTokenDetailsStore = defineStore('tokenDetails', () => {
)

const tokenEvents = computed(() => {
const store = useRecentBlocksStore()
return rawTokenEvents.value
? adaptTokenEvents(rawTokenEvents.value, store.blockHeight)
? adaptTokenEvents(rawTokenEvents.value)
: null
})

Expand Down

0 comments on commit bc2d7bd

Please sign in to comment.