mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-07-20 22:25:41 +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)}
|
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"
|
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
|
Mint wUSDT
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => setMintModalAsset(MINTABLE_ASSETS.wDOT)}
|
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"
|
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
|
Mint wDOT
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => setMintModalAsset(MINTABLE_ASSETS.wETH)}
|
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"
|
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
|
Mint wETH
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => setMintModalAsset(MINTABLE_ASSETS.wBTC)}
|
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"
|
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
|
Mint wBTC
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ type TransactionStatus = 'idle' | 'signing' | 'submitting' | 'success' | 'error'
|
|||||||
|
|
||||||
// All supported tokens - filtered dynamically based on available pools
|
// All supported tokens - filtered dynamically based on available pools
|
||||||
const ALL_TOKENS = [
|
const ALL_TOKENS = [
|
||||||
{ symbol: 'HEZ', emoji: '🟡', assetId: -1, name: 'HEZ', decimals: 12, displaySymbol: 'HEZ', logo: '/shared/images/hez_token_512.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: '/shared/images/pez.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: '/shared/images/USDT(hez)logo.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: '/shared/images/dot.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: '/shared/images/etherium.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: '/shared/images/bitcoin.png' },
|
{ symbol: 'BTC', emoji: '🟠', assetId: 1003, name: 'BTC', decimals: 8, displaySymbol: 'BTC', logo: '/tokens/BTC.png' },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
// Helper to get tokens that have available pools
|
// Helper to get tokens that have available pools
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const MINTABLE_ASSETS: Record<string, AssetConfig> = {
|
|||||||
symbol: 'wUSDT',
|
symbol: 'wUSDT',
|
||||||
name: 'Wrapped USDT',
|
name: 'Wrapped USDT',
|
||||||
decimals: 6,
|
decimals: 6,
|
||||||
logo: '/shared/images/USDT(hez)logo.png',
|
logo: '/tokens/USDT.png',
|
||||||
defaultAmount: '10000',
|
defaultAmount: '10000',
|
||||||
color: 'green',
|
color: 'green',
|
||||||
},
|
},
|
||||||
@@ -24,7 +24,7 @@ export const MINTABLE_ASSETS: Record<string, AssetConfig> = {
|
|||||||
symbol: 'wDOT',
|
symbol: 'wDOT',
|
||||||
name: 'Wrapped DOT',
|
name: 'Wrapped DOT',
|
||||||
decimals: 10,
|
decimals: 10,
|
||||||
logo: '/shared/images/dot.png',
|
logo: '/tokens/DOT.png',
|
||||||
defaultAmount: '100',
|
defaultAmount: '100',
|
||||||
color: 'pink',
|
color: 'pink',
|
||||||
},
|
},
|
||||||
@@ -33,7 +33,7 @@ export const MINTABLE_ASSETS: Record<string, AssetConfig> = {
|
|||||||
symbol: 'wETH',
|
symbol: 'wETH',
|
||||||
name: 'Wrapped ETH',
|
name: 'Wrapped ETH',
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
logo: '/shared/images/etherium.png',
|
logo: '/tokens/ETH.png',
|
||||||
defaultAmount: '10',
|
defaultAmount: '10',
|
||||||
color: 'purple',
|
color: 'purple',
|
||||||
},
|
},
|
||||||
@@ -42,7 +42,7 @@ export const MINTABLE_ASSETS: Record<string, AssetConfig> = {
|
|||||||
symbol: 'wBTC',
|
symbol: 'wBTC',
|
||||||
name: 'Wrapped BTC',
|
name: 'Wrapped BTC',
|
||||||
decimals: 8,
|
decimals: 8,
|
||||||
logo: '/shared/images/bitcoin.png',
|
logo: '/tokens/BTC.png',
|
||||||
defaultAmount: '1',
|
defaultAmount: '1',
|
||||||
color: 'orange',
|
color: 'orange',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { AlertCircle, CheckCircle2 } from 'lucide-react';
|
|||||||
import { usePezkuwi } from '@/contexts/PezkuwiContext';
|
import { usePezkuwi } from '@/contexts/PezkuwiContext';
|
||||||
import { useWallet } from '@/contexts/WalletContext';
|
import { useWallet } from '@/contexts/WalletContext';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { web3FromAddress } from '@pezkuwi/extension-dapp';
|
import { web3FromAddress, web3Enable } from '@pezkuwi/extension-dapp';
|
||||||
import {
|
import {
|
||||||
getStakingInfo,
|
getStakingInfo,
|
||||||
getActiveValidators,
|
getActiveValidators,
|
||||||
@@ -30,6 +30,19 @@ import { LoadingState } from '@pezkuwi/components/AsyncComponent';
|
|||||||
import { ValidatorPoolDashboard } from './ValidatorPoolDashboard';
|
import { ValidatorPoolDashboard } from './ValidatorPoolDashboard';
|
||||||
import { handleBlockchainError, handleBlockchainSuccess } from '@pezkuwi/lib/error-handler';
|
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 = () => {
|
export const StakingDashboard: React.FC = () => {
|
||||||
const { api, peopleApi, selectedAccount, isApiReady, isPeopleReady } = usePezkuwi();
|
const { api, peopleApi, selectedAccount, isApiReady, isPeopleReady } = usePezkuwi();
|
||||||
const { balances, refreshBalances } = useWallet();
|
const { balances, refreshBalances } = useWallet();
|
||||||
@@ -113,7 +126,7 @@ export const StakingDashboard: React.FC = () => {
|
|||||||
|
|
||||||
setIsRecordingScore(true);
|
setIsRecordingScore(true);
|
||||||
try {
|
try {
|
||||||
const injector = await web3FromAddress(selectedAccount.address);
|
const injector = await getInjectorSigner(selectedAccount.address);
|
||||||
const result = await recordTrustScore(peopleApi, selectedAccount.address, injector.signer);
|
const result = await recordTrustScore(peopleApi, selectedAccount.address, injector.signer);
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -141,7 +154,7 @@ export const StakingDashboard: React.FC = () => {
|
|||||||
|
|
||||||
setIsClaimingReward(true);
|
setIsClaimingReward(true);
|
||||||
try {
|
try {
|
||||||
const injector = await web3FromAddress(selectedAccount.address);
|
const injector = await getInjectorSigner(selectedAccount.address);
|
||||||
const result = await claimPezReward(peopleApi, selectedAccount.address, epochIndex, injector.signer);
|
const result = await claimPezReward(peopleApi, selectedAccount.address, epochIndex, injector.signer);
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -182,7 +195,7 @@ export const StakingDashboard: React.FC = () => {
|
|||||||
throw new Error('Insufficient HEZ balance');
|
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
|
// If already bonded, use bondExtra, otherwise use bond
|
||||||
let tx;
|
let tx;
|
||||||
@@ -235,7 +248,7 @@ export const StakingDashboard: React.FC = () => {
|
|||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const injector = await web3FromAddress(selectedAccount.address);
|
const injector = await getInjectorSigner(selectedAccount.address);
|
||||||
|
|
||||||
const tx = api.tx.staking.nominate(selectedValidators);
|
const tx = api.tx.staking.nominate(selectedValidators);
|
||||||
|
|
||||||
@@ -278,7 +291,7 @@ export const StakingDashboard: React.FC = () => {
|
|||||||
throw new Error('Insufficient staked amount');
|
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);
|
const tx = api.tx.staking.unbond(amount);
|
||||||
|
|
||||||
await tx.signAndSend(
|
await tx.signAndSend(
|
||||||
@@ -322,7 +335,7 @@ export const StakingDashboard: React.FC = () => {
|
|||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const injector = await web3FromAddress(selectedAccount.address);
|
const injector = await getInjectorSigner(selectedAccount.address);
|
||||||
|
|
||||||
// Number of slashing spans (usually 0)
|
// Number of slashing spans (usually 0)
|
||||||
const tx = api.tx.staking.withdrawUnbonded(0);
|
const tx = api.tx.staking.withdrawUnbonded(0);
|
||||||
@@ -370,7 +383,7 @@ export const StakingDashboard: React.FC = () => {
|
|||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
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
|
// stakingScore pallet is on People Chain - uses cached staking data from Asset Hub
|
||||||
const tx = peopleApi.tx.stakingScore.startScoreTracking();
|
const tx = peopleApi.tx.stakingScore.startScoreTracking();
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,10 @@ export const PezkuwiProvider: React.FC<PezkuwiProviderProps> = ({
|
|||||||
extrinsic: {},
|
extrinsic: {},
|
||||||
payload: {},
|
payload: {},
|
||||||
},
|
},
|
||||||
|
StorageWeightReclaim: {
|
||||||
|
extrinsic: {},
|
||||||
|
payload: {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -198,6 +202,10 @@ export const PezkuwiProvider: React.FC<PezkuwiProviderProps> = ({
|
|||||||
extrinsic: {},
|
extrinsic: {},
|
||||||
payload: {},
|
payload: {},
|
||||||
},
|
},
|
||||||
|
StorageWeightReclaim: {
|
||||||
|
extrinsic: {},
|
||||||
|
payload: {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -232,6 +240,10 @@ export const PezkuwiProvider: React.FC<PezkuwiProviderProps> = ({
|
|||||||
extrinsic: {},
|
extrinsic: {},
|
||||||
payload: {},
|
payload: {},
|
||||||
},
|
},
|
||||||
|
StorageWeightReclaim: {
|
||||||
|
extrinsic: {},
|
||||||
|
payload: {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user