File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,14 +46,18 @@ func (r *APIResponse[T]) UnmarshalJSON(data []byte) error {
4646
4747 // When status is "ok", "response" contains "type" and "data"
4848 r .Type = string (parsed .GetStringBytes ("response" , "type" ))
49- responseData := parsed .GetStringBytes ("response" , "data" )
49+
50+ // GetStringBytes() only works on string, we should do a Get instead
51+ responseData := parsed .Get ("response" , "data" )
5052
5153 if responseData == nil {
5254 return fmt .Errorf ("missing response.data field in successful response" )
5355 }
5456
57+ b := responseData .MarshalTo (nil )
58+
5559 // Use fastjson's built-in unmarshaling if possible, fallback to json.Unmarshal
56- if err := json .Unmarshal (responseData , & r .Data ); err != nil {
60+ if err := json .Unmarshal (b , & r .Data ); err != nil {
5761 return fmt .Errorf ("failed to unmarshal response data: %w" , err )
5862 }
5963
Original file line number Diff line number Diff line change @@ -70,17 +70,19 @@ func (e *Exchange) postAction(
7070 "signature" : signature ,
7171 }
7272
73- // Handle vault address based on action type
74- if actionMap , ok := action .(map [string ]any ); ok {
75- if actionMap ["type" ] != "usdClassTransfer" {
76- payload ["vaultAddress" ] = e .vault
73+ if e .vault != "" {
74+ // Handle vault address based on action type
75+ if actionMap , ok := action .(map [string ]any ); ok {
76+ if actionMap ["type" ] != "usdClassTransfer" {
77+ payload ["vaultAddress" ] = e .vault
78+ } else {
79+ payload ["vaultAddress" ] = nil
80+ }
7781 } else {
78- payload ["vaultAddress" ] = nil
82+ // For struct types, we need to use reflection or type assertion
83+ // For now, assume it's not usdClassTransfer
84+ payload ["vaultAddress" ] = e .vault
7985 }
80- } else {
81- // For struct types, we need to use reflection or type assertion
82- // For now, assume it's not usdClassTransfer
83- payload ["vaultAddress" ] = e .vault
8486 }
8587
8688 // Add expiration time if set
Original file line number Diff line number Diff line change 11package hyperliquid
22
33import (
4+ "encoding/json"
45 "fmt"
56)
67
@@ -39,7 +40,12 @@ type OrderStatusFilled struct {
3940type OrderStatus struct {
4041 Resting * OrderStatusResting `json:"resting,omitempty"`
4142 Filled * OrderStatusFilled `json:"filled,omitempty"`
42- Error * error `json:"error,omitempty"`
43+ Error * string `json:"error,omitempty"`
44+ }
45+
46+ func (s * OrderStatus ) String () string {
47+ data , _ := json .Marshal (s )
48+ return string (data )
4349}
4450
4551type OrderResponse struct {
You can’t perform that action at this time.
0 commit comments