fix validation, fix incorrect schemas

This commit is contained in:
Victor Oliva
2025-11-15 08:58:26 -03:00
parent fc04a6441a
commit ffb630d6b1
3 changed files with 31 additions and 40 deletions

View File

@@ -2,13 +2,6 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "chain_getBlockHash params",
"oneOf": [
{
"type": "object",
"description": "{} or { blockNumber }.",
"maxProperties": 1,
"additionalProperties": false,
"properties": { "blockNumber": { "type": "number" } }
},
{
"type": "array",
"description": "[] or [blockNumber].",

View File

@@ -2,20 +2,6 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "state_getReadProof params",
"oneOf": [
{
"type": "object",
"description": "{ keys } or { keys, at }.",
"required": ["keys"],
"additionalProperties": false,
"properties": {
"keys": {
"type": "array",
"description": "Storage keys to prove.",
"items": { "$ref": "./common.json#/$defs/hex" }
},
"at": { "$ref": "./common.json#/$defs/hex" }
}
},
{
"type": "array",
"description": "[keys] or [keys, at].",
@@ -29,6 +15,21 @@
},
{ "$ref": "./common.json#/$defs/hex" }
]
},
{
"type": "object",
"description": "{ keys } or { keys, at } or { keys, hash }.",
"required": ["keys"],
"additionalProperties": false,
"properties": {
"keys": {
"type": "array",
"description": "Storage keys to prove.",
"items": { "$ref": "./common.json#/$defs/hex" }
},
"at": { "$ref": "./common.json#/$defs/hex" },
"hash": { "$ref": "./common.json#/$defs/hex" }
}
}
]
}

View File

@@ -27,7 +27,7 @@ export const RpcCalls = withSubscribe(
const methods = useStateObservable(chainRpcMethods$)
const setSchema = useRef<((method: string | null) => void) | null>(null)
const [method, _setMethod] = useState<string | null>(null)
const [params, setParams] = useState<string>("{\n \n}")
const [params, setParams] = useState<string>("[\n \n]")
const theme = useTheme()
const setMethod = (method: string | null) => {
@@ -77,28 +77,25 @@ export const RpcCalls = withSubscribe(
if (!model) return
setSchema.current = (method) => {
monaco.languages.json.jsonDefaults.setDiagnosticsOptions(
method
? {
validate: true,
schemas: [
{
uri: `${SCHEMA_URL}/rpc_schemas/${method}.json`,
fileMatch: [model.uri.toString()],
},
],
enableSchemaRequest: true,
schemaRequest: "ignore",
}
: {
validate: false,
},
)
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
validate: true,
schemas: method
? [
{
uri: `${SCHEMA_URL}/rpc_schemas/${method}.json`,
fileMatch: [model.uri.toString()],
},
]
: [],
enableSchemaRequest: true,
schemaRequest: "ignore",
})
monaco.languages.json.jsonDefaults.setModeConfiguration(
method
? { completionItems: true }
? { completionItems: true, diagnostics: true }
: {
completionItems: false,
diagnostics: true,
},
)
}