Some checks are pending
docker-build-cometbft / vars (push) Waiting to run
docker-build-cometbft / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-cometbft / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-cometbft / merge-images (push) Blocked by required conditions
docker-build-e2e-node / vars (push) Waiting to run
docker-build-e2e-node / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-e2e-node / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-e2e-node / merge-images (push) Blocked by required conditions
46 lines
831 B
Go
46 lines
831 B
Go
package client
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
"reflect"
|
|
|
|
cmtjson "git.cw.tr/mukan-network/mukan-consensus/libs/json"
|
|
)
|
|
|
|
func argsToURLValues(args map[string]interface{}) (url.Values, error) {
|
|
values := make(url.Values)
|
|
if len(args) == 0 {
|
|
return values, nil
|
|
}
|
|
|
|
err := argsToJSON(args)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
for key, val := range args {
|
|
values.Set(key, val.(string))
|
|
}
|
|
|
|
return values, nil
|
|
}
|
|
|
|
func argsToJSON(args map[string]interface{}) error {
|
|
for k, v := range args {
|
|
rt := reflect.TypeOf(v)
|
|
isByteSlice := rt.Kind() == reflect.Slice && rt.Elem().Kind() == reflect.Uint8
|
|
if isByteSlice {
|
|
bytes := reflect.ValueOf(v).Bytes()
|
|
args[k] = fmt.Sprintf("0x%X", bytes)
|
|
continue
|
|
}
|
|
|
|
data, err := cmtjson.Marshal(v)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
args[k] = string(data)
|
|
}
|
|
return nil
|
|
}
|