Skip to content

Commit

Permalink
Do not use getChainBySlug, update /chains (#111)
Browse files Browse the repository at this point in the history
* Do not use getChainBySlug

* Update @thirdweb-dev/chains

* Accept normal chain slug

---------

Co-authored-by: Nacho Iacovino <[email protected]>
  • Loading branch information
MananTank and nachoiacovino authored Jul 24, 2023
1 parent fed37ab commit a40a8f3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@chakra-ui/react": "^2.1.0",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@thirdweb-dev/chains": "^0.1.27-nightly-2d088d36-20230704174941",
"@thirdweb-dev/chains": "^0.1.38",
"@thirdweb-dev/react": "^3.14.8-nightly-2d088d36-20230704174941",
"@thirdweb-dev/sdk": "^3.10.28-nightly-2d088d36-20230704174941",
"color": "^4.2.3",
Expand Down
10 changes: 2 additions & 8 deletions src/embeds/erc1155.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { useGasless } from "../shared/hooks/useGasless";
import chakraTheme from "../shared/theme";
import { fontsizeCss } from "../shared/theme/typography";
import { TokenMetadataPage } from "../shared/token-metadata-page";
import { Chain, getChainBySlug } from "@thirdweb-dev/chains";

interface Erc1155EmbedProps {
contractAddress: string;
Expand Down Expand Up @@ -72,12 +71,7 @@ const App: React.FC = () => {
const chain =
urlParams.get("chain") && urlParams.get("chain")?.startsWith("{")
? JSON.parse(String(urlParams.get("chain")))
: urlParams.get("chain");
const tempChain = getChainBySlug(
typeof chain === "string" ? chain : chain.slug,
);
const activeChain: Chain | string =
typeof chain === "string" ? chain : { ...chain, icon: tempChain.icon };
: urlParams.get("chain") || "";
const contractAddress = urlParams.get("contract") || "";
const tokenId = urlParams.get("tokenId") || "0";
const relayerUrl = urlParams.get("relayUrl") || "";
Expand All @@ -103,7 +97,7 @@ const App: React.FC = () => {
/>
<ChakraProvider theme={chakraTheme}>
<ThirdwebProvider
activeChain={activeChain}
activeChain={chain}
sdkOptions={sdkOptions}
storageInterface={
ipfsGateway
Expand Down
10 changes: 2 additions & 8 deletions src/embeds/erc20.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Footer } from "../shared/footer";
import { useGasless } from "../shared/hooks/useGasless";
import chakraTheme from "../shared/theme";
import { fontsizeCss } from "../shared/theme/typography";
import { Chain, getChainBySlug } from "@thirdweb-dev/chains";

interface Erc20EmbedProps {
colorScheme: "light" | "dark";
Expand Down Expand Up @@ -67,12 +66,7 @@ const App: React.FC = () => {
const chain =
urlParams.get("chain") && urlParams.get("chain")?.startsWith("{")
? JSON.parse(String(urlParams.get("chain")))
: urlParams.get("chain");
const tempChain = getChainBySlug(
typeof chain === "string" ? chain : chain.slug,
);
const activeChain: Chain | string =
typeof chain === "string" ? chain : { ...chain, icon: tempChain.icon };
: urlParams.get("chain") || "";
const contractAddress = urlParams.get("contract") || "";
const relayerUrl = urlParams.get("relayUrl") || "";
const biconomyApiKey = urlParams.get("biconomyApiKey") || "";
Expand All @@ -97,7 +91,7 @@ const App: React.FC = () => {
/>
<ChakraProvider theme={chakraTheme}>
<ThirdwebProvider
activeChain={activeChain}
activeChain={chain}
sdkOptions={sdkOptions}
storageInterface={
ipfsGateway
Expand Down
10 changes: 2 additions & 8 deletions src/embeds/erc721.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Header } from "../shared/header";
import { useGasless } from "../shared/hooks/useGasless";
import chakraTheme from "../shared/theme";
import { fontsizeCss } from "../shared/theme/typography";
import { Chain, getChainBySlug } from "@thirdweb-dev/chains";

interface Erc721EmbedProps {
contractAddress: string;
Expand Down Expand Up @@ -68,12 +67,7 @@ const App: React.FC = () => {
const chain =
urlParams.get("chain") && urlParams.get("chain")?.startsWith("{")
? JSON.parse(String(urlParams.get("chain")))
: urlParams.get("chain");
const tempChain = getChainBySlug(
typeof chain === "string" ? chain : chain.slug,
);
const activeChain: Chain | string =
typeof chain === "string" ? chain : { ...chain, icon: tempChain.icon };
: urlParams.get("chain") || "";
const contractAddress = urlParams.get("contract") || "";
const relayerUrl = urlParams.get("relayUrl") || "";
const biconomyApiKey = urlParams.get("biconomyApiKey") || "";
Expand All @@ -98,7 +92,7 @@ const App: React.FC = () => {
/>
<ChakraProvider theme={chakraTheme}>
<ThirdwebProvider
activeChain={activeChain}
activeChain={chain}
sdkOptions={sdkOptions}
storageInterface={
ipfsGateway
Expand Down
13 changes: 3 additions & 10 deletions src/embeds/marketplace-v3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
Button,
Center,
ChakraProvider,
ColorMode,
Flex,
Heading,
Icon,
Expand Down Expand Up @@ -50,7 +49,6 @@ import { Footer } from "../shared/footer";
import { useGasless } from "../shared/hooks/useGasless";
import chakraTheme from "../shared/theme";
import { fontsizeCss } from "../shared/theme/typography";
import { Chain, getChainBySlug } from "@thirdweb-dev/chains";

interface MarketplaceV3EmbedProps {
rpcUrl?: string;
Expand Down Expand Up @@ -259,7 +257,7 @@ const EnglishAuctionComponent: React.FC<EnglishAuctionProps> = ({
{BigNumber.from(listing.buyoutBidAmount).gt(0) && (
<Tooltip
label={`
You can buyout this auction to instantly purchase
You can buyout this auction to instantly purchase
all the listed assets and end the bidding process.
`}
>
Expand Down Expand Up @@ -682,12 +680,7 @@ const App: React.FC = () => {
const chain =
urlParams.get("chain") && urlParams.get("chain")?.startsWith("{")
? JSON.parse(String(urlParams.get("chain")))
: urlParams.get("chain");
const tempChain = getChainBySlug(
typeof chain === "string" ? chain : chain.slug,
);
const activeChain: Chain | string =
typeof chain === "string" ? chain : { ...chain, icon: tempChain.icon };
: urlParams.get("chain") || "";
const contractAddress = urlParams.get("contract") || "";
const directListingId = urlParams.get("directListingId") || "";
const englishAuctionId = urlParams.get("englishAuctionId") || "";
Expand Down Expand Up @@ -716,7 +709,7 @@ const App: React.FC = () => {
/>
<ChakraProvider theme={chakraTheme}>
<ThirdwebProvider
activeChain={activeChain}
activeChain={chain}
sdkOptions={sdkOptions}
storageInterface={
ipfsGateway
Expand Down
5 changes: 4 additions & 1 deletion src/embeds/marketplace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,10 @@ const MarketplaceEmbed: React.FC<MarketplaceEmbedProps> = ({
const urlParams = new URL(window.location.toString()).searchParams;

const App: React.FC = () => {
const chain = JSON.parse(urlParams.get("chain") || "");
const chain =
urlParams.get("chain") && urlParams.get("chain")?.startsWith("{")
? JSON.parse(String(urlParams.get("chain")))
: urlParams.get("chain") || "";
const contractAddress = urlParams.get("contract") || "";
const listingId = urlParams.get("listingId") || "";
const relayerUrl = urlParams.get("relayUrl") || "";
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3355,11 +3355,16 @@
"@tanstack/query-core" "4.29.19"
use-sync-external-store "^1.2.0"

"@thirdweb-dev/[email protected]", "@thirdweb-dev/chains@^0.1.27-nightly-2d088d36-20230704174941":
"@thirdweb-dev/[email protected]":
version "0.1.27-nightly-2d088d36-20230704174941"
resolved "https://registry.yarnpkg.com/@thirdweb-dev/chains/-/chains-0.1.27-nightly-2d088d36-20230704174941.tgz#ac52ac76dc360480c15ddfe570b30ce1ca47715d"
integrity sha512-UJh2Up2cHjieZsur8i38UDlFPmFEzdpjD/rxCKKZszWrfh/m+WNdLakzdoDiN2y53qE4SeAxjbErLm+7Uv5p7w==

"@thirdweb-dev/chains@^0.1.38":
version "0.1.38"
resolved "https://registry.yarnpkg.com/@thirdweb-dev/chains/-/chains-0.1.38.tgz#57e93239645a013f0677c711f3f1cdc7cde54db8"
integrity sha512-XiH/2X5Hgs50fWMX0u4pB/hv2dZSnFSDwF1i54YViDv1Ydganzwt2PEK1Fct0u4Oz8FHww2ybc459FDNaRBnew==

"@thirdweb-dev/[email protected]":
version "1.3.8-nightly-2d088d36-20230704174941"
resolved "https://registry.yarnpkg.com/@thirdweb-dev/contracts-js/-/contracts-js-1.3.8-nightly-2d088d36-20230704174941.tgz#0f8113471660c42e7c22dd0a7023a1f5c0518bf8"
Expand Down

0 comments on commit a40a8f3

Please sign in to comment.