-
Notifications
You must be signed in to change notification settings - Fork 17
COSMOS SIGNER #1141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
COSMOS SIGNER #1141
Conversation
|
@code-z2 is attempting to deploy a commit to the LedgerHQ Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this 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-cosmospackage with core signing functionality - Sample application integration demonstrating Cosmos signer usage
- Dependency updates including
cosmjs-typeslibrary 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"); |
Copilot
AI
Nov 23, 2025
There was a problem hiding this comment.
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.
| throw new Error( | ||
| `SignTransactionCommand: expected cosmos style number of path elements, got ${path.length}`, | ||
| ); |
Copilot
AI
Nov 23, 2025
There was a problem hiding this comment.
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.
| serialize(): Uint8Array | null { | ||
| const canonicalJson = stringifyCanonical( | ||
| this.stdSignDoc as unknown as JsonValue, | ||
| ); | ||
| return base64StringToBuffer(canonicalJson); |
Copilot
AI
Nov 23, 2025
There was a problem hiding this comment.
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.
| 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); |
| ], | ||
| gas: "80000", | ||
| }, | ||
| memo: "dummy 0.1 uusdc transfer on boble", |
Copilot
AI
Nov 23, 2025
There was a problem hiding this comment.
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".
| memo: "dummy 0.1 uusdc transfer on boble", | |
| memo: "dummy 0.1 uusdc transfer on noble", |
| description: | ||
| "Perform all the actions necessary to get a Solana address from the device", |
Copilot
AI
Nov 23, 2025
There was a problem hiding this comment.
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.
| { | ||
| title: "Sign Transaction", | ||
| description: | ||
| "Perform all the actions necessary to sign a Solana transaction with the device", |
Copilot
AI
Nov 23, 2025
There was a problem hiding this comment.
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.
| "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", |
- 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
…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
📝 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
✅ Checklist
Pull Requests must pass CI checks and undergo code review. Set the PR as Draft if it is not yet ready for review.
🧐 Checklist for the PR Reviewers