BlockchainStreamReader

scalus.cardano.node.stream.BlockchainStreamReader

Future-based streaming reader, mirroring BlockchainReader.

Wanted for read-only surfaces — a scenario runner's post-run reader, an emulator projection — where handing out a provider would imply a submit path that does not exist.

Attributes

Graph
Supertypes
trait BlockchainStreamReaderTF[Future]
trait BlockchainReaderTF[Future]
class Object
trait Matchable
class Any
Show all
Known subtypes

Members list

Value members

Inherited methods

Check the status of a transaction on the blockchain.

Check the status of a transaction on the blockchain.

Fallback implementation: look for UTxOs produced by the transaction. A provider that can answer authoritatively should override this — BlockfrostProvider asks the API, and EmulatorBase consults its applied-transaction index — because this inference has a blind spot in each direction. It cannot see a mempool, so a pending transaction reads as NotFound; and a transaction all of whose outputs have since been spent also reads as NotFound, since it produces no current UTxOs.

What it must not do is report a transaction that was never submitted as Confirmed. An empty result is therefore not a confirmation — the inherited BlockchainProviderTF.submitAndPoll builds on this answer, and "confirmed" for a transaction that never reached the chain is the one wrong answer that silently corrupts a caller's state.

Attributes

Inherited from:
BlockchainReader
def findUtxo(input: TransactionInput): Future[Either[UtxoQueryError, Utxo]]

Find a single UTxO by its transaction input.

Find a single UTxO by its transaction input.

Attributes

Returns

Right(utxo) if found, Left(NotFound) otherwise

Inherited from:
BlockchainReaderTF
def findUtxos(address: Address): Future[Either[UtxoQueryError, Utxos]]

Find all UTxOs at the given address.

Find all UTxOs at the given address.

Attributes

Inherited from:
BlockchainReaderTF
def findUtxos(inputs: Set[TransactionInput]): Future[Either[UtxoQueryError, Utxos]]

Find UTxOs by a set of transaction inputs (fails with NotFound if not all are found).

Find UTxOs by a set of transaction inputs (fails with NotFound if not all are found).

Attributes

Inherited from:
BlockchainReaderTF
override protected def mapF[A, B](fa: Future[A])(f: A => B): Future[B]

Map over the Future effect using this reader's captured ExecutionContext.

Map over the Future effect using this reader's captured ExecutionContext.

Attributes

Definition Classes
Inherited from:
BlockchainReader
inline def queryUtxos(inline f: Utxo => Boolean): UtxoQueryWithReaderTF[Future]

Query UTxOs using a lambda DSL.

Query UTxOs using a lambda DSL.

Translates the lambda to a UtxoQuery at compile time and returns a builder that can be further configured before execution. Effect-polymorphic — the resulting .execute() returns the reader's own F[Either[UtxoQueryError, Utxos]], so the same call shape works on Future-typed providers (Blockfrost, JS) and direct-style providers (ox Id).

Example:

// Simple query — execute immediately
reader.queryUtxos { u =>
 u.output.address == myAddress
}.execute()

// With pagination and minimum total
reader.queryUtxos { u =>
 u.output.address == myAddress && u.output.value.hasAsset(policyId, assetName)
}.minTotal(Coin.ada(100)).limit(10).execute()

Supported expressions:

  • u.output.address == addr — query by address
  • u.input.transactionId == txId — query by transaction
  • u.output.value.hasAsset(policyId, assetName) — query/filter by asset
  • u.output.value.coin >= amount — filter by minimum lovelace
  • u.output.hasDatumHash(hash) — filter by datum hash
  • && — AND combination
  • || — OR combination

Value parameters

f

Lambda expression from Utxo to Boolean

Attributes

Returns

A UtxoQueryWithReaderTF builder over this reader's effect type

Inherited from:
BlockchainReaderTF

Subscribe with default options.

Subscribe with default options.

Attributes

Inherited from:
BlockchainStreamReaderTF

Subscribe with default options.

Subscribe with default options.

Attributes

Inherited from:
BlockchainStreamReaderTF

Subscribe with default options.

Subscribe with default options.

Attributes

Inherited from:
BlockchainStreamReaderTF

Inherited and Abstract methods

Returns CardanoInfo for this reader.

Returns CardanoInfo for this reader.

This is always available synchronously after the reader is constructed. For emulators, this returns the current context. For remote providers like BlockfrostProvider, the CardanoInfo is fetched during async construction.

Attributes

Inherited from:
BlockchainReader
def close(): Future[Unit]

Attributes

Inherited from:
BlockchainStreamReaderTF
def currentSlot: Future[SlotNo]

Returns the current slot number.

Returns the current slot number.

Attributes

Inherited from:
BlockchainReader
def executionContext: ExecutionContext

Returns the ExecutionContext captured by this reader.

Returns the ExecutionContext captured by this reader.

This is used internally by default method implementations. External code can use this when working with Futures returned by reader methods, or provide their own.

Attributes

Inherited from:
BlockchainReader

Fetches the latest protocol parameters from the network.

Fetches the latest protocol parameters from the network.

Attributes

Inherited from:
BlockchainReader
def findUtxos(query: UtxoQuery): Future[Either[UtxoQueryError, Utxos]]

Find UTxOs using a type-safe query.

Find UTxOs using a type-safe query.

Value parameters

query

The query specifying source, filters, and pagination

Attributes

Returns

Either a UtxoQueryError or the matching UTxOs

Inherited from:
BlockchainReader
def getDatum(datumHash: DataHash): Future[Option[Data]]

Look up a datum by its hash. Returns None if unknown.

Look up a datum by its hash. Returns None if unknown.

Attributes

Inherited from:
BlockchainReader

What this provider can do. The only thing an implementation declares; per-request support is derived from it by SubscriptionSupport.of.

What this provider can do. The only thing an implementation declares; per-request support is derived from it by SubscriptionSupport.of.

Attributes

Inherited from:
BlockchainStreamReaderTF

Latest-value stream of protocol parameters: the current value on subscribe, then changes.

Latest-value stream of protocol parameters: the current value on subscribe, then changes.

Attributes

Inherited from:
BlockchainStreamReaderTF

Latest-value stream of chain-tip updates — newer wins, so a subscriber always sees the most recent tip when it pulls rather than a backlog of stale ones.

Latest-value stream of chain-tip updates — newer wins, so a subscriber always sees the most recent tip when it pulls rather than a backlog of stale ones.

Attributes

Inherited from:
BlockchainStreamReaderTF

Latest-value stream of one transaction's status, following it through the mempool into a block — and back out again if a rollback orphans it.

Latest-value stream of one transaction's status, following it through the mempool into a block — and back out again if a rollback orphans it.

Attributes

Inherited from:
BlockchainStreamReaderTF