Skip to content

Conversation

@mbertin-ledger
Copy link
Member

📝 Description

Replace this text by a clear and concise description of what this pull request is about and why it is needed. Be sure to explain the problem you're addressing and the solution you're proposing.
For libraries, you can add a code sample of how to use it.
For bugfixes, you can explain the previous behavior and how it was fixed.
In case of visual features, please attach screenshots or video recordings to demonstrate the changes.

❓ Context

  • JIRA or GitHub link:
  • Feature:

✅ Checklist

Pull Requests must pass CI checks and undergo code review. Set the PR as Draft if it is not yet ready for review.

  • Covered by automatic tests
  • Changeset is provided
  • Documentation is up-to-date
  • Impact of the changes:
    • list of the changes

🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.

Copilot AI review requested due to automatic review settings November 23, 2025 13:14
@mbertin-ledger mbertin-ledger requested a review from a team as a code owner November 23, 2025 13:14
@vercel
Copy link

vercel bot commented Nov 23, 2025

@code-z2 is attempting to deploy a commit to the LedgerHQ Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a new Cosmos blockchain signer implementation to the Device Signer Kit, expanding the library's multi-chain support alongside existing Bitcoin, Ethereum, and Solana signers. The implementation follows the established architecture patterns used in other signers, providing address retrieval and transaction signing capabilities for Cosmos-based blockchains.

Key Changes:

  • New @ledgerhq/device-signer-kit-cosmos package with core signing functionality
  • Sample application integration demonstrating Cosmos signer usage
  • Dependency updates including cosmjs-types library addition

Reviewed changes

Copilot reviewed 41 out of 42 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Adds cosmjs-types dependency to catalog
pnpm-lock.yaml Updates lockfile with cosmos signer dependencies and package references
packages/signer/signer-cosmos/package.json Defines new cosmos signer package configuration and dependencies
packages/signer/signer-cosmos/tsconfig.json TypeScript configuration with path aliases for cosmos signer
packages/signer/signer-cosmos/tsconfig.prod.json Production build TypeScript configuration
packages/signer/signer-cosmos/vitest.config.mjs Test configuration for cosmos signer package
packages/signer/signer-cosmos/vitest.setup.mjs Test setup importing reflect-metadata for dependency injection
packages/signer/signer-cosmos/eslint.config.mjs ESLint configuration following DSDK standards
packages/signer/signer-cosmos/.prettierrc.js Prettier configuration for code formatting
packages/signer/signer-cosmos/.prettierignore Prettier ignore patterns for build artifacts
packages/signer/signer-cosmos/src/index.ts Main entry point exporting public API
packages/signer/signer-cosmos/src/api/**/*.ts Public API layer including types, models, and builder
packages/signer/signer-cosmos/src/internal/**/*.ts Internal implementation including commands, device actions, and dependency injection
apps/sample/package.json Adds cosmos signer dependency to sample app
apps/sample/src/app/signers/cosmos/page.tsx Cosmos signer page component for sample app
apps/sample/src/components/SignerView/index.tsx Updates signer list to include Cosmos option
apps/sample/src/components/SignerCosmosView/**/*.tsx Cosmos signer demo component with address and transaction signing examples
package.json Adds cosmos signer workspace script
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// HRP
const hrp = this.args.prefix; // e.g. "cosmos"
if (!hrp || hrp.length === 0) {
throw new Error("SignTransactionCommand: prefix is required");
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

The error message incorrectly references "SignTransactionCommand" but should reference "GetPubKeyCommand" since this is in the GetPubKeyCommand class.

Copilot uses AI. Check for mistakes.
Comment on lines 73 to 75
throw new Error(
`SignTransactionCommand: expected cosmos style number of path elements, got ${path.length}`,
);
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

The error message incorrectly references "SignTransactionCommand" but should reference "GetPubKeyCommand" since this is in the GetPubKeyCommand class.

Copilot uses AI. Check for mistakes.
Comment on lines 29 to 33
serialize(): Uint8Array | null {
const canonicalJson = stringifyCanonical(
this.stdSignDoc as unknown as JsonValue,
);
return base64StringToBuffer(canonicalJson);
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

The serialize() method incorrectly uses base64StringToBuffer() which expects a base64-encoded string as input. However, stringifyCanonical() returns a JSON string (not base64). This will cause base64StringToBuffer() to return null for invalid base64 input. The method should instead use new TextEncoder().encode(canonicalJson) to convert the JSON string directly to a Uint8Array.

Suggested change
serialize(): Uint8Array | null {
const canonicalJson = stringifyCanonical(
this.stdSignDoc as unknown as JsonValue,
);
return base64StringToBuffer(canonicalJson);
serialize(): Uint8Array {
const canonicalJson = stringifyCanonical(
this.stdSignDoc as unknown as JsonValue,
);
return new TextEncoder().encode(canonicalJson);

Copilot uses AI. Check for mistakes.
],
gas: "80000",
},
memo: "dummy 0.1 uusdc transfer on boble",
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

Typo in the memo text: "boble" should be "noble".

Suggested change
memo: "dummy 0.1 uusdc transfer on boble",
memo: "dummy 0.1 uusdc transfer on noble",

Copilot uses AI. Check for mistakes.
Comment on lines 39 to 40
description:
"Perform all the actions necessary to get a Solana address from the device",
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

The description incorrectly references "Solana" but should reference "Cosmos" since this is the Cosmos signer view.

Copilot uses AI. Check for mistakes.
{
title: "Sign Transaction",
description:
"Perform all the actions necessary to sign a Solana transaction with the device",
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

The description incorrectly references "Solana" but should reference "Cosmos" since this is the Cosmos signer view.

Suggested change
"Perform all the actions necessary to sign a Solana transaction with the device",
"Perform all the actions necessary to sign a Cosmos transaction with the device",

Copilot uses AI. Check for mistakes.
- Add prettier, eslint, vitest, and typescript config files
- Set up package.json with build scripts and dependencies
- Include cosmjs-types in workspace dependencies
Add error codes and error factory for cosmos app commands to handle device exchange errors
Add type definitions for SignerCosmos interface and related models including:
- Signature, MessageOptions, TransactionOptions, SignDoc, AddressOptions
- GetAddress and SignTransaction command types
- Device action types for address and transaction signing
Add type exports for address and transaction operations from device action types
Import reflect-metadata for inversify dependency injection support
…jection

- introduce DI container setup with inversify
- add use cases for address and transaction operations
- remove unused types and consolidate public key definition
- update signer interface to use SignDoc instead of Uint8Array
Implement new command to retrieve public key and address from device. The command handles APDU construction, response parsing, and error cases specific to Cosmos app integration.
Add TransactionOptions as an optional parameter to the signTransaction method in CosmosAppBinder and update related type definitions. This allows for more flexible transaction signing configurations.
Implement SignTransactionCommand to handle transaction signing phases (init, add, last) with APDU construction and response parsing. Includes derivation path validation
implement ProvideTransactionContextTask, SendSignDataTask, SendCommandInChunksTask, BuildTransactionContextTask and SignTransactionDeviceAction for handling Solana transaction signing flow
- Replace boilerplate signing tasks with CosmosSignDataTask
- Add support for JSON format transactions with canonical serialization
- Simplify device action state machine by removing boilerplate logic
- Add readonly modifiers to transaction options interface
- Introduce new SignTransactionDAInternalState type
update SignerCosmosBuilder class to use DefaultSignerCosmos and fix documentation
- Add cosmos signer package and sample UI components
- Update transaction signing to use serialized sign doc
- Remove unused chainId from TransactionOptions
- Add cosmos to supported signers list
- Update dependencies and lockfile
add validation for hrp and derivation path length
remove unnecessary response length check and add debug log
- Add dummy sign doc for testing cosmos transactions
- Refactor GetPubKeyCommand to better handle public key and address extraction
- Update SignTransactionCommand to properly handle derivation path and prefix
- Simplify sign doc handling in SignerCosmosView component
code-z2 and others added 6 commits December 5, 2025 22:04
…error messages

- Remove cosmjs-types dependency as it's no longer needed
- Extract Json types and canonical serialization to separate module
- Replace SignDoc class with simpler createSignDoc factory function
- Improve error messages in GetPubKeyCommand
- Update sample app to use new SignDoc API
- implement test utilities for device action mocking
- add tests for DefaultSignerCosmos
- add tests for CosmosAppBinder
- add tests for GetAddressUseCase and SignTransactionUseCase
- add tests for CosmosAppErrors
- add tests for SignTransactionDeviceAction
- add tests for SignTransactionCommand
- add tests for CosmosSignDataTask
- add tests for GetPubKeyCommand
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