From 939136aab8f43cfe336c87267c62b2fff4889af8 Mon Sep 17 00:00:00 2001 From: Joshua Schmidt <123490974+JoshuaSchmidt-OpenSea@users.noreply.github.com> Date: Thu, 18 May 2023 15:41:36 -0500 Subject: [PATCH] Add animation URLS to Opensea Asset (#968) * Include animation urls in asset (#325) * Add getAsset integration test --------- Co-authored-by: Will Harris <30779570+fjij@users.noreply.github.com> --- src/__integration_tests__/getAsset.ts | 20 ++++++++++++++++++++ src/types.ts | 4 ++++ src/utils/utils.ts | 3 +++ 3 files changed, 27 insertions(+) create mode 100644 src/__integration_tests__/getAsset.ts diff --git a/src/__integration_tests__/getAsset.ts b/src/__integration_tests__/getAsset.ts new file mode 100644 index 000000000..da2f414b1 --- /dev/null +++ b/src/__integration_tests__/getAsset.ts @@ -0,0 +1,20 @@ +import { assert } from "chai"; +import { suite, test } from "mocha"; +import { sdk } from "./init"; + +suite("SDK: getAsset", () => { + test("Get Asset", async () => { + const tokenAddress = "0x059edd72cd353df5106d2b9cc5ab83a52287ac3a"; // Chromie Squiggles + const assetToGet = { + tokenAddress, + tokenId: "1", + }; + const asset = await sdk.api.getAsset(assetToGet); + assert(asset, "Asset should not be null"); + assert( + asset.assetContract.address === tokenAddress, + "Contract address should match." + ); + assert(asset.animationUrl, "Animation URL should not be null"); + }); +}); diff --git a/src/types.ts b/src/types.ts index 22cd18d15..287114040 100644 --- a/src/types.ts +++ b/src/types.ts @@ -400,6 +400,10 @@ export interface OpenSeaAsset extends Asset { imageUrlOriginal: string; // Thumbnail url for this token imageUrlThumbnail: string; + // The animation url for this token, if it exists + animationUrl: string | null; + // The original animation url for this token, if it exists + animationUrlOriginal: string | null; // Link to token on OpenSea openseaLink: string; // Link to token on dapp's site diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 336eea964..5fb8a3a3f 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -238,6 +238,9 @@ export const assetFromJSON = (asset: any): OpenSeaAsset => { imageUrlOriginal: asset.image_original_url, imageUrlThumbnail: asset.image_thumbnail_url, + animationUrl: asset.animation_url, + animationUrlOriginal: asset.animation_original_url, + externalLink: asset.external_link, openseaLink: asset.permalink, traits: asset.traits,