-
Notifications
You must be signed in to change notification settings - Fork 3
/
Utils.purs
69 lines (64 loc) · 1.88 KB
/
Utils.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module Seath.HTTP.Utils (mkLeaderConfig, mkUserConfig) where
import Contract.Prelude
import Aeson (class EncodeAeson)
import Contract.PlutusData (class FromData, class ToData)
import Contract.Scripts (class DatumType, class RedeemerType)
import Contract.Transaction (Transaction)
import Seath.Core.ChainBuilder as ChainBuilder
import Seath.Core.Types (CoreConfiguration)
import Seath.HTTP.UserHandlers as HttpUser
import Seath.Network.Types
( LeaderConfiguration(LeaderConfiguration)
, MilliSeconds
, RunContract(RunContract)
, UserConfiguration(UserConfiguration)
)
mkLeaderConfig
:: forall (actionType :: Type) (userStateType :: Type) (validatorType :: Type)
(redeemerType :: Type)
(datumType :: Type)
. DatumType validatorType datumType
=> RedeemerType validatorType redeemerType
=> FromData datumType
=> ToData datumType
=> FromData redeemerType
=> ToData redeemerType
=> MilliSeconds
-> Int
-> MilliSeconds
-> CoreConfiguration actionType userStateType validatorType datumType
redeemerType
-> RunContract
-> LeaderConfiguration actionType
mkLeaderConfig
maxWaitingTimeBeforeBuildChain
numberOfActionToTriggerChainBuilder
maxWaitingTimeForSignature
coreConfig
runContract =
let
(RunContract runC) = runContract
buildChain = \actions -> runC $ fst <$> ChainBuilder.buildChain coreConfig
actions
Nothing
in
LeaderConfiguration
{ maxWaitingTimeForSignature
, numberOfActionToTriggerChainBuilder
, maxWaitingTimeBeforeBuildChain
, runContract
, buildChain
}
mkUserConfig
:: forall a
. EncodeAeson a
=> String
-> RunContract
-> (Transaction -> Aff (Either String Transaction))
-> UserConfiguration a
mkUserConfig leaderUrl runContract checkChainedTx =
UserConfiguration
{ networkHandlers: HttpUser.mkHttpHandlers leaderUrl
, runContract
, checkChainedTx
}