Skip to content

Commit

Permalink
Merge pull request #45 from Salvionied/main
Browse files Browse the repository at this point in the history
fix: tweak some issues
  • Loading branch information
Vardominator authored Apr 6, 2024
2 parents 2148ef5 + 48eb310 commit b7b8a7e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
22 changes: 22 additions & 0 deletions client/block_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions client/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion models/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions models/epochs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b7b8a7e

Please sign in to comment.