Skip to content

Commit ba1a7a9

Browse files
committed
feat: required signers (extra tx witnesses)
1 parent 75bbb41 commit ba1a7a9

3 files changed

Lines changed: 52 additions & 14 deletions

File tree

api_transaction_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@ func TestTransactionRedeemersIntegration(t *testing.T) {
207207
testIntUtil(t, fp, &got, &want)
208208
}
209209

210+
func TestTransactionRequiredSignersIntegration(t *testing.T) {
211+
hash := "b024ad35c6309a71a8e613d8bfea2a8185d81eda379ca9128877adefcde1c515"
212+
api := blockfrost.NewAPIClient(blockfrost.APIClientOptions{})
213+
got, err := api.TransactionRequiredSigners(context.TODO(), hash)
214+
if err != nil {
215+
t.Fatal(err)
216+
}
217+
fp := filepath.Join(testdata, strings.ToLower(strings.TrimPrefix(t.Name(), "Test"))+".golden")
218+
want := []blockfrost.TransactionRequiredSigner{}
219+
testIntUtil(t, fp, &got, &want)
220+
}
221+
210222
func TestTransactionDelegationCertsIntegration(t *testing.T) {
211223
hash := "6d619f41ba2e11b78c0d5647fb71ee5df05622fda1748a9124446226e54e6b50"
212224
api := blockfrost.NewAPIClient(blockfrost.APIClientOptions{})

api_transactions.go

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ import (
1010
)
1111

1212
const (
13-
resourceTxs = "txs"
14-
resourceTx = "tx"
15-
resourceTxStakes = "stakes"
16-
resourceTxUTXOs = "utxos"
17-
resourceTxWithdrawals = "withdrawals"
18-
resourceTxMetadata = "metadata"
19-
resourceTxRedeemers = "redeemers"
20-
resourceCbor = "cbor"
21-
resourceTxDelegations = "delegations"
22-
resourceTxPoolUpdates = "pool_updates"
23-
resourceTxPoolRetires = "pool_retires"
24-
resourceTxSubmit = "submit"
25-
resourceTxEvaluate = "utils/txs/evaluate"
26-
resourceTxEvaluateUtxos = "utils/txs/evaluate/utxos"
13+
resourceTxs = "txs"
14+
resourceTx = "tx"
15+
resourceTxStakes = "stakes"
16+
resourceTxUTXOs = "utxos"
17+
resourceTxWithdrawals = "withdrawals"
18+
resourceTxMetadata = "metadata"
19+
resourceTxRedeemers = "redeemers"
20+
resourceTxRequiredSigners = "required_signers"
21+
resourceCbor = "cbor"
22+
resourceTxDelegations = "delegations"
23+
resourceTxPoolUpdates = "pool_updates"
24+
resourceTxPoolRetires = "pool_retires"
25+
resourceTxSubmit = "submit"
26+
resourceTxEvaluate = "utils/txs/evaluate"
27+
resourceTxEvaluateUtxos = "utils/txs/evaluate/utxos"
2728
)
2829

2930
type TransactionContent struct {
@@ -284,6 +285,10 @@ type TransactionRedeemer struct {
284285
Fee string `json:"fee"`
285286
}
286287

288+
type TransactionRequiredSigner struct {
289+
WitnessHash string `json:"witness_hash"`
290+
}
291+
287292
type Quantity string
288293

289294
type Value struct {
@@ -563,6 +568,26 @@ func (c *apiClient) TransactionPoolRetirementCerts(ctx context.Context, hash str
563568
return tcs, nil
564569
}
565570

571+
func (c *apiClient) TransactionRequiredSigners(ctx context.Context, hash string) (tm []TransactionRequiredSigner, err error) {
572+
requestUrl, err := url.Parse(fmt.Sprintf("%s/%s/%s/%s", c.server, resourceTxs, hash, resourceTxRequiredSigners))
573+
if err != nil {
574+
return
575+
}
576+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestUrl.String(), nil)
577+
if err != nil {
578+
return
579+
}
580+
res, err := c.handleRequest(req)
581+
if err != nil {
582+
return
583+
}
584+
defer res.Body.Close()
585+
if err = json.NewDecoder(res.Body).Decode(&tm); err != nil {
586+
return
587+
}
588+
return tm, nil
589+
}
590+
566591
func (c *apiClient) TransactionSubmit(ctx context.Context, cbor []byte) (hash string, err error) {
567592
requestUrl, err := url.Parse(fmt.Sprintf("%s/%s/%s", c.server, resourceTx, resourceTxSubmit))
568593
if err != nil {

client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ type APIClient interface {
180180
TransactionMetadata(ctx context.Context, hash string) ([]TransactionMetadata, error)
181181
TransactionMetadataInCBORs(ctx context.Context, hash string) ([]TransactionMetadataCbor, error)
182182
TransactionRedeemers(ctx context.Context, hash string) ([]TransactionRedeemer, error)
183+
TransactionRequiredSigners(ctx context.Context, hash string) ([]TransactionRequiredSigner, error)
183184
TransactionDelegationCerts(ctx context.Context, hash string) ([]TransactionDelegation, error)
184185
TransactionPoolUpdates(ctx context.Context, hash string) ([]TransactionPoolCert, error)
185186
TransactionPoolUpdateCerts(ctx context.Context, hash string) ([]TransactionPoolCert, error)

0 commit comments

Comments
 (0)