Skip to content

Commit

Permalink
CNS-improve the verification for subsquid (#1021)
Browse files Browse the repository at this point in the history
* improve the verification

* bump target version
  • Loading branch information
omerlavanet authored Dec 5, 2023
1 parent 8d8d5f6 commit 64c17fa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cookbook/specs/spec_add_sqdsubgraph.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@
{
"name": "health",
"parse_directive": {
"function_template": "/subgraphs/name/1",
"function_template": "{\"query\":\"{\n pools(first: 5) {\n id\n poolid\n platform {\n id\n }\n name\n }\n}\"}",
"function_tag": "VERIFICATION",
"result_parsing": {
"parser_arg": [
"0",
"message"
"error"
],
"parser_func": "PARSE_CANONICAL"
},
"api_name": "/subgraphs/name/1"
},
"values": [
{
"expected_value": "Body is required"
"expected_value": "GraphQL server error (client error): Invalid subgraph name \"1\""
}
]
}
Expand Down
9 changes: 8 additions & 1 deletion protocol/chainlib/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ func (bcp *RestChainParser) GetUniqueName() string {

func (apip *RestChainParser) CraftMessage(parsing *spectypes.ParseDirective, connectionType string, craftData *CraftData, metadata []pairingtypes.Metadata) (ChainMessageForSend, error) {
if craftData != nil {
var data []byte = nil
urlPath := string(craftData.Data)
if craftData.ConnectionType == http.MethodPost {
// on post we need to send the data provided in the templace with the api as method
data = craftData.Data
urlPath = craftData.Path
}
// chain fetcher sends the replaced request inside data
chainMessage, err := apip.ParseMsg(string(craftData.Data), nil, craftData.ConnectionType, metadata, 0)
chainMessage, err := apip.ParseMsg(urlPath, data, craftData.ConnectionType, metadata, 0)
if err == nil {
chainMessage.AppendHeader(metadata)
}
Expand Down
5 changes: 3 additions & 2 deletions protocol/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ func ParseFromReply(rpcInput RPCInput, blockParser spectypes.BlockParser) (strin
}

if strings.Contains(response, "\"") {
response, err = strconv.Unquote(response)
responseUnquoted, err := strconv.Unquote(response)
if err != nil {
return "", err
return response, nil
}
return responseUnquoted, nil
}

return response, nil
Expand Down
2 changes: 1 addition & 1 deletion x/protocol/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
var _ paramtypes.ParamSet = (*Params)(nil)

const (
TARGET_VERSION = "0.30.2"
TARGET_VERSION = "0.30.3"
MIN_VERSION = "0.27.1"
)

Expand Down

0 comments on commit 64c17fa

Please sign in to comment.