Skip to content

Commit

Permalink
Merge branch 'main' into feat/contracts/linear-vesting
Browse files Browse the repository at this point in the history
  • Loading branch information
Vardominator authored Oct 29, 2023
2 parents 83a4f94 + f16ce64 commit 2135ed1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
19 changes: 19 additions & 0 deletions client/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,22 @@ func (c *Client) TransactionOutputsFromReferences(
return &transactionOutputsFromReferences, nil

}

func (c *Client) EvaluateTx(txCbor string, AdditionalUtxos ...string) ([]models.RedeemerEvaluation, error) {
url := "/transactions/evaluate"
body := models.EvaluateTx{
Cbor: txCbor,
AdditionalUtxos: AdditionalUtxos,
}
resp, err := c.post(url, body)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var redeemerEvals []models.RedeemerEvaluation
err = json.NewDecoder(resp.Body).Decode(&redeemerEvals)
if err != nil {
return nil, err
}
return redeemerEvals, nil
}
18 changes: 18 additions & 0 deletions models/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,21 @@ type TransactionOutputsFromReferences struct {
LastUpdated utils.LastUpdated `json:"last_updated"`
NextCursor string `json:"next_cursor"`
}

type EvaluateTx struct {
Cbor string `json:"cbor"`
AdditionalUtxos []string `json:"additional_utxos"`
}

type ExecutionUnits struct {
Mem int64 `json:"Mem"`
Steps int64 `json:"Steps"`
}

type RedeemerEvaluation struct {
ExUnits ExecutionUnits `json:"ex_units"`
RedeemerIndex int `json:"redeemer_index"`
RedeemerTag string `json:"redeemer_tag"`
}

type EvaluateTxResponse []RedeemerEvaluation

0 comments on commit 2135ed1

Please sign in to comment.