diff --git a/api_transaction_test.go b/api_transaction_test.go index 8de312e..974b4b4 100644 --- a/api_transaction_test.go +++ b/api_transaction_test.go @@ -207,6 +207,18 @@ func TestTransactionRedeemersIntegration(t *testing.T) { testIntUtil(t, fp, &got, &want) } +func TestTransactionRequiredSignersIntegration(t *testing.T) { + hash := "b024ad35c6309a71a8e613d8bfea2a8185d81eda379ca9128877adefcde1c515" + api := blockfrost.NewAPIClient(blockfrost.APIClientOptions{}) + got, err := api.TransactionRequiredSigners(context.TODO(), hash) + if err != nil { + t.Fatal(err) + } + fp := filepath.Join(testdata, strings.ToLower(strings.TrimPrefix(t.Name(), "Test"))+".golden") + want := []blockfrost.TransactionRequiredSigner{} + testIntUtil(t, fp, &got, &want) +} + func TestTransactionDelegationCertsIntegration(t *testing.T) { hash := "6d619f41ba2e11b78c0d5647fb71ee5df05622fda1748a9124446226e54e6b50" api := blockfrost.NewAPIClient(blockfrost.APIClientOptions{}) diff --git a/api_transactions.go b/api_transactions.go index aae8e95..0e40f98 100644 --- a/api_transactions.go +++ b/api_transactions.go @@ -10,20 +10,21 @@ import ( ) const ( - resourceTxs = "txs" - resourceTx = "tx" - resourceTxStakes = "stakes" - resourceTxUTXOs = "utxos" - resourceTxWithdrawals = "withdrawals" - resourceTxMetadata = "metadata" - resourceTxRedeemers = "redeemers" - resourceCbor = "cbor" - resourceTxDelegations = "delegations" - resourceTxPoolUpdates = "pool_updates" - resourceTxPoolRetires = "pool_retires" - resourceTxSubmit = "submit" - resourceTxEvaluate = "utils/txs/evaluate" - resourceTxEvaluateUtxos = "utils/txs/evaluate/utxos" + resourceTxs = "txs" + resourceTx = "tx" + resourceTxStakes = "stakes" + resourceTxUTXOs = "utxos" + resourceTxWithdrawals = "withdrawals" + resourceTxMetadata = "metadata" + resourceTxRedeemers = "redeemers" + resourceTxRequiredSigners = "required_signers" + resourceCbor = "cbor" + resourceTxDelegations = "delegations" + resourceTxPoolUpdates = "pool_updates" + resourceTxPoolRetires = "pool_retires" + resourceTxSubmit = "submit" + resourceTxEvaluate = "utils/txs/evaluate" + resourceTxEvaluateUtxos = "utils/txs/evaluate/utxos" ) type TransactionContent struct { @@ -284,6 +285,10 @@ type TransactionRedeemer struct { Fee string `json:"fee"` } +type TransactionRequiredSigner struct { + WitnessHash string `json:"witness_hash"` +} + type Quantity string type Value struct { @@ -563,6 +568,26 @@ func (c *apiClient) TransactionPoolRetirementCerts(ctx context.Context, hash str return tcs, nil } +func (c *apiClient) TransactionRequiredSigners(ctx context.Context, hash string) (tm []TransactionRequiredSigner, err error) { + requestUrl, err := url.Parse(fmt.Sprintf("%s/%s/%s/%s", c.server, resourceTxs, hash, resourceTxRequiredSigners)) + if err != nil { + return + } + req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestUrl.String(), nil) + if err != nil { + return + } + res, err := c.handleRequest(req) + if err != nil { + return + } + defer res.Body.Close() + if err = json.NewDecoder(res.Body).Decode(&tm); err != nil { + return + } + return tm, nil +} + func (c *apiClient) TransactionSubmit(ctx context.Context, cbor []byte) (hash string, err error) { requestUrl, err := url.Parse(fmt.Sprintf("%s/%s/%s", c.server, resourceTx, resourceTxSubmit)) if err != nil { diff --git a/client.go b/client.go index 579ff75..24329e0 100644 --- a/client.go +++ b/client.go @@ -179,6 +179,7 @@ type APIClient interface { TransactionMetadata(ctx context.Context, hash string) ([]TransactionMetadata, error) TransactionMetadataInCBORs(ctx context.Context, hash string) ([]TransactionMetadataCbor, error) TransactionRedeemers(ctx context.Context, hash string) ([]TransactionRedeemer, error) + TransactionRequiredSigners(ctx context.Context, hash string) ([]TransactionRequiredSigner, error) TransactionDelegationCerts(ctx context.Context, hash string) ([]TransactionDelegation, error) TransactionPoolUpdates(ctx context.Context, hash string) ([]TransactionPoolCert, error) TransactionPoolUpdateCerts(ctx context.Context, hash string) ([]TransactionPoolCert, error) diff --git a/internal/version/version.go b/internal/version/version.go index d9c752a..4e10f96 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -11,7 +11,7 @@ import ( const ( Major = 0 Minor = 2 - Patch = 0 + Patch = 1 Prerelease = "" )