Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
feat(BUX-156): refactor arc_query_tx (a little)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszos4chain committed Aug 8, 2023
1 parent 2526c96 commit 6ffa739
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions broadcast/internal/arc/arc_query_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package arc

import (
"context"
"encoding/json"
"errors"
"io"

"github.com/bitcoin-sv/go-broadcast-client/broadcast"
arc_utils "github.com/bitcoin-sv/go-broadcast-client/broadcast/internal/arc/utils"
"github.com/bitcoin-sv/go-broadcast-client/broadcast/internal/httpclient"
)

Expand Down Expand Up @@ -48,20 +47,10 @@ func queryTransaction(ctx context.Context, arc *ArcClient, txHash string) (*broa
return nil, err
}

model, err := decodeQueryTxBody(resp.Body)
if err != nil {
return nil, err
}

return model, nil
}

func decodeQueryTxBody(body io.ReadCloser) (*broadcast.QueryTxResponse, error) {
model := broadcast.QueryTxResponse{}
err := json.NewDecoder(body).Decode(&model)

err = arc_utils.DecodeResponseBody(resp.Body, &model)
if err != nil {
return nil, broadcast.ErrUnableToDecodeResponse
return nil, err
}

return &model, nil
Expand Down

0 comments on commit 6ffa739

Please sign in to comment.