Subscripting a transaction's pre_token_balances and post_token_balances returns the same object?
Bewinxed opened this issue · comments
So let's say i fetch a transaction:
tx_sig='4JsupFeVjPjLQfYLGGkDds6PZbfqhehJXYu5XryNN26hwChX9oPisZra61vvMzAK2xhQHa84r44aWaenD8hbjpgg',
encoding="jsonParsed",
commitment=None,
max_supported_transaction_version=None,
)
Then I print the transaction meta and I get:
pre_token_balances: Some(
[
UiTransactionTokenBalance {
account_index: 1,
mint: "cUBeL4fhn1yznohws5Gquc3CnomDJwKL7Bz24RSCEVu",
ui_token_amount: UiTokenAmount {
ui_amount: Some(
1.0,
),
decimals: 0,
amount: "1",
ui_amount_string: "1",
},
owner: Some(
"Bwinxuqwf5uNcqCAFG8Wqt7cGcirdPkthn4MbNXhJY8f",
),
program_id: Skip,
},
],
),
post_token_balances: Some(
[
UiTransactionTokenBalance {
account_index: 1,
mint: "cUBeL4fhn1yznohws5Gquc3CnomDJwKL7Bz24RSCEVu",
ui_token_amount: UiTokenAmount {
ui_amount: Some(
1.0,
),
decimals: 0,
amount: "1",
ui_amount_string: "1",
},
owner: Some(
"GUfCR9mK6azb9vcpsxgXyj7XRPAKJd4KMHTTVvtncGgp",
),
program_id: Skip,
},
],
),
then I do this:
pre_balances = response.transaction.meta.pre_token_balances
post_balances = response.transaction.meta.post_token_balances
print(pre_balances)
print(post_balances)
They both return the pre balances value
[
UiTransactionTokenBalance {
account_index: 1,
mint: "cUBeL4fhn1yznohws5Gquc3CnomDJwKL7Bz24RSCEVu",
ui_token_amount: UiTokenAmount {
ui_amount: Some(
1.0,
),
decimals: 0,
amount: "1",
ui_amount_string: "1",
},
owner: Some(
"GUfCR9mK6azb9vcpsxgXyj7XRPAKJd4KMHTTVvtncGgp",
),
program_id: Skip,
},
],
),
I had to turn meta into a dict using loads(response.transaction.meta.to_json())
and only then could I access the proper token balances.
Even if I print the objects directly they print the same value, and even if I do
response.transaction.meta.post_token_balances == response.transaction.meta.pre_token_balances it returns True
Am I tripping?
I believe this is a Solana JSON RPC API issue. We don't have control over what the Solana Node returns back. Might want to ask someone at @solana-labs
Are you using the latest solana-py? This should be fixed by kevinheavey/solders#59