applications/videofolder/source.js
//init tronWeb based on tronLink state
init tronWeb based on tronLink state
init tronWeb based on tronLink state
async function initTronLink(tronWeb){
    let promise = new Promise((resolve, reject) => {
        setTimeout(()=>{
            resolve(tronWeb)
        }, tronLinkTimeout)
        try{
           window.tronWeb.contract().at(contractAddr).then(() => {
                let isInstalled = false;
                let isSignedIn = false;
                if(window.tronWeb !== undefined){
                    isInstalled = true;
                    window.isTronLink = true;
                    if (window.tronWeb.defaultAddress.hex !== false){
                        isSignedIn = true;
                    }
                }
                console.log('isInstalled', isInstalled)
                console.log('isSignedIn', isSignedIn)
                if(isInstalled && isSignedIn){
                    resolve(window.tronWeb) 
                }
                resolve(tronWeb)
            })
        }
        catch{
            window.isTronLink = false;
            resolve(tronWeb)
        }
    })
    return promise;
}
async function initTronLink ( tronWeb ) { let promise = new Promise ( ( resolve , reject ) => { setTimeout ( ( ) => { resolve ( tronWeb ) } , tronLinkTimeout ) try { window . tronWeb . contract ( ) . at ( contractAddr ) . then ( ( ) => { let isInstalled = false ; let isSignedIn = false ; if ( window . tronWeb !== undefined ) { isInstalled = true ; window . isTronLink = true ; if ( window . tronWeb . defaultAddress . hex !== false ) { isSignedIn = true ; } } console . log ( 'isInstalled' , isInstalled ) console . log ( 'isSignedIn' , isSignedIn ) if ( isInstalled && isSignedIn ) { resolve ( window . tronWeb ) } resolve ( tronWeb ) } ) } catch { window . isTronLink = false ; resolve ( tronWeb ) } } ) return promise ; }
init tronWeb based on tronLink state
init tronWeb based on tronLink state