From 7f8dd6e24ddceca4b3c050bdab2cade4f2324e73 Mon Sep 17 00:00:00 2001 From: orman Date: Tue, 9 Jul 2024 15:54:05 +0300 Subject: [PATCH 01/15] add-collections-api --- fireblocks_sdk/sdk.py | 26 +++++++++++++++++++++++- fireblocks_sdk/tokenization_api_types.py | 20 ++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index ee55310..e4b1d23 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -50,7 +50,8 @@ TokenLinkStatus, \ TokenLinkType, \ ReadCallFunction, \ - WriteCallFunction + WriteCallFunction, \ + CreateCollectionRequest from .sdk_token_provider import SdkTokenProvider @@ -2910,6 +2911,29 @@ 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 get_contract_templates( self, initialization_phase: Optional[ContractInitializationPhase] = None, diff --git a/fireblocks_sdk/tokenization_api_types.py b/fireblocks_sdk/tokenization_api_types.py index bbc4838..c4d741d 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,23 @@ 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 ContractDeployRequest(BaseDictClass): def __init__( From a4422f6e3941d897c1a6c8b533e1822ce9b32dac Mon Sep 17 00:00:00 2001 From: orman Date: Thu, 11 Jul 2024 17:02:05 +0300 Subject: [PATCH 02/15] chore: Add mint_collection_token and burn_collection_token methods to FireblocksSDK --- fireblocks_sdk/sdk.py | 10 +++++++- fireblocks_sdk/tokenization_api_types.py | 32 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index e4b1d23..8809088 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -51,7 +51,9 @@ TokenLinkType, \ ReadCallFunction, \ WriteCallFunction, \ - CreateCollectionRequest + CreateCollectionRequest, \ + MintCollectionTokenRequest, \ + BurnCollectionTokenRequest from .sdk_token_provider import SdkTokenProvider @@ -2934,6 +2936,12 @@ def get_linked_collection(self, id: str): def unlinked_collection(self, id: str): return self._delete_request(f"/v1/tokenization/collections/{id}") + def mint_collection_token(self, request: MintCollectionTokenRequest): + return self._post_request("/v1/tokenization/collections/tokens/mint", request.to_dict()) + + def burn_collection_token(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, diff --git a/fireblocks_sdk/tokenization_api_types.py b/fireblocks_sdk/tokenization_api_types.py index c4d741d..2e03827 100644 --- a/fireblocks_sdk/tokenization_api_types.py +++ b/fireblocks_sdk/tokenization_api_types.py @@ -99,7 +99,39 @@ def __init__( 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, + 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 class ContractDeployRequest(BaseDictClass): def __init__( From 34fdbdd6e30a8e45c3556ad80199e466899439b4 Mon Sep 17 00:00:00 2001 From: orman Date: Mon, 15 Jul 2024 19:11:56 +0300 Subject: [PATCH 03/15] refactor: Rename methods for minting and burning NFTs in FireblocksSDK --- fireblocks_sdk/sdk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index 8809088..a297d02 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -2936,10 +2936,10 @@ def get_linked_collection(self, id: str): def unlinked_collection(self, id: str): return self._delete_request(f"/v1/tokenization/collections/{id}") - def mint_collection_token(self, request: MintCollectionTokenRequest): + def mint_nft(self, request: MintCollectionTokenRequest): return self._post_request("/v1/tokenization/collections/tokens/mint", request.to_dict()) - def burn_collection_token(self, request: BurnCollectionTokenRequest): + def burn_nft(self, request: BurnCollectionTokenRequest): return self._post_request("/v1/tokenization/collections/tokens/burn", request.to_dict()) def get_contract_templates( From f87750d371748eb067b875565bb606547a7035a7 Mon Sep 17 00:00:00 2001 From: Github Actions Date: Tue, 16 Jul 2024 07:29:29 +0000 Subject: [PATCH 04/15] release 2.10.0 --- .bumpversion.cfg | 2 +- setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 2a728c7..5a09adb 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.9.0 +current_version = 2.10.0 commit = false tag = false diff --git a/setup.py b/setup.py index 143abe1..89c70a1 100644 --- a/setup.py +++ b/setup.py @@ -2,13 +2,13 @@ setup( name = 'fireblocks_sdk', packages = ['fireblocks_sdk'], - version = '2.9.0', + version = '2.10.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.10.0.tar.gz', keywords = ['Fireblocks', 'SDK'], install_requires=[ 'PyJWT>=2.8.0', From 3dd1b7ee4a2f0194572a15bb6fe9dfc2204e5916 Mon Sep 17 00:00:00 2001 From: Phaniraj Govindaraju Date: Mon, 29 Jul 2024 12:37:00 +1000 Subject: [PATCH 05/15] Link any contract endpoints --- fireblocks_sdk/sdk.py | 26 +++++++++++++++++++++--- fireblocks_sdk/tokenization_api_types.py | 9 ++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index a297d02..e601f19 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -2900,11 +2900,19 @@ def get_linked_token(self, id: str): def get_linked_tokens_count(self): return self._get_request(f"/v1/tokenization/tokens/count") - def link_token(self, type: TokenLinkType, ref_id: str, display_name: Optional[str] = None): + def link_token(self, type: TokenLinkType, ref_id: Optional[str] = None, + display_name: Optional[str] = None, base_asset_id: Optional[str] = None, contract_address: Optional[str] = None): body = { "type": type, - "refId": ref_id, } + + if ref_id: + body["refId"] = ref_id + + if base_asset_id and contract_address: + body["baseAssetId"] = base_asset_id + body["contractAddress"] = contract_address + if display_name: body["displayName"] = display_name @@ -3017,7 +3025,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(f"/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(f"/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 2e03827..1378420 100644 --- a/fireblocks_sdk/tokenization_api_types.py +++ b/fireblocks_sdk/tokenization_api_types.py @@ -260,3 +260,12 @@ def __init__( self.amount = amount self.fee_level = fee_level self.note = note + +class ContractWithABIDto: + def __init__(self, address: str, base_asset_id: str, name: str, abi: List[AbiFunction], is_proxy: Optional[bool] = None, implementation: Optional[str] = None): + self.address = address + self.base_asset_id = base_asset_id + self.name = name + self.abi = abi + self.is_proxy = is_proxy + self.implementation = implementation From 9bc3e667e76f5a033d7e3776a277c1f7a371cfb3 Mon Sep 17 00:00:00 2001 From: Phaniraj Govindaraju Date: Mon, 29 Jul 2024 12:38:49 +1000 Subject: [PATCH 06/15] Remove return type --- fireblocks_sdk/tokenization_api_types.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/fireblocks_sdk/tokenization_api_types.py b/fireblocks_sdk/tokenization_api_types.py index 1378420..ea1abe4 100644 --- a/fireblocks_sdk/tokenization_api_types.py +++ b/fireblocks_sdk/tokenization_api_types.py @@ -261,11 +261,3 @@ def __init__( self.fee_level = fee_level self.note = note -class ContractWithABIDto: - def __init__(self, address: str, base_asset_id: str, name: str, abi: List[AbiFunction], is_proxy: Optional[bool] = None, implementation: Optional[str] = None): - self.address = address - self.base_asset_id = base_asset_id - self.name = name - self.abi = abi - self.is_proxy = is_proxy - self.implementation = implementation From d7928df2bb5622201a2664c6c8e1216bf1158304 Mon Sep 17 00:00:00 2001 From: Phaniraj Govindaraju Date: Mon, 29 Jul 2024 12:39:18 +1000 Subject: [PATCH 07/15] Remove empty line --- fireblocks_sdk/tokenization_api_types.py | 1 - 1 file changed, 1 deletion(-) diff --git a/fireblocks_sdk/tokenization_api_types.py b/fireblocks_sdk/tokenization_api_types.py index ea1abe4..2e03827 100644 --- a/fireblocks_sdk/tokenization_api_types.py +++ b/fireblocks_sdk/tokenization_api_types.py @@ -260,4 +260,3 @@ def __init__( self.amount = amount self.fee_level = fee_level self.note = note - From 45329124250e364a04767b250ae31e89d48c8060 Mon Sep 17 00:00:00 2001 From: Phaniraj Govindaraju Date: Mon, 29 Jul 2024 12:42:18 +1000 Subject: [PATCH 08/15] Bug fix --- fireblocks_sdk/sdk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index e601f19..439be9f 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -3027,13 +3027,13 @@ 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(f"/v1/contracts/fetch_abi",{ + 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(f"/v1/contracts/abi",{ + return self._post_request("/v1/contracts/abi",{ "baseAssetId": base_asset_id, "contractAddress": contract_address }) From b09a23e062dd76d4e8a4a9b1dfca2605b505d097 Mon Sep 17 00:00:00 2001 From: Trong Nguyen Date: Wed, 31 Jul 2024 18:31:53 +1000 Subject: [PATCH 09/15] removed unnecessary field from BurnCollectionTokenRequest --- fireblocks_sdk/tokenization_api_types.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fireblocks_sdk/tokenization_api_types.py b/fireblocks_sdk/tokenization_api_types.py index 2e03827..be6b106 100644 --- a/fireblocks_sdk/tokenization_api_types.py +++ b/fireblocks_sdk/tokenization_api_types.py @@ -121,14 +121,10 @@ def __init__( class BurnCollectionTokenRequest(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 From 99a3b6da172693cb766a8017a5c32e7c883ad36e Mon Sep 17 00:00:00 2001 From: Phaniraj Govindaraju Date: Mon, 5 Aug 2024 11:34:21 +1000 Subject: [PATCH 10/15] Address comment --- fireblocks_sdk/sdk.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index 439be9f..6e7bd06 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -2900,19 +2900,26 @@ def get_linked_token(self, id: str): def get_linked_tokens_count(self): return self._get_request(f"/v1/tokenization/tokens/count") - def link_token(self, type: TokenLinkType, ref_id: Optional[str] = None, - display_name: Optional[str] = None, base_asset_id: Optional[str] = None, contract_address: Optional[str] = None): + def link_token(self, type: TokenLinkType, ref_id: str = None, + display_name: Optional[str] = None): body = { "type": type, + "refId": ref_id } - - if ref_id: - body["refId"] = ref_id - if base_asset_id and contract_address: - body["baseAssetId"] = base_asset_id - body["contractAddress"] = contract_address + 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 = None, + contract_address: str = None, display_name: Optional[str] = None): + body = { + "type": type, + "baseAssetId": base_asset_id, + "contractAddress": contract_address + } + if display_name: body["displayName"] = display_name From 0d35b2632a5b167916ec21e9debe8f200fef847c Mon Sep 17 00:00:00 2001 From: Phaniraj Govindaraju Date: Mon, 5 Aug 2024 11:42:33 +1000 Subject: [PATCH 11/15] Minor fix --- fireblocks_sdk/sdk.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index 6e7bd06..6cd643c 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -2900,11 +2900,10 @@ def get_linked_token(self, id: str): def get_linked_tokens_count(self): return self._get_request(f"/v1/tokenization/tokens/count") - def link_token(self, type: TokenLinkType, ref_id: str = None, - display_name: Optional[str] = None): + def link_token(self, type: TokenLinkType, ref_id: str = None, display_name: Optional[str] = None): body = { "type": type, - "refId": ref_id + "refId": ref_id, } if display_name: @@ -2917,7 +2916,7 @@ def link_contract_by_address(self, type: TokenLinkType, base_asset_id: str = Non body = { "type": type, "baseAssetId": base_asset_id, - "contractAddress": contract_address + "contractAddress": contract_address, } if display_name: From 215ee166715c73216cba26356266986fddfd3944 Mon Sep 17 00:00:00 2001 From: Phaniraj Govindaraju Date: Mon, 5 Aug 2024 11:44:02 +1000 Subject: [PATCH 12/15] Self review update --- fireblocks_sdk/sdk.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index 6cd643c..a342119 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -2900,7 +2900,7 @@ def get_linked_token(self, id: str): def get_linked_tokens_count(self): return self._get_request(f"/v1/tokenization/tokens/count") - def link_token(self, type: TokenLinkType, ref_id: str = None, display_name: Optional[str] = None): + def link_token(self, type: TokenLinkType, ref_id: str, display_name: Optional[str] = None): body = { "type": type, "refId": ref_id, @@ -2911,8 +2911,8 @@ def link_token(self, type: TokenLinkType, ref_id: str = None, display_name: Opti return self._post_request(f"/v1/tokenization/tokens/link", body) - def link_contract_by_address(self, type: TokenLinkType, base_asset_id: str = None, - contract_address: str = None, display_name: Optional[str] = None): + 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, From ab6576267f8ffe7632db83466b15daafbfa5ffba Mon Sep 17 00:00:00 2001 From: Phaniraj Govindaraju Date: Mon, 5 Aug 2024 11:44:54 +1000 Subject: [PATCH 13/15] Fix formatting --- fireblocks_sdk/sdk.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index a342119..c831813 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -2911,8 +2911,7 @@ def link_token(self, type: TokenLinkType, ref_id: str, display_name: Optional[st 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): + 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, From 1eaf68dc7cddc960665b69ca2f4e8a7c207c0e9e Mon Sep 17 00:00:00 2001 From: vsiskin <121620421+vsiskin@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:05:57 +0200 Subject: [PATCH 14/15] add set asset price api (#186) * add set asset price api * fix tabs * fix: price type --------- Co-authored-by: Lazar Stijakovic --- fireblocks_sdk/sdk.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index c831813..e06bed2 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -407,6 +407,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 ): From 1c547be36acdd75e86e05f2821f04c9f86ac626e Mon Sep 17 00:00:00 2001 From: Github Actions Date: Tue, 13 Aug 2024 09:41:06 +0000 Subject: [PATCH 15/15] release 2.11.0 --- .bumpversion.cfg | 2 +- setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 5a09adb..c129a62 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.10.0 +current_version = 2.11.0 commit = false tag = false diff --git a/setup.py b/setup.py index 89c70a1..ec72925 100644 --- a/setup.py +++ b/setup.py @@ -2,13 +2,13 @@ setup( name = 'fireblocks_sdk', packages = ['fireblocks_sdk'], - version = '2.10.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.10.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',