Skip to content

Commit

Permalink
Remove dead code, update CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
klntsky committed Apr 16, 2024
1 parent 262dee4 commit 6f51fc5
Show file tree
Hide file tree
Showing 32 changed files with 85 additions and 639 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Expand Up @@ -64,6 +64,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]

In this version, we've refactored CTL and separated it into multiple reusable sub-packages, most notably:

- this package
- `purescript-cardano-types` - (`Cardano.Types.*`) - domain types for Cardano ledger
- `purescript-cardano-serialization-lib` - (`Cardano.Serialization.Lib.*`) - PureScript wrapper for CSL
- `purescript-plutus-types` - (`Cardano.Plutus.*`) - Plutus-style domain types used only for `ToData`/`FromData` instances.

See the [cardano-purescript repo](https://github.com/klntsky/cardano-purescript) for a complete list of new packages.

### Added

### Changed
Expand All @@ -78,11 +87,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- `plutusScriptV1FromEnvelope`, `plutusScriptV2FromEnvelope` have been replaced with `plutusScriptFromEnvelope` (the script is tagged with its language anyway)
- `NoOutputDatum` variant has been removed from `OutputDatum`: instead, it was made optional via Maybe in `TransactionOutput`
- `TransactionMetadatum` constructor naming, in PS and JSON encoding: `MetadataMap` -> `Map`, `MetadataList` -> `List`
- `Contract.PlutusData.Redeemer` has been renamed to `RedeemerDatum` (to resolve naming conflict with `cardano-ledger`-style redeemer)
- `Contract.PlutusData.Datum` has been deprecated, use `Cardano.Types.PlutusData`

### Fixed

### Removed

- `Contract.Address` utilities to work with `Address` - use `mkAddress` and machinery from `Cardano.Types.Address`
- `Contract.Credential` renamings:
- `PubKeyCredential` -> `PubKeyHashCredential`
- `ScriptCredential` -> `ScriptHashCredential`
- `ModifyTx` error: made conversion functions total and removed the need to handle it
- `Contract.CborBytes` utils:
- `cborBytesToByteArray`
Expand Down Expand Up @@ -114,7 +129,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- `Contract.Transaction`:
- `TransactionOutputWithRefScript` - use `Cardano.Types.TransactionOutput`. It comes with refscript included.
- `getTxFinalFee`

- `Contract.Numeric.NatRatio` - the module was not used in the library.
- `Contract.AssocMap` - use `Cardano.Plutus.Types.Map` from [`purescript-plutus-types`](https://github.com/mlabs-haskell/purescript-plutus-types)



Expand Down
14 changes: 9 additions & 5 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -42,9 +42,7 @@
"base64-js": "^1.5.1",
"bignumber.js": "^9.1.1",
"bip39": "^3.1.0",
"blakejs": "1.2.1",
"bufferutil": "4.0.5",
"jssha": "3.2.0",
"puppeteer-core": "^15.3.2",
"reconnecting-websocket": "4.4.0",
"uniqid": "5.4.0",
Expand All @@ -53,6 +51,8 @@
"xhr2": "0.2.1"
},
"devDependencies": {
"blakejs": "1.2.1",
"jssha": "3.2.0",
"buffer": "6.0.3",
"doctoc": "^2.2.1",
"esbuild": "0.18.11",
Expand Down
12 changes: 0 additions & 12 deletions src/Contract/Numeric/NatRatio.purs

This file was deleted.

4 changes: 4 additions & 0 deletions src/Contract/PlutusData.purs
Expand Up @@ -8,6 +8,7 @@ module Contract.PlutusData
, unitRedeemer
, module X
, Datum
, Redeemer
) where

import Prelude
Expand Down Expand Up @@ -125,3 +126,6 @@ unitRedeemer = Redeemer.unit

-- | DEPRECATED. Use `Cardano.Types.PlutusData`
type Datum = PlutusData

-- | DEPRECATED. Use `Contract.PlutusData.RedeemerDatum`
type Redeemer = RedeemerDatum
5 changes: 0 additions & 5 deletions src/Contract/Prim/Any.purs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Contract/Staking.purs
Expand Up @@ -11,8 +11,8 @@ import Cardano.Types (Ed25519KeyHash, PoolPubKeyHash, ScriptHash)
import Contract.Monad (Contract)
import Control.Monad.Reader (asks)
import Ctl.Internal.Contract.Monad (getQueryHandle)
import Ctl.Internal.QueryM.Pools (DelegationsAndRewards)
import Ctl.Internal.QueryM.Pools (DelegationsAndRewards) as X
import Ctl.Internal.Types.DelegationsAndRewards (DelegationsAndRewards)
import Ctl.Internal.Types.DelegationsAndRewards (DelegationsAndRewards) as X
import Data.Either (either)
import Data.Maybe (Maybe)
import Data.Newtype (wrap)
Expand Down
1 change: 1 addition & 0 deletions src/Internal/Metadata/MetadataType.purs
Expand Up @@ -16,6 +16,7 @@ import Data.Maybe (Maybe)
import Data.Newtype (unwrap, wrap)
import Type.Proxy (Proxy(Proxy))

-- | Associates a metadata label with a type. E.g. a CIP-25 metadata type could be associated with label `721`.
class (FromMetadata a, ToMetadata a) <= MetadataType (a :: Type) where
metadataLabel :: Proxy a -> MetadataLabel

Expand Down
12 changes: 10 additions & 2 deletions src/Internal/QueryM/Ogmios.purs
Expand Up @@ -129,6 +129,7 @@ import Cardano.Types.PlutusScript (PlutusScript(PlutusScript))
import Cardano.Types.PlutusScript as PlutusScript
import Cardano.Types.PoolMetadata (PoolMetadata(PoolMetadata))
import Cardano.Types.PoolPubKeyHash (PoolPubKeyHash)
import Cardano.Types.RedeemerTag (RedeemerTag(Spend, Mint, Cert, Reward)) as RedeemerTag
import Cardano.Types.Relay
( Relay(SingleHostAddr, SingleHostName, MultiHostName)
)
Expand Down Expand Up @@ -163,7 +164,6 @@ import Ctl.Internal.Types.ProtocolParameters
)
import Ctl.Internal.Types.Rational (Rational, (%))
import Ctl.Internal.Types.Rational as Rational
import Ctl.Internal.Types.RedeemerTag as RedeemerTag
import Ctl.Internal.Types.SystemStart
( SystemStart
, sysStartFromOgmiosTimestamp
Expand Down Expand Up @@ -806,10 +806,18 @@ decodeRedeemerPointer redeemerPtrRaw = note redeemerPtrTypeMismatch
case split (Pattern ":") redeemerPtrRaw of
[ tagRaw, indexRaw ] ->
{ redeemerTag: _, redeemerIndex: _ }
<$> RedeemerTag.fromString tagRaw
<$> redeemerTagFromString tagRaw
<*> UInt.fromString indexRaw
_ -> Nothing

redeemerTagFromString :: String -> Maybe RedeemerTag
redeemerTagFromString = case _ of
"spend" -> Just RedeemerTag.Spend
"mint" -> Just RedeemerTag.Mint
"certificate" -> Just RedeemerTag.Cert
"withdrawal" -> Just RedeemerTag.Reward
_ -> Nothing

type OgmiosDatum = String
type OgmiosScript = String
type OgmiosTxId = String
Expand Down
2 changes: 0 additions & 2 deletions src/Internal/QueryM/Pools.purs
Expand Up @@ -4,7 +4,6 @@ module Ctl.Internal.QueryM.Pools
, getPoolsParameters
, getPubKeyHashDelegationsAndRewards
, getValidatorHashDelegationsAndRewards
, module X
) where

import Prelude
Expand All @@ -21,7 +20,6 @@ import Ctl.Internal.QueryM.Ogmios
)
import Ctl.Internal.QueryM.Ogmios as Ogmios
import Ctl.Internal.Types.DelegationsAndRewards (DelegationsAndRewards)
import Ctl.Internal.Types.DelegationsAndRewards (DelegationsAndRewards) as X
import Ctl.Internal.Types.StakeValidatorHash (StakeValidatorHash)
import Data.ByteArray (byteArrayToHex)
import Data.Map (Map)
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Service/Blockfrost.purs
Expand Up @@ -165,7 +165,6 @@ import Ctl.Internal.QueryM.Ogmios
, decodeRedeemerPointer
)
import Ctl.Internal.QueryM.Ogmios as Ogmios
import Ctl.Internal.QueryM.Pools (DelegationsAndRewards)
import Ctl.Internal.ServerConfig (ServerConfig, mkHttpUrl)
import Ctl.Internal.Service.Error
( ClientError
Expand All @@ -183,6 +182,7 @@ import Ctl.Internal.Service.Helpers
, decodeAssetClass
)
import Ctl.Internal.Types.Chain (Tip(Tip, TipAtGenesis))
import Ctl.Internal.Types.DelegationsAndRewards (DelegationsAndRewards)
import Ctl.Internal.Types.EraSummaries
( EraSummaries
, EraSummary
Expand Down
11 changes: 0 additions & 11 deletions src/Internal/Types/Aliases.purs

This file was deleted.

13 changes: 0 additions & 13 deletions src/Internal/Types/Any.purs

This file was deleted.

0 comments on commit 6f51fc5

Please sign in to comment.