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

[Feature Request] Decode WriteSetChangeWriteTableItem.data to not null #376

Open
0xbe1 opened this issue Apr 21, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@0xbe1
Copy link

0xbe1 commented Apr 21, 2024

🚀 Feature Request Description

Currently, the data?: DecodedTableData; field in WriteSetChangeWriteTableItem is always null based on ts-sdk call. Would be great if it can be decoded and filled.

Motivation

Is your feature request related to a problem? Please describe you use case.

It's helpful to know what's inside the WriteTableItem without having to make an additional getTableItem call.

Pitch

Describe the solution you would like

Describe alternatives you've considered

Are you willing to open a pull request? (See CONTRIBUTING)

Additional context

Use this txn https://aptoscan.com/transaction/563060087#changes as an example. From aptoscan.com we easily tell the decoded data (see below).
image

However, when using ts-sdk to write a script (see below), the data field is always null

import { Aptos, AptosConfig, Network, WriteSetChange, WriteSetChangeWriteTableItem, isUserTransactionResponse } from "@aptos-labs/ts-sdk";

const aptos = new Aptos(new AptosConfig({ network: Network.MAINNET }));

main();

async function main() {
    // https://aptoscan.com/transaction/563060087
    const tx = await aptos.getTransactionByVersion({ledgerVersion: 563060087});
    if (isUserTransactionResponse(tx) && tx.success) {
        for (const change of tx.changes) {
            if (isWriteSetChangeWriteTableItem(change)) {
                console.log("change", JSON.stringify(change))
            }
        }
    }
}

export function isWriteSetChangeWriteTableItem(
  change: WriteSetChange,
): change is WriteSetChangeWriteTableItem {
  return "handle" in change && "value" in change;
}

running this script we get (note the null data field)

change {"state_key_hash":"0x6e4b28d40f98a106a65163530924c0dcb40c1349d3aa915d108b4d6cfc1ddb19","handle":"0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca","key":"0x0619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935","value":"0x8d566b50caf783010000000000000000","data":null,"type":"write_table_item"}
change {"state_key_hash":"0xc72c73ecb64a06a52ec893597d0047058b2a54b3a3366f9544284f535d5d9d6b","handle":"0x7a36d3935ebd2045f49fab033acad5212782ff81c4b79bd55cc1af3ce7c8418b","key":"0x4b3078643931366139353064346331323739646634616130643666333230313138343264633563363333613435633131616335303139323332633135396431313562623a3a636f696e3a3a54","value":"0x376dc669882afc0501000000000000000400","data":null,"type":"write_table_item"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

1 participant