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 #206

Merged
merged 2 commits into from
Sep 5, 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
51 changes: 49 additions & 2 deletions src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
TimePeriod,
AuditsResponse,
NFTOwnershipFilter,
NFTOwnedAssetsFilter,
Token,
TokenWithBalance,
Web3PagedResponse,
Expand Down Expand Up @@ -1427,11 +1428,14 @@ export class FireblocksSDK {
* @param filter.order Order value
* @param filter.status Status (LISTED, ARCHIVED)
* @param filter.search Search filter
* @param filter.ncwAccountIds List of Non-Custodial wallet account IDs
* @param filter.ncwId Non-Custodial wallet id
* @param filter.walletType Wallet type (VAULT_ACCOUNT, END_USER_WALLET)
*/
public async getOwnedNFTs(filter?: NFTOwnershipFilter): Promise<Web3PagedResponse<TokenWithBalance>> {
let url = "/v1/nfts/ownership/tokens";
if (filter) {
const { blockchainDescriptor, vaultAccountIds, collectionIds, ids, pageCursor, pageSize, sort, order, status, search } = filter;
const { blockchainDescriptor, vaultAccountIds, collectionIds, ids, pageCursor, pageSize, sort, order, status, search, ncwId, ncwAccountIds, walletType } = filter;
const requestFilter = {
vaultAccountIds: this.getCommaSeparatedList(vaultAccountIds),
blockchainDescriptor,
Expand All @@ -1443,6 +1447,9 @@ export class FireblocksSDK {
order,
status,
search,
ncwId,
ncwAccountIds,
walletType,
};
url += `?${queryString.stringify(requestFilter)}`;
}
Expand All @@ -1451,7 +1458,11 @@ export class FireblocksSDK {

/**
*
* Get a list of owned NFT collections
* @param filter.search Search by value
* @param filter.status Status (LISTED, ARCHIVED)
* @param filter.ncwId Non-Custodial wallet id
* @param filter.walletType Wallet type (VAULT_ACCOUNT, END_USER_WALLET)
* @param filter.pageCursor Page cursor
* @param filter.pageSize Page size
* @param filter.sort Sort by value
Expand All @@ -1460,10 +1471,46 @@ export class FireblocksSDK {
public async listOwnedCollections(filter?: NFTOwnedCollectionsFilter): Promise<Web3PagedResponse<CollectionOwnership>> {
let url = "/v1/nfts/ownership/collections";
if (filter) {
const { search, pageCursor, pageSize, sort, order } = filter;
const { search, status, ncwId, walletType, pageCursor, pageSize, sort, order } = filter;

const requestFilter = {
search,
status,
ncwId,
walletType,
pageCursor,
pageSize,
sort: this.getCommaSeparatedList(sort),
order,
};
url += `?${queryString.stringify(requestFilter)}`;
}

return await this.apiClient.issueGetRequest(url);
}

/**
*
* Get a list of owned tokens
* @param filter.search Search by value
* @param filter.status Status (LISTED, ARCHIVED)
* @param filter.ncwId Non-Custodial wallet id
* @param filter.walletType Wallet type (VAULT_ACCOUNT, END_USER_WALLET)
* @param filter.pageCursor Page cursor
* @param filter.pageSize Page size
* @param filter.sort Sort by value
* @param filter.order Order by value
*/
public async listOwnedAssets(filter?: NFTOwnedAssetsFilter): Promise<Web3PagedResponse<Token>> {
let url = "/v1/nfts/ownership/assets";
if (filter) {
const { search, status, ncwId, walletType, pageCursor, pageSize, sort, order } = filter;

const requestFilter = {
search,
status,
ncwId,
walletType,
pageCursor,
pageSize,
sort: this.getCommaSeparatedList(sort),
Expand Down
31 changes: 29 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,16 +776,33 @@ export interface NFTOwnershipFilter {
order?: OrderValues;
status?: NFTOwnershipStatus;
search?: string;
ncwId?: string;
ncwAccountIds?: string[];
walletType?: NFTOwnershipWalletType;
}

export interface NFTOwnedCollectionsFilter {
search?: string;
status?: NFTOwnershipStatus;
ncwId?: string;
walletType?: NFTOwnershipWalletType;
pageCursor?: string;
pageSize?: number;
sort?: GetOwnedCollectionsSortValues[];
order?: OrderValues;
}

export interface NFTOwnedAssetsFilter {
search?: string;
status?: NFTOwnershipStatus;
ncwId?: string;
walletType?: NFTOwnershipWalletType;
pageCursor?: string;
pageSize?: number;
sort?: GetOwnedAssetsSortValues[];
order?: OrderValues;
}

export interface GetNFTsFilter {
ids: string[];
pageCursor?: string;
Expand Down Expand Up @@ -822,13 +839,14 @@ export interface Token {
collection?: NFTCollection;
}

export interface TokenWithBalance extends Token {
export interface BaseTokenWithBalance extends Token {
balance: string;
vaultAccountId: string;
ownershipStartTime: number;
ownershipLastUpdateTime: number;
}

export type TokenWithBalance = (WorkspaceWalletIdentifier | NonCustodialWalletIdentifier) & BaseTokenWithBalance;

export interface CollectionOwnership extends NFTCollection {
standard?: string;
blockchainDescriptor: string;
Expand Down Expand Up @@ -1368,6 +1386,10 @@ export enum GetOwnedCollectionsSortValues {
"name" = "name",
}

export enum GetOwnedAssetsSortValues {
"name" = "name",
}

export enum OrderValues {
"ASC" = "ASC",
"DESC" = "DESC",
Expand All @@ -1378,6 +1400,11 @@ export enum NFTOwnershipStatus {
"ARCHIVED" = "ARCHIVED",
}

export enum NFTOwnershipWalletType {
"VAULT_ACCOUNT" = "VAULT_ACCOUNT",
"END_USER_WALLET" = "END_USER_WALLET",
}

export interface ContractUploadRequest {
name: string;
description: string;
Expand Down