Encode account and instruction integers as little-endian#63
Conversation
Switches every hand-rolled u16/u32/u64 field currently stored/sent big-endian to little-endian: OrderIntent's sell_amount/buy_amount/valid_to, OrderAccount's amount_withdrawn/amount_received, and the BeginSettle/ FinalizeSettle counterpart-index fields (finalize_ix_index/begin_ix_index). Little-endian is the Borsh/Anchor convention; this is a first step toward Anchor-compatible on-chain data so external tooling (indexers, explorers) can read it without bespoke decoding. This changes the order UID hash and the wire format of CreateOrder/BeginSettle/FinalizeSettle - not backwards compatible with any existing on-chain state or off-chain signers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
This gets external tooling the right byte values, but on its own it won't let the off-chain indexer decode without bespoke logic. The crate's instruction parsers are Could we expose the pull parse as a data-only |
Yep, sorry about that. The purpose of this PR is not designed to provide all in one fix to our indexing/data decoding issues, only to start taking steps to try and improve this. Regarding the BTW on #49 I don't know if we have made a final decision on this yet, but my guess is we will end up moving there because its easier to maintain and simplifies a lot of functions.
A data-only on-chain call? We should have a call to confirm what the use case is, but perhaps its possible to clal the affected order pda's data sturctures instead (which is now 100% IDL compliant with this and #64 change) |
Summary
OrderIntent'ssell_amount/buy_amount/valid_to,OrderAccount'samount_withdrawn/amount_received, and theBeginSettle/FinalizeSettlecounterpart-index fields (finalize_ix_index/begin_ix_index).CreateOrder,BeginSettle, andFinalizeSettle. Not compatible with any existing on-chain state or off-chain signers built against the old big-endian format. We are not concerned about this breakage at this stage.Test plan
just build-verifiedto rebuild the on-chain.socargo test --workspace— all tests pass, including updated regression tests pinning the new little-endian byte layouts and UID hash🤖 Generated with Claude Code