diff --git a/client/block_info.go b/client/block_info.go index 996e937..3cc614c 100644 --- a/client/block_info.go +++ b/client/block_info.go @@ -67,3 +67,25 @@ func (c *Client) BlockInfo(blockHeight int64) (*BlockInfo, error) { return &blockInfo, nil } + +func (c *Client) LatestBlock() (*BlockInfo, error) { + req, err := http.NewRequest("GET", fmt.Sprintf("%s/blocks/latest", c.BaseUrl), nil) + if err != nil { + return nil, err + } + + req.Header.Set("Content-Type", "application/json") + + var responseBody string + blockInfo := BlockInfo{} + if err := c.sendRequest(req, &responseBody); err != nil { + return nil, err + } + + if err := json.Unmarshal([]byte(responseBody), &blockInfo); err != nil { + fmt.Println("Cannot unmarshal JSON: ", err) + os.Exit(1) + } + + return &blockInfo, nil +} diff --git a/client/transactions.go b/client/transactions.go index e19abe4..795f1a5 100644 --- a/client/transactions.go +++ b/client/transactions.go @@ -32,6 +32,7 @@ func (c *Client) SubmitTx(cbor string) (models.BasicResponse, error) { } defer resp.Body.Close() var submitTx models.BasicResponse + err = json.NewDecoder(resp.Body).Decode(&submitTx) if err != nil { return models.BasicResponse{}, err diff --git a/models/addresses.go b/models/addresses.go index 5713971..d4b1b5b 100644 --- a/models/addresses.go +++ b/models/addresses.go @@ -81,7 +81,7 @@ type Utxo struct { ReferenceScript ReferenceScript `json:"reference_script"` TxHash string `json:"tx_hash"` Slot int64 `json:"slot"` - TxOutCbor string `json:"tx_out_cbor"` + TxOutCbor string `json:"txout_cbor"` } type ReferenceScript struct { diff --git a/models/epochs.go b/models/epochs.go index 85bd62e..e14b8d8 100644 --- a/models/epochs.go +++ b/models/epochs.go @@ -3,11 +3,11 @@ package models import "github.com/maestro-org/go-sdk/utils" type Epoch struct { - BlkCount int `json:"blk_count"` - EpochNo int `json:"epoch_no"` - Fees int `json:"fees"` - StartTime int `json:"start_time"` - TxCount int `json:"tx_count"` + BlkCount int `json:"blk_count"` + EpochNo int `json:"epoch_no"` + Fees string `json:"fees"` + StartTime int `json:"start_time"` + TxCount int `json:"tx_count"` } type EpochResp struct {