Skip to content

✨ (context-module) [DSDK-1142]: Add solana clear sign loaders#1511

Open
fAnselmi-Ledger wants to merge 1 commit into
developfrom
feat/dsdk-1138-solana-tx-check-loaders
Open

✨ (context-module) [DSDK-1142]: Add solana clear sign loaders#1511
fAnselmi-Ledger wants to merge 1 commit into
developfrom
feat/dsdk-1138-solana-tx-check-loaders

Conversation

@fAnselmi-Ledger
Copy link
Copy Markdown
Contributor

@fAnselmi-Ledger fAnselmi-Ledger commented May 25, 2026

📝 Description

Ticket 1 of the Solana generic clear-signing: six new context-module loaders that fetch the static (CAL) and dynamic (challenge-bound) descriptors the merge engine needs.

What's in:

Loaders (under modules/solana/):

  • InstructionInfoContextLoader, CAL, one HTTP call per programId fanned out in parallel
  • EnumVariantContextLoader, second-pass API: caller supplies selected (programId, enumId, variantIndex) after running the host-side IDL_TYPE_POOL walker
  • TokenInfoContextLoader, CAL by mint pubkey, emits SOLANA_TOKEN_INFO
  • TokenAccountStateContextLoader, AltResolutionContextLoader, SolanaTrustedNameContextLoader, challenge-bound dynamic backend

Shared infra in shared/utils/:

  • deviceModelIdCodec, supported clear-sign device set (also adopted by SolanaTransactionCheckLoader)
  • u8Codec, for byte-wide TLV fields (used by both loader canHandle codecs and HttpAltResolutionDataSource)
  • signedDescriptorDtoCodec, purify-ts codec for the {signedDescriptor, keyId, keyUsage} envelope returned by every dynamic backend endpoint
  • makeCertificateCache(loader, device), per-batch (keyId, keyUsage) cert-load memoiser, shared by the 3 challenge-bound loaders
  • loadCertificateResult(loader, params), tagged-Result wrapper so cert+data can Promise.all without one path's rejection tanking the other
  • HexStringUtils.hexToBytes, rejects empty / 0x-only / odd-length / non-hex

Types:

  • 5 new ClearSignContextType values + typed payload overrides + SolanaInstructionSubstructureKind enum mapping the 4 substructure type bytes.

DI:

  • module factories wired into di.ts Solana branch + DefaultContextModule._getDefaultLoaders + barrel exports.

Notes:

  • Validation via purify-ts Codec everywhere: canHandle inputs (per-loader codecs), dynamic backend envelopes (signedDescriptorDtoCodec), CAL responses (inline per-datasource codecs), u8 invariants (u8Codec)
  • Parallelism: cert load runs concurrently with CAL fetches for the 3 single-cert loaders (via loadCertificateResult + Promise.all) the 3 challenge-bound loaders dedup per-batch cert loads via makeCertificateCache so N requests sharing the same PKI key issue 1 loadCertificate, not N
  • Empty signedDescriptor rejected at the codec, missing signature => ERROR context (not silent empty), loadCertificate wrapped in try/catch => per-request ERROR, || (not ??) on network so "" also falls back
  • SolanaContextSuccessType deliberately NOT widened to avoid breaking the signer's mapped registry, widening + handlers will land together in the device-action wiring PR

❓ 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.

  • 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 May 25, 2026 14:55
@fAnselmi-Ledger fAnselmi-Ledger requested a review from a team as a code owner May 25, 2026 14:55
@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
device-sdk-ts-sample Ready Ready Preview, Comment May 26, 2026 9:19am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
doc-device-management-kit Ignored Ignored May 26, 2026 9:19am

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 25, 2026

Danger Check Results

Messages

Danger: All checks passed successfully! 🎉

Generated by 🚫 dangerJS against c340207

Copy link
Copy Markdown
Contributor

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

Adds a set of Solana context-module loaders and supporting utilities to power the Solana generic clear-signing pipeline (static CAL descriptors + challenge-bound dynamic descriptors), and wires them into the context-module DI/export surface.

Changes:

  • Added shared input-validation codecs (deviceModelIdCodec, u8Codec) and stricter hex decoding (HexStringUtils.hexToBytes) with tests.
  • Implemented new Solana loaders + HTTP datasources for instruction-info (CAL), enum-variant (second-pass CAL), token-info (CAL), and dynamic descriptors (token-account-state, ALT resolution, trusted name), with tests.
  • Extended context types/payload typings and registered new modules/loaders in DI + default loader set + package exports.

Reviewed changes

Copilot reviewed 55 out of 55 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/signer/context-module/src/shared/utils/u8Codec.ts Adds a purify-ts codec for validating u8 (0..255) inputs.
packages/signer/context-module/src/shared/utils/u8Codec.test.ts Unit tests for u8Codec decode/encode behavior.
packages/signer/context-module/src/shared/utils/HexStringUtils.ts Adds hexToBytes with strict validation (non-empty, even-length, hex-only).
packages/signer/context-module/src/shared/utils/HexStringUtils.test.ts Adds tests for hexToBytes success and failure cases.
packages/signer/context-module/src/shared/utils/deviceModelIdCodec.ts Introduces a shared codec for supported clear-sign/tx-check device models.
packages/signer/context-module/src/shared/utils/deviceModelIdCodec.test.ts Tests supported/unsupported device models for deviceModelIdCodec.
packages/signer/context-module/src/shared/model/ClearSignContext.ts Extends ClearSignContextType with new Solana clear-signing context types.
packages/signer/context-module/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.ts New loader for challenge-bound Solana trusted-name descriptors + cert dedup.
packages/signer/context-module/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.test.ts Tests canHandle/load behavior for trusted-name loader.
packages/signer/context-module/src/modules/solana/trusted-name/di/trustedNameTypes.ts DI symbols for Solana trusted-name module.
packages/signer/context-module/src/modules/solana/trusted-name/di/trustedNameModuleFactory.ts DI container module binding trusted-name datasource + loader.
packages/signer/context-module/src/modules/solana/trusted-name/data/TrustedNameDataSource.ts Defines trusted-name datasource interface and result types.
packages/signer/context-module/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.ts HTTP implementation for Solana trusted-name reverse lookup + hex decode.
packages/signer/context-module/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.test.ts Tests Solana trusted-name HTTP datasource request/response handling.
packages/signer/context-module/src/modules/solana/token-info/domain/TokenInfoContextLoader.ts New CAL-backed token-info loader (mint pubkey keyed) with cert + signature selection.
packages/signer/context-module/src/modules/solana/token-info/domain/TokenInfoContextLoader.test.ts Tests token-info loader dedup, error cases, mode selection, default network.
packages/signer/context-module/src/modules/solana/token-info/di/tokenInfoTypes.ts DI symbols for token-info module.
packages/signer/context-module/src/modules/solana/token-info/di/tokenInfoModuleFactory.ts DI bindings for token-info datasource + loader.
packages/signer/context-module/src/modules/solana/token-info/data/TokenInfoDataSource.ts Defines token-info datasource contract and result types.
packages/signer/context-module/src/modules/solana/token-info/data/HttpTokenInfoDataSource.ts HTTP datasource for CAL token-info descriptor lookup by mint.
packages/signer/context-module/src/modules/solana/token-info/data/HttpTokenInfoDataSource.test.ts Tests token-info HTTP datasource behavior and errors.
packages/signer/context-module/src/modules/solana/token-account-state/domain/TokenAccountStateContextLoader.ts Loader for challenge-bound token-account-state descriptors + per-batch cert dedup.
packages/signer/context-module/src/modules/solana/token-account-state/domain/TokenAccountStateContextLoader.test.ts Tests token-account-state loader canHandle/load error handling.
packages/signer/context-module/src/modules/solana/token-account-state/di/tokenAccountStateTypes.ts DI symbols for token-account-state module.
packages/signer/context-module/src/modules/solana/token-account-state/di/tokenAccountStateModuleFactory.ts DI bindings for token-account-state datasource + loader.
packages/signer/context-module/src/modules/solana/token-account-state/data/TokenAccountStateDataSource.ts Defines token-account-state datasource contract.
packages/signer/context-module/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.ts HTTP datasource for token-account-state backend endpoint + hex decode.
packages/signer/context-module/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.test.ts Tests token-account-state HTTP datasource request/hex validation/errors.
packages/signer/context-module/src/modules/solana/model/SolanaPayloads.ts Adds new typed payloads (instruction-info, enum-variant, token-info, dynamic descriptors).
packages/signer/context-module/src/modules/solana/model/SolanaContextTypes.ts Adds note about intentionally not widening Solana success union yet.
packages/signer/context-module/src/modules/solana/model/SolanaClearSignContext.ts Extends Solana payload overrides + exports for new context payload types.
packages/signer/context-module/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.ts CAL instruction-info loader (one call per programId, filters discriminators, bundles substructures).
packages/signer/context-module/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.ts Extensive tests for instruction-info loader behavior, filtering, signature/mode, errors.
packages/signer/context-module/src/modules/solana/instruction-info/di/instructionInfoTypes.ts DI symbols for instruction-info module.
packages/signer/context-module/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.ts DI bindings for instruction-info datasource + loader.
packages/signer/context-module/src/modules/solana/instruction-info/data/InstructionInfoDto.ts DTO typings for CAL /solana?output=descriptors_instruction response.
packages/signer/context-module/src/modules/solana/instruction-info/data/InstructionInfoDataSource.ts Datasource interface for fetching instruction descriptors per program.
packages/signer/context-module/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.ts HTTP datasource for CAL instruction-info, unwraps envelope and validates presence.
packages/signer/context-module/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.ts Tests instruction-info HTTP datasource success and error cases.
packages/signer/context-module/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.ts Second-pass enum-variant loader (fetches CAL per programId, emits only selected variants).
packages/signer/context-module/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.test.ts Tests enum-variant loader selection, deduped fetches, errors, cert failures.
packages/signer/context-module/src/modules/solana/enum-variant/di/enumVariantTypes.ts DI symbols for enum-variant loader.
packages/signer/context-module/src/modules/solana/enum-variant/di/enumVariantModuleFactory.ts DI module for enum-variant loader (reuses instruction-info datasource binding).
packages/signer/context-module/src/modules/solana/alt-resolution/domain/AltResolutionContextLoader.ts Loader for challenge-bound ALT resolution descriptors + per-batch cert dedup.
packages/signer/context-module/src/modules/solana/alt-resolution/domain/AltResolutionContextLoader.test.ts Tests alt-resolution loader canHandle/load and certificate dedup behavior.
packages/signer/context-module/src/modules/solana/alt-resolution/di/altResolutionTypes.ts DI symbols for alt-resolution module.
packages/signer/context-module/src/modules/solana/alt-resolution/di/altResolutionModuleFactory.ts DI bindings for alt-resolution datasource + loader.
packages/signer/context-module/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.ts HTTP datasource for ALT resolution endpoint + entryIndex validation + hex decode.
packages/signer/context-module/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.test.ts Tests ALT resolution HTTP datasource validation and error paths.
packages/signer/context-module/src/modules/solana/alt-resolution/data/AltResolutionDataSource.ts Defines ALT resolution datasource contract and result types.
packages/signer/context-module/src/modules/multichain/transaction-check/loaders/SolanaTransactionCheckLoader.ts Reuses shared deviceModelIdCodec for device validation in tx-check loader.
packages/signer/context-module/src/index.ts Exports newly added Solana loaders/datasources from the package entrypoint.
packages/signer/context-module/src/di.ts Registers new Solana module factories in the Solana DI branch.
packages/signer/context-module/src/DefaultContextModule.ts Adds new Solana loaders to the default loader list for the Solana chain.
.changeset/plain-houses-itch.md Declares a minor bump with a brief release-note entry.

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

Comment thread packages/signer/context-module/src/modules/solana/model/SolanaContextTypes.ts Outdated
Comment thread packages/signer/context-module/src/modules/solana/model/SolanaPayloads.ts Outdated
Comment thread .changeset/plain-houses-itch.md Outdated
@fAnselmi-Ledger fAnselmi-Ledger changed the title ✨ (context-module): Add solana tx checks loaders ✨ (context-module) [DSDK-1142]: Add solana tx checks loaders May 25, 2026
@fAnselmi-Ledger fAnselmi-Ledger changed the title ✨ (context-module) [DSDK-1142]: Add solana tx checks loaders ✨ (context-module) [DSDK-1142]: Add solana clear sign loaders May 25, 2026
@fAnselmi-Ledger fAnselmi-Ledger force-pushed the feat/dsdk-1138-solana-tx-check-loaders branch from 69975aa to 4e8bd56 Compare May 25, 2026 16:01
@fAnselmi-Ledger fAnselmi-Ledger force-pushed the feat/dsdk-1138-solana-tx-check-loaders branch from 4e8bd56 to c340207 Compare May 26, 2026 09:15
@ledger-wiz-cspm-secret-detection
Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 5 Medium
Software Management Finding Software Management Findings -
Total 5 Medium

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@sonarqubecloud
Copy link
Copy Markdown

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