Skip to content
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
6 changes: 2 additions & 4 deletions test/api/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import { getWETHAddress } from "../../src/utils";
import {
BAYC_CONTRACT_ADDRESS,
mainAPI,
MAINNET_API_KEY,
testnetAPI,
OPENSEA_API_KEY,
} from "../utils/constants";

suite("API", () => {
test("API has correct base url", () => {
assert.equal(mainAPI.apiBaseUrl, "https://api.opensea.io");
assert.equal(testnetAPI.apiBaseUrl, "https://testnets-api.opensea.io");
});

test("Includes API key in request", async () => {
Expand All @@ -21,7 +19,7 @@ suite("API", () => {
const logPromise = new Promise<void>((resolve, reject) => {
mainAPI.logger = (log) => {
try {
assert.include(log, `"x-api-key":"${MAINNET_API_KEY}"`);
assert.include(log, `"x-api-key":"${OPENSEA_API_KEY}"`);
resolve();
} catch (e) {
reject(e);
Expand Down
3 changes: 1 addition & 2 deletions test/api/getOrders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ suite("Getting orders", () => {

[OrderSide.LISTING, OrderSide.OFFER].forEach((side) => {
test(`getOrders should return a list of orders > ${side}`, async () => {
const { orders, next, previous } = await mainAPI.getOrders({
const { orders, next } = await mainAPI.getOrders({
protocol: "seaport",
side,
tokenIds: BAYC_TOKEN_IDS,
assetContractAddress: BAYC_CONTRACT_ADDRESS,
});
orders.map((order) => expectValidOrder(order));
expect(next).to.not.be.undefined;
expect(previous).to.not.be.undefined;
});
});
});
21 changes: 8 additions & 13 deletions test/integration/postOrder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ suite("SDK: order posting", () => {
});

test("Post Listing - Mainnet", async function () {
// English auctions are no longer supported on OpenSea
this.skip();

if (!TOKEN_ADDRESS_MAINNET || !TOKEN_ID_MAINNET) {
this.skip();
}
Expand All @@ -72,6 +69,9 @@ suite("SDK: order posting", () => {
});

test("Post English Auction Listing - Mainnet", async function () {
// English auctions are no longer supported on OpenSea
this.skip();

if (!TOKEN_ADDRESS_MAINNET || !TOKEN_ID_MAINNET) {
this.skip();
}
Expand Down Expand Up @@ -102,26 +102,21 @@ suite("SDK: order posting", () => {
});

test.skip("Post Listing - Polygon", async function () {
// POL not currently supported on OS2, update this test to use WETH
// (will need to supply account with WETH and do approval to conduit)

if (!TOKEN_ADDRESS_POLYGON || !TOKEN_ID_POLYGON) {
this.skip();
}
const listing = {
accountAddress: walletAddress,
paymentTokenAddress: getWETHAddress(sdkPolygon.chain),
startAmount: +LISTING_AMOUNT * 1_000_000,
asset: {
tokenAddress: TOKEN_ADDRESS_POLYGON,
tokenId: TOKEN_ID_POLYGON,
tokenAddress: TOKEN_ADDRESS_POLYGON as string,
tokenId: TOKEN_ID_POLYGON as string,
},
expirationTime,
};
const order = await sdkPolygon.createListing(listing);
expectValidOrder(order);
});

test("Post Collection Offer - Mainnet", async () => {
test.skip("Post Collection Offer - Mainnet", async () => {
const collection = await sdk.api.getCollection("cool-cats-nft");
const paymentTokenAddress = getWETHAddress(sdk.chain);
const postOrderRequest = {
Expand All @@ -148,7 +143,7 @@ suite("SDK: order posting", () => {
);
});

test("Post Collection Offer - Polygon", async () => {
test.skip("Post Collection Offer - Polygon", async () => {
const collection = await sdkPolygon.api.getCollection("arttoken-1155-4");
const paymentTokenAddress = getWETHAddress(sdkPolygon.chain);
const postOrderRequest = {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ethers } from "ethers";
import { OpenSeaSDK } from "../../src/sdk";
import { Chain } from "../../src/types";
import {
MAINNET_API_KEY,
OPENSEA_API_KEY,
RPC_PROVIDER_MAINNET,
RPC_PROVIDER_POLYGON,
WALLET_PRIV_KEY,
Expand Down Expand Up @@ -36,7 +36,7 @@ export const sdk = new OpenSeaSDK(
walletMainnet,
{
chain: Chain.Mainnet,
apiKey: MAINNET_API_KEY,
apiKey: OPENSEA_API_KEY,
},
(line) => console.info(`MAINNET: ${line}`),
);
Expand All @@ -45,7 +45,7 @@ export const sdkPolygon = new OpenSeaSDK(
walletPolygon,
{
chain: Chain.Polygon,
apiKey: MAINNET_API_KEY,
apiKey: OPENSEA_API_KEY,
},
(line) => console.info(`POLYGON: ${line}`),
);
14 changes: 2 additions & 12 deletions test/sdk/getBalance.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import { assert } from "chai";
import { ethers } from "ethers";
import { suite, test } from "mocha";
import { OpenSeaSDK } from "../../src/index";
import { Chain, TokenStandard } from "../../src/types";
import { MAINNET_API_KEY, RPC_PROVIDER_MAINNET } from "../utils/constants";

const client = new OpenSeaSDK(
RPC_PROVIDER_MAINNET,
{
chain: Chain.Mainnet,
apiKey: MAINNET_API_KEY,
},
(line) => console.info(`MAINNET: ${line}`),
);
import { TokenStandard } from "../../src/types";
import { client } from "../utils/constants";

suite("SDK: getBalance", () => {
const accountAddress = "0x000000000000000000000000000000000000dEaD";
Expand Down
19 changes: 2 additions & 17 deletions test/sdk/misc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,11 @@ import {
SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS,
SHARED_STOREFRONT_ADDRESSES,
} from "../../src/constants";
import { OpenSeaSDK } from "../../src/index";
import { Chain } from "../../src/types";
import {
decodeTokenIds,
getAddressAfterRemappingSharedStorefrontAddressToLazyMintAdapterAddress,
} from "../../src/utils/utils";
import {
DAPPER_ADDRESS,
MAINNET_API_KEY,
RPC_PROVIDER_MAINNET,
} from "../utils/constants";

const client = new OpenSeaSDK(
RPC_PROVIDER_MAINNET,
{
chain: Chain.Mainnet,
apiKey: MAINNET_API_KEY,
},
(line) => console.info(`MAINNET: ${line}`),
);
import { BAYC_CONTRACT_ADDRESS, client } from "../utils/constants";

suite("SDK: misc", () => {
test("Instance has public methods", () => {
Expand All @@ -37,7 +22,7 @@ suite("SDK: misc", () => {
});

test("Checks that a non-shared storefront address is not remapped", async () => {
const address = DAPPER_ADDRESS;
const address = BAYC_CONTRACT_ADDRESS;
assert.equal(
getAddressAfterRemappingSharedStorefrontAddressToLazyMintAdapterAddress(
address,
Expand Down
17 changes: 3 additions & 14 deletions test/sdk/orders.spec.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
import { assert } from "chai";
import { suite, test } from "mocha";
import { OpenSeaSDK } from "../../src/index";
import { Chain } from "../../src/types";
import { MAINNET_API_KEY, RPC_PROVIDER_MAINNET } from "../utils/constants";

const client = new OpenSeaSDK(
RPC_PROVIDER_MAINNET,
{
chain: Chain.Mainnet,
apiKey: MAINNET_API_KEY,
},
(line) => console.info(`MAINNET: ${line}`),
);
import { client } from "../utils/constants";

suite("SDK: orders", () => {
test("Fungible tokens filter", async () => {
const manaAddress = "0x0f5d2fb29fb7d3cfee444a200298f468908cc942";
const manaPaymentToken = await client.api.getPaymentToken(manaAddress);
assert.isNotNull(manaPaymentToken);
assert.equal(manaPaymentToken.name, "Decentraland MANA");
assert.equal(manaPaymentToken.name, "Decentraland");
assert.equal(manaPaymentToken.address, manaAddress);
assert.equal(manaPaymentToken.decimals, 18);

const daiAddress = "0x6b175474e89094c44da98b954eedeac495271d0f";
const daiPaymentToken = await client.api.getPaymentToken(daiAddress);
assert.isNotNull(daiPaymentToken);
assert.equal(daiPaymentToken.name, "Dai Stablecoin");
assert.equal(daiPaymentToken.name, "Dai");
assert.equal(daiPaymentToken.decimals, 18);
});
});
39 changes: 27 additions & 12 deletions test/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { ethers } from "ethers";
import { OpenSeaSDK } from "../../src";
import { OpenSeaAPI } from "../../src/api";
import { Chain } from "../../src/types";

export const MAINNET_API_KEY = process.env.OPENSEA_API_KEY;
require("dotenv").config();

export const OPENSEA_API_KEY = process.env.OPENSEA_API_KEY;
export const WALLET_PRIV_KEY = process.env.WALLET_PRIV_KEY;

const ALCHEMY_API_KEY_MAINNET = process.env.ALCHEMY_API_KEY;
Expand All @@ -15,23 +18,35 @@ export const RPC_PROVIDER_POLYGON = new ethers.JsonRpcProvider(
`https://polygon-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY_POLYGON}`,
);

export const OFFER_AMOUNT = process.env.OFFER_AMOUNT ?? "0.004";
export const DAPPER_ADDRESS = "0x4819352bd7fadcCFAA8A2cDA4b2825a9ec51417c";
export const BAYC_CONTRACT_ADDRESS =
"0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d";
export const BAYC_TOKEN_IDS = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];

export const mainAPI = new OpenSeaAPI(
export const client = new OpenSeaSDK(
RPC_PROVIDER_MAINNET,
{
apiKey: MAINNET_API_KEY,
chain: Chain.Mainnet,
apiKey: OPENSEA_API_KEY,
},
process.env.DEBUG ? console.log : undefined,
(line) => console.info(`MAINNET: ${line}`),
);

export const testnetAPI = new OpenSeaAPI(
export const mainAPI = new OpenSeaAPI(
{
chain: Chain.Sepolia,
apiKey: OPENSEA_API_KEY,
chain: Chain.Mainnet,
},
process.env.DEBUG ? console.log : undefined,
);

export const OFFER_AMOUNT = process.env.OFFER_AMOUNT ?? "0.004";

export const BAYC_CONTRACT_ADDRESS =
"0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d";
export const BAYC_TOKEN_IDS = [
"9703",
"4049",
"5340",
"7354",
"2352",
"7112",
"3255",
"5532",
"4610",
];