Skip to content

fix: add missing exports with Cardano prefix#39

Merged
Mercurial merged 1 commit intoutxorpc:mainfrom
SebastienGllmt:missing-exports
Mar 16, 2025
Merged

fix: add missing exports with Cardano prefix#39
Mercurial merged 1 commit intoutxorpc:mainfrom
SebastienGllmt:missing-exports

Conversation

@SebastienGllmt
Copy link
Copy Markdown
Contributor

The package is missing these type exports, which makes it hard to work with the library

Comment thread src/index.ts
Comment on lines +6 to +12
ChainPoint as CardanoChainPoint,
Utxo as CardanoUtxo,
TipEvent as CardanoTipEvent,
TxEvent as CardanoTxEvent,
MempoolEvent as CardanoMempoolEvent,
TxHash as CardanoTxHash,
TxCbor as CardanoTxCbor,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you're fine with just re-exporting everything with a Cardano prefix

If you really don't like this, you could make that all the Cardano types are instead exported under @utxorpc/sdk/cardano using conditional exports, but given Cardano is the only chain supported at the moment it might not be worth spending time on this now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this, we can revisit later once we have more chains avaialble.

@Mercurial Mercurial changed the title Add missing exports fix: add missing exports with Cardano prefix Mar 16, 2025
@Mercurial Mercurial merged commit 82611f9 into utxorpc:main Mar 16, 2025
@SebastienGllmt SebastienGllmt deleted the missing-exports branch March 16, 2025 19:56
@SebastienGllmt
Copy link
Copy Markdown
Contributor Author

SebastienGllmt commented Mar 16, 2025

I noticed after this PR was merged that the ChainPoint exported here is actually just a JSON-friendly copy of a separate type (that is a class and not a json object) also called ChainPoint

You can import the class version by doing

import type { query } from "npm:@utxorpc/spec";

const point: query.ChainPoint // use it like this

I still need the ChainPoint exported like in this PR (i.e. we shouldn't revert this PR) because

  1. There is no type-safe way to go from the class to the JSON type provided by utxorpc as far as I know
  2. There isn't even a way to do the transformation properly dynamically either as per the issue mentioned here: test: add initial unit tests #38 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants