Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
yveshauser committed Sep 14, 2023
1 parent ff5083b commit 0bec17e
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 72 deletions.
1 change: 0 additions & 1 deletion src/Component/ApplyInputs/Machine.purs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ data InputChoices
| SpecificNotifyInput NotifyInput
| AdvanceContract V1.Contract


newtype AutoRun = AutoRun Boolean

data State
Expand Down
2 changes: 1 addition & 1 deletion src/Component/CreateContract/Machine.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
6 changes: 3 additions & 3 deletions src/Component/Types/ContractInfo.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ]

3 changes: 2 additions & 1 deletion src/Component/Widgets/Form.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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'
4 changes: 2 additions & 2 deletions src/Component/Widgets/Modal.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/Contrib/Data/DateTime/Instant.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/Contrib/Polyform/FormSpecs/StatefulFormSpec.purs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type FormState st err =
| st
}


type FieldInitialsRow r =
( name :: FieldId
, initial :: Array String
Expand Down Expand Up @@ -147,7 +146,6 @@ toFormValidator name fieldValidator = do
Array.head value
UrlEncoded.fromValidator name validator'


input
:: forall a doc err m st
. Monad m
Expand Down Expand Up @@ -202,4 +200,3 @@ multiSelect name initial err render touched validator = StatefulFormSpec
, render
}


3 changes: 2 additions & 1 deletion src/Contrib/React/Basic/Hooks/UseMealyMachine.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/Contrib/React/Basic/Hooks/UseMooreMachine.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/React/Basic/Hooks/UseStatefulFormSpec.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/Contrib/React/MarloweGraph.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
36 changes: 18 additions & 18 deletions src/Contrib/ReactBootstrap/DropdownButton.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -84,4 +85,3 @@ dropdownButton props children = do
props' = Record.insert (Proxy :: Proxy "children") (toJSX children) props
_internalDropdownButton props'


3 changes: 2 additions & 1 deletion src/Contrib/ReactBootstrap/DropdownItem.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ fieldValidity touched value errors = do
isValid = Just [] == map fst errors
{ errors: errors', isInvalid, isValid }


data FormControlSizing = FormControlSm | FormControlLg

data LabelSpacing
Expand Down Expand Up @@ -336,7 +335,6 @@ textInput props = formSpecBuilderT do
props'.validator
pure form


_validator = (Proxy :: Proxy "validator")
_type = (Proxy :: Proxy "type")

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
]

Expand Down
1 change: 0 additions & 1 deletion src/Contrib/ReactBootstrap/Types.purs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ dropDirection =
, "down": unsafeCoerce "down"
}


-- export type AlignDirection = 'start' | 'end';
-- export type ResponsiveAlignProp = {
-- sm: AlignDirection;
Expand Down
4 changes: 2 additions & 2 deletions src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =<<
Expand Down

0 comments on commit 0bec17e

Please sign in to comment.