mirror of
https://github.com/pezkuwichain/pezkuwi-telegram-miniapp.git
synced 2026-04-22 03:07:55 +00:00
feat: 3-state staking score UI with cached data support
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pezkuwi-telegram-miniapp",
|
"name": "pezkuwi-telegram-miniapp",
|
||||||
"version": "1.0.202",
|
"version": "1.0.205",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Pezkuwichain Telegram Mini App - Forum, Announcements, Rewards",
|
"description": "Pezkuwichain Telegram Mini App - Forum, Announcements, Rewards",
|
||||||
"author": "Pezkuwichain Team",
|
"author": "Pezkuwichain Team",
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ const ar: Translations = {
|
|||||||
citizen: 'مواطن',
|
citizen: 'مواطن',
|
||||||
staking: 'التخزين',
|
staking: 'التخزين',
|
||||||
stakingNotStarted: 'لم يبدأ بعد',
|
stakingNotStarted: 'لم يبدأ بعد',
|
||||||
|
stakingWaitingData: 'في انتظار البيانات...',
|
||||||
stakingCountedInTrust: 'يُحتسب في نقاط الثقة',
|
stakingCountedInTrust: 'يُحتسب في نقاط الثقة',
|
||||||
people: '{count} شخص',
|
people: '{count} شخص',
|
||||||
tiki: 'تيكي',
|
tiki: 'تيكي',
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ const ckb: Translations = {
|
|||||||
citizen: 'هاوڵاتی',
|
citizen: 'هاوڵاتی',
|
||||||
staking: 'ستەیکینگ',
|
staking: 'ستەیکینگ',
|
||||||
stakingNotStarted: 'دەستپێنەکراوە',
|
stakingNotStarted: 'دەستپێنەکراوە',
|
||||||
|
stakingWaitingData: 'چاوەڕوانی داتا...',
|
||||||
stakingCountedInTrust: 'لە خاڵی متمانە ژمێردراوە',
|
stakingCountedInTrust: 'لە خاڵی متمانە ژمێردراوە',
|
||||||
people: '{count} کەس',
|
people: '{count} کەس',
|
||||||
tiki: 'تیکی',
|
tiki: 'تیکی',
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ const en: Translations = {
|
|||||||
citizen: 'Citizen',
|
citizen: 'Citizen',
|
||||||
staking: 'Staking',
|
staking: 'Staking',
|
||||||
stakingNotStarted: 'Not started',
|
stakingNotStarted: 'Not started',
|
||||||
|
stakingWaitingData: 'Waiting for data...',
|
||||||
stakingCountedInTrust: 'Counted in Trust score',
|
stakingCountedInTrust: 'Counted in Trust score',
|
||||||
people: '{count} people',
|
people: '{count} people',
|
||||||
tiki: 'Tiki',
|
tiki: 'Tiki',
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ const fa: Translations = {
|
|||||||
citizen: 'شهروند',
|
citizen: 'شهروند',
|
||||||
staking: 'سهامگذاری',
|
staking: 'سهامگذاری',
|
||||||
stakingNotStarted: 'شروع نشده',
|
stakingNotStarted: 'شروع نشده',
|
||||||
|
stakingWaitingData: 'در انتظار دادهها...',
|
||||||
stakingCountedInTrust: 'در امتیاز اعتماد محاسبه میشود',
|
stakingCountedInTrust: 'در امتیاز اعتماد محاسبه میشود',
|
||||||
people: '{count} نفر',
|
people: '{count} نفر',
|
||||||
tiki: 'تیکی',
|
tiki: 'تیکی',
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ const krd: Translations = {
|
|||||||
citizen: 'Welat\u00ee',
|
citizen: 'Welat\u00ee',
|
||||||
staking: 'Staking',
|
staking: 'Staking',
|
||||||
stakingNotStarted: 'Nehat\u00eeye destp\u00eakirin',
|
stakingNotStarted: 'Nehat\u00eeye destp\u00eakirin',
|
||||||
|
stakingWaitingData: 'Li benda daneyan...',
|
||||||
stakingCountedInTrust: 'Di Trust de t\u00ea hesibandin',
|
stakingCountedInTrust: 'Di Trust de t\u00ea hesibandin',
|
||||||
people: '{count} kes',
|
people: '{count} kes',
|
||||||
tiki: 'Tiki',
|
tiki: 'Tiki',
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ const tr: Translations = {
|
|||||||
citizen: 'Vatandaş',
|
citizen: 'Vatandaş',
|
||||||
staking: 'Staking',
|
staking: 'Staking',
|
||||||
stakingNotStarted: 'Başlamadı',
|
stakingNotStarted: 'Başlamadı',
|
||||||
|
stakingWaitingData: 'Veri bekleniyor...',
|
||||||
stakingCountedInTrust: 'Güven puanına dahil',
|
stakingCountedInTrust: 'Güven puanına dahil',
|
||||||
people: '{count} kişi',
|
people: '{count} kişi',
|
||||||
tiki: 'Tiki',
|
tiki: 'Tiki',
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ export interface Translations {
|
|||||||
citizen: string;
|
citizen: string;
|
||||||
staking: string;
|
staking: string;
|
||||||
stakingNotStarted: string;
|
stakingNotStarted: string;
|
||||||
|
stakingWaitingData: string;
|
||||||
stakingCountedInTrust: string;
|
stakingCountedInTrust: string;
|
||||||
people: string;
|
people: string;
|
||||||
tiki: string;
|
tiki: string;
|
||||||
|
|||||||
+48
-3
@@ -28,6 +28,7 @@ export interface UserScores {
|
|||||||
|
|
||||||
export interface StakingScoreStatus {
|
export interface StakingScoreStatus {
|
||||||
isTracking: boolean;
|
isTracking: boolean;
|
||||||
|
hasCachedData: boolean; // Whether noter has submitted staking data
|
||||||
startBlock: number | null;
|
startBlock: number | null;
|
||||||
currentBlock: number;
|
currentBlock: number;
|
||||||
durationBlocks: number;
|
durationBlocks: number;
|
||||||
@@ -107,7 +108,13 @@ export async function getStakingScoreStatus(
|
|||||||
try {
|
try {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
if (!(peopleApi?.query as any)?.stakingScore?.stakingStartBlock) {
|
if (!(peopleApi?.query as any)?.stakingScore?.stakingStartBlock) {
|
||||||
return { isTracking: false, startBlock: null, currentBlock: 0, durationBlocks: 0 };
|
return {
|
||||||
|
isTracking: false,
|
||||||
|
hasCachedData: false,
|
||||||
|
startBlock: null,
|
||||||
|
currentBlock: 0,
|
||||||
|
durationBlocks: 0,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
@@ -115,21 +122,59 @@ export async function getStakingScoreStatus(
|
|||||||
const currentBlock = Number((await peopleApi.query.system.number()).toString());
|
const currentBlock = Number((await peopleApi.query.system.number()).toString());
|
||||||
|
|
||||||
if (startBlockResult.isEmpty || startBlockResult.isNone) {
|
if (startBlockResult.isEmpty || startBlockResult.isNone) {
|
||||||
return { isTracking: false, startBlock: null, currentBlock, durationBlocks: 0 };
|
return {
|
||||||
|
isTracking: false,
|
||||||
|
hasCachedData: false,
|
||||||
|
startBlock: null,
|
||||||
|
currentBlock,
|
||||||
|
durationBlocks: 0,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const startBlock = Number(startBlockResult.toString());
|
const startBlock = Number(startBlockResult.toString());
|
||||||
const durationBlocks = currentBlock - startBlock;
|
const durationBlocks = currentBlock - startBlock;
|
||||||
|
|
||||||
|
// Check if noter has submitted cached staking data
|
||||||
|
let hasCachedData = false;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
if ((peopleApi.query as any).stakingScore?.cachedStakingDetails) {
|
||||||
|
try {
|
||||||
|
const [relayResult, assetHubResult] = await Promise.all([
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
(peopleApi.query as any).stakingScore
|
||||||
|
.cachedStakingDetails(address, 'RelayChain')
|
||||||
|
.catch(() => ({ isSome: false, isEmpty: true })),
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
(peopleApi.query as any).stakingScore
|
||||||
|
.cachedStakingDetails(address, 'AssetHub')
|
||||||
|
.catch(() => ({ isSome: false, isEmpty: true })),
|
||||||
|
]);
|
||||||
|
hasCachedData =
|
||||||
|
relayResult.isSome ||
|
||||||
|
!relayResult.isEmpty ||
|
||||||
|
assetHubResult.isSome ||
|
||||||
|
!assetHubResult.isEmpty;
|
||||||
|
} catch {
|
||||||
|
hasCachedData = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isTracking: true,
|
isTracking: true,
|
||||||
|
hasCachedData,
|
||||||
startBlock,
|
startBlock,
|
||||||
currentBlock,
|
currentBlock,
|
||||||
durationBlocks,
|
durationBlocks,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching staking score status:', error);
|
console.error('Error fetching staking score status:', error);
|
||||||
return { isTracking: false, startBlock: null, currentBlock: 0, durationBlocks: 0 };
|
return {
|
||||||
|
isTracking: false,
|
||||||
|
hasCachedData: false,
|
||||||
|
startBlock: null,
|
||||||
|
currentBlock: 0,
|
||||||
|
durationBlocks: 0,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -609,10 +609,16 @@ export function RewardsSection() {
|
|||||||
</div>
|
</div>
|
||||||
<p className="text-2xl font-bold text-blue-400">
|
<p className="text-2xl font-bold text-blue-400">
|
||||||
{stakingStatus?.isTracking ? (
|
{stakingStatus?.isTracking ? (
|
||||||
<span className="flex items-center gap-1">
|
stakingStatus.hasCachedData ? (
|
||||||
<Clock className="w-4 h-4" />
|
<span className="flex items-center gap-1">
|
||||||
{formatDuration(stakingStatus.durationBlocks)}
|
<Clock className="w-4 h-4" />
|
||||||
</span>
|
{formatDuration(stakingStatus.durationBlocks)}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span className="text-sm text-yellow-400">
|
||||||
|
{t('rewards.stakingWaitingData')}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<span className="text-sm text-muted-foreground">
|
<span className="text-sm text-muted-foreground">
|
||||||
{t('rewards.stakingNotStarted')}
|
{t('rewards.stakingNotStarted')}
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.202",
|
"version": "1.0.205",
|
||||||
"buildTime": "2026-02-15T22:27:40.363Z",
|
"buildTime": "2026-02-16T22:56:49.789Z",
|
||||||
"buildNumber": 1771194460364
|
"buildNumber": 1771282609790
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* PezkuwiChain Telegram Bot - Supabase Edge Function
|
* PezkuwiChain Telegram Bot - Supabase Edge Function
|
||||||
* Handles webhook updates from two separate bots:
|
* Handles webhook updates from two separate bots:
|
||||||
* - @Pezkuwichain_Bot (main) → telegram.pezkuwichain.io
|
* - @Pezkuwichain_Bot (main) → telegram.pezkuwichain.io
|
||||||
* - @pezkuwichainBot (krd) → telegram.pezkiwi.app
|
* - @pezkuwichainBot (krd) → telegram.pezkiwi.app
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';
|
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';
|
||||||
|
|||||||
Reference in New Issue
Block a user