Repository: alchemyplatform/alchemy-sdk-js
Pull request #43 (2022-06-30 22:27:39)

Fix naming on new NFT API

deric-alchemy: looks good!

Patch:
diff --git a/README.md b/README.md
index 44d36c2b..597d2956 100644
--- a/README.md
+++ b/README.md
@@ -172,9 +172,11 @@ The SDK currently supports the following [NFT API](https://docs.alchemy.com/alch
 - `getOwnersForNft()`: Get all the owners for a given NFT contract address and a particular token ID.
 - `getOwnersForCollection()`: Get all the owners for a given NFT contract address.
 - `checkNftOwnership()`: Check that the provided owner address owns one or more of the provided NFT contract addresses.
-- `isSpamContract()`: Check whether the given NFT contract address is a spam contract as defined by Alchemy (see the [NFT API FAQ](https://docs.alchemy.com/alchemy/enhanced-apis/nft-api/nft-api-faq#nft-spam-classification))
+- `isSpamNftContract()`: Check whether the given NFT contract address is a spam contract as defined by Alchemy (see the [NFT API FAQ](https://docs.alchemy.com/alchemy/enhanced-apis/nft-api/nft-api-faq#nft-spam-classification))
+- `getSpamNftContracts()`: Returns a list of all spam contracts marked by Alchemy.
 - `findContractDeployer()`: Find the contract deployer and block number for a given NFT contract address.
 - `refreshNftMetadata()`: Refresh the cached NFT metadata for a contract address and tokenId.
+- `getNftFloorPrice()`: Returns the floor prices of a NFT contract by marketplace.
 
 ### Comparing `BaseNft` and `Nft`
 
diff --git a/package.json b/package.json
index 40e09edf..187db725 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@alch/alchemy-sdk",
-  "version": "1.0.4",
+  "version": "1.0.5",
   "description": "Extended Ethers.js SDK for Alchemy APIs",
   "author": "Alchemy",
   "license": "MIT",
diff --git a/src/api/nft-api.ts b/src/api/nft-api.ts
index de61cb91..33497e6a 100644
--- a/src/api/nft-api.ts
+++ b/src/api/nft-api.ts
@@ -4,7 +4,7 @@ import {
   DeployResult,
   GetBaseNftsForCollectionOptions,
   GetBaseNftsForOwnerOptions,
-  GetFloorPriceResponse,
+  GetNftFloorPriceResponse,
   GetNftsForCollectionOptions,
   GetNftsForOwnerOptions,
   GetOwnersForCollectionResponse,
@@ -537,11 +537,11 @@ export async function checkNftOwnership(
  * @param contractAddress - The contract address to check.
  * @beta
  */
-export async function isSpamContract(
+export async function isSpamNftContract(
   alchemy: Alchemy,
   contractAddress: string
 ): Promise<boolean> {
-  const response = await requestHttpWithBackoff<IsSpamContractParams, boolean>(
+  return requestHttpWithBackoff<IsSpamContractParams, boolean>(
     alchemy,
     AlchemyApiType.NFT,
     'isSpamContract',
@@ -549,7 +549,6 @@ export async function isSpamContract(
       contractAddress
     }
   );
-  return response;
 }
 
 /**
@@ -560,34 +559,34 @@ export async function isSpamContract(
  * @param alchemy - The Alchemy SDK instance.
  * @beta
  */
-export async function getSpamContracts(alchemy: Alchemy): Promise<string[]> {
-  const response = await requestHttpWithBackoff<undefined, string[]>(
+export async function getSpamNftContracts(alchemy: Alchemy): Promise<string[]> {
+  return requestHttpWithBackoff<undefined, string[]>(
     alchemy,
     AlchemyApiType.NFT,
     'getSpamContracts',
     undefined
   );
-  return response;
 }
 
 /**
- * Returns the floor prices of a NFT collection by marketplace.
+ * Returns the floor prices of a NFT contract by marketplace.
  *
  * @param alchemy - The Alchemy SDK instance.
  * @param contractAddress - The contract address for the NFT collection.
  * @beta
  */
-export async function getFloorPrice(
+export async function getNftFloorPrice(
   alchemy: Alchemy,
   contractAddress: string
-): Promise<GetFloorPriceResponse> {
-  const response = await requestHttpWithBackoff<
-    GetFloorPriceParams,
-    GetFloorPriceResponse
-  >(alchemy, AlchemyApiType.NFT, 'getFloorPrice', {
-    contractAddress
-  });
-  return response;
+): Promise<GetNftFloorPriceResponse> {
+  return requestHttpWithBackoff<GetFloorPriceParams, GetNftFloorPriceResponse>(
+    alchemy,
+    AlchemyApiType.NFT,
+    'getFloorPrice',
+    {
+      contractAddress
+    }
+  );
 }
 
 /**
@@ -827,7 +826,7 @@ interface GetNftMetadataParams {
 }
 
 /**
- * <<<<<<< HEAD Interface for the `isSpamContract` endpoint.
+ * Interface for the `isSpamContract` endpoint.
  *
  * @internal
  */
diff --git a/src/index.ts b/src/index.ts
index dd7c8b90..7791db51 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -17,9 +17,9 @@ export {
   getOwnersForNft,
   getOwnersForCollection,
   checkNftOwnership,
-  isSpamContract,
-  getSpamContracts,
-  getFloorPrice,
+  isSpamNftContract,
+  getSpamNftContracts,
+  getNftFloorPrice,
   findContractDeployer,
   refreshNftMetadata
 } from './api/nft-api';
diff --git a/src/types/types.ts b/src/types/types.ts
index 60500587..efb71065 100644
--- a/src/types/types.ts
+++ b/src/types/types.ts
@@ -329,7 +329,7 @@ export interface GetOwnersForCollectionResponse {
 }
 
 /**
- * The successful object returned by the {@link getFloorPrice} call for each
+ * The successful object returned by the {@link getNftFloorPrice} call for each
  * marketplace (e.g. looksRare).
  *
  * @public
@@ -346,7 +346,7 @@ export interface FloorPriceMarketplace {
 }
 
 /**
- * The failing object returned by the {@link getFloorPrice} call for each
+ * The failing object returned by the {@link getNftFloorPrice} call for each
  * marketplace (e.g. looksRare).
  *
  * @public
@@ -357,11 +357,11 @@ export interface FloorPriceError {
 }
 
 /**
- * The response object for the {@link getFloorPrice}.
+ * The response object for the {@link getNftFloorPrice} method.
  *
  * @public
  */
-export interface GetFloorPriceResponse {
+export interface GetNftFloorPriceResponse {
   /**
    * Name of the NFT marketplace where the collection is listed. Current
    * marketplaces supported: OpenSea, LooksRare
diff --git a/src/version.ts b/src/version.ts
index f2f2260c..94777913 100644
--- a/src/version.ts
+++ b/src/version.ts
@@ -1,3 +1,3 @@
 // This file is autogenerated by injectVersion.js. Any changes will be
 // overwritten on commit!
-export const VERSION = '1.0.3';
+export const VERSION = '1.0.5';


Test patch:
diff --git a/test/unit/nft-api.test.ts b/test/unit/nft-api.test.ts
index 099b6f5e..119ada26 100644
--- a/test/unit/nft-api.test.ts
+++ b/test/unit/nft-api.test.ts
@@ -5,8 +5,8 @@ import {
   CollectionBaseNftsResponse,
   CollectionNftsResponse,
   fromHex,
-  getFloorPrice,
-  GetFloorPriceResponse,
+  getNftFloorPrice,
+  GetNftFloorPriceResponse,
   getNftMetadata,
   getNftsForCollection,
   getNftsForCollectionIterator,
@@ -15,9 +15,9 @@ import {
   GetNftsForOwnerOptions,
   getOwnersForCollection,
   getOwnersForNft,
-  getSpamContracts,
+  getSpamNftContracts,
   initializeAlchemy,
-  isSpamContract,
+  isSpamNftContract,
   Nft,
   NftContract,
   NftExcludeFilters,
@@ -1044,11 +1044,11 @@ describe('NFT module', () => {
     });
   });
 
-  describe('isSpamContract', () => {
+  describe('isSpamNftContract', () => {
     const spamContract = '0x000440f08436a7b866d1ae42db5e0be801da722a';
     it('calls with the correct parameters', async () => {
       mock.onGet().reply(200, true);
-      await isSpamContract(alchemy, spamContract);
+      await isSpamNftContract(alchemy, spamContract);
       expect(mock.history.get.length).toEqual(1);
       expect(mock.history.get[0].params).toHaveProperty(
         'contractAddress',
@@ -1057,17 +1057,17 @@ describe('NFT module', () => {
     });
   });
 
-  describe('getSpamContracts', () => {
+  describe('getSpamNftContracts', () => {
     it('calls with the correct parameters', async () => {
       mock.onGet().reply(200, ['0xABC', '0xABD']);
-      await getSpamContracts(alchemy);
+      await getSpamNftContracts(alchemy);
       expect(mock.history.get.length).toEqual(1);
     });
   });
 
-  describe('getFloorPrice', () => {
+  describe('getNftFloorPrice', () => {
     const contractAddress = '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d';
-    const templateResponse: GetFloorPriceResponse = {
+    const templateResponse: GetNftFloorPriceResponse = {
       openSea: {
         floorPrice: 90.969,
         priceCurrency: 'ETH',
@@ -1088,7 +1088,7 @@ describe('NFT module', () => {
     });
 
     it('calls with the correct parameters', async () => {
-      await getFloorPrice(alchemy, contractAddress);
+      await getNftFloorPrice(alchemy, contractAddress);
       expect(mock.history.get.length).toEqual(1);
       expect(mock.history.get[0].params).toHaveProperty(
         'contractAddress',
@@ -1100,7 +1100,7 @@ describe('NFT module', () => {
       mock.reset();
       mock.onGet().reply(429, 'Too many requests');
 
-      await expect(getFloorPrice(alchemy, contractAddress)).rejects.toThrow(
+      await expect(getNftFloorPrice(alchemy, contractAddress)).rejects.toThrow(
         'Too many requests'
       );
     });
@@ -1108,7 +1108,7 @@ describe('NFT module', () => {
     it('surfaces errors', async () => {
       mock.reset();
       mock.onGet().reply(500, 'Internal Server Error');
-      await expect(getFloorPrice(alchemy, contractAddress)).rejects.toThrow(
+      await expect(getNftFloorPrice(alchemy, contractAddress)).rejects.toThrow(
         'Internal Server Error'
       );
     });