コード例 #1
0
def post_contract_v1() -> Tuple[str, int, Dict[str, str]]:
    if not flask.request.is_json:
        raise exceptions.BadRequest("Could not parse JSON")

    contract = flask.request.json

    try:
        _validate_sc_create_v1(contract)
        if contract.get("custom_indexes"):
            helpers.verify_custom_indexes_options(contract.get("custom_indexes"))
    except fastjsonschema.JsonSchemaException:
        raise exceptions.ValidationException("User input did not match JSON schema")

    return helpers.flask_http_response(202, smart_contracts.create_contract_v1(contract))
コード例 #2
0
def register_transaction_type_v1(**kwargs) -> Tuple[str, int, Dict[str, str]]:
    if not flask.request.is_json:
        raise exceptions.BadRequest("Could not parse JSON")

    content = flask.request.json

    try:
        _validate_create_txn_type_v1(content)
        if content.get("custom_indexes"):
            helpers.verify_custom_indexes_options(content["custom_indexes"])
    except fastjsonschema.JsonSchemaException as e:
        raise exceptions.ValidationException(str(e))

    transaction_types.register_transaction_type_v1(content)
    return helpers.flask_http_response(200, helpers.format_success(True))
コード例 #3
0
ファイル: helpers_utest.py プロジェクト: uningan/dragonchain
 def test_verify_custom_indexes_options_valid_text(self):
     helpers.verify_custom_indexes_options([{"type": "text", "field_name": "banana", "path": "ba/na/na"}])