import { DEFAULT_GLOBAL_CONFIG } from '@/lib/constants' import { LastDeploymentData, DeployContractParams, GlobalConfig, VerifyContractParams } from '@/lib/functions/types' import { create } from 'zustand' interface GlobalState { // configs globalConfig: GlobalConfig setGlobalConfig: (globalConfig: GlobalConfig) => void verifyContractConfig?: Partial setVerifyContractConfig: ( verifyContractConfig: Partial ) => void deployContractConfig?: Partial setDeployContractConfig: ( deployContractConfig: Partial ) => void // loading states isLoading: boolean setIsLoading: (isLoading: boolean) => void isGenerating: boolean setIsGenerating: (isGenerating: boolean) => void isDeploying: boolean setIsDeploying: (isDeploying: boolean) => void isVerifying: boolean setIsVerifying: (isPolling: boolean) => void // last deployment data lastDeploymentData?: LastDeploymentData setLastDeploymentData: (lastDeploymentData: LastDeploymentData) => void } export const useGlobalStore = create(set => ({ // configs globalConfig: DEFAULT_GLOBAL_CONFIG, setGlobalConfig: (globalConfig: GlobalConfig) => set({ globalConfig }), verifyContractConfig: undefined, setVerifyContractConfig: ( verifyContractConfig: Partial ) => set({ verifyContractConfig }), deployContractConfig: undefined, setDeployContractConfig: ( deployContractConfig: Partial ) => set({ deployContractConfig }), // loading states isLoading: false, setIsLoading: (isLoading: boolean) => set({ isLoading }), isGenerating: false, setIsGenerating: (isGenerating: boolean) => set({ isGenerating }), isDeploying: false, setIsDeploying: (isDeploying: boolean) => set({ isDeploying }), isVerifying: false, setIsVerifying: (isVerifying: boolean) => set({ isVerifying }), // last deployment data lastDeploymentData: undefined, setLastDeploymentData: (lastDeploymentData: LastDeploymentData) => set({ lastDeploymentData }) }))