From f73e546e8c6d85576f33ffea9fcbec39a7f0f4ec Mon Sep 17 00:00:00 2001 From: MarcoMandar Date: Thu, 4 Jul 2024 14:50:37 +0100 Subject: [PATCH 1/8] update Branding Signed-off-by: MarcoMandar --- .vscode/settings.json | 2 +- README.md | 8 ++++---- components/DashboardFooter.vue | 2 +- .../columns/RegistrationActionColumn.vue | 2 +- components/ui-kit/Ticker.vue | 2 +- components/ui-kit/TitleAndLogo.vue | 2 +- composables/registrator/index.ts | 2 +- config/web3modal.config.ts | 4 ++-- nuxt.config.ts | 2 +- stores/useFacilitatorStore.ts | 2 +- stores/useMetricsStore.ts | 2 +- stores/usePriceStore.ts | 4 ++-- stores/useUserStore.ts | 8 ++++---- types/relay.ts | 2 +- utils/relays.ts | 2 +- 15 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9e6ea08..ff2bdce 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "cSpell.words": [ "Arweave", - "ator" + "anon" ], "files.associations": { "*.css": "tailwindcss" diff --git a/README.md b/README.md index 0b23720..fb3d8d6 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# ATOR Relay Dashboard (WIP) +# AnyOne Relay Dashboard (WIP) -This repo houses the code to display the user specific information pertaining to ATOR Relays. +This repo houses the code to display the user specific information pertaining to ANON Relays. ## To Do @@ -18,11 +18,11 @@ While this list seems long much of the boilerplate exists. This is actually the third iteration of this code: -1. ATOR built: https://github.com/ATOR-Development/ator-dashboard/ +1. ANON built: https://github.com/ATOR-Development/ator-dashboard/ 2. Brewlabs built: https://github.com/brewlabs-code/ator/ 3. Brewlabs built stripped down: https://github.com/brewlabs-code/ator-relay-dashboard -For reasons not worth getting into now ATOR changed directions technically. As such the 2nd build was halted. +For reasons not worth getting into now ANON changed directions technically. As such the 2nd build was halted. Now, the underlying tech has changed somewhat and we are developing an MVP version focussing on the user account section. Much of the code has been migrated but also some updates where necessary. diff --git a/components/DashboardFooter.vue b/components/DashboardFooter.vue index d75dea5..c12130b 100755 --- a/components/DashboardFooter.vue +++ b/components/DashboardFooter.vue @@ -96,7 +96,7 @@ const isOpen = ref(false);
-

ATOR

+

ANON

View Contracts
Lock
-
Lock 100 $ATOR
+
Lock 100 $ANON
$ATOR$ANON diff --git a/components/ui-kit/TitleAndLogo.vue b/components/ui-kit/TitleAndLogo.vue index 80dde4d..6d5b15b 100755 --- a/components/ui-kit/TitleAndLogo.vue +++ b/components/ui-kit/TitleAndLogo.vue @@ -5,7 +5,7 @@

- ATOR + AnyOne

diff --git a/composables/registrator/index.ts b/composables/registrator/index.ts index 4332dbf..ea10098 100755 --- a/composables/registrator/index.ts +++ b/composables/registrator/index.ts @@ -204,7 +204,7 @@ export class Registrator { color: 'primary', title: 'Success', timeout: 0, - description: `Relay locked. We've locked ${formatEther(registratorStore.totalLockedTokens || '0')} $ATOR.`, + description: `Relay locked. We've locked ${formatEther(registratorStore.totalLockedTokens || '0')} $ANON.`, }); return result; diff --git a/config/web3modal.config.ts b/config/web3modal.config.ts index 51f7699..c9d9b8b 100755 --- a/config/web3modal.config.ts +++ b/config/web3modal.config.ts @@ -7,13 +7,13 @@ export const metadata = { icons: ['/images/ator-logo.png'], }; -export const getAtorAddress = () => { +export const getAnonAddress = () => { const runtimeConfig = useRuntimeConfig(); return runtimeConfig.public.sepoliaAtorTokenContract; }; -export const getAtorAddressMain = () => { +export const getAnonAddressMain = () => { const runtimeConfig = useRuntimeConfig(); return runtimeConfig.public.tokenContractMain; diff --git a/nuxt.config.ts b/nuxt.config.ts index d241011..b0b3163 100755 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -13,7 +13,7 @@ export default defineNuxtConfig({ { hid: 'description', name: 'Description', - content: 'ATOR Dashboard', + content: 'ANON Dashboard', }, { property: 'og:site_name', content: 'ATOR Dashboard' }, { name: 'twitter:site', content: '@atorprotocol' }, diff --git a/stores/useFacilitatorStore.ts b/stores/useFacilitatorStore.ts index 6262ecc..68060b7 100755 --- a/stores/useFacilitatorStore.ts +++ b/stores/useFacilitatorStore.ts @@ -127,7 +127,7 @@ export const useFacilitatorStore = defineStore('facilitator', { icon: 'i-heroicons-check-circle', color: 'primary', title: 'Success', - description: `Rewards redeemed successfully. You've redeemed ${pendingClaimCopy.amount} $ATOR.`, + description: `Rewards redeemed successfully. You've redeemed ${pendingClaimCopy.amount} $ANON.`, actions: [ { label: 'View transaction', diff --git a/stores/useMetricsStore.ts b/stores/useMetricsStore.ts index e9556ff..5cc4619 100755 --- a/stores/useMetricsStore.ts +++ b/stores/useMetricsStore.ts @@ -31,7 +31,7 @@ export type RelayVerificationResult = export interface ValidatedRelay { fingerprint: string; - ator_address: string; + anon_address: string; consensus_weight: number; consensus_weight_fraction: number; observed_bandwidth: number; diff --git a/stores/usePriceStore.ts b/stores/usePriceStore.ts index 8de8d73..ff2cdef 100755 --- a/stores/usePriceStore.ts +++ b/stores/usePriceStore.ts @@ -1,8 +1,8 @@ -import { getAtorAddressMain } from '~/config/web3modal.config'; +import { getAnonAddressMain } from '~/config/web3modal.config'; const to = Math.floor(Date.now() / 1000); const from = to - 3600 * 48; // 48 hrs -const apiEndpoint = `https://api.dex.guru/v1/tradingview/history?symbol=${getAtorAddressMain()}-eth_USD&resolution=240&from=${from}&to=${to}`; // TODO Use In MainNet +const apiEndpoint = `https://api.dex.guru/v1/tradingview/history?symbol=${getAnonAddressMain()}-eth_USD&resolution=240&from=${from}&to=${to}`; // TODO Use In MainNet import Logger from '~/utils/logger'; diff --git a/stores/useUserStore.ts b/stores/useUserStore.ts index 12ebe04..c0de01f 100755 --- a/stores/useUserStore.ts +++ b/stores/useUserStore.ts @@ -6,7 +6,7 @@ import type { RelayMeta } from '@/types/relay'; import { warpRead, warpReadSerials } from '@/utils/warp.read'; import { config } from '@/config/wagmi.config'; -import { getAtorAddress } from '@/config/web3modal.config'; +import { getAnonAddress } from '@/config/web3modal.config'; import type { RelayRow } from '@/types/relay'; import { getRelaysInfo } from '@/utils/relays'; import { toDisplayString } from 'vue'; @@ -30,19 +30,19 @@ export const useUserStore = defineStore('user', { serials: [] as string[], }), actions: { - // Get ATOR balance + // Get ANON balance async getTokenBalance() { if (!this.userData.address) { return; } - const token = getAtorAddress() as `0x${string}`; + const token = getAnonAddress() as `0x${string}`; this.tokenBalance = await getBalance(config, { token, address: this.userData.address as `0x${string}`, }); }, - // Get ATOR balance in USD using price store + // Get ANON balance in USD using price store async getUsdTokenBalance() { const priceStore = usePriceStore(); await priceStore.fetchPrice(); diff --git a/types/relay.ts b/types/relay.ts index 435d605..8d92314 100755 --- a/types/relay.ts +++ b/types/relay.ts @@ -10,7 +10,7 @@ export type RelayMeta = { fingerprint: string; nickname?: string; status?: string; - ator_address: string; + anon_address: string; consensus_weight: string; observed_bandwidth: number; consensus_weight_fraction: number; diff --git a/utils/relays.ts b/utils/relays.ts index 05f8dd3..7e7699d 100755 --- a/utils/relays.ts +++ b/utils/relays.ts @@ -24,7 +24,7 @@ export const getRelaysInfo = async (fingerPrints: string[]) => { fingerprint: relay.fingerprint, nickname: relay.nickname, status: '', - ator_address: relay.ator_address, + anon_address: relay.anon_address, consensus_weight: relay.consensus_weight.toString(), observed_bandwidth: relay.observed_bandwidth, consensus_weight_fraction: relay.consensus_weight_fraction, From b9758dd8e9beca7429715a85ca348b672eab6372 Mon Sep 17 00:00:00 2001 From: MarcoMandar Date: Thu, 4 Jul 2024 15:54:50 +0100 Subject: [PATCH 2/8] update footer mobile Signed-off-by: MarcoMandar --- components/DashboardFooter.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/components/DashboardFooter.vue b/components/DashboardFooter.vue index c12130b..c8201ff 100755 --- a/components/DashboardFooter.vue +++ b/components/DashboardFooter.vue @@ -96,7 +96,6 @@ const isOpen = ref(false);
-

ANON

View Contracts Date: Fri, 5 Jul 2024 04:25:07 +0100 Subject: [PATCH 3/8] Add relay cache and logs Signed-off-by: MarcoMandar --- .../DataTableMyRelays/DataTableMyRelays.vue | 152 +++++++++++------- composables/relayCache.ts | 112 +++++++++++++ stores/useUserStore.ts | 77 +++++---- 3 files changed, 254 insertions(+), 87 deletions(-) create mode 100644 composables/relayCache.ts diff --git a/components/DataTableMyRelays/DataTableMyRelays.vue b/components/DataTableMyRelays/DataTableMyRelays.vue index 2500f1f..e456f17 100755 --- a/components/DataTableMyRelays/DataTableMyRelays.vue +++ b/components/DataTableMyRelays/DataTableMyRelays.vue @@ -7,7 +7,6 @@ import { type RelayRow, type RelayTabType } from '@/types/relay'; import { RELAY_COLUMS, TABS, VERBS } from '@/constants/relay'; import { useMetricsStore } from '@/stores/useMetricsStore'; - import Tabs from '../ui-kit/Tabs.vue'; import Tooltip from '../ui-kit/Tooltip.vue'; import Popover from '../ui-kit/Popover.vue'; @@ -18,7 +17,7 @@ import LockStatusColumn from './columns/LockStatusColumn.vue'; import RegistrationActionColumn from './columns/RegistrationActionColumn.vue'; import { useRegistrator } from '@/composables/registrator'; import { useRegistratorStore } from '@/stores/useRegistratorStore'; -import {ethers} from 'ethers'; +import { ethers } from 'ethers'; const toast = useToast(); const userStore = useUserStore(); @@ -27,51 +26,53 @@ const metricsStore = useMetricsStore(); const registratorStore = useRegistratorStore(); const { allRelays, claimableRelays } = storeToRefs(userStore); -const { address } = useAccount({ config}); +const { address } = useAccount({ config }); const currentTab = ref('all'); const registerModalOpen = ref(false); // Fetching and refreshing the relay data from Warp - stored in Pinia user store -const { - refresh: verifiedRelaysRefresh, - error: verifiedRelaysError, - pending: verifiedPending, -} = await useAsyncData( - 'verifiedRelays', - () => userStore.getVerifiedRelays(), - { server: false, watch: [address] } -); -const { - refresh: claimableRelaysRefresh, - error: claimableRelaysError, - pending: claimablePending, -} = await useAsyncData( - 'claimableRelays', - () => userStore.getClaimableRelays(), - { watch: [address] } -); +const { error: verifiedRelaysError, pending: verifiedPending } = + await useAsyncData('verifiedRelays', () => userStore.getVerifiedRelays(), { + server: false, + watch: [address], + }); +const { error: claimableRelaysError, pending: claimablePending } = + await useAsyncData('claimableRelays', () => userStore.getClaimableRelays(), { + watch: [address], + }); const ethAddress = ref(''); const ethAddressError = ref(null); const fingerPrintRegister = ref(''); const fingerPrintRegisterError = ref(null); -if (claimableRelaysError.value?.cause?.message == "rate limited" || verifiedRelaysError.value?.cause?.message == "rate limited") { +if ( + claimableRelaysError.value?.cause?.message == 'rate limited' || + verifiedRelaysError.value?.cause?.message == 'rate limited' +) { toast.add({ - id: "claimable-relays-error", - icon: 'i-heroicons-exclamation-triangle', - color: 'primary', - title: 'Arweave rate limit exceeded!', - timeout: 0, - description: 'Please wait...', - }); + id: 'claimable-relays-error', + icon: 'i-heroicons-exclamation-triangle', + color: 'primary', + title: 'Arweave rate limit exceeded!', + timeout: 0, + description: 'Please wait...', + }); if (claimableRelaysError.value != null) { - userStore.claimRelayRefresh().then(() => claimableRelaysError.value = null); + userStore + .claimRelayRefresh() + .then(() => (claimableRelaysError.value = null)); } else if (verifiedRelaysError.value != null) { - userStore.verifiedRelaysRefresh().then(() => verifiedRelaysError.value = null); + userStore + .verifiedRelaysRefresh() + .then(() => (verifiedRelaysError.value = null)); } else { - userStore.claimRelayRefresh().then(() => claimableRelaysError.value = null); - userStore.verifiedRelaysRefresh().then(() => verifiedRelaysError.value = null); + userStore + .claimRelayRefresh() + .then(() => (claimableRelaysError.value = null)); + userStore + .verifiedRelaysRefresh() + .then(() => (verifiedRelaysError.value = null)); } // keep trying to fetch the claimable relays } @@ -118,8 +119,8 @@ const relayAction = async (action: FunctionName, fingerprint: string) => { } // Refresh the relays - await verifiedRelaysRefresh(); - await claimableRelaysRefresh(); + await userStore.getVerifiedRelays(true); + await userStore.getClaimableRelays(true); toast.add({ icon: 'i-heroicons-check-circle', @@ -177,7 +178,7 @@ const handleLockRelay = async (fingerprint: string) => { try { const register = useRegistrator(); - await register?.lock(fingerprint, ""); + await register?.lock(fingerprint, ''); selectedRow!.class = ''; selectedRow!.isWorking = false; @@ -194,10 +195,10 @@ const handleLockRemote = async () => { } // check for empty - if (fingerPrintRegister.value == "" || ethAddress.value == "") { + if (fingerPrintRegister.value == '' || ethAddress.value == '') { toast.remove('invalid-evm-address'); toast.add({ - id: "invalid-evm-address", + id: 'invalid-evm-address', icon: 'i-heroicons-x-circle', color: 'amber', title: 'Error', @@ -210,21 +211,20 @@ const handleLockRemote = async () => { if (!ethers.isAddress(ethAddress.value)) { toast.remove('invalid-evm-address'); toast.add({ - id: "invalid-evm-address", + id: 'invalid-evm-address', icon: 'i-heroicons-x-circle', color: 'amber', title: 'Error', description: `Invalid EVM address`, - }) + }); return; } try { const register = useRegistrator(); await register?.lock(fingerPrintRegister.value, ethAddress.value); - } catch (error: any) { - } -} + } catch (error: any) {} +}; const filterUniqueRelays = (relays: RelayRow[]) => { const seen = new Set(); @@ -262,26 +262,38 @@ const handleUnlockClick = (fingerprint: string) => { if (registratorStore.isRelayLocked(fingerprint)) { toast.remove('unlock-relays-error'); toast.add({ - id: "unlock-relays-error", + id: 'unlock-relays-error', icon: 'i-heroicons-exclamation-triangle', color: 'amber', title: 'Unlock failed', timeout: 0, description: `This relay is currently locked. It unlocks at block: ${registratorStore.getUnlockTime(fingerprint)}`, - }) + }); } -} +};