diff --git a/client/txmanager.go b/client/txmanager.go new file mode 100644 index 0000000..b19ae82 --- /dev/null +++ b/client/txmanager.go @@ -0,0 +1,68 @@ +package client + +import ( + "encoding/json" + "fmt" + + "github.com/maestro-org/go-sdk/models" +) + +func (c *Client) TxManagerHistory() (*[]models.TxManagerState, error) { + url := "/txmanager/history" + resp, err := c.get(url) + if err != nil { + return nil, err + } + defer resp.Body.Close() + var txManagerStates []models.TxManagerState + err = json.NewDecoder(resp.Body).Decode(&txManagerStates) + if err != nil { + return nil, err + } + return &txManagerStates, nil +} + +func (c *Client) TxManagerSubmit(cbor string) (models.BasicResponse, error) { + url := "/txmanager" + resp, err := c.post(url, cbor) + if err != nil { + return models.BasicResponse{}, err + } + defer resp.Body.Close() + var submitTx models.BasicResponse + err = json.NewDecoder(resp.Body).Decode(&submitTx) + if err != nil { + return models.BasicResponse{}, err + } + return submitTx, nil +} + +func (c *Client) TxManagerSubmitTurbo(cbor string) (models.BasicResponse, error) { + url := "/txmanager/turbosubmit" + resp, err := c.post(url, cbor) + if err != nil { + return models.BasicResponse{}, err + } + defer resp.Body.Close() + var submitTx models.BasicResponse + err = json.NewDecoder(resp.Body).Decode(&submitTx) + if err != nil { + return models.BasicResponse{}, err + } + return submitTx, nil +} + +func (c *Client) TxManagerState(txHash string) (*models.TxManagerState, error) { + url := fmt.Sprintf("/txmanager/%s/state", txHash) + resp, err := c.get(url) + if err != nil { + return nil, err + } + defer resp.Body.Close() + var txManagerState models.TxManagerState + err = json.NewDecoder(resp.Body).Decode(&txManagerState) + if err != nil { + return nil, err + } + return &txManagerState, nil +} diff --git a/models/transactions.go b/models/transactions.go index 68adaf5..5bde671 100644 --- a/models/transactions.go +++ b/models/transactions.go @@ -10,12 +10,14 @@ type Certificates struct { StakeDeregistrations []any `json:"stake_deregistrations"` StakeRegistrationsReserves []any `json:"stake_registrations_reserves"` } + type Redeemers struct { Certificates []any `json:"certificates"` Mints []any `json:"mints"` Spends []any `json:"spends"` Withdrawals []any `json:"withdrawals"` } + type TransactionDetail struct { AdditionalSigners []string `json:"additional_signers"` BlockAbsoluteSlot int64 `json:"block_absolute_slot"` diff --git a/models/txmanager.go b/models/txmanager.go new file mode 100644 index 0000000..4efe9b5 --- /dev/null +++ b/models/txmanager.go @@ -0,0 +1,8 @@ +package models + +type TxManagerState struct { + Block string `json:"block"` // Block number + State string `json:"state"` // Transaction state + Timestamp string `json:"timestamp"` // Timestamp of last state change + TransactionHash string `json:"transaction_hash"` // Transaction hash +}