Skip to content

Commit

Permalink
add types to configStore
Browse files Browse the repository at this point in the history
  • Loading branch information
mezger75 committed Jul 21, 2024
1 parent d4c13ae commit 3b6cf5f
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions frontend/src/app/store/configStore.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import {create} from "zustand";
import { create } from "zustand";
import ApiDomainService from "@/app/api/api-domain-service";
import { Abi } from "viem";

export interface ConfigState {
contractConfig: ContractConfig; // Define a more specific type based on your configuration
setConractConfig: (config: any) => void;
contractConfig: ContractConfig;
setConractConfig: (config: ContractConfig) => void;
fetchContractConfig: () => Promise<ContractConfig>;
wagmiConfig: any;
setWagmiConfig: (config: any) => void;
}

0;
export interface ContractConfig {
chains: ChainConfig[];
abi: any[];
abi: Abi[];
}

export interface ChainConfig {
Expand All @@ -21,23 +23,22 @@ export interface ChainConfig {
contract: string;
}


const abi: any[] = [];
const abi: Abi[] = [];

const chains: ChainConfig[] = [];

export const useConfigStore = create<ConfigState>((set) => ({
contractConfig: {chains, abi},
contractConfig: { chains, abi },
wagmiConfig: {},
setConractConfig: (contractConfig) => set({contractConfig}),
setWagmiConfig: (wagmiConfig) => set({wagmiConfig}),
setConractConfig: (contractConfig) => set({ contractConfig }),
setWagmiConfig: (wagmiConfig) => set({ wagmiConfig }),
fetchContractConfig: async () => {
const apiUrl = new ApiDomainService().getRestUrl();
return fetch(`${apiUrl}/contract/config`)
.then((response) => response.json())
.then((data) => {
set({contractConfig: data});
set({ contractConfig: data });
return data;
});
}
},
}));

0 comments on commit 3b6cf5f

Please sign in to comment.