fix for the min collateral needed

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2026-02-20 18:57:04 +03:00
parent e05fc99296
commit 7733a6cd3b
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
2 changed files with 12 additions and 11 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "ghost-dao-interface", "name": "ghost-dao-interface",
"private": true, "private": true,
"version": "0.5.29", "version": "0.5.30",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@ -96,6 +96,7 @@ export const useMinQuorum = (chainId) => {
export const useProposalThreshold = (chainId, name) => { export const useProposalThreshold = (chainId, name) => {
const decimals = getTokenDecimals(name); const decimals = getTokenDecimals(name);
const { proposalCount } = useProposalCount(chainId);
const { data } = useReadContract({ const { data } = useReadContract({
abi: GovernorStorageAbi, abi: GovernorStorageAbi,
@ -113,19 +114,19 @@ export const useProposalThreshold = (chainId, name) => {
chainId: chainId, chainId: chainId,
}); });
const lastIndex = proposalCount === 0n ? 0n : proposalCount - 1n;
const { proposalId } = useProposalDetailsAt(chainId, lastIndex, {
enabled: proposalCount !== 0n
});
const { state } = useProposalState(chainId, proposalId, {
enabled: proposalCount !== 0n && !!proposalId
});
let threshold = new DecimalBigNumber(data ?? 0n, decimals); let threshold = new DecimalBigNumber(data ?? 0n, decimals);
const { proposalCount } = useProposalCount(chainId); if (proposalCount !== 0n && state !== undefined && state < 2) {
if (proposalCount !== 0n) {
const lastIndex = proposalCount === 0n ? 0n : proposalCount - 1n
const { proposalId } = useProposalDetailsAt(chainId, lastIndex);
const { state } = useProposalState(chainId, proposalId);
if (state < 2) {
threshold = new DecimalBigNumber(activeProposedLock ?? 0n, decimals); threshold = new DecimalBigNumber(activeProposedLock ?? 0n, decimals);
} }
}
return { threshold }; return { threshold };
} }