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

[Proposal] getAssetSignatures method response schema #176

Open
RequescoS opened this issue Mar 1, 2024 · 0 comments
Open

[Proposal] getAssetSignatures method response schema #176

RequescoS opened this issue Mar 1, 2024 · 0 comments

Comments

@RequescoS
Copy link

RequescoS commented Mar 1, 2024

Hi guys! I'd like to discuss some insights regarding the getAssetSignatures methods within the DAS-API standard.
Currently, the method returns the following structure:

{
    "total": 2,
    "limit": 1000,
    "page": 1,
    "items": [
        [
            "5nLi8m72bU6PBcz4Xrk23P6KTGy9ufF92kZiQXjTv9ELgkUxrNaiCGhMF4vh6RAcisw9DEQWJt9ogM3G2uCuwwV7",
            "MintToCollectionV1"
        ],
        [
            "323Ag4J69gagBt3neUvajNauMydiXZTmXYSfdK5swWcK1iwCUypcXv45UFcy5PTt136G9gtQ45oyPJRs1f2zFZ3v",
            "Transfer"
        ]
    ]
}

I would like to draw your attention particularly to the structure of the items field. It is an array of arrays, each containing two string elements. This format may introduce several challenges for future use, support, and extension of this API method, specifically:

  1. The lack of field names within arrays complicates understanding the elements' meanings without additional documentation or context, potentially leading to misinterpretation and misuse.
  2. Relying on index-based data access in deserialized structures heightens the risk of errors, as it is easy to reference an incorrect index, leading to inaccurate data retrieval or runtime errors.
  3. Implementing data-driven algorithms becomes more complex and less intuitive due to the necessity of managing array indices, increasing the likelihood of mistakes.
  4. Extending the internal array structure poses various difficulties. For instance, adding a slot number to the inner array, alongside the transaction signature and instruction name (akin to the implementation in the getSignaturesForAddress method of solana-rpc), introduces type inconsistencies. While Rust can utilize a tuple (String, String, u64), Golang would require a [][]interface{}, necessitating type conversion from interface to string or uint64 before each element's usage. Moreover, even in Rust, handling a tuple (String, String, u64) is less clear and convenient than working with a dedicated data structure.

To address these issues, we propose an alternative data structure for the items field in the getAssetSignatures method. The following JSON schema demonstrates our suggestion, where each element of the items array is a separate structure:

{
	"total": 4,
	"limit": 4,
	"page": 4,
	"items": [
		{
			"signature": "bwXqHvK2ytieSpbDxdxyk9M3C6RX1jSRndkW9ZNxaMQRhPJKJFmSYgg1Qwe8vBuUV3WsvButeq4ivVCnaVdShXe",
			"instruction": "TestInstruction",
			"slot": 180
		},
		{
			"signature": "61tZnQLFyedD9WJmdMAJ1jWCapo72paE2A7eY5mvaFbQmg85QSBiwg69Ze4a7Di8HBZbamcvnvLJaFjCoT5vnEQi",
			"instruction": "TestInstruction",
			"slot": 182
		},
		{
			"signature": "4MagGFKHJPsPTxWeyPEE6n8ftkHcDrFHLHnbq5Mg17iMe2SawrVVtqY5TBtyKhPTcP6oRvspmcNgMCJHGKshRbyt",
			"instruction": "TestInstruction",
			"slot": 184
		},
		{
			"signature": "3CiRao3MpyFeNxtsw8KE2LYirFfXKNFRmqNb3tiUNRA9hkPip63Hze9Am19imazR4rQVckLNzExHdoyFhyXjWiu3",
			"instruction": "TestInstruction",
			"slot": 186
		},
	]
}

This approach addresses all previously mentioned issues. I invite you to discuss the merits and potential drawbacks of this proposal. Thanks!

@RequescoS RequescoS changed the title [Proposal] getSignaturesForAddress method response schema [Proposal] getAssetSignatures method response schema Mar 4, 2024
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

No branches or pull requests

1 participant