thirdweb 5.59.1-nightly-21b032d1b845276817c2f8ada5566f4719a41ad0-20240927000336 → 5.59.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/social/profiles.js +2 -2
- package/dist/cjs/storage/download.js +3 -1
- package/dist/cjs/storage/download.js.map +1 -1
- package/dist/cjs/storage/upload/web-node.js +1 -4
- package/dist/cjs/storage/upload/web-node.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/userop.js +2 -0
- package/dist/cjs/wallets/smart/lib/userop.js.map +1 -1
- package/dist/cjs/wallets/wallet-connect/controller.js +8 -19
- package/dist/cjs/wallets/wallet-connect/controller.js.map +1 -1
- package/dist/esm/social/profiles.js +2 -2
- package/dist/esm/storage/download.js +3 -1
- package/dist/esm/storage/download.js.map +1 -1
- package/dist/esm/storage/upload/web-node.js +1 -4
- package/dist/esm/storage/upload/web-node.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/smart/lib/userop.js +2 -0
- package/dist/esm/wallets/smart/lib/userop.js.map +1 -1
- package/dist/esm/wallets/wallet-connect/controller.js +8 -19
- package/dist/esm/wallets/wallet-connect/controller.js.map +1 -1
- package/dist/types/social/profiles.d.ts +2 -2
- package/dist/types/storage/download.d.ts.map +1 -1
- package/dist/types/storage/upload/web-node.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/userop.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/extensions/erc1155/drop1155.test.ts +2 -11
- package/src/extensions/erc1155/token1155.test.ts +2 -11
- package/src/extensions/erc20/drop20.test.ts +2 -11
- package/src/extensions/erc721/drop721.test.ts +3 -11
- package/src/extensions/erc721/lazyMinting/write/createAndReveal.test.ts +2 -2
- package/src/extensions/erc721/write/mintTo.test.ts +2 -0
- package/src/extensions/marketplace/english-auctions/english-auctions.test.ts +3 -0
- package/src/extensions/marketplace/offers/offers.test.ts +3 -0
- package/src/extensions/modules/ClaimableERC1155/claimableERC1155.test.ts +2 -1
- package/src/extensions/modules/ClaimableERC20/claimableERC20.test.ts +2 -1
- package/src/extensions/modules/ClaimableERC721/claimableERC721.test.ts +2 -1
- package/src/extensions/modules/MintableERC1155/mintableERC1155.test.ts +2 -0
- package/src/extensions/modules/MintableERC20/mintableERC20.test.ts +2 -0
- package/src/extensions/modules/MintableERC721/mintableERC721.test.ts +2 -0
- package/src/extensions/modules/OpenEditionMetadataERC721/openEditionERC721.test.ts +2 -0
- package/src/extensions/permissions/permissions.test.ts +3 -0
- package/src/social/profiles.ts +2 -2
- package/src/storage/download.test.ts +130 -0
- package/src/storage/download.ts +3 -1
- package/src/storage/upload/web-node.test.ts +118 -0
- package/src/storage/upload/web-node.ts +1 -4
- package/src/version.ts +1 -1
- package/src/wallets/smart/lib/userop.ts +2 -0
- package/src/wallets/wallet-connect/controller.ts +26 -23
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userop.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/smart/lib/userop.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,+BAA+B,CAAC;AAOvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAI1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EACV,cAAc,EAEd,kBAAkB,EAClB,gBAA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;;GAkBG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IAC5C,KAAK,EAAE,KAAK,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;CACvB,GAAG,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,CA0C/C;AAiDD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,YAAY,EAAE,mBAAmB,EAAE,CAAC;IACpC,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC;IACvB,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,gDAkEA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "thirdweb",
|
3
|
-
"version": "5.59.
|
3
|
+
"version": "5.59.2",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "git+https://github.com/thirdweb-dev/js.git#main"
|
@@ -320,6 +320,7 @@
|
|
320
320
|
"expo-web-browser": "13.0.3",
|
321
321
|
"happy-dom": "^15.7.4",
|
322
322
|
"knip": "^5.30.5",
|
323
|
+
"msw": "^2.4.9",
|
323
324
|
"prettier": "^3.3.2",
|
324
325
|
"react": "18.3.1",
|
325
326
|
"react-native": "0.75.3",
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { VITALIK_WALLET } from "../../../test/src/addresses.js";
|
3
4
|
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
|
4
5
|
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
@@ -11,7 +12,6 @@ import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
|
11
12
|
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
|
12
13
|
import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js";
|
13
14
|
import { toEther } from "../../utils/units.js";
|
14
|
-
import { getContractMetadata } from "../common/read/getContractMetadata.js";
|
15
15
|
import { deployERC1155Contract } from "../prebuilts/deploy-erc1155.js";
|
16
16
|
import { balanceOf } from "./__generated__/IERC1155/read/balanceOf.js";
|
17
17
|
import { nextTokenIdToMint } from "./__generated__/IERC1155Enumerable/read/nextTokenIdToMint.js";
|
@@ -37,6 +37,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
37
37
|
client: TEST_CLIENT,
|
38
38
|
params: {
|
39
39
|
name: "Test DropERC1155",
|
40
|
+
contractURI: TEST_CONTRACT_URI,
|
40
41
|
},
|
41
42
|
type: "DropERC1155",
|
42
43
|
});
|
@@ -49,16 +50,6 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
49
50
|
// this deploys a contract, it may take some time
|
50
51
|
}, 60_000);
|
51
52
|
|
52
|
-
describe("Deployment", () => {
|
53
|
-
it("should deploy", async () => {
|
54
|
-
expect(contract).toBeDefined();
|
55
|
-
});
|
56
|
-
it("should have the correct name", async () => {
|
57
|
-
const metadata = await getContractMetadata({ contract });
|
58
|
-
expect(metadata.name).toBe("Test DropERC1155");
|
59
|
-
});
|
60
|
-
});
|
61
|
-
|
62
53
|
it("should allow for lazy minting tokens", async () => {
|
63
54
|
const mintTx = lazyMint({
|
64
55
|
contract,
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -7,7 +8,6 @@ import {
|
|
7
8
|
} from "../../../test/src/test-wallets.js";
|
8
9
|
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
9
10
|
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
|
10
|
-
import { getContractMetadata } from "../common/read/getContractMetadata.js";
|
11
11
|
import { deployERC1155Contract } from "../prebuilts/deploy-erc1155.js";
|
12
12
|
import { balanceOf } from "./__generated__/IERC1155/read/balanceOf.js";
|
13
13
|
import { totalSupply } from "./__generated__/IERC1155/read/totalSupply.js";
|
@@ -27,6 +27,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenERC1155", () => {
|
|
27
27
|
client: TEST_CLIENT,
|
28
28
|
params: {
|
29
29
|
name: "Test TokenERC1155",
|
30
|
+
contractURI: TEST_CONTRACT_URI,
|
30
31
|
},
|
31
32
|
type: "TokenERC1155",
|
32
33
|
});
|
@@ -39,16 +40,6 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenERC1155", () => {
|
|
39
40
|
// this deploys a contract, it may take some time
|
40
41
|
}, 60_000);
|
41
42
|
|
42
|
-
describe("Deployment", () => {
|
43
|
-
it("should deploy", async () => {
|
44
|
-
expect(contract).toBeDefined();
|
45
|
-
});
|
46
|
-
it("should have the correct name", async () => {
|
47
|
-
const metadata = await getContractMetadata({ contract });
|
48
|
-
expect(metadata.name).toBe("Test TokenERC1155");
|
49
|
-
});
|
50
|
-
});
|
51
|
-
|
52
43
|
it("should allow for minting tokens", async () => {
|
53
44
|
// initially no tokens minted
|
54
45
|
await expect(nextTokenIdToMint({ contract })).resolves.toBe(0n);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { VITALIK_WALLET } from "../../../test/src/addresses.js";
|
3
4
|
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
|
4
5
|
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
@@ -12,7 +13,6 @@ import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
|
12
13
|
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
|
13
14
|
import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js";
|
14
15
|
import { toEther } from "../../utils/units.js";
|
15
|
-
import { getContractMetadata } from "../common/read/getContractMetadata.js";
|
16
16
|
import { deployERC20Contract } from "../prebuilts/deploy-erc20.js";
|
17
17
|
import { getClaimConditions } from "./drops/read/getClaimConditions.js";
|
18
18
|
import { claimTo } from "./drops/write/claimTo.js";
|
@@ -35,6 +35,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
35
35
|
client: TEST_CLIENT,
|
36
36
|
params: {
|
37
37
|
name: "Test DropERC20",
|
38
|
+
contractURI: TEST_CONTRACT_URI,
|
38
39
|
},
|
39
40
|
type: "DropERC20",
|
40
41
|
});
|
@@ -47,16 +48,6 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
47
48
|
// this deploys a contract, it may take some time
|
48
49
|
}, 60_000);
|
49
50
|
|
50
|
-
describe("Deployment", () => {
|
51
|
-
it("should deploy", async () => {
|
52
|
-
expect(contract).toBeDefined();
|
53
|
-
});
|
54
|
-
it("should have the correct name", async () => {
|
55
|
-
const metadata = await getContractMetadata({ contract });
|
56
|
-
expect(metadata.name).toBe("Test DropERC20");
|
57
|
-
});
|
58
|
-
});
|
59
|
-
|
60
51
|
it("should allow to claim tokens", async () => {
|
61
52
|
await expect(
|
62
53
|
getBalance({ contract, address: TEST_ACCOUNT_A.address }),
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { VITALIK_WALLET } from "../../../test/src/addresses.js";
|
3
4
|
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
|
4
5
|
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
@@ -12,7 +13,6 @@ import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
|
12
13
|
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
|
13
14
|
import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js";
|
14
15
|
import { toEther } from "../../utils/units.js";
|
15
|
-
import { getContractMetadata } from "../common/read/getContractMetadata.js";
|
16
16
|
import { deployERC20Contract } from "../prebuilts/deploy-erc20.js";
|
17
17
|
import { deployERC721Contract } from "../prebuilts/deploy-erc721.js";
|
18
18
|
import { balanceOf } from "./__generated__/IERC721A/read/balanceOf.js";
|
@@ -40,6 +40,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
40
40
|
client: TEST_CLIENT,
|
41
41
|
params: {
|
42
42
|
name: "Test DropERC721",
|
43
|
+
contractURI: TEST_CONTRACT_URI,
|
43
44
|
},
|
44
45
|
type: "DropERC721",
|
45
46
|
});
|
@@ -50,6 +51,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
50
51
|
client: TEST_CLIENT,
|
51
52
|
params: {
|
52
53
|
name: "Test ERC20",
|
54
|
+
contractURI: TEST_CONTRACT_URI,
|
53
55
|
},
|
54
56
|
type: "TokenERC20",
|
55
57
|
});
|
@@ -68,16 +70,6 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
68
70
|
// this deploys a contract, it may take some time
|
69
71
|
}, 120_000);
|
70
72
|
|
71
|
-
describe("Deployment", () => {
|
72
|
-
it("should deploy", async () => {
|
73
|
-
expect(contract).toBeDefined();
|
74
|
-
});
|
75
|
-
it("should have the correct name", async () => {
|
76
|
-
const metadata = await getContractMetadata({ contract });
|
77
|
-
expect(metadata.name).toBe("Test DropERC721");
|
78
|
-
});
|
79
|
-
});
|
80
|
-
|
81
73
|
it("should allow for lazy minting tokens", async () => {
|
82
74
|
const mintTx = lazyMint({
|
83
75
|
contract,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { beforeAll, describe, it } from "vitest";
|
2
2
|
import { expect } from "vitest";
|
3
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
3
4
|
import { ANVIL_CHAIN } from "../../../../../test/src/chains.js";
|
4
5
|
import { TEST_CLIENT } from "../../../../../test/src/test-clients.js";
|
5
6
|
import { TEST_ACCOUNT_A } from "../../../../../test/src/test-wallets.js";
|
@@ -39,8 +40,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("createAndReveal", () => {
|
|
39
40
|
type: "DropERC721",
|
40
41
|
params: {
|
41
42
|
name: "Test NFT",
|
42
|
-
|
43
|
-
contractURI: "",
|
43
|
+
contractURI: TEST_CONTRACT_URI,
|
44
44
|
},
|
45
45
|
});
|
46
46
|
contract = getContract({
|
@@ -3,6 +3,7 @@ import { ANVIL_CHAIN } from "~test/chains.js";
|
|
3
3
|
import { TEST_CLIENT } from "~test/test-clients.js";
|
4
4
|
import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
|
5
5
|
|
6
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
6
7
|
import {
|
7
8
|
type ThirdwebContract,
|
8
9
|
getContract,
|
@@ -27,6 +28,7 @@ describe.runIf(!!process.env.TW_SECRET_KEY)("erc721 mintTo extension", () => {
|
|
27
28
|
type: "TokenERC721",
|
28
29
|
params: {
|
29
30
|
name: "NFTDrop",
|
31
|
+
contractURI: TEST_CONTRACT_URI,
|
30
32
|
},
|
31
33
|
});
|
32
34
|
contract = getContract({
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -37,6 +38,7 @@ describe.skip("Marketplace: English Auctions", () => {
|
|
37
38
|
client: TEST_CLIENT,
|
38
39
|
params: {
|
39
40
|
name: "TestMarketPlace",
|
41
|
+
contractURI: TEST_CONTRACT_URI,
|
40
42
|
},
|
41
43
|
});
|
42
44
|
marketplaceContract = getContract({
|
@@ -53,6 +55,7 @@ describe.skip("Marketplace: English Auctions", () => {
|
|
53
55
|
client: TEST_CLIENT,
|
54
56
|
params: {
|
55
57
|
name: "TestERC721",
|
58
|
+
contractURI: TEST_CONTRACT_URI,
|
56
59
|
},
|
57
60
|
});
|
58
61
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -43,6 +44,7 @@ describe.skip("Marketplace: Offers", () => {
|
|
43
44
|
client: TEST_CLIENT,
|
44
45
|
params: {
|
45
46
|
name: "TestMarketPlace",
|
47
|
+
contractURI: TEST_CONTRACT_URI,
|
46
48
|
},
|
47
49
|
});
|
48
50
|
marketplaceContract = getContract({
|
@@ -59,6 +61,7 @@ describe.skip("Marketplace: Offers", () => {
|
|
59
61
|
client: TEST_CLIENT,
|
60
62
|
params: {
|
61
63
|
name: "TestERC721",
|
64
|
+
contractURI: TEST_CONTRACT_URI,
|
62
65
|
},
|
63
66
|
});
|
64
67
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -29,7 +30,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ModularClaimableERC1155", () => {
|
|
29
30
|
core: "ERC1155",
|
30
31
|
params: {
|
31
32
|
name: "TestDropERC1155",
|
32
|
-
|
33
|
+
contractURI: TEST_CONTRACT_URI,
|
33
34
|
},
|
34
35
|
modules: [
|
35
36
|
ClaimableERC1155.module({
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -26,7 +27,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ModularDropERC20", () => {
|
|
26
27
|
core: "ERC20",
|
27
28
|
params: {
|
28
29
|
name: "TestDropERC20",
|
29
|
-
|
30
|
+
contractURI: TEST_CONTRACT_URI,
|
30
31
|
},
|
31
32
|
modules: [
|
32
33
|
ClaimableERC20.module({
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -27,7 +28,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ModularClaimableERC721", () => {
|
|
27
28
|
core: "ERC721",
|
28
29
|
params: {
|
29
30
|
name: "TestDropERC721",
|
30
|
-
|
31
|
+
contractURI: TEST_CONTRACT_URI,
|
31
32
|
},
|
32
33
|
modules: [
|
33
34
|
ClaimableERC721.module({
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -32,6 +33,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ModularTokenERC1155", () => {
|
|
32
33
|
params: {
|
33
34
|
name: "TestTokenERC1155",
|
34
35
|
symbol: "TT",
|
36
|
+
contractURI: TEST_CONTRACT_URI,
|
35
37
|
},
|
36
38
|
modules: [
|
37
39
|
MintableERC1155.module({
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -27,6 +28,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ModularTokenERC20", () => {
|
|
27
28
|
params: {
|
28
29
|
name: "TestTokenERC20",
|
29
30
|
symbol: "TT",
|
31
|
+
contractURI: TEST_CONTRACT_URI,
|
30
32
|
},
|
31
33
|
modules: [
|
32
34
|
MintableERC20.module({
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -31,6 +32,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ModularTokenERC721", () => {
|
|
31
32
|
params: {
|
32
33
|
name: "TestTokenERC721",
|
33
34
|
symbol: "TT",
|
35
|
+
contractURI: TEST_CONTRACT_URI,
|
34
36
|
},
|
35
37
|
modules: [
|
36
38
|
MintableERC721.module({
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -30,6 +31,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ModularOpenEditionERC721", () => {
|
|
30
31
|
params: {
|
31
32
|
name: "TestDropERC721",
|
32
33
|
symbol: "TT",
|
34
|
+
contractURI: TEST_CONTRACT_URI,
|
33
35
|
},
|
34
36
|
modules: [
|
35
37
|
ClaimableERC721.module({
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -22,6 +23,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Permissions", () => {
|
|
22
23
|
client: TEST_CLIENT,
|
23
24
|
params: {
|
24
25
|
name: "PermissionsErc20",
|
26
|
+
contractURI: TEST_CONTRACT_URI,
|
25
27
|
},
|
26
28
|
type: "TokenERC20",
|
27
29
|
});
|
@@ -196,6 +198,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("PermissionsEnumerable", () => {
|
|
196
198
|
client: TEST_CLIENT,
|
197
199
|
params: {
|
198
200
|
name: "PermissionsErc20",
|
201
|
+
contractURI: TEST_CONTRACT_URI,
|
199
202
|
},
|
200
203
|
type: "TokenERC20",
|
201
204
|
});
|
package/src/social/profiles.ts
CHANGED
@@ -12,8 +12,8 @@ import type { SocialProfile } from "./types.js";
|
|
12
12
|
*
|
13
13
|
* @example
|
14
14
|
* ```ts
|
15
|
-
* import {
|
16
|
-
* const profiles = await
|
15
|
+
* import { getSocialProfiles } from "thirdweb/social";
|
16
|
+
* const profiles = await getSocialProfiles({
|
17
17
|
* address: "0x...",
|
18
18
|
* client,
|
19
19
|
* });
|
@@ -0,0 +1,130 @@
|
|
1
|
+
import { http, HttpResponse } from "msw";
|
2
|
+
import { setupServer } from "msw/node";
|
3
|
+
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
|
4
|
+
import { handlers as storageHandlers } from "../../test/src/mocks/storage.js";
|
5
|
+
import type { ThirdwebClient } from "../client/client.js";
|
6
|
+
import { download } from "./download.js";
|
7
|
+
|
8
|
+
const server = setupServer(...storageHandlers);
|
9
|
+
|
10
|
+
describe("download", () => {
|
11
|
+
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
12
|
+
afterAll(() => server.close());
|
13
|
+
afterEach(() => server.resetHandlers());
|
14
|
+
|
15
|
+
const mockClient: ThirdwebClient = {
|
16
|
+
clientId: "test-client-id",
|
17
|
+
secretKey: "test-secret-key",
|
18
|
+
};
|
19
|
+
|
20
|
+
it("should download IPFS file successfully", async () => {
|
21
|
+
const mockContent = "Test IPFS content";
|
22
|
+
server.use(
|
23
|
+
http.get("https://*.ipfscdn.io/ipfs/:hash/:id", () => {
|
24
|
+
return new HttpResponse(mockContent, {
|
25
|
+
status: 200,
|
26
|
+
headers: { "Content-Type": "text/plain" },
|
27
|
+
});
|
28
|
+
}),
|
29
|
+
);
|
30
|
+
|
31
|
+
const result = await download({
|
32
|
+
client: mockClient,
|
33
|
+
uri: "ipfs://QmTest1234567890TestHash/file.txt",
|
34
|
+
});
|
35
|
+
|
36
|
+
expect(result.ok).toBe(true);
|
37
|
+
expect(await result.text()).toBe(mockContent);
|
38
|
+
});
|
39
|
+
|
40
|
+
it("should download Arweave file successfully", async () => {
|
41
|
+
const mockContent = "Test Arweave content";
|
42
|
+
server.use(
|
43
|
+
http.get("https://arweave.net/:id", () => {
|
44
|
+
return new HttpResponse(mockContent, {
|
45
|
+
status: 200,
|
46
|
+
headers: { "Content-Type": "text/plain" },
|
47
|
+
});
|
48
|
+
}),
|
49
|
+
);
|
50
|
+
|
51
|
+
const result = await download({
|
52
|
+
client: mockClient,
|
53
|
+
uri: "ar://TestArweaveTransactionId",
|
54
|
+
});
|
55
|
+
|
56
|
+
expect(result.ok).toBe(true);
|
57
|
+
expect(await result.text()).toBe(mockContent);
|
58
|
+
});
|
59
|
+
|
60
|
+
it("should download HTTP file successfully", async () => {
|
61
|
+
const mockContent = "Test HTTP content";
|
62
|
+
server.use(
|
63
|
+
http.get("https://example.com/file.txt", () => {
|
64
|
+
return new HttpResponse(mockContent, {
|
65
|
+
status: 200,
|
66
|
+
headers: { "Content-Type": "text/plain" },
|
67
|
+
});
|
68
|
+
}),
|
69
|
+
);
|
70
|
+
|
71
|
+
const result = await download({
|
72
|
+
client: mockClient,
|
73
|
+
uri: "https://example.com/file.txt",
|
74
|
+
});
|
75
|
+
|
76
|
+
expect(result.ok).toBe(true);
|
77
|
+
expect(await result.text()).toBe(mockContent);
|
78
|
+
});
|
79
|
+
|
80
|
+
it("should throw an error for failed downloads", async () => {
|
81
|
+
server.use(
|
82
|
+
http.get("https://*.ipfscdn.io/ipfs/:hash/:id", () => {
|
83
|
+
return new HttpResponse(null, { status: 404 });
|
84
|
+
}),
|
85
|
+
);
|
86
|
+
|
87
|
+
await expect(
|
88
|
+
download({
|
89
|
+
client: mockClient,
|
90
|
+
uri: "ipfs://QmTest1234567890TestHash/nonexistent.txt",
|
91
|
+
}),
|
92
|
+
).rejects.toThrow("Failed to download file: Not Found");
|
93
|
+
});
|
94
|
+
|
95
|
+
it("should respect custom timeout", async () => {
|
96
|
+
server.use(
|
97
|
+
http.get("https://*.ipfscdn.io/ipfs/:hash/:id", async () => {
|
98
|
+
await new Promise((resolve) => setTimeout(resolve, 10000));
|
99
|
+
return new HttpResponse("Delayed response", { status: 200 });
|
100
|
+
}),
|
101
|
+
);
|
102
|
+
|
103
|
+
await expect(
|
104
|
+
download({
|
105
|
+
client: mockClient,
|
106
|
+
uri: "ipfs://QmTest1234567890TestHash/file.txt",
|
107
|
+
requestTimeoutMs: 500,
|
108
|
+
}),
|
109
|
+
).rejects.toThrow("This operation was aborted");
|
110
|
+
});
|
111
|
+
|
112
|
+
it("should respect custom client timeout", async () => {
|
113
|
+
server.use(
|
114
|
+
http.get("https://*.ipfscdn.io/ipfs/:hash/:id", async () => {
|
115
|
+
await new Promise((resolve) => setTimeout(resolve, 10000));
|
116
|
+
return new HttpResponse("Delayed response", { status: 200 });
|
117
|
+
}),
|
118
|
+
);
|
119
|
+
|
120
|
+
await expect(
|
121
|
+
download({
|
122
|
+
client: {
|
123
|
+
...mockClient,
|
124
|
+
config: { storage: { fetch: { requestTimeoutMs: 500 } } },
|
125
|
+
},
|
126
|
+
uri: "ipfs://QmTest1234567890TestHash/file.txt",
|
127
|
+
}),
|
128
|
+
).rejects.toThrow("This operation was aborted");
|
129
|
+
});
|
130
|
+
});
|
package/src/storage/download.ts
CHANGED
@@ -76,7 +76,9 @@ export async function download(options: DownloadOptions) {
|
|
76
76
|
keepalive: options.client.config?.storage?.fetch?.keepalive,
|
77
77
|
headers: options.client.config?.storage?.fetch?.headers,
|
78
78
|
requestTimeoutMs:
|
79
|
-
options.
|
79
|
+
options.requestTimeoutMs ??
|
80
|
+
options.client.config?.storage?.fetch?.requestTimeoutMs ??
|
81
|
+
60000,
|
80
82
|
});
|
81
83
|
|
82
84
|
if (!res.ok) {
|
@@ -0,0 +1,118 @@
|
|
1
|
+
import { http, HttpResponse } from "msw";
|
2
|
+
import { setupServer } from "msw/node";
|
3
|
+
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
|
4
|
+
import { handlers as storageHandlers } from "../../../test/src/mocks/storage.js";
|
5
|
+
import type { ThirdwebClient } from "../../client/client.js";
|
6
|
+
import { getThirdwebDomains } from "../../utils/domains.js";
|
7
|
+
import { uploadBatch } from "./web-node.js";
|
8
|
+
|
9
|
+
const server = setupServer(...storageHandlers);
|
10
|
+
|
11
|
+
describe("uploadBatch", () => {
|
12
|
+
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
13
|
+
afterAll(() => server.close());
|
14
|
+
afterEach(() => server.resetHandlers());
|
15
|
+
|
16
|
+
const mockClient: ThirdwebClient = {
|
17
|
+
clientId: "test-client-id",
|
18
|
+
secretKey: "test-secret-key",
|
19
|
+
};
|
20
|
+
|
21
|
+
it("should upload files successfully", async () => {
|
22
|
+
const form = new FormData();
|
23
|
+
form.append("file1", new Blob(["test content"]), "file1.txt");
|
24
|
+
form.append("file2", new Blob(["another test"]), "file2.txt");
|
25
|
+
|
26
|
+
const result = await uploadBatch(mockClient, form, [
|
27
|
+
"file1.txt",
|
28
|
+
"file2.txt",
|
29
|
+
]);
|
30
|
+
|
31
|
+
expect(result).toHaveLength(2);
|
32
|
+
expect(result[0]).toBe("ipfs://QmTest1234567890TestHash/file1.txt");
|
33
|
+
expect(result[1]).toBe("ipfs://QmTest1234567890TestHash/file2.txt");
|
34
|
+
});
|
35
|
+
|
36
|
+
it("should throw an error for unauthorized access", async () => {
|
37
|
+
server.use(
|
38
|
+
http.post(
|
39
|
+
`https://${getThirdwebDomains().storage}/ipfs/upload`,
|
40
|
+
() => new HttpResponse(null, { status: 401 }),
|
41
|
+
),
|
42
|
+
);
|
43
|
+
|
44
|
+
const form = new FormData();
|
45
|
+
form.append("file", new Blob(["test"]), "file.txt");
|
46
|
+
|
47
|
+
await expect(uploadBatch(mockClient, form, ["file.txt"])).rejects.toThrow(
|
48
|
+
"Unauthorized - You don't have permission to use this service.",
|
49
|
+
);
|
50
|
+
});
|
51
|
+
|
52
|
+
it("should throw an error for storage limit reached", async () => {
|
53
|
+
server.use(
|
54
|
+
http.post(
|
55
|
+
`https://${getThirdwebDomains().storage}/ipfs/upload`,
|
56
|
+
() => new HttpResponse(null, { status: 402 }),
|
57
|
+
),
|
58
|
+
);
|
59
|
+
|
60
|
+
const form = new FormData();
|
61
|
+
form.append("file", new Blob(["test"]), "file.txt");
|
62
|
+
|
63
|
+
await expect(uploadBatch(mockClient, form, ["file.txt"])).rejects.toThrow(
|
64
|
+
"You have reached your storage limit. Please add a valid payment method to continue using the service.",
|
65
|
+
);
|
66
|
+
});
|
67
|
+
|
68
|
+
it("should throw an error for forbidden access", async () => {
|
69
|
+
server.use(
|
70
|
+
http.post(
|
71
|
+
`https://${getThirdwebDomains().storage}/ipfs/upload`,
|
72
|
+
() => new HttpResponse(null, { status: 403 }),
|
73
|
+
),
|
74
|
+
);
|
75
|
+
|
76
|
+
const form = new FormData();
|
77
|
+
form.append("file", new Blob(["test"]), "file.txt");
|
78
|
+
|
79
|
+
await expect(uploadBatch(mockClient, form, ["file.txt"])).rejects.toThrow(
|
80
|
+
"Forbidden - You don't have permission to use this service.",
|
81
|
+
);
|
82
|
+
});
|
83
|
+
|
84
|
+
it("should throw an error for other HTTP errors", async () => {
|
85
|
+
server.use(
|
86
|
+
http.post(
|
87
|
+
`https://${getThirdwebDomains().storage}/ipfs/upload`,
|
88
|
+
() =>
|
89
|
+
new HttpResponse(null, {
|
90
|
+
status: 500,
|
91
|
+
statusText: "Internal Server Error",
|
92
|
+
}),
|
93
|
+
),
|
94
|
+
);
|
95
|
+
|
96
|
+
const form = new FormData();
|
97
|
+
form.append("file", new Blob(["test"]), "file.txt");
|
98
|
+
|
99
|
+
await expect(uploadBatch(mockClient, form, ["file.txt"])).rejects.toThrow(
|
100
|
+
"Failed to upload files to IPFS - 500 - Internal Server Error",
|
101
|
+
);
|
102
|
+
});
|
103
|
+
|
104
|
+
it("should throw an error for missing CID", async () => {
|
105
|
+
server.use(
|
106
|
+
http.post(`https://${getThirdwebDomains().storage}/ipfs/upload`, () =>
|
107
|
+
HttpResponse.json({}),
|
108
|
+
),
|
109
|
+
);
|
110
|
+
|
111
|
+
const form = new FormData();
|
112
|
+
form.append("file", new Blob(["test"]), "file.txt");
|
113
|
+
|
114
|
+
await expect(uploadBatch(mockClient, form, ["file.txt"])).rejects.toThrow(
|
115
|
+
"Failed to upload files to IPFS - Bad CID",
|
116
|
+
);
|
117
|
+
});
|
118
|
+
});
|