From ee822b75ab4016facbfd6e5cb4ee10710efe2f1c Mon Sep 17 00:00:00 2001 From: Kilter Date: Wed, 4 Dec 2024 15:22:52 -0500 Subject: [PATCH 1/4] integrating base for recurring anchor contract --- .../views/create/AddressInterface.tsx | 80 +++++++++++++++++-- .../create/AlloProtocol/AlloProtocolModal.tsx | 53 ++++++++++++ src/components/views/create/CreateProject.tsx | 9 ++- src/config/development.tsx | 1 + src/config/production.tsx | 1 + src/types/config.ts | 6 +- 6 files changed, 140 insertions(+), 10 deletions(-) diff --git a/src/components/views/create/AddressInterface.tsx b/src/components/views/create/AddressInterface.tsx index c6a2e251fc..311271d1e4 100644 --- a/src/components/views/create/AddressInterface.tsx +++ b/src/components/views/create/AddressInterface.tsx @@ -1,5 +1,6 @@ import { useFormContext } from 'react-hook-form'; import { useIntl } from 'react-intl'; +import { useAccount, useSwitchChain } from 'wagmi'; import styled, { css } from 'styled-components'; import { B, @@ -23,13 +24,16 @@ import { getChainName } from '@/lib/network'; import { IChainType } from '@/types/config'; import { findAddressByChain } from '@/lib/helpers'; import { useGeneralWallet } from '@/providers/generalWalletProvider'; -import { IAnchorContractData } from '@/apollo/types/types'; +import { IAnchorContractData, IProject } from '@/apollo/types/types'; import { IconWithTooltip } from '@/components/IconWithToolTip'; import { EInputs } from './types'; import links from '@/lib/constants/links'; +import { STOP_RECURRING_SETUP_ON_CREATION } from './CreateProject'; +import { saveAnchorContract } from './AlloProtocol/AlloProtocolModal'; interface IAddressInterfaceProps extends IChainType { networkId: number; + project?: IProject; onButtonClick?: () => void; anchorContractData?: IAnchorContractData; isEditMode?: boolean; @@ -41,21 +45,30 @@ interface IconContainerProps { const AddressInterface = ({ networkId, + project, onButtonClick, chainType, anchorContractData, isEditMode, }: IAddressInterfaceProps) => { + const { chain } = useAccount(); + const { switchChain } = useSwitchChain(); const { setValue, watch } = useFormContext(); const { formatMessage } = useIntl(); const { isOnEVM } = useGeneralWallet(); + const isOnOptimism = chain + ? chain.id === config.OPTIMISM_NETWORK_NUMBER + : false; + const isOnBase = chain ? chain.id === config.BASE_NETWORK_NUMBER : false; + const inputName = EInputs.addresses; const alloProtocolRegistry = watch(EInputs.alloProtocolRegistry) as boolean; const value = watch(inputName); const isOptimism = networkId === config.OPTIMISM_NETWORK_NUMBER; + const isBase = networkId === config.BASE_NETWORK_NUMBER; const addressObj = findAddressByChain(value, networkId, chainType); const walletAddress = addressObj?.address; @@ -67,6 +80,15 @@ const AddressInterface = ({ config.OPTIMISM_NETWORK_NUMBER, chainType, ); + const hasBaseAddress = !!findAddressByChain( + value, + config.BASE_NETWORK_NUMBER, + chainType, + ); + const isRecurringOnOptimismReady = isOptimism && hasOptimismAddress; + const isRecurringOnBaseReady = isBase && hasBaseAddress; + const isRecurringDonationsReady = + isRecurringOnBaseReady || isRecurringOnOptimismReady; return ( @@ -117,7 +139,7 @@ const AddressInterface = ({ {hasAddress ? walletAddress : 'No address added yet!'} {hasAddress && - (hasAnchorContract && isOptimism ? ( + (hasAnchorContract && (isOptimism || isBase) ? ( ))} - {isOptimism && isOnEVM && ( - // Render this section only on Optimism + {(isOptimism || isBase) && isOnEVM && ( + // Render this section only on Optimism and Base - +
{hasAnchorContract && isEditMode @@ -192,18 +214,55 @@ const AddressInterface = ({ + ) : STOP_RECURRING_SETUP_ON_CREATION ? ( + +