MystenLabs / sui

Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by the Move programming language
https://sui.io
Apache License 2.0
6.22k stars 11.2k forks source link

Update API docs with full type definition #3877

Closed 666lcz closed 2 years ago

666lcz commented 2 years ago

Our API docs (and in particular to the type definitions of key response types like SuiEventEnvelope) are hard to discover in our current docs site. You will only see SuiEventEnvelope if you happen to click on sui_subscribeEvent, and even then you will not see the full type definition. I think our docs should show type definitions in addition to API functions.

context: https://mysten-labs.slack.com/archives/C03GYL579PD/p1659991524419939

patrickkuo commented 2 years ago

There are on going work to improve the navigation of the doc, see https://github.com/MystenLabs/sui/issues/1362

also cc @Clay-Mysten

Clay-Mysten commented 2 years ago

Also, I think there is work here to expose the full type definition as requested by @sblackshear . Adding @Jibz1 for help.

Clay-Mysten commented 2 years ago

@patrickkuo says we can also generate the curl commands now shown in our docs. Is this possible, @Jibz1 ? Thanks!

Clay-Mysten commented 2 years ago

As well as include some boiler plate text to make requests and responses valid. @patrickkuo can explain more.

patrickkuo commented 2 years ago

We can resolve the $ref path to get the full type definition. e.g. definition for EventEnvelopehttps://github.com/MystenLabs/sui/blob/db724585021b554742158b44e74e0646fccf6651/crates/sui-open-rpc/spec/openrpc.json#L2248-L2281

Regarding the request/response boilerplate code, I am not sure if this is the right issue to mention that, I will do it here anyway 😅: the request and response in our current api doc is not a valid JSON-RPC request/response. using sui_batchTransaction as an example, the request should looks like

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "sui_batchTransaction",
  "params": [
    "0x76a04053bda0a88bda5177b86a15c3b29f559873",
    [
      {
        "moveCallRequestParams": {
          "arguments": [
            "Example NFT",
            "An NFT created by the Sui Command Line Tool",
            "ipfs://bafkreibngqhl3gaa7daob4i2vccziay2jjlp435cf66vhono7nrvww53ty"
          ],
          "function": "mint",
          "module": "devnet_nft",
          "packageObjectId": "0x0000000000000000000000000000000000000002",
          "typeArguments": []
        }
      },
      {
        "transferObjectRequestParams": {
          "objectId": "0x1f6de831e52bfb76e51cca8b4e9016838657edfa",
          "recipient": "0xcb481232299cd5743151ac4b2d63ae198e7bb0a9"
        }
      }
    ],
    "0x011f28e473c95f4013d7d53ec5fbc3b42df8ed10",
    1000
  ]
}

we can use openrpc playground as an example of how to render the request/response

regarding curl command, I think it's nice to have, we can add it if we have bandwidth

Jibz1 commented 2 years ago

This is done

Clay-Mysten commented 2 years ago

This is done

Thanks, Godwin!