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

Instances and fixes from Cardax CTL integration #529

Merged
merged 109 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
f8b58d2
Switch Argounaut to Aeson (CurrencySymbol, ByteArray)
bladyjoker May 17, 2022
3108268
Migrate TokenName
bladyjoker May 17, 2022
9cc8b10
Added Aeson encoder for PlutusData and added tests for it
bladyjoker May 17, 2022
2acb642
make format
bladyjoker May 17, 2022
d9444f2
Make Plutus.Types.AssocMap PlutusData-compatible with PlutusTx.AssocMap
bladyjoker May 18, 2022
5265417
Matching plutus-core Data with Types.PlutusData PlutusData rep (confu…
bladyjoker May 18, 2022
7bb3b70
adjust api to work for an arbitrary hashing method from PlutusTx
MangoIV May 18, 2022
f03223f
plutus-core Map encoding issues #2
bladyjoker May 18, 2022
81373e5
plutus-core Map encoding issues #3
bladyjoker May 18, 2022
b82c08c
Merge remote-tracking branch 'upstream/master' into mangoiv/add-sha2-…
MangoIV May 18, 2022
51bc89e
add documentation for the new endpoint
MangoIV May 18, 2022
404f9e2
added frontend part of plutusHash
MangoIV May 18, 2022
7e8f874
Revert "plutus-core Map encoding issues #3"
bladyjoker May 18, 2022
88f7b1b
Revert "plutus-core Map encoding issues #2"
bladyjoker May 18, 2022
e744b5e
Revert "Matching plutus-core Data with Types.PlutusData PlutusData re…
bladyjoker May 18, 2022
d5953f0
fixes and new integrations tests for QueryM.Crypto
MangoIV May 18, 2022
9cd8095
Merge remote-tracking branch 'upstream/master' into mangoiv/add-sha2-…
MangoIV May 19, 2022
1963a82
add fixes required asked for by @ngua
MangoIV May 19, 2022
5473777
Revert "Make Plutus.Types.AssocMap PlutusData-compatible with PlutusT…
bladyjoker May 19, 2022
ccf5767
fix integration tests and return Either String instead of Maybe becau…
MangoIV May 19, 2022
2b7f562
Switch Plutus.Types.Credential to use HasPlutusSchema
bladyjoker May 19, 2022
bf14bca
Cosmetics on Plutus.Types.Credential
bladyjoker May 19, 2022
4cd11c3
Migrate Plutus.Types.Address to HasPlutusSchema
bladyjoker May 19, 2022
b6dba8a
Added a bunch of Aeson instances for plutus-ledger-api types
bladyjoker May 19, 2022
76bd3c5
Merge branch 'master' into bladyjoker/use_aeson
bladyjoker May 19, 2022
f7ceea1
spago2nix generate
bladyjoker May 19, 2022
15a6ec6
Formatting
ngua May 20, 2022
8f041fb
Merge branch 'master' into hashing
ngua May 20, 2022
433ee68
Use `unless`
ngua May 20, 2022
0095aa3
Imports
ngua May 20, 2022
a8d12e0
Merge remote-tracking branch 'plutonomicon/klntsky/use-purescript-aes…
bladyjoker May 20, 2022
391f8cb
Simplify field names
ngua May 20, 2022
a4ae6a6
Update readme
ngua May 20, 2022
ec0898a
Merge remote-tracking branch 'plutonomicon/klntsky/use-purescript-aes…
bladyjoker May 20, 2022
b1a8af6
Fix ogmios-datum-cache package path
bladyjoker May 20, 2022
c106ebb
Update ogmios-datum-cache input
bladyjoker May 20, 2022
aced50d
added fixes compatibility with Aeson-conversion PR
MangoIV May 21, 2022
ff4e9e0
Merge pull request #436 from MangoIV/hashing
bladyjoker May 23, 2022
c6a77ee
Merge remote-tracking branch 'plutonomicon/master' into bladyjoker/us…
bladyjoker May 23, 2022
37d53f8
Fix broken merge
bladyjoker May 23, 2022
f3f3d52
testing a fix for rational stuff
May 23, 2022
4271958
rational fix attempt #2
May 23, 2022
cad0bd6
broke Types.Rational to test some things
May 23, 2022
e5e5802
unbroke Types.Rational. json still not working
May 23, 2022
8babe19
maybe this will work
May 23, 2022
6ab5951
I think this fixes the Rational Aeson instance
May 23, 2022
28d6372
maybe *this* will fix it...
May 23, 2022
2083853
Fixed Aeson for Rationals and tested with purs-bridge
bladyjoker May 24, 2022
8990890
make format
bladyjoker May 24, 2022
ba5a568
synced w/ ctl master
May 24, 2022
ba6d0f8
fixed exports in QueryM resulting from merge
May 24, 2022
533232b
attempt #1 at fixing TokenName Aeson
May 24, 2022
ae94a3a
attempt #2 at fixing TokenName aeson
May 24, 2022
af85973
Restored Rings for Rational
bladyjoker May 24, 2022
3f93286
Merge branch 'bladyjoker/use_aeson' of github.com:plutonomicon/cardan…
bladyjoker May 24, 2022
9f851d3
attempt #3 at fixing TokenName aeson
May 24, 2022
4d45d4b
attempt #3.1 at fixing TokenName aeson
May 24, 2022
3d709fc
synced w/ remote
May 24, 2022
912e0ed
attempt #4 at fixing TokenName Aeson
May 24, 2022
474a11c
attempt #4.1 at fixing TokenName Aeson
May 24, 2022
cf0a3e3
attempt #4.2 at fixing TokenName aeson
May 24, 2022
9cbd298
fixed issue with hashing function
MangoIV May 24, 2022
2223390
Merge remote-tracking branch 'plutonomicon/dshuiski/testnet-addr-conv…
bladyjoker May 25, 2022
609a1bf
tried to fix the fromjson and tojson, doesn't work
MangoIV May 25, 2022
5b9cdca
merge upstream
MangoIV May 25, 2022
5ed0996
broke tokenname instance on purpose, revert
May 25, 2022
552fcce
unbroke instances
May 25, 2022
405cc39
TokenName aeson fix attempt #5
May 25, 2022
697b2c7
Restore Address lost in a merge and add a test (FAIL due to infinite …
bladyjoker May 25, 2022
4f6ae89
Merge branch 'bladyjoker/use_aeson' of github.com:plutonomicon/cardan…
bladyjoker May 25, 2022
e96a604
spago2nix generate and make format
bladyjoker May 25, 2022
a52034d
TokenName aeson fix attemp #5.1
May 25, 2022
4f743a2
TokenName aeson fix attemp #5.2
May 25, 2022
add06f9
upgraded to new purescript-aeson version
May 25, 2022
3393fa6
adding package lock stuff b/c ps-bridge tests break when I remove the…
May 25, 2022
1f50571
spago2nix generate
May 25, 2022
1ab58d8
wrote EncodeAeson/DecodeAeson instances for Datum (attempting to unb…
May 26, 2022
0fdbece
merged upstream - broken - ammend this
MangoIV May 26, 2022
24b6d7f
Merge remote-tracking branch 'upstream/dshuiski/client-side-hashing' …
MangoIV May 26, 2022
d0e2752
removed Crypto in front-and-backend
MangoIV May 26, 2022
89c25a4
Fixed ScriptHash Aeson instance, added Credential tests
bladyjoker May 26, 2022
ea9e88e
Forgot to include the module file -.-
bladyjoker May 26, 2022
08d41da
Fixed ScriptHash and ValidatorHash Aeson instances (I think)
bladyjoker May 26, 2022
73d0259
fix reindexing issue
MangoIV May 29, 2022
5e18ad6
Revert "fix reindexing issue"
MangoIV May 29, 2022
53ce888
Merge remote-tracking branch 'upstream/dshuiski/fix-rdmr-indexes' int…
MangoIV May 30, 2022
0bfde32
tried to implemented MultipleRedeemers test
MangoIV May 30, 2022
fd3b335
Merge remote-tracking branch 'plutonomicon/master' into bladyjoker/us…
bladyjoker May 31, 2022
d75bc32
Updated Credential Aeson instances
Jun 2, 2022
5da9f36
Updated Datum EncodeAeson instance
Jun 2, 2022
b7b7ece
Updated Interval EncodeAeson instance
Jun 2, 2022
9c4cc8b
Updated Value EncodeAeson instance
Jun 2, 2022
a45759c
Updated PubKeyHash EncodeAeson instance
Jun 2, 2022
d99e71f
Updated TokenName EncodeAeson instance
Jun 2, 2022
f5e941d
Merge remote-tracking branch 'plutonomicon/master' into bladyjoker/us…
bladyjoker Jun 3, 2022
1421f8e
Merge remote-tracking branch 'plutonomicon/bladyjoker/use-emurgo-csl'…
bladyjoker Jun 3, 2022
86a0afe
Cleanup after merge
bladyjoker Jun 3, 2022
16fe556
Merge remote-tracking branch 'plutonomicon/dshuiski/fix-rdmr-indexes'…
bladyjoker Jun 3, 2022
39b53dd
ScriptLookups cleanup
bladyjoker Jun 3, 2022
152b128
Added Test.OgmiosDatumCache testing hashing and Aeson roundtrip for P…
bladyjoker Jun 6, 2022
97f6ade
Restore `server/*` and select modules
ngua Jun 10, 2022
c7e6e7e
`dhall format`
ngua Jun 10, 2022
d381099
Revert ODC input
ngua Jun 10, 2022
545c7cf
Update gitattributes
ngua Jun 10, 2022
65d7109
Merge branch 'master' into from-cardax-work-pr
ngua Jun 10, 2022
9de755a
Apply suggestions from #419
ngua Jun 10, 2022
17f60f5
Merge branch 'master' into from-cardax-work-pr
ngua Jun 10, 2022
6ffe323
Update changelog
ngua Jun 10, 2022
f8273f2
Small style things
ngua Jun 10, 2022
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
spago-packages.nix linguist-generated=true
flake.lock linguist-generated=true
server/config/pparams.json linguist-generated=true
fixtures/**/*.json linguist-generated=true
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]

## [1.0.0] - 2022-06-07
## [1.0.0] - 2022-06-10

CTL's initial release!
32 changes: 32 additions & 0 deletions packages.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,38 @@ let additions =
, repo = "https://github.com/mlabs-haskell/purescript-aeson.git"
, version = "69bd18c4a9cffdebc45c55d2448740721a91854c"
}
, aeson-helpers =
{ dependencies =
[ "aff"
, "argonaut-codecs"
, "argonaut-core"
, "arrays"
, "bifunctors"
, "contravariant"
, "control"
, "effect"
, "either"
, "enums"
, "foldable-traversable"
, "foreign-object"
, "maybe"
, "newtype"
, "ordered-collections"
, "prelude"
, "profunctor"
, "psci-support"
, "quickcheck"
, "record"
, "spec"
, "spec-quickcheck"
, "transformers"
, "tuples"
, "typelevel-prelude"
]
, repo =
"https://github.com/mlabs-haskell/purescript-bridge-aeson-helpers.git"
, version = "44d0dae060cf78babd4534320192b58c16a6f45b"
}
, sequences =
{ dependencies =
[ "arrays"
Expand Down
36 changes: 36 additions & 0 deletions spago-packages.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ You can edit this file as you like.
{ name = "cardano-transaction-lib"
, dependencies =
[ "aeson"
, "aeson-helpers"
, "aff"
, "aff-promise"
, "affjax"
Expand Down Expand Up @@ -54,6 +55,7 @@ You can edit this file as you like.
, "spec"
, "strings"
, "tailrec"
, "text-encoding"
, "these"
, "transformers"
, "tuples"
Expand Down
4 changes: 1 addition & 3 deletions src/Cardano/Types/Value.purs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ import Prelude hiding (join)
import Aeson
( class DecodeAeson
, class EncodeAeson
, JsonDecodeError
( TypeMismatch
)
, JsonDecodeError(TypeMismatch)
, caseAesonObject
, encodeAeson'
, getField
Expand Down
2 changes: 1 addition & 1 deletion src/Deserialization/FromBytes.purs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Serialization.Types
, TransactionWitnessSet
, VRFKeyHash
)
import Type.Prelude (Proxy(..))
import Type.Prelude (Proxy(Proxy))
import Type.Row (type (+))
import Types.ByteArray (ByteArray)

Expand Down
73 changes: 53 additions & 20 deletions src/Plutus/Types/Address.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,41 @@ module Plutus.Types.Address

import Prelude

import Data.Maybe (Maybe(Just, Nothing))
import Aeson
( class DecodeAeson
, class EncodeAeson
, JsonDecodeError(TypeMismatch)
, caseAesonObject
, encodeAeson'
, (.:)
)
import Data.Either (Either(Left))
import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
import Data.Maybe (Maybe(Just, Nothing))
import Data.Newtype (class Newtype, wrap, unwrap)
import FromData (class FromData, fromData)
import Data.Show.Generic (genericShow)
import FromData (class FromData, genericFromData)
import Plutus.Types.Credential
( Credential(PubKeyCredential, ScriptCredential)
, StakingCredential(StakingHash)
)
import Plutus.Types.DataSchema
( class HasPlutusSchema
, type (:+)
, type (:=)
, type (@@)
, I
, PNil
)
import Serialization.Address (NetworkId)
import ToData (class ToData, toData)
import Types.Scripts (ValidatorHash)
import Types.PlutusData (PlutusData(Constr))
import ToData (class ToData, genericToData)
import TypeLevel.Nat (Z)
import Types.PubKeyHash
( PaymentPubKeyHash(PaymentPubKeyHash)
, PubKeyHash
, StakePubKeyHash
, PubKeyHash
)
import Plutus.Types.Credential
( Credential(PubKeyCredential, ScriptCredential)
, StakingCredential(StakingHash)
)
import Types.Scripts (ValidatorHash)

--------------------------------------------------------------------------------
-- Address
Expand Down Expand Up @@ -61,18 +78,34 @@ derive instance Generic Address _
instance Show Address where
show = genericShow

instance
HasPlutusSchema
Address
( "Address"
:=
( "addressCredential" := I Credential :+ "addressStakingCredential"
:= I (Maybe StakingCredential)
:+ PNil
)
@@ Z
:+ PNil
)

instance ToData Address where
toData (Address a) = Constr zero $
[ toData a.addressCredential, toData a.addressStakingCredential ]
toData = genericToData

instance FromData Address where
fromData (Constr n [ credD, stakingCredD ]) | n == zero =
Address <$>
( { addressCredential: _, addressStakingCredential: _ }
<$> fromData credD
<*> fromData stakingCredD
)
fromData _ = Nothing
fromData = genericFromData

instance DecodeAeson Address where
decodeAeson = caseAesonObject (Left $ TypeMismatch "Expected object") $
\obj -> do
addressCredential <- obj .: "addressCredential"
addressStakingCredential <- obj .: "addressStakingCredential"
pure $ Address { addressCredential, addressStakingCredential }

instance EncodeAeson Address where
encodeAeson' (Address addr) = encodeAeson' addr

--------------------------------------------------------------------------------
-- Useful functions
Expand Down
23 changes: 9 additions & 14 deletions src/Plutus/Types/AssocMap.purs
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,21 @@ module Plutus.Types.AssocMap

import Prelude

import Aeson (class DecodeAeson, class EncodeAeson)
import Data.Array ((:))
import Data.Array
( any
, deleteAt
, filter
, findIndex
, mapMaybe
, null
, singleton
) as Array
import Data.Array (any, deleteAt, filter, findIndex, mapMaybe, null, singleton) as Array
import Data.Bifunctor (bimap)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(Just, Nothing), isJust)
import Data.Newtype (class Newtype, unwrap)
import Data.Foldable (lookup) as Foldable
import Data.Foldable
( class Foldable
, foldlDefault
, foldMap
, foldr
, foldrDefault
)
import Data.Foldable (lookup) as Foldable
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(Just, Nothing), isJust)
import Data.Newtype (class Newtype, unwrap)
import Data.Show.Generic (genericShow)
import Data.These (These(Both, That, This), these)
import Data.Traversable (class Traversable, for, sequence, traverse)
Expand All @@ -67,6 +60,8 @@ derive instance Generic (Map k v) _
derive instance Newtype (Map k v) _
derive newtype instance (Eq k, Eq v) => Eq (Map k v)
derive newtype instance (Ord k, Ord v) => Ord (Map k v)
derive newtype instance (EncodeAeson k, EncodeAeson v) => EncodeAeson (Map k v)
derive newtype instance (DecodeAeson k, DecodeAeson v) => DecodeAeson (Map k v)

instance (Show k, Show v) => Show (Map k v) where
show = genericShow
Expand Down Expand Up @@ -222,4 +217,4 @@ mapMaybeWithKey
-> Map k a
-> Map k b
mapMaybeWithKey f (Map xs) =
Map $ Array.mapMaybe (\(k /\ v) -> (k /\ _) <$> f k v) xs
Map $ Array.mapMaybe (\(k /\ v) -> (k /\ _) <$> f k v) xs
Loading