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

add missing fields to Get NFT #1447

Merged
merged 2 commits into from
Apr 17, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opensea-js",
"version": "7.1.4",
"version": "7.1.5",
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data",
"license": "MIT",
"author": "OpenSea Developers",
Expand Down
22 changes: 22 additions & 0 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ export type NFT = {
image_url: string;
/** URL of metadata */
metadata_url: string;
/** URL on OpenSea */
opensea_url: string;
/** Date of latest NFT update */
updated_at: string;
/** Whether NFT is disabled for trading on OpenSea */
Expand All @@ -219,6 +221,26 @@ export type NFT = {
is_nsfw: boolean;
/** Traits for the NFT, returns null if the NFT has than 50 traits */
traits: Trait[] | null;
/** Creator of the NFT */
creator: string;
/** Owners of the NFT */
owners: {
address: string;
quantity: number;
};
/** Rarity of the NFT */
rarity: null | {
strategy_id: string | null;
strategy_version: string | null;
rank: number | null;
score: number | null;
calculated_at: string;
max_rank: number | null;
tokens_scored: number | null;
ranking_features: null | {
unique_attribute_count: number;
};
};
};

/**
Expand Down
20 changes: 4 additions & 16 deletions test/integration/getNFTs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,11 @@ suite("SDK: NFTs", () => {

test("Get NFT", async () => {
const tokenAddress = "0x4768cbf202f365fbf704b9b9d397551a0443909b"; // Roo Troop
const identifier = "2";
const response = await sdk.api.getNFT(
tokenAddress,
identifier,
Chain.Polygon,
);
const tokenId = "2";
const response = await sdk.api.getNFT(tokenAddress, tokenId, Chain.Polygon);
assert(response.nft, "Response should contain nft.");
assert.equal(
response.nft.contract,
tokenAddress,
"NFT address should match token address",
);
assert.equal(
response.nft.identifier,
identifier,
"NFT address should match token address",
);
assert.equal(response.nft.contract, tokenAddress, "The address matches");
assert.equal(response.nft.identifier, tokenId, "The token id matches");
});

test("Refresh NFT", async () => {
Expand Down
Loading