fix network select rule && redirect url

This commit is contained in:
Jonas Daniels
2022-05-01 17:24:42 -07:00
parent eacf8b116b
commit 0cad69b7cb
4 changed files with 13 additions and 10 deletions
@@ -32,6 +32,7 @@ import { UrlMap } from "constants/mappings";
import { isAddress } from "ethers/lib/utils";
import { useTrack } from "hooks/analytics/useTrack";
import { useImageFileOrUrl } from "hooks/useImageFileOrUrl";
import { useSingleQueryParam } from "hooks/useQueryParam";
import { useTxNotifications } from "hooks/useTxNotifications";
import { useRouter } from "next/router";
import { useEffect, useMemo } from "react";
@@ -207,6 +208,8 @@ const BuiltinContractForm: React.VFC<BuiltinContractFormProps> = ({
"Failed to deploy contract",
);
const wallet = useSingleQueryParam("wallet") || "dashboard";
const { trackEvent } = useTrack();
const router = useRouter();
@@ -250,7 +253,7 @@ const BuiltinContractForm: React.VFC<BuiltinContractFormProps> = ({
});
onSuccess();
router.push(
`/dashboard/${SupportedChainIdToNetworkMap[selectedChain]}/${UrlMap[contractType]}/${contractAddress}`,
`/${wallet}/${SupportedChainIdToNetworkMap[selectedChain]}/${UrlMap[contractType]}/${contractAddress}`,
);
},
onError: (err) => {
@@ -12,7 +12,6 @@ import {
Skeleton,
Textarea,
} from "@chakra-ui/react";
import { useAddress } from "@thirdweb-dev/react";
import { ChainId } from "@thirdweb-dev/sdk";
import { CustomContractMetadata } from "@thirdweb-dev/sdk/dist/src/schema/contracts/custom";
import { TransactionButton } from "components/buttons/TransactionButton";
@@ -20,6 +19,7 @@ import { SupportedNetworkSelect } from "components/selects/SupportedNetworkSelec
import { FileInput } from "components/shared/FileInput";
import { useTrack } from "hooks/analytics/useTrack";
import { useImageFileOrUrl } from "hooks/useImageFileOrUrl";
import { useSingleQueryParam } from "hooks/useQueryParam";
import { useTxNotifications } from "hooks/useTxNotifications";
import { useRouter } from "next/router";
import { useCallback, useState } from "react";
@@ -70,7 +70,7 @@ const CustomContractForm: React.VFC<CustomContractFormProps> = ({
}, []);
const deploy = useCustomContractDeployMutation(ipfsHash);
const walletAddress = useAddress();
const wallet = useSingleQueryParam("wallet") || "dashboard";
const router = useRouter();
const { onSuccess, onError } = useTxNotifications(
"Successfully deployed contract",
@@ -119,7 +119,7 @@ const CustomContractForm: React.VFC<CustomContractFormProps> = ({
onSuccess();
router.push(
`/${walletAddress}/${SupportedChainIdToNetworkMap[selectedChain]}/${deployedContractAddress}`,
`/${wallet}/${SupportedChainIdToNetworkMap[selectedChain]}/${deployedContractAddress}`,
);
},
onError: (err) => {
@@ -248,7 +248,7 @@ const CustomContractForm: React.VFC<CustomContractFormProps> = ({
<FormControl>
<SupportedNetworkSelect
disabledChainIds={SUPPORTED_CHAIN_IDS.filter(
(c) => c === ChainId.Mumbai || c === ChainId.Rinkeby,
(c) => c !== ChainId.Mumbai && c !== ChainId.Rinkeby,
)}
disabledChainIdText="coming soon"
isDisabled={deploy.isLoading || !publishMetadata.isSuccess}
+1 -1
View File
@@ -26,7 +26,7 @@
"@n8tb1t/use-scroll-position": "^2.0.3",
"@thirdweb-dev/chain-icons": "^1.0.2",
"@thirdweb-dev/react": "^2.2.2",
"@thirdweb-dev/sdk": "^2.1.4-0",
"@thirdweb-dev/sdk": "^2.1.4",
"color": "^4.0.1",
"date-fns": "^2.28.0",
"emotion-theming": "^11.0.0",
+4 -4
View File
@@ -1784,10 +1784,10 @@
tiny-invariant "^1.2.0"
wagmi "^0.2.28"
"@thirdweb-dev/sdk@^2.1.4-0":
version "2.1.4-0"
resolved "https://registry.yarnpkg.com/@thirdweb-dev/sdk/-/sdk-2.1.4-0.tgz#e48f65582790b7d307eb3d4f858443c7bb8ce31c"
integrity sha512-WXBOeQsEDNpLmtBMAtutUKW44JzBmA85GfVHYE4fkX9001D5iC8vE3cNbmHj6vVatoqRUl1EtQRbwMWMnP28/Q==
"@thirdweb-dev/sdk@^2.1.4":
version "2.1.4"
resolved "https://registry.yarnpkg.com/@thirdweb-dev/sdk/-/sdk-2.1.4.tgz#71dfa199cf2bff7bef68996238a9f80be9cd6f9a"
integrity sha512-Fa2U3QpMhWnlJvt8q+4hElmt2aLNgdJbdmS6BB8Ds0fOqfWFSEPwuva2wiq0tHPsdMqCvCuXDhWVsaTEiVmMEQ==
dependencies:
"@ethersproject/bignumber" "^5.6.0"
"@ethersproject/bytes" "^5.6.1"