From b00d07a3ae17782cadc1ead9cf25e1d676f8d782 Mon Sep 17 00:00:00 2001 From: Lazar Stijakovic Date: Thu, 19 Dec 2024 13:37:51 +0100 Subject: [PATCH] feat: added asset and blockchain beta apis --- fireblocks_sdk/api_types.py | 14 ++++++ fireblocks_sdk/sdk.py | 94 +++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/fireblocks_sdk/api_types.py b/fireblocks_sdk/api_types.py index 71517a3..49f0d6a 100644 --- a/fireblocks_sdk/api_types.py +++ b/fireblocks_sdk/api_types.py @@ -407,6 +407,20 @@ def serialize(self) -> dict: 'spam': self.spam, } + +class AssetClassValues(str, Enum): + NATIVE = "NATIVE" + FT = "FT" + FIAT = "FIAT" + NFT = "NFT" + SFT = "SFT" + + +class AssetScopeValues(str, Enum): + GLOBAL = "Global" + LOCAL = "Local" + + class OrderValues(str, Enum): ASC = "ASC" DESC = "DESC" diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index e8c9294..e070acb 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -42,6 +42,8 @@ TokenOwnershipSpamUpdatePayload, TokenOwnershipSpamUpdatePayload, RescanTx, + AssetClassValues, + AssetScopeValues, ) from .tokenization_api_types import \ CreateTokenRequest, \ @@ -1370,6 +1372,98 @@ def register_new_asset(self, blockchainId, address, symbol=None, idempotency_key return self._post_request("/v1/assets", body, idempotency_key) + def list_assets( + self, + blockchain_id: str = None, + asset_class: AssetClassValues = None, + symbol: str = None, + scope: AssetScopeValues = None, + deprecated: bool = None, + page_cursor: str = None, + page_size: int = None, + ): + """ + List assets [BETA] + + Args: + blockchain_id (str): Blockchain id of the assets + asset_class (AssetClassValues): Assets class + symbol (str): Assets onchain symbol + scope (AssetScopeValues): Scope of the assets + deprecated (bool): Are assets deprecated + page_cursor (str): Next page cursor to fetch + page_size (int): Items per page + """ + + url = "/v1/assets" + if blockchain_id: + url += f"?blockchainId={blockchain_id}" + if asset_class: + url += f"&assetClass={asset_class.value}" + if symbol: + url += f"?symbol={symbol}" + if scope: + url += f"&scope={scope.value}" + if deprecated is not None: + url += f"&deprecated={deprecated}" + if page_cursor: + url += f"?pageCursor={page_cursor}" + if page_size: + url += f"?pageSize={page_size}" + return self._get_request(url) + + def get_asset_by_id(self, asset_id: str): + """ + Get an asset [BETA] + + Args: + asset_id (str): The ID or legacyId of the asset + """ + + return self._get_request(f"/v1/assets/{asset_id}") + + def list_blockchains( + self, + protocol: str = None, + deprecated: bool = None, + test: bool = None, + page_cursor: str = None, + page_size: int = None, + ): + """ + List blockchains [BETA] + + Args: + protocol (str): Blockchain protocol + deprecated (bool): Is blockchain deprecated + test (bool): Is test blockchain + page_cursor (str): Page cursor to fetch + page_size (int): Items per page (max 500) + """ + + url = "/v1/blockchains" + if protocol: + url += f"?protocol={protocol}" + if deprecated is not None: + url += f"&deprecated={deprecated}" + if test is not None: + url += f"&test={test}" + if page_cursor: + url += f"?pageCursor={page_cursor}" + if page_size: + url += f"?pageSize={page_size}" + return self._get_request(url) + + def get_blockchain_by_id(self, blockchain_id: str): + """ + Get an blockchain [BETA] + + Args: + blockchain_id (str): The ID or legacyId of the blockchain + """ + + return self._get_request(f"/v1/blockchains/{blockchain_id}") + def create_vault_asset(self, vault_account_id, asset_id, idempotency_key=None): """Creates a new asset within an existing vault account