From 441b9994e7a2c322bb0439efcfd19def9f0c7dd5 Mon Sep 17 00:00:00 2001 From: Andrei O Date: Mon, 23 Sep 2024 08:23:25 +0300 Subject: [PATCH] Merge branch 'main' of https://github.com/andrei0x309/yup-live --- apps/yup-live-mobile/android/app/build.gradle | 4 +- .../src/views/ClaimRewardPage.vue | 4 +- .../src/views/CrossPostModal.vue | 29 ++- .../src/views/TokenMetrics.vue | 2 +- .../public/mobile/latest-version.json | 2 +- .../src/components/content/post/crossPost.vue | 27 ++- .../src/components/content/token-metrics.vue | 192 ++++++++++-------- packages/components/post-types/bsky.vue | 13 +- .../post-types/inner/bskyPostBody.vue | 169 +++++++++------ packages/components/post/videoPlayer.vue | 7 + packages/shared/src/types/post.ts | 1 + packages/shared/src/types/web3/media.ts | 1 + packages/shared/src/utils/changeLog.ts | 9 + packages/shared/src/utils/post.ts | 2 +- .../shared/src/utils/requests/mastodon.ts | 43 ++++ yarn.lock | 6 +- 16 files changed, 329 insertions(+), 182 deletions(-) create mode 100644 packages/shared/src/utils/requests/mastodon.ts diff --git a/apps/yup-live-mobile/android/app/build.gradle b/apps/yup-live-mobile/android/app/build.gradle index da4ea25..bf3d5c4 100644 --- a/apps/yup-live-mobile/android/app/build.gradle +++ b/apps/yup-live-mobile/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "gf.info.yup" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 59 - versionName "1.4.8" + versionCode 60 + versionName "1.4.9" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/apps/yup-live-mobile/src/views/ClaimRewardPage.vue b/apps/yup-live-mobile/src/views/ClaimRewardPage.vue index 882ab6f..6b01535 100644 --- a/apps/yup-live-mobile/src/views/ClaimRewardPage.vue +++ b/apps/yup-live-mobile/src/views/ClaimRewardPage.vue @@ -12,10 +12,10 @@ @ion-change="segmentChange" > - All + Yup - Rewards + Moxie diff --git a/apps/yup-live-mobile/src/views/CrossPostModal.vue b/apps/yup-live-mobile/src/views/CrossPostModal.vue index 7036142..4d1f668 100644 --- a/apps/yup-live-mobile/src/views/CrossPostModal.vue +++ b/apps/yup-live-mobile/src/views/CrossPostModal.vue @@ -45,7 +45,7 @@ title="Error" :type="postErrorType" class="mb-4" - :timeout="6000" + :timeout="36000" />
@@ -147,6 +147,7 @@
@@ -26,7 +32,9 @@

{{ `${dataSupply.value.supply} YUP` }}

- {{ `/ ${dataSupply.value.maxSupply} YUP` }} + {{ + `/ ${dataSupply.value.maxSupply} YUP` + }}
@@ -39,7 +47,9 @@

{{ `${dataActionCount.value.actCount} ` }}

- This month: {{ dataActionCount.value.actCountMonth }} + This month: {{ dataActionCount.value.actCountMonth }}
@@ -52,7 +62,9 @@

{{ `${dataEmissions.value.emissions} YUP` }}

- {{ `$${dataEmissions.value.emissionsValue}` }} + {{ + `$${dataEmissions.value.emissionsValue}` + }}
@@ -66,78 +78,90 @@ import { onUnmounted, defineComponent, ComputedRef, - Ref -} from 'vue' + Ref, +} from "vue"; -import { formatNumber } from 'shared/src/utils/misc' +import { formatNumber } from "shared/src/utils/misc"; export default defineComponent({ - name: 'TokenMetrics', + name: "TokenMetrics", components: {}, setup() { - type GeckoData = Ref> - type DataEmissions = Ref> - type DataActCount = Ref> - type DataSupply = Ref> + type GeckoData = Ref< + ComputedRef<{ + price: string; + priceRaw: number; + priceChangeRaw: number; + priceChange: string; + }> + >; + type DataEmissions = Ref>; + type DataActCount = Ref>; + type DataSupply = Ref< + ComputedRef<{ supply: string; mcap: string; maxSupply: string }> + >; - const dataEmissions: DataEmissions = ref(null) as unknown as DataEmissions - const dataSupply: DataSupply = ref(null) as unknown as DataSupply - const dataGecko: GeckoData = ref(null) as unknown as GeckoData - const dataActionCount: DataActCount = ref(null) as unknown as DataActCount + const dataEmissions: DataEmissions = (ref(null) as unknown) as DataEmissions; + const dataSupply: DataSupply = (ref(null) as unknown) as DataSupply; + const dataGecko: GeckoData = (ref(null) as unknown) as GeckoData; + const dataActionCount: DataActCount = (ref(null) as unknown) as DataActCount; const currentDayEmission = async () => { - const today = new Date() - if (today.getFullYear() > 2024 && today.getMonth() > 8 && today.getDate() > 21) { - return 10000 + const today = new Date(); + if (today.getFullYear() >= 2024 && today.getMonth() >= 8 && today.getDate() >= 22) { + return 10000; } - const yearData = await import(/* @vite-ignore */`/emissions/years/${today.getFullYear()}.js`/* @vite-ignore */) - const dateString = `${today.getFullYear()}-${('0' + String(today.getMonth() + 1)).slice(-2)}-${('0' + String(today.getDate())).slice( - -2 - )}` - const offsetContract = 5546 - return yearData.data[dateString] - offsetContract - } + const yearData = await import( + /* @vite-ignore */ `/emissions/years/${today.getFullYear()}.js` /* @vite-ignore */ + ); + const dateString = `${today.getFullYear()}-${( + "0" + String(today.getMonth() + 1) + ).slice(-2)}-${("0" + String(today.getDate())).slice(-2)}`; + const offsetContract = 5546; + return yearData.data[dateString] - offsetContract; + }; const getSupply = async () => { - const req = await fetch('https://api.yup.io/metrics/current-supply', { - method: 'GET', + const req = await fetch("https://api.yup.io/metrics/current-supply", { + method: "GET", headers: { - 'Content-Type': 'application/json;charset=utf-8' - } - }) + "Content-Type": "application/json;charset=utf-8", + }, + }); if (!req.ok) { - throw new Error(`Request failed with status ${req.status}`) + throw new Error(`Request failed with status ${req.status}`); } - const data = await req.json() - return data - } + const data = await req.json(); + return data; + }; const getGeckoData = async () => { - const req = await fetch('https://yup-token-cache-hono.deno.dev/token/yup', { + const req = await fetch("https://yup-token-cache-hono.deno.dev/token/yup", { headers: { - 'Authorization': (Math.random() / 20.2).toString(36).substring(2) + Date.now().toString(36) - } - }) + Authorization: + (Math.random() / 20.2).toString(36).substring(2) + Date.now().toString(36), + }, + }); if (!req.ok) { - throw new Error(`Request failed with status ${req.status}`) + throw new Error(`Request failed with status ${req.status}`); } - const data = await req.json() - return data - } + const data = await req.json(); + return data; + }; const getActionsCount = async () => { - const req = fetch('https://api.yup.io/metrics/total-votes') - const req2 = fetch('https://api.yup.io/metrics/total-votes/last-month') - const [res, res2] = await Promise.all([req, req2]) + const req = fetch("https://api.yup.io/metrics/total-votes"); + const req2 = fetch("https://api.yup.io/metrics/total-votes/last-month"); + const [res, res2] = await Promise.all([req, req2]); if (!res.ok || !res2.ok) { - throw new Error(`One request failed with status ${res.status} | ${res2.status}`) + throw new Error(`One request failed with status ${res.status} | ${res2.status}`); } - const [data, data2] = await Promise.all([res.json(), res2.json()]) + const [data, data2] = await Promise.all([res.json(), res2.json()]); return { total: data, - lastMonth: data2 - } - } + lastMonth: data2, + }; + }; // const showAlertError = (title, message) => { // alertHidden.value = false; // alertTitle.value = title; @@ -158,53 +182,55 @@ export default defineComponent({ dataEmissions.value = computed(() => { return { emissions: formatNumber(emission, 0), - emissionsValue: formatNumber(emission * dataGecko.value.value.priceRaw, 2) - } - }) - }) + emissionsValue: formatNumber(emission * dataGecko.value.value.priceRaw, 2), + }; + }); + }); const gKP = getGeckoData().then((gecko) => { dataGecko.value = computed(() => { return { price: formatNumber(gecko.market_data.current_price.usd, 4), priceRaw: gecko.market_data.current_price.usd, priceChangeRaw: gecko.market_data.price_change_percentage_24h, - priceChange: Math.abs(gecko.market_data.price_change_percentage_24h).toFixed(2) - } - }) - }) + priceChange: Math.abs(gecko.market_data.price_change_percentage_24h).toFixed( + 2 + ), + }; + }); + }); getSupply().then((supply) => { gKP.then(() => { dataSupply.value = computed(() => { return { supply: formatNumber(supply.totalSupply, 0), maxSupply: formatNumber(supply.supplyWhenInfStop, 0), - mcap: formatNumber(supply.totalSupply * dataGecko.value.value.priceRaw, 0) - } - }) - }) - }) + mcap: formatNumber(supply.totalSupply * dataGecko.value.value.priceRaw, 0), + }; + }); + }); + }); getActionsCount().then((actionCount) => { dataActionCount.value = computed(() => { return { actCount: formatNumber(actionCount.total, 0), - actCountMonth: formatNumber(actionCount.lastMonth, 0) - } - }) - }) - }) + actCountMonth: formatNumber(actionCount.lastMonth, 0), + }; + }); + }); + }); onUnmounted(() => { // do nothing - }) + }); return { dataEmissions, dataSupply, dataGecko, - dataActionCount - } - } -}) + dataActionCount, + }; + }, +});