Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add asset and blockchain beta apis #200

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions fireblocks_sdk/api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
94 changes: 94 additions & 0 deletions fireblocks_sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
TokenOwnershipSpamUpdatePayload,
TokenOwnershipSpamUpdatePayload,
RescanTx,
AssetClassValues,
AssetScopeValues,
)
from .tokenization_api_types import \
CreateTokenRequest, \
Expand Down Expand Up @@ -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

Expand Down
Loading