Skip to content

Commit 6ac6fe7

Browse files
committed
feat: required signers (extra tx witnesses)
1 parent baaeb82 commit 6ac6fe7

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

blockfrost/api/cardano/transactions.py

+21
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,27 @@ def transaction_redeemers(self, hash: str, **kwargs):
244244
headers=self.default_headers
245245
)
246246

247+
@list_request_wrapper
248+
def transaction_required_signers(self, hash: str, **kwargs):
249+
"""
250+
Obtain the transaction required signers (extra transaction witnesses).
251+
252+
https://docs.blockfrost.io/#tag/Cardano-Transactions/paths/~1txs~1{hash}~required_signers/get
253+
254+
:param hash: Hash of the requested transaction.
255+
:type hash: str
256+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
257+
:type return_type: str
258+
:returns A list of objects.
259+
:rtype [Namespace]
260+
:raises ApiError: If API fails
261+
:raises Exception: If the API response is somehow malformed.
262+
"""
263+
return requests.get(
264+
url=f"{self.url}/txs/{hash}/required_signers",
265+
headers=self.default_headers
266+
)
267+
247268

248269
@request_wrapper
249270
def transaction_submit(self, file_path: str, **kwargs):

tests/test_cardano_transactions.py

+22
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,28 @@ def test_integration_transaction_redeemers():
361361
assert api.transaction_redeemers(hash=hash) == []
362362

363363

364+
def test_transaction_required_signers(requests_mock):
365+
api = BlockFrostApi()
366+
mock_data = [
367+
{
368+
{
369+
"witness_hash": 'db7685e2d763133630e1a4afdefc5752d4b1c9be6c102e71242fb06f',
370+
},
371+
}
372+
]
373+
requests_mock.get(f"{api.url}/txs/{hash}/required_signers", json=mock_data)
374+
assert api.transaction_required_signers(
375+
hash=hash) == convert_json_to_object(mock_data)
376+
377+
378+
def test_integration_transaction_required_signers():
379+
if os.getenv('BLOCKFROST_PROJECT_ID_MAINNET'):
380+
api = BlockFrostApi(project_id=os.getenv(
381+
'BLOCKFROST_PROJECT_ID_MAINNET'))
382+
assert api.transaction_required_signers(hash="b024ad35c6309a71a8e613d8bfea2a8185d81eda379ca9128877adefcde1c515") == [
383+
{"witness_hash": 'db7685e2d763133630e1a4afdefc5752d4b1c9be6c102e71242fb06f'}]
384+
385+
364386
def test_transaction_submit(requests_mock):
365387
api = BlockFrostApi()
366388
mock_data = hash

0 commit comments

Comments
 (0)