Skip to content

Commit 4c2056d

Browse files
authored
(chore) - remove extraneous deps (#149)
* remove extraneous deps * try whatwg polyfill * add changeset
1 parent 5b9db00 commit 4c2056d

File tree

8 files changed

+54
-43
lines changed

8 files changed

+54
-43
lines changed

.changeset/few-queens-bathe.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@web3-ui/components': patch
3+
'@web3-ui/core': patch
4+
---
5+
6+
Remove the `cross-fetch` polyfill

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"jest": "^26.6.3",
4646
"lint-staged": "^12.1.3",
4747
"msw": "^0.35.0",
48-
"ts-jest": "^26.4.4"
48+
"ts-jest": "^26.4.4",
49+
"whatwg-fetch": "^3.6.2"
4950
},
5051
"lint-staged": {
5152
"*.{ts,tsx,md,json}": [

packages/components/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@
3030
"@babel/runtime": "^7.16.3",
3131
"@chakra-ui/icons": "^1.1.1",
3232
"@chakra-ui/react": "^1.7.2",
33-
"@emotion/core": "^11.0.0",
3433
"@emotion/react": "^11",
3534
"@emotion/styled": "^11",
36-
"cross-fetch": "^3.1.4",
3735
"ethers": "^5.5.2",
3836
"framer-motion": "^4"
3937
},

packages/components/src/components/NFT/NFT.tsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import {
99
VStack,
1010
Skeleton,
1111
Alert,
12-
AlertIcon,
12+
AlertIcon
1313
} from '@chakra-ui/react';
14-
import fetch from 'cross-fetch';
1514

1615
export interface NFTProps {
1716
/**
@@ -47,7 +46,9 @@ export const NFT = ({ contractAddress, tokenId, size = 'xs' }: NFTProps) => {
4746

4847
const fetchNFTData = useCallback(async () => {
4948
try {
50-
const res = await fetch(`https://api.opensea.io/api/v1/asset/${contractAddress}/${tokenId}/`);
49+
const res = await fetch(
50+
`https://api.opensea.io/api/v1/asset/${contractAddress}/${tokenId}/`
51+
);
5152
if (!res.ok) {
5253
throw Error(
5354
`OpenSea request failed with status: ${res.status}. Make sure you are on mainnet.`
@@ -61,7 +62,7 @@ export const NFT = ({ contractAddress, tokenId, size = 'xs' }: NFTProps) => {
6162
name: data.name,
6263
assetContractName: data.asset_contract.name,
6364
assetContractSymbol: data.asset_contract.symbol,
64-
animationUrl: data.animation_url,
65+
animationUrl: data.animation_url
6566
});
6667
}
6768
} catch (error) {
@@ -90,7 +91,7 @@ export const NFT = ({ contractAddress, tokenId, size = 'xs' }: NFTProps) => {
9091
export const NFTCard = ({
9192
data,
9293
errorMessage = '',
93-
size,
94+
size
9495
}: {
9596
data: NFTData | undefined | null;
9697
errorMessage?: string | undefined;
@@ -106,38 +107,49 @@ export const NFTCard = ({
106107

107108
if (errorMessage) {
108109
return (
109-
<Alert status='error'>
110+
<Alert status="error">
110111
<AlertIcon />
111112
{errorMessage}
112113
</Alert>
113114
);
114115
}
115116

116117
return (
117-
<Skeleton isLoaded={!!data} maxW={size} h='md'>
118-
<Box maxW={size} borderRadius='lg' borderWidth='1px' overflow='hidden'>
118+
<Skeleton isLoaded={!!data} maxW={size} h="md">
119+
<Box maxW={size} borderRadius="lg" borderWidth="1px" overflow="hidden">
119120
{animationUrl ? (
120121
animationUrl.endsWith('.mp3') ? (
121122
<VStack>
122-
<Image src={imageUrl} alt={displayName} borderRadius='lg' w={size} />
123-
<audio src={animationUrl} controls autoPlay muted style={{ borderRadius: '7px' }} />
123+
<Image
124+
src={imageUrl}
125+
alt={displayName}
126+
borderRadius="lg"
127+
w={size}
128+
/>
129+
<audio
130+
src={animationUrl}
131+
controls
132+
autoPlay
133+
muted
134+
style={{ borderRadius: '7px' }}
135+
/>
124136
</VStack>
125137
) : (
126-
<Flex w={size} h={size} bg='black' justifyContent='center'>
138+
<Flex w={size} h={size} bg="black" justifyContent="center">
127139
<video src={animationUrl} controls autoPlay muted />
128140
</Flex>
129141
)
130142
) : (
131-
<Image src={imageUrl} alt={displayName} borderRadius='lg' w={size} />
143+
<Image src={imageUrl} alt={displayName} borderRadius="lg" w={size} />
132144
)}
133-
<Box p='6'>
134-
<Flex alignItems='center' justifyContent='space-between' pb='2'>
135-
<Heading as='h3' size='sm' style={{ overflowWrap: 'anywhere' }}>
145+
<Box p="6">
146+
<Flex alignItems="center" justifyContent="space-between" pb="2">
147+
<Heading as="h3" size="sm" style={{ overflowWrap: 'anywhere' }}>
136148
{displayName}
137149
</Heading>
138-
{assetContractSymbol && <Tag size='sm'>{assetContractSymbol}</Tag>}
150+
{assetContractSymbol && <Tag size="sm">{assetContractSymbol}</Tag>}
139151
</Flex>
140-
<Text fontSize='xs'>
152+
<Text fontSize="xs">
141153
{assetContractName} #{tokenId}
142154
</Text>
143155
</Box>

packages/components/src/components/NFTGallery/NFTGallery.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useEffect } from 'react';
2-
import fetch from 'cross-fetch';
32
import { ethers } from 'ethers';
43
import { VStack, Heading, Grid, Alert, AlertIcon } from '@chakra-ui/react';
54
import { NFTCard } from '../NFT';
@@ -35,7 +34,11 @@ export interface OpenSeaAsset {
3534
* Component to display a grid of NFTs owned by an address. It uses the OpenSea API to fetch
3635
* the NFTs.
3736
*/
38-
export const NFTGallery = ({ address, gridWidth = 4, web3Provider }: NFTGalleryProps) => {
37+
export const NFTGallery = ({
38+
address,
39+
gridWidth = 4,
40+
web3Provider
41+
}: NFTGalleryProps) => {
3942
const [nfts, setNfts] = React.useState<OpenSeaAsset[]>([]);
4043
const [errorMessage, setErrorMessage] = React.useState();
4144

@@ -65,9 +68,9 @@ export const NFTGallery = ({ address, gridWidth = 4, web3Provider }: NFTGalleryP
6568

6669
return (
6770
<VStack>
68-
<Heading size='lg'>NFT Gallery</Heading>
71+
<Heading size="lg">NFT Gallery</Heading>
6972
{errorMessage && (
70-
<Alert status='error'>
73+
<Alert status="error">
7174
<AlertIcon />
7275
{errorMessage}
7376
</Alert>
@@ -81,9 +84,9 @@ export const NFTGallery = ({ address, gridWidth = 4, web3Provider }: NFTGalleryP
8184
imageUrl: nft.image_url,
8285
tokenId: nft.token_id,
8386
assetContractName: nft.asset_contract.name,
84-
assetContractSymbol: nft.asset_contract.symbol,
87+
assetContractSymbol: nft.asset_contract.symbol
8588
}}
86-
size='xs'
89+
size="xs"
8790
/>
8891
))}
8992
</Grid>

packages/core/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@
2929
"dependencies": {
3030
"@babel/runtime": "^7.16.3",
3131
"@chakra-ui/react": "^1.7.2",
32-
"@emotion/core": "^11.0.0",
3332
"@emotion/react": "^11",
3433
"@emotion/styled": "^11",
35-
"classnames": "^2.2.6",
36-
"cross-fetch": "^3.1.4",
3734
"framer-motion": "^4",
3835
"@web3-ui/components": "^0.3.0",
3936
"@web3-ui/hooks": "^0.5.0"

utils/setupTests.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import "@testing-library/jest-dom";
2-
import { server } from "./server";
1+
import '@testing-library/jest-dom';
2+
import { server } from './server';
3+
require('whatwg-fetch');
34

45
beforeAll(() => server.listen());
56
afterEach(() => server.resetHandlers());

yarn.lock

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,11 +1999,6 @@
19991999
"@emotion/sheet" "0.9.4"
20002000
"@emotion/utils" "0.11.3"
20012001

2002-
"@emotion/core@^11.0.0":
2003-
version "11.0.0"
2004-
resolved "https://registry.yarnpkg.com/@emotion/core/-/core-11.0.0.tgz#d075867e07864119de7cfd5268c15012bd2d6290"
2005-
integrity sha512-w4sE3AmHmyG6RDKf6mIbtHpgJUSJ2uGvPQb8VXFL7hFjMPibE8IiehG8cMX3Ztm4svfCQV6KqusQbeIOkurBcA==
2006-
20072002
"@emotion/css@^10.0.27":
20082003
version "10.0.27"
20092004
resolved "https://registry.yarnpkg.com/@emotion/css/-/css-10.0.27.tgz#3a7458198fbbebb53b01b2b87f64e5e21241e14c"
@@ -6896,13 +6891,6 @@ cross-fetch@^2.1.0:
68966891
node-fetch "2.6.1"
68976892
whatwg-fetch "2.0.4"
68986893

6899-
cross-fetch@^3.1.4:
6900-
version "3.1.4"
6901-
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.4.tgz#9723f3a3a247bf8b89039f3a380a9244e8fa2f39"
6902-
integrity sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==
6903-
dependencies:
6904-
node-fetch "2.6.1"
6905-
69066894
[email protected], cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
69076895
version "7.0.3"
69086896
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
@@ -16500,6 +16488,11 @@ [email protected]:
1650016488
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
1650116489
integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==
1650216490

16491+
whatwg-fetch@^3.6.2:
16492+
version "3.6.2"
16493+
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c"
16494+
integrity sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==
16495+
1650316496
whatwg-mimetype@^2.3.0:
1650416497
version "2.3.0"
1650516498
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf"

0 commit comments

Comments
 (0)