-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Chris Gianelloni <[email protected]>
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |