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

fix(sui_indexer): get object packages #20349

Merged

Conversation

sergiupopescu199
Copy link
Contributor

@sergiupopescu199 sergiupopescu199 commented Nov 20, 2024

Description

When requesting a package object

curl --location 'localhost:9124' \
--header 'content-type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "sui_getObject",
    "params": [
        "0x2",
        {
            "showType": true,
            "showContent": true,
            "showOwner": true,
            "showPreviousTransaction": true,
            "showStorageRebate": true,
            "showDisplay": true
        }
    ]
}'
   

this error is returned

{
    "jsonrpc": "2.0",
    "error": {
        "code": -32000,
        "message": "Indexer failed to read PostgresDB with error: `Object (0x0000000000000000000000000000000000000000000000000000000000000002, SequenceNumber(1), o#8MAXVsbUti4fZvSmk8xvKLYsaKSWyv8nNomCkGpLaj1T) is not a Move object`"
    },
    "id": 3
}

Before this commit the indexer was able to fetch the package objects, this PR fixes the ability to get package objects in the indexer's ReadApi get_object RPC function.

Inspired from this PR: iotaledger/iota#3610

Test plan

Start Postgres

docker run --rm --name sui_indexer -e POSTGRES_PASSWORD=postgrespw -e POSTGRES_USER=postgres -e POSTGRES_DB=sui_indexer -d -p 5432:5432 postgres

start the local network

RUST_LOG=info cargo run --bin sui start --force-regenesis  --with-indexer
REQUEST & RESPONSE
   curl --location 'localhost:9124' \
--header 'content-type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "sui_getObject",
    "params": [
        "0x2",
        {
            "showType": true,
            "showContent": true,
            "showOwner": true,
            "showPreviousTransaction": true,
            "showStorageRebate": true,
            "showDisplay": true
        }
    ]
}'
{
    "jsonrpc": "2.0",
    "result": {
        "data": {
            "objectId": "0x0000000000000000000000000000000000000000000000000000000000000002",
            "version": "1",
            "digest": "FwHb3FcUrPqMuzdvTK9jsp6xuwM4HzTTAc5dz9AsBwVZ",
            "type": "package",
            "owner": "Immutable",
            "previousTransaction": "2oLipcFA1DRyVfV2C8xzXJmG8scXDLKyQfFCQD6kLXpz",
            "storageRebate": "0",
            "display": {
                "data": null,
                "error": null
            },
            "content": {
                "dataType": "package",
                "disassembled": {..}
            }
        }
    },
    "id": 3
}

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer: A minor fix of JSON RPC Read API to return package object properly.
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

Copy link

vercel bot commented Nov 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 2:54pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Nov 20, 2024 2:54pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Nov 20, 2024 2:54pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Nov 20, 2024 2:54pm

@gegaowp
Copy link
Contributor

gegaowp commented Nov 20, 2024

looks good, thanks @sergiupopescu199 for the fix, running CI now and will merge after that.

@sergiupopescu199
Copy link
Contributor Author

looks good, thanks @sergiupopescu199 for the fix, running CI now and will merge after that.

Thank you @gegaowp really appreciated!

@gegaowp gegaowp merged commit e1cfa3b into MystenLabs:main Nov 20, 2024
47 of 49 checks passed
@sergiupopescu199 sergiupopescu199 deleted the sergiupopescu/get_object_packages branch November 20, 2024 18:41
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