Skip to content

Commit

Permalink
feat: required signers (extra tx witnesses)
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbackspace committed Feb 6, 2024
1 parent baaeb82 commit 6ac6fe7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
21 changes: 21 additions & 0 deletions blockfrost/api/cardano/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,27 @@ def transaction_redeemers(self, hash: str, **kwargs):
headers=self.default_headers
)

@list_request_wrapper
def transaction_required_signers(self, hash: str, **kwargs):
"""
Obtain the transaction required signers (extra transaction witnesses).
https://docs.blockfrost.io/#tag/Cardano-Transactions/paths/~1txs~1{hash}~required_signers/get
:param hash: Hash of the requested transaction.
:type hash: str
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
:type return_type: str
:returns A list of objects.
:rtype [Namespace]
:raises ApiError: If API fails
:raises Exception: If the API response is somehow malformed.
"""
return requests.get(
url=f"{self.url}/txs/{hash}/required_signers",
headers=self.default_headers
)


@request_wrapper
def transaction_submit(self, file_path: str, **kwargs):
Expand Down
22 changes: 22 additions & 0 deletions tests/test_cardano_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,28 @@ def test_integration_transaction_redeemers():
assert api.transaction_redeemers(hash=hash) == []


def test_transaction_required_signers(requests_mock):
api = BlockFrostApi()
mock_data = [
{
{
"witness_hash": 'db7685e2d763133630e1a4afdefc5752d4b1c9be6c102e71242fb06f',
},
}
]
requests_mock.get(f"{api.url}/txs/{hash}/required_signers", json=mock_data)
assert api.transaction_required_signers(
hash=hash) == convert_json_to_object(mock_data)


def test_integration_transaction_required_signers():
if os.getenv('BLOCKFROST_PROJECT_ID_MAINNET'):
api = BlockFrostApi(project_id=os.getenv(
'BLOCKFROST_PROJECT_ID_MAINNET'))
assert api.transaction_required_signers(hash="b024ad35c6309a71a8e613d8bfea2a8185d81eda379ca9128877adefcde1c515") == [
{"witness_hash": 'db7685e2d763133630e1a4afdefc5752d4b1c9be6c102e71242fb06f'}]


def test_transaction_submit(requests_mock):
api = BlockFrostApi()
mock_data = hash
Expand Down

0 comments on commit 6ac6fe7

Please sign in to comment.