Skip to content

Add Cardano support#7

Open
Tomasvrba wants to merge 7 commits into
BitBoxSwiss:masterfrom
Tomasvrba:cardano
Open

Add Cardano support#7
Tomasvrba wants to merge 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? 😄

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 requested a review from benma July 9, 2026 01:27
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