Skip to content

Commit

Permalink
remove fetch polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls committed Sep 19, 2023
1 parent bc537e5 commit 88cc2cd
Show file tree
Hide file tree
Showing 47 changed files with 157 additions and 231 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"private": true,
"engines": {
"node": ">=16.7.0"
"node": ">=18.0.0"
},
"scripts": {
"preinstall": "npx only-allow pnpm",
Expand Down Expand Up @@ -56,10 +56,8 @@
},
"pnpm": {
"overrides": {
"cross-fetch@>=3.0.0 <3.1.5": ">=3.1.5",
"got@<11.8.5": ">=11.8.5",
"glob-parent@<5.1.2": ">=5.1.2",
"node-fetch@<2.6.7": ">=2.6.7",
"nth-check@<2.0.1": ">=2.0.1",
"socket.io-parser@>=4.0.4 <4.2.3": ">=4.2.3",
"fast-xml-parser@<4.2.4": ">=4.2.4",
Expand Down
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"got": "11.8.5",
"inquirer": "^8.2.3",
"js-yaml": "^4.1.0",
"node-fetch": "^3.3.2",
"open": "^8.4.0",
"prompts": "^2.4.2",
"rimraf": "^3.0.2",
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ export const getDependenciesForPython = (

export const getLatestVersion = async (packageName: string): Promise<any> => {
try {
const fetch = (await import("node-fetch")).default;
const url = `https://registry.npmjs.org/${packageName}`;
const response = await fetch(url);
if (!response.ok) {
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@
"bn.js": "^5.2.1",
"bs58": "^5.0.0",
"buffer": "^6.0.3",
"cross-fetch": "^3.1.8",
"eventemitter3": "^5.0.1",
"fast-deep-equal": "^3.1.3",
"merkletreejs": "^0.2.24",
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/src/evm/common/gas-price.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChainId } from "../constants/chains/ChainId";
import fetch from "cross-fetch";
import { BigNumber, utils, providers } from "ethers";
import { Mumbai, Polygon } from "@thirdweb-dev/chains";
import { isBrowser } from "./utils";
Expand Down
6 changes: 2 additions & 4 deletions packages/sdk/src/evm/common/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { Abi } from "../schema/contracts/custom";
import { Contract, utils, providers } from "ethers";
import { EtherscanResult, VerificationStatus } from "../types/verification";
import fetch from "cross-fetch";
import { ConstructorParamMap } from "../types/any-evm/deploy-data";
import { getChainProvider } from "../constants/urls";
import invariant from "tiny-invariant";
Expand Down Expand Up @@ -464,9 +463,8 @@ async function fetchDeployBytecodeFromPublishedContractMetadata(
getChainProvider("polygon", {}),
) as ContractPublisher;

const publishedMetadataUri = await contract.getPublishedUriFromCompilerUri(
compilerMetaUri,
);
const publishedMetadataUri =
await contract.getPublishedUriFromCompilerUri(compilerMetaUri);
if (publishedMetadataUri.length === 0) {
throw Error(
`Could not resolve published metadata URI from ${compilerMetaUri}`,
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/src/evm/core/classes/contract-wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ForwarderABI from "@thirdweb-dev/contracts-js/dist/abis/Forwarder.json";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import fetch from "cross-fetch";
import {
BaseContract,
BigNumber,
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/src/evm/core/classes/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
import { signEIP2612Permit } from "../../common/permit";
import { signTypedDataInternal } from "../../common/sign";
import ForwarderABI from "@thirdweb-dev/contracts-js/dist/abis/Forwarder.json";
import fetch from "cross-fetch";
import { BytesLike } from "ethers";
import { CONTRACT_ADDRESSES } from "../../constants/addresses/CONTRACT_ADDRESSES";
import { getContractAddressByChainId } from "../../constants/addresses/getContractAddressByChainId";
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/src/evm/integrations/thirdweb-checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ChainId } from "../constants/chains/ChainId";
import { ContractWrapper } from "../core/classes/contract-wrapper";
import { SignedPayload721WithQuantitySignature } from "../schema/contracts/common/signature";
import { PrebuiltEditionDrop, PrebuiltNFTDrop } from "../types/eips";
// import fetch from "cross-fetch";
import invariant from "tiny-invariant";

const PAPER_API_BASE = `https://paper.xyz/api` as const;
Expand Down
9 changes: 3 additions & 6 deletions packages/sdk/test/evm/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import {
} from "./utils";
import { IAccountCore, IAccountFactory } from "@thirdweb-dev/contracts-js";

global.fetch = /* @__PURE__ */ require("cross-fetch");

/* @__PURE__ */ describe("Accounts with account factory", function () {
describe("Accounts with account factory", function () {
let accountFactory: AccountFactory<IAccountFactory>;
let account: Account<IAccountCore>;

Expand Down Expand Up @@ -141,9 +139,8 @@ global.fetch = /* @__PURE__ */ require("cross-fetch");
"Correct admin for account.",
);

const associatedAccounts = await accountFactory.getAssociatedAccounts(
admin,
);
const associatedAccounts =
await accountFactory.getAssociatedAccounts(admin);

assert.isTrue(
associatedAccounts.length === 1,
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/evm/airdrop-erc1155.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
Forwarder__factory,
} from "@thirdweb-dev/contracts-js";

global.fetch = require("cross-fetch");

/**
* Throughout these tests, the admin wallet will be performing the airdrops.
*
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/evm/airdrop-erc20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import {
abi as TWCloneFactoryAbi,
} from "./metadata/TWCloneFactory";

global.fetch = require("cross-fetch");

let tokenAddress = NATIVE_TOKEN_ADDRESS;

/**
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/evm/airdrop-erc721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
abi as TWCloneFactoryAbi,
} from "./metadata/TWCloneFactory";

global.fetch = require("cross-fetch");

/**
* Throughout these tests, the admin wallet will be performing the airdrops.
*
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/evm/custom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import {
greeterCompilerMetadata,
} from "./mock/greeterContractMetadata";

global.fetch = require("cross-fetch");

describe("Custom Contracts", async () => {
let customContractAddress: string;
let nftContractAddress: string;
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/evm/edition-drop-v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import { assert, expect, use } from "chai";
import { BigNumber } from "ethers";
import invariant from "tiny-invariant";

global.fetch = require("cross-fetch");

const deepEqualInAnyOrder = require("deep-equal-in-any-order");

use(deepEqualInAnyOrder);
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/evm/edition-drop-v4.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { assert, expect, use } from "chai";
import { BigNumber } from "ethers";
import invariant from "tiny-invariant";

global.fetch = require("cross-fetch");

const deepEqualInAnyOrder = require("deep-equal-in-any-order");

use(deepEqualInAnyOrder);
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/evm/edition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { assert, expect } from "chai";
import { ethers } from "ethers";

global.fetch = require("cross-fetch");

describe("Edition Contract", async () => {
let bundleContract: Edition;
// let nftContract: NFTContract;
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/evm/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { MockContractPublisher__factory } from "@thirdweb-dev/contracts-js";
import { expect } from "chai";
import { ethers } from "ethers";

global.fetch = require("cross-fetch");

describe("Events", async () => {
let dropContract: NFTDrop;
let dropContract2: NFTDrop;
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/evm/feature-detection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { signers, sdk } from "./before-setup";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { expect } from "chai";

global.fetch = require("cross-fetch");

describe("Feature Detection", async () => {
let adminWallet: SignerWithAddress;

Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/evm/gasless.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { ethers, Wallet } from "ethers";

const RPC_URL = "https://rpc-mumbai.maticvigil.com/";

global.fetch = require("cross-fetch");

describe("Gasless Forwarder", async () => {
it.skip("should use sdk with biconomy", async () => {
const BUNDLE_DROP_ADDRESS = "0xEBed8e37a32660dbCeeeC19cCBb952b7d214f008";
Expand Down
47 changes: 18 additions & 29 deletions packages/sdk/test/evm/marketplace-v3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { expect, assert } from "chai";
import { BigNumber, ethers } from "ethers";

global.fetch = require("cross-fetch");

let tokenAddress = NATIVE_TOKEN_ADDRESS;

/**
Expand Down Expand Up @@ -230,9 +228,8 @@ describe("Marketplace V3", async () => {
isReservedListing: false,
});

const listing = await marketplaceContract.directListings.getListing(
listingId,
);
const listing =
await marketplaceContract.directListings.getListing(listingId);
expect(listing.currencyContractAddress.toLowerCase()).to.equal(
NATIVE_TOKEN_ADDRESS.toLowerCase(),
);
Expand Down Expand Up @@ -377,12 +374,10 @@ describe("Marketplace V3", async () => {
});

it("should return correct listing", async () => {
const listingOne = await marketplaceContract.directListings.getListing(
directListingOneId,
);
const listingTwo = await marketplaceContract.directListings.getListing(
directListingTwoId,
);
const listingOne =
await marketplaceContract.directListings.getListing(directListingOneId);
const listingTwo =
await marketplaceContract.directListings.getListing(directListingTwoId);
assert.equal(listingOne.tokenId.toString(), "0");
assert.equal(listingOne.asset.id.toString(), "0");
assert.equal(listingOne.asset.name, "Test 0");
Expand Down Expand Up @@ -468,9 +463,8 @@ describe("Marketplace V3", async () => {
});

it("should correctly cancel a direct listing", async () => {
const listing = await marketplaceContract.directListings.getListing(
directListingId,
);
const listing =
await marketplaceContract.directListings.getListing(directListingId);
assert.equal(listing.quantity.toString(), "1");
await marketplaceContract.directListings.cancelListing(directListingId);

Expand Down Expand Up @@ -652,12 +646,10 @@ describe("Marketplace V3", async () => {
});

it("should return correct auction", async () => {
const auctionOne = await marketplaceContract.englishAuctions.getAuction(
auctionOneId,
);
const auctionTwo = await marketplaceContract.englishAuctions.getAuction(
auctionTwoId,
);
const auctionOne =
await marketplaceContract.englishAuctions.getAuction(auctionOneId);
const auctionTwo =
await marketplaceContract.englishAuctions.getAuction(auctionTwoId);
assert.equal(auctionOne.tokenId.toString(), "2");
assert.equal(auctionOne.asset.id.toString(), "2");
assert.equal(auctionOne.asset.name, "Test 3");
Expand Down Expand Up @@ -700,9 +692,8 @@ describe("Marketplace V3", async () => {
await sdk.updateSignerOrProvider(bobWallet);
await marketplaceContract.englishAuctions.makeBid(auctionId, 0.3);

let winningBid = await marketplaceContract.englishAuctions.getWinningBid(
auctionId,
);
let winningBid =
await marketplaceContract.englishAuctions.getWinningBid(auctionId);

assert.equal(winningBid?.bidderAddress, bobWallet.address);
assert.equal(
Expand All @@ -715,9 +706,8 @@ describe("Marketplace V3", async () => {
await sdk.updateSignerOrProvider(samWallet);
await marketplaceContract.englishAuctions.makeBid(auctionId, 0.6);

winningBid = await marketplaceContract.englishAuctions.getWinningBid(
auctionId,
);
winningBid =
await marketplaceContract.englishAuctions.getWinningBid(auctionId);
assert.equal(winningBid?.bidderAddress, samWallet.address);
assert.equal(
winningBid?.bidAmount.toString(),
Expand Down Expand Up @@ -1105,9 +1095,8 @@ describe("Marketplace V3", async () => {
it("should not allow you to update an active direct listing", async () => {
const pricePerToken = ethers.utils.parseUnits("0.1");

const directListing = await marketplaceContract.directListings.getListing(
directListingId,
);
const directListing =
await marketplaceContract.directListings.getListing(directListingId);
assert.equal(
directListing.pricePerToken.toString(),
pricePerToken.toString(),
Expand Down
Loading

0 comments on commit 88cc2cd

Please sign in to comment.