@particle-network/authkit
Version:
Auth Core provides MPC (Multi-Party Computation)-based threshold signatures.
3 lines (2 loc) • 1.81 kB
JavaScript
"use client";
import{H as h,ha as y,ja as m,pa as A,ta as C}from"./chunk-6YEBFRI3.mjs";import"./chunk-2FKLQE76.mjs";import{AuthCoreEvent as f,isConnected as E}from"@particle-network/auth-core";import I,{useCallback as P,useEffect as g}from"react";var v=()=>{let{provider:l}=y(),{wallet:a}=m(),{modalOptions:e}=C(),{connected:w}=h(),{walletEntryPlugin:t}=A(),r=P(async c=>{var i,s,p,o,u;if(c==="open-account-and-security")(s=(i=window.particle)==null?void 0:i._internal)==null||s.openAccountAndSecurity();else if(c==="get-user-info")return(u=(o=(p=window.particle)==null?void 0:p._internal)==null?void 0:o.getUserInfo)==null?void 0:u.call(o)},[]);return g(()=>{var c,i,s;if(e.wallet!==!1&&t){let p={...e.wallet,erc4337:e.erc4337,language:e.language,customStyle:{...e.customStyle,supportChains:(c=e.chains)==null?void 0:c.map(n=>{var d;return{id:n.id,name:n.name,chainType:((d=n==null?void 0:n.custom)==null?void 0:d.chainType)||"evm"}})}};t.init({projectId:e.projectId,clientKey:e.clientKey,appId:e.appId},p);let o=()=>{t.setWalletCore({ethereum:l,solana:a,customEventHandler:r}),t.walletEntryCreate()},u=()=>{t.walletEntryDestroy()};return typeof window!="undefined"&&((i=window.particleAuth)==null||i.on(f.ParticleAuthDisconnect,u),(s=window.particleAuth)==null||s.on(f.ParticleAuthConnect,o)),E()&&(t.setWalletCore({ethereum:l,solana:a,customEventHandler:r}),t.walletEntryCreate()),()=>{var n,d;typeof window!="undefined"&&((n=window.particleAuth)==null||n.off(f.ParticleAuthDisconnect,u),(d=window.particleAuth)==null||d.off(f.ParticleAuthConnect,o))}}},[e,l,a,r,t]),g(()=>{w&&e.wallet!==!1&&t&&t.setWalletCore({ethereum:l,solana:a,customEventHandler:r})},[w,l,a,e.wallet,r,t]),I.createElement("div",{id:"auth-core-modal-wallet-plugin",style:{display:"none"}},"Wallet Plugin")},U=v;export{U as default};