Skip to content

feat: add signing component registry and firmware-gated reqs#728

Merged
yilmazbahadir merged 6 commits intodevfrom
baha/feat/primitive-registry
Mar 4, 2026
Merged

feat: add signing component registry and firmware-gated reqs#728
yilmazbahadir merged 6 commits intodevfrom
baha/feat/primitive-registry

Conversation

@yilmazbahadir
Copy link
Collaborator

@yilmazbahadir yilmazbahadir commented Feb 25, 2026

📝 Summary

This PR introduces a plugin-owned signing-component registry for chain plugins and removes broad SDK helper coupling when adding/migrating chains.

It includes:

  • plugin-owned definitions/requirements with explicit minFirmware gating
  • transactional registration behavior in SDK runtime
  • signer migration for evm, solana, cosmos, xrp
  • compatibility fixes for existing DeviceContext integrations
  • terminology/API refactor from primitive to signing component
  • lint/wiring cleanup commits needed to stabilize and pass checks

🔧 Context / Implementation

  • Added chain-core signing component model:
    • SigningComponentKind, SigningComponentDefinition, SigningComponentRequirement
    • ChainSigningSuite
    • signingSuite?: ChainSigningSuite on ChainPlugin
  • Replaced primitive registry with signing component registry in chain-core:
    • createSigningComponentRegistry, preflight, atomic register, resolve, resolveOrThrow, reverseResolve, has, list, reset
    • collision semantics retained for name/code conflicts
  • Replaced SDK primitive lifecycle with signing component lifecycle:
    • lazy/idempotent seeding from EXTERNAL.SIGNING.{HASHES,CURVES,ENCODINGS}
    • plugin preflight/register helpers
    • fail-closed requirement shape validation (minFirmware required)
  • Made registration transactional and safe:
    • seed -> preflight -> register plugin -> commit definitions
    • rollback on failure
    • discovery path uses same registration flow
  • Added plugin-owned definition cleanup on unregister:
    • tracks plugin-owned signing component definitions
    • unregisterChain() removes owned definitions and prevents stale conflicts on re-register
  • Added firmware requirement enforcement in useChain() before signer creation.
  • Setup now seeds signing components early (idempotent).
  • Migrated lattice signers to context.resolveSigningComponent(...):
    • evm, solana, cosmos, xrp
  • Preserved compatibility for older contexts:
    • signers now fallback to constants.EXTERNAL.SIGNING when resolver is absent
  • Kept explicit request-time EIP-7702 firmware gate in EVM signer (>= 0.18.0).
  • Tightened firmware typing (packages/types/src/firmware.ts) by removing permissive index signatures from signing maps.
  • GET_ADDR_FLAGS and getFwVersionConst() behavior remain unchanged in this PR.

Concrete developer experience — what a new chain plugin author writes:

export const latticePlugin: ChainPlugin<LatticeNewChainContext> = {
  chainId: 'newchain',
  device: 'lattice',
  module: newchain,
  createSigner: (context) => createLatticeNewChainSigner(context),
  signingSuite: {
    definitions: [
      { kind: 'encoding', name: 'NEWCHAIN', code: 9 },
      { kind: 'hash', name: 'BLAKE2B', code: 4 },
    ],
    requirements: [
      { kind: 'curve', name: 'ED25519', minFirmware: [0, 14, 0] },
      { kind: 'encoding', name: 'NEWCHAIN', minFirmware: [0, 20, 0] },
      { kind: 'hash', name: 'BLAKE2B', minFirmware: [0, 20, 0] },
    ],
  },
};

// Inside signer:
const curveCode = context.resolveSigningComponent('curve', 'ED25519');
const encodingCode = context.resolveSigningComponent('encoding', 'NEWCHAIN');
const hashCode = context.resolveSigningComponent('hash', 'BLAKE2B');

…ents

Migrate EVM/Solana/Cosmos/XRP lattice signers to resolve primitives via registry, add transactional chain registration, and extend unit test coverage.
@yilmazbahadir yilmazbahadir changed the title feat: add plugin-owned primitive registry and firmware-gated requirem… feat: add plugin-owned primitive registry and firmware-gated reqs Feb 25, 2026
@yilmazbahadir yilmazbahadir force-pushed the baha/feat/primitive-registry branch from 70f9fae to a83c402 Compare February 25, 2026 13:44
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 25, 2026

Open in StackBlitz

npm i https://pkg.pr.new/gridplus-sdk@728

commit: 4909666

@yilmazbahadir yilmazbahadir marked this pull request as ready for review February 25, 2026 20:52
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d308cf86e2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…imitives on unregister

Add lattice signer fallback to EXTERNAL.SIGNING when resolvePrimitive is absent, and remove plugin-owned primitive definitions during unregisterChain to prevent stale conflicts.
@yilmazbahadir yilmazbahadir requested a review from hmrkx February 25, 2026 21:36
Replace Primitive* types and registry APIs with SigningComponent* across chain-core and sdk.

Migrate lattice signers/context to resolveSigningComponent with EXTERNAL.SIGNING fallback to preserve DeviceContext compatibility.

Rename primitive-focused modules/tests and keep transactional plugin register/unregister cleanup for plugin-owned signing components.
@yilmazbahadir yilmazbahadir changed the title feat: add plugin-owned primitive registry and firmware-gated reqs feat: add signing component registry and firmware-gated reqs Mar 4, 2026
@yilmazbahadir yilmazbahadir merged commit 4e11d02 into dev Mar 4, 2026
6 checks 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