UNPKG

@particle-network/auth-core-modal

Version:

Auth Core provides MPC (Multi-Party Computation)-based threshold signatures.

3 lines (2 loc) 1.51 kB
"use client"; import{F as y,G as A,ia as h,ka as g,ua as C}from"./chunk-CNYYVI6H.js";import"./chunk-L535NPP3.js";import{AuthCoreEvent as o,getUserInfo as E,isConnected as P}from"@particle-network/auth-core";import{walletEntryPlugin as n}from"@particle-network/wallet";import O,{useCallback as b,useEffect as I}from"react";var D=()=>{var u;let{provider:l}=h(),{wallet:i}=g(),{openAccountAndSecurity:c}=y(),{modalOptions:e}=C(),{connected:r}=A(),a=b(async t=>{if(t==="open-account-and-security")c();else if(t==="get-user-info")return E()},[c]);return I(()=>{var t,s,d;if(((t=e.wallet)==null?void 0:t.visible)!==!1){let v={...e.wallet,erc4337:e.erc4337,language:e.language};n.init({projectId:e.projectId,clientKey:e.clientKey,appId:e.appId},v);let f=()=>{n.walletEntryCreate()},p=()=>{n.walletEntryDestroy()};return typeof window!="undefined"&&((s=window.particleAuth)==null||s.on(o.ParticleAuthDisconnect,p),(d=window.particleAuth)==null||d.on(o.ParticleAuthConnect,f)),P()&&n.walletEntryCreate(),()=>{var w,m;typeof window!="undefined"&&((w=window.particleAuth)==null||w.off(o.ParticleAuthDisconnect,p),(m=window.particleAuth)==null||m.off(o.ParticleAuthConnect,f))}}},[e.projectId,e.clientKey,e.appId,e.wallet,e.erc4337,e.language]),I(()=>{var t;r&&((t=e.wallet)==null?void 0:t.visible)!==!1&&n.setWalletCore({ethereum:l,solana:i},a)},[r,l,i,(u=e.wallet)==null?void 0:u.visible,a]),O.createElement("div",{id:"auth-core-modal-wallet-plugin",style:{display:"none"}},"Wallet Plugin")},G=D;export{G as default};