Adjust for Westend paras naming (#5197)

This commit is contained in:
Jaco 2021-05-03 20:07:37 +03:00 committed by GitHub
parent 8dc95cf2c1
commit fa9a982eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 25 deletions

View File

@ -75,7 +75,7 @@ function Bid ({ auctionInfo, className, lastWinners, ownedIds }: Props): React.R
<>
<Button
icon='plus'
isDisabled={!ownedIds.length || !hasAccounts || !auctionInfo?.numAuctions || !auctionInfo.leasePeriod || !auctionInfo.endBlock || bestNumber?.gte(auctionInfo.endBlock.add(api.consts.auctions.endingPeriod as BlockNumber))}
isDisabled={!ownedIds.length || !hasAccounts || !auctionInfo?.numAuctions || !auctionInfo.leasePeriod || !auctionInfo.endBlock || !api.consts.auctions || bestNumber?.gte(auctionInfo.endBlock.add(api.consts.auctions.endingPeriod as BlockNumber))}
label={t<string>('Bid')}
onClick={toggleOpen}
/>

View File

@ -83,7 +83,7 @@ function Summary ({ auctionInfo, className, lastWinners }: Props): React.ReactEl
<CardSummary
label={t<string>('ending period')}
progress={{
total: api.consts.auctions.endingPeriod as BlockNumber,
total: api.consts.auctions?.endingPeriod as BlockNumber,
value: bestNumber.sub(auctionInfo.endBlock),
withTime: true
}}

View File

@ -103,12 +103,12 @@ function Parachain ({ bestNumber, channelDst, channelSrc, className = '', id, la
[api.query.paras.heads, id],
[api.query.paras.futureCodeUpgrades, id],
[api.query.paras.paraLifecycles, id],
[api.query.dmp.downwardMessageQueues, id],
[api.query.ump.relayDispatchQueues, id],
[api.query.hrmp.hrmpEgressChannelsIndex, id],
[api.query.hrmp.hrmpIngressChannelsIndex, id],
[api.query.hrmp.hrmpWatermarks, id],
[api.query.inclusion.pendingAvailability, id],
[(api.query.parasDmp || api.query.dmp)?.downwardMessageQueues, id],
[(api.query.parasUmp || api.query.ump)?.relayDispatchQueues, id],
[(api.query.parasHrmp || api.query.hrmp)?.hrmpEgressChannelsIndex, id],
[(api.query.parasHrmp || api.query.hrmp)?.hrmpIngressChannelsIndex, id],
[(api.query.parasHrmp || api.query.hrmp)?.hrmpWatermarks, id],
[(api.query.parasInclusion || api.query.inclusion)?.pendingAvailability, id],
[api.query.registrar.paras, id],
[api.query.slots.leases, id]
], optionsMulti);

View File

@ -89,13 +89,13 @@ function extractEvents (api: ApiPromise, lastBlock: SignedBlockExtended, prev: L
lastBlock.events.forEach(({ event, phase }) => {
if (phase.isApplyExtrinsic) {
if (api.events.inclusion.CandidateBacked.is(event)) {
if ((api.events.parasInclusion || api.events.inclusion)?.CandidateBacked.is(event)) {
includeEntry(backed, event, blockHash, blockNumber);
wasBacked = true;
} else if (api.events.inclusion.CandidateIncluded.is(event)) {
} else if ((api.events.parasInclusion || api.events.inclusion)?.CandidateIncluded.is(event)) {
includeEntry(included, event, blockHash, blockNumber);
wasIncluded = true;
} else if (api.events.inclusion.CandidateTimedOut.is(event)) {
} else if ((api.events.parasInclusion || api.events.inclusion)?.CandidateTimedOut.is(event)) {
includeEntry(timeout, event, blockHash, blockNumber);
wasTimeout = true;
}
@ -149,8 +149,8 @@ function Parachains ({ actionsQueue, ids, leasePeriod, scheduled }: Props): Reac
const [{ lastBacked, lastIncluded, lastTimeout }, setLastEvents] = useState<LastEvents>(EMPTY_EVENTS);
const [validators, validatorGroups, activeIndices] = useCallMulti<MultiResult>([
api.query.session.validators,
api.query.paraScheduler?.validatorGroups || api.query.scheduler?.validatorGroups,
api.query.shared.activeValidatorIndices
(api.query.parasScheduler || api.query.paraScheduler || api.query.scheduler)?.validatorGroups,
(api.query.parasShared || api.query.shared)?.activeValidatorIndices
], optionsMulti);
const hrmp = useHrmp();
const hasLinksMap = useIsParasLinked(ids);

View File

@ -24,7 +24,7 @@ export default function useAuctionInfo (): AuctionInfo | undefined {
const { api } = useApi();
return useCallMulti<AuctionInfo>([
api.query.auctions.auctionCounter,
api.query.auctions.auctionInfo
api.query.auctions?.auctionCounter,
api.query.auctions?.auctionInfo
], optionsMulti);
}

View File

@ -166,9 +166,9 @@ function extractFundIds (keys: StorageKey<[ParaId]>[]): ParaId[] {
export default function useFunds (): Campaigns {
const { api } = useApi();
const bestNumber = useBestNumber();
const trigger = useEventTrigger([api.events.crowdloan.Created]);
const paraIds = useMapKeys(api.query.crowdloan.funds, { at: trigger, transform: extractFundIds });
const campaigns = useCall<Campaign[]>(api.query.crowdloan.funds.multi, [paraIds], optFundMulti);
const trigger = useEventTrigger([api.events.crowdloan?.Created]);
const paraIds = useMapKeys(api.query.crowdloan?.funds, { at: trigger, transform: extractFundIds });
const campaigns = useCall<Campaign[]>(api.query.crowdloan?.funds.multi, [paraIds], optFundMulti);
const leases = useCall<ParaId[]>(api.query.slots.leases.multi, [paraIds], optLeaseMulti);
const [result, setResult] = useState<Campaigns>(EMPTY);

View File

@ -31,8 +31,11 @@ function extractChannelIds (keys: StorageKey<[HrmpChannelId]>[]): HrmpChannelId[
export default function useHrmp (): AllChannels | undefined {
const { api } = useApi();
const trigger = useEventTrigger([api.events.hrmp.OpenChannelAccepted, api.events.hrmp.ChannelClosed]);
const channelIds = useMapKeys(api.query.hrmp.hrmpChannels, { at: trigger, transform: extractChannelIds });
const trigger = useEventTrigger([
(api.events.parasHrmp || api.events.hrmp)?.OpenChannelAccepted,
(api.events.parasHrmp || api.events.hrmp)?.ChannelClosed
]);
const channelIds = useMapKeys((api.query.parasHrmp || api.query.hrmp)?.hrmpChannels, { at: trigger, transform: extractChannelIds });
return useCall<AllChannels>(channelIds && api.query.hrmp.hrmpChannels.multi, [channelIds], optChannels);
return useCall<AllChannels>(channelIds && (api.query.parasHrmp || api.query.hrmp)?.hrmpChannels.multi, [channelIds], optChannels);
}

View File

@ -23,7 +23,7 @@ export default function useRanges (): [number, number][] {
return useMemo(
(): [number, number][] => {
if (isU32(api.consts.auctions.leasePeriodsPerSlot)) {
if (isU32(api.consts.auctions?.leasePeriodsPerSlot)) {
const ranges: [number, number][] = [];
for (let i = 0; api.consts.auctions.leasePeriodsPerSlot.gtn(i); i++) {

View File

@ -126,10 +126,10 @@ export default function useWinningData (auctionInfo?: AuctionInfo): Winning[] |
const ranges = useRanges();
const [result, setResult] = useState<Winning[] | undefined>();
const bestNumber = useBestNumber();
const trigger = useEventTrigger([api.events.auctions.BidAccepted]);
const trigger = useEventTrigger([api.events.auctions?.BidAccepted]);
const triggerRef = useRef(trigger);
const initialEntries = useCall<[StorageKey<[BlockNumber]>, Option<WinningData>][]>(api.query.auctions.winning.entries);
const optFirstData = useCall<Option<WinningData>>(api.query.auctions.winning, FIRST_PARAM);
const initialEntries = useCall<[StorageKey<[BlockNumber]>, Option<WinningData>][]>(api.query.auctions?.winning.entries);
const optFirstData = useCall<Option<WinningData>>(api.query.auctions?.winning, FIRST_PARAM);
// should be fired once, all entries as an initial round
useEffect((): void => {