Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify encoding to not output "i":null in JSON #1260

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion golden/accounts-module-crossChainSendCR/golden
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"gas":0,"result":{"status":"success","data":{"a":{"int":3}}},"reqKey":"DldRwCblQ7Loqy6wYJnaodHl30d3j3eH-qtFzfEv46g","logs":"1mwhFumbCoQ2VpOJqEVD0IgAAOmY2RhDuW1PiVD1pGk","events":[{"params":["1","xchain.p",[{"int":3}]],"name":"X_YIELD","module":{"namespace":null,"name":"pact"},"moduleHash":"AHE7loAN5c-ajfetxFoDkmVcixfwr0-tKfKh7mylSvo"}],"metaData":null,"continuation":{"executed":null,"pactId":"DldRwCblQ7Loqy6wYJnaodHl30d3j3eH-qtFzfEv46g","stepHasRollback":false,"step":0,"yield":{"data":{"a":{"int":3}},"source":"","provenance":{"targetChainId":"1","moduleHash":"AHE7loAN5c-ajfetxFoDkmVcixfwr0-tKfKh7mylSvo"}},"continuation":{"args":[{"int":3}],"def":"xchain.p"},"stepCount":2},"txId":null}
{"gas":0,"result":{"status":"success","data":{"a":{"int":3}}},"reqKey":"DldRwCblQ7Loqy6wYJnaodHl30d3j3eH-qtFzfEv46g","logs":"zSoMddrOTQFY_PG-n2GNlpLn5MoIkVtQQGlN9qds4bM","events":[{"params":["1","xchain.p",[{"int":3}]],"name":"X_YIELD","module":{"namespace":null,"name":"pact"},"moduleHash":"AHE7loAN5c-ajfetxFoDkmVcixfwr0-tKfKh7mylSvo"}],"metaData":null,"continuation":{"executed":null,"pactId":"DldRwCblQ7Loqy6wYJnaodHl30d3j3eH-qtFzfEv46g","stepHasRollback":false,"step":0,"yield":{"data":{"a":{"int":3}},"source":"","provenance":{"targetChainId":"1","moduleHash":"AHE7loAN5c-ajfetxFoDkmVcixfwr0-tKfKh7mylSvo"}},"continuation":{"args":[{"int":3}],"def":"xchain.p"},"stepCount":2},"txId":null}
2 changes: 1 addition & 1 deletion golden/accounts-module-crossChainSendCRBackCompat/golden
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"gas":0,"result":{"status":"success","data":{"a":{"int":3}}},"reqKey":"DldRwCblQ7Loqy6wYJnaodHl30d3j3eH-qtFzfEv46g","logs":"o4k6VwRSTWZnHAXGvzx-Q7yoUDRBtTYU9Uuv6W_6FmI","metaData":null,"continuation":{"executed":null,"pactId":"DldRwCblQ7Loqy6wYJnaodHl30d3j3eH-qtFzfEv46g","stepHasRollback":false,"step":0,"yield":{"data":{"a":{"int":3}},"provenance":{"targetChainId":"1","moduleHash":"AHE7loAN5c-ajfetxFoDkmVcixfwr0-tKfKh7mylSvo"}},"continuation":{"args":[{"int":3}],"def":"xchain.p"},"stepCount":2},"txId":null}
{"gas":0,"result":{"status":"success","data":{"a":{"int":3}}},"reqKey":"DldRwCblQ7Loqy6wYJnaodHl30d3j3eH-qtFzfEv46g","logs":"iQA0Bk4mmrB64fFsTV97HRTr21Dqkg66O2GfGv6opqI","metaData":null,"continuation":{"executed":null,"pactId":"DldRwCblQ7Loqy6wYJnaodHl30d3j3eH-qtFzfEv46g","stepHasRollback":false,"step":0,"yield":{"data":{"a":{"int":3}},"provenance":{"targetChainId":"1","moduleHash":"AHE7loAN5c-ajfetxFoDkmVcixfwr0-tKfKh7mylSvo"}},"continuation":{"args":[{"int":3}],"def":"xchain.p"},"stepCount":2},"txId":null}
2 changes: 1 addition & 1 deletion golden/accounts-module-eventCR/golden
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"gas":0,"result":{"status":"success","data":1},"reqKey":"DldRwCblQ7Loqy6wYJnaodHl30d3j3eH-qtFzfEv46g","logs":"cqZ-6rAE2TTv8ZXj8EbwsR_eUOp_RquGGnt4nnc4ck4","events":[{"params":["Alice",10.1],"name":"CAP","module":{"namespace":null,"name":"events-test"},"moduleHash":"fBdyelQUFqIWDrvMFLe0_WJ6DpEpCsnAhBR2X7nd71U"}],"metaData":null,"continuation":null,"txId":null}
{"gas":0,"result":{"status":"success","data":1},"reqKey":"DldRwCblQ7Loqy6wYJnaodHl30d3j3eH-qtFzfEv46g","logs":"Zd51RR1xifJHz6FDAfJA-I42f5gWoiVinU-VH_1A88M","events":[{"params":["Alice",10.1],"name":"CAP","module":{"namespace":null,"name":"events-test"},"moduleHash":"fBdyelQUFqIWDrvMFLe0_WJ6DpEpCsnAhBR2X7nd71U"}],"metaData":null,"continuation":null,"txId":null}
65 changes: 28 additions & 37 deletions src/Pact/Types/Term.hs
Original file line number Diff line number Diff line change
Expand Up @@ -752,84 +752,75 @@ unprop t = TermUnknown (show t)

instance J.Encode n => J.Encode (Term n) where
build = \case
(TModule d b i) -> J.object
(TModule d b i) -> J.object $
[ prop TermBody J..= b
, prop TermModule J..= d
, inf i
]
(TList ts ty i) -> J.object
] ++ inf i
(TList ts ty i) -> J.object $
[ prop TermList J..= J.Array ts
, prop TermType J..= ty
, inf i
]
] ++ inf i
(TDef d _i) -> J.build d
-- TNative intentionally not marshallable
(TNative n _fn tys _exs d tl i) -> J.object
(TNative n _fn tys _exs d tl i) -> J.object $
[ prop TermNatFunTypes J..= J.Array tys
, prop TermName J..= n
, prop TermFun J..= J.null {- TODO fn -}
, prop TermNatTopLevel J..= tl
, prop TermNatExamples J..= J.null {- TODO exs -}
, prop TermNatDocs J..= d
, inf i
]
(TConst d m c met i) -> J.object
] ++ inf i
(TConst d m c met i) -> J.object $
[ prop TermModName J..= m
, prop TermConstArg J..= d
, prop TermMeta J..= met
, prop TermConstVal J..= c
, inf i
]
] ++ inf i
(TApp a _i) -> J.build a
(TVar n i) -> J.object
(TVar n i) -> J.object $
[ prop TermVar J..= n
, inf i
]
(TBinding bs b c i) -> J.object
] ++ inf i
(TBinding bs b c i) -> J.object $
[ prop TermBody J..= b
, prop TermPairs J..= J.Array bs
, prop TermType J..= c
, inf i
]
] ++ inf i
(TObject o _i) -> J.build o
(TLiteral l i) -> J.object
[ inf i
, prop TermLiteral J..= l
(TLiteral l i) -> J.object $
inf i ++
[ prop TermLiteral J..= l
]
(TLam tlam _i) -> J.build tlam
(TGuard k i) -> J.object
(TGuard k i) -> J.object $
[ prop TermGuard J..= k
, inf i
]
] ++ inf i
(TUse u _i) -> J.build u
(TStep s tmeta i) -> J.object
(TStep s tmeta i) -> J.object $
[ prop TermBody J..= s
, prop TermMeta J..= tmeta
, inf i
]
(TSchema sn smod smeta sfs i) -> J.object
] ++ inf i
(TSchema sn smod smeta sfs i) -> J.object $
[ prop TermModName J..= smod
, prop TermName J..= sn
, prop TermMeta J..= smeta
, inf i
, prop TermFields J..= J.Array sfs
] ++ inf i ++
[ prop TermFields J..= J.Array sfs
]
(TTable tn tmod th tty tmeta i) -> J.object
(TTable tn tmod th tty tmeta i) -> J.object $
[ prop TermHash J..= th
, prop TermModName J..= tmod
, prop TermName J..= tn
, prop TermMeta J..= tmeta
, prop TermType J..= tty
, inf i
]
(TDynamic r m i) -> J.object
] ++ inf i
(TDynamic r m i) -> J.object $
[ prop TermDynRef J..= r
, inf i
, prop TermDynMem J..= m
]
] ++ inf i
(TModRef mr _i) -> J.build mr
where
inf i = "i" J..= i
inf (Info Nothing) = []
inf i = [ "i" J..= i ]

instance FromJSON n => FromJSON (Term n) where

Expand Down