toncenter / tonweb

JavaScript SDK for TON (The Open Network)
MIT License
533 stars 152 forks source link

Fix to make tonweb compatible with Python module "ton-http-api" #117

Open Stanislav-Povolotsky opened 11 months ago

Stanislav-Povolotsky commented 11 months ago

According to the TonRequestJsonRPC scheme, the "id" field must have 'string' type.

If the "id" field is a number, the Python ton-http-api module returns the following error: "error": "Validation error: [{'type': 'string_type', 'loc': ('body', 'id'), 'msg': 'Input should be a valid string'

The TonCenter endpoint (https://toncenter.com/api/v2/jsonRPC) works well because the "id" value is converted to a string somewhere on its way to the server. It also has string type in the response.

TonRequestJsonRPC scheme from https://toncenter.com/api/v2/openapi.json

"TonRequestJsonRPC": {
    "title": "TonRequestJsonRPC",
    "required": [
        "method"
    ],
    "type": "object",
    "properties": {
        "method": {
            "title": "Method",
            "type": "string"
        },
        "params": {
            "title": "Params",
            "type": "object",
            "default": {}
        },
        "id": {
            "title": "Id",
            "type": "string"
        },
        "jsonrpc": {
            "title": "Jsonrpc",
            "type": "string"
        }
    }
}
TheSmartnik commented 9 months ago

Thanks! Had the same problem. The fix is working