import { networkName } from '../../../utilities' ; import { Helpers , TorusOptions , WalletModule } from '../../../interfaces' ; import torusIcon from '../wallet-icons/icon-torus' ; function torus ( options ) { const { networkId , preferred , label , iconSrc , svg , buttonPosition , modalZIndex , apiKey , buildEnv , enableLogging , enabledVerifiers , loginConfig , showTorusButton , integrity , whiteLabel , loginMethod , rpcUrl } = options ; return { name : label || 'Torus' , svg : svg || torusIcon , iconSrc , wallet : async ( helpers ) => { const { createModernProviderInterface } = helpers ; const { default : Torus } = await import ( '@toruslabs/torus-embed' ) ; const instance = new Torus ( { buttonPosition , modalZIndex , apiKey } ) ; await instance . init ( { buildEnv , enableLogging , network : { host : rpcUrl || networkName ( networkId ) , chainId : networkId , networkName : `${ networkName ( networkId ) } Network` } , showTorusButton : showTorusButton , enabledVerifiers : enabledVerifiers , loginConfig , integrity , whiteLabel } ) ; const provider = instance . provider ; return { provider , interface : { ... createModernProviderInterface ( provider ) , name : 'Torus' , dashboard : ( ) => instance . showWallet ( 'home' ) , connect : async ( ) => { const result = await instance . login ( { verifier : loginMethod } ) ; return { message : result [ 0 ] } ; } , disconnect : ( ) => instance . cleanUp ( ) } , instance } ; } , type : 'sdk' , desktop : true , mobile : true , preferred } ; } export default torus ;