desmos-labs/dpm

Implement profile input validation

Closed this issue · 0 comments

Currently when saving a profile no input validation is performed on the values inserted by the user. This can make the transaction fail with different errors (eg. invalid DTag, invalid Bio, etc). To solve this we can:

  1. Download the current x/profiles parameters stored on chain
  2. Use the downloaded parameters as references to implement input validation.

To get the parameters the following GraphQL query can be used:

query Params {
  profiles_params {
    params
  }
}

Here is an example response:

{
  "data": {
    "profiles_params": [
      {
        "params": {
          "bio": {
            "max_length": "1000"
          },
          "dtag": {
            "reg_ex": "^[A-Za-z0-9_]+$",
            "max_length": "30",
            "min_length": "3"
          },
          "oracle": {
            "ask_count": 5,
            "min_count": 3,
            "script_id": 32,
            "fee_amount": [],
            "execute_gas": 200000,
            "prepare_gas": 50000
          },
          "nickname": {
            "max_length": "1000",
            "min_length": "2"
          }
        }
      }
    ]
  }
}

You can only consider the bio, dtag and nickname fields as they describe the limitations applied to profiles.