Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.
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
22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
{
"name": "@thirdweb-dev/sdk",
"version": "2.3.2",
"version": "2.3.3-1",
"description": "The main thirdweb SDK.",
"repository": {
"type": "git",
"url": "git+https://github.com/thirdweb-dev/typescript-sdk.git"
},
"license": "Apache-2.0",
"source": "src/index.ts",
"main": "dist/index.js",
"types": "dist/src/index.d.ts",
"module": "dist/index.mjs",
"browser": "dist/index.js",
"unpkg": "dist/index.global.js",
"main": "dist/node/index.js",
"module": "dist/node/index.mjs",
"browser": "dist/browser/index.js",
"unpkg": "dist/browser/index.global.js",
"exports": {
"node": {
"module": "./dist/node/index.mjs",
"require": "./dist/node/index.js"
},
"default": "./dist/browser/index.mjs"
},
"files": [
"dist/**/*"
],
Expand Down Expand Up @@ -46,17 +52,14 @@
"@swc/core": "^1.2.177",
"@typechain/ethers-v5": "^10.0.0",
"@types/chai": "^4.3.1",
"@types/deep-equal": "^1.0.1",
"@types/deep-equal-in-any-order": "^1.0.1",
"@types/expect": "^24.3.0",
"@types/form-data": "^2.5.0",
"@types/mocha": "^9.1.1",
"@types/node": "^17.0.0",
"@types/uuid": "^8.3.3",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"chai": "^4.3.6",
"deep-equal": "^2.0.5",
"deep-equal-in-any-order": "^1.1.18",
"eslint": "^8",
"eslint-config-prettier": "^8.3.0",
Expand Down Expand Up @@ -84,6 +87,7 @@
"cbor": "^8.1.0",
"cross-fetch": "^3.1.5",
"eventemitter3": "^4.0.7",
"fast-deep-equal": "^3.1.3",
"form-data": "^4.0.0",
"merkletreejs": "^0.2.24",
"multihashes": "^4.0.3",
Expand Down
3 changes: 1 addition & 2 deletions src/core/classes/drop-claim-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { BigNumber, constants, ethers } from "ethers";
import { isNativeToken } from "../../common/currency";
import { ContractWrapper } from "./contract-wrapper";
import { Amount, ClaimCondition, ClaimConditionInput } from "../../types";
import deepEqual from "deep-equal";
import { ClaimEligibility } from "../../enums";
import { TransactionResult } from "../types";
import {
Expand All @@ -20,12 +19,12 @@ import {
transformResultToClaimCondition,
updateExistingClaimConditions,
} from "../../common/claim-conditions";

import { detectContractFeature } from "../../common/feature-detection";
import { PriceSchema } from "../../schema";
import { includesErrorMessage } from "../../common";
import ERC20Abi from "../../../abis/IERC20.json";
import { isNode } from "../../common/utils";
import deepEqual from "fast-deep-equal";

/**
* Manages claim conditions for NFT Drop contracts
Expand Down
2 changes: 1 addition & 1 deletion src/core/classes/drop-erc1155-claim-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BigNumber, BigNumberish, constants, ethers } from "ethers";
import { isNativeToken } from "../../common/currency";
import { ContractWrapper } from "./contract-wrapper";
import { ClaimCondition, ClaimConditionInput } from "../../types";
import deepEqual from "deep-equal";
import deepEqual from "fast-deep-equal";
import { ClaimEligibility } from "../../enums";
import { TransactionResult } from "../index";
import {
Expand Down
2 changes: 2 additions & 0 deletions src/core/classes/ipfs-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
} from "../helpers/storage";
import { IpfsUploader } from "../uploaders/ipfs-uploader";
import { UploadProgressEvent } from "../../types/events";
import { File } from "@web-std/file";
import FormData from "form-data";

/**
* IPFS Storage implementation, accepts custom IPFS gateways
Expand Down
1 change: 1 addition & 0 deletions src/core/classes/remote-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { UploadProgressEvent } from "../../types/events";
import { IStorage } from "../interfaces/IStorage";
import { UploadResult } from "../interfaces/IStorageUpload";
import { FileOrBuffer, JsonObject } from "../types";
import { File } from "@web-std/file";

/**
* Fetch and upload files to IPFS or any other storage.
Expand Down
1 change: 1 addition & 0 deletions src/core/helpers/storage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Json } from "../types";
import { File } from "@web-std/file";

/**
* Given a map of file hashes to ipfs uris, this function will hash
Expand Down
7 changes: 2 additions & 5 deletions src/core/uploaders/ipfs-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import {
import { FileOrBuffer } from "../types";
import { PINATA_IPFS_URL, TW_IPFS_SERVER_URL } from "../../constants/urls";
import { UploadProgressEvent } from "../../types/events";

if (!globalThis.FormData) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
globalThis.FormData = require("form-data");
}
import { File } from "@web-std/file";
import FormData from "form-data";

/**
* @internal
Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import "cross-fetch/polyfill";

export type { ContractType, NetworkOrSignerOrProvider } from "./core/types";
export type {
NFTMetadataInput,
Expand Down
5 changes: 0 additions & 5 deletions src/schema/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import { z } from "zod";
import { Json } from "../core/types";
import { isBrowser } from "../common/utils";

if (!globalThis.File) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
globalThis.File = require("@web-std/file").File;
}

export const MAX_BPS = 10_000;

const fileOrBufferUnion = isBrowser()
Expand Down
1 change: 1 addition & 0 deletions test/mock/MockStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { FileOrBuffer, JsonObject } from "../../src/core/types";
import { v4 as uuidv4 } from "uuid";
import { IStorage, NotFoundError } from "../../src";
import { UploadResult } from "../../src/core/interfaces/IStorageUpload";
import { File } from "@web-std/file";

export class MockStorage implements IStorage {
private objects: { [key: string]: any } = {};
Expand Down
32 changes: 29 additions & 3 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { defineConfig } from "tsup";
import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill";

export default defineConfig([
// build normal build
// build for node
{
name: "package",
name: "node",
entry: ["src/index.ts"],
sourcemap: true,
// we'll just manually "clean" the dist dir before running this (to avoid potential race conditions)
Expand All @@ -19,8 +19,33 @@ export default defineConfig([
treeshake: true,
globalName: "ThirdwebSDK",
format: ["cjs", "esm"],
outDir: "dist/node",
banner: {
js: `import "cross-fetch/dist/node-polyfill.js";`,
},
},
// build for browser
{
name: "browser",
entry: ["src/index.ts"],
sourcemap: true,
// we'll just manually "clean" the dist dir before running this (to avoid potential race conditions)
clean: false,
minify: true,
platform: "browser",
replaceNodeEnv: true,
// now required because not defaulted anymore
shims: true,
// use rollup for build to get smaller bundle sizes with tree shaking
treeshake: true,
globalName: "ThirdwebSDK",
format: ["cjs", "esm"],
// contains node-only functions, aka has to be bundled in for browser
noExternal: ["cbor"],
esbuildPlugins: [NodeModulesPolyfillPlugin()],
outDir: "dist/browser",
},
// also build iife (UMD build for <script> tag use)
// build for script-tag usage <script src="..."></script>
{
name: "script",
entry: ["src/index.ts"],
Expand All @@ -40,5 +65,6 @@ export default defineConfig([
// inject ThirdwebSDK into window
footer: { js: "window.ThirdwebSDK = window._thirdweb.ThirdwebSDK;" },
esbuildPlugins: [NodeModulesPolyfillPlugin()],
outDir: "dist/browser",
},
]);
Loading