diff --git a/src/__integration_tests__/README.md b/src/__integration_tests__/README.md index ca0931780..96ccbdfa6 100644 --- a/src/__integration_tests__/README.md +++ b/src/__integration_tests__/README.md @@ -8,7 +8,6 @@ Environment variables for integration tests are set using `.env`. This file is n ``` API_KEY = "" # OpenSea API Key -WALLET_ADDRESS = "" WALLET_PRIV_KEY = "" ALCHEMY_API_KEY = "" # The following needs to be an NFT owned by the WALLET_ADDRESS diff --git a/src/__integration_tests__/getCollection.ts b/src/__integration_tests__/getCollection.ts new file mode 100644 index 000000000..5baf9593e --- /dev/null +++ b/src/__integration_tests__/getCollection.ts @@ -0,0 +1,19 @@ +import { assert } from "chai"; +import { suite, test } from "mocha"; +import { sdk } from "./init"; +import { SafelistStatus } from "../types"; + +suite("SDK: getCollection", () => { + test("Get Verified Collection", async () => { + const slug = "cool-cats-nft"; + const collection = await sdk.api.getCollection(slug); + + assert(collection, "Collection should not be null"); + assert(collection.name, "Collection name should exist"); + assert(collection.slug === slug, "Collection slug should match."); + assert( + collection.safelistRequestStatus === SafelistStatus.VERIFIED, + "Collection should be verified." + ); + }); +}); diff --git a/src/__integration_tests__/init.ts b/src/__integration_tests__/init.ts new file mode 100644 index 000000000..94609ef3e --- /dev/null +++ b/src/__integration_tests__/init.ts @@ -0,0 +1,35 @@ +import { ethers } from "ethers"; +import Web3 from "web3"; +import { Network } from "wyvern-js/lib/types"; +import { + ALCHEMY_API_KEY, + MAINNET_API_KEY, + WALLET_PRIV_KEY, +} from "../__tests__/constants"; +import { OpenSeaSDK } from "../sdk"; + +export const TOKEN_ADDRESS = process.env.SELL_ORDER_CONTRACT_ADDRESS; +export const TOKEN_ID = process.env.SELL_ORDER_TOKEN_ID; +export const LISTING_AMOUNT = process.env.LISTING_AMOUNT; + +const webProvider = new Web3.providers.HttpProvider( + `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}` +); + +const rpcProvider = new ethers.providers.JsonRpcProvider( + `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}` +); + +const wallet = new ethers.Wallet(WALLET_PRIV_KEY ?? "", rpcProvider); + +export const walletAddress = wallet.address; + +export const sdk = new OpenSeaSDK( + webProvider, + { + networkName: Network.Main, + apiKey: MAINNET_API_KEY, + }, + (line) => console.info(`MAINNET: ${line}`), + wallet +); diff --git a/src/__integration_tests__/postOrder.ts b/src/__integration_tests__/postOrder.ts index 34ab718d2..a3b347be0 100644 --- a/src/__integration_tests__/postOrder.ts +++ b/src/__integration_tests__/postOrder.ts @@ -1,44 +1,14 @@ import { expect } from "chai"; -import { ethers } from "ethers"; import { suite, test } from "mocha"; -import Web3 from "web3"; import { - MAINNET_API_KEY, - WALLET_ADDRESS, - WALLET_PRIV_KEY, - ALCHEMY_API_KEY, - WETH_ADDRESS, - OFFER_AMOUNT, -} from "../__tests__/constants"; + LISTING_AMOUNT, + TOKEN_ADDRESS, + TOKEN_ID, + sdk, + walletAddress, +} from "./init"; +import { WETH_ADDRESS, OFFER_AMOUNT } from "../__tests__/constants"; import { expectValidOrder } from "../__tests__/utils"; -import { OpenSeaSDK } from "../index"; -import { Network } from "../types"; - -const TOKEN_ADDRESS = process.env.SELL_ORDER_CONTRACT_ADDRESS; -const TOKEN_ID = process.env.SELL_ORDER_TOKEN_ID; -const LISTING_AMOUNT = process.env.LISTING_AMOUNT; - -const walletAddress = WALLET_ADDRESS ?? ""; - -const webProvider = new Web3.providers.HttpProvider( - `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}` -); - -const rpcProvider = new ethers.providers.JsonRpcProvider( - `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}` -); - -const wallet = new ethers.Wallet(WALLET_PRIV_KEY ?? "", rpcProvider); - -const sdk = new OpenSeaSDK( - webProvider, - { - networkName: Network.Main, - apiKey: MAINNET_API_KEY, - }, - (line) => console.info(`MAINNET: ${line}`), - wallet -); suite("SDK: order posting", () => { test("Post Buy Order", async () => { diff --git a/src/__tests__/constants.ts b/src/__tests__/constants.ts index ae5890cec..b55e745d1 100644 --- a/src/__tests__/constants.ts +++ b/src/__tests__/constants.ts @@ -2,7 +2,6 @@ import { OpenSeaAPI } from "../api"; import { Network } from "../types"; export const MAINNET_API_KEY = process.env.API_KEY; -export const WALLET_ADDRESS = process.env.WALLET_ADDRESS; export const WALLET_PRIV_KEY = process.env.WALLET_PRIV_KEY; export const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY; export const OFFER_AMOUNT = process.env.OFFER_AMOUNT; diff --git a/src/types.ts b/src/types.ts index 3bd6342f0..22cd18d15 100644 --- a/src/types.ts +++ b/src/types.ts @@ -183,6 +183,22 @@ export enum TokenStandardVersion { ERC721v3 = "3.0", } +/** + * The collection's approval status within OpenSea. + * Can be not_requested (brand new collections) + * requested (collections that requested safelisting on our site) + * approved (collections that are approved on our site and can be found in search results) + * verified (verified collections) + */ + +export enum SafelistStatus { + NOT_REQUESTED = "not_requested", + REQUESTED = "requested", + APPROVED = "approved", + VERIFIED = "verified", + DISABLED_TOP_TRENDING = "disabled_top_trending", +} + // Collection fees mapping recipient address to basis points export interface Fees { openseaFees: Map; @@ -334,6 +350,8 @@ export interface OpenSeaCollection extends OpenSeaFees { stats: object; // Data about displaying cards displayData: object; + // The collection's approval status + safelistRequestStatus: SafelistStatus; // Tokens allowed for this collection paymentTokens: OpenSeaFungibleToken[]; // Address for dev fee payouts diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 158fe3fa3..336eea964 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -367,6 +367,7 @@ export const collectionFromJSON = (collection: any): OpenSeaCollection => { featured: collection.featured, featuredImageUrl: collection.featured_image_url, displayData: collection.display_data, + safelistRequestStatus: collection.safelist_request_status, paymentTokens: (collection.payment_tokens || []).map(tokenFromJSON), openseaBuyerFeeBasisPoints: +collection.opensea_buyer_fee_basis_points, openseaSellerFeeBasisPoints: +collection.opensea_seller_fee_basis_points,