feat: read a market's details from a create_market transaction#165
Merged
Conversation
Time Submission Status
Submit or update total time with: Add time on top of previous submission with: See available commands to help comply with our Guidelines. |
Contributor
📝 WalkthroughWalkthroughAdds a new ChangesdecodeCreateMarketPayload decoder
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant decodeCreateMarketPayload
participant decodeMarketData
Caller->>decodeCreateMarketPayload: payload (DecodedTransactionPayload)
decodeCreateMarketPayload->>decodeCreateMarketPayload: check action === "create_market"
decodeCreateMarketPayload->>decodeCreateMarketPayload: validate call arguments length
decodeCreateMarketPayload->>decodeMarketData: query_components bytes
decodeMarketData-->>decodeCreateMarketPayload: market or decode error
decodeCreateMarketPayload-->>Caller: CreateMarketPayload or null
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
Author
|
@holdex pr submit-time 4h |
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.
resolves: https://github.com/trufnetwork/trufscan/issues/173
A block explorer reading a
create_markettransaction gets back its five raw action arguments, one of which (query_components) is a nested double-encoding — an ABI tuple wrapping a kwil-native argument blob. Decoding that meant knowing create_market's argument order and stitching two decoders together by hand. The SDK owns the encode side (OrderbookAction.createMarket,encodeQueryComponents), so it should own the symmetric decode.Adds
decodeCreateMarketPayload(payload), the transaction-level counterpart tocreateMarket. Given a decoded execute payload (fromTransactionAction.getTransactionInput/decodeTransactionPayload) it returns a structuredCreateMarketPayload:nullwhen the transaction isn't acreate_marketcall, so callers branch cleanly.create_marketbut doesn't carry its five arguments.query_componentsare decoded toMarketData(type + thresholds) via the existingdecodeMarketData. Decode is non-fatal: a committed-but-execution-failed create_market can carry empty/garbage components, somarketis leftnullrather than crashing an explorer that's iterating a block.The argument order (
$bridge, $query_components, $settle_time, $max_spread, $min_order_size) matches the on-chaincreate_marketsignature in node migration032-order-book-actions.sql.Test-first: four cases watched fail before the code existed — structured fields, the nested market decode, the null-when-not-create_market path, and the throw-on-truncated path. Also verified against the exact
query_componentsbyte vector from trufscan#173.test:unit(292),typecheck, andbuildare green.Summary by CodeRabbit
New Features
create_markettransaction details into a structured, easy-to-use format.Bug Fixes
Tests