From 0bec17eb6f4ad5f9b07637a5712bcc8d0d924211 Mon Sep 17 00:00:00 2001 From: Yves Hauser Date: Thu, 14 Sep 2023 10:27:54 +0200 Subject: [PATCH] formatting --- src/Component/ApplyInputs/Machine.purs | 1 - src/Component/CreateContract/Machine.purs | 2 +- src/Component/Types/ContractInfo.purs | 6 +-- src/Component/Widgets/Form.purs | 3 +- src/Component/Widgets/Modal.purs | 4 +- src/Contrib/Data/DateTime/Instant.purs | 4 +- .../Polyform/FormSpecs/StatefulFormSpec.purs | 3 -- .../React/Basic/Hooks/UseMealyMachine.purs | 3 +- .../React/Basic/Hooks/UseMooreMachine.purs | 16 +++---- .../Basic/Hooks/UseStatefulFormSpec.purs | 2 +- src/Contrib/React/MarloweGraph.purs | 1 - .../ReactBootstrap/DropdownButton.purs | 36 +++++++-------- src/Contrib/ReactBootstrap/DropdownItem.purs | 3 +- .../StatefulFormSpecBuilders.purs | 2 - .../StatlessFormSpecBuilders.purs | 46 +++++++++---------- src/Contrib/ReactBootstrap/Types.purs | 1 - src/Main.purs | 4 +- 17 files changed, 65 insertions(+), 72 deletions(-) diff --git a/src/Component/ApplyInputs/Machine.purs b/src/Component/ApplyInputs/Machine.purs index 13438714..b13044ed 100644 --- a/src/Component/ApplyInputs/Machine.purs +++ b/src/Component/ApplyInputs/Machine.purs @@ -67,7 +67,6 @@ data InputChoices | SpecificNotifyInput NotifyInput | AdvanceContract V1.Contract - newtype AutoRun = AutoRun Boolean data State diff --git a/src/Component/CreateContract/Machine.purs b/src/Component/CreateContract/Machine.purs index 7998b92f..7a25deaf 100644 --- a/src/Component/CreateContract/Machine.purs +++ b/src/Component/CreateContract/Machine.purs @@ -133,7 +133,7 @@ step state action = do DefineRoleTokensSucceeded rolesConfig -> FetchingRequiredWalletContext { contract, tags, rolesConfig: Just rolesConfig, errors: Nothing } _ -> state FetchingRequiredWalletContext r@{ errors: Just _ } -> case action of - FetchRequiredWalletContext -> FetchingRequiredWalletContext $ r{ errors = Nothing } + FetchRequiredWalletContext -> FetchingRequiredWalletContext $ r { errors = Nothing } _ -> state FetchingRequiredWalletContext r -> case action of FetchRequiredWalletContextFailed error -> FetchingRequiredWalletContext $ r { errors = Just error } diff --git a/src/Component/Types/ContractInfo.purs b/src/Component/Types/ContractInfo.purs index 38394a7e..d1beb390 100644 --- a/src/Component/Types/ContractInfo.purs +++ b/src/Component/Types/ContractInfo.purs @@ -83,8 +83,8 @@ fetchAppliedInputs serverURL transactionEndpoints = do Runtime.getResource' serverURL transactionEndpoint {} {} pure $ results `foldMapFlipped` case _ of - Left err -> V (Left [err]) - Right ({ payload: { resource: Runtime.Tx { inputs, invalidBefore, invalidHereafter }}}) -> do + Left err -> V (Left [ err ]) + Right ({ payload: { resource: Runtime.Tx { inputs, invalidBefore, invalidHereafter } } }) -> do let -- = NormalInput InputContent -- | MerkleizedInput InputContent String Contract @@ -94,5 +94,5 @@ fetchAppliedInputs serverURL transactionEndpoints = do timeInterval = V1.TimeInterval (Instant.fromDateTime invalidBefore) (Instant.fromDateTime invalidHereafter) V $ Right $ case Array.uncons inputs of Just _ -> inputs <#> \input -> Just (inputToInputContent input) /\ timeInterval - Nothing -> [Nothing /\ timeInterval] + Nothing -> [ Nothing /\ timeInterval ] diff --git a/src/Component/Widgets/Form.purs b/src/Component/Widgets/Form.purs index 84395d5b..3677407b 100644 --- a/src/Component/Widgets/Form.purs +++ b/src/Component/Widgets/Form.purs @@ -212,7 +212,7 @@ addressInput . Monad builderM => MonadEffect validatorM => Row.Lacks "validator" props - => Row.Cons "validator" (AddressInputValidator validatorM) props ( validator :: AddressInputValidator validatorM | props) + => Row.Cons "validator" (AddressInputValidator validatorM) props (validator :: AddressInputValidator validatorM | props) => Defaults TextInputOptionalProps { validator :: AddressInputValidator validatorM | props } (TextInputProps validatorM (Maybe Bech32)) => CardanoMultiplatformLib.Lib -> { | props } @@ -224,6 +224,7 @@ addressInput cardanoMultiplatformLib props = do Just value -> liftEffect $ bech32FromString cardanoMultiplatformLib value >>= case _ of Nothing -> pure $ Left [ "Invalid bech32 address" ] Just bech32 -> pure $ Right $ Just bech32 + props' :: { validator :: AddressInputValidator validatorM | props } props' = Record.insert (Proxy :: Proxy "validator") validator props textInput props' diff --git a/src/Component/Widgets/Modal.purs b/src/Component/Widgets/Modal.purs index e22b1ca4..7ea2b8a8 100644 --- a/src/Component/Widgets/Modal.purs +++ b/src/Component/Widgets/Modal.purs @@ -95,8 +95,8 @@ mkModal = do -- other handler. onModalDialogClicked = handler stopPropagation (const $ pure unit) - modalClassName = "modal-dialog" <> if fullscreen - then " modal-fullscreen" + modalClassName = "modal-dialog" <> + if fullscreen then " modal-fullscreen" else case size of Small -> " modal-sm" Medium -> " modal-md" diff --git a/src/Contrib/Data/DateTime/Instant.purs b/src/Contrib/Data/DateTime/Instant.purs index 387ca09f..1a426e3d 100644 --- a/src/Contrib/Data/DateTime/Instant.purs +++ b/src/Contrib/Data/DateTime/Instant.purs @@ -15,8 +15,8 @@ import Partial.Unsafe (unsafeCrashWith) unsafeInstant :: Milliseconds -> Instant unsafeInstant t = case instant t of - Just i -> i - Nothing -> unsafeCrashWith $ "Contrib.Data.DateTime.Instant.unsafeInstant: invalid instant value:" <> unsafeStringify t + Just i -> i + Nothing -> unsafeCrashWith $ "Contrib.Data.DateTime.Instant.unsafeInstant: invalid instant value:" <> unsafeStringify t unsafeInstantFromInt :: Int -> Instant unsafeInstantFromInt = unsafeInstant <<< Milliseconds <<< Int.toNumber diff --git a/src/Contrib/Polyform/FormSpecs/StatefulFormSpec.purs b/src/Contrib/Polyform/FormSpecs/StatefulFormSpec.purs index 9cd25e64..1a1f43e2 100644 --- a/src/Contrib/Polyform/FormSpecs/StatefulFormSpec.purs +++ b/src/Contrib/Polyform/FormSpecs/StatefulFormSpec.purs @@ -45,7 +45,6 @@ type FormState st err = | st } - type FieldInitialsRow r = ( name :: FieldId , initial :: Array String @@ -147,7 +146,6 @@ toFormValidator name fieldValidator = do Array.head value UrlEncoded.fromValidator name validator' - input :: forall a doc err m st . Monad m @@ -202,4 +200,3 @@ multiSelect name initial err render touched validator = StatefulFormSpec , render } - diff --git a/src/Contrib/React/Basic/Hooks/UseMealyMachine.purs b/src/Contrib/React/Basic/Hooks/UseMealyMachine.purs index fb2ecf74..1acb4c98 100644 --- a/src/Contrib/React/Basic/Hooks/UseMealyMachine.purs +++ b/src/Contrib/React/Basic/Hooks/UseMealyMachine.purs @@ -40,7 +40,8 @@ useMealyMachine :: forall output state action . MealyMachineSpec state action output -> React.Hook - (UseMealyMachine state action output) (state /\ Maybe output /\ (action -> Effect Unit)) + (UseMealyMachine state action output) + (state /\ Maybe output /\ (action -> Effect Unit)) useMealyMachine { driver, initialState, step } = React.coerceHook React.do { state: { state, output }, version } /\ setState <- useVersionedState' { state: initialState, output: Nothing } stateRef <- useStateRef version state diff --git a/src/Contrib/React/Basic/Hooks/UseMooreMachine.purs b/src/Contrib/React/Basic/Hooks/UseMooreMachine.purs index 32cf5203..ea56bf58 100644 --- a/src/Contrib/React/Basic/Hooks/UseMooreMachine.purs +++ b/src/Contrib/React/Basic/Hooks/UseMooreMachine.purs @@ -46,14 +46,14 @@ useMooreMachine :: forall output state action . MooreMachineSpec state action output -> React.Hook - (UseMooreMachine state action output) - { state :: state - , output :: output - , applyAction :: action -> Effect Unit - -- If just after the reset in the handler you have to use `applyAction` then - -- you can use the returned value to do it. - , reset :: Maybe (MooreMachineSpec state action output) -> Effect (action -> Effect Unit) - } + (UseMooreMachine state action output) + { state :: state + , output :: output + , applyAction :: action -> Effect Unit + -- If just after the reset in the handler you have to use `applyAction` then + -- you can use the returned value to do it. + , reset :: Maybe (MooreMachineSpec state action output) -> Effect (action -> Effect Unit) + } useMooreMachine initialSpec = React.coerceHook React.do { state: spec, version: specVersion } /\ setSpec <- useVersionedState' initialSpec specRef <- useStateRef specVersion spec diff --git a/src/Contrib/React/Basic/Hooks/UseStatefulFormSpec.purs b/src/Contrib/React/Basic/Hooks/UseStatefulFormSpec.purs index 630a6a0f..f5e47962 100644 --- a/src/Contrib/React/Basic/Hooks/UseStatefulFormSpec.purs +++ b/src/Contrib/React/Basic/Hooks/UseStatefulFormSpec.purs @@ -113,7 +113,7 @@ useStatefulFormSpec ({ spec: StatefulFormSpec { fields, validator }, onSubmit, v useEffect debouncedQuery do when (not <<< null $ touched) do - result /\ state' <- flip runStateT state $ (runValidator validator) debouncedQuery + result /\ state' <- flip runStateT state $ (runValidator validator) debouncedQuery setInternalStatefulFormState state' setValidationResult $ Just (result /\ debouncedQuery) pure $ pure unit diff --git a/src/Contrib/React/MarloweGraph.purs b/src/Contrib/React/MarloweGraph.purs index a6bdbe69..7f86506f 100644 --- a/src/Contrib/React/MarloweGraph.purs +++ b/src/Contrib/React/MarloweGraph.purs @@ -38,7 +38,6 @@ executionPathIndicies = foldMap \(_ /\ path) -> do arr = Array.NonEmpty.toArray path <#> fst map branchIndex arr - type Props = { contract :: V1.Contract, executionPath :: Opt ExecutionPath } -- { contract :: V1.Contract, path :: ExecutionPath } diff --git a/src/Contrib/ReactBootstrap/DropdownButton.purs b/src/Contrib/ReactBootstrap/DropdownButton.purs index 2895ee2a..3df2b186 100644 --- a/src/Contrib/ReactBootstrap/DropdownButton.purs +++ b/src/Contrib/ReactBootstrap/DropdownButton.purs @@ -25,44 +25,45 @@ import Unsafe.Coerce (unsafeCoerce) -- flip?: boolean; -- } - -- Some not implemented placeholders type PropsFromToggle :: forall k. k -> k -type PropsFromToggle r = ( | r) +type PropsFromToggle r = (| r) foreign import data DropdownMenuVariant :: Type foreign import data RootCloseEvent :: Type -rootCloseEvent :: - { click :: RootCloseEvent - , mousedown :: RootCloseEvent - } +rootCloseEvent + :: { click :: RootCloseEvent + , mousedown :: RootCloseEvent + } rootCloseEvent = { click: unsafeCoerce "click" , mousedown: unsafeCoerce "mousedown" } type DropdownButtonProps r = - DropdownProps + - PropsFromToggle + - ( title :: JSX -- ReactNode - , menuRole :: Opt String - , renderMenuOnMount :: Opt Boolean - , rootCloseEvent :: Opt RootCloseEvent - , menuVariant :: Opt DropdownMenuVariant - , flip :: Opt Boolean - | r - ) + DropdownProps + + PropsFromToggle + + + ( title :: JSX -- ReactNode + , menuRole :: Opt String + , renderMenuOnMount :: Opt Boolean + , rootCloseEvent :: Opt RootCloseEvent + , menuVariant :: Opt DropdownMenuVariant + , flip :: Opt Boolean + | r + ) foreign import _DropdownButton :: ReactComponent { | DropdownButtonProps () } _internalDropdownButton :: forall props . NoProblem.Coerce { | props } { | DropdownButtonProps () } - => { | props } -> JSX + => { | props } + -> JSX _internalDropdownButton props = do let props' = NoProblem.coerce props @@ -84,4 +85,3 @@ dropdownButton props children = do props' = Record.insert (Proxy :: Proxy "children") (toJSX children) props _internalDropdownButton props' - diff --git a/src/Contrib/ReactBootstrap/DropdownItem.purs b/src/Contrib/ReactBootstrap/DropdownItem.purs index c1b20cd1..57655a30 100644 --- a/src/Contrib/ReactBootstrap/DropdownItem.purs +++ b/src/Contrib/ReactBootstrap/DropdownItem.purs @@ -55,7 +55,8 @@ foreign import _DropdownItem :: ReactComponent { | DropdownItemProps () } _internalDropdownItem :: forall props . NoProblem.Coerce { | props } { | DropdownItemProps () } - => { | props } -> JSX + => { | props } + -> JSX _internalDropdownItem props = do let props' = NoProblem.coerce props diff --git a/src/Contrib/ReactBootstrap/FormSpecBuilders/StatefulFormSpecBuilders.purs b/src/Contrib/ReactBootstrap/FormSpecBuilders/StatefulFormSpecBuilders.purs index 7d4c3eea..ebe3623d 100644 --- a/src/Contrib/ReactBootstrap/FormSpecBuilders/StatefulFormSpecBuilders.purs +++ b/src/Contrib/ReactBootstrap/FormSpecBuilders/StatefulFormSpecBuilders.purs @@ -73,7 +73,6 @@ import ReactBootstrap.Form.Control as Form.Control import Record as Record import Type.Prelude (Proxy(..)) - type StatefulBootstrapFormSpec validatorM st = StatefulFormSpec validatorM st (Array JSX) String fromStatlessFormSpec = FormSpecBuilder.hoistFormSpec liftStatelessFormSpec @@ -121,7 +120,6 @@ dateTimeField dateTimeField possibleLabel possibleHelpText dateTimeValidator = do FormSpecBuilder.hoistFormSpec liftStatelessFormSpec $ StatelessFormSpecBuilders.dateTimeField possibleLabel possibleHelpText dateTimeValidator - type MultiFieldIds = { multi :: FieldId, sub :: Array FieldId } -- multiField diff --git a/src/Contrib/ReactBootstrap/FormSpecBuilders/StatlessFormSpecBuilders.purs b/src/Contrib/ReactBootstrap/FormSpecBuilders/StatlessFormSpecBuilders.purs index f267c428..b5557e76 100644 --- a/src/Contrib/ReactBootstrap/FormSpecBuilders/StatlessFormSpecBuilders.purs +++ b/src/Contrib/ReactBootstrap/FormSpecBuilders/StatlessFormSpecBuilders.purs @@ -102,7 +102,6 @@ fieldValidity touched value errors = do isValid = Just [] == map fst errors { errors: errors', isInvalid, isValid } - data FormControlSizing = FormControlSm | FormControlLg data LabelSpacing @@ -336,7 +335,6 @@ textInput props = formSpecBuilderT do props'.validator pure form - _validator = (Proxy :: Proxy "validator") _type = (Proxy :: Proxy "type") @@ -667,7 +665,7 @@ textArea textArea props = formSpecBuilderT do name <- _genFieldId props' let - form ::StatelessBootstrapFormSpec validatorM Query a + form :: StatelessBootstrapFormSpec validatorM Query a form = StatelessFormSpec.input name props'.initial @@ -966,8 +964,8 @@ booleanField props = do validator = liftFnEither case _ of "on" -> Right true _ -> Right false - booleanAsValue = if _ - then "on" + booleanAsValue = + if _ then "on" else "off" initial = fromOpt false props'.initial @@ -1012,10 +1010,10 @@ renderBooleanField { disabled, label: possibleLabel, layout, possibleHelpText, n MultiColumn spacing -> labelSpacingsToClasses spacing Inline -> { labelColClass: "", inputColClass: "" } label' = case NoProblem.toMaybe possibleLabel of - Nothing -> mempty - Just label -> if isInline layout - then DOM.label {} [ label ] - else DOM.label { className: "col-form-label-sm " <> labelColClass, htmlFor: nameStr } [ label ] + Nothing -> mempty + Just label -> + if isInline layout then DOM.label {} [ label ] + else DOM.label { className: "col-form-label-sm " <> labelColClass, htmlFor: nameStr } [ label ] body = do let @@ -1027,21 +1025,21 @@ renderBooleanField { disabled, label: possibleLabel, layout, possibleHelpText, n DOM.div { className } $ [ Form.check - { className: "min-h-1_2rem" - , disabled - , id: nameStr - , isValid - , isInvalid - , name: nameStr - , "type": - if switch then Check.checkType.switch - else Check.checkType.radio - , value: "on" - , checked - , onChange: handler_ do - onChange $ if checked then "off" else "on" - } - -- We should probably render this as `feedback` above when in `inline` + { className: "min-h-1_2rem" + , disabled + , id: nameStr + , isValid + , isInvalid + , name: nameStr + , "type": + if switch then Check.checkType.switch + else Check.checkType.radio + , value: "on" + , checked + , onChange: handler_ do + onChange $ if checked then "off" else "on" + } + -- We should probably render this as `feedback` above when in `inline` , helpText ] diff --git a/src/Contrib/ReactBootstrap/Types.purs b/src/Contrib/ReactBootstrap/Types.purs index bdcf4e4a..b11d3ce7 100644 --- a/src/Contrib/ReactBootstrap/Types.purs +++ b/src/Contrib/ReactBootstrap/Types.purs @@ -29,7 +29,6 @@ dropDirection = , "down": unsafeCoerce "down" } - -- export type AlignDirection = 'start' | 'end'; -- export type ResponsiveAlignProp = { -- sm: AlignDirection; diff --git a/src/Main.purs b/src/Main.purs index a86ed8a6..318bc541 100644 --- a/src/Main.purs +++ b/src/Main.purs @@ -67,8 +67,8 @@ main configJson = do -- FIXME: Slotting numbers have to be provided by Marlowe Runtime slotting = case config.network of - "mainnet" -> Slotting { slotLength: BigInt.fromInt 1000 , slotZeroTime: unsafePartial $ fromJust $ BigInt.fromString "1591566291000" } - _ -> Slotting { slotLength: BigInt.fromInt 1000 , slotZeroTime: unsafePartial $ fromJust $ BigInt.fromString "1666656000000" } + "mainnet" -> Slotting { slotLength: BigInt.fromInt 1000, slotZeroTime: unsafePartial $ fromJust $ BigInt.fromString "1591566291000" } + _ -> Slotting { slotLength: BigInt.fromInt 1000, slotZeroTime: unsafePartial $ fromJust $ BigInt.fromString "1666656000000" } doc :: HTMLDocument <- document =<< window container :: Element <- maybe (throw "Could not find element with id 'app-root'") pure =<<