feat: add plugin-owned primitive registry and firmware-gated reqs#728
feat: add plugin-owned primitive registry and firmware-gated reqs#728yilmazbahadir wants to merge 4 commits intodevfrom
Conversation
…ents Migrate EVM/Solana/Cosmos/XRP lattice signers to resolve primitives via registry, add transactional chain registration, and extend unit test coverage.
70f9fae to
a83c402
Compare
commit: |
There was a problem hiding this comment.
💡 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.
| KECCAK256: typeof LatticeSignHash.keccak256; | ||
| SHA256: typeof LatticeSignHash.sha256; | ||
| SHA512HALF?: typeof LatticeSignHash.sha512half; | ||
| [key: string]: number | undefined; |
There was a problem hiding this comment.
should we have this generic item here? it reduces the type safety support we get when using them.
| getXpub?: boolean; | ||
| }; | ||
|
|
||
| export type PrimitiveKind = 'hash' | 'curve' | 'encoding'; |
There was a problem hiding this comment.
i'm not sure this is the best name for this. it's a little too generic and doesn't exactly explain what it is.
| return Math.max(0, Math.trunc(value)); | ||
| }; | ||
|
|
||
| export const getFirmwareVersion = (client: unknown): FirmwareVersionTuple => { |
There was a problem hiding this comment.
don't we have this somewhere else. did we move it?
| import { buildSigResultFromRsv, compressSecp256k1Pubkey } from './shared'; | ||
|
|
||
| type LatticeCosmosContext = DeviceContext & { | ||
| type PrimitiveCodeMaps = { |
There was a problem hiding this comment.
this is more like a "protocol" or something right?
primitive code map could be a lot of things.
📝 Summary
This PR implements a plugin-owned primitive registry so adding/migrating chains no longer requires broad SDK helper coupling.
It introduces primitive definitions/requirements on chain plugins, migrates current Lattice signers (
evm,solana,cosmos,xrp) to runtime primitive resolution, and enforces explicit firmware gating viaminFirmware(nobaselineshorthand).🔧 Context / Implementation
PrimitiveKind,PrimitiveDefinition,PrimitiveRequirement,PluginPrimitivesprimitives?: PluginPrimitivesonChainPlugincreatePrimitiveRegistry,preflight, atomicregister,resolve,resolveOrThrow,reverseResolve,has,list,reset(test isolation)EXTERNAL.SIGNING.{HASHES,CURVES,ENCODINGS}minFirmwareuseChain()before signer creation.evm,solana,cosmos,xrp) tocontext.resolvePrimitive(...)for signing primitive codes.SECP256K1,KECCAK256,EVMED25519,NONE,SOLANASECP256K1,SHA256,COSMOSSECP256K1,SHA512HALF,XRPmin firmware: 0.18.0).GET_ADDR_FLAGSand existinggetFwVersionConst()behavior unchanged in this PR.Concrete developer experience — what a new chain plugin author writes:
🧪 Test Plan
pnpm --filter @gridplus/chain-core typecheckpnpm --filter gridplus-sdk typecheckpnpm --filter gridplus-sdk test-unitExpected result: all commands pass, registration remains fail-safe/transactional, and signer payloads resolve primitive codes via registry with correct firmware gating behavior.
🖼️ Screenshots (if applicable)