-
Notifications
You must be signed in to change notification settings - Fork 51
Description
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:
- The lack of field names within arrays complicates understanding the elements' meanings without additional documentation or context, potentially leading to misinterpretation and misuse.
- 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.
- Implementing data-driven algorithms becomes more complex and less intuitive due to the necessity of managing array indices, increasing the likelihood of mistakes.
- 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
getSignaturesForAddressmethod 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!