Skip to content

Commit

Permalink
Merge branch 'dshuiski/1599-blockfrost-get-utxo' into dshuiski/balanc…
Browse files Browse the repository at this point in the history
…er-constraints
  • Loading branch information
errfrom committed Jan 9, 2025
2 parents 6fd4d3b + ed1b028 commit 355e70d
Show file tree
Hide file tree
Showing 16 changed files with 405 additions and 308 deletions.
71 changes: 43 additions & 28 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,82 +7,96 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [[v9.3.1]](#v931)
- [[Unreleased]](#unreleased)
- [Changed](#changed)
- [Fixed](#fixed)
- [[v9.3.0]](#v930)
- [[v9.3.1]](#v931)
- [Fixed](#fixed-1)
- [Changed](#changed)
- [[v9.3.0]](#v930)
- [Fixed](#fixed-2)
- [Changed](#changed-1)
- [[v9.2.0]](#v920)
- [Added](#added)
- [Changed](#changed-1)
- [Changed](#changed-2)
- [Removed](#removed)
- [Fixed](#fixed-2)
- [Fixed](#fixed-3)
- [[v9.1.0]](#v910)
- [Added](#added-1)
- [Changed](#changed-2)
- [Changed](#changed-3)
- [Removed](#removed-1)
- [Fixed](#fixed-3)
- [Fixed](#fixed-4)
- [[v9.0.0]](#v900)
- [Deprecated](#deprecated)
- [Added](#added-2)
- [Removed](#removed-2)
- [Changed](#changed-3)
- [Fixed](#fixed-4)
- [[v8.0.0]](#v800)
- [Added](#added-3)
- [Changed](#changed-4)
- [Fixed](#fixed-5)
- [[v8.0.0]](#v800)
- [Added](#added-3)
- [Changed](#changed-5)
- [Fixed](#fixed-6)
- [Removed](#removed-3)
- [[v7.0.0]](#v700)
- [Added](#added-4)
- [Changed](#changed-5)
- [Fixed](#fixed-6)
- [Changed](#changed-6)
- [Fixed](#fixed-7)
- [Removed](#removed-4)
- [[v6.0.0]](#v600)
- [Added](#added-5)
- [Changed](#changed-6)
- [Fixed](#fixed-7)
- [Changed](#changed-7)
- [Fixed](#fixed-8)
- [Removed](#removed-5)
- [[v5.0.0]](#v500)
- [Added](#added-6)
- [Changed](#changed-7)
- [Changed](#changed-8)
- [Removed](#removed-6)
- [Fixed](#fixed-8)
- [Fixed](#fixed-9)
- [Runtime Dependencies](#runtime-dependencies)
- [[v4.0.2] - 2023-01-17](#v402---2023-01-17)
- [Fixed](#fixed-9)
- [Fixed](#fixed-10)
- [[v4.0.1] - 2022-12-20](#v401---2022-12-20)
- [Added](#added-7)
- [[v4.0.0] - 2022-12-15](#v400---2022-12-15)
- [Added](#added-8)
- [Changed](#changed-8)
- [Changed](#changed-9)
- [Removed](#removed-7)
- [Fixed](#fixed-10)
- [Fixed](#fixed-11)
- [Runtime Dependencies](#runtime-dependencies-1)
- [[3.0.0] - 2022-11-21](#300---2022-11-21)
- [Added](#added-9)
- [Changed](#changed-9)
- [Changed](#changed-10)
- [Removed](#removed-8)
- [Fixed](#fixed-11)
- [Fixed](#fixed-12)
- [Runtime Dependencies](#runtime-dependencies-2)
- [[2.0.0] - 2022-09-12](#200---2022-09-12)
- [Added](#added-10)
- [Changed](#changed-10)
- [Changed](#changed-11)
- [Removed](#removed-9)
- [Fixed](#fixed-12)
- [Fixed](#fixed-13)
- [[2.0.0-alpha] - 2022-07-05](#200-alpha---2022-07-05)
- [Added](#added-11)
- [Removed](#removed-10)
- [Changed](#changed-11)
- [Fixed](#fixed-13)
- [[1.1.0] - 2022-06-30](#110---2022-06-30)
- [Changed](#changed-12)
- [Fixed](#fixed-14)
- [[1.0.1] - 2022-06-17](#101---2022-06-17)
- [[1.1.0] - 2022-06-30](#110---2022-06-30)
- [Fixed](#fixed-15)
- [[1.0.1] - 2022-06-17](#101---2022-06-17)
- [Fixed](#fixed-16)
- [[1.0.0] - 2022-06-10](#100---2022-06-10)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## [Unreleased]

### Changed

- `cardano-serialization-lib` has been updated to `v13.2.0` ([#1656](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1656))

### Fixed

- Fixed transaction witness set 'attach' functions. Previously, the updated witness set was incorrectly appended to the existing set, causing performance degradation when processing constraints for complex transactions. ([#1653](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1653))
- Updating to CSL `v13.2.0` should resolve the issue of occasional transaction script integrity hash mismatches on tx submission ([#1656](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1656))

## [v9.3.1]

### Fixed
Expand Down Expand Up @@ -163,6 +177,7 @@ This version provides basic Conway support and replaces Plutip with `cardano-tes

### Changed

- **IMPORTANT** `Contract.TxConstraints.mustPayTo*` functions no longer automatically include datums in the witness set - use `Contract.TxConstraints.mustIncludeDatum`. This change may require updating existing code to ensure datums are included properly ([#1624](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1624)).
- `Contract.Test.Plutip` is replaced with `Contract.Test.Testnet` that uses `cardano-testnet` instead of Plutip. As a result, we reduced the dependency footprint (`cardano-testnet` is distributed with `cardano-node`, so there are no internal Haskell components anymore in CTL) ([#1624](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1624))

### Removed
Expand Down
50 changes: 25 additions & 25 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"license": "MIT",
"dependencies": {
"@mlabs-haskell/cardano-message-signing": "^1.0.1",
"@mlabs-haskell/cardano-serialization-lib-gc": "12.0.0",
"@mlabs-haskell/cardano-serialization-lib-gc": "13.2.0",
"@mlabs-haskell/json-bigint": "2.0.0",
"@mlabs-haskell/uplc-apply-args": "1.0.29-alpha",
"@noble/secp256k1": "^1.7.0",
Expand Down
4 changes: 2 additions & 2 deletions packages.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ let additions =
]
, repo =
"https://github.com/mlabs-haskell/purescript-cardano-serialization-lib"
, version = "v2.0.0"
, version = "v3.0.0"
}
, cardano-plutus-data-schema =
{ dependencies = [ "prelude" ]
Expand Down Expand Up @@ -372,7 +372,7 @@ let additions =
, "unsafe-coerce"
]
, repo = "https://github.com/mlabs-haskell/purescript-cardano-types"
, version = "v3.0.0"
, version = "v4.0.0"
}
, cardano-message-signing =
{ dependencies =
Expand Down
12 changes: 6 additions & 6 deletions spago-packages.nix

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

19 changes: 14 additions & 5 deletions src/Internal/Service/Blockfrost.purs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,15 +1186,24 @@ instance Show BlockfrostUtxosOfTransaction where
instance DecodeAeson BlockfrostUtxosOfTransaction where
decodeAeson = aesonObject \obj -> do
txHash <- getField obj "hash"
getField obj "outputs"
>>= aesonArray (map wrap <<< traverse (decodeUtxoEntry txHash))
outputs <- getField obj "outputs"
aesonArray (map (wrap <<< catMaybes) <<< traverse (decodeUtxoEntry txHash))
outputs
where
decodeUtxoEntry
:: TransactionHash
-> Aeson
-> Either JsonDecodeError BlockfrostUnspentOutput
decodeUtxoEntry txHash utxoAeson =
Tuple <$> decodeTxOref txHash utxoAeson <*> decodeAeson utxoAeson
-> Either JsonDecodeError (Maybe BlockfrostUnspentOutput)
decodeUtxoEntry txHash utxoAeson = do
(consumedByTx :: Maybe String) <- aesonObject
(flip getFieldOptional "consumed_by_tx")
utxoAeson
case consumedByTx of
Nothing ->
Just <$>
(Tuple <$> decodeTxOref txHash utxoAeson <*> decodeAeson utxoAeson)
Just _ ->
pure Nothing

decodeTxOref
:: TransactionHash -> Aeson -> Either JsonDecodeError TransactionInput
Expand Down
14 changes: 9 additions & 5 deletions src/Internal/Spawn.purs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ spawn' cmd args opts mbFilter cont = do
child <- ChildProcess.spawn cmd args opts
let fullCmd = cmd <> foldMap (" " <> _) args
closedAVar <- AVar.empty
interface <- RL.createInterface (stdout child) mempty
stdoutInterfaceRef <- Ref.new Nothing
stderrInterface <- RL.createInterface (stderr child) mempty
flip RL.setLineHandler stderrInterface \str -> do
traceM $ "stderr: " <> str
outputRef <- Ref.new ""
ChildProcess.onClose child \code -> do
RL.close interface
stdoutInterface <- Ref.read stdoutInterfaceRef
traverse_ RL.close stdoutInterface
RL.close stderrInterface
void $ AVar.tryPut code closedAVar
output <- Ref.read outputRef
cont $ Left $ error
Expand All @@ -113,16 +115,18 @@ spawn' cmd args opts mbFilter cont = do
case mbFilter of
Nothing -> cont (pure mp)
Just filter -> do
flip RL.setLineHandler interface
stdoutInterface <- RL.createInterface (stdout child) mempty
Ref.write (Just stdoutInterface) stdoutInterfaceRef
flip RL.setLineHandler stdoutInterface
\str -> do
output <- Ref.modify (_ <> str <> "\n") outputRef
filter { output, line: str } >>= case _ of
Success -> do
clearLineHandler interface
clearLineHandler stdoutInterface
cont (pure mp)
Cancel -> do
kill SIGINT child
clearLineHandler interface
clearLineHandler stdoutInterface
cont $ Left $ error
$ "Process cancelled because output received: "
<> str
Expand Down
12 changes: 6 additions & 6 deletions src/Internal/Testnet/Contract.purs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module Ctl.Internal.Testnet.Contract
import Contract.Prelude

import Cardano.Serialization.Lib (privateKey_generateEd25519) as Csl
import Cardano.Types (NetworkId(TestnetId))
import Cardano.Types.Address (Address, getPaymentCredential, getStakeCredential)
import Cardano.Types.Address (toBech32) as Address
import Cardano.Types.BigInt (BigInt)
Expand Down Expand Up @@ -65,6 +64,7 @@ import Ctl.Internal.Testnet.DistributeFunds (Tx(Tx)) as DistrFunds
import Ctl.Internal.Testnet.Server
( StartedTestnetCluster
, makeClusterContractEnv
, mkLogging
, startTestnetCluster
)
import Ctl.Internal.Testnet.Types (TestnetConfig)
Expand Down Expand Up @@ -242,18 +242,18 @@ startTestnetContractEnv
}
startTestnetContractEnv cfg distr cleanupRef = do
_ <- cleanupOnExit cleanupRef
cluster <- startTestnetCluster cfg cleanupRef
{ env, printLogs, clearLogs } <- makeClusterContractEnv cleanupRef cfg
let env' = env { networkId = TestnetId }
wallets <- mkWallets env' cluster
logging@{ logger } <- liftEffect $ mkLogging cfg
cluster <- startTestnetCluster cfg cleanupRef logger
{ env, printLogs, clearLogs } <- makeClusterContractEnv cleanupRef logging
wallets <- mkWallets env cluster
apathize $ liftEffect $
for_ env.hooks.onClusterStartup \onClusterStartup ->
onClusterStartup
{ nodeSocketPath: (unwrap cluster).paths.nodeSocketPath
}
pure
{ cluster
, env: env'
, env
, wallets
, printLogs
, clearLogs
Expand Down
Loading

0 comments on commit 355e70d

Please sign in to comment.