Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support base64 input too #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

prasincs
Copy link

I tried using this library and immediately found that I was converting base64 inputs constantly into hex to pass in. Ideally using a library like clap would've made this easier and less error prone but I like that the library has very few dependencies. I've added an optional --format that's hex by default but you can pass base64 too.

It's still backwards compatible with the examples in the README , but you can directly pass the base64 values

cargo run parse --transaction AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAHCuBScTaPd6LF/v53zlDisvk862ce7osXJzTI1N+dnt3BhqNYVmZLAzBmkMHA+9S1ghrqHGT/uMNooEIuR64NKJXeKIuoe5AwIebIwqvxLCSE6YsEB5Kx+7hwkbyODddrZgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwZGb+UhFzL/7K26csOb57yM5bvF9xJrLEObOkAAAAAEedVb8jHAbu50xW7OaBUH/bGy3qP0jlECsc2iVrwTjwbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCpjJclj04kifG7PRApFI4NgwtaE5na/xCEBI572Nvp+Fm0P/on9df2SnTAmx8pWHneSwmrNt/J3VFLMhqns4zl6Mb6evO+2606PWXzaqvJdDGxu+TC0vbg5HymAgNFL11hZBnO5wuDnrTq3RQRqnPupv2HANpfDqcwE22x3W+y3mYIBAAFAsBcFQAEAAkDyqIAAAAAAAAHBgACAA4DBgEBAwIAAgwCAAAAgPD6AgAAAAAGAQIBEQcGAAEACQMGAQEFFQYAAgEFCQUIBRAPCg0BAgsMABEGBSTlF8uXeuOtKgEAAAASAGQAAYDw+gIAAAAAXTRwAAAAAAAyAAAGAwIAAAEJAVi3P6ZtH7SgViYQE268hMdylUKo15LLm9KtG/dcMNWkBL3CwboEl7y7vw== --format base64

returns

Parsing transaction: AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAHCuBScTaPd6LF/v53zlDisvk862ce7osXJzTI1N+dnt3BhqNYVmZLAzBmkMHA+9S1ghrqHGT/uMNooEIuR64NKJXeKIuoe5AwIebIwqvxLCSE6YsEB5Kx+7hwkbyODddrZgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwZGb+UhFzL/7K26csOb57yM5bvF9xJrLEObOkAAAAAEedVb8jHAbu50xW7OaBUH/bGy3qP0jlECsc2iVrwTjwbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCpjJclj04kifG7PRApFI4NgwtaE5na/xCEBI572Nvp+Fm0P/on9df2SnTAmx8pWHneSwmrNt/J3VFLMhqns4zl6Mb6evO+2606PWXzaqvJdDGxu+TC0vbg5HymAgNFL11hZBnO5wuDnrTq3RQRqnPupv2HANpfDqcwE22x3W+y3mYIBAAFAsBcFQAEAAkDyqIAAAAAAAAHBgACAA4DBgEBAwIAAgwCAAAAgPD6AgAAAAAGAQIBEQcGAAEACQMGAQEFFQYAAgEFCQUIBRAPCg0BAgsMABEGBSTlF8uXeuOtKgEAAAASAGQAAYDw+gIAAAAAXTRwAAAAAAAyAAAGAwIAAAEJAVi3P6ZtH7SgViYQE268hMdylUKo15LLm9KtG/dcMNWkBL3CwboEl7y7vw==
Flag: Some("--transaction")
Format Flag: Some("base64")
Unsigned Transaction: 0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800100070ae05271368f77a2c5fefe77ce50e2b2f93ceb671eee8b172734c8d4df9d9eddc186a35856664b03306690c1c0fbd4b5821aea1c64ffb8c368a0422e47ae0d2895de288ba87b903021e6c8c2abf12c2484e98b040792b1fbb87091bc8e0dd76b6600000000000000000000000000000000000000000000000000000000000000000306466fe5211732ffecadba72c39be7bc8ce5bbc5f7126b2c439b3a400000000479d55bf231c06eee74c56ece681507fdb1b2dea3f48e5102b1cda256bc138f06ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a98c97258f4e2489f1bb3d1029148e0d830b5a1399daff1084048e7bd8dbe9f859b43ffa27f5d7f64a74c09b1f295879de4b09ab36dfc9dd514b321aa7b38ce5e8c6fa7af3bedbad3a3d65f36aabc97431b1bbe4c2d2f6e0e47ca60203452f5d616419cee70b839eb4eadd1411aa73eea6fd8700da5f0ea730136db1dd6fb2de660804000502c05c150004000903caa200000000000007060002000e03060101030200020c0200000080f0fa02000000000601020111070600010009030601010515060002010509050805100f0a0d01020b0c0011060524e517cb977ae3ad2a01000000120064000180f0fa02000000005d34700000000000320000060302000001090158b73fa66d1fb4a0562610136ebc84c7729542a8d792cb9bd2ad1bf75c30d5a404bdc2c1ba0497bcbbbf
Solana Parsed Transaction Payload:
  Unsigned Payload: AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAHCuBScTaPd6LF/v53zlDisvk862ce7osXJzTI1N+dnt3BhqNYVmZLAzBmkMHA+9S1ghrqHGT/uMNooEIuR64NKJXeKIuoe5AwIebIwqvxLCSE6YsEB5Kx+7hwkbyODddrZgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwZGb+UhFzL/7K26csOb57yM5bvF9xJrLEObOkAAAAAEedVb8jHAbu50xW7OaBUH/bGy3qP0jlECsc2iVrwTjwbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCpjJclj04kifG7PRApFI4NgwtaE5na/xCEBI572Nvp+Fm0P/on9df2SnTAmx8pWHneSwmrNt/J3VFLMhqns4zl6Mb6evO+2606PWXzaqvJdDGxu+TC0vbg5HymAgNFL11hZBnO5wuDnrTq3RQRqnPupv2HANpfDqcwE22x3W+y3mYIBAAFAsBcFQAEAAkDyqIAAAAAAAAHBgACAA4DBgEBAwIAAgwCAAAAgPD6AgAAAAAGAQIBEQcGAAEACQMGAQEFFQYAAgEFCQUIBRAPCg0BAgsMABEGBSTlF8uXeuOtKgEAAAASAGQAAYDw+gIAAAAAXTRwAAAAAAAyAAAGAwIAAAEJAVi3P6ZtH7SgViYQE268hMdylUKo15LLm9KtG/dcMNWkBL3CwboEl7y7vw==
  Transaction Metadata:
    Signatures: ["00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"]
    Account Keys: ["G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp", "A4a6VbNvKA58AGpXBEMhp7bPNN9bDCFS9qze4qWDBBQ8", "FxDNKZ14p3W7o1tpinH935oiwUo3YiZowzP1hUcUzUFw", "11111111111111111111111111111111", "ComputeBudget111111111111111111111111111111", "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf", "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"]
    Program Keys: ["11111111111111111111111111111111", "ComputeBudget111111111111111111111111111111", "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"]
    Recent Blockhash: 7jkbVYFiE9wY2Ghuk8e99nZmfnN1R4gUVbJAgPeQSirH
    Instructions:
      Instruction 1:
        Program Key: ComputeBudget111111111111111111111111111111
        Accounts: []
        Instruction Data (hex): 02c05c1500
        Address Table Lookups: []
      Instruction 2:
        Program Key: ComputeBudget111111111111111111111111111111
        Accounts: []
        Instruction Data (hex): 03caa2000000000000
        Address Table Lookups: []
      Instruction 3:
        Program Key: ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL
        Accounts: [SolanaAccount { account_key: "G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp", signer: true, writable: true }, SolanaAccount { account_key: "FxDNKZ14p3W7o1tpinH935oiwUo3YiZowzP1hUcUzUFw", signer: false, writable: true }, SolanaAccount { account_key: "G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp", signer: true, writable: true }, SolanaAccount { account_key: "11111111111111111111111111111111", signer: false, writable: false }, SolanaAccount { account_key: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", signer: false, writable: false }]
        Instruction Data (hex): 01
        Address Table Lookups: [SolanaSingleAddressTableLookup { address_table_key: "6yJwigBRYdkrpfDEsCRj7H5rrzdnAYv8LHzYbb5jRFKy", index: 151, writable: false }]
      Instruction 4:
        Program Key: 11111111111111111111111111111111
        Accounts: [SolanaAccount { account_key: "G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp", signer: true, writable: true }, SolanaAccount { account_key: "FxDNKZ14p3W7o1tpinH935oiwUo3YiZowzP1hUcUzUFw", signer: false, writable: true }]
        Instruction Data (hex): 0200000080f0fa0200000000
        Address Table Lookups: []
      Instruction 5:
        Program Key: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
        Accounts: [SolanaAccount { account_key: "FxDNKZ14p3W7o1tpinH935oiwUo3YiZowzP1hUcUzUFw", signer: false, writable: true }]
        Instruction Data (hex): 11
        Address Table Lookups: []
      Instruction 6:
        Program Key: ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL
        Accounts: [SolanaAccount { account_key: "G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp", signer: true, writable: true }, SolanaAccount { account_key: "A4a6VbNvKA58AGpXBEMhp7bPNN9bDCFS9qze4qWDBBQ8", signer: false, writable: true }, SolanaAccount { account_key: "G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp", signer: true, writable: true }, SolanaAccount { account_key: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", signer: false, writable: false }, SolanaAccount { account_key: "11111111111111111111111111111111", signer: false, writable: false }, SolanaAccount { account_key: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", signer: false, writable: false }]
        Instruction Data (hex): 01
        Address Table Lookups: []
      Instruction 7:
        Program Key: JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4
        Accounts: [SolanaAccount { account_key: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", signer: false, writable: false }, SolanaAccount { account_key: "G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp", signer: true, writable: true }, SolanaAccount { account_key: "FxDNKZ14p3W7o1tpinH935oiwUo3YiZowzP1hUcUzUFw", signer: false, writable: true }, SolanaAccount { account_key: "A4a6VbNvKA58AGpXBEMhp7bPNN9bDCFS9qze4qWDBBQ8", signer: false, writable: true }, SolanaAccount { account_key: "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", signer: false, writable: false }, SolanaAccount { account_key: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", signer: false, writable: false }, SolanaAccount { account_key: "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", signer: false, writable: false }, SolanaAccount { account_key: "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf", signer: false, writable: false }, SolanaAccount { account_key: "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", signer: false, writable: false }, SolanaAccount { account_key: "A4a6VbNvKA58AGpXBEMhp7bPNN9bDCFS9qze4qWDBBQ8", signer: false, writable: true }, SolanaAccount { account_key: "FxDNKZ14p3W7o1tpinH935oiwUo3YiZowzP1hUcUzUFw", signer: false, writable: true }, SolanaAccount { account_key: "G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp", signer: true, writable: true }, SolanaAccount { account_key: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", signer: false, writable: false }, SolanaAccount { account_key: "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", signer: false, writable: false }]
        Instruction Data (hex): e517cb977ae3ad2a01000000120064000180f0fa02000000005d34700000000000320000
        Address Table Lookups: [SolanaSingleAddressTableLookup { address_table_key: "6yJwigBRYdkrpfDEsCRj7H5rrzdnAYv8LHzYbb5jRFKy", index: 187, writable: false }, SolanaSingleAddressTableLookup { address_table_key: "6yJwigBRYdkrpfDEsCRj7H5rrzdnAYv8LHzYbb5jRFKy", index: 188, writable: false }, SolanaSingleAddressTableLookup { address_table_key: "6yJwigBRYdkrpfDEsCRj7H5rrzdnAYv8LHzYbb5jRFKy", index: 189, writable: true }, SolanaSingleAddressTableLookup { address_table_key: "6yJwigBRYdkrpfDEsCRj7H5rrzdnAYv8LHzYbb5jRFKy", index: 186, writable: true }, SolanaSingleAddressTableLookup { address_table_key: "6yJwigBRYdkrpfDEsCRj7H5rrzdnAYv8LHzYbb5jRFKy", index: 194, writable: true }, SolanaSingleAddressTableLookup { address_table_key: "6yJwigBRYdkrpfDEsCRj7H5rrzdnAYv8LHzYbb5jRFKy", index: 193, writable: true }, SolanaSingleAddressTableLookup { address_table_key: "6yJwigBRYdkrpfDEsCRj7H5rrzdnAYv8LHzYbb5jRFKy", index: 191, writable: false }]
      Instruction 8:
        Program Key: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
        Accounts: [SolanaAccount { account_key: "FxDNKZ14p3W7o1tpinH935oiwUo3YiZowzP1hUcUzUFw", signer: false, writable: true }, SolanaAccount { account_key: "G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp", signer: true, writable: true }, SolanaAccount { account_key: "G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp", signer: true, writable: true }]
        Instruction Data (hex): 09
        Address Table Lookups: []
    Transfers:
      Transfer 1:
        From: G6fEj2pt4YYAxLS8JAsY5BL6hea7Fpe8Xyqscg2e7pgp
        To: FxDNKZ14p3W7o1tpinH935oiwUo3YiZowzP1hUcUzUFw
        Amount: 50000000
    SPL Transfers:
    Address Table Lookups: [SolanaAddressTableLookup { address_table_key: "6yJwigBRYdkrpfDEsCRj7H5rrzdnAYv8LHzYbb5jRFKy", writable_indexes: [189, 194, 193, 186], readonly_indexes: [151, 188, 187, 191] }]

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.

1 participant