diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 2a728c7..c129a62 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.9.0 +current_version = 2.11.0 commit = false tag = false diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index 9a3ead0..636618a 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -51,7 +51,10 @@ TokenLinkStatus, \ TokenLinkType, \ ReadCallFunction, \ - WriteCallFunction + WriteCallFunction, \ + CreateCollectionRequest, \ + MintCollectionTokenRequest, \ + BurnCollectionTokenRequest from .sdk_token_provider import SdkTokenProvider @@ -405,6 +408,22 @@ def get_supported_assets(self): return self._get_request("/v1/supported_assets") + def set_asset_price(self, id: str, currency: str, price: float): + """Set asset price + + Args: + id (str): The asset ID + currency (str): The currency (according to ISO 4217 currency codes) + price (str): The price in currency + """ + + body = { + "currency": currency, + "price": price, + } + + return self._post_request(f"/v1/assets/prices/${id}", body) + def get_vault_accounts_with_page_info( self, paged_vault_accounts_request_filters: PagedVaultAccountsRequestFilters ): @@ -2916,6 +2935,19 @@ def link_token(self, type: TokenLinkType, ref_id: str, display_name: Optional[st "type": type, "refId": ref_id, } + + if display_name: + body["displayName"] = display_name + + return self._post_request(f"/v1/tokenization/tokens/link", body) + + def link_contract_by_address(self, type: TokenLinkType, base_asset_id: str, contract_address: str, display_name: Optional[str] = None): + body = { + "type": type, + "baseAssetId": base_asset_id, + "contractAddress": contract_address, + } + if display_name: body["displayName"] = display_name @@ -2924,6 +2956,35 @@ def link_token(self, type: TokenLinkType, ref_id: str, display_name: Optional[st def unlink_token(self, id: str): return self._delete_request(f"/v1/tokenization/tokens/{id}") + def create_new_collection(self, request: CreateCollectionRequest): + return self._post_request("/v1/tokenization/collections", request.to_dict()) + + def get_linked_collections(self, status: Optional[TokenLinkStatus] = None, page_size: Optional[int] = None, page_cursor: Optional[str] = None): + request_filter = {} + + if status: + request_filter["status"] = status.value + + if page_size: + request_filter["pageSize"] = page_size + + if page_cursor: + request_filter["pageCursor"] = page_cursor + + return self._get_request("/v1/tokenization/collections", query_params=request_filter) + + def get_linked_collection(self, id: str): + return self._get_request(f"/v1/tokenization/collections/{id}") + + def unlinked_collection(self, id: str): + return self._delete_request(f"/v1/tokenization/collections/{id}") + + def mint_nft(self, request: MintCollectionTokenRequest): + return self._post_request("/v1/tokenization/collections/tokens/mint", request.to_dict()) + + def burn_nft(self, request: BurnCollectionTokenRequest): + return self._post_request("/v1/tokenization/collections/tokens/burn", request.to_dict()) + def get_contract_templates( self, initialization_phase: Optional[ContractInitializationPhase] = None, @@ -2999,7 +3060,19 @@ def get_contract_by_address(self, base_asset_id: str, contract_address: str): def get_contract_abi(self, base_asset_id: str, contract_address: str): return self._get_request(f"/v1/contract_interactions/base_asset_id/{base_asset_id}/contract_address/{contract_address}/functions") - + + def fetch_or_scrape_abi(self, base_asset_id: str, contract_address: str): + return self._post_request("/v1/contracts/fetch-abi",{ + "baseAssetId": base_asset_id, + "contractAddress": contract_address + }) + + def add_abi(self, base_asset_id: str, contract_address: str): + return self._post_request("/v1/contracts/abi",{ + "baseAssetId": base_asset_id, + "contractAddress": contract_address + }) + def read_contract_call_function(self, base_asset_id: str, contract_address: str, request: ReadCallFunction): return self._post_request(f"/v1/contract_interactions/base_asset_id/{base_asset_id}/contract_address/{contract_address}/functions/read", request.to_dict()) diff --git a/fireblocks_sdk/tokenization_api_types.py b/fireblocks_sdk/tokenization_api_types.py index bbc4838..be6b106 100644 --- a/fireblocks_sdk/tokenization_api_types.py +++ b/fireblocks_sdk/tokenization_api_types.py @@ -4,6 +4,9 @@ from .api_types import convert_class_to_dict +class CollectionLinkType(str, Enum): + NON_FUNGIBLE_TOKEN = "NON_FUNGIBLE_TOKEN" + SEMI_FUNGIBLE_TOKEN = "SEMI_FUNGIBLE_TOKEN" class BaseDictClass(ABC): def to_dict(self): @@ -80,6 +83,51 @@ def __init__( self.blockchain_id = blockchain_id self.display_name = display_name +class CreateCollectionRequest(BaseDictClass): + def __init__( + self, + base_asset_id: str, + vault_account_id: str, + type: CollectionLinkType, + name: str, + admin_address: str, + display_name: Optional[str] = None, + ): + self.base_asset_id = base_asset_id + self.vault_account_id = vault_account_id + self.type = type + self.name = name + self.admin_address = admin_address + self.display_name = display_name + +class MintCollectionTokenRequest(BaseDictClass): + def __init__( + self, + to: str, + tokenId: str, + vaultAccountId: str, + amount: Optional[str] = None, + metadataURI: Optional[str] = None, + metadata: Optional[str] = None, + ): + self.to = to + self.tokenId = tokenId + self.vaultAccountId = vaultAccountId + self.amount = amount + self.metadataURI = metadataURI + self.metadata = metadata + + +class BurnCollectionTokenRequest(BaseDictClass): + def __init__( + self, + tokenId: str, + vaultAccountId: str, + amount: Optional[str] = None, + ): + self.tokenId = tokenId + self.vaultAccountId = vaultAccountId + self.amount = amount class ContractDeployRequest(BaseDictClass): def __init__( diff --git a/setup.py b/setup.py index 143abe1..ec72925 100644 --- a/setup.py +++ b/setup.py @@ -2,13 +2,13 @@ setup( name = 'fireblocks_sdk', packages = ['fireblocks_sdk'], - version = '2.9.0', + version = '2.11.0', license='MIT', description = 'Fireblocks python SDK', long_description="""Fireblocks python SDK""", long_description_content_type='text/markdown', url = 'https://github.com/fireblocks/fireblocks-sdk-py', - download_url = 'https://github.com/fireblocks/fireblocks-sdk-py/archive/v2.9.0.tar.gz', + download_url = 'https://github.com/fireblocks/fireblocks-sdk-py/archive/v2.11.0.tar.gz', keywords = ['Fireblocks', 'SDK'], install_requires=[ 'PyJWT>=2.8.0',