Add missing inline preimage conditions (#8882)

This commit is contained in:
Jaco 2023-01-25 13:19:59 +02:00 committed by GitHub
parent 564c3b267a
commit 7d1e037fdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -3,7 +3,7 @@
import type { ApiPromise } from '@polkadot/api';
import type { Hash } from '@polkadot/types/interfaces';
import type { PalletConvictionVotingTally, PalletRankedCollectiveTally, PalletReferendaDeposit, PalletReferendaTrackInfo } from '@polkadot/types/lookup';
import type { PalletConvictionVotingTally, PalletRankedCollectiveTally, PalletReferendaDeposit, PalletReferendaReferendumStatusConvictionVotingTally, PalletReferendaReferendumStatusRankedCollectiveTally, PalletReferendaTrackInfo } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { HexString } from '@polkadot/util/types';
import type { Referendum, ReferendumProps as Props } from '../types';
@ -29,6 +29,7 @@ interface Expanded {
decideEnd: BN | null;
confirmEnd: BN | null;
};
ongoing: PalletReferendaReferendumStatusConvictionVotingTally | PalletReferendaReferendumStatusRankedCollectiveTally;
proposalHash?: HexString;
submissionDeposit: PalletReferendaDeposit | null;
tally: PalletConvictionVotingTally | PalletRankedCollectiveTally;
@ -63,6 +64,7 @@ function expandOngoing (api: ApiPromise, info: Referendum['info'], track?: Palle
return {
decisionDeposit: unwrapDeposit(ongoing.decisionDeposit),
ongoing,
periods: {
confirmEnd,
decideEnd,
@ -80,12 +82,12 @@ function Ongoing ({ isMember, members, palletReferenda, palletVote, ranks, track
const { t } = useTranslation();
const { api } = useApi();
const { decisionDeposit, periods: { confirmEnd, decideEnd, periodEnd }, proposalHash, submissionDeposit, tally, tallyTotal } = useMemo(
const { decisionDeposit, ongoing, periods: { confirmEnd, decideEnd, periodEnd }, submissionDeposit, tally, tallyTotal } = useMemo(
() => expandOngoing(api, info, track),
[api, info, track]
);
const preimage = usePreimage(proposalHash);
const preimage = usePreimage(ongoing.proposal || (ongoing as unknown as { proposalHash: Hash }).proposalHash);
return (
<>
@ -98,7 +100,7 @@ function Ongoing ({ isMember, members, palletReferenda, palletVote, ranks, track
withHash
/>
)
: <div className='shortHash'>{proposalHash}</div>
: <div className='shortHash'>{preimage?.proposalHash}</div>
}
</td>
<Deposits

View File

@ -207,7 +207,7 @@ function usePreimageImpl (hashOrBounded?: Hash | HexString | FrameSupportPreimag
[api, hashOrBounded]
);
const optStatus = useCall<Option<PalletPreimageRequestStatus>>(paramsStatus && api.query.preimage?.statusFor, paramsStatus);
const optStatus = useCall<Option<PalletPreimageRequestStatus>>(!inlineData && paramsStatus && api.query.preimage?.statusFor, paramsStatus);
// from the retrieved status (if any), get the on-chain stored bytes
const { paramsBytes, resultPreimageFor } = useMemo(