Skip to content

Use index to order the raw inputs#4713

Open
nikhil-gupta-tw wants to merge 2 commits intomasterfrom
fix/sui-input-order
Open

Use index to order the raw inputs#4713
nikhil-gupta-tw wants to merge 2 commits intomasterfrom
fix/sui-input-order

Conversation

@nikhil-gupta-tw
Copy link
Copy Markdown

This pull request ensures that transaction inputs are processed in the order specified by their index field, regardless of their order in the raw JSON, and adds a new test to verify this behavior.

Transaction input ordering:

  • Modified TransactionBuilder::raw_json to explicitly sort transaction inputs by their index field before processing, ensuring consistent input order.

Testing improvements:

  • Added a new test test_raw_json_sorts_inputs_by_declared_index in aftermath_json_support.rs to verify that inputs are sorted and processed according to their declared index, not their order in the JSON array.
  • Added necessary imports for CallArg, TransactionData, and TransactionKind to support the new test.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes TransactionBuilder::raw_json process Sui programmable transaction inputs in the order defined by each input’s index field (rather than JSON array order), and adds a regression test to verify the behavior.

Changes:

  • Sort raw JSON inputs by their declared index before converting them into CallArgs.
  • Add a unit test asserting that out-of-order JSON inputs are reordered into index order.
  • Add supporting imports in the test for inspecting the produced TransactionData.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
rust/chains/tw_sui/src/transaction/transaction_builder.rs Sorts raw inputs by index prior to building the programmable transaction inputs vector.
rust/chains/tw_sui/tests/aftermath_json_support.rs Adds a test that confirms raw_json orders inputs by declared index.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

Binary size comparison

➡️ aarch64-apple-ios: 14.34 MB

➡️ aarch64-apple-ios-sim: 14.35 MB

➡️ aarch64-linux-android: 18.78 MB

➡️ armv7-linux-androideabi: 16.21 MB

➡️ wasm32-unknown-emscripten: 13.69 MB

Copy link
Copy Markdown
Contributor

@sergei-boiko-trustwallet sergei-boiko-trustwallet left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants