Skip to content

Commit

Permalink
feat: Migrate to v3 endpoints pt1 (#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
janmichek authored Apr 8, 2024
1 parent 4ec85a2 commit 99863de
Show file tree
Hide file tree
Showing 32 changed files with 70 additions and 64 deletions.
2 changes: 1 addition & 1 deletion src/components/ContractDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const contractNodeUrl = computed(() =>
`${NODE_URL}/v3/contracts/${props.contractDetails.id}`,
)
const contractMiddlewareUrl = computed(() =>
`${MIDDLEWARE_URL}/v2/contracts/${props.contractDetails.id}`,
`${MIDDLEWARE_URL}/v3/contracts/${props.contractDetails.id}`,
)
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/components/ContractsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const loadNextContracts = () => {
}
const loadContracts = () => {
fetchContracts(`/v2/txs?type=contract_create&limit=${limit.value}`)
fetchContracts(`/v3/transactions?type=contract_create&limit=${limit.value}`)
fetchContractsCount()
pageIndex.value = 1
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/KeyblockDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const keyblockNodeUrl = computed(() =>
`${NODE_URL}/v3/key-blocks/hash/${props.keyblockDetails.hash}`,
)
const keyblockMiddlewareUrl = computed(() =>
`${MIDDLEWARE_URL}/v2/key-blocks/${props.keyblockDetails.hash}`,
`${MIDDLEWARE_URL}/v3/key-blocks/${props.keyblockDetails.hash}`,
)
const isNextKeyblockMined = computed(() =>
props.keyblockDetails.height < latestBlockHeight.value,
Expand Down
2 changes: 1 addition & 1 deletion src/components/MicroblockDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const microblockNodeUrl = computed(() =>
`${NODE_URL}/v3/micro-blocks/hash/${props.microblockDetails.hash}/header`,
)
const microblockMiddlewareUrl = computed(() =>
`${MIDDLEWARE_URL}/v2/micro-blocks/${props.microblockDetails.hash}`,
`${MIDDLEWARE_URL}/v3/micro-blocks/${props.microblockDetails.hash}`,
)
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/components/MicroblockTransactionsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function loadTransactions() {
const { txType } = route.query
const txTypeOption = TX_TYPES_OPTIONS.find(option => option.typeQuery === txType)
selectedTxType.value = txTypeOption || TX_TYPES_OPTIONS[0]
await fetchMicroblockTransactions({ queryParameters: `/v2/micro-blocks/${route.params.id}/txs/?limit=${limit.value}${selectedTxType.value.typeQuery ? '&type=' + selectedTxType.value.typeQuery : ''}` })
await fetchMicroblockTransactions({ queryParameters: `/v3/micro-blocks/${route.params.id}/transactions/?limit=${limit.value}${selectedTxType.value.typeQuery ? '&type=' + selectedTxType.value.typeQuery : ''}` })
pageIndex.value = 1
}
Expand Down
16 changes: 10 additions & 6 deletions src/components/NetworkSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,27 @@ import { computed, ref } from 'vue'
import { useRuntimeConfig } from 'nuxt/app'
import AppSelect from '@/components/AppSelect'
const config = useRuntimeConfig()
const {
NETWORK_NAME,
ALTERNATIVE_NETWORK_NAME,
ALTERNATIVE_NETWORK_URL,
} = useRuntimeConfig().public
const selectedNetwork = ref({
name: config.public.NETWORK_NAME,
name: NETWORK_NAME,
})
const networks = ref([
{
name: config.public.NETWORK_NAME,
name: NETWORK_NAME,
url: null,
},
{
name: config.public.ALTERNATIVE_NETWORK_NAME,
url: config.public.ALTERNATIVE_NETWORK_URL,
name: ALTERNATIVE_NETWORK_NAME,
url: ALTERNATIVE_NETWORK_URL,
},
])
const hasAlternativeNetwork = computed(() => !!config.public.ALTERNATIVE_NETWORK_URL)
const hasAlternativeNetwork = computed(() => !!ALTERNATIVE_NETWORK_URL)
const navigate = selectedOption => window.location.replace(selectedOption.url)
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/components/OracleDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const oracleNodeUrl = computed(() =>
)
const oracleMiddlewareUrl = computed(() =>
`${MIDDLEWARE_URL}/v2/oracles/${props.oracleDetails.id}`,
`${MIDDLEWARE_URL}/v3/oracles/${props.oracleDetails.id}`,
)
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/components/OracleEventsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function loadNextEvents() {
if (process.client) {
const limit = computed(() => isDesktop() ? 10 : 3)
fetchOracleEvents(`/v2/oracles/${route.params.id}/responses?limit=${limit.value}`)
fetchOracleEvents(`/v3/oracles/${route.params.id}/responses?limit=${limit.value}`)
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/components/OraclesPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function loadOracles() {
const { state } = route.query
const oracleStateOption = ORACLE_STATES_OPTIONS.find(option => option.stateQuery === state)
selectedOracleState.value = oracleStateOption || ORACLE_STATES_OPTIONS[0]
await fetchOracles(`/v2/oracles?limit=${limit.value}${selectedOracleState.value.stateQuery ? '&state=' + selectedOracleState.value.stateQuery : ''}`)
await fetchOracles(`/v3/oracles?limit=${limit.value}${selectedOracleState.value.stateQuery ? '&state=' + selectedOracleState.value.stateQuery : ''}`)
await fetchOraclesCount()
pageIndex.value = 1
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/StateChannelDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const props = defineProps({
},
})
const stateChannelMiddlewareUrl = `${MIDDLEWARE_URL}/v2/channels/${props.stateChannelDetails.id}`
const stateChannelMiddlewareUrl = `${MIDDLEWARE_URL}/v3/channels/${props.stateChannelDetails.id}`
</script>

<style scoped>
Expand Down
4 changes: 2 additions & 2 deletions src/components/TokenSymbolIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { useRuntimeConfig } from 'nuxt/app'
import { LAEX_CONTRACT_ID } from '@/utils/constants'
const config = useRuntimeConfig()
const { AE_TOKEN_ID } = useRuntimeConfig().public
const props = defineProps({
contractId: {
Expand All @@ -26,7 +26,7 @@ const props = defineProps({
},
})
const isAe = computed(() => props.contractId === config.public.AE_TOKEN_ID)
const isAe = computed(() => props.contractId === AE_TOKEN_ID)
const isLaex = computed(() => props.contractId === LAEX_CONTRACT_ID)
</script>
2 changes: 1 addition & 1 deletion src/components/TransactionGeneralPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const transactionNodeUrl = computed(() => {
})
const transactionMiddlewareUrl = computed(() => {
return `${MIDDLEWARE_URL}/v2/txs/${props.transactionDetails.hash}`
return `${MIDDLEWARE_URL}/v3/transactions/${props.transactionDetails.hash}`
})
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/components/TransactionsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function loadTransactions() {
const { txType } = route.query
const txTypeOption = TX_TYPES_OPTIONS.find(option => option.typeQuery === txType)
selectedTxType.value = txTypeOption || TX_TYPES_OPTIONS[0]
await fetchTransactions(`/v2/txs?limit=${limit.value}${selectedTxType.value.typeQuery ? '&type=' + selectedTxType.value.typeQuery : ''}`)
await fetchTransactions(`/v3/transactions?limit=${limit.value}${selectedTxType.value.typeQuery ? '&type=' + selectedTxType.value.typeQuery : ''}`)
await fetchTransactionsCount(selectedTxType.value.typeQuery)
pageIndex.value = 1
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/names/[name].vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ try {
if (hasNameHistory && process.client) {
const limit = isDesktop() ? 10 : 3
fetchNameActions({ queryParameters: `/v2/accounts/${nameHash.value}/activities?limit=${limit}` })
fetchNameActions({ queryParameters: `/v3/accounts/${nameHash.value}/activities?limit=${limit}` })
}
</script>
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/sentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import * as Sentry from '@sentry/vue'
import { BrowserTracing } from '@sentry/tracing'

export default defineNuxtPlugin(({ vueApp }) => {
export default defineNuxtPlugin(({vueApp}) => {
if (process.server) {
return
}

const config = useRuntimeConfig()
const {SENTRY_DSN, APP_DOMAIN} = useRuntimeConfig().public

if (!config.public.SENTRY_DSN || !config.public.APP_DOMAIN) {
if (!SENTRY_DSN || !APP_DOMAIN) {
console.warn('Sentry configuration is not set therefore it will not be initialized.')
return
}
Expand All @@ -18,11 +18,11 @@ export default defineNuxtPlugin(({ vueApp }) => {

Sentry.init({
app: vueApp,
dsn: config.public.SENTRY_DSN,
dsn: SENTRY_DSN,
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: [config.public.APP_DOMAIN, /^\//],
tracingOrigins: [APP_DOMAIN, /^\//],
}),
],
beforeSend: (event) => {
Expand Down
4 changes: 2 additions & 2 deletions src/stores/accountDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const useAccountStore = defineStore('account', () => {

async function fetchAccountActivities({ accountId, limit, queryParameters } = {}) {
rawAccountActivities.value = null
const defaultParameters = `/v2/accounts/${accountId}/activities?limit=${limit ?? 10}`
const defaultParameters = `/v3/accounts/${accountId}/activities?limit=${limit ?? 10}`
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
rawAccountActivities.value = data
}
Expand All @@ -139,7 +139,7 @@ export const useAccountStore = defineStore('account', () => {
return
}

const transactionsUrl = new URL(`${MIDDLEWARE_URL}/v2/txs`)
const transactionsUrl = new URL(`${MIDDLEWARE_URL}/v3/transactions`)
transactionsUrl.searchParams.append('direction', 'backward')
transactionsUrl.searchParams.append('limit', limit ?? 10)

Expand Down
4 changes: 2 additions & 2 deletions src/stores/blockchainStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const useBlockchainStatsStore = defineStore('blockchainStats', () => {
const totalTokenSupply = ref(null)

async function fetchTotalStats() {
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/totalstats?limit=1`)
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/totalstats?limit=1`)
const lastBlock = data.data[0]
activeOraclesCount.value = lastBlock.activeOracles
oraclesCount.value = lastBlock.activeOracles + lastBlock.inactiveOracles
Expand All @@ -34,7 +34,7 @@ export const useBlockchainStatsStore = defineStore('blockchainStats', () => {
}

async function fetchMaxTps() {
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/stats`)
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/stats`)
maxTps.value = data.maxTransactionsPerSecond
}

Expand Down
4 changes: 2 additions & 2 deletions src/stores/contractDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const useContractDetailsStore = defineStore('contractDetails', () => {

async function fetchContractCreationTx() {
contractCreationTx.value = null
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/txs?limit=1&contract=${contractId.value}&direction=forward`)
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/transactions?limit=1&contract=${contractId.value}&direction=forward`)
contractCreationTx.value = data?.data[0]
}

Expand Down Expand Up @@ -106,7 +106,7 @@ export const useContractDetailsStore = defineStore('contractDetails', () => {
return
}

const transactionsUrl = new URL(`${MIDDLEWARE_URL}/v2/txs`)
const transactionsUrl = new URL(`${MIDDLEWARE_URL}/v3/transactions`)
transactionsUrl.searchParams.append('direction', 'backward')
transactionsUrl.searchParams.append('limit', limit ?? 10)
transactionsUrl.searchParams.append('type', 'contract_call')
Expand Down
2 changes: 1 addition & 1 deletion src/stores/contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useContractsStore = defineStore('contracts', () => {
)

async function fetchContracts(queryParameters = null) {
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || '/v2/txs?type=contract_create&limit=10'}`)
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || '/v3/transactions?type=contract_create&limit=10'}`)

const verifiedContracts = await fetchVerifiedContracts(data)
if (verifiedContracts) {
Expand Down
2 changes: 1 addition & 1 deletion src/stores/dashboardStateChannels.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const useDashboardStateChannelsStore = defineStore('dashboardStateChannel
)

async function fetchStateChannels() {
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/channels?&limit=4`)
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/channels?&limit=4`)
rawStateChannels.value = data.data
}

Expand Down
8 changes: 4 additions & 4 deletions src/stores/keyblockDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const useKeyblockDetailsStore = defineStore('keyblockDetails', () => {
async function fetchKeyblockDetails(keyblockId) {
rawKeyblock.value = null
try {
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/key-blocks/${keyblockId}`)
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/key-blocks/${keyblockId}`)
rawKeyblock.value = data
} catch (error) {
if (error.response?.status === 404) {
Expand All @@ -37,20 +37,20 @@ export const useKeyblockDetailsStore = defineStore('keyblockDetails', () => {

async function fetchKeyblockMicroblocks({ queryParameters, limit, keyblockHash } = {}) {
rawKeyblockMicroblocks.value = null
const defaultParameters = `/v2/key-blocks/${keyblockHash}/micro-blocks?limit=${limit ?? 10}`
const defaultParameters = `/v3/key-blocks/${keyblockHash}/micro-blocks?limit=${limit ?? 10}`
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
rawKeyblockMicroblocks.value = data
}

async function fetchKeyblockDeltaStats(keyblockHeight) {
keyblockDeltaStats.value = null
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/deltastats?scope=gen:${keyblockHeight}`)
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/deltastats?scope=gen:${keyblockHeight}`)
keyblockDeltaStats.value = data.data[0]
}

async function isKeyblockAvailable(keyblockHash) {
try {
await axios.get(`${MIDDLEWARE_URL}/v2/key-blocks/${keyblockHash}`)
await axios.get(`${MIDDLEWARE_URL}/v3/key-blocks/${keyblockHash}`)
return true
} catch (error) {
if (error.response.status === 404) {
Expand Down
6 changes: 3 additions & 3 deletions src/stores/microblockDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export const useMicroblockDetailsStore = defineStore('microblockDetails', () =>

async function fetchMicroblock(microblockHash) {
rawMicroblock.value = null
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/micro-blocks/${microblockHash}`)
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/micro-blocks/${microblockHash}`)
rawMicroblock.value = data
}

async function fetchMicroblockTransactions({ queryParameters, limit, microblockHash } = {}) {
rawMicroblockTransactions.value = null
const defaultParameters = `/v2/micro-blocks/${microblockHash}/txs?limit=${limit ?? 10}`
const { data } = await axios.get(`${useRuntimeConfig().public.MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
const defaultParameters = `/v3/micro-blocks/${microblockHash}/transactions?limit=${limit ?? 10}`
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
rawMicroblockTransactions.value = data
}

Expand Down
6 changes: 3 additions & 3 deletions src/stores/nftDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ export const useNftDetailsStore = defineStore('nftDetails', () => {
async function fetchNftInventory({ queryParameters, limit } = {}) {
nftInventory.value = null
const defaultParameters = `/v2/aex141/${nftId.value}/templates?limit=${limit ?? 10}`
const { data } = await axios.get(`${useRuntimeConfig().public.MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
nftInventory.value = data
}

async function fetchNftOwners({ queryParameters, limit } = {}) {
nftOwners.value = null
const defaultParameters = `/v2/aex141/${nftId.value}/owners?limit=${limit ?? 10}`
const { data } = await axios.get(`${useRuntimeConfig().public.MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
nftOwners.value = data
}

async function fetchNftTransfers({ queryParameters, limit } = {}) {
rawNftTransfers.value = null
const defaultParameters = `/v2/aex141/transfers/${nftId.value}?limit=${limit ?? 10}`
const { data } = await axios.get(`${useRuntimeConfig().public.MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
rawNftTransfers.value = data
}

Expand Down
6 changes: 3 additions & 3 deletions src/stores/oracleDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ export const useOracleDetailsStore = defineStore('oracleDetails', () => {
}

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

async function fetchLastExtendedTx() {
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/txs?direction=backward&limit=1&type=oracle_extend&oracle=${oracleId.value}`)
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/transactions?direction=backward&limit=1&type=oracle_extend&oracle=${oracleId.value}`)
lastExtendedTx.value = data.data?.[0]
}

async function fetchOracleEvents(queryParameters = null) {
rawEvents.value = null
const defaultParameters = `/v2/oracles/${oracleId.value}/responses`
const defaultParameters = `/v3/oracles/${oracleId.value}/responses`

try {
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
Expand Down
4 changes: 2 additions & 2 deletions src/stores/oracles.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const useOraclesStore = defineStore('oracles', () => {

async function fetchOracles(queryParameters = null) {
rawOracles.value = null
const defaultParameters = '/v2/oracles?direction=backward&limit=10'
const defaultParameters = '/v3/oracles?direction=backward&limit=10'
const { data } = await axios.get(
`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`,
)
Expand All @@ -42,7 +42,7 @@ export const useOraclesStore = defineStore('oracles', () => {

async function fetchOraclesCount() {
rawOraclesCount.value = null
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/totalstats?limit=1`)
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/totalstats?limit=1`)
rawOraclesCount.value = data.data[0]
}

Expand Down
Loading

0 comments on commit 99863de

Please sign in to comment.