refactor: Completed final cleanup and resolved local changes before push

This commit is contained in:
2025-11-21 07:28:47 +03:00
parent c8b3007449
commit 60a32a325e
20 changed files with 389 additions and 35 deletions
+13
View File
@@ -14,6 +14,7 @@ interface PolkadotContextType {
connectWallet: () => Promise<void>;
disconnectWallet: () => void;
error: string | null;
sudoKey: string | null;
}
const PolkadotContext = createContext<PolkadotContextType | undefined>(undefined);
@@ -32,6 +33,7 @@ export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
const [accounts, setAccounts] = useState<InjectedAccountWithMeta[]>([]);
const [selectedAccount, setSelectedAccount] = useState<InjectedAccountWithMeta | null>(null);
const [error, setError] = useState<string | null>(null);
const [sudoKey, setSudoKey] = useState<string | null>(null);
// Wrapper to trigger events when wallet changes
const handleSetSelectedAccount = (account: InjectedAccountWithMeta | null) => {
@@ -88,6 +90,16 @@ export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
if (import.meta.env.DEV) console.log(`🖥️ Node: ${nodeName} v${nodeVersion}`);
}
// Fetch sudo key from blockchain
try {
const sudoAccount = await apiInstance.query.sudo.key();
const sudoAddress = sudoAccount.toString();
setSudoKey(sudoAddress);
if (import.meta.env.DEV) console.log(`🔑 Sudo key: ${sudoAddress}`);
} catch (err) {
if (import.meta.env.DEV) console.warn('⚠️ Failed to fetch sudo key (sudo pallet may not be available):', err);
}
return;
} catch (err) {
lastError = err;
@@ -216,6 +228,7 @@ export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
connectWallet,
disconnectWallet,
error,
sudoKey,
};
return (