Skip to content

Add Cardano support#7

Merged
Tomasvrba merged 7 commits into
BitBoxSwiss:masterfrom
Tomasvrba:cardano
Jul 17, 2026
Merged

Add Cardano support#7
Tomasvrba merged 7 commits into
BitBoxSwiss:masterfrom
Tomasvrba:cardano

Conversation

@Tomasvrba

Copy link
Copy Markdown
Collaborator

No description provided.

@Tomasvrba
Tomasvrba requested a review from benma July 7, 2026 01:47

@benma benma left a comment

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.

Nice! Thanks!

Comment thread src/internal/cardano/methods.ts Outdated
Comment on lines +59 to +71
function validateUint32(value: number, detail: string): number {
if (!Number.isInteger(value) || value < 0 || value > UINT32_MAX) {
throw invalidTypeError(detail);
}
return value;
}

function validateUint64(value: bigint, detail: string): bigint {
if (typeof value !== 'bigint' || value < 0n || value > UINT64_MAX) {
throw invalidTypeError(detail);
}
return value;
}

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.

Move to internal/utils.ts?

Comment thread src/internal/cardano/methods.ts Outdated
Comment on lines +222 to +224
function bytesArray(bytes: Uint8Array): number[] {
return Array.from(bytes);
}

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.

Why a helper function that wraps an existing function?

Comment thread src/index.ts Outdated
cardanoSupported(): boolean {
this.#requireOpen('cardanoSupported');
return false;
return cardanoSupportedImpl(this.#requireOpen('cardanoSupported').info);

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.

In ETH, the method is implemented right here in index.ts. Maybe do the same for Cardano for consistency. The Rust-based package uses "self.is_multi_edition()", could make sense to have a similar helper here.

Comment thread src/internal/cardano/methods.ts Outdated
Comment on lines +52 to +53
import { parseKeypath } from '../eth/keypath.js';
import { requireVersion } from '../eth/version.js';

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.

Move these helpers to internal/keypath.js and internal/version.js? Not clean to have Cardano (and later BTC) import from eth.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

oops, missed that one

Comment thread src/internal/cardano/methods.ts Outdated
return Array.from(bytes);
}

async function queryCardano(

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.

The corresponding ETH function lives in eth/query.ts - change Cardano or ETH to make it consistent? 😄

@Tomasvrba
Tomasvrba requested a review from benma July 9, 2026 01:27

@benma benma left a comment

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.

See minor nit, after that feel free to squash and merge

Comment thread src/internal/cardano/methods.ts Outdated
info: Info,
transaction: CardanoTransaction,
): Promise<CardanoSignTransactionResult> {
requireCardanoVersion(info);

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.

Minor nit: someone on very old firmware will be asked to upgrade to the wrong version (v9.8 instead of v9.22) if tagCborSets is on. They would normally then upgrade to the latest anyway 😄

Comment thread CHANGELOG.md
# Changelog

## [Unreleased]
- Add Cardano support

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.

Please also update the package version to v0.2.0 and move this to a new ## 0.2.0 entry so after merge it's ready for publishing

Move keypath parsing, firmware version checks, product support checks,
and integer validation into neutral internal modules.

Make Cardano query helper consistent with ETH query layout.
@Tomasvrba
Tomasvrba merged commit b934820 into BitBoxSwiss:master Jul 17, 2026
1 check passed
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