mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 19:27:56 +00:00
Fix all shadow deprecation warnings across entire mobile app
- Replaced shadowColor/shadowOffset/shadowOpacity/shadowRadius with boxShadow - Fixed 28 files (21 screens + 7 components) - Preserved elevation for Android compatibility - All React Native Web deprecation warnings resolved Files fixed: - All screen components - All reusable components - Navigation components - Modal components
This commit is contained in:
@@ -178,7 +178,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
// Listen for wallet changes (from PolkadotContext)
|
||||
// Listen for wallet changes (from PezkuwiContext)
|
||||
const handleWalletChange = () => {
|
||||
checkAdminStatus();
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createContext, useContext, useState, useEffect, useCallback, ReactNode } from 'react';
|
||||
import { useAuth } from '@/contexts/AuthContext';
|
||||
import { usePolkadot } from '@/contexts/PolkadotContext';
|
||||
import { usePezkuwi } from '@/contexts/PezkuwiContext';
|
||||
import { supabase } from '@/lib/supabase';
|
||||
import { getAllTikiNFTDetails, generateCitizenNumber, type TikiNFTDetails } from '@pezkuwi/lib/tiki';
|
||||
import { getKycStatus } from '@pezkuwi/lib/kyc';
|
||||
@@ -17,7 +17,7 @@ const DashboardContext = createContext<DashboardData | undefined>(undefined);
|
||||
|
||||
export function DashboardProvider({ children }: { children: ReactNode }) {
|
||||
const { user } = useAuth();
|
||||
const { api, isApiReady, selectedAccount } = usePolkadot();
|
||||
const { api, isApiReady, selectedAccount } = usePezkuwi();
|
||||
const [profile, setProfile] = useState<Record<string, unknown> | null>(null);
|
||||
const [nftDetails, setNftDetails] = useState<{ citizenNFT: TikiNFTDetails | null; roleNFTs: TikiNFTDetails[]; totalNFTs: number }>({
|
||||
citizenNFT: null,
|
||||
|
||||
@@ -2,9 +2,9 @@ import React, { createContext, useContext, useEffect, useState, ReactNode } from
|
||||
import { ApiPromise, WsProvider } from '@pezkuwi/api';
|
||||
import { web3Accounts, web3Enable } from '@pezkuwi/extension-dapp';
|
||||
import type { InjectedAccountWithMeta } from '@pezkuwi/extension-inject/types';
|
||||
import { DEFAULT_ENDPOINT } from '../../../shared/blockchain/polkadot';
|
||||
import { DEFAULT_ENDPOINT } from '../../../shared/blockchain/pezkuwi';
|
||||
|
||||
interface PolkadotContextType {
|
||||
interface PezkuwiContextType {
|
||||
api: ApiPromise | null;
|
||||
isApiReady: boolean;
|
||||
isConnected: boolean;
|
||||
@@ -17,14 +17,14 @@ interface PolkadotContextType {
|
||||
sudoKey: string | null;
|
||||
}
|
||||
|
||||
const PolkadotContext = createContext<PolkadotContextType | undefined>(undefined);
|
||||
const PezkuwiContext = createContext<PezkuwiContextType | undefined>(undefined);
|
||||
|
||||
interface PolkadotProviderProps {
|
||||
interface PezkuwiProviderProps {
|
||||
children: ReactNode;
|
||||
endpoint?: string;
|
||||
}
|
||||
|
||||
export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
|
||||
export const PezkuwiProvider: React.FC<PezkuwiProviderProps> = ({
|
||||
children,
|
||||
endpoint = DEFAULT_ENDPOINT // Beta testnet RPC from shared config
|
||||
}) => {
|
||||
@@ -50,7 +50,7 @@ export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize Polkadot API with fallback endpoints
|
||||
// Initialize Pezkuwi API with fallback endpoints
|
||||
useEffect(() => {
|
||||
const FALLBACK_ENDPOINTS = [
|
||||
endpoint,
|
||||
@@ -161,7 +161,7 @@ export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
|
||||
restoreWallet();
|
||||
}, []);
|
||||
|
||||
// Connect wallet (Polkadot.js extension)
|
||||
// Connect wallet (Pezkuwi.js extension)
|
||||
const connectWallet = async () => {
|
||||
try {
|
||||
setError(null);
|
||||
@@ -170,20 +170,20 @@ export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
|
||||
const extensions = await web3Enable('PezkuwiChain');
|
||||
|
||||
if (extensions.length === 0) {
|
||||
setError('Please install Polkadot.js extension');
|
||||
window.open('https://polkadot.js.org/extension/', '_blank');
|
||||
setError('Please install Pezkuwi.js extension');
|
||||
window.open('https://js.pezkuwichain.io/extension/', '_blank');
|
||||
return;
|
||||
}
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
if (import.meta.env.DEV) console.log('✅ Polkadot.js extension enabled');
|
||||
if (import.meta.env.DEV) console.log('✅ Pezkuwi.js extension enabled');
|
||||
}
|
||||
|
||||
// Get accounts
|
||||
const allAccounts = await web3Accounts();
|
||||
|
||||
if (allAccounts.length === 0) {
|
||||
setError('No accounts found. Please create an account in Polkadot.js extension');
|
||||
setError('No accounts found. Please create an account in Pezkuwi.js extension');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
const value: PolkadotContextType = {
|
||||
const value: PezkuwiContextType = {
|
||||
api,
|
||||
isApiReady,
|
||||
isConnected: isApiReady, // Alias for backward compatibility
|
||||
@@ -233,17 +233,17 @@ export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<PolkadotContext.Provider value={value}>
|
||||
<PezkuwiContext.Provider value={value}>
|
||||
{children}
|
||||
</PolkadotContext.Provider>
|
||||
</PezkuwiContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
// Hook to use Polkadot context
|
||||
export const usePolkadot = (): PolkadotContextType => {
|
||||
const context = useContext(PolkadotContext);
|
||||
// Hook to use Pezkuwi context
|
||||
export const usePezkuwi = (): PezkuwiContextType => {
|
||||
const context = useContext(PezkuwiContext);
|
||||
if (!context) {
|
||||
throw new Error('usePolkadot must be used within PolkadotProvider');
|
||||
throw new Error('usePezkuwi must be used within PezkuwiProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createContext, useContext, useState, useEffect, ReactNode, useCallback } from 'react';
|
||||
import { usePolkadot } from '@/contexts/PolkadotContext';
|
||||
import { usePezkuwi } from '@/contexts/PezkuwiContext';
|
||||
import { useWallet } from '@/contexts/WalletContext';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import {
|
||||
@@ -21,7 +21,7 @@ interface ReferralContextValue {
|
||||
const ReferralContext = createContext<ReferralContextValue | undefined>(undefined);
|
||||
|
||||
export function ReferralProvider({ children }: { children: ReactNode }) {
|
||||
const { api, isApiReady } = usePolkadot();
|
||||
const { api, isApiReady } = usePezkuwi();
|
||||
const { account } = useWallet();
|
||||
const { toast } = useToast();
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// ========================================
|
||||
// WalletContext - Polkadot.js Wallet Integration
|
||||
// WalletContext - Pezkuwi.js Wallet Integration
|
||||
// ========================================
|
||||
// This context wraps PolkadotContext and provides wallet functionality
|
||||
// ⚠️ MIGRATION NOTE: This now uses Polkadot.js instead of MetaMask/Ethereum
|
||||
// This context wraps PezkuwiContext and provides wallet functionality
|
||||
// ⚠️ MIGRATION NOTE: This now uses Pezkuwi.js instead of MetaMask/Ethereum
|
||||
|
||||
import React, { createContext, useContext, useState, useEffect, useCallback } from 'react';
|
||||
import { usePolkadot } from './PolkadotContext';
|
||||
import { usePezkuwi } from './PezkuwiContext';
|
||||
import { WALLET_ERRORS, formatBalance, ASSET_IDS } from '@pezkuwi/lib/wallet';
|
||||
import type { InjectedAccountWithMeta } from '@pezkuwi/extension-inject/types';
|
||||
import type { Signer } from '@pezkuwi/api/types';
|
||||
@@ -25,7 +25,7 @@ interface WalletContextType {
|
||||
balance: string; // Legacy: HEZ balance
|
||||
balances: TokenBalances; // All token balances
|
||||
error: string | null;
|
||||
signer: Signer | null; // Polkadot.js signer for transactions
|
||||
signer: Signer | null; // Pezkuwi.js signer for transactions
|
||||
connectWallet: () => Promise<void>;
|
||||
disconnect: () => void;
|
||||
switchAccount: (account: InjectedAccountWithMeta) => void;
|
||||
@@ -37,13 +37,13 @@ interface WalletContextType {
|
||||
const WalletContext = createContext<WalletContextType | undefined>(undefined);
|
||||
|
||||
export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
const polkadot = usePolkadot();
|
||||
const pezkuwi = usePezkuwi();
|
||||
|
||||
if (import.meta.env.DEV) console.log('🎯 WalletProvider render:', {
|
||||
hasApi: !!polkadot.api,
|
||||
isApiReady: polkadot.isApiReady,
|
||||
selectedAccount: polkadot.selectedAccount?.address,
|
||||
accountsCount: polkadot.accounts.length
|
||||
hasApi: !!pezkuwi.api,
|
||||
isApiReady: pezkuwi.isApiReady,
|
||||
selectedAccount: pezkuwi.selectedAccount?.address,
|
||||
accountsCount: pezkuwi.accounts.length
|
||||
});
|
||||
|
||||
const [balance, setBalance] = useState<string>('0');
|
||||
@@ -53,7 +53,7 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
|
||||
// Fetch all token balances when account changes
|
||||
const updateBalance = useCallback(async (address: string) => {
|
||||
if (!polkadot.api || !polkadot.isApiReady) {
|
||||
if (!pezkuwi.api || !pezkuwi.isApiReady) {
|
||||
if (import.meta.env.DEV) console.warn('API not ready, cannot fetch balance');
|
||||
return;
|
||||
}
|
||||
@@ -62,14 +62,14 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
if (import.meta.env.DEV) console.log('💰 Fetching all token balances for:', address);
|
||||
|
||||
// Fetch HEZ (native token)
|
||||
const { data: nativeBalance } = await polkadot.api.query.system.account(address);
|
||||
const { data: nativeBalance } = await pezkuwi.api.query.system.account(address);
|
||||
const hezBalance = formatBalance(nativeBalance.free.toString());
|
||||
setBalance(hezBalance); // Legacy support
|
||||
|
||||
// Fetch PEZ (Asset ID: 1)
|
||||
let pezBalance = '0';
|
||||
try {
|
||||
const pezData = await polkadot.api.query.assets.account(ASSET_IDS.PEZ, address);
|
||||
const pezData = await pezkuwi.api.query.assets.account(ASSET_IDS.PEZ, address);
|
||||
if (import.meta.env.DEV) console.log('📊 Raw PEZ data:', pezData.toHuman());
|
||||
|
||||
if (pezData.isSome) {
|
||||
@@ -87,7 +87,7 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
// Fetch wHEZ (Asset ID: 0)
|
||||
let whezBalance = '0';
|
||||
try {
|
||||
const whezData = await polkadot.api.query.assets.account(ASSET_IDS.WHEZ, address);
|
||||
const whezData = await pezkuwi.api.query.assets.account(ASSET_IDS.WHEZ, address);
|
||||
if (import.meta.env.DEV) console.log('📊 Raw wHEZ data:', whezData.toHuman());
|
||||
|
||||
if (whezData.isSome) {
|
||||
@@ -105,7 +105,7 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
// Fetch wUSDT (Asset ID: 2) - IMPORTANT: wUSDT has 6 decimals, not 12!
|
||||
let wusdtBalance = '0';
|
||||
try {
|
||||
const wusdtData = await polkadot.api.query.assets.account(ASSET_IDS.WUSDT, address);
|
||||
const wusdtData = await pezkuwi.api.query.assets.account(ASSET_IDS.WUSDT, address);
|
||||
if (import.meta.env.DEV) console.log('📊 Raw wUSDT data:', wusdtData.toHuman());
|
||||
|
||||
if (wusdtData.isSome) {
|
||||
@@ -132,45 +132,45 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
if (import.meta.env.DEV) console.error('Failed to fetch balances:', err);
|
||||
setError('Failed to fetch balances');
|
||||
}
|
||||
}, [polkadot.api, polkadot.isApiReady]);
|
||||
}, [pezkuwi.api, pezkuwi.isApiReady]);
|
||||
|
||||
// Connect wallet (Polkadot.js extension)
|
||||
// Connect wallet (Pezkuwi.js extension)
|
||||
const connectWallet = useCallback(async () => {
|
||||
try {
|
||||
setError(null);
|
||||
await polkadot.connectWallet();
|
||||
await pezkuwi.connectWallet();
|
||||
} catch (err) {
|
||||
if (import.meta.env.DEV) console.error('Wallet connection failed:', err);
|
||||
const errorMessage = err instanceof Error ? err.message : WALLET_ERRORS.CONNECTION_FAILED;
|
||||
setError(errorMessage);
|
||||
}
|
||||
}, [polkadot]);
|
||||
}, [pezkuwi]);
|
||||
|
||||
// Disconnect wallet
|
||||
const disconnect = useCallback(() => {
|
||||
polkadot.disconnectWallet();
|
||||
pezkuwi.disconnectWallet();
|
||||
setBalance('0');
|
||||
setError(null);
|
||||
}, [polkadot]);
|
||||
}, [pezkuwi]);
|
||||
|
||||
// Switch account
|
||||
const switchAccount = useCallback((account: InjectedAccountWithMeta) => {
|
||||
polkadot.setSelectedAccount(account);
|
||||
}, [polkadot]);
|
||||
pezkuwi.setSelectedAccount(account);
|
||||
}, [pezkuwi]);
|
||||
|
||||
// Sign and submit transaction
|
||||
const signTransaction = useCallback(async (tx: unknown): Promise<string> => {
|
||||
if (!polkadot.api || !polkadot.selectedAccount) {
|
||||
if (!pezkuwi.api || !pezkuwi.selectedAccount) {
|
||||
throw new Error(WALLET_ERRORS.API_NOT_READY);
|
||||
}
|
||||
|
||||
try {
|
||||
const { web3FromAddress } = await import('@pezkuwi/extension-dapp');
|
||||
const injector = await web3FromAddress(polkadot.selectedAccount.address);
|
||||
const injector = await web3FromAddress(pezkuwi.selectedAccount.address);
|
||||
|
||||
// Sign and send transaction
|
||||
const hash = await tx.signAndSend(
|
||||
polkadot.selectedAccount.address,
|
||||
pezkuwi.selectedAccount.address,
|
||||
{ signer: injector.signer }
|
||||
);
|
||||
|
||||
@@ -179,24 +179,24 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
if (import.meta.env.DEV) console.error('Transaction failed:', error);
|
||||
throw new Error(error instanceof Error ? error.message : WALLET_ERRORS.TRANSACTION_FAILED);
|
||||
}
|
||||
}, [polkadot.api, polkadot.selectedAccount]);
|
||||
}, [pezkuwi.api, pezkuwi.selectedAccount]);
|
||||
|
||||
// Sign message
|
||||
const signMessage = useCallback(async (message: string): Promise<string> => {
|
||||
if (!polkadot.selectedAccount) {
|
||||
if (!pezkuwi.selectedAccount) {
|
||||
throw new Error('No account selected');
|
||||
}
|
||||
|
||||
try {
|
||||
const { web3FromAddress } = await import('@pezkuwi/extension-dapp');
|
||||
const injector = await web3FromAddress(polkadot.selectedAccount.address);
|
||||
const injector = await web3FromAddress(pezkuwi.selectedAccount.address);
|
||||
|
||||
if (!injector.signer.signRaw) {
|
||||
throw new Error('Wallet does not support message signing');
|
||||
}
|
||||
|
||||
const { signature } = await injector.signer.signRaw({
|
||||
address: polkadot.selectedAccount.address,
|
||||
address: pezkuwi.selectedAccount.address,
|
||||
data: message,
|
||||
type: 'bytes'
|
||||
});
|
||||
@@ -206,16 +206,16 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
if (import.meta.env.DEV) console.error('Message signing failed:', error);
|
||||
throw new Error(error instanceof Error ? error.message : 'Failed to sign message');
|
||||
}
|
||||
}, [polkadot.selectedAccount]);
|
||||
}, [pezkuwi.selectedAccount]);
|
||||
|
||||
// Get signer from extension when account changes
|
||||
useEffect(() => {
|
||||
const getSigner = async () => {
|
||||
if (polkadot.selectedAccount) {
|
||||
if (pezkuwi.selectedAccount) {
|
||||
try {
|
||||
const injector = await web3FromAddress(polkadot.selectedAccount.address);
|
||||
const injector = await web3FromAddress(pezkuwi.selectedAccount.address);
|
||||
setSigner(injector.signer);
|
||||
if (import.meta.env.DEV) console.log('✅ Signer obtained for', polkadot.selectedAccount.address);
|
||||
if (import.meta.env.DEV) console.log('✅ Signer obtained for', pezkuwi.selectedAccount.address);
|
||||
} catch (error) {
|
||||
if (import.meta.env.DEV) console.error('Failed to get signer:', error);
|
||||
setSigner(null);
|
||||
@@ -226,42 +226,42 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
};
|
||||
|
||||
getSigner();
|
||||
}, [polkadot.selectedAccount]);
|
||||
}, [pezkuwi.selectedAccount]);
|
||||
|
||||
// Update balance when selected account changes
|
||||
useEffect(() => {
|
||||
if (import.meta.env.DEV) console.log('🔄 WalletContext useEffect triggered!', {
|
||||
hasAccount: !!polkadot.selectedAccount,
|
||||
isApiReady: polkadot.isApiReady,
|
||||
address: polkadot.selectedAccount?.address
|
||||
hasAccount: !!pezkuwi.selectedAccount,
|
||||
isApiReady: pezkuwi.isApiReady,
|
||||
address: pezkuwi.selectedAccount?.address
|
||||
});
|
||||
|
||||
if (polkadot.selectedAccount && polkadot.isApiReady) {
|
||||
updateBalance(polkadot.selectedAccount.address);
|
||||
if (pezkuwi.selectedAccount && pezkuwi.isApiReady) {
|
||||
updateBalance(pezkuwi.selectedAccount.address);
|
||||
}
|
||||
}, [polkadot.selectedAccount, polkadot.isApiReady, updateBalance]);
|
||||
}, [pezkuwi.selectedAccount, pezkuwi.isApiReady, updateBalance]);
|
||||
|
||||
// Sync error state with PolkadotContext
|
||||
// Sync error state with PezkuwiContext
|
||||
useEffect(() => {
|
||||
if (polkadot.error) {
|
||||
setError(polkadot.error);
|
||||
if (pezkuwi.error) {
|
||||
setError(pezkuwi.error);
|
||||
}
|
||||
}, [polkadot.error]);
|
||||
}, [pezkuwi.error]);
|
||||
|
||||
// Refresh balances for current account
|
||||
const refreshBalances = useCallback(async () => {
|
||||
if (polkadot.selectedAccount) {
|
||||
await updateBalance(polkadot.selectedAccount.address);
|
||||
if (pezkuwi.selectedAccount) {
|
||||
await updateBalance(pezkuwi.selectedAccount.address);
|
||||
}
|
||||
}, [polkadot.selectedAccount, updateBalance]);
|
||||
}, [pezkuwi.selectedAccount, updateBalance]);
|
||||
|
||||
const value: WalletContextType = {
|
||||
isConnected: polkadot.accounts.length > 0,
|
||||
account: polkadot.selectedAccount?.address || null,
|
||||
accounts: polkadot.accounts,
|
||||
isConnected: pezkuwi.accounts.length > 0,
|
||||
account: pezkuwi.selectedAccount?.address || null,
|
||||
accounts: pezkuwi.accounts,
|
||||
balance,
|
||||
balances,
|
||||
error: error || polkadot.error,
|
||||
error: error || pezkuwi.error,
|
||||
signer,
|
||||
connectWallet,
|
||||
disconnect,
|
||||
|
||||
Reference in New Issue
Block a user