// Quick way to parse the denom from the json
// without worrying on the different message types
// that the unsigned may have. In the future this
// might be improved parsing the right msg type
Quick way to parse the denom from the json
without worrying on the different message types
that the unsigned may have. In the future this
might be improved parsing the right msg type
// Quick way to parse the denom from the json // without worrying on the different message types // that the unsigned may have . In the future this // might be improved parsing the right msg type
func parseDenomFromJson(tx []byte) (string, error) {
	var anyJson map[string]interface{}
	err := json.Unmarshal(tx, &anyJson)
	if err != nil {
		return "", fmt.Errorf("cannot parse tx json, error %s", err)
	}
	if anyJson["auth_info"] != nil {
		auth, ok := anyJson["auth_info"].(map[string]interface{})
		if ok {
			if auth["fee"] != nil {
				fee, ok := auth["fee"].(map[string]interface{})
				if ok {
					if fee["amount"] != nil {
						value, ok := fee["amount"].([]interface{})
						if ok {
							if len(value) >= 1 {
								firstValue, ok := value[0].(map[string]interface{})
								if ok {
									if firstValue["denom"] != nil {
										return firstValue["denom"].(string), nil
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return "", fmt.Errorf("cannot parse json, cannot find denom value")
}
func parseDenomFromJson ( tx [ ] byte ) ( string , error ) { var anyJson map [ string ] interface { } err := json . Unmarshal ( tx , & anyJson ) if err != nil { return " " , fmt . Errorf ( " " , err ) } if anyJson [ " " ] != nil { auth , ok := anyJson [ " " ] . ( map [ string ] interface { } ) if ok { if auth [ " " ] != nil { fee , ok := auth [ " " ] . ( map [ string ] interface { } ) if ok { if fee [ " " ] != nil { value , ok := fee [ " " ] . ( [ ] interface { } ) if ok { if len ( value ) >= 1 { firstValue , ok := value [ 0 ] . ( map [ string ] interface { } ) if ok { if firstValue [ " " ] != nil { return firstValue [ " " ] . ( string ) , nil } } } } } } } } } return " " , fmt . Errorf ( " " ) }
Quick way to parse the denom from the json
without worrying on the different message types
that the unsigned may have.
Quick way to parse the denom from the json without worrying on the different message types that the unsigned may have .
// in case cannot find the denom value in the json, return an error