Skip to content

feat: Decode Swig Instructions#83

Open
santy311 wants to merge 6 commits intomainfrom
santhosh/decoder-2
Open

feat: Decode Swig Instructions#83
santy311 wants to merge 6 commits intomainfrom
santhosh/decoder-2

Conversation

@santy311
Copy link
Collaborator

@santy311 santy311 commented Aug 1, 2025

This PR introduces transaction decoding and simulation capabilities to the SWIG Rust SDK, enhancing the devex with better transaction visibility and debugging tools.

  1. Transaction Decoder
    New decoder.rs module with comprehensive SWIG instruction decoding
  • DecodedTransaction struct providing human-readable transaction information including:
  • Instruction type identification (CreateSwig, AddAuthority, Sign, etc.)
  • Role ID and authority type tracking
  • InstructionType enum covering all SWIG operations:
  1. Transaction Simulation
  • Account balance tracking with AccountChange struct showing pre/post transaction states
  • Balance change analysis for all accounts involved in transactions
  • Account summary generation providing detailed balance impact information
  • Integration with existing wallet functionality for seamless simulation workflow

@santy311
Copy link
Collaborator Author

santy311 commented Aug 1, 2025

cargo test should_decode_create_swig_instruction --features=rust_sdk_test -- --nocapture

Copy link
Contributor

@tracy-codes tracy-codes left a comment

Choose a reason for hiding this comment

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

This looks great so far! I think if we can set the output type to be json or in something like a set of solana tranasction instructions struct types that we can then either base58 encode or base64 encode, that would take this to the next level here.

@santy311
Copy link
Collaborator Author

santy311 commented Aug 6, 2025

@tracy-codes I have added support for JSON outputs with a small hack in states crate

{
  "instruction_type": "Sign",
  "description": "Sign a transaction",
  "role_id": 0,
  "authority_type": "Ed25519",
  "data": null,
  "fee_payer": "Frtjd3aVM7A9HCP5VCkyjCn3KtBEhSDycY9t4Qs9ntTt",
  "account_summary": [
    {
      "account_id": "Frtjd3aVM7A9HCP5VCkyjCn3KtBEhSDycY9t4Qs9ntTt",
      "account_name": null,
      "pre_balance": 9998365280,
      "post_balance": 9998360280,
      "balance_change": -5000
    },
    {
      "account_id": "7JKfJaxbNSqvzMryvQMeAejxCR4odjHj1vh3Jxnuxgu8",
      "account_name": null,
      "pre_balance": 0,
      "post_balance": 100000000,
      "balance_change": 100000000
    },
    {
      "account_id": "Add51oQvYk863Rp35W4Hzv1Uk3GHLTnbn2tSuiFDoDJc",
      "account_name": null,
      "pre_balance": 10001614720,
      "post_balance": 9901614720,
      "balance_change": -100000000
    }
  ]
}

@santy311 santy311 changed the title WIP: Decode Swig Instructions feat: Decode Swig Instructions Aug 6, 2025
@tracy-codes tracy-codes self-requested a review August 7, 2025 22:13
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.

2 participants