import { useBlockchainPropertiesControllerGet } from '@energyweb/issuer-irec-api-react-query-client' ; import { useWeb3 } from '@energyweb/origin-ui-web3' ; import { IBlockchainProperties } from '@energyweb/issuer' ; import { RegistryExtended__factory as RegistryExtendedFactory } from '@energyweb/issuer/dist/js/src/ethers/factories/RegistryExtended__factory' ; import { Issuer__factory as IssuerFactory } from '@energyweb/issuer/dist/js/src/ethers/factories/Issuer__factory' ; import { Certificate } from '@energyweb/issuer/dist/js/src/blockchain-facade/Certificate' ; export const useGetBlockchainCertificateHandler = ( ) => { const { data : blockchainProperties , isLoading } = useBlockchainPropertiesControllerGet ( ) ; const { web3 } = useWeb3 ( ) ; const getBlockchainCertificate = async ( id ) => { const configuration = { web3 , registry : RegistryExtendedFactory . connect ( blockchainProperties ?. registry , web3 ) , issuer : IssuerFactory . connect ( blockchainProperties ?. issuer , web3 ) , activeUser : web3 . getSigner ( ) , } ; const certificate = new Certificate ( id , configuration ) ; await certificate . sync ( ) ; return certificate ; } ; return { getBlockchainCertificate , isLoading } ; } ;