Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 Fix mocked council stages following the Nara upgrade #4807

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions packages/ui/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createGlobalStyle } from 'styled-components'

import { GlobalModals } from '../src/app/GlobalModals'
import { GlobalStyle } from '../src/app/providers/GlobalStyle'
import { ResponsiveProvider } from '../src/common/providers/responsive/provider'
import { OnBoardingProvider } from '../src/common/providers/onboarding/provider'
import { NotificationsHolder } from '../src/common/components/page/SideNotification'
import { TransactionStatus } from '../src/common/components/TransactionStatus/TransactionStatus'
Expand Down Expand Up @@ -53,16 +54,18 @@ const RHFDecorator: Decorator = (Story) => {
)
}

const ModalDecorator: Decorator = (Story) => (
const Providers: Decorator = (Story) => (
<TransactionStatusProvider>
<ModalContextProvider>
<OnBoardingProvider>
<ValidatorContextProvider>
<Story />
<GlobalModals />
<NotificationsHolder>
<TransactionStatus />
</NotificationsHolder>
<ResponsiveProvider>
<Story />
<GlobalModals />
<NotificationsHolder>
<TransactionStatus />
</NotificationsHolder>
</ResponsiveProvider>
</ValidatorContextProvider>
</OnBoardingProvider>
</ModalContextProvider>
Expand All @@ -85,7 +88,7 @@ const KeyringDecorator: Decorator = (Story) => {
}

export const decorators = [
ModalDecorator,
Providers,
stylesWrapperDecorator,
i18nextDecorator,
RHFDecorator,
Expand Down
2 changes: 0 additions & 2 deletions packages/ui/src/app/App.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ export default {
: {
query: {
members: { membershipPrice: joy(20) },
council: { stage: { stage: { isIdle: true }, changedAt: 123 } },
referendum: { stage: {} },
staking: {
validators: {
entries: Object.entries(validators).map(([address, { commission }]) => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ export default {
accounts: { list: allAccounts },
chain: {
query: {
council: {
stage: { stage: { isIdle: true }, changedAt: 123 },
},
referendum: {
accountsOptedOut: {
keys: Array.from({ length: 23 }).map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export default {
council: {
budget: joy(1000),
councilorReward: joy(1),
stage: { stage: { isIdle: true }, changedAt: 123 },
},
referendum: { stage: {} },
},
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/src/council/hooks/useElectionStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ export const useElectionStage = (): UseElectionStage => {
export const electionStageObservable = (api: Api) => {
const councilObservable = api.query.council.stage().pipe(
concatMap(({ stage: councilStage, changedAt }): Observable<StageInfo> => {
if (councilStage.isIdle) {
if (councilStage.isIdle.valueOf()) {
return of({ stage: 'inactive', changedAt })
} else if (councilStage.isAnnouncing) {
} else if (councilStage.isAnnouncing.valueOf()) {
return of({ stage: 'announcing', changedAt })
}
return EMPTY
})
)
const referendumObservable = api.query.referendum.stage().pipe(
concatMap((referendumStage): Observable<StageInfo> => {
if (referendumStage.isVoting) {
if (referendumStage.isVoting.valueOf()) {
return of({ stage: 'voting', changedAt: referendumStage.asVoting.started })
} else if (referendumStage.isRevealing) {
} else if (referendumStage.isRevealing.valueOf()) {
return of({ stage: 'revealing', changedAt: referendumStage.asRevealing.started })
}
return EMPTY
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/mocks/data/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ export const proposalsPagesChain = (
budget: councilBudget,
councilorReward,
nextRewardPayments,
stage: { stage: { isIdle: true }, changedAt: 123 },
},
referendum: { stage: {} },

Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/mocks/providers/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export const MockApiProvider: FC<MockApiProps> = ({ children, chain }) => {
const defaultQuery = {
session: { validators: [] },
staking: { activeEra: {} },
council: { stage: { stage: { isIdle: true, isAnnouncing: false }, changedAt: 123 } },
referendum: { stage: { isVoting: false, isRevealing: false } },
}
const rpcChain = {
getBlockHash: createType('BlockHash', BLOCK_HASH),
Expand Down
Loading