diff --git a/env.js b/env.js index f1df1cf4..e503f864 100644 --- a/env.js +++ b/env.js @@ -26,6 +26,7 @@ const TESTNET = { NETWORK_EXPLORER: 'https://explorer-test.telos.net', TELOS_API_ENDPOINT: 'https://api-dev.telos.net/v1', //'http://localhost:9999/v1', //for local instance of api INDEXER_API_ENDPOINT: 'https://api.testnet.teloscan.io/v1', + EXPORT_API_ENDPOINT: 'https://api.testnet.teloscan.io', VERIFIED_CONTRACTS_BUCKET: 'verified-evm-contracts-testnet', STAKED_TLOS_CONTRACT_ADDRESS: '0xa9991E4daA44922D00a78B6D986cDf628d46C4DD', TELOS_ESCROW_CONTRACT_ADDRESS: '0x7E9cF9fBc881652B05BB8F26298fFAB538163b6f', @@ -49,6 +50,7 @@ const MAINNET = { NETWORK_EXPLORER: 'https://explorer.telos.net', TELOS_API_ENDPOINT: 'https://api.telos.net/v1', //'http://localhost:9999/v1', //for local instance of api INDEXER_API_ENDPOINT: 'https://api.teloscan.io/v1', + EXPORT_API_ENDPOINT: 'https://api.teloscan.io', VERIFIED_CONTRACTS_BUCKET: 'verified-evm-contracts', STAKED_TLOS_CONTRACT_ADDRESS: '0xB4B01216a5Bc8F1C8A33CD990A1239030E60C905', TELOS_ESCROW_CONTRACT_ADDRESS: '0x95F5713A1422Aa3FBD3DCB8D553945C128ee3855', diff --git a/package.json b/package.json index 5562a09b..44ad46ec 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "ual-wombat": "^0.3.3", "universal-authenticator-library": "^0.3.0", "vue": "3", - "vue-i18n": "^9.0.0", + "vue-i18n": "^9.9.0", "vue-inline-svg": "^3.1.2", "vue-json-pretty": "^2.2.4", "vue-json-viewer": "3", diff --git a/src/boot/errorHandling.js b/src/boot/errorHandling.js index 0308ab84..5fdd3c66 100644 --- a/src/boot/errorHandling.js +++ b/src/boot/errorHandling.js @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-var-requires */ import { boot } from 'quasar/wrappers'; import { Dialog, Notify } from 'quasar'; +import { getCurrentInstance } from 'vue'; // to persist the notification and require user to dismiss pass `true` as second param const errorNotification = function(error, dismiss = false) { @@ -405,3 +406,32 @@ export { icons, NotificationAction, }; + +export function useNotifications() { + const instance = getCurrentInstance(); + if (!instance) { + throw new Error('useNotifications must be used within a setup function.'); + } + + const { proxy } = instance; + + const notifySuccessTransaction = proxy.$notifySuccessTransaction; + const notifySuccessMessage = proxy.$notifySuccessMessage; + const notifySuccessCopy = proxy.$notifySuccessCopy; + const notifyFailure = proxy.$notifyFailure; + const notifyFailureWithAction = proxy.$notifyFailureWithAction; + const notifyDisconnected = proxy.$notifyDisconnected; + const notifyNeutralMessage = proxy.$notifyNeutralMessage; + const notifyRememberInfo = proxy.$notifyRememberInfo; + + return { + notifySuccessTransaction, + notifySuccessMessage, + notifySuccessCopy, + notifyFailure, + notifyFailureWithAction, + notifyDisconnected, + notifyNeutralMessage, + notifyRememberInfo, + }; +} diff --git a/src/boot/i18n.js b/src/boot/i18n.js index e12a5af6..2d6ea50c 100644 --- a/src/boot/i18n.js +++ b/src/boot/i18n.js @@ -6,11 +6,11 @@ import messages from 'src/i18n'; let lastChosenLanguage = localStorage.getItem('language'); //if not present in local storage then check user browser language -if(!lastChosenLanguage) { +if (!lastChosenLanguage) { lastChosenLanguage = navigator.language.toLowerCase().split(/[_-]+/)[0]; } // Check if the browser language is supported, if not, fall back to 'en-us' -if(!Object.keys(messages).includes(lastChosenLanguage)) { +if (!Object.keys(messages).includes(lastChosenLanguage)) { lastChosenLanguage = 'en-us'; } @@ -38,7 +38,10 @@ export default boot(({ app }) => { if (newLanguage !== currentLanguage) { localStorage.setItem('language', newLanguage); - window.location.reload(); + + if (currentLanguage) { + window.location.reload(); + } } // TODO: investigate if there is a better way to change the language not reloading the page // i18n.locale = newLanguage; diff --git a/src/boot/telosApi.js b/src/boot/telosApi.js index 4d3f59fb..88724a0f 100644 --- a/src/boot/telosApi.js +++ b/src/boot/telosApi.js @@ -10,6 +10,9 @@ const telosApi = axios.create({ const indexerApi = axios.create({ baseURL: process.env.INDEXER_API_ENDPOINT, }); +const exportApi = axios.create({ + baseURL: process.env.EXPORT_API_ENDPOINT, +}); const hyperion = axios.create({ baseURL: process.env.NETWORK_EVM_ENDPOINT, }); @@ -21,9 +24,11 @@ let contractManager = new ContractManager(indexerApi, fragmentParser); export default boot(({ app, store }) => { app.config.globalProperties.$telosApi = telosApi; app.config.globalProperties.$indexerApi = indexerApi; + app.config.globalProperties.$exportApi = exportApi; app.config.globalProperties.$fragmentParser = fragmentParser; store.$contractManager = app.config.globalProperties.$contractManager = markRaw(contractManager); store.$indexerApi = indexerApi; + store.$exportApi = exportApi; // Intercept API answer to set contracts & abi in cache directly indexerApi.interceptors.response.use(function (response) { if(response.data?.abi?.length > 0){ @@ -42,4 +47,4 @@ export default boot(({ app, store }) => { }); -export { telosApi, indexerApi, contractManager, fragmentParser }; +export { telosApi, indexerApi, exportApi, contractManager, fragmentParser }; diff --git a/src/components/header/AppHeaderLinks.vue b/src/components/header/AppHeaderLinks.vue index a26245c7..0db27929 100644 --- a/src/components/header/AppHeaderLinks.vue +++ b/src/components/header/AppHeaderLinks.vue @@ -71,7 +71,7 @@ const telos_bridgeMenuItem = { const moreSubmenuItems = { internal: [ - // { name: 'export', label: $t('components.header.csv_export') }, + { name: 'export', label: $t('components.header.csv_export') }, { name: 'health', label: $t('components.header.health_monitor') }, ], external: [ diff --git a/src/components/header/LanguageSwitcherModal.vue b/src/components/header/LanguageSwitcherModal.vue index a048eff3..dcbf855a 100644 --- a/src/components/header/LanguageSwitcherModal.vue +++ b/src/components/header/LanguageSwitcherModal.vue @@ -17,7 +17,7 @@ export default { }), created() { this.selectedLanguage = { - code: this.$i18n.locale, + code: this.$i18n.global.locale.value, name: this.$t('locale.current_language_name'), }; diff --git a/src/components/inputs/AddressInput.vue b/src/components/inputs/AddressInput.vue index 940d0837..9dacef2b 100644 --- a/src/components/inputs/AddressInput.vue +++ b/src/components/inputs/AddressInput.vue @@ -58,12 +58,16 @@ export default { } } }, + resetValidation() { + this.$refs.input.resetValidation(); + }, }, };