Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
The result of `palletFrozen().toJSON()` is a `boolean` primitive however `createType('bool').toJSON()` returns a `Boolean` object (this is why the test was failing. To be safer lets work with a js boolean instead of the polkdaot.js type.
  • Loading branch information
thesan committed Mar 12, 2024
1 parent 3a494a8 commit 8dc136b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ export const AddNewProposalModal = () => {
const maximumReferralCut = api?.consts.members.referralCutMaximumPercent
const minCashoutAllowed = api?.consts.content.minimumCashoutAllowedLimit
const maxCashoutAllowed = api?.consts.content.maximumCashoutAllowedLimit
const palletFrozenStatus = useFirstObservableValue(() => api?.query?.projectToken?.palletFrozen(), [api?.isConnected])
const palletFrozenStatus = useFirstObservableValue(
() => api?.query?.projectToken?.palletFrozen(),
[api?.isConnected]
)?.isTrue
const currentBlock = useCurrentBlockNumber()
const { hideModal, showModal } = useModal<AddNewProposalModalCall>()
const [state, send, service] = useMachine(addNewProposalMachine)
Expand Down Expand Up @@ -114,7 +117,7 @@ export const AddNewProposalModal = () => {
})

useEffect(() => {
if (palletFrozenStatus !== undefined) form.setValue('updatePalletFrozenStatus.enable', palletFrozenStatus.isTrue)
if (palletFrozenStatus !== undefined) form.setValue('updatePalletFrozenStatus.enable', palletFrozenStatus)
}, [palletFrozenStatus])

const formValues = form.getValues() as AddNewProposalForm
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/proposals/model/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const equalToContext = (
name: type ?? 'equalToContext',
exclusive: false,
test(value: boolean) {
const validationValue = get(this.options.context, contextPath).toJSON()
const validationValue = get(this.options.context, contextPath)
return (
value === validationValue ||
this.createError({
Expand Down

0 comments on commit 8dc136b

Please sign in to comment.