Skip to content

Commit

Permalink
more master merge
Browse files Browse the repository at this point in the history
  • Loading branch information
imalsogreg committed Dec 13, 2023
1 parent df29b07 commit ce21070
Showing 1 changed file with 63 additions and 49 deletions.
112 changes: 63 additions & 49 deletions pact-core/Pact/Core/Serialise/CBOR_V1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,12 @@ instance Serialise i => Serialise (DefTable Name i) where
instance
(Serialise b, Serialise i)
=> Serialise (Step Name Type b i) where
encode (Step t mt) = encodeWord 0 <> encode t <> encode mt
encode (StepWithRollback t rb mt) = encodeWord 1 <> encode t
<> encode rb <> encode mt
encode (Step t) = encodeWord 0 <> encode t
encode (StepWithRollback t rb) = encodeWord 1 <> encode t <> encode rb

decode = decodeWord >>= \case
0 -> Step <$> decode <*> decode
1 -> StepWithRollback <$> decode <*> decode <*> decode
0 -> Step <$> decode
1 -> StepWithRollback <$> decode <*> decode
_ -> fail "unexpected decoding"

instance
Expand Down Expand Up @@ -428,16 +427,22 @@ instance Serialise Schema where
instance Serialise Type where
encode (TyPrim pt) = encodeWord 0 <> encode pt
encode (TyList ty) = encodeWord 1 <> encode ty
encode (TyModRef mr) = encodeWord 2 <> encode mr
encode (TyObject s) = encodeWord 3 <> encode s
encode (TyTable s) = encodeWord 4 <> encode s
encode TyAnyList = encodeWord 2
encode (TyModRef mr) = encodeWord 3 <> encode mr
encode (TyObject s) = encodeWord 4 <> encode s
encode TyAnyObject = encodeWord 5
encode (TyTable s) = encodeWord 6 <> encode s
encode TyCapToken = encodeWord 7

decode = decodeWord >>= \case
0 -> TyPrim <$> decode
1 -> TyList <$> decode
2 -> TyModRef <$> decode
3 -> TyObject <$> decode
4 -> TyTable <$> decode
2 -> pure TyAnyList
3 -> TyModRef <$> decode
4 -> TyObject <$> decode
5 -> pure TyAnyObject
6 -> TyTable <$> decode
7 -> pure TyCapToken
_ -> fail "unexpected decoding"

instance Serialise Import where
Expand Down Expand Up @@ -545,6 +550,9 @@ instance Serialise RawBuiltin where
RawRound -> encodeWord 19
RawCeiling -> encodeWord 20
RawFloor -> encodeWord 21
RawRoundPrec -> encodeWord 22
RawCeilingPrec -> encodeWord 23
RawFloorPrec -> encodeWord 24
RawExp -> encodeWord 22
RawLn -> encodeWord 23
RawSqrt -> encodeWord 24
Expand Down Expand Up @@ -586,6 +594,7 @@ instance Serialise RawBuiltin where
RawB64Decode -> encodeWord 60
RawStrToList -> encodeWord 61
RawYield -> encodeWord 62
RawYieldToChain -> encodeWord 63
RawResume -> encodeWord 63
RawBind -> encodeWord 64
RawRequireCapability -> encodeWord 65
Expand Down Expand Up @@ -633,6 +642,8 @@ instance Serialise RawBuiltin where
RawNamespace -> encodeWord 107
RawDefineNamespace -> encodeWord 108
RawDescribeNamespace -> encodeWord 109
RawChainData -> encodeWord 100
RawIsCharset -> encodeWord 100
RawCreatePrincipal -> encodeWord 110
RawIsPrincipal -> encodeWord 111
RawTypeOfPrincipal -> encodeWord 112
Expand Down Expand Up @@ -662,44 +673,47 @@ instance Serialise RawBuiltin where
19 -> pure RawRound
20 -> pure RawCeiling
21 -> pure RawFloor
22 -> pure RawExp
23 -> pure RawLn
24 -> pure RawSqrt
25 -> pure RawLogBase
26 -> pure RawLength
27 -> pure RawTake
28 -> pure RawDrop
29 -> pure RawConcat
30 -> pure RawReverse
31 -> pure RawContains
32 -> pure RawSort
33 -> pure RawSortObject
34 -> pure RawRemove
35 -> pure RawMod
36 -> pure RawMap
37 -> pure RawFilter
38 -> pure RawZip
39 -> pure RawIntToStr
40 -> pure RawStrToInt
41 -> pure RawStrToIntBase
42 -> pure RawFold
43 -> pure RawDistinct
44 -> pure RawFormat
45 -> pure RawEnumerate
46 -> pure RawEnumerateStepN
47 -> pure RawShow
48 -> pure RawReadMsg
49 -> pure RawReadMsgDefault
50 -> pure RawReadInteger
51 -> pure RawReadDecimal
52 -> pure RawReadString
53 -> pure RawReadKeyset
54 -> pure RawEnforceGuard
55 -> pure RawEnforceKeyset
56 -> pure RawKeysetRefGuard
57 -> pure RawAt
58 -> pure RawMakeList
59 -> pure RawB64Encode
22 -> pure RawRoundPrec
23 -> pure RawCeilingPrec
24 -> pure RawFloorPrec
25 -> pure RawExp
26 -> pure RawLn
27 -> pure RawSqrt
28 -> pure RawLogBase
29 -> pure RawLength
30 -> pure RawTake
31 -> pure RawDrop
32 -> pure RawConcat
33 -> pure RawReverse
34 -> pure RawContains
35 -> pure RawSort
36 -> pure RawSortObject
37 -> pure RawRemove
38 -> pure RawMod
39 -> pure RawMap
40 -> pure RawFilter
41 -> pure RawZip
42 -> pure RawIntToStr
43 -> pure RawStrToInt
44 -> pure RawStrToIntBase
45 -> pure RawFold
46 -> pure RawDistinct
47 -> pure RawFormat
48 -> pure RawEnumerate
49 -> pure RawEnumerateStepN
50 -> pure RawShow
51 -> pure RawReadMsg
52 -> pure RawReadMsgDefault
53 -> pure RawReadInteger
54 -> pure RawReadDecimal
55 -> pure RawReadString
56 -> pure RawReadKeyset
57 -> pure RawEnforceGuard
58 -> pure RawEnforceKeyset
59 -> pure RawKeysetRefGuard
60 -> pure RawAt
61 -> pure RawMakeList
62 -> pure RawB64Encode
60 -> pure RawB64Decode
61 -> pure RawStrToList
62 -> pure RawYield
Expand Down

0 comments on commit ce21070

Please sign in to comment.