Repository navigation
feat(ismp): add cross-chain types and a typed ismp_* client - #2
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds ISMP types and
client.ismp, a typed client for theismp_*RPC endpoints, so consumers can read cross-chain traffic without hand-rolling shapes. Read-only by design: dispatching a message is an extrinsic, and a root-only one on this chain.Downstream of the Hyperbridge integration —
privacy-explorerneeds these types to render cross-chain activity, and it pins this package from the npm registry rather than a workspace link, so this has to ship before the explorer can consume it.Two shapes a consumer would otherwise get wrong
Both captured from a running node, not inferred from the pallet source.
A request comes back wrapped in its variant, not flattened:
[{ "Post": { "source": "SUBSTRATE-orbi", "dest": "KUSAMA-1000", "nonce": 0, ... } }]Reading
result[0].sourceyieldsundefined.IsmpRequestis therefore a union that forces narrowing on the key first.Each transport names a chain differently. The
ismp_*RPCs serialise a state machine as a string ("KUSAMA-1000"); decoded block events give the SCALE enum ({ type: 'Kusama', value: 1000 }). Both are typed — assuming one silently readsundefinedfrom the other.ismp_queryEventswas another surprise: it returns a map keyed by block hash, with unmatched blocks present as empty arrays, so the keys describe the range scanned rather than the blocks that matched.Events
All seven
ismpMessagingvariants, plus the sevenismpvariants worth modelling. The union documents what it deliberately omits and why — consensus-client lifecycle is answered better by the RPCs,RelayerFeeWithdrawncan only be triggered by the configured coprocessor, andResponseis never deposited bypallet-ismpat all.Includes the
commitmentthat runtime spec 12 added toMessageReceived,MessageRejected,RequestTimedOutandGetResponseReceived. Before that field existed, an arrival could not be attributed to any message and an expiry could not be matched to what expired. The doc comments carry the two asymmetries that are easy to get backwards:PostRequestHandledfires on the destination whileGetRequestHandledfires on the origin, and*Handled/*TimeoutHandledare different structs.Null over throw
latestHeightandchallengePeriodreturnnullwhen a channel is unknown. The RPC answers absent state with an error code, which at the JSON-RPC layer is indistinguishable from a transport failure — and "not onboarded yet" is a normal state during setup, so making every caller wrap it in try/catch would be the wrong default.Verification
Exercised against a live dev node with a real dispatched message, not only compiled: narrowing on
Postresolves, all three lookups returnnullon an absent channel instead of throwing,eventsreturns its block-hash map, andrequests([])short-circuits without a call.857 tests pass across 35 files, including 7 new structural ones.
typecheck:all, lint and build are clean.Release
Version
0.2.0→0.3.0, additive only. The CHANGELOG section is in place — I reproduced the release workflow's gate (grep "^## \[0.3.0\]") to confirm it passes.