mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 02:07:55 +00:00
fix: broken image paths and staking signer reconnect
This commit is contained in:
@@ -142,28 +142,28 @@ export const DEXDashboard: React.FC = () => {
|
||||
onClick={() => setShowInitializeUsdtModal(true)}
|
||||
className="flex items-center justify-center gap-2 px-4 py-3 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors font-medium"
|
||||
>
|
||||
<img src="/shared/images/USDT(hez)logo.png" alt="USDT" className="w-5 h-5 rounded-full" />
|
||||
<img src="/tokens/USDT.png" alt="USDT" className="w-5 h-5 rounded-full" />
|
||||
Mint wUSDT
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setMintModalAsset(MINTABLE_ASSETS.wDOT)}
|
||||
className="flex items-center justify-center gap-2 px-4 py-3 bg-pink-600 hover:bg-pink-700 text-white rounded-lg transition-colors font-medium"
|
||||
>
|
||||
<img src="/shared/images/dot.png" alt="DOT" className="w-5 h-5 rounded-full" />
|
||||
<img src="/tokens/DOT.png" alt="DOT" className="w-5 h-5 rounded-full" />
|
||||
Mint wDOT
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setMintModalAsset(MINTABLE_ASSETS.wETH)}
|
||||
className="flex items-center justify-center gap-2 px-4 py-3 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium"
|
||||
>
|
||||
<img src="/shared/images/etherium.png" alt="ETH" className="w-5 h-5 rounded-full" />
|
||||
<img src="/tokens/ETH.png" alt="ETH" className="w-5 h-5 rounded-full" />
|
||||
Mint wETH
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setMintModalAsset(MINTABLE_ASSETS.wBTC)}
|
||||
className="flex items-center justify-center gap-2 px-4 py-3 bg-orange-600 hover:bg-orange-700 text-white rounded-lg transition-colors font-medium"
|
||||
>
|
||||
<img src="/shared/images/bitcoin.png" alt="BTC" className="w-5 h-5 rounded-full" />
|
||||
<img src="/tokens/BTC.png" alt="BTC" className="w-5 h-5 rounded-full" />
|
||||
Mint wBTC
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -26,12 +26,12 @@ type TransactionStatus = 'idle' | 'signing' | 'submitting' | 'success' | 'error'
|
||||
|
||||
// All supported tokens - filtered dynamically based on available pools
|
||||
const ALL_TOKENS = [
|
||||
{ symbol: 'HEZ', emoji: '🟡', assetId: -1, name: 'HEZ', decimals: 12, displaySymbol: 'HEZ', logo: '/shared/images/hez_token_512.png' },
|
||||
{ symbol: 'PEZ', emoji: '🔵', assetId: 1, name: 'PEZ', decimals: 12, displaySymbol: 'PEZ', logo: '/shared/images/pez.png' },
|
||||
{ symbol: 'USDT', emoji: '💵', assetId: 1000, name: 'USDT', decimals: 6, displaySymbol: 'USDT', logo: '/shared/images/USDT(hez)logo.png' },
|
||||
{ symbol: 'DOT', emoji: '🔴', assetId: 1001, name: 'DOT', decimals: 10, displaySymbol: 'DOT', logo: '/shared/images/dot.png' },
|
||||
{ symbol: 'ETH', emoji: '💎', assetId: 1002, name: 'ETH', decimals: 18, displaySymbol: 'ETH', logo: '/shared/images/etherium.png' },
|
||||
{ symbol: 'BTC', emoji: '🟠', assetId: 1003, name: 'BTC', decimals: 8, displaySymbol: 'BTC', logo: '/shared/images/bitcoin.png' },
|
||||
{ symbol: 'HEZ', emoji: '🟡', assetId: -1, name: 'HEZ', decimals: 12, displaySymbol: 'HEZ', logo: '/tokens/HEZ.png' },
|
||||
{ symbol: 'PEZ', emoji: '🔵', assetId: 1, name: 'PEZ', decimals: 12, displaySymbol: 'PEZ', logo: '/tokens/PEZ.png' },
|
||||
{ symbol: 'USDT', emoji: '💵', assetId: 1000, name: 'USDT', decimals: 6, displaySymbol: 'USDT', logo: '/tokens/USDT.png' },
|
||||
{ symbol: 'DOT', emoji: '🔴', assetId: 1001, name: 'DOT', decimals: 10, displaySymbol: 'DOT', logo: '/tokens/DOT.png' },
|
||||
{ symbol: 'ETH', emoji: '💎', assetId: 1002, name: 'ETH', decimals: 18, displaySymbol: 'ETH', logo: '/tokens/ETH.png' },
|
||||
{ symbol: 'BTC', emoji: '🟠', assetId: 1003, name: 'BTC', decimals: 8, displaySymbol: 'BTC', logo: '/tokens/BTC.png' },
|
||||
] as const;
|
||||
|
||||
// Helper to get tokens that have available pools
|
||||
|
||||
@@ -15,7 +15,7 @@ export const MINTABLE_ASSETS: Record<string, AssetConfig> = {
|
||||
symbol: 'wUSDT',
|
||||
name: 'Wrapped USDT',
|
||||
decimals: 6,
|
||||
logo: '/shared/images/USDT(hez)logo.png',
|
||||
logo: '/tokens/USDT.png',
|
||||
defaultAmount: '10000',
|
||||
color: 'green',
|
||||
},
|
||||
@@ -24,7 +24,7 @@ export const MINTABLE_ASSETS: Record<string, AssetConfig> = {
|
||||
symbol: 'wDOT',
|
||||
name: 'Wrapped DOT',
|
||||
decimals: 10,
|
||||
logo: '/shared/images/dot.png',
|
||||
logo: '/tokens/DOT.png',
|
||||
defaultAmount: '100',
|
||||
color: 'pink',
|
||||
},
|
||||
@@ -33,7 +33,7 @@ export const MINTABLE_ASSETS: Record<string, AssetConfig> = {
|
||||
symbol: 'wETH',
|
||||
name: 'Wrapped ETH',
|
||||
decimals: 18,
|
||||
logo: '/shared/images/etherium.png',
|
||||
logo: '/tokens/ETH.png',
|
||||
defaultAmount: '10',
|
||||
color: 'purple',
|
||||
},
|
||||
@@ -42,7 +42,7 @@ export const MINTABLE_ASSETS: Record<string, AssetConfig> = {
|
||||
symbol: 'wBTC',
|
||||
name: 'Wrapped BTC',
|
||||
decimals: 8,
|
||||
logo: '/shared/images/bitcoin.png',
|
||||
logo: '/tokens/BTC.png',
|
||||
defaultAmount: '1',
|
||||
color: 'orange',
|
||||
},
|
||||
|
||||
@@ -10,7 +10,7 @@ import { AlertCircle, CheckCircle2 } from 'lucide-react';
|
||||
import { usePezkuwi } from '@/contexts/PezkuwiContext';
|
||||
import { useWallet } from '@/contexts/WalletContext';
|
||||
import { toast } from 'sonner';
|
||||
import { web3FromAddress } from '@pezkuwi/extension-dapp';
|
||||
import { web3FromAddress, web3Enable } from '@pezkuwi/extension-dapp';
|
||||
import {
|
||||
getStakingInfo,
|
||||
getActiveValidators,
|
||||
@@ -30,6 +30,19 @@ import { LoadingState } from '@pezkuwi/components/AsyncComponent';
|
||||
import { ValidatorPoolDashboard } from './ValidatorPoolDashboard';
|
||||
import { handleBlockchainError, handleBlockchainSuccess } from '@pezkuwi/lib/error-handler';
|
||||
|
||||
// Get signer with auto-reconnect if extension session expired
|
||||
async function getInjectorSigner(address: string) {
|
||||
let injector = await web3FromAddress(address);
|
||||
if (!injector?.signer) {
|
||||
await web3Enable('PezkuwiChain');
|
||||
injector = await web3FromAddress(address);
|
||||
if (!injector?.signer) {
|
||||
throw new Error('Wallet signer not available. Please reconnect your wallet.');
|
||||
}
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
|
||||
export const StakingDashboard: React.FC = () => {
|
||||
const { api, peopleApi, selectedAccount, isApiReady, isPeopleReady } = usePezkuwi();
|
||||
const { balances, refreshBalances } = useWallet();
|
||||
@@ -113,7 +126,7 @@ export const StakingDashboard: React.FC = () => {
|
||||
|
||||
setIsRecordingScore(true);
|
||||
try {
|
||||
const injector = await web3FromAddress(selectedAccount.address);
|
||||
const injector = await getInjectorSigner(selectedAccount.address);
|
||||
const result = await recordTrustScore(peopleApi, selectedAccount.address, injector.signer);
|
||||
|
||||
if (result.success) {
|
||||
@@ -141,7 +154,7 @@ export const StakingDashboard: React.FC = () => {
|
||||
|
||||
setIsClaimingReward(true);
|
||||
try {
|
||||
const injector = await web3FromAddress(selectedAccount.address);
|
||||
const injector = await getInjectorSigner(selectedAccount.address);
|
||||
const result = await claimPezReward(peopleApi, selectedAccount.address, epochIndex, injector.signer);
|
||||
|
||||
if (result.success) {
|
||||
@@ -182,7 +195,7 @@ export const StakingDashboard: React.FC = () => {
|
||||
throw new Error('Insufficient HEZ balance');
|
||||
}
|
||||
|
||||
const injector = await web3FromAddress(selectedAccount.address);
|
||||
const injector = await getInjectorSigner(selectedAccount.address);
|
||||
|
||||
// If already bonded, use bondExtra, otherwise use bond
|
||||
let tx;
|
||||
@@ -235,7 +248,7 @@ export const StakingDashboard: React.FC = () => {
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const injector = await web3FromAddress(selectedAccount.address);
|
||||
const injector = await getInjectorSigner(selectedAccount.address);
|
||||
|
||||
const tx = api.tx.staking.nominate(selectedValidators);
|
||||
|
||||
@@ -278,7 +291,7 @@ export const StakingDashboard: React.FC = () => {
|
||||
throw new Error('Insufficient staked amount');
|
||||
}
|
||||
|
||||
const injector = await web3FromAddress(selectedAccount.address);
|
||||
const injector = await getInjectorSigner(selectedAccount.address);
|
||||
const tx = api.tx.staking.unbond(amount);
|
||||
|
||||
await tx.signAndSend(
|
||||
@@ -322,7 +335,7 @@ export const StakingDashboard: React.FC = () => {
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const injector = await web3FromAddress(selectedAccount.address);
|
||||
const injector = await getInjectorSigner(selectedAccount.address);
|
||||
|
||||
// Number of slashing spans (usually 0)
|
||||
const tx = api.tx.staking.withdrawUnbonded(0);
|
||||
@@ -370,7 +383,7 @@ export const StakingDashboard: React.FC = () => {
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const injector = await web3FromAddress(selectedAccount.address);
|
||||
const injector = await getInjectorSigner(selectedAccount.address);
|
||||
// stakingScore pallet is on People Chain - uses cached staking data from Asset Hub
|
||||
const tx = peopleApi.tx.stakingScore.startScoreTracking();
|
||||
|
||||
|
||||
@@ -121,6 +121,10 @@ export const PezkuwiProvider: React.FC<PezkuwiProviderProps> = ({
|
||||
extrinsic: {},
|
||||
payload: {},
|
||||
},
|
||||
StorageWeightReclaim: {
|
||||
extrinsic: {},
|
||||
payload: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -198,6 +202,10 @@ export const PezkuwiProvider: React.FC<PezkuwiProviderProps> = ({
|
||||
extrinsic: {},
|
||||
payload: {},
|
||||
},
|
||||
StorageWeightReclaim: {
|
||||
extrinsic: {},
|
||||
payload: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -232,6 +240,10 @@ export const PezkuwiProvider: React.FC<PezkuwiProviderProps> = ({
|
||||
extrinsic: {},
|
||||
payload: {},
|
||||
},
|
||||
StorageWeightReclaim: {
|
||||
extrinsic: {},
|
||||
payload: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user