@@ -2,8 +2,8 @@ import * as fcl from "@onflow/fcl"
22import useAccounts from "hooks/useAccounts"
33import { ConnectedAppConfig } from "hooks/useConnectedAppConfig"
44import { Account } from "src/accounts"
5- import React , { createContext , useEffect , useMemo , useState } from "react"
6- import { WalletUtils } from "@onflow/fcl "
5+ import React , { createContext , useMemo , useState } from "react"
6+ import { useFclData } from "hooks/useFclData "
77
88type AuthzReadyData = {
99 type : string
@@ -92,19 +92,15 @@ export const AuthzContext = createContext<AuthzContextType>({
9292} )
9393
9494export function AuthzContextProvider ( { children} : { children : React . ReactNode } ) {
95- const [ signable , setSignable ] = useState < AuthSignable | null > ( null )
95+ const signable = useFclData < AuthSignable > ( {
96+ transformFrontchannel : ( data : AuthzReadyData ) => {
97+ return data . body
98+ } ,
99+ } )
96100 const [ codePreview , setCodePreview ] = useState < CodePreview | null > ( null )
97101
98102 const { data : accountsData } = useAccounts ( )
99103
100- useEffect ( ( ) => {
101- function callback ( data : AuthzReadyData ) {
102- setSignable ( data . body )
103- }
104-
105- WalletUtils . ready ( callback )
106- } , [ ] )
107-
108104 const accounts = useMemo ( ( ) => {
109105 if ( ! accountsData ) return { }
110106 const hash : Record < string , Account > = { }
0 commit comments