thirdweb 5.89.1 → 5.90.0
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/chains/constants.js +17 -2
- package/dist/cjs/chains/constants.js.map +1 -1
- package/dist/cjs/exports/wallets/smart.js +2 -1
- package/dist/cjs/exports/wallets/smart.js.map +1 -1
- package/dist/cjs/storage/download.js +16 -0
- package/dist/cjs/storage/download.js.map +1 -1
- package/dist/cjs/storage/mock.js +46 -0
- package/dist/cjs/storage/mock.js.map +1 -0
- package/dist/cjs/storage/upload/web-node.js +6 -1
- package/dist/cjs/storage/upload/web-node.js.map +1 -1
- package/dist/cjs/transaction/actions/estimate-gas-cost.js +1 -1
- package/dist/cjs/transaction/actions/estimate-gas-cost.js.map +1 -1
- package/dist/cjs/utils/process.js +4 -1
- package/dist/cjs/utils/process.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/manager/index.js +1 -1
- package/dist/cjs/wallets/manager/index.js.map +1 -1
- package/dist/cjs/wallets/smart/index.js +1 -0
- package/dist/cjs/wallets/smart/index.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/bundler.js +75 -0
- package/dist/cjs/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/userop.js +35 -13
- package/dist/cjs/wallets/smart/lib/userop.js.map +1 -1
- package/dist/esm/chains/constants.js +17 -2
- package/dist/esm/chains/constants.js.map +1 -1
- package/dist/esm/exports/wallets/smart.js +1 -1
- package/dist/esm/exports/wallets/smart.js.map +1 -1
- package/dist/esm/storage/download.js +16 -0
- package/dist/esm/storage/download.js.map +1 -1
- package/dist/esm/storage/mock.js +42 -0
- package/dist/esm/storage/mock.js.map +1 -0
- package/dist/esm/storage/upload/web-node.js +6 -1
- package/dist/esm/storage/upload/web-node.js.map +1 -1
- package/dist/esm/transaction/actions/estimate-gas-cost.js +1 -1
- package/dist/esm/transaction/actions/estimate-gas-cost.js.map +1 -1
- package/dist/esm/utils/process.js +3 -0
- package/dist/esm/utils/process.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/manager/index.js +1 -1
- package/dist/esm/wallets/manager/index.js.map +1 -1
- package/dist/esm/wallets/smart/index.js +1 -1
- package/dist/esm/wallets/smart/index.js.map +1 -1
- package/dist/esm/wallets/smart/lib/bundler.js +74 -0
- package/dist/esm/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/esm/wallets/smart/lib/userop.js +34 -13
- package/dist/esm/wallets/smart/lib/userop.js.map +1 -1
- package/dist/types/chains/constants.d.ts +1 -1
- package/dist/types/chains/constants.d.ts.map +1 -1
- package/dist/types/exports/wallets/smart.d.ts +1 -1
- package/dist/types/exports/wallets/smart.d.ts.map +1 -1
- package/dist/types/storage/download.d.ts.map +1 -1
- package/dist/types/storage/mock.d.ts +11 -0
- package/dist/types/storage/mock.d.ts.map +1 -0
- package/dist/types/storage/upload/web-node.d.ts.map +1 -1
- package/dist/types/utils/process.d.ts +1 -0
- package/dist/types/utils/process.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/manager/index.d.ts +1 -1
- package/dist/types/wallets/manager/index.d.ts.map +1 -1
- package/dist/types/wallets/smart/index.d.ts +2 -0
- package/dist/types/wallets/smart/index.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/bundler.d.ts +30 -1
- package/dist/types/wallets/smart/lib/bundler.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/userop.d.ts +8 -0
- package/dist/types/wallets/smart/lib/userop.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/adapters/viem-legacy.test.ts +1 -1
- package/src/auth/verify-typed-data.test.ts +2 -4
- package/src/chains/constants.ts +17 -2
- package/src/contract/actions/resolve-abi.test.ts +3 -3
- package/src/exports/wallets/smart.ts +1 -0
- package/src/extensions/erc1155/customDrop1155.test.ts +3 -14
- package/src/extensions/erc1155/drop1155.test.ts +3 -14
- package/src/extensions/erc1155/token1155.test.ts +16 -109
- package/src/extensions/erc20/read/getCurrencyMetadata.test.ts +1 -1
- package/src/extensions/erc721/customDrop721.test.ts +3 -13
- package/src/extensions/erc721/drop721.test.ts +3 -13
- package/src/extensions/erc721/read/getNFTs.test.ts +1 -1
- package/src/extensions/erc721/read/getOwnedTokenIds.test.ts +1 -1
- package/src/extensions/lens/read/resolveAddress.test.ts +1 -1
- package/src/extensions/prebuilts/deploy-vote.test.ts +1 -1
- package/src/extensions/unstoppable-domains/read/resolveAddress.test.ts +1 -1
- package/src/extensions/unstoppable-domains/read/resolveName.test.ts +1 -1
- package/src/pay/convert/cryptoToFiat.test.ts +4 -4
- package/src/pay/convert/fiatToCrypto.test.ts +4 -4
- package/src/react/core/hooks/wallets/useConnect.test.tsx +3 -3
- package/src/react/web/ui/prebuilt/Account/balance.test.tsx +7 -13
- package/src/react/web/ui/prebuilt/Chain/icon.test.tsx +1 -1
- package/src/react/web/ui/prebuilt/NFT/description.test.tsx +1 -1
- package/src/react/web/ui/prebuilt/NFT/media.test.tsx +1 -1
- package/src/react/web/ui/prebuilt/NFT/name.test.tsx +1 -1
- package/src/react/web/ui/prebuilt/NFT/utils.test.ts +1 -1
- package/src/react/web/ui/prebuilt/Token/name.test.tsx +1 -1
- package/src/react/web/ui/prebuilt/Token/symbol.test.tsx +1 -1
- package/src/react/web/ui/prebuilt/Wallet/icon.test.tsx +1 -1
- package/src/react/web/ui/prebuilt/Wallet/name.test.tsx +1 -1
- package/src/react/web/ui/prebuilt/thirdweb/ClaimButton/ClaimButton.test.tsx +1 -1
- package/src/storage/download.test.ts +1 -1
- package/src/storage/download.ts +17 -0
- package/src/storage/mock.ts +52 -0
- package/src/storage/upload/web-node.test.ts +2 -1
- package/src/storage/upload/web-node.ts +8 -1
- package/src/transaction/actions/encode.test.ts +1 -1
- package/src/transaction/actions/estimate-gas-cost.ts +1 -1
- package/src/utils/nft/fetch-token-metadata.test.ts +1 -1
- package/src/utils/process.ts +4 -0
- package/src/version.ts +1 -1
- package/src/wallets/manager/index.ts +6 -2
- package/src/wallets/smart/index.ts +1 -1
- package/src/wallets/smart/lib/bundler.ts +95 -0
- package/src/wallets/smart/lib/userop.ts +42 -15
- package/src/wallets/smart/smart-wallet-integration-v07.test.ts +25 -21
- package/src/wallets/smart/smart-wallet-integration.test.ts +21 -1
- package/src/wallets/smart/smart-wallet-modular.test.ts +1 -2
@@ -96,19 +96,9 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
96
96
|
});
|
97
97
|
|
98
98
|
await expect(nextTokenIdToMint({ contract })).resolves.toBe(10n);
|
99
|
-
await
|
100
|
-
|
101
|
-
)
|
102
|
-
{
|
103
|
-
"id": 0n,
|
104
|
-
"metadata": {
|
105
|
-
"name": "Test NFT",
|
106
|
-
},
|
107
|
-
"owner": null,
|
108
|
-
"tokenURI": "ipfs://QmY1Rr4C7cYVPAaXykMMxg3AVbatDZ6Rd7u3gzt79CiDSB/0",
|
109
|
-
"type": "ERC721",
|
110
|
-
}
|
111
|
-
`);
|
99
|
+
expect((await getNFT({ contract, tokenId: 0n })).metadata.name).toBe(
|
100
|
+
"Test NFT",
|
101
|
+
);
|
112
102
|
});
|
113
103
|
|
114
104
|
it("should allow to claim tokens", async () => {
|
@@ -189,7 +189,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
|
|
189
189
|
});
|
190
190
|
|
191
191
|
it("should throw error if totalSupply and nextTokenIdToMint are not supported", async () => {
|
192
|
-
await expect(
|
192
|
+
await expect(
|
193
193
|
getNFTs({ contract: UNISWAPV3_FACTORY_CONTRACT }),
|
194
194
|
).rejects.toThrowError(
|
195
195
|
"Contract requires either `nextTokenIdToMint` or `totalSupply` function available to determine the next token ID to mint",
|
@@ -22,7 +22,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getOwnedTokenIds", () => {
|
|
22
22
|
it("should throw if tokenOfOwnerByIndex or tokensOfOwner not supported", async () => {
|
23
23
|
// We know current Lens contract on Polygon doesn't have this.
|
24
24
|
const contract = UNISWAPV3_FACTORY_CONTRACT;
|
25
|
-
await expect(
|
25
|
+
await expect(
|
26
26
|
getOwnedTokenIds({ contract, owner: TEST_ACCOUNT_B.address }),
|
27
27
|
).rejects.toThrowError(
|
28
28
|
`The contract at ${contract.address} on chain ${contract.chain.id} does not support the tokenOfOwnerByIndex or tokensOfOwner interface`,
|
@@ -14,7 +14,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("resolve lens address", () => {
|
|
14
14
|
});
|
15
15
|
|
16
16
|
it("should throw if passed an invalid lens handle", async () => {
|
17
|
-
await expect(
|
17
|
+
await expect(
|
18
18
|
resolveAddress({ client: TEST_CLIENT, name: "vitalik.eth" }),
|
19
19
|
).rejects.toThrowError(
|
20
20
|
"Could not fetch the wallet address for lens handle: vitalik.eth",
|
@@ -9,7 +9,7 @@ const account = TEST_ACCOUNT_B;
|
|
9
9
|
|
10
10
|
describe.runIf(process.env.TW_SECRET_KEY)("deploy-voteERC20 contract", () => {
|
11
11
|
it("should throw if passed an non-integer-like value to minVoteQuorumRequiredPercent", async () => {
|
12
|
-
await expect(
|
12
|
+
await expect(
|
13
13
|
deployVoteContract({
|
14
14
|
account,
|
15
15
|
client: TEST_CLIENT,
|
@@ -18,7 +18,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
18
18
|
});
|
19
19
|
|
20
20
|
it("should throw error on addresses that dont own any UD", async () => {
|
21
|
-
await expect(
|
21
|
+
await expect(
|
22
22
|
resolveName({ client: TEST_CLIENT, address: TEST_ACCOUNT_D.address }),
|
23
23
|
).rejects.toThrowError(
|
24
24
|
`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`,
|
@@ -52,7 +52,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
|
|
52
52
|
});
|
53
53
|
|
54
54
|
it("should throw error for testnet chain (because testnets are not supported", async () => {
|
55
|
-
await expect(
|
55
|
+
await expect(
|
56
56
|
convertCryptoToFiat({
|
57
57
|
chain: sepolia,
|
58
58
|
fromTokenAddress: NATIVE_TOKEN_ADDRESS,
|
@@ -66,7 +66,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
|
|
66
66
|
});
|
67
67
|
|
68
68
|
it("should throw error if fromTokenAddress is set to an invalid EVM address", async () => {
|
69
|
-
await expect(
|
69
|
+
await expect(
|
70
70
|
convertCryptoToFiat({
|
71
71
|
chain: ethereum,
|
72
72
|
fromTokenAddress: "haha",
|
@@ -80,7 +80,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
|
|
80
80
|
});
|
81
81
|
|
82
82
|
it("should throw error if fromTokenAddress is set to a wallet address", async () => {
|
83
|
-
await expect(
|
83
|
+
await expect(
|
84
84
|
convertCryptoToFiat({
|
85
85
|
chain: base,
|
86
86
|
fromTokenAddress: TEST_ACCOUNT_A.address,
|
@@ -99,7 +99,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
|
|
99
99
|
status: 400,
|
100
100
|
statusText: "Bad Request",
|
101
101
|
});
|
102
|
-
await expect(
|
102
|
+
await expect(
|
103
103
|
convertCryptoToFiat({
|
104
104
|
chain: base,
|
105
105
|
fromTokenAddress: NATIVE_TOKEN_ADDRESS,
|
@@ -53,7 +53,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: fiatToCrypto", () => {
|
|
53
53
|
});
|
54
54
|
|
55
55
|
it("should throw error for testnet chain (because testnets are not supported", async () => {
|
56
|
-
await expect(
|
56
|
+
await expect(
|
57
57
|
convertFiatToCrypto({
|
58
58
|
chain: sepolia,
|
59
59
|
to: NATIVE_TOKEN_ADDRESS,
|
@@ -67,7 +67,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: fiatToCrypto", () => {
|
|
67
67
|
});
|
68
68
|
|
69
69
|
it("should throw error if `to` is set to an invalid EVM address", async () => {
|
70
|
-
await expect(
|
70
|
+
await expect(
|
71
71
|
convertFiatToCrypto({
|
72
72
|
chain: ethereum,
|
73
73
|
to: "haha",
|
@@ -81,7 +81,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: fiatToCrypto", () => {
|
|
81
81
|
});
|
82
82
|
|
83
83
|
it("should throw error if `to` is set to a wallet address", async () => {
|
84
|
-
await expect(
|
84
|
+
await expect(
|
85
85
|
convertFiatToCrypto({
|
86
86
|
chain: base,
|
87
87
|
to: TEST_ACCOUNT_A.address,
|
@@ -100,7 +100,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: fiatToCrypto", () => {
|
|
100
100
|
status: 400,
|
101
101
|
statusText: "Bad Request",
|
102
102
|
});
|
103
|
-
await expect(
|
103
|
+
await expect(
|
104
104
|
convertFiatToCrypto({
|
105
105
|
chain: ethereum,
|
106
106
|
to: NATIVE_TOKEN_ADDRESS,
|
@@ -48,7 +48,7 @@ describe("useAddConnectedWallet", () => {
|
|
48
48
|
},
|
49
49
|
);
|
50
50
|
const { result } = renderHook(() => useConnect(), { wrapper });
|
51
|
-
expect(statusResult.current).toEqual("
|
51
|
+
expect(statusResult.current).toEqual("unknown");
|
52
52
|
await result.current.connect(async () => wallet);
|
53
53
|
expect(statusResult.current).toEqual("connected");
|
54
54
|
|
@@ -67,7 +67,7 @@ describe("useAddConnectedWallet", () => {
|
|
67
67
|
},
|
68
68
|
);
|
69
69
|
const { result } = renderHook(() => useConnect(), { wrapper });
|
70
|
-
expect(statusResult.current).toEqual("
|
70
|
+
expect(statusResult.current).toEqual("unknown");
|
71
71
|
await result.current.connect(async () => wallet);
|
72
72
|
expect(statusResult.current).toEqual("connected");
|
73
73
|
|
@@ -85,7 +85,7 @@ describe("useAddConnectedWallet", () => {
|
|
85
85
|
wrapper,
|
86
86
|
},
|
87
87
|
);
|
88
|
-
expect(statusResult.current).toEqual("
|
88
|
+
expect(statusResult.current).toEqual("unknown");
|
89
89
|
const { result } = renderHook(() => useConnect(), { wrapper });
|
90
90
|
await result.current.connect(async () => {
|
91
91
|
throw new Error("test");
|
@@ -72,14 +72,8 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
|
|
72
72
|
expect(result.symbol).toBe("$");
|
73
73
|
});
|
74
74
|
|
75
|
-
it("`loadAccountBalance` should throw if `chain` is not passed", async () => {
|
76
|
-
await expect(() =>
|
77
|
-
loadAccountBalance({ client: TEST_CLIENT, address: VITALIK_WALLET }),
|
78
|
-
).rejects.toThrowError("chain is required");
|
79
|
-
});
|
80
|
-
|
81
75
|
it("`loadAccountBalance` should throw if `tokenAddress` is mistakenly passed as native token", async () => {
|
82
|
-
await expect(
|
76
|
+
await expect(
|
83
77
|
loadAccountBalance({
|
84
78
|
client: TEST_CLIENT,
|
85
79
|
address: VITALIK_WALLET,
|
@@ -92,7 +86,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
|
|
92
86
|
});
|
93
87
|
|
94
88
|
it("`loadAccountBalance` should throw if `address` is not a valid evm address", async () => {
|
95
|
-
await expect(
|
89
|
+
await expect(
|
96
90
|
loadAccountBalance({
|
97
91
|
client: TEST_CLIENT,
|
98
92
|
// biome-ignore lint/suspicious/noExplicitAny: for the test
|
@@ -103,7 +97,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
|
|
103
97
|
});
|
104
98
|
|
105
99
|
it("`loadAccountBalance` should throw if `tokenAddress` is passed but is not a valid evm address", async () => {
|
106
|
-
await expect(
|
100
|
+
await expect(
|
107
101
|
loadAccountBalance({
|
108
102
|
client: TEST_CLIENT,
|
109
103
|
address: VITALIK_WALLET,
|
@@ -133,7 +127,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
|
|
133
127
|
});
|
134
128
|
|
135
129
|
it("`loadAccountBalance` should throw if failed to load tokenBalance (native token)", async () => {
|
136
|
-
await expect(
|
130
|
+
await expect(
|
137
131
|
loadAccountBalance({
|
138
132
|
client: TEST_CLIENT,
|
139
133
|
address: VITALIK_WALLET,
|
@@ -145,7 +139,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
|
|
145
139
|
});
|
146
140
|
|
147
141
|
it("`loadAccountBalance` should throw if failed to load tokenBalance (erc20 token)", async () => {
|
148
|
-
await expect(
|
142
|
+
await expect(
|
149
143
|
loadAccountBalance({
|
150
144
|
client: TEST_CLIENT,
|
151
145
|
address: VITALIK_WALLET,
|
@@ -158,7 +152,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
|
|
158
152
|
});
|
159
153
|
|
160
154
|
it("if fetching fiat value then it should throw if failed to resolve (native token)", async () => {
|
161
|
-
await expect(
|
155
|
+
await expect(
|
162
156
|
loadAccountBalance({
|
163
157
|
client: TEST_CLIENT,
|
164
158
|
address: VITALIK_WALLET,
|
@@ -171,7 +165,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
|
|
171
165
|
});
|
172
166
|
|
173
167
|
it("if fetching fiat value then it should throw if failed to resolve (erc20 token)", async () => {
|
174
|
-
await expect(
|
168
|
+
await expect(
|
175
169
|
loadAccountBalance({
|
176
170
|
client: TEST_CLIENT,
|
177
171
|
address: VITALIK_WALLET,
|
@@ -76,7 +76,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ChainIcon", () => {
|
|
76
76
|
});
|
77
77
|
|
78
78
|
it("fetchChainIcon should throw error if failed to resolve chain icon", async () => {
|
79
|
-
await expect(
|
79
|
+
await expect(
|
80
80
|
fetchChainIcon({ chain: defineChain(-1), client }),
|
81
81
|
).rejects.toThrowError("Failed to resolve icon for chain");
|
82
82
|
});
|
@@ -53,7 +53,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFTDescription", () => {
|
|
53
53
|
});
|
54
54
|
|
55
55
|
it("fetchNftDescription should throw error if failed to resolve nft info", async () => {
|
56
|
-
await expect(
|
56
|
+
await expect(
|
57
57
|
fetchNftDescription({
|
58
58
|
contract: UNISWAPV3_FACTORY_CONTRACT,
|
59
59
|
tokenId: 0n,
|
@@ -70,7 +70,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFTMedia", () => {
|
|
70
70
|
});
|
71
71
|
|
72
72
|
it("fetchNftMedia should throw error if failed to resolve nft info", async () => {
|
73
|
-
await expect(
|
73
|
+
await expect(
|
74
74
|
fetchNftMedia({
|
75
75
|
contract: UNISWAPV3_FACTORY_CONTRACT,
|
76
76
|
tokenId: 0n,
|
@@ -54,7 +54,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFTName", () => {
|
|
54
54
|
});
|
55
55
|
|
56
56
|
it("fetchNftName should throw error if failed to resolve nft info", async () => {
|
57
|
-
await expect(
|
57
|
+
await expect(
|
58
58
|
fetchNftName({
|
59
59
|
contract: UNISWAPV3_FACTORY_CONTRACT,
|
60
60
|
tokenId: 0n,
|
@@ -86,7 +86,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("getNFTInfo", () => {
|
|
86
86
|
});
|
87
87
|
|
88
88
|
it("should throw error if failed to load nft info", async () => {
|
89
|
-
await expect(
|
89
|
+
await expect(
|
90
90
|
getNFTInfo({ contract: UNISWAPV3_FACTORY_CONTRACT, tokenId: 0n }),
|
91
91
|
).rejects.toThrowError("Failed to load NFT metadata");
|
92
92
|
});
|
@@ -73,7 +73,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenName component", () => {
|
|
73
73
|
});
|
74
74
|
|
75
75
|
it("fetchTokenName should throw in the end where all fallback solutions failed to resolve to any name", async () => {
|
76
|
-
await expect(
|
76
|
+
await expect(
|
77
77
|
fetchTokenName({
|
78
78
|
address: UNISWAPV3_FACTORY_CONTRACT.address,
|
79
79
|
client,
|
@@ -73,7 +73,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenSymbol component", () => {
|
|
73
73
|
});
|
74
74
|
|
75
75
|
it("fetchTokenSymbol should throw in the end where all fallback solutions failed to resolve to any symbol", async () => {
|
76
|
-
await expect(
|
76
|
+
await expect(
|
77
77
|
fetchTokenSymbol({
|
78
78
|
address: UNISWAPV3_FACTORY_CONTRACT.address,
|
79
79
|
client,
|
@@ -11,7 +11,7 @@ describe("WalletIcon", () => {
|
|
11
11
|
});
|
12
12
|
|
13
13
|
it("should throw error if WalletId is not supported", async () => {
|
14
|
-
await expect(
|
14
|
+
await expect(
|
15
15
|
// @ts-ignore For test
|
16
16
|
fetchWalletImage({ id: "__undefined__" }),
|
17
17
|
).rejects.toThrowError("Wallet with id __undefined__ not found");
|
@@ -16,7 +16,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("WalletName", () => {
|
|
16
16
|
|
17
17
|
it("fetchWalletName should throw error if failed to get name", async () => {
|
18
18
|
// @ts-ignore for test
|
19
|
-
await expect(
|
19
|
+
await expect(fetchWalletName({ id: "test___" })).rejects.toThrowError(
|
20
20
|
"Wallet with id test___ not found",
|
21
21
|
);
|
22
22
|
});
|
@@ -7,7 +7,7 @@ import { download } from "./download.js";
|
|
7
7
|
|
8
8
|
const server = setupServer(...storageHandlers);
|
9
9
|
|
10
|
-
describe("download", () => {
|
10
|
+
describe.skip("download", () => {
|
11
11
|
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
12
12
|
afterAll(() => server.close());
|
13
13
|
afterEach(() => server.resetHandlers());
|
package/src/storage/download.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import { getClientFetch } from "../utils/fetch.js";
|
2
2
|
import { type ResolveSchemeOptions, resolveScheme } from "../utils/ipfs.js";
|
3
|
+
import { IS_TEST } from "../utils/process.js";
|
3
4
|
import type { Prettify } from "../utils/type-utils.js";
|
5
|
+
import { getFromMockStorage } from "./mock.js";
|
4
6
|
|
5
7
|
export type DownloadOptions = Prettify<
|
6
8
|
ResolveSchemeOptions & {
|
@@ -64,6 +66,21 @@ export type DownloadOptions = Prettify<
|
|
64
66
|
* @storage
|
65
67
|
*/
|
66
68
|
export async function download(options: DownloadOptions) {
|
69
|
+
if (IS_TEST) {
|
70
|
+
const hash = options.uri.split("://")[1];
|
71
|
+
if (!hash) {
|
72
|
+
throw new Error("Invalid hash");
|
73
|
+
}
|
74
|
+
const data = getFromMockStorage(hash);
|
75
|
+
if (data) {
|
76
|
+
return {
|
77
|
+
ok: true,
|
78
|
+
status: 200,
|
79
|
+
json: () => Promise.resolve(data),
|
80
|
+
} as Response;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
67
84
|
let url: string;
|
68
85
|
if (options.uri.startsWith("ar://")) {
|
69
86
|
const { resolveArweaveScheme } = await import("../utils/arweave.js");
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { randomBytesHex } from "../utils/random.js";
|
2
|
+
|
3
|
+
const mockStorage = new Map<string, unknown>();
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Extracts file contents from FormData and stores it as JSON
|
7
|
+
* @returns The storage key with filename if present
|
8
|
+
*/
|
9
|
+
export async function addToMockStorage(value: FormData): Promise<string[]> {
|
10
|
+
const key = randomBytesHex();
|
11
|
+
|
12
|
+
// Get the first file from FormData
|
13
|
+
const files = value.getAll("file") as File[];
|
14
|
+
if (!files) {
|
15
|
+
throw new Error("No file found in FormData");
|
16
|
+
}
|
17
|
+
|
18
|
+
// Read file contents
|
19
|
+
return Promise.all(
|
20
|
+
files.map(async (file) => {
|
21
|
+
const text = await file.text();
|
22
|
+
let data: unknown;
|
23
|
+
|
24
|
+
try {
|
25
|
+
// Parse the contents as JSON
|
26
|
+
data = JSON.parse(text);
|
27
|
+
} catch {
|
28
|
+
throw new Error("File contents must be valid JSON");
|
29
|
+
}
|
30
|
+
|
31
|
+
// If file has a name, return key/filename format
|
32
|
+
const filename =
|
33
|
+
"name" in file && file.name ? file.name.replace("files/", "") : "";
|
34
|
+
|
35
|
+
// console.log("mockStorage upload", key, data, filename);
|
36
|
+
|
37
|
+
const hash = `${key}${filename ? `/${filename}` : ""}`;
|
38
|
+
mockStorage.set(hash, data);
|
39
|
+
return `ipfs://${hash}`;
|
40
|
+
}),
|
41
|
+
);
|
42
|
+
}
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Retrieves parsed JSON data from storage
|
46
|
+
* @returns The parsed data object or undefined if not found
|
47
|
+
*/
|
48
|
+
export function getFromMockStorage(key: string): unknown {
|
49
|
+
const data = mockStorage.get(key);
|
50
|
+
// console.log("mockStorage get", key, data);
|
51
|
+
return data;
|
52
|
+
}
|
@@ -8,7 +8,8 @@ import { uploadBatch } from "./web-node.js";
|
|
8
8
|
|
9
9
|
const server = setupServer(...storageHandlers);
|
10
10
|
|
11
|
-
|
11
|
+
// skip this test for now, will need to be manually run
|
12
|
+
describe.skip("uploadBatch", () => {
|
12
13
|
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
13
14
|
afterAll(() => server.close());
|
14
15
|
afterEach(() => server.resetHandlers());
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import type { ThirdwebClient } from "../../client/client.js";
|
2
2
|
import { getThirdwebDomains } from "../../utils/domains.js";
|
3
3
|
import { getClientFetch } from "../../utils/fetch.js";
|
4
|
+
import { IS_TEST } from "../../utils/process.js";
|
5
|
+
import { addToMockStorage } from "../mock.js";
|
4
6
|
import type { UploadOptions, UploadableFile } from "./types.js";
|
5
7
|
|
6
8
|
export async function uploadBatch<const TFiles extends UploadableFile[]>(
|
@@ -9,6 +11,10 @@ export async function uploadBatch<const TFiles extends UploadableFile[]>(
|
|
9
11
|
fileNames: string[],
|
10
12
|
options?: UploadOptions<TFiles>,
|
11
13
|
) {
|
14
|
+
if (IS_TEST) {
|
15
|
+
return addToMockStorage(form);
|
16
|
+
}
|
17
|
+
|
12
18
|
const headers: HeadersInit = {};
|
13
19
|
|
14
20
|
const res = await getClientFetch(client)(
|
@@ -17,7 +23,8 @@ export async function uploadBatch<const TFiles extends UploadableFile[]>(
|
|
17
23
|
method: "POST",
|
18
24
|
headers,
|
19
25
|
body: form,
|
20
|
-
requestTimeoutMs:
|
26
|
+
requestTimeoutMs:
|
27
|
+
client.config?.storage?.fetch?.requestTimeoutMs || 120000,
|
21
28
|
},
|
22
29
|
);
|
23
30
|
|
@@ -203,7 +203,7 @@ describe("transaction: encode", () => {
|
|
203
203
|
// @ts-ignore Intentionally for the test purpose
|
204
204
|
extraCallData: "I'm a cat",
|
205
205
|
});
|
206
|
-
await expect(
|
206
|
+
await expect(getExtraCallDataFromTx(tx)).rejects.toThrowError(
|
207
207
|
"Invalid extra calldata - must be a hex string",
|
208
208
|
);
|
209
209
|
});
|
@@ -44,7 +44,7 @@ export async function estimateGasCost(
|
|
44
44
|
);
|
45
45
|
}
|
46
46
|
let l1Fee: bigint;
|
47
|
-
if (isOpStackChain(transaction.chain)) {
|
47
|
+
if (await isOpStackChain(transaction.chain)) {
|
48
48
|
const { estimateL1Fee } = await import("../../gas/estimate-l1-fee.js");
|
49
49
|
l1Fee = await estimateL1Fee({
|
50
50
|
transaction,
|
package/src/utils/process.ts
CHANGED
@@ -1,3 +1,7 @@
|
|
1
1
|
export const IS_DEV =
|
2
2
|
// biome-ignore lint/nursery/noProcessEnv: ok in this file
|
3
3
|
process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
4
|
+
|
5
|
+
export const IS_TEST =
|
6
|
+
// biome-ignore lint/nursery/noProcessEnv: ok in this file
|
7
|
+
process.env.NODE_ENV === "test";
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.
|
1
|
+
export const version = "5.90.0";
|
@@ -15,7 +15,11 @@ import type { SmartWalletOptions } from "../smart/types.js";
|
|
15
15
|
import type { WalletId } from "../wallet-types.js";
|
16
16
|
|
17
17
|
type WalletIdToConnectedWalletMap = Map<string, Wallet>;
|
18
|
-
export type ConnectionStatus =
|
18
|
+
export type ConnectionStatus =
|
19
|
+
| "connected"
|
20
|
+
| "disconnected"
|
21
|
+
| "connecting"
|
22
|
+
| "unknown";
|
19
23
|
|
20
24
|
const CONNECTED_WALLET_IDS = "thirdweb:connected-wallet-ids";
|
21
25
|
const LAST_ACTIVE_EOA_ID = "thirdweb:active-wallet-id";
|
@@ -47,7 +51,7 @@ export function createConnectionManager(storage: AsyncStorage) {
|
|
47
51
|
const activeAccountStore = createStore<Account | undefined>(undefined);
|
48
52
|
const activeWalletChainStore = createStore<Chain | undefined>(undefined);
|
49
53
|
const activeWalletConnectionStatusStore =
|
50
|
-
createStore<ConnectionStatus>("
|
54
|
+
createStore<ConnectionStatus>("unknown");
|
51
55
|
|
52
56
|
const definedChainsStore = createStore<Map<number, Chain>>(new Map());
|
53
57
|
|