diff --git a/web/components/organisms/deploy/DeploySOResolver.tsx b/web/components/organisms/deploy/DeploySOResolver.tsx index de6dc1d..d7812a6 100644 --- a/web/components/organisms/deploy/DeploySOResolver.tsx +++ b/web/components/organisms/deploy/DeploySOResolver.tsx @@ -5,7 +5,7 @@ import { FC, useEffect, useMemo, useState } from "react"; import { useAccount, useChainId, useSimulateContract, useSwitchChain, useWriteContract } from "wagmi"; import { Address, formatEther } from "viem"; import { useDeployedResolvers } from "../../../stores/deployed_resolvers"; -import { SORDeployments } from "../../../util/deployments"; +import { SORDeployments, isSOREnabled } from "../../../util/deployments"; // https url that must include '{sender}' // const gatewayRegex = new RegExp("^https://.*{sender}.*$"); @@ -38,7 +38,10 @@ export const DeployResolverCard: FC = () => { const isGatewayUrlValid = gatewayRegex.test(gatewayUrl.trim()); const isSignersValid = signersRegex.test(signers.trim()); - const isReady = isGatewayUrlValid && isSignersValid; + const enabledOnChain = isSOREnabled(chainId); + const isReadyForChain = enabledOnChain === 'available'; + + const isReady = isGatewayUrlValid && isSignersValid && isReadyForChain; const factoryAddress = SORDeployments[chainId]?.[0]?.factory; @@ -54,45 +57,7 @@ export const DeployResolverCard: FC = () => { const { chains, switchChain } = useSwitchChain(); - const {writeContract} = useWriteContract(); - - // const { write, data } = useContractWrite(config); - // const receipt = useWaitForTransaction(data); - - // const gas = useMemo(() => { - // if (!EstimateData) return null; - // if (!FeeData) return null; - // if (!FeeData.gasPrice) return null; - - // const num = FeeData.gasPrice.mul(EstimateData.request.gasLimit); - // const goerliOffset = chainId == 5 ? 1000n : 1n; - - // return { - // // Is it me or is goerli fee data off by /1000 - // gasTotal: formatEther(num.toBigInt() / goerliOffset, 'gwei').substring(0, 8), - // } - // }, [FeeData, EstimateData]); - - // console.log({ receipt: receipt?.data }); - - // useEffect(() => { - // if (!data) return; - - // logTransaction(data.hash, chainId.toString()); - // }, [data]); - - // useEffect(() => { - // if (!receipt?.data) return; - - // const x = receipt.data; - - // const first = x.logs[0]; - // const address = first.address; - - // console.log('Contracted Deployed at: ' + address); - - // logTransactionSuccess(receipt.data.transactionHash, chainId.toString(), address); - // }, [receipt?.data]); + const { writeContract } = useWriteContract(); return ( @@ -111,6 +76,18 @@ export const DeployResolverCard: FC = () => { options={chains.map((chain) => ({ value: chain.id.toString(), label: chain.name, + node:
+
{chain.name}
+
+ {(() => { + switch (isSOREnabled(chain.id)) { + case 'available': return Available; + case 'deprecated': return Deprecated; + case 'unavailable': return Unavailable; + } + })()} +
+
}))} onChange={(event) => { switchChain({ @@ -203,9 +180,13 @@ export const DeployResolverCard: FC = () => { chainId, functionName: 'createOffchainResolver', args: [gatewayUrl, signersToArray(signers)], + }, { + onSuccess(data, variables, context) { + logTransaction(data, chainId.toString());; + } }) }}> - { isLoading ? 'Estimating Fees...' : isSuccess ? 'Deploy ' + EstimateData?.request.gas + ' gas' : 'Deploy'} + {isLoading ? 'Estimating Fees...' : isSuccess ? 'Deploy ' + EstimateData?.request.gas + ' gas' : 'Deploy'} ); })() diff --git a/web/components/organisms/deployed_resolvers/DeployedResolvers.tsx b/web/components/organisms/deployed_resolvers/DeployedResolvers.tsx index 76fcb3e..8a63c97 100644 --- a/web/components/organisms/deployed_resolvers/DeployedResolvers.tsx +++ b/web/components/organisms/deployed_resolvers/DeployedResolvers.tsx @@ -22,7 +22,7 @@ export const DeployedResolvers = () => {
{ - transactionForChain.map((transaction) => ) + transactionForChain.map((transaction) => ).reverse() }
diff --git a/web/components/organisms/deployed_resolvers/PendingResolver.tsx b/web/components/organisms/deployed_resolvers/PendingResolver.tsx index 0b6e291..c4616a2 100644 --- a/web/components/organisms/deployed_resolvers/PendingResolver.tsx +++ b/web/components/organisms/deployed_resolvers/PendingResolver.tsx @@ -1,7 +1,7 @@ import { FC, useEffect } from "react"; import { FiExternalLink, FiLoader } from "react-icons/fi"; import { TransactionStatePending, useDeployedResolvers } from "../../../stores/deployed_resolvers"; -import { explorer_urls } from "../../../util/deployments"; +import { chainIdToName, explorer_urls } from "../../../util/deployments"; import { useWaitForTransactionReceipt } from "wagmi"; export const PendingResolver: FC<{ transaction: TransactionStatePending }> = ({ transaction }) => { @@ -40,7 +40,7 @@ export const PendingResolver: FC<{ transaction: TransactionStatePending }> = ({ on - {transaction.chain} + {chainIdToName(Number.parseInt(transaction.chain))} diff --git a/web/util/deployments.ts b/web/util/deployments.ts index 8df7a67..0a7bb4d 100644 --- a/web/util/deployments.ts +++ b/web/util/deployments.ts @@ -8,6 +8,12 @@ type SORDeployment = { version: SORVersion; }; +export const isSOREnabled = (chainId: number) => { + if (chainId == 5) return 'deprecated'; + if (SORDeployments.hasOwnProperty(chainId) && SORDeployments[chainId].length > 0) return 'available'; + return 'unavailable'; +}; + export const SORDeployments: Record = { [mainnet.id]: [ {