caivega / ipfslib

Other
2 stars 1 forks source link

[enhancement] - rpc请求及返回格式批处理化[数组化] #163

Open caivega opened 3 years ago

caivega commented 3 years ago

原则:

jt_version

request:

  1. (请求参数为空数组, 等同于[{"format":"text"}])
  2. string(format) (请求数组项为string, 等同于{"format":string},默认属性为format)
  3. object (请求数组项为object)
    • format: string["text", "json"](支持的为string类型,内容为"text"及"json")

注:()内为注释,下同

jt_createWallet

request:

  1. string(type)
  2. object
    • type string["ecdsa", "ed25519", "sm2"]

jt_createAccount

request:

  1. string(nick, type("ecdsa"))
  2. object
    • nick string(alphas[a-zA-Z], numbers[0-9], chinese characters[\u4e00-\u9fa5] and underscores[_])(0,256]
    • type string["ecdsa", "ed25519", "sm2"]

jt_getAccount

request:

  1. string(address)
  2. object
    • address[string(account)]
    • currency[string(currency)]
    • issuer[string(account)]
    • ledger["validated", "current"]

jt_accounts

request:

  1. [](all nick)
  2. string(nick)
  3. object
    • nick

jt_getCurrency

request:

  1. string(currency)
  2. object
    • currency[string(currency)]
    • issuer(string(account)]
    • ledger

jt_blockNumber

request:

  1. []
  2. string(type, "number")
  3. object
    • type["number", "info"]

jt_getBalance

request:

  1. string(address)
  2. object
    • address[string(account)]
    • currency[string(currency)]
    • issuer[string(account)]
    • ledger["validated", "current"]

jt_getBlockByHash

request:

  1. string(hash)
  2. object
    • hash[string(half_sha512)]
    • full[boolean]
    • ledger

jt_getBlockByNumber

request:

  1. string(number)
  2. object
    • number(string)
    • full(boolean)
    • ledger

jt_getBlockTransactionCountByHash

request:

  1. string(hash)
  2. object
    • hash
    • ledger

jt_getBlockTransactionCountByNumber

request:

  1. string(number)
  2. object
    • number(string)
    • ledger

jt_getTransactionCount

request:

  1. string(address)
  2. object
    • address
    • ledger

jt_getTransactionByHash

request:

  1. string(hash)
  2. object
    • hash
    • full[boolean]
    • ledger

jt_getTransactionByIndex

request:

  1. object
    • address
    • index, sequence[integer(sequence)]
    • full[boolean]
    • ledger

jt_getTransactionByBlockHashAndIndex

request:

  1. object
    • hash
    • index[integer]
    • full[boolean]
    • ledger

jt_getTransactionByBlockNumberAndIndex

request:

  1. object
    • number[string]
    • index[integer]
    • full[boolean]
    • ledger

jt_getTransactionReceipt

request:

  1. object
    • hash
    • ledger

jt_sign

request:

  1. object
    • from, address[string(account)]
    • secret[string(secret)]
    • message[string(hex)]

jt_sendTransaction

jt_signTransaction

request:

  1. object

    • type["Payment", "IssueCoin"]

    • from, address[string(account)]

    • secret[string(secret)]

    • to[string(account)]

    • sequence[integer(sequence)]

    • fee[string]

    • flags[integer]

    • memos[array]

    • value[string(amount)]

    • name[string]

    • symbol[string]

    • decimals[string]

    • total_supply[string]

    • local[boolean]

jt_sendRawTransaction

request:

  1. string(blob)
  2. object
    • blob[string]

jt_batch

{"jsonrpc":"2.0","method":"jt_batch","params":[
  {
    "jsonrpc":"2.0","method":"jt_version","params":[]
  },
  {
    "jsonrpc":"2.0","method":"jt_blockNumber","params":[]
  }
],"id":1}
foreso-GitHub commented 3 years ago

jt_createWallet的返回结果,第2层result仍然是数组,,似乎没有必要。

{
    "jsonrpc": "2.0",
    "method": "jt_createWallet",
    "params": [
        {
            "type": "Ed25519"
        }
    ],
    "id": 1
}

{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "result": [
                {
                    "address": "jsAtX6G3bryNau1b7nLepK486AnrtPH8Cr",
                    "secret": "sEd7wfmvUUJJVZtbQLYNUZEB3u6CgwN",
                    "type": "Ed25519"
                }
            ]
        }
    ]
}

建议改成:

{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "result": {
                    "address": "jsAtX6G3bryNau1b7nLepK486AnrtPH8Cr",
                    "secret": "sEd7wfmvUUJJVZtbQLYNUZEB3u6CgwN",
                    "type": "Ed25519"
                }
        }
    ]
}
foreso-GitHub commented 3 years ago

补充,jt_createAccount有如上同样的问题

caivega commented 3 years ago

补充,jt_createAccount有如上同样的问题

已修复,已更新,下一个build可以验证下

foreso-GitHub commented 3 years ago

补充,jt_createAccount有如上同样的问题

已修复,已更新,下一个build可以验证下

版本v0.5.4-dev-20210202-95e57512b464d7595068a4dda3e2fe1cfae85d1b中已经修复。