Skip to content

Commit

Permalink
client: Send empty maps instead of nil.
Browse files Browse the repository at this point in the history
  • Loading branch information
jholdstock committed Oct 16, 2024
1 parent caf02de commit fb693ce
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ func (c *Client) FeeAddress(ctx context.Context, req types.FeeAddressRequest,
func (c *Client) PayFee(ctx context.Context, req types.PayFeeRequest,
commitmentAddr stdaddr.Address) (*types.PayFeeResponse, error) {

// TSpendPolicy and TreasuryPolicy are optional but must be an empty map
// rather than nil.
if req.TSpendPolicy == nil {
req.TSpendPolicy = map[string]string{}
}
if req.TreasuryPolicy == nil {
req.TreasuryPolicy = map[string]string{}
}

requestBody, err := json.Marshal(req)
if err != nil {
return nil, err
Expand Down Expand Up @@ -110,6 +119,15 @@ func (c *Client) TicketStatus(ctx context.Context, req types.TicketStatusRequest
func (c *Client) SetVoteChoices(ctx context.Context, req types.SetVoteChoicesRequest,
commitmentAddr stdaddr.Address) (*types.SetVoteChoicesResponse, error) {

// TSpendPolicy and TreasuryPolicy are optional but must be an empty map
// rather than nil.
if req.TSpendPolicy == nil {
req.TSpendPolicy = map[string]string{}
}
if req.TreasuryPolicy == nil {
req.TreasuryPolicy = map[string]string{}
}

requestBody, err := json.Marshal(req)
if err != nil {
return nil, err
Expand Down

0 comments on commit fb693ce

Please sign in to comment.