* homepage: infinite looping logo carousel * split partners logo among two rows on mobile * remove lazy loading from partner logos * Fix partner logo cut off on safari * fade-in logo carousel at the container edge * v1 * v2 * remove temp code changes * switch network *technically* works, and new chains package * Fix src warning in AsyncContractTypeCell * Updated Design for config form, fix metadata error * add initial deployment status modal * Fix contract duplication bug in dashboard * Make RPC url always editable * v3 - middleware + refactor * reset form when selecting custom option * Fix crash on sources tab for unsupported chains * add missing deps in effects * /evm - use SSG with fallback * /evm - add ensQuery dehydration back * /solana - fix program page loading issue * Allow editing details for custom chains * solana program context * fix build crash * fix all the networkOrAddress getters * use chain icons from chains package * separation of fallback and final page * Fix wrong default network type in form * validation improvements in configure network form * disable custom chains from dropdown on On non thirdweb contracts deploy page * Fix wrong network slug * custom chain improvement * Fix Lightmode UI of Network Config Form * UI improvements for network search dropdown * UI tweaks * code review cleanup * UI tweaks * Network Config Form: Better Keyboard UX * fix broken /contracts/release and /contracts/deploy routes * add configure networks button for custom contract deployment page * UI tweaks for network configurator * fix merge * add the icon to the custom chain * Bunch of Improvements * Improve auto chain configuration * Do not allow adding custom network with existing chain id * Show delete default chains with 1-click add * Convert delete dialog to a popover * Retain all fields when selecting a chain from list * Allow configuring chain Icons * Allow using chainId as network slug for custom networks * Remove unnecessary chainInfos object passed in provider * configurable slug + prefill form * improve scrollbar styling * upgrade to newer sdk etc * make it work * Various testjame improvements * Stop form submit event propagation * preselect “testnet” for custom network based on name * Clear form errors when selecting a network from list * Improved UI for Delete network popover * Disable “Add Network” button when on add network page * Change fallback chain icon * custom and search tabs * reduce layout shift when switching tabs * allChains caching with idb * Add IPFS upload button for icon input * Deploy Modal, chain icon, code cleanup * Fix Deploy Modal not working for custom contract deployment * Fix Fantom testnet icon * Remove useDashboardNetwork() * Update Deploy Modal wording in case for 3 prompt scenario * Remove hardhat and localhost from CURRENCIES object * Remove gateway.ipfscdn.io from images.remotePatterns in next config * add chain config tracking * remove useChainInfos() * Remove EVM_RPC_URL_MAP usage as much as possible * Fix Network Switcher for non-default chains * upgrade new dev sdk versions * fix versions * Fix contractInfo.chain not available on contract page of custom chain * Fix contract page links in overview page * Update default chain Icon * bunch of UI improvements for network configuration modal * Better active state for add network button and chains * Suggest a slug for custom network * Show chain id next to network names in list * Allow searching by chain id * Autofocus on first input of the form * Add cross button for clearing search input * Toggle search results open state with chevron icon * Add icons in chain list * handle wallet connected to unsupported network in <SupportedNetworkSelect/> * No reload required after adding a network * revert last commit - reload still required * handle case where wallet is connected to an auto configured chain - show it as unknown network * update dependencies and switch to activeChain and supportedChains * nightly sdk versions * Improved Icon Uploader * always use default chains for polygon registry work * dev version & updated list fetching * Improved Chain ID input in Network Configurator * Improved Network ID validation and prefill * Hide etherscan verification button for non-default chains * Form Refactor + network type toolip * update deps * update package versions * upgrade dependencies * show "create custom" when no search results found * slug calculated from prefillName should not be considered dirty * open edit screen when selecting already configured network from list * fuzzy search with fuse.js * replace thirdweb key with it's value in form * temp fix for getChainRPC throwing error * update to newer chains package * lots of rpc cleanup etc * fix nightly maybe? * upgrade to nightly packages * add initial import contract search input * fix localhost * clean up smoe more stuff * lots of updates * Show "Request Testnet Funds" button in wallet when applicable (#856) * fix crash on events page * Fix Links in Overview page * import contract improvements * Fix wrong explorer tab link in ContractPermissionsPage * make search faster (individual queries) * properly split contract and program routing * remove all via stuff etc * various further improvements * add a proxy and setup storage to hit that proxy * further cleanup --------- Co-authored-by: Jonas Daniels <[email protected]> Co-authored-by: Joaquim Verges <[email protected]>
93 lines
2.4 KiB
TypeScript
93 lines
2.4 KiB
TypeScript
import { contractKeys, networkKeys } from "../cache-keys";
|
|
import { useMutationWithInvalidate } from "./query/useQueryWithNetwork";
|
|
import { useAddress, useSDK, useSigner } from "@thirdweb-dev/react";
|
|
import {
|
|
addContractToMultiChainRegistry,
|
|
getGaslessPolygonSDK,
|
|
} from "components/contract-components/utils";
|
|
import invariant from "tiny-invariant";
|
|
|
|
type RemoveContractParams = {
|
|
contractAddress: string;
|
|
};
|
|
|
|
export function useRemoveContractMutation(
|
|
chainId: number,
|
|
registry: "old" | "new" | "none",
|
|
) {
|
|
const sdk = useSDK();
|
|
const walletAddress = useAddress();
|
|
const signer = useSigner();
|
|
|
|
return useMutationWithInvalidate(
|
|
async (data: RemoveContractParams) => {
|
|
if (registry === "none") {
|
|
throw new Error(`Contract is already removed`);
|
|
}
|
|
|
|
invariant(
|
|
walletAddress,
|
|
"cannot add a contract without a wallet address",
|
|
);
|
|
invariant(sdk, "sdk not provided");
|
|
|
|
const { contractAddress } = data;
|
|
|
|
// remove from old registry
|
|
if (registry === "old") {
|
|
const oldRegistry = await sdk?.deployer.getRegistry();
|
|
return await oldRegistry?.removeContract(contractAddress);
|
|
}
|
|
|
|
// remove from new multichain registry
|
|
else {
|
|
const gaslessPolygonSDK = getGaslessPolygonSDK(signer);
|
|
return await gaslessPolygonSDK.multiChainRegistry?.removeContract({
|
|
address: contractAddress,
|
|
chainId,
|
|
});
|
|
}
|
|
},
|
|
{
|
|
onSuccess: (_data, _variables, _options, invalidate) => {
|
|
return invalidate([
|
|
networkKeys.multiChainRegistry,
|
|
contractKeys.list(walletAddress),
|
|
]);
|
|
},
|
|
},
|
|
);
|
|
}
|
|
|
|
type AddContractParams = {
|
|
contractAddress: string;
|
|
chainId: number;
|
|
};
|
|
|
|
export function useAddContractMutation() {
|
|
const sdk = useSDK();
|
|
const walletAddress = useAddress();
|
|
const signer = useSigner();
|
|
|
|
return useMutationWithInvalidate(
|
|
async (data: AddContractParams) => {
|
|
invariant(walletAddress, "cannot add a contract without an address");
|
|
invariant(sdk, "sdk not provided");
|
|
|
|
// add to new multichain registry
|
|
return await addContractToMultiChainRegistry(
|
|
{
|
|
address: data.contractAddress,
|
|
chainId: data.chainId,
|
|
},
|
|
signer,
|
|
);
|
|
},
|
|
{
|
|
onSuccess: (_data, _variables, _options, invalidate) => {
|
|
return invalidate([networkKeys.multiChainRegistry]);
|
|
},
|
|
},
|
|
);
|
|
}
|