(pType string, pValue string)
| 173 | } |
| 174 | |
| 175 | func parseRawParamValue(pType string, pValue string) (interface{}, error) { |
| 176 | switch strings.ToLower(pType) { |
| 177 | case PARAM_TYPE_BYTE_ARRAY: |
| 178 | value, err := hex.DecodeString(pValue) |
| 179 | if err != nil { |
| 180 | return nil, fmt.Errorf("parse byte array param:%s error:%s", pValue, err) |
| 181 | } |
| 182 | return value, nil |
| 183 | case PARAM_TYPE_STRING: |
| 184 | return pValue, nil |
| 185 | case PARAM_TYPE_INTEGER: |
| 186 | if pValue == "" { |
| 187 | return nil, fmt.Errorf("invalid integer") |
| 188 | } |
| 189 | value, err := strconv.ParseInt(pValue, 10, 64) |
| 190 | if err != nil { |
| 191 | return nil, fmt.Errorf("parse integer param:%s error:%s", pValue, err) |
| 192 | } |
| 193 | return value, nil |
| 194 | case PARAM_TYPE_BOOLEAN: |
| 195 | switch strings.ToLower(pValue) { |
| 196 | case "true": |
| 197 | return true, nil |
| 198 | case "false": |
| 199 | return false, nil |
| 200 | default: |
| 201 | return nil, fmt.Errorf("parse boolean param:%s failed", pValue) |
| 202 | } |
| 203 | case PARAM_TYPE_ADDRESS: |
| 204 | return common.AddressFromBase58(pValue) |
| 205 | |
| 206 | default: |
| 207 | return nil, fmt.Errorf("unspport param type:%s", pType) |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | //ParseReturnValue return the value of rawReturnTypeStr type. |
| 212 | //Return type can be: bytearray, string, int, bool. |
no test coverage detected