Skip to content

Commit

Permalink
[thirdweb] chore: Update vitest to 3.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquim-verges committed Feb 27, 2025
1 parent 40784a2 commit 94dc47c
Show file tree
Hide file tree
Showing 26 changed files with 54 additions and 180 deletions.
14 changes: 4 additions & 10 deletions packages/service-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
},
"typesVersions": {
"*": {
"node": [
"./dist/types/node/index.d.ts"
],
"cf-worker": [
"./dist/types/cf-worker/index.d.ts"
]
"node": ["./dist/types/node/index.d.ts"],
"cf-worker": ["./dist/types/cf-worker/index.d.ts"]
}
},
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/pay",
Expand All @@ -40,9 +36,7 @@
"url": "https://github.com/thirdweb-dev/js/issues"
},
"author": "thirdweb eng <[email protected]>",
"files": [
"dist/"
],
"files": ["dist/"],
"sideEffects": false,
"dependencies": {
"@confluentinc/kafka-javascript": "^1.2.0",
Expand All @@ -53,7 +47,7 @@
"@cloudflare/workers-types": "4.20250224.0",
"@types/node": "22.13.5",
"typescript": "5.7.3",
"vitest": "3.0.7"
"vitest": "3.0.5"
},
"scripts": {
"format": "biome format ./src --write",
Expand Down
6 changes: 3 additions & 3 deletions packages/thirdweb/src/contract/actions/resolve-abi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ it("should throw error if contract bytecode is 0x", async () => {
client: TEST_CLIENT,
chain: FORKED_ETHEREUM_CHAIN,
});
await expect(() =>
resolveAbiFromBytecode(wrongContract),
).rejects.toThrowError("Failed to load contract bytecode");
await expect(resolveAbiFromBytecode(wrongContract)).rejects.toThrowError(
"Failed to load contract bytecode",
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getCurrencyMetadata } from "./getCurrencyMetadata.js";

describe("getCurrencyMetadata", () => {
it("should throw if not a valid ERC20 contract", async () => {
await expect(() =>
await expect(
getCurrencyMetadata({ contract: DOODLES_CONTRACT }),
).rejects.toThrowError("Invalid currency token");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
});

it("should throw error if totalSupply and nextTokenIdToMint are not supported", async () => {
await expect(() =>
await expect(
getNFTs({ contract: UNISWAPV3_FACTORY_CONTRACT }),
).rejects.toThrowError(
"Contract requires either `nextTokenIdToMint` or `totalSupply` function available to determine the next token ID to mint",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getOwnedTokenIds", () => {
it("should throw if tokenOfOwnerByIndex or tokensOfOwner not supported", async () => {
// We know current Lens contract on Polygon doesn't have this.
const contract = UNISWAPV3_FACTORY_CONTRACT;
await expect(() =>
await expect(
getOwnedTokenIds({ contract, owner: TEST_ACCOUNT_B.address }),
).rejects.toThrowError(
`The contract at ${contract.address} on chain ${contract.chain.id} does not support the tokenOfOwnerByIndex or tokensOfOwner interface`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("resolve lens address", () => {
});

it("should throw if passed an invalid lens handle", async () => {
await expect(() =>
await expect(
resolveAddress({ client: TEST_CLIENT, name: "vitalik.eth" }),
).rejects.toThrowError(
"Could not fetch the wallet address for lens handle: vitalik.eth",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const account = TEST_ACCOUNT_B;

describe.runIf(process.env.TW_SECRET_KEY)("deploy-voteERC20 contract", () => {
it("should throw if passed an non-integer-like value to minVoteQuorumRequiredPercent", async () => {
await expect(() =>
await expect(
deployVoteContract({
account,
client: TEST_CLIENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
});

it("should throw an error with a non-existent domain name", async () => {
await expect(() =>
await expect(
resolveAddress({
name: "thirdwebsdk.thissuredoesnotexist",
client: TEST_CLIENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
});

it("should throw error on addresses that dont own any UD", async () => {
await expect(() =>
await expect(
resolveName({ client: TEST_CLIENT, address: TEST_ACCOUNT_D.address }),
).rejects.toThrowError(
`Failed to retrieve domain for address: ${TEST_ACCOUNT_D.address}. Make sure you have set the Reverse Resolution address for your domain at https://unstoppabledomains.com/manage?page=reverseResolution&domain=your-domain`,
Expand Down
8 changes: 4 additions & 4 deletions packages/thirdweb/src/pay/convert/cryptoToFiat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
});

it("should throw error for testnet chain (because testnets are not supported", async () => {
await expect(() =>
await expect(
convertCryptoToFiat({
chain: sepolia,
fromTokenAddress: NATIVE_TOKEN_ADDRESS,
Expand All @@ -66,7 +66,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
});

it("should throw error if fromTokenAddress is set to an invalid EVM address", async () => {
await expect(() =>
await expect(
convertCryptoToFiat({
chain: ethereum,
fromTokenAddress: "haha",
Expand All @@ -80,7 +80,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
});

it("should throw error if fromTokenAddress is set to a wallet address", async () => {
await expect(() =>
await expect(
convertCryptoToFiat({
chain: base,
fromTokenAddress: TEST_ACCOUNT_A.address,
Expand All @@ -99,7 +99,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
status: 400,
statusText: "Bad Request",
});
await expect(() =>
await expect(
convertCryptoToFiat({
chain: base,
fromTokenAddress: NATIVE_TOKEN_ADDRESS,
Expand Down
8 changes: 4 additions & 4 deletions packages/thirdweb/src/pay/convert/fiatToCrypto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: fiatToCrypto", () => {
});

it("should throw error for testnet chain (because testnets are not supported", async () => {
await expect(() =>
await expect(
convertFiatToCrypto({
chain: sepolia,
to: NATIVE_TOKEN_ADDRESS,
Expand All @@ -67,7 +67,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: fiatToCrypto", () => {
});

it("should throw error if `to` is set to an invalid EVM address", async () => {
await expect(() =>
await expect(
convertFiatToCrypto({
chain: ethereum,
to: "haha",
Expand All @@ -81,7 +81,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: fiatToCrypto", () => {
});

it("should throw error if `to` is set to a wallet address", async () => {
await expect(() =>
await expect(
convertFiatToCrypto({
chain: base,
to: TEST_ACCOUNT_A.address,
Expand All @@ -100,7 +100,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: fiatToCrypto", () => {
status: 400,
statusText: "Bad Request",
});
await expect(() =>
await expect(
convertFiatToCrypto({
chain: ethereum,
to: NATIVE_TOKEN_ADDRESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
});

it("`loadAccountBalance` should throw if `chain` is not passed", async () => {
await expect(() =>
await expect(
loadAccountBalance({ client: TEST_CLIENT, address: VITALIK_WALLET }),
).rejects.toThrowError("chain is required");
});

it("`loadAccountBalance` should throw if `tokenAddress` is mistakenly passed as native token", async () => {
await expect(() =>
await expect(
loadAccountBalance({
client: TEST_CLIENT,
address: VITALIK_WALLET,
Expand All @@ -92,7 +92,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
});

it("`loadAccountBalance` should throw if `address` is not a valid evm address", async () => {
await expect(() =>
await expect(
loadAccountBalance({
client: TEST_CLIENT,
// biome-ignore lint/suspicious/noExplicitAny: for the test
Expand All @@ -103,7 +103,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
});

it("`loadAccountBalance` should throw if `tokenAddress` is passed but is not a valid evm address", async () => {
await expect(() =>
await expect(
loadAccountBalance({
client: TEST_CLIENT,
address: VITALIK_WALLET,
Expand Down Expand Up @@ -133,7 +133,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
});

it("`loadAccountBalance` should throw if failed to load tokenBalance (native token)", async () => {
await expect(() =>
await expect(
loadAccountBalance({
client: TEST_CLIENT,
address: VITALIK_WALLET,
Expand All @@ -145,7 +145,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
});

it("`loadAccountBalance` should throw if failed to load tokenBalance (erc20 token)", async () => {
await expect(() =>
await expect(
loadAccountBalance({
client: TEST_CLIENT,
address: VITALIK_WALLET,
Expand All @@ -158,7 +158,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
});

it("if fetching fiat value then it should throw if failed to resolve (native token)", async () => {
await expect(() =>
await expect(
loadAccountBalance({
client: TEST_CLIENT,
address: VITALIK_WALLET,
Expand All @@ -171,7 +171,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
});

it("if fetching fiat value then it should throw if failed to resolve (erc20 token)", async () => {
await expect(() =>
await expect(
loadAccountBalance({
client: TEST_CLIENT,
address: VITALIK_WALLET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ChainIcon", () => {
});

it("fetchChainIcon should throw error if failed to resolve chain icon", async () => {
await expect(() =>
await expect(
fetchChainIcon({ chain: defineChain(-1), client }),
).rejects.toThrowError("Failed to resolve icon for chain");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFTDescription", () => {
});

it("fetchNftDescription should throw error if failed to resolve nft info", async () => {
await expect(() =>
await expect(
fetchNftDescription({
contract: UNISWAPV3_FACTORY_CONTRACT,
tokenId: 0n,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFTMedia", () => {
});

it("fetchNftMedia should throw error if failed to resolve nft info", async () => {
await expect(() =>
await expect(
fetchNftMedia({
contract: UNISWAPV3_FACTORY_CONTRACT,
tokenId: 0n,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFTName", () => {
});

it("fetchNftName should throw error if failed to resolve nft info", async () => {
await expect(() =>
await expect(
fetchNftName({
contract: UNISWAPV3_FACTORY_CONTRACT,
tokenId: 0n,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("getNFTInfo", () => {
});

it("should throw error if failed to load nft info", async () => {
await expect(() =>
await expect(
getNFTInfo({ contract: UNISWAPV3_FACTORY_CONTRACT, tokenId: 0n }),
).rejects.toThrowError("Failed to load NFT metadata");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenName component", () => {
});

it("fetchTokenName should throw in the end where all fallback solutions failed to resolve to any name", async () => {
await expect(() =>
await expect(
fetchTokenName({
address: UNISWAPV3_FACTORY_CONTRACT.address,
client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenSymbol component", () => {
});

it("fetchTokenSymbol should throw in the end where all fallback solutions failed to resolve to any symbol", async () => {
await expect(() =>
await expect(
fetchTokenSymbol({
address: UNISWAPV3_FACTORY_CONTRACT.address,
client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("WalletIcon", () => {
});

it("should throw error if WalletId is not supported", async () => {
await expect(() =>
await expect(
// @ts-ignore For test
fetchWalletImage({ id: "__undefined__" }),
).rejects.toThrowError("Wallet with id __undefined__ not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("WalletName", () => {

it("fetchWalletName should throw error if failed to get name", async () => {
// @ts-ignore for test
await expect(() => fetchWalletName({ id: "test___" })).rejects.toThrowError(
await expect(fetchWalletName({ id: "test___" })).rejects.toThrowError(
"Wallet with id test___ not found",
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ClaimButton", () => {
},
});
const contract = getContract({ address, chain, client });
await expect(() =>
await expect(
getERC20ClaimTo({
contract,
account,
Expand Down
3 changes: 2 additions & 1 deletion packages/thirdweb/src/storage/upload/web-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export async function uploadBatch<const TFiles extends UploadableFile[]>(
method: "POST",
headers,
body: form,
requestTimeoutMs: client.config?.storage?.fetch?.requestTimeoutMs,
requestTimeoutMs:
client.config?.storage?.fetch?.requestTimeoutMs || 120000,
},
);

Expand Down
2 changes: 1 addition & 1 deletion packages/thirdweb/src/transaction/actions/encode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe("transaction: encode", () => {
// @ts-ignore Intentionally for the test purpose
extraCallData: "I'm a cat",
});
await expect(() => getExtraCallDataFromTx(tx)).rejects.toThrowError(
await expect(getExtraCallDataFromTx(tx)).rejects.toThrowError(
"Invalid extra calldata - must be a hex string",
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ describe("fetchTokenMetadata", () => {
tokenId: 0n,
tokenUri: invalidBase64Json,
};
await expect(() => fetchTokenMetadata(options)).rejects.toThrowError();
await expect(fetchTokenMetadata(options)).rejects.toThrowError();
});
});
Loading

0 comments on commit 94dc47c

Please sign in to comment.