diff --git a/src/provider/masa-context-provider.tsx b/src/provider/masa-context-provider.tsx index 58607953..cb475ce6 100644 --- a/src/provider/masa-context-provider.tsx +++ b/src/provider/masa-context-provider.tsx @@ -141,7 +141,7 @@ export const MasaContextProvider = ({ } = useModal(isLoggedIn, hasWalletAddress, areScopesFullfiled); // custom SBTs - const { customContracts } = useCustomGallerySBT( + const { customContracts, handleAddSBT } = useCustomGallerySBT( masaInstance, customGallerySBT ); @@ -301,6 +301,7 @@ export const MasaContextProvider = ({ fullScreenGallery, // custom SBTs customSBTs, + handleAddSBT, }; return ( diff --git a/src/provider/masa-shape.ts b/src/provider/masa-shape.ts index ec5b5617..199f35bd 100644 --- a/src/provider/masa-shape.ts +++ b/src/provider/masa-shape.ts @@ -115,4 +115,5 @@ export interface MasaShape { fullScreenGallery?: boolean; // customSBTs customSBTs?: any[]; + handleAddSBT?: (isCollection: boolean, name: string, address: string) => void; } diff --git a/src/provider/modules/custom-sbts/custom-sbts.ts b/src/provider/modules/custom-sbts/custom-sbts.ts index 0993b75b..5f5b7c85 100644 --- a/src/provider/modules/custom-sbts/custom-sbts.ts +++ b/src/provider/modules/custom-sbts/custom-sbts.ts @@ -1,11 +1,24 @@ -import { useEffect, useState } from 'react'; +import { useLocalStorage } from 'provider/use-local-storage'; +import { useCallback, useEffect, useState } from 'react'; export const useCustomGallerySBT = ( masa, customGallerySBT -): { customContracts: any[] } => { +): { + customContracts: any[]; + handleAddSBT: (isCollection: boolean, name: string, address: string) => void; +} => { + const { localStorageSet } = useLocalStorage(); + const [contracts, setContracts] = useState([]); + const handleAddSBT = useCallback((isCollection, name, address) => { + localStorageSet(`masa-gallery-${isCollection ? 'sbt' : 'badge'}-${name}`, { + address, + name, + }); + }, []); + useEffect(() => { if (masa) { (async () => { @@ -21,7 +34,7 @@ export const useCustomGallerySBT = ( } }, [customGallerySBT, masa]); - return { customContracts: contracts }; + return { customContracts: contracts, handleAddSBT }; }; export const useCustomSBT = (masa, customContracts) => { diff --git a/src/provider/modules/soulnames/soulnames.ts b/src/provider/modules/soulnames/soulnames.ts index 8befaea4..9afdaafa 100644 --- a/src/provider/modules/soulnames/soulnames.ts +++ b/src/provider/modules/soulnames/soulnames.ts @@ -67,8 +67,6 @@ export const useSoulnames = ( [masa] ); - console.log({ soulnames, isLoading, status, error }); - return { soulnames, isSoulnamesLoading: isLoading || isFetching,