diff --git a/venus-devtool/api-gen/common/common.go b/venus-devtool/api-gen/common/common.go index b4e1102c9e..fa081a6722 100644 --- a/venus-devtool/api-gen/common/common.go +++ b/venus-devtool/api-gen/common/common.go @@ -34,6 +34,7 @@ func init() { RPCMeta: util.RPCMeta{ Version: 0, MethodNamespace: "Message", + ApiNamespace: "messager.IMessager", }, }, util.APIMeta{ @@ -43,7 +44,8 @@ func init() { IncludeAll: true, }, RPCMeta: util.RPCMeta{ - Version: 0, + Version: 0, + ApiNamespace: "wallet.IFullAPI", }, }, util.APIMeta{ @@ -55,6 +57,7 @@ func init() { RPCMeta: util.RPCMeta{ Version: 2, MethodNamespace: "Gateway", + ApiNamespace: "gateway.IGateway", }, }, util.APIMeta{ @@ -66,6 +69,7 @@ func init() { RPCMeta: util.RPCMeta{ Version: 1, MethodNamespace: "Gateway", + ApiNamespace: "gateway.IGateway", }, }, util.APIMeta{ @@ -77,6 +81,7 @@ func init() { RPCMeta: util.RPCMeta{ Version: 0, MethodNamespace: "Gateway", + ApiNamespace: "gateway.IGateway", }, }, util.APIMeta{ @@ -88,6 +93,7 @@ func init() { RPCMeta: util.RPCMeta{ Version: 0, MethodNamespace: "VENUS_MARKET", + ApiNamespace: "v1.IMarket", }, }, util.APIMeta{ @@ -99,6 +105,7 @@ func init() { RPCMeta: util.RPCMeta{ Version: 1, MethodNamespace: "VENUS_MARKET", + ApiNamespace: "v1.IMarket", }, }, util.APIMeta{ @@ -110,6 +117,7 @@ func init() { RPCMeta: util.RPCMeta{ Version: 0, MethodNamespace: "VENUS_MARKET_CLIENT", + ApiNamespace: "client.IMarketClient", }, }, ) diff --git a/venus-devtool/api-gen/doc_gen.go b/venus-devtool/api-gen/doc_gen.go index 18f1a75f47..bd0999c033 100644 --- a/venus-devtool/api-gen/doc_gen.go +++ b/venus-devtool/api-gen/doc_gen.go @@ -156,21 +156,25 @@ func writeAPIInfo(astMeta *util.ASTMeta, rpcMeta util.RPCMeta, groups []MethodGr if methNs == "" { methNs = "Filecoin" } + + apiNs := rpcMeta.ApiNamespace + tmpl, err := template.New("curl").Parse(`# Sample code of curl {{ .StartBash }} # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v{{ .APIVersion }} -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "{{ .Namespace }}.", "params": , "id": 0}' +curl http://:/rpc/v{{ .APIVersion }} -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: {{ .APINamespace }}" -H "Authorization: Bearer " -d '{"method": "{{ .Namespace }}.", "params": , "id": 0}' {{ .EndBash }} `) if err != nil { return fmt.Errorf("parse template: %w", err) } err = tmpl.Execute(buf, map[string]interface{}{ - "APIVersion": rpcMeta.Version, - "Namespace": methNs, - "StartBash": "```bash", - "EndBash": "```", + "APIVersion": rpcMeta.Version, + "Namespace": methNs, + "APINamespace": apiNs, + "StartBash": "```bash", + "EndBash": "```", }) if err != nil { return fmt.Errorf("exec curl template: %w", err) diff --git a/venus-devtool/util/api_meta.go b/venus-devtool/util/api_meta.go index 28bdeb223d..ef1399a381 100644 --- a/venus-devtool/util/api_meta.go +++ b/venus-devtool/util/api_meta.go @@ -35,7 +35,8 @@ var ChainAPIPairs = []struct { IncludeAll: true, }, RPCMeta: RPCMeta{ - Version: 0, + Version: 0, + ApiNamespace: "v1.FullNode", }, }, }, @@ -55,7 +56,8 @@ var ChainAPIPairs = []struct { IncludeAll: true, }, RPCMeta: RPCMeta{ - Version: 1, + Version: 1, + ApiNamespace: "v1.FullNode", }, }, }, @@ -67,6 +69,7 @@ type RPCMeta struct { Version uint32 Namespace string MethodNamespace string + ApiNamespace string } type APIMeta struct { diff --git a/venus-shared/api/chain/v0/method.md b/venus-shared/api/chain/v0/method.md index 844a36ae2b..256c7df767 100644 --- a/venus-shared/api/chain/v0/method.md +++ b/venus-shared/api/chain/v0/method.md @@ -2,7 +2,7 @@ ```bash # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "Filecoin.", "params": , "id": 0}' +curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: v1.FullNode" -H "Authorization: Bearer " -d '{"method": "Filecoin.", "params": , "id": 0}' ``` # Groups diff --git a/venus-shared/api/chain/v1/method.md b/venus-shared/api/chain/v1/method.md index 143f53a90e..99428414e4 100644 --- a/venus-shared/api/chain/v1/method.md +++ b/venus-shared/api/chain/v1/method.md @@ -2,7 +2,7 @@ ```bash # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "Filecoin.", "params": , "id": 0}' +curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: v1.FullNode" -H "Authorization: Bearer " -d '{"method": "Filecoin.", "params": , "id": 0}' ``` # Groups diff --git a/venus-shared/api/gateway/v0/method.md b/venus-shared/api/gateway/v0/method.md index fa2ffa9fe9..09dcade456 100644 --- a/venus-shared/api/gateway/v0/method.md +++ b/venus-shared/api/gateway/v0/method.md @@ -2,7 +2,7 @@ ```bash # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "Gateway.", "params": , "id": 0}' +curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: gateway.IGateway" -H "Authorization: Bearer " -d '{"method": "Gateway.", "params": , "id": 0}' ``` # Groups diff --git a/venus-shared/api/gateway/v1/method.md b/venus-shared/api/gateway/v1/method.md index 32acd22260..a8211bdba4 100644 --- a/venus-shared/api/gateway/v1/method.md +++ b/venus-shared/api/gateway/v1/method.md @@ -2,7 +2,7 @@ ```bash # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "Gateway.", "params": , "id": 0}' +curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: gateway.IGateway" -H "Authorization: Bearer " -d '{"method": "Gateway.", "params": , "id": 0}' ``` # Groups diff --git a/venus-shared/api/gateway/v2/method.md b/venus-shared/api/gateway/v2/method.md index fc7ae223a7..40ec1e852e 100644 --- a/venus-shared/api/gateway/v2/method.md +++ b/venus-shared/api/gateway/v2/method.md @@ -2,7 +2,7 @@ ```bash # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v2 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "Gateway.", "params": , "id": 0}' +curl http://:/rpc/v2 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: gateway.IGateway" -H "Authorization: Bearer " -d '{"method": "Gateway.", "params": , "id": 0}' ``` # Groups diff --git a/venus-shared/api/market/client/method.md b/venus-shared/api/market/client/method.md index c59105831d..4a44e5047b 100644 --- a/venus-shared/api/market/client/method.md +++ b/venus-shared/api/market/client/method.md @@ -2,7 +2,7 @@ ```bash # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "VENUS_MARKET_CLIENT.", "params": , "id": 0}' +curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: client.IMarketClient" -H "Authorization: Bearer " -d '{"method": "VENUS_MARKET_CLIENT.", "params": , "id": 0}' ``` # Groups diff --git a/venus-shared/api/market/v0/method.md b/venus-shared/api/market/v0/method.md index 76cd317e58..1e93505f2d 100644 --- a/venus-shared/api/market/v0/method.md +++ b/venus-shared/api/market/v0/method.md @@ -2,7 +2,7 @@ ```bash # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "VENUS_MARKET.", "params": , "id": 0}' +curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: v1.IMarket" -H "Authorization: Bearer " -d '{"method": "VENUS_MARKET.", "params": , "id": 0}' ``` # Groups diff --git a/venus-shared/api/market/v1/method.md b/venus-shared/api/market/v1/method.md index 4f6e9aef24..9b1d8929af 100644 --- a/venus-shared/api/market/v1/method.md +++ b/venus-shared/api/market/v1/method.md @@ -2,7 +2,7 @@ ```bash # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "VENUS_MARKET.", "params": , "id": 0}' +curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: v1.IMarket" -H "Authorization: Bearer " -d '{"method": "VENUS_MARKET.", "params": , "id": 0}' ``` # Groups diff --git a/venus-shared/api/messager/method.md b/venus-shared/api/messager/method.md index 34acbbfb35..61b44ce211 100644 --- a/venus-shared/api/messager/method.md +++ b/venus-shared/api/messager/method.md @@ -2,7 +2,7 @@ ```bash # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "Message.", "params": , "id": 0}' +curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: messager.IMessager" -H "Authorization: Bearer " -d '{"method": "Message.", "params": , "id": 0}' ``` # Groups diff --git a/venus-shared/api/wallet/method.md b/venus-shared/api/wallet/method.md index 99982e56cc..835125951d 100644 --- a/venus-shared/api/wallet/method.md +++ b/venus-shared/api/wallet/method.md @@ -2,7 +2,7 @@ ```bash # corresponding to the value of Inputs Tag of each API -curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"method": "Filecoin.", "params": , "id": 0}' +curl http://:/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: wallet.IFullAPI" -H "Authorization: Bearer " -d '{"method": "Filecoin.", "params": , "id": 0}' ``` # Groups