mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-29 00:47:57 +00:00
Integrate live blockchain data for delegation features
- Created useDelegation hook to fetch real delegation data from blockchain - Queries democracy.voting pallet for all delegations - Tracks delegate totals, delegator counts, and voting power - Calculates delegate performance metrics and success rates - Fetches user's own delegations with conviction levels - Auto-refreshes every 30 seconds for live updates - Provides delegateVotes and undelegateVotes transaction builders - Updated DelegationManager component to use live data - Replaced mock delegates with real blockchain delegates - Replaced mock delegations with user's actual delegations - Added loading states with spinner during data fetch - Added error handling with user-friendly messages - Added "Live Blockchain Data" badge for transparency - Formatted token amounts from blockchain units (12 decimals) - Show delegate addresses in monospace font - Display delegator count and conviction levels - Empty states for no delegates/delegations scenarios - Enhanced PolkadotContext with isConnected property - Added isConnected as alias for isApiReady - Maintains backward compatibility with existing hooks - Added formatNumber utility to lib/utils - Formats large numbers with K/M/B suffixes - Handles decimals and edge cases - Consistent formatting across all components All delegation data now comes from live blockchain queries.
This commit is contained in:
@@ -6,6 +6,7 @@ import type { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';
|
||||
interface PolkadotContextType {
|
||||
api: ApiPromise | null;
|
||||
isApiReady: boolean;
|
||||
isConnected: boolean;
|
||||
accounts: InjectedAccountWithMeta[];
|
||||
selectedAccount: InjectedAccountWithMeta | null;
|
||||
setSelectedAccount: (account: InjectedAccountWithMeta | null) => void;
|
||||
@@ -119,6 +120,7 @@ export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
|
||||
const value: PolkadotContextType = {
|
||||
api,
|
||||
isApiReady,
|
||||
isConnected: isApiReady, // Alias for backward compatibility
|
||||
accounts,
|
||||
selectedAccount,
|
||||
setSelectedAccount,
|
||||
|
||||
Reference in New Issue
Block a user