From fe30eab4222de8b2b7b23b52a20e0f746517afd0 Mon Sep 17 00:00:00 2001 From: Lazar Stijakovic Date: Tue, 5 Sep 2023 11:48:29 +0200 Subject: [PATCH 1/4] feat: added list owned assets and ncw for NFTs --- fireblocks_sdk/api_types.py | 9 ++++++ fireblocks_sdk/sdk.py | 63 +++++++++++++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/fireblocks_sdk/api_types.py b/fireblocks_sdk/api_types.py index 9c6dc29..ec6f61e 100644 --- a/fireblocks_sdk/api_types.py +++ b/fireblocks_sdk/api_types.py @@ -284,6 +284,15 @@ class GetOwnedCollectionsSortValue(str, Enum): COLLECTION_NAME = "name" +class GetOwnedAssetsSortValues(str, Enum): + ASSET_NAME = "name" + + +class NFTsWalletTypeValues(str, Enum): + VAULT_ACCOUNT = "VAULT_ACCOUNT" + END_USER_WALLET = "END_USER_WALLET" + + class OrderValues(str, Enum): ASC = "ASC" DESC = "DESC" diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index 0c04ddb..17e4d2f 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -10,7 +10,7 @@ from .api_types import FireblocksApiException, TRANSACTION_TYPES, TRANSACTION_STATUS_TYPES, TransferPeerPath, \ DestinationTransferPeerPath, TransferTicketTerm, TRANSACTION_TRANSFER, SIGNING_ALGORITHM, UnsignedMessage, \ FEE_LEVEL, PagedVaultAccountsRequestFilters, TransactionDestination, NFTOwnershipStatusValues, IssueTokenRequest, \ - GetAssetWalletsFilters, TimePeriod, GetOwnedCollectionsSortValue, GetOwnedNftsSortValues, GetNftsSortValues, OrderValues + GetAssetWalletsFilters, TimePeriod, GetOwnedCollectionsSortValue, GetOwnedNftsSortValues, GetNftsSortValues, GetOwnedAssetsSortValues, NFTsWalletTypeValues, OrderValues from .sdk_token_provider import SdkTokenProvider @@ -138,7 +138,8 @@ def refresh_nft_ownership_by_vault(self, blockchain_descriptor: str, vault_accou def get_owned_nfts(self, blockchain_descriptor: str, vault_account_ids: List[str] = None, ids: List[str] = None, collection_ids: List[str] = None, page_cursor: str = '', page_size: int = 100, sort: List[GetOwnedNftsSortValues] = None, - order: OrderValues = None, status: NFTOwnershipStatusValues = None, search: str = None): + order: OrderValues = None, status: NFTOwnershipStatusValues = None, search: str = None, + ncw_account_ids: List[str] = None, ncw_id: str = None, wallet_type: NFTsWalletTypeValues = None): """ """ @@ -158,6 +159,15 @@ def get_owned_nfts(self, blockchain_descriptor: str, vault_account_ids: List[str if collection_ids: params['collectionIds'] = ",".join(collection_ids) + if ncw_account_ids: + params['ncwAccountIds'] = ",".join(ncw_account_ids) + + if ncw_id: + params['ncwId'] = ncw_id.value + + if wallet_type: + params['walletType'] = wallet_type.value + if page_cursor: params['pageCursor'] = page_cursor @@ -178,7 +188,9 @@ def get_owned_nfts(self, blockchain_descriptor: str, vault_account_ids: List[str return self._get_request(url, query_params=params) - def list_owned_collections(self, search: str = None, sort: List[GetOwnedCollectionsSortValue] = None, + def list_owned_collections(self, search: str = None, status: NFTOwnershipStatusValues = None, + ncw_id: str = None, wallet_type: NFTsWalletTypeValues = None, + sort: List[GetOwnedCollectionsSortValue] = None, order: OrderValues = None, page_cursor: str = '', page_size: int = 100): """ @@ -190,6 +202,15 @@ def list_owned_collections(self, search: str = None, sort: List[GetOwnedCollecti if search: params['search'] = search + if status: + params['status'] = status + + if ncw_id: + params['ncwId'] = ncw_id.value + + if wallet_type: + params['walletType'] = wallet_type.value + if page_cursor: params['pageCursor'] = page_cursor @@ -204,6 +225,42 @@ def list_owned_collections(self, search: str = None, sort: List[GetOwnedCollecti return self._get_request(url, query_params=params) + def list_owned_assets(self, search: str = None, status: NFTOwnershipStatusValues = None, + ncw_id: str = None, wallet_type: NFTsWalletTypeValues = None, + sort: List[GetOwnedAssetsSortValues] = None, + order: OrderValues = None, page_cursor: str = '', page_size: int = 100): + """ + """ + url = f"/v1/nfts/ownership/assets" + + params = {} + + if search: + params['search'] = search + + if status: + params['status'] = status + + if ncw_id: + params['ncwId'] = ncw_id.value + + if wallet_type: + params['walletType'] = wallet_type.value + + if page_cursor: + params['pageCursor'] = page_cursor + + if page_size: + params['pageSize'] = page_size + + if sort: + params['sort'] = ",".join(sort) + + if order: + params['order'] = order + + return self._get_request(url, query_params=params) + def update_nft_ownership_status(self, id: str, status: NFTOwnershipStatusValues): """Update NFT ownership status for specific token From 4669f2b3343dca9e999417121af30cfbf82f83ee Mon Sep 17 00:00:00 2001 From: Lazar Stijakovic Date: Tue, 12 Sep 2023 12:08:28 +0200 Subject: [PATCH 2/4] fix: removed duplicate class GetOwnedAssetsSortValues --- fireblocks_sdk/api_types.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fireblocks_sdk/api_types.py b/fireblocks_sdk/api_types.py index a23eec2..69ee649 100644 --- a/fireblocks_sdk/api_types.py +++ b/fireblocks_sdk/api_types.py @@ -287,10 +287,6 @@ class GetOwnedAssetsSortValues(str, Enum): ASSET_NAME = "name" -class GetOwnedAssetsSortValues(str, Enum): - ASSET_NAME = "name" - - class NFTsWalletTypeValues(str, Enum): VAULT_ACCOUNT = "VAULT_ACCOUNT" END_USER_WALLET = "END_USER_WALLET" From f59c62f5473a44979688830f405484362e834020 Mon Sep 17 00:00:00 2001 From: Lazar Stijakovic Date: Tue, 12 Sep 2023 12:09:00 +0200 Subject: [PATCH 3/4] lint: added empty line --- fireblocks_sdk/api_types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fireblocks_sdk/api_types.py b/fireblocks_sdk/api_types.py index 69ee649..ec6f61e 100644 --- a/fireblocks_sdk/api_types.py +++ b/fireblocks_sdk/api_types.py @@ -283,6 +283,7 @@ class NFTOwnershipStatusValues(str, Enum): class GetOwnedCollectionsSortValue(str, Enum): COLLECTION_NAME = "name" + class GetOwnedAssetsSortValues(str, Enum): ASSET_NAME = "name" From ebdd1b833a1e840d762e6e788115eb4da994fe87 Mon Sep 17 00:00:00 2001 From: Lazar Stijakovic Date: Tue, 17 Oct 2023 12:26:25 +0200 Subject: [PATCH 4/4] fix: status filter --- fireblocks_sdk/sdk.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index 62ecb11..3cf0d6e 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -204,7 +204,7 @@ def list_owned_collections(self, search: str = None, status: NFTOwnershipStatusV params['search'] = search if status: - params['status'] = status + params['status'] = status.value if ncw_id: params['ncwId'] = ncw_id.value @@ -224,9 +224,6 @@ def list_owned_collections(self, search: str = None, status: NFTOwnershipStatusV if order: params['order'] = order.value - if status: - params['status'] = status - return self._get_request(url, query_params=params) def list_owned_assets(self, search: str = None, status: NFTOwnershipStatusValues = None, @@ -243,7 +240,7 @@ def list_owned_assets(self, search: str = None, status: NFTOwnershipStatusValues params['search'] = search if status: - params['status'] = status + params['status'] = status.value if ncw_id: params['ncwId'] = ncw_id.value