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

Added list owned assets endpoint and NCW for NFTs #122

Merged
merged 6 commits into from
Oct 17, 2023
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
5 changes: 5 additions & 0 deletions fireblocks_sdk/api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ 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"
Expand Down
51 changes: 38 additions & 13 deletions fireblocks_sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
DestinationTransferPeerPath, TransferTicketTerm, TRANSACTION_TRANSFER, SIGNING_ALGORITHM, UnsignedMessage, \
FEE_LEVEL, PagedVaultAccountsRequestFilters, TransactionDestination, NFTOwnershipStatusValues, IssueTokenRequest, \
GetAssetWalletsFilters, TimePeriod, GetOwnedCollectionsSortValue, GetOwnedNftsSortValues, GetNftsSortValues, OrderValues, \
GetOwnedAssetsSortValues, PolicyRule, GetSmartTransferFilters
GetOwnedAssetsSortValues, PolicyRule, GetSmartTransferFilters, NFTsWalletTypeValues
from .sdk_token_provider import SdkTokenProvider


Expand Down Expand Up @@ -139,7 +139,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):
"""

"""
Expand All @@ -159,6 +160,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

Expand All @@ -179,8 +189,10 @@ 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,
order: OrderValues = None, page_cursor: str = '', page_size: int = 100, status: NFTOwnershipStatusValues = 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):
"""

"""
Expand All @@ -191,6 +203,15 @@ def list_owned_collections(self, search: str = None, sort: List[GetOwnedCollecti
if search:
params['search'] = search

if status:
params['status'] = status.value

if ncw_id:
params['ncwId'] = ncw_id.value

if wallet_type:
params['walletType'] = wallet_type.value

if page_cursor:
params['pageCursor'] = page_cursor

Expand All @@ -203,15 +224,13 @@ def list_owned_collections(self, search: str = None, sort: List[GetOwnedCollecti
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, sort: List[GetOwnedAssetsSortValues] = None,
order: OrderValues = None, page_cursor: str = '', page_size: int = 100, status: NFTOwnershipStatusValues = None):
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"

Expand All @@ -220,6 +239,15 @@ def list_owned_assets(self, search: str = None, sort: List[GetOwnedAssetsSortVal
if search:
params['search'] = search

if status:
params['status'] = status.value

if ncw_id:
params['ncwId'] = ncw_id.value

if wallet_type:
params['walletType'] = wallet_type.value

if page_cursor:
params['pageCursor'] = page_cursor

Expand All @@ -232,9 +260,6 @@ def list_owned_assets(self, search: str = None, sort: List[GetOwnedAssetsSortVal
if order:
params['order'] = order

if status:
params['status'] = status

return self._get_request(url, query_params=params)

def update_nft_ownership_status(self, id: str, status: NFTOwnershipStatusValues):
Expand Down