-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from blockfrost/chore/improvements
Add missing methods for mempool, add tx_submit_cbor and tx_evaluate_cbor accepting cbor bytes/string
- Loading branch information
Showing
7 changed files
with
495 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import requests | ||
from blockfrost.utils import list_request_wrapper | ||
|
||
|
||
@list_request_wrapper | ||
def mempool(self, **kwargs): | ||
""" | ||
Obtains transactions that are currently stored in Blockfrost mempool, waiting to be included in a newly minted block. | ||
Returns only transactions submitted via Blockfrost.io. | ||
https://docs.blockfrost.io/#tag/Cardano-Mempool/paths/~1mempool/get | ||
:param return_type: Optional. "object", "json" or "pandas". Default: "object". | ||
:type return_type: str | ||
:param gather_pages: Optional. Default: false. Will collect all pages into one return | ||
:type gather_pages: bool | ||
:param count: Optional. Default: 100. The number of results displayed on one page. | ||
:type count: int | ||
:param page: Optional. The page number for listing the results. | ||
:type page: int | ||
: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}/mempool", | ||
params=self.query_parameters(kwargs), | ||
headers=self.default_headers | ||
) | ||
|
||
@list_request_wrapper | ||
def mempool_tx(self, hash: str, **kwargs): | ||
""" | ||
Obtains mempool transaction | ||
https://docs.blockfrost.io/#tag/Cardano-Mempool/paths/~1mempool~1%7Bhash%7D/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 | ||
:param gather_pages: Optional. Default: false. Will collect all pages into one return | ||
:type gather_pages: bool | ||
:param count: Optional. Default: 100. The number of results displayed on one page. | ||
:type count: int | ||
:param page: Optional. The page number for listing the results. | ||
:type page: int | ||
: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}/mempool/{hash}", | ||
params=self.query_parameters(kwargs), | ||
headers=self.default_headers | ||
) | ||
|
||
@list_request_wrapper | ||
def mempool_address(self, address: str, **kwargs): | ||
""" | ||
Obtains list of mempool transactions where at least one of the transaction inputs or outputs belongs to the address (paginated). | ||
Shows only transactions submitted via Blockfrost.io. | ||
https://docs.blockfrost.io/#tag/Cardano-Mempool/paths/~1mempool~1addresses~1%7Baddress%7D/get | ||
:param address: Bech32 address. | ||
:type address: str | ||
:param return_type: Optional. "object", "json" or "pandas". Default: "object". | ||
:type return_type: str | ||
:param gather_pages: Optional. Default: false. Will collect all pages into one return | ||
:type gather_pages: bool | ||
:param count: Optional. Default: 100. The number of results displayed on one page. | ||
:type count: int | ||
:param page: Optional. The page number for listing the results. | ||
:type page: int | ||
: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}/mempool/addresses/{address}", | ||
params=self.query_parameters(kwargs), | ||
headers=self.default_headers | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.