@privy-io/react-auth 1.92.2 → 1.92.3-beta-20241024200145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/cjs/events-context-DoOSxXpH.js +1 -0
  2. package/dist/cjs/getEmbeddedConnectedWallet-DLJVq5Hk.js +1 -0
  3. package/dist/cjs/index.js +231 -226
  4. package/dist/cjs/{privy-context-Do1698Nd.js → privy-context-CGQoQ1iQ.js} +1 -1
  5. package/dist/cjs/smart-wallets.js +1 -1
  6. package/dist/cjs/solana.js +1 -1
  7. package/dist/cjs/ui.js +1 -1
  8. package/dist/cjs/{useFundWallet-DEtObexE.js → useFundWallet-gcAF6eQj.js} +2 -2
  9. package/dist/cjs/{useSolanaWallets-B7NjCslk.js → useSolanaWallets-9YEhqb4o.js} +1 -1
  10. package/dist/cjs/{useWallets-Db8wjylW.js → useWallets-fvZTYN8Z.js} +1 -1
  11. package/dist/dts/index.d.mts +12 -1
  12. package/dist/dts/index.d.ts +12 -1
  13. package/dist/dts/smart-wallets.d.mts +3 -2
  14. package/dist/dts/smart-wallets.d.ts +3 -2
  15. package/dist/esm/events-context-BcbWmpUg.mjs +1 -0
  16. package/dist/esm/getEmbeddedConnectedWallet-BF0i-4Oo.mjs +1 -0
  17. package/dist/esm/index.mjs +328 -323
  18. package/dist/esm/privy-context--IShbIGm.mjs +1 -0
  19. package/dist/esm/smart-wallets.mjs +1 -1
  20. package/dist/esm/solana.mjs +1 -1
  21. package/dist/esm/ui.mjs +1 -1
  22. package/dist/esm/{useFundWallet-D5B39g9B.mjs → useFundWallet-BBE2QbPF.mjs} +1 -1
  23. package/dist/esm/{useSolanaWallets-DFH-p-7f.mjs → useSolanaWallets-BK1ZsW9P.mjs} +1 -1
  24. package/dist/esm/useWallets-ctd8F0LF.mjs +1 -0
  25. package/package.json +3 -3
  26. package/dist/cjs/events-context-DZk3apgV.js +0 -1
  27. package/dist/cjs/getEmbeddedConnectedWallet-CaBjd2bz.js +0 -1
  28. package/dist/esm/events-context-DLn7buIf.mjs +0 -1
  29. package/dist/esm/getEmbeddedConnectedWallet-Dv6wjrtm.mjs +0 -1
  30. package/dist/esm/privy-context-QVrL4VJ3.mjs +0 -1
  31. package/dist/esm/useWallets-BQQjDV6b.mjs +0 -1
@@ -0,0 +1 @@
1
+ import{FetchError as e}from"ofetch";import{createContext as t,useContext as n}from"react";var i;class a extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(e,t,n){super(e),t instanceof Error&&(this.cause=t),this.privyErrorCode=n}}class s extends a{constructor(e,t,n,i,a,s){super(n,i,a),this.type=e,this.status=t,this.data=s}}class l extends a{constructor(e,t,n){super(e,t,n),this.type="client_error"}}class r extends l{constructor(){super("Request timed out",void 0,"client_request_timeout")}}class o extends a{constructor(e,t,n){super(e,t,n),this.type="connector_error"}}const _=t=>{if(t instanceof a)return t;if(!(t instanceof e))return d(t);if(!t.response)return new s("api_error",null,t.message,t);let{type:n,message:i,error:l,code:r}=t.data;return new s(n||"ApiError",t.response.status,i||l,t,r,t.data)},d=e=>e instanceof a?e:e instanceof Error?new l(e.message,e):new l(`Internal error: ${e}`);var u;(i=u||(u={})).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",i.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",i.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",i.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",i.INVALID_DATA="invalid_data",i.INVALID_CAPTCHA="invalid_captcha",i.LINKED_TO_ANOTHER_USER="linked_to_another_user",i.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",i.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",i.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",i.USER_EXITED_UPDATE_FLOW="exited_update_flow",i.ALLOWLIST_REJECTED="allowlist_rejected",i.OAUTH_USER_DENIED="oauth_user_denied",i.OAUTH_UNEXPECTED="oauth_unexpected",i.UNKNOWN_AUTH_ERROR="unknown_auth_error",i.USER_EXITED_AUTH_FLOW="exited_auth_flow",i.USER_EXITED_LINK_FLOW="exited_link_flow",i.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",i.MUST_BE_AUTHENTICATED="must_be_authenticated",i.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",i.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",i.CLIENT_REQUEST_TIMEOUT="client_request_timeout",i.INVALID_CREDENTIALS="invalid_credentials",i.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",i.UNKNOWN_MFA_ERROR="unknown_mfa_error",i.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",i.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",i.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",i.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",i.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",i.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",i.TRANSACTION_FAILURE="transaction_failure",i.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",i.NOT_SUPPORTED="not_supported",i.CAPTCHA_TIMEOUT="captcha_timeout",i.INVALID_MESSAGE="invalid_message",i.UNABLE_TO_SIGN="unable_to_sign",i.CAPTCHA_FAILURE="captcha_failure",i.CAPTCHA_DISABLED="captcha_disabled",i.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",i.TOO_MANY_REQUESTS="too_many_requests",i.USER_LIMIT_REACHED="max_accounts_reached",i.DISALLOWED_LOGIN_METHOD="disallowed_login_method",i.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",i.PASSKEY_NOT_ALLOWED="passkey_not_allowed",i.USER_DOES_NOT_EXIST="user_does_not_exist",i.INSUFFICIENT_BALANCE="insufficient_balance",i.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required";class c extends l{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}}class E extends l{constructor(e="Embedded wallet error",t){super(e,t,"unknown_embedded_wallet_error")}}class A extends l{constructor(e="User must be authenticated"){super(e,void 0,"must_be_authenticated")}}class p extends l{constructor(e){super("This application is in development mode and must be upgraded to production to log in new users.",e,"max_accounts_reached")}}const S=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},h=e=>()=>{throw Error(e.trim())},T=t({isNewUserThisSession:!1,walletConnectionStatus:null,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,appId:"notAdded",customAuthStatus:{status:"not-enabled"},noPromptOnSignature:{current:!1},nativeTokenSymbolForChainId:S,initializeWalletProxy:S,getAuthMeta:S,getAuthFlow:S,closePrivyModal:S,openPrivyModal:S,connectWallet:S,initLoginWithWallet:S,loginWithWallet:S,initLoginWithFarcaster:S,loginWithFarcaster:S,loginWithCode:S,initLoginWithEmail:S,initLoginWithSms:S,initUpdateEmail:S,initUpdatePhone:S,resendEmailCode:S,resendSmsCode:S,initLoginWithHeadlessOAuth:S,loginWithHeadlessOAuth:S,crossAppAuthFlow:S,initLoginWithOAuth:S,recoveryOAuthFlow:S,loginWithOAuth:S,passkeyAuthState:{status:"initial"},setPasskeyAuthState:S,initLoginWithPasskey:S,loginWithPasskey:S,initLinkWithPasskey:S,linkWithPasskey:S,refreshUser:S,loginWithGuestAccountFlow:S,walletProxy:null,createAnalyticsEvent:S,acceptTerms:S,getUsdTokenPrice:S,getUsdPriceForSol:S,recoverEmbeddedEthereumWallet:S,getMoonpaySignedUrl:S,initCoinbaseOnRamp:S,getCoinbaseOnRampStatus:S,updateWallets:S,fundWallet:S,fundSolanaWallet:S,setReadyToTrue:S,requestFarcasterSignerStatus:S,initLoginWithTelegram:S,loginWithTelegram:S,generateSiweMessage:S,generateSiweMessageForSmartWallet:S,linkWithSiwe:S,linkSmartWallet:S,delegateWallet:S,revokeDelegatedWallet:S,embeddedSolanaWallet:null,createEmbeddedSolanaWallet:S,recoverEmbeddedSolanaWallet:S,exportSolanaWallet:S,solanaSignMessage:S,connectCoinbaseSmartWallet:S,initiateAccountTransfer:S,emailOtpState:{status:"initial"},setEmailOtpState:S,smsOtpState:{status:"initial"},setSmsOtpState:S,siweState:{status:"initial"},setSiweState:S,oAuthState:{status:"initial"},setOAuthState:S}),m=()=>n(T),W=t({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:S,login:S,connectOrCreateWallet:S,linkEmail:S,linkPhone:S,linkFarcaster:S,linkWallet:S,startCrossAppAuthFlow:S,linkGoogle:S,linkTwitter:S,linkDiscord:S,linkGithub:S,linkSpotify:S,linkInstagram:S,linkTelegram:S,linkTiktok:S,linkLinkedIn:S,linkApple:S,linkPasskey:S,updateEmail:S,updatePhone:S,logout:S,getAccessToken:S,getEthereumProvider:S,getEthersProvider:S,getWeb3jsProvider:S,unlinkEmail:S,unlinkPhone:S,unlinkWallet:S,unlinkGoogle:S,unlinkTwitter:S,unlinkDiscord:S,unlinkGithub:S,unlinkSpotify:S,unlinkInstagram:S,unlinkTiktok:S,unlinkLinkedIn:S,unlinkApple:S,unlinkCrossAppAccount:S,unlinkFarcaster:S,unlinkTelegram:S,unlinkPasskey:S,setActiveWallet:S,forkSession:S,createWallet:S,importWallet:S,signMessage:S,signTypedData:S,enrollInMfa:S,initEnrollmentWithSms:S,initEnrollmentWithTotp:S,initEnrollmentWithPasskey:S,promptMfa:S,init:S,submitEnrollmentWithSms:S,submitEnrollmentWithTotp:S,submitEnrollmentWithPasskey:S,unenroll:S,submit:S,cancel:S,sendTransaction:S,sendSolanaTransaction:S,exportWallet:S,setWalletPassword:S,setWalletRecovery:S,requestFarcasterSignerFromWarpcast:S,getFarcasterSignerPublicKey:S,signFarcasterMessage:S,createGuestAccount:S,initLoginWithEmail:S,initLoginWithSms:S,otpState:{status:"initial"},loginWithCode:S,fundWallet:S,initLoginWithHeadlessOAuth:S,loginWithHeadlessOAuth:S,generateSiweMessage:S,linkWithSiwe:S,signMessageWithCrossAppWallet:S,signTypedDataWithCrossAppWallet:S,sendTransactionWithCrossAppWallet:S,isHeadlessOAuthLoading:!1,isModalOpen:!1,mfaMethods:[]}),g=()=>n(W);export{T as I,l as P,u as a,a as b,o as c,r as d,d as e,_ as f,s as g,g as h,p as i,E as j,A as k,W as l,c as m,S as n,h as o,m as u};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useRef as t,useState as a,useCallback as n,useContext as r,useEffect as i,createContext as s}from"react";import{z as o,a3 as l}from"./useWallets-BQQjDV6b.mjs";import{P as c,u as d,h as m}from"./privy-context-QVrL4VJ3.mjs";import{u,g as p,M as f}from"./getEmbeddedConnectedWallet-Dv6wjrtm.mjs";export{b as useAbstractSmartWallets}from"./getEmbeddedConnectedWallet-Dv6wjrtm.mjs";import{createSmartAccountClient as h}from"permissionless";import{toLightSmartAccount as g,toBiconomySmartAccount as y,toEcdsaKernelSmartAccount as w,toSafeSmartAccount as W}from"permissionless/accounts";import{createPimlicoClient as P}from"permissionless/clients/pimlico";import{createPublicClient as E,http as v}from"viem";import{entryPoint06Address as C,entryPoint07Address as S}from"viem/account-abstraction";import"@ethersproject/providers";import"tinycolor2";import"ofetch";import"viem/actions";import"viem/chains";let T={address:C,version:"0.6"},x={address:S,version:"0.7"},I=({owner:e,smartWalletType:t,chain:a})=>{let n=E({chain:a,transport:v()});switch(t){case"safe":return W({client:n,entryPoint:x,owners:[e],version:"1.4.1"});case"kernel":return w({client:n,version:"0.3.1",entryPoint:x,owners:[e]});case"biconomy":return y({client:n,owners:[e],entryPoint:T});case"light_account":return g({client:n,entryPoint:T,owner:e,version:"1.1.0"});default:throw Error(`Invalid smart account type: ${t}.`)}},N=["rpc.zerodev.app","public.pimlico.io","api.pimlico.io"];let D=({calls:e,chain:t,maxPriorityFeePerGas:a,maxFeePerGas:n,nonce:r})=>e.map((e=>({to:e.to||void 0,data:e.data,value:e.value,chainId:t.id,nonce:r,maxFeePerGas:n,maxPriorityFeePerGas:a})));const F=async({chain:e,paymasterContext:t,embeddedWallet:a,user:n,smartWalletsConfig:r})=>{if(!r?.enabled||!n||!a)return;let i=await a.getEthereumProvider(),s=r?.configuredNetworks.find((t=>t.chainId===`eip155:${e.id}`));if(!s)throw new c(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let o=n.smartWallet?.smartWalletType??r.smartWalletType,l=await(async({owner:e,smartWalletType:t,chain:a,bundlerUrl:n,paymasterUrl:r,paymasterContext:i})=>{let s=E({chain:a,transport:v()}),o=await I({owner:e,smartWalletType:t,chain:a}),l=P({transport:v(n),entryPoint:o.entryPoint}),c=r?P({transport:v(r),entryPoint:o.entryPoint}):void 0;return h({account:o,chain:a,paymaster:c,paymasterContext:i,bundlerTransport:v(n),userOperation:{estimateFeesPerGas:async()=>{if(N.some((e=>n.includes(e))))return await l.getUserOperationGasPrice().then((e=>e.fast));{let e=await s.estimateFeesPerGas();return{...e,maxFeePerGas:125n*e.maxFeePerGas/100n,maxPriorityFeePerGas:125n*e.maxPriorityFeePerGas/100n}}}}})})({owner:i,smartWalletType:o,chain:e,paymasterContext:t,...s});if(!l)throw new c(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return l},_=({clientConfig:e,smartWalletsConfig:r})=>{let{noPromptOnSignature:i,openPrivyModal:s}=d(),h=o(),{setModalData:g}=u(),{user:y}=m(),{chains:w}=o(),{chainId:W,clients:P,setChainId:E,chainIdState:v}=(()=>{let e=t(),[n,r]=a();return{clients:t({}),setChainId:t=>{e.current=t,r(t)},chainId:e,chainIdState:n}})(),C=w.find((e=>e.id===v)),{wallets:S}=l(),T=n((async()=>W.current),[W]),b=n((async({id:t})=>{if(!P.current[t]){let a=p(S),n=await F({chain:w.find((e=>e.id===t)),embeddedWallet:a,user:y,paymasterContext:e?.paymasterContext,smartWalletsConfig:r});n&&(P.current[t]=n)}E(t)}),[w,e,S,y,r]);return{wrapSmartAccountClient:e=>{P.current[e.chain.id]=e,v||E(e.chain.id);return{...e,sendTransaction:async e=>{let t=void 0===h.embeddedWallets.showWalletUIs?h.embeddedWallets.noPromptOnSignature:!h.embeddedWallets.showWalletUIs,a=P.current[W.current];if(!a)throw new c(`Smart wallet client for chain (eip155:${W.current}) not found`);if(t)return i.current=!0,await a.sendTransaction(e).finally((()=>i.current=!1));let n=[];"calls"in e&&void 0!==e.calls?n=[...e.calls]:"to"in e&&(n=[{to:e.to,value:e.value||BigInt(0),data:e.data||"0x"}]);let r=async()=>{if(!a.paymaster)return!1;let{paymasterAndData:t,paymasterData:r}=await a.prepareUserOperation({calls:n,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return Number(t??r??0)>0};return new Promise((async(t,o)=>{i.current=!0,g({connectWallet:{onCompleteNavigateTo:f.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN,onFailure:()=>{}},sendTransaction:{transactionRequests:D({calls:n,chain:a.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),rootWallet:{address:a.account.address},transactingWallet:{address:a.account.address,walletIndex:null},getIsSponsored:r,onConfirm:()=>a.sendTransaction(e),onSuccess:e=>t(e.hash),onFailure:o,uiOptions:{}}}),s(f.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{i.current=!1}))},signMessage:async({message:e})=>{let t=void 0===h.embeddedWallets.showWalletUIs?h.embeddedWallets.noPromptOnSignature:!h.embeddedWallets.showWalletUIs,a=P.current[W.current];if(!a)throw new c(`Smart wallet client for chain (eip155:${W.current}) not found`);return t?(i.current=!0,await a.signMessage({message:e}).finally((()=>i.current=!1))):new Promise((async(t,n)=>{i.current=!0,g({connectWallet:{onCompleteNavigateTo:f.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>a.signMessage({message:e}),onSuccess:e=>t(e),onFailure:n,uiOptions:{}}}),s(f.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{i.current=!1}))},signTypedData:async e=>{let t=void 0===h.embeddedWallets.showWalletUIs?h.embeddedWallets.noPromptOnSignature:!h.embeddedWallets.showWalletUIs,a=P.current[W.current];if(!a)throw new c(`Smart wallet client for chain (eip155:${W.current}) not found`);return t?(i.current=!0,await a.signTypedData(e).finally((()=>i.current=!1))):new Promise((async(t,n)=>{i.current=!0,g({connectWallet:{onCompleteNavigateTo:f.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>a.signTypedData(e),onSuccess:e=>t(e),onFailure:n,uiOptions:{}}}),s(f.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{i.current=!1}))},getChainId:T,chain:C,switchChain:b}}}};let G=s({client:void 0});const M=({config:t,children:a})=>e(U,{children:e($,{config:t,children:e(B,{children:a})})}),O=()=>{let{client:e}=r(G);return{client:e}};let A=s({config:void 0}),L=()=>{let{config:e}=r(A);return{config:e}},U=({children:t})=>{let[n,r]=a(void 0),{client:s}=d();return i((()=>{!n&&s&&(async()=>{try{if(!s)return void console.warn("No client found");let e=await s.getSmartWalletsConfig();r(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!s]),e(A.Provider,{value:{config:n},children:t})},$=({config:t,children:n})=>{let{config:r}=L(),{chains:s,defaultChain:d}=o(),{wallets:u}=l(),{user:f}=m(),[h,g]=a(),y=p(u);return i((()=>{(async()=>{if(!r?.enabled)return;let e=r.configuredNetworks.find((e=>e.chainId===`eip155:${d.id}`))?d:s.find((e=>r.configuredNetworks.map((e=>e.chainId)).includes(`eip155:${e.id}`)));if(!e)throw new c("Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.");g(await F({chain:e,paymasterContext:t?.paymasterContext,embeddedWallet:y,user:f,smartWalletsConfig:r}))})()}),[!!r?.enabled,!!f?.smartWallet,!!y]),e(R.Provider,{value:{client:h,config:t},children:n})},R=s({client:void 0,config:void 0}),B=({children:t})=>{let{client:a,config:n}=(()=>{let{client:e,config:t}=r(R);return{client:e,config:t}})(),{config:s}=L(),{wrapSmartAccountClient:o}=_({clientConfig:n,smartWalletsConfig:s}),{user:l}=m(),{generateSiweMessageForSmartWallet:c,linkSmartWallet:u,noPromptOnSignature:p}=d();return i((()=>{(async()=>{if(a&&!l?.smartWallet&&s?.enabled)try{let e=await c({address:a.account.address,chainId:`eip155:${a.chain.id}`});p.current=!0;let t=await a.signMessage({message:e});await u({signature:t,message:e,smartWalletType:s.smartWalletType})}catch(e){console.error("Error creating smart wallet:",e)}finally{p.current=!1}})()}),[!!a,!!l?.smartWallet,!!s?.enabled]),e(G.Provider,{value:{client:l?.smartWallet&&a?o(a):void 0},children:t})};export{M as SmartWalletsProvider,O as useSmartWallets};
1
+ import{jsx as e}from"react/jsx-runtime";import{useRef as t,useState as n,useCallback as a,useContext as r,useEffect as i,createContext as s}from"react";import{Q as o,z as l,a3 as c}from"./useWallets-ctd8F0LF.mjs";import{P as d,u as m,h as u}from"./privy-context--IShbIGm.mjs";import{u as p,g as f,M as g}from"./getEmbeddedConnectedWallet-BF0i-4Oo.mjs";export{b as useAbstractSmartWallets}from"./getEmbeddedConnectedWallet-BF0i-4Oo.mjs";import{http as h,createPublicClient as y}from"viem";import{createSmartAccountClient as w}from"permissionless";import{toLightSmartAccount as W,toBiconomySmartAccount as C,toEcdsaKernelSmartAccount as P,toSafeSmartAccount as E}from"permissionless/accounts";import{createPimlicoClient as v}from"permissionless/clients/pimlico";import{entryPoint06Address as I,entryPoint07Address as S}from"viem/account-abstraction";import"@ethersproject/providers";import"tinycolor2";import"ofetch";import"viem/actions";import"viem/chains";let T={address:I,version:"0.6"},x={address:S,version:"0.7"},N=({owner:e,smartWalletType:t,publicClient:n})=>{switch(t){case"safe":return E({client:n,entryPoint:x,owners:[e],version:"1.4.1"});case"kernel":return P({client:n,version:"0.3.1",entryPoint:x,owners:[e]});case"biconomy":return C({client:n,owners:[e],entryPoint:T});case"light_account":return W({client:n,entryPoint:T,owner:e,version:"1.1.0"});default:throw Error(`Invalid smart account type: ${t}.`)}},D=["rpc.zerodev.app","public.pimlico.io","api.pimlico.io"];const F=async({owner:e,smartWalletType:t,chain:n,publicClient:a,bundlerUrl:r,paymasterUrl:i,paymasterContext:s})=>{let o=await N({owner:e,smartWalletType:t,publicClient:a}),l=v({transport:h(r),entryPoint:o.entryPoint}),c=i?v({transport:h(i),entryPoint:o.entryPoint}):void 0;return w({account:o,chain:n,paymaster:c,paymasterContext:s,bundlerTransport:h(r),userOperation:{estimateFeesPerGas:async()=>{if(D.some((e=>r.includes(e))))return await l.getUserOperationGasPrice().then((e=>e.fast));{let e=await a.estimateFeesPerGas();return{...e,maxFeePerGas:125n*e.maxFeePerGas/100n,maxPriorityFeePerGas:125n*e.maxPriorityFeePerGas/100n}}}}})};let _=({calls:e,chain:t,maxPriorityFeePerGas:n,maxFeePerGas:a,nonce:r})=>e.map((e=>({to:e.to||void 0,data:e.data,value:e.value,chainId:t.id,nonce:r,maxFeePerGas:a,maxPriorityFeePerGas:n})));const G=async({chain:e,paymasterContext:t,embeddedWallet:n,user:a,smartWalletsConfig:r,rpcConfig:i,privyAppId:s})=>{if(!r?.enabled||!a||!n)return;let l=await n.getEthereumProvider(),c=r?.configuredNetworks.find((t=>t.chainId===`eip155:${e.id}`));if(!c)throw new d(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let m=a.smartWallet?.smartWalletType??r.smartWalletType,u=o(e,i,s),p=y({chain:e,transport:h(u)}),f=await F({owner:l,smartWalletType:m,chain:e,publicClient:p,paymasterContext:t,...c});if(!f)throw new d(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return f},A=({clientConfig:e,smartWalletsConfig:r})=>{let{noPromptOnSignature:i,openPrivyModal:s,appId:o}=m(),h=l(),{setModalData:y}=p(),{user:w}=u(),{chains:W}=l(),{chainId:C,clients:P,setChainId:E,chainIdState:v}=(()=>{let e=t(),[a,r]=n();return{clients:t({}),setChainId:t=>{e.current=t,r(t)},chainId:e,chainIdState:a}})(),I=W.find((e=>e.id===v)),{wallets:S}=c(),b=a((async()=>C.current),[C]),T=a((async({id:t})=>{if(!P.current[t]){let n=f(S),a=await G({chain:W.find((e=>e.id===t)),embeddedWallet:n,user:w,paymasterContext:e?.paymasterContext,smartWalletsConfig:r,rpcConfig:h.rpcConfig,privyAppId:o});a&&(P.current[t]=a)}E(t)}),[W,e,S,w,r]);return{wrapSmartAccountClient:e=>{P.current[e.chain.id]=e,v||E(e.chain.id);return{...e,sendTransaction:async e=>{let t=void 0===h.embeddedWallets.showWalletUIs?h.embeddedWallets.noPromptOnSignature:!h.embeddedWallets.showWalletUIs,n=P.current[C.current];if(!n)throw new d(`Smart wallet client for chain (eip155:${C.current}) not found`);if(t)return i.current=!0,await n.sendTransaction(e).finally((()=>i.current=!1));let a=[];"calls"in e&&void 0!==e.calls?a=[...e.calls]:"to"in e&&(a=[{to:e.to,value:e.value||BigInt(0),data:e.data||"0x"}]);let r=async()=>{if(!n.paymaster)return!1;let{paymasterAndData:t,paymasterData:r}=await n.prepareUserOperation({calls:a,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return Number(t??r??0)>0};return new Promise((async(t,o)=>{i.current=!0,y({connectWallet:{onCompleteNavigateTo:g.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN,onFailure:()=>{}},sendTransaction:{transactionRequests:_({calls:a,chain:n.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),rootWallet:{address:n.account.address},transactingWallet:{address:n.account.address,walletIndex:null},getIsSponsored:r,onConfirm:()=>n.sendTransaction(e),onSuccess:e=>t(e.hash),onFailure:o,uiOptions:{}}}),s(g.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{i.current=!1}))},signMessage:async({message:e})=>{let t=void 0===h.embeddedWallets.showWalletUIs?h.embeddedWallets.noPromptOnSignature:!h.embeddedWallets.showWalletUIs,n=P.current[C.current];if(!n)throw new d(`Smart wallet client for chain (eip155:${C.current}) not found`);return t?(i.current=!0,await n.signMessage({message:e}).finally((()=>i.current=!1))):new Promise((async(t,a)=>{i.current=!0,y({connectWallet:{onCompleteNavigateTo:g.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>n.signMessage({message:e}),onSuccess:e=>t(e),onFailure:a,uiOptions:{}}}),s(g.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{i.current=!1}))},signTypedData:async e=>{let t=void 0===h.embeddedWallets.showWalletUIs?h.embeddedWallets.noPromptOnSignature:!h.embeddedWallets.showWalletUIs,n=P.current[C.current];if(!n)throw new d(`Smart wallet client for chain (eip155:${C.current}) not found`);return t?(i.current=!0,await n.signTypedData(e).finally((()=>i.current=!1))):new Promise((async(t,a)=>{i.current=!0,y({connectWallet:{onCompleteNavigateTo:g.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>n.signTypedData(e),onSuccess:e=>t(e),onFailure:a,uiOptions:{}}}),s(g.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{i.current=!1}))},getChainId:b,chain:I,switchChain:T}}}};let M=s({client:void 0});const O=({config:t,children:n})=>e(R,{children:e(B,{config:t,children:e(k,{children:n})})}),L=()=>{let{client:e}=r(M);return{client:e}};let U=s({config:void 0}),$=()=>{let{config:e}=r(U);return{config:e}},R=({children:t})=>{let[a,r]=n(void 0),{client:s}=m();return i((()=>{!a&&s&&(async()=>{try{if(!s)return void console.warn("No client found");let e=await s.getSmartWalletsConfig();r(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!s]),e(U.Provider,{value:{config:a},children:t})},B=({config:t,children:a})=>{let{config:r}=$(),{appId:s}=m(),{chains:o,defaultChain:p,rpcConfig:g}=l(),{wallets:h}=c(),{user:y}=u(),[w,W]=n(),C=f(h);return i((()=>{(async()=>{if(!r?.enabled)return;let e=r.configuredNetworks.find((e=>e.chainId===`eip155:${p.id}`))?p:o.find((e=>r.configuredNetworks.map((e=>e.chainId)).includes(`eip155:${e.id}`)));if(!e)throw new d("Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.");W(await G({chain:e,privyAppId:s,paymasterContext:t?.paymasterContext,rpcConfig:g,embeddedWallet:C,user:y,smartWalletsConfig:r}))})()}),[!!r?.enabled,!!y?.smartWallet,!!C]),e(j.Provider,{value:{client:w,config:t},children:a})},j=s({client:void 0,config:void 0}),k=({children:t})=>{let{client:n,config:a}=(()=>{let{client:e,config:t}=r(j);return{client:e,config:t}})(),{config:s}=$(),{wrapSmartAccountClient:o}=A({clientConfig:a,smartWalletsConfig:s}),{user:l}=u(),{generateSiweMessageForSmartWallet:c,linkSmartWallet:d,noPromptOnSignature:p}=m();return i((()=>{(async()=>{if(n&&!l?.smartWallet&&s?.enabled)try{let e=await c({address:n.account.address,chainId:`eip155:${n.chain.id}`});p.current=!0;let t=await n.signMessage({message:e});await d({signature:t,message:e,smartWalletType:s.smartWalletType})}catch(e){console.error("Error creating smart wallet:",e)}finally{p.current=!1}})()}),[!!n,!!l?.smartWallet,!!s?.enabled]),e(M.Provider,{value:{client:l?.smartWallet&&n?o(n):void 0},children:t})};export{O as SmartWalletsProvider,L as useSmartWallets};
@@ -1 +1 @@
1
- import{isWalletAdapterCompatibleStandardWallet as t}from"@solana/wallet-adapter-base";import{StandardWalletAdapter as e}from"@solana/wallet-standard-wallet-adapter-base";import{getWallets as a}from"@wallet-standard/app";import{S as o}from"./useSolanaWallets-DFH-p-7f.mjs";export{u as useSolanaWallets}from"./useSolanaWallets-DFH-p-7f.mjs";import{u as r}from"./events-context-DLn7buIf.mjs";import{u as l}from"./privy-context-QVrL4VJ3.mjs";import"eventemitter3";import"@ethersproject/logger";import"@ethersproject/address";import"react";import"ofetch";const n=t=>{let e,{get:r,on:l}=a(),n=t?.shouldAutoConnect??!0,p=s(r()),m=p.map((t=>new o(t,n))),i=[];return{_setOnConnectorsUpdated:t=>{e=t},onMount:()=>{i.push(l("register",((...t)=>{m=(p=p.concat(...s(t))).map((t=>new o(t,n))),e?.(m)})),l("unregister",((...t)=>{m=(p=p.filter((e=>t.some((t=>e.wallet===t))))).map((t=>new o(t,n))),e?.(m)})))},onUnmount:()=>{let t=i.pop();for(;t;)t(),t=i.pop()},get:()=>m}};let s=a=>a.filter(t).map((t=>new e({wallet:t})));const p=t=>{r("fundSolanaWallet",t);let{fundSolanaWallet:e}=l();return{fundWallet:e}};export{o as SolanaAdapterConnector,n as toSolanaWalletConnectors,p as useFundWallet};
1
+ import{isWalletAdapterCompatibleStandardWallet as t}from"@solana/wallet-adapter-base";import{StandardWalletAdapter as e}from"@solana/wallet-standard-wallet-adapter-base";import{getWallets as a}from"@wallet-standard/app";import{S as o}from"./useSolanaWallets-BK1ZsW9P.mjs";export{u as useSolanaWallets}from"./useSolanaWallets-BK1ZsW9P.mjs";import{u as r}from"./events-context-BcbWmpUg.mjs";import{u as l}from"./privy-context--IShbIGm.mjs";import"eventemitter3";import"@ethersproject/logger";import"@ethersproject/address";import"react";import"ofetch";const n=t=>{let e,{get:r,on:l}=a(),n=t?.shouldAutoConnect??!0,p=s(r()),m=p.map((t=>new o(t,n))),i=[];return{_setOnConnectorsUpdated:t=>{e=t},onMount:()=>{i.push(l("register",((...t)=>{m=(p=p.concat(...s(t))).map((t=>new o(t,n))),e?.(m)})),l("unregister",((...t)=>{m=(p=p.filter((e=>t.some((t=>e.wallet===t))))).map((t=>new o(t,n))),e?.(m)})))},onUnmount:()=>{let t=i.pop();for(;t;)t(),t=i.pop()},get:()=>m}};let s=a=>a.filter(t).map((t=>new e({wallet:t})));const p=t=>{r("fundSolanaWallet",t);let{fundSolanaWallet:e}=l();return{fundWallet:e}};export{o as SolanaAdapterConnector,n as toSolanaWalletConnectors,p as useFundWallet};
package/dist/esm/ui.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import{h as r,u as n}from"./privy-context-QVrL4VJ3.mjs";import{f as l,u as o,x as a,o as s,W as d,k as c,d as h,q as p,b as C,v as u,w as g,B as f}from"./useFundWallet-D5B39g9B.mjs";import{E as w,a3 as m,z as v}from"./useWallets-BQQjDV6b.mjs";import{styled as x,css as y}from"styled-components";import{CheckIcon as _}from"@heroicons/react/24/outline";import*as k from"react";import{useState as b,useContext as M,createContext as L,useRef as z}from"react";import{useMergeRefs as H,useTransitionStyles as V,FloatingPortal as F,FloatingFocusManager as Z,useFloating as B,autoUpdate as U,offset as S,flip as A,shift as O,useInteractions as j,useClick as R,useDismiss as P,useRole as G}from"@floating-ui/react";import{g as T}from"./events-context-DLn7buIf.mjs";import"ofetch";import"@heroicons/react/24/outline/Square2StackIcon";import"@ethersproject/bignumber";import"@ethersproject/units";import"viem";import"@ethersproject/providers";import"tinycolor2";import"@ethersproject/address";const W=t=>e("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:e("path",{d:"M9.99999 10.8333C12.3012 10.8333 14.1667 8.96785 14.1667 6.66667C14.1667 4.36548 12.3012 2.5 9.99999 2.5C7.69881 2.5 5.83333 4.36548 5.83333 6.66667C5.83333 8.96785 7.69881 10.8333 9.99999 10.8333ZM9.99999 10.8333C11.7681 10.8333 13.4638 11.5357 14.714 12.786C15.9643 14.0362 16.6667 15.7319 16.6667 17.5M9.99999 10.8333C8.23188 10.8333 6.53619 11.5357 5.28595 12.786C4.03571 14.0362 3.33333 15.7319 3.33333 17.5",stroke:"currentColor",strokeWidth:"1.67",strokeLinecap:"round",strokeLinejoin:"round"})}),N=x.button`
1
+ import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import{h as r,u as n}from"./privy-context--IShbIGm.mjs";import{f as l,u as o,x as a,o as s,W as d,k as c,d as h,q as p,b as C,v as u,w as g,B as f}from"./useFundWallet-BBE2QbPF.mjs";import{E as w,a3 as m,z as v}from"./useWallets-ctd8F0LF.mjs";import{styled as x,css as y}from"styled-components";import{CheckIcon as _}from"@heroicons/react/24/outline";import*as k from"react";import{useState as b,useContext as M,createContext as L,useRef as z}from"react";import{useMergeRefs as H,useTransitionStyles as V,FloatingPortal as F,FloatingFocusManager as Z,useFloating as B,autoUpdate as U,offset as S,flip as A,shift as O,useInteractions as j,useClick as R,useDismiss as P,useRole as G}from"@floating-ui/react";import{g as T}from"./events-context-BcbWmpUg.mjs";import"ofetch";import"@heroicons/react/24/outline/Square2StackIcon";import"@ethersproject/bignumber";import"@ethersproject/units";import"viem";import"@ethersproject/providers";import"tinycolor2";import"@ethersproject/address";const W=t=>e("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:e("path",{d:"M9.99999 10.8333C12.3012 10.8333 14.1667 8.96785 14.1667 6.66667C14.1667 4.36548 12.3012 2.5 9.99999 2.5C7.69881 2.5 5.83333 4.36548 5.83333 6.66667C5.83333 8.96785 7.69881 10.8333 9.99999 10.8333ZM9.99999 10.8333C11.7681 10.8333 13.4638 11.5357 14.714 12.786C15.9643 14.0362 16.6667 15.7319 16.6667 17.5M9.99999 10.8333C8.23188 10.8333 6.53619 11.5357 5.28595 12.786C4.03571 14.0362 3.33333 15.7319 3.33333 17.5",stroke:"currentColor",strokeWidth:"1.67",strokeLinecap:"round",strokeLinejoin:"round"})}),N=x.button`
2
2
  --size: ${({$size:e})=>`${e}px`};
3
3
 
4
4
  -webkit-font-smoothing: antialiased;
@@ -1,4 +1,4 @@
1
- import{useState as r,useEffect as e,createContext as o,useContext as t,useMemo as a,useCallback as c}from"react";import{jsx as i,jsxs as l,Fragment as n}from"react/jsx-runtime";import{styled as s,keyframes as d,css as h}from"styled-components";import{E as v,z as p,ao as u,Q as m}from"./useWallets-BQQjDV6b.mjs";import{u as g}from"./events-context-DLn7buIf.mjs";import{l as y,u as f,h as b}from"./privy-context-QVrL4VJ3.mjs";import w from"@heroicons/react/24/outline/Square2StackIcon";import{BigNumber as x}from"@ethersproject/bignumber";import{formatEther as $}from"@ethersproject/units";import{createPublicClient as V,http as Z}from"viem";let M=r=>x.from(r);function P(r){if("number"==typeof r||"bigint"==typeof r||"string"==typeof r)return r;if("function"==typeof r.toHexString)return r.toHexString();throw Error(`Expected numeric value but received ${r}`)}function k(r){let e={};return void 0!==r.to&&(e.to=r.to),void 0!==r.data&&(e.data=r.data),void 0!==r.chainId&&(e.chainId=r.chainId),void 0!==r.type&&(e.type=r.type),void 0!==r.accessList&&(e.accessList=r.accessList),void 0!==r.nonce&&(e.nonce=M(r.nonce).toNumber()),void 0!==r.gasLimit&&(e.gasLimit=M(r.gasLimit)),void 0!==r.gasPrice&&(e.gasPrice=M(r.gasPrice)),void 0!==r.value&&(e.value=M(r.value)),void 0!==r.maxFeePerGas&&(e.maxFeePerGas=M(r.maxFeePerGas)),void 0!==r.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=M(r.maxPriorityFeePerGas)),e}class L{get(r){let e=localStorage.getItem(r);return null===e?void 0:JSON.parse(e)}put(r,e){void 0!==e?localStorage.setItem(r,JSON.stringify(e)):this.del(r)}del(r){localStorage.removeItem(r)}getKeys(){return Object.entries(localStorage).map((([r])=>r))}}function T(){try{let r="privy:__session_storage__test",e=new L;return e.put(r,"blobby"),e.del(r),!0}catch(r){return!1}}var C="undefined"!=typeof window&&window.localStorage?new L:new class{get(r){return this._cache[r]}put(r,e){void 0!==e?this._cache[r]=e:this.del(r)}del(r){delete this._cache[r]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};const S=o=>{let[t,a]=r("auto");return e((()=>{let r=new ResizeObserver((r=>{a(r[0]?.contentRect.height??"auto")}));return o.current&&r.observe(o.current),()=>{o.current&&r.unobserve(o.current)}}),[o.current]),t},_=({success:r,fail:e})=>l(n,{children:[i(I,{className:r?"success":e?"fail":""}),i(N,{className:r?"success":e?"fail":""})]}),I=s.span`
1
+ import{useState as r,useEffect as e,createContext as o,useContext as t,useMemo as a,useCallback as c}from"react";import{jsx as i,jsxs as l,Fragment as n}from"react/jsx-runtime";import{styled as s,keyframes as d,css as h}from"styled-components";import{E as v,z as p,ao as u,Q as m}from"./useWallets-ctd8F0LF.mjs";import{u as g}from"./events-context-BcbWmpUg.mjs";import{l as y,u as f,h as b}from"./privy-context--IShbIGm.mjs";import w from"@heroicons/react/24/outline/Square2StackIcon";import{BigNumber as x}from"@ethersproject/bignumber";import{formatEther as $}from"@ethersproject/units";import{createPublicClient as V,http as Z}from"viem";let M=r=>x.from(r);function P(r){if("number"==typeof r||"bigint"==typeof r||"string"==typeof r)return r;if("function"==typeof r.toHexString)return r.toHexString();throw Error(`Expected numeric value but received ${r}`)}function k(r){let e={};return void 0!==r.to&&(e.to=r.to),void 0!==r.data&&(e.data=r.data),void 0!==r.chainId&&(e.chainId=r.chainId),void 0!==r.type&&(e.type=r.type),void 0!==r.accessList&&(e.accessList=r.accessList),void 0!==r.nonce&&(e.nonce=M(r.nonce).toNumber()),void 0!==r.gasLimit&&(e.gasLimit=M(r.gasLimit)),void 0!==r.gasPrice&&(e.gasPrice=M(r.gasPrice)),void 0!==r.value&&(e.value=M(r.value)),void 0!==r.maxFeePerGas&&(e.maxFeePerGas=M(r.maxFeePerGas)),void 0!==r.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=M(r.maxPriorityFeePerGas)),e}class L{get(r){let e=localStorage.getItem(r);return null===e?void 0:JSON.parse(e)}put(r,e){void 0!==e?localStorage.setItem(r,JSON.stringify(e)):this.del(r)}del(r){localStorage.removeItem(r)}getKeys(){return Object.entries(localStorage).map((([r])=>r))}}function T(){try{let r="privy:__session_storage__test",e=new L;return e.put(r,"blobby"),e.del(r),!0}catch(r){return!1}}var C="undefined"!=typeof window&&window.localStorage?new L:new class{get(r){return this._cache[r]}put(r,e){void 0!==e?this._cache[r]=e:this.del(r)}del(r){delete this._cache[r]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};const S=o=>{let[t,a]=r("auto");return e((()=>{let r=new ResizeObserver((r=>{a(r[0]?.contentRect.height??"auto")}));return o.current&&r.observe(o.current),()=>{o.current&&r.unobserve(o.current)}}),[o.current]),t},_=({success:r,fail:e})=>l(n,{children:[i(I,{className:r?"success":e?"fail":""}),i(N,{className:r?"success":e?"fail":""})]}),I=s.span`
2
2
  && {
3
3
  width: 82px;
4
4
  height: 82px;
@@ -1 +1 @@
1
- import{c as e,b as t,o as a,u as s,h as n,P as i}from"./privy-context-QVrL4VJ3.mjs";import r from"eventemitter3";import{ErrorCode as o}from"@ethersproject/logger";import{a as l}from"./events-context-DLn7buIf.mjs";var d,c;(c=d||(d={})).MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",c.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",c.INVALID_DATA="invalid_data",c.LINKED_TO_ANOTHER_USER="linked_to_another_user",c.ALLOWLIST_REJECTED="allowlist_rejected",c.OAUTH_USER_DENIED="oauth_user_denied",c.UNKNOWN_AUTH_ERROR="unknown_auth_error",c.USER_EXITED_AUTH_FLOW="exited_auth_flow",c.MUST_BE_AUTHENTICATED="must_be_authenticated",c.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",c.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",c.CLIENT_REQUEST_TIMEOUT="client_request_timeout",c.INVALID_CREDENTIALS="invalid_credentials";class _ extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(e,t,a){super(e),t instanceof Error&&(this.cause=t),this.privyErrorCode=a}}class E extends _{constructor(e,t,a){super(e),this.type="provider_error",this.code=t,this.data=a}}let u={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1},E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don’t see your wallet? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don’t see your wallet? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don’t see your wallet? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}};class h extends E{constructor(e){super(e.message,e.code,e.data);let t=Object.values(u).find((t=>t.eipCode===e.code));this.details=t||u.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=u.E32002_CONNECTION_ALREADY_PENDING:this.details=u.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=u.E32002_WALLET_LOCKED))}}class p extends e{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class m extends e{constructor(){super("User rejected connection"),this.type="wallet_error"}}const y=t=>{if(t instanceof e)return t;if(t?.code&&t?.reason){let e=new g(t);return t.code===o.ACTION_REJECTED&&(e.details=u.E4001_USER_REJECTED_REQUEST),e}return t?.code?new g(t):new e("Unknown connector error",t)};class T extends t{constructor(e,t,a){super(e),this.type="provider_error",this.code=t,this.data=a}}class g extends T{constructor(e){super(e.message,e.code,e.data);let t=Object.values(u).find((t=>t.eipCode===e.code));this.details=t||u.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=u.E32002_CONNECTION_ALREADY_PENDING:this.details=u.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=u.E32002_WALLET_LOCKED))}}const w={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1},...u};class C extends r{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const R=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","crypto.com_wallet_extension","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","privy","unknown","phantom","solflare","glow"];function N(e){return"solana"===e.chainType}function A(e){return"solana"===e.type}class b extends C{get isInstalled(){return"Installed"===this.adapter.readyState}buildConnectedWallet(e,t){let s,n,i;if("Installed"!==e.readyState||!e.publicKey)throw Error("Wallet is not connected.");return"signMessage"in e&&(s=async(...t)=>{if(!e.connected)throw Error("Wallet is not connected.");return await e.signMessage(t[0])}),"sendTransaction"in e&&(n=async(...t)=>await e.sendTransaction(t[0],t[1],t[2])),"signTransaction"in e&&(i=async t=>await e.signTransaction(t)),{type:"solana",address:e.publicKey.toBase58(),meta:t,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>e.connected,disconnect:()=>{try{e.disconnect()}catch(e){console.error("Wallet does not support programmatic disconnect")}},getProvider:a(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:s??a(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:n??a(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:i??a(`${this.walletClientType||""} wallet does not support 'signTransaction'`)}}async syncAccounts(){if("Installed"===this.adapter.readyState&&this.adapter.publicKey){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find((e=>this.adapter.publicKey&&e.address===this.adapter.publicKey.toBase58()))||(this.wallets=[this.buildConnectedWallet(this.adapter,e)],this.emit("walletsUpdated"))}else this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"))}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAutoConnect&&await this.adapter.autoConnect().catch(console.error),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt))[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}constructor(e,t){super(function(e){return R.includes(e)}(e.name.toLowerCase())?e.name.toLowerCase():"unknown"),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=()=>{this.adapter.disconnect().then((()=>this.onDisconnect())).catch((e=>console.error("Error disconnecting",e)))},this.promptConnection=async()=>{try{await this.adapter.connect()}catch(e){throw y(e)}},this.onDisconnect=()=>{this.syncAccounts()},this.onConnect=e=>{this.syncAccounts()},this.onError=e=>{this.syncAccounts()},this.onReadyStateChange=e=>{"Installed"!==e&&(this.connected=!1),this.syncAccounts()},this.adapter=e,this.shouldAutoConnect=t,this.wallets=[]}}const D=()=>{let{embeddedSolanaWallet:e,exportSolanaWallet:t,createEmbeddedSolanaWallet:a,solanaWallets:r,initDelegateAction:o}=s(),{user:d}=n();return{createWallet:a,exportWallet:t,delegateWalletAction:async()=>{let e=l(d);if(!e)throw new i("User must have a solana wallet in order to delegate actions");return await o({address:e.address})},wallets:r.concat(e?[e]:[])}};export{w as C,u as E,g as P,b as S,m as U,p as W,C as a,T as b,A as c,y as f,N as i,h as l,D as u};
1
+ import{c as e,b as t,o as a,u as s,h as n,P as r}from"./privy-context--IShbIGm.mjs";import i from"eventemitter3";import{ErrorCode as o}from"@ethersproject/logger";import{a as l}from"./events-context-BcbWmpUg.mjs";var d,c;(c=d||(d={})).MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",c.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",c.INVALID_DATA="invalid_data",c.LINKED_TO_ANOTHER_USER="linked_to_another_user",c.ALLOWLIST_REJECTED="allowlist_rejected",c.OAUTH_USER_DENIED="oauth_user_denied",c.UNKNOWN_AUTH_ERROR="unknown_auth_error",c.USER_EXITED_AUTH_FLOW="exited_auth_flow",c.MUST_BE_AUTHENTICATED="must_be_authenticated",c.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",c.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",c.CLIENT_REQUEST_TIMEOUT="client_request_timeout",c.INVALID_CREDENTIALS="invalid_credentials";class _ extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(e,t,a){super(e),t instanceof Error&&(this.cause=t),this.privyErrorCode=a}}class E extends _{constructor(e,t,a){super(e),this.type="provider_error",this.code=t,this.data=a}}let u={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1},E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don’t see your wallet? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don’t see your wallet? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don’t see your wallet? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}};class h extends E{constructor(e){super(e.message,e.code,e.data);let t=Object.values(u).find((t=>t.eipCode===e.code));this.details=t||u.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=u.E32002_CONNECTION_ALREADY_PENDING:this.details=u.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=u.E32002_WALLET_LOCKED))}}class p extends e{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class y extends e{constructor(){super("User rejected connection"),this.type="wallet_error"}}const T=t=>{if(t instanceof e)return t;if(t?.code&&t?.reason){let e=new g(t);return t.code===o.ACTION_REJECTED&&(e.details=u.E4001_USER_REJECTED_REQUEST),e}return t?.code?new g(t):new e("Unknown connector error",t)};class m extends t{constructor(e,t,a){super(e),this.type="provider_error",this.code=t,this.data=a}}class g extends m{constructor(e){super(e.message,e.code,e.data);let t=Object.values(u).find((t=>t.eipCode===e.code));this.details=t||u.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=u.E32002_CONNECTION_ALREADY_PENDING:this.details=u.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=u.E32002_WALLET_LOCKED))}}const w={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1},...u};class C extends i{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const R=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","crypto.com_wallet_extension","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","privy","unknown","phantom","solflare","glow"];function N(e){return"solana"===e.chainType}function A(e){return"solana"===e.type}class b extends C{get isInstalled(){return"Installed"===this.adapter.readyState}buildConnectedWallet(e,t){let s,n,r;if("Installed"!==e.readyState||!e.publicKey)throw Error("Wallet is not connected.");return"signMessage"in e&&(s=async(...t)=>{if(!e.connected)throw Error("Wallet is not connected.");return await e.signMessage(t[0])}),"sendTransaction"in e&&(n=async(...t)=>await e.sendTransaction(t[0],t[1],t[2])),"signTransaction"in e&&(r=async t=>await e.signTransaction(t)),{type:"solana",address:e.publicKey.toBase58(),meta:t,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>e.connected,disconnect:()=>{try{e.disconnect()}catch(e){console.error("Wallet does not support programmatic disconnect")}},getProvider:a(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:s??a(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:n??a(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:r??a(`${this.walletClientType||""} wallet does not support 'signTransaction'`)}}async syncAccounts(){if("Installed"===this.adapter.readyState&&this.adapter.publicKey){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find((e=>this.adapter.publicKey&&e.address===this.adapter.publicKey.toBase58()))||(this.wallets=[this.buildConnectedWallet(this.adapter,e)],this.emit("walletsUpdated"))}else this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"))}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAutoConnect&&await this.adapter.autoConnect().catch(console.error),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt))[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}constructor(e,t){super(function(e){return R.includes(e)}(e.name.toLowerCase())?e.name.toLowerCase():"unknown"),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=()=>{this.adapter.disconnect().then((()=>this.onDisconnect())).catch((e=>console.error("Error disconnecting",e)))},this.promptConnection=async()=>{try{await this.adapter.connect()}catch(e){throw T(e)}},this.onDisconnect=()=>{this.syncAccounts()},this.onConnect=e=>{this.syncAccounts()},this.onError=e=>{this.syncAccounts()},this.onReadyStateChange=e=>{"Installed"!==e&&(this.connected=!1),this.syncAccounts()},this.adapter=e,this.shouldAutoConnect=t,this.wallets=[]}}const D=()=>{let{embeddedSolanaWallet:e,exportSolanaWallet:t,createEmbeddedSolanaWallet:a,solanaWallets:i,delegateWallet:o}=s(),{user:d}=n();return{createWallet:a,exportWallet:t,delegateWalletAction:async()=>{let e=l(d);if(!e)throw new r("User must have a solana wallet in order to delegate actions");return await o({address:e.address,chainType:"solana"})},wallets:i.concat(e?[e]:[])}};export{w as C,g as P,h as R,b as S,y as U,p as W,C as a,m as b,A as c,T as f,N as i,u as n,D as u};
@@ -0,0 +1 @@
1
+ import{StaticJsonRpcProvider as e}from"@ethersproject/providers";import{c as t}from"./privy-context--IShbIGm.mjs";import{jsx as a}from"react/jsx-runtime";import{useState as r,useMemo as n,useEffect as l,useContext as i,createContext as o}from"react";import s from"tinycolor2";const p=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,c=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==p(e))return!1;if(e.providers)for(let t of e.providers)if(!c(t))return!1;return!0},u=()=>{if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId)return!0}return!1},h=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers)for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0;return!1},d=(e,t)=>{let a=[],r=[];for(let[n,l]of e.entries())n<t?a.push(l):r.push(l);return[a,r]},m=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),f=(e,t)=>{let a=e.slice(0),r=[];for(;a.length;)r.push(a.splice(0,t));return r},g=(e,t=3,a=4,r="ethereum")=>{if(!e)return"";let n="ethereum"===r?2:0;return t+a+n+3>=e.length?e:`${e.slice(0,n+t)}...${e.slice(e.length-a,e.length)}`},y=(e,t=3,a=4)=>g(e,t,a,"solana"),b=e=>new Promise((t=>setTimeout(t,e)));function w(e,{interval:t=100,timeout:a=5e3}={}){return new Promise(((r,n)=>{let l,i=0,o=()=>{i>=a?n("Max attempts reached without result"):(l=e(),i+=t,null==l?setTimeout(o,t):r(l))};o()}))}const v=(e,t={})=>{let a=t.delayMs||150,r=t.maxAttempts||270;return new Promise((async(n,l)=>{let i=!1,o=0;for(;!i&&o<r;){if(t.abortSignal?.aborted)return;e().then((e=>{i=!0,n(e)}),((...e)=>{i=!0,l(...e)})),o+=1,await b(a)}i||l(Error("Exceeded max attempts before resolving function"))}))},C=(e,t,a={},r={})=>{let n=new URL(t,e);for(let[e,t]of Object.entries(a))void 0!==t&&n.searchParams.set(e,t);let l=Object.entries(r);if(l.length>0){let e=new URLSearchParams;for(let[t,a]of l)e.append(t,a);n.hash=e.toString()}return n.href},k=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),E=e=>"string"==typeof e?e:"0x"+e.toString(16);async function W({store:e,walletList:t,externalWalletConfig:a,walletChainType:r,timeout:n=3e3}){let l=!1,i=window;return new Promise((o=>{function s(){if(l)return;l=!0,window.removeEventListener("ethereum#initialized",s);let n=e.getProviders();console.debug("Detected injected providers:",n.map((e=>e.info)));let i=[];for(let e of n)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===r&&"app.phantom"===e.info.rdns||i.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==r)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let a=[];if(t.providers?.length)for(let e of t.providers)e&&a.push(e);return a.push(e.ethereum),a}()){let t=p(e);if(!n.some((e=>e.info.name===t))){if(c(e,!0)&&!i.find((e=>"metamask"===e.type))){i.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!i.find((e=>"phantom"===e.type))){i.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!i.find((e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==a.coinbaseWallet?.connectionOptions))){i.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}i.find((e=>"unknown_browser_extension"===e.type))||i.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}o(i)}i.ethereum?s():(window.addEventListener("ethereum#initialized",s,{once:!0}),setTimeout((()=>{s()}),n))}))}function S(e){return`eip155:${String(Number(e))}`}const U=(e,a,r,n)=>{let l=Number(e),i=a.find((e=>e.id===l));if(!i)throw new t(`Unsupported chainId ${e}`,4901);return x(i,r,n)},x=(e,a,r)=>{let n,l=e.id,i=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])n=e.rpcUrls.privyWalletOverride.http[0];else if(a.rpcUrls&&a.rpcUrls[i])n=a.rpcUrls[i];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",r),n=t.toString()}else n=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!n)throw new t(`No RPC url found for ${l}`);return n},O=(e,a)=>{let r=Number(e),n=a.find((e=>e.id===r));if(!n)throw new t(`Unsupported chainId ${e}`,4901);return n.blockExplorers?.default.url},A=(a,r,n,l)=>{let i=Number(a),o=r.find((e=>e.id===i));if(!o)throw new t(`Unsupported chainId ${a}`,4901);return new e(o.rpcUrls.privyWalletOverride&&o.rpcUrls.privyWalletOverride.http[0]?o.rpcUrls.privyWalletOverride.http[0]:n.rpcUrls&&n.rpcUrls[i]?n.rpcUrls[i]:o.rpcUrls.privy?.http[0]?{url:o.rpcUrls.privy.http[0],headers:{"privy-app-id":l.appId}}:o.rpcUrls.public?.http[0]?o.rpcUrls.public.http[0]:o.rpcUrls.default?.http[0])},M=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},a=e.types.EIP712Domain??Object.entries(e.domain).map((([e,a])=>{if(null!=a&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:a}}};function T(e,{min:t,max:a}){return Math.min(Math.max(e,t),a)}const F="https://auth.privy.io",P=2e4,L=1400,H=2500,_=4e3,I="1.92.3-beta-20241024200145",D="privy:token",j="privy-token",B="privy:refresh_token",z="privy-refresh-token",R="privy:id_token",K="privy-id-token",$="privy-session",q="privy:session_transfer_token",Z="privy:caid",N=e=>`privy:guest:${e}`,G=e=>`privy:cross-app:${e}`,X="privy:state_code",Y="privy:code_verifier",J="privy:headless_oauth",V="privy:oauth_disable_signup",Q=e=>`privy:wallet:${e}`,ee="privy:connectors",te="privy:connections",ae=12e4,re=1,ne="0x1",le=3e4,ie="https://api.moonpay.com/v1",oe="https://api.moonpay.com/v1",se="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",pe="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",ce="deprecated",ue={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-mainnet.rpc.privy.systems"]},alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}},he={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0},de={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}},me={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0},fe={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-mainnet.rpc.privy.systems"]},blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}}},ge={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0},ye={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1},be={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1},we={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://mainnet.rpc.privy.systems"]},alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}},ve={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-mainnet.rpc.privy.systems"]},alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}},Ce={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0},ke={id:137,name:"Polygon Mainnet",network:"polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-mainnet.rpc.privy.systems"]},alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}},Ee={id:80002,name:"Polygon Amoy",network:"polygon-amoy",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-amoy.rpc.privy.systems"]},infura:{http:["https://polygon-amoy.infura.io/v3"],webSocket:["wss://polygon-amoy.infura.io/ws/v3"]},default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"OK LINK",url:"https://www.oklink.com/amoy"}},testnet:!0},We={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{privy:{http:["https://sepolia.rpc.privy.systems"]},alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0},Se={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}},Ue=[ue,he,We,we,ve,Ce,ke,Ee,ye,{id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0},{id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}},{id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}},fe,ge,{id:80085,network:"berachain-artio",name:"Berachain Artio",nativeCurrency:{name:"BERA",symbol:"BERA",decimals:18},rpcUrls:{default:{http:["https://berachain-artio.rpc.privy.systems"]},public:{http:["https://berachain-artio.rpc.privy.systems"]}},blockExplorers:{default:{name:"Beratrail",url:"https://artio.beratrail.io"}},testnet:!0},{id:42,network:"lukso",name:"LUKSO",nativeCurrency:{name:"LUKSO",symbol:"LYX",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.lukso.network"],webSocket:["wss://ws-rpc.mainnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Mainnet Explorer",url:"https://explorer.execution.mainnet.lukso.network"}}},be,{id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0},de,me,Se,{id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0},{id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0},{id:17e3,name:"Holesky",network:"holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://ethereum-holesky.publicnode.com"]},public:{http:["https://ethereum-holesky.publicnode.com"]}},blockExplorers:{etherscan:{name:"EtherScan",url:"https://holesky.etherscan.io"},default:{name:"EtherScan",url:"https://holesky.etherscan.io"}}},{id:690,name:"Redstone",network:"redstone",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.redstonechain.com"]},public:{http:["https://rpc.redstonechain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.redstone.xyz/"}}},{id:17069,name:"Garnet Holesky",network:"garnet-holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.garnetchain.com"]},public:{http:["https://rpc.garnetchain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.garnetchain.com"}}}],xe=new Set(Ue.map((e=>e.id))),Oe={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",rpcConfig:{rpcUrls:{},rpcTimeouts:{}},externalWallets:{coinbaseWallet:{connectionOptions:"all"}},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}};let Ae=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","wallet_connect","detected_wallets","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe"]),Me=e=>Ae.has(e),Te=(e,t,a)=>a.indexOf(e)===t;const Fe=({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(Me).filter(Te):e?e.filter(Me).filter(Te):Oe.appearance.walletList;function Pe(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}}function Le(e){let t=e.filter((e=>!xe.has(e.id)));return Ue.concat(t)}function He(e,t){return{...e,rpcUrls:{...e.rpcUrls,privy:{http:[t]}}}}let _e="#FFFFFF";function Ie(e,t){let a=Math.max(0,Math.min(1,e.toHsl().l+t));return s({...e.toHsl(),l:a})}function De({backgroundTheme:e,accentHex:t}){let a;switch(e){case"light":a=_e;break;case"dark":a="#1E1E1D";break;default:a=e}let r=s(a),n=s(t),l=s("#51BA81"),i=s("#FFB74D"),o=s("#EC6351"),p=function(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}(r.getLuminance()),c=Ie(r,"light"===p?-.04:.11),u=Ie(r,"light"===p?-.88:.87),h=Ie(r,"light"===p?-.7:.75),d=Ie(r,"light"===p?-.43:.45).desaturate("light"===p?60:20),m=Ie(r,"light"===p?-.08:.25).desaturate("light"===p?60:20),f=Ie(n,.15),g=Ie(n,-.06),y=Ie(o,.3),b=Ie(i,.3),w=s(n.getLuminance()>.5?"#040217":_e),v=Ie(l,-.16),C=Ie(l,.4);return{colorScheme:p,background:r.toHslString(),background2:c.toHslString(),foreground:u.toHslString(),foreground2:h.toHslString(),foreground3:d.toHslString(),foreground4:m.toHslString(),accent:n.toHslString(),accentLight:f.toHslString(),accentDark:g.toHslString(),foregroundAccent:w.toHslString(),success:l.toHslString(),successDark:v.toHslString(),successLight:C.toHslString(),error:o.toHslString(),errorLight:y.toHslString(),warn:i.toHslString(),warnLight:b.toHslString()}}function je(e,t,a){let r,n,l,i,o,s,p,c,u,h,d,m,f,g,y,b,w=a?console.warn:()=>{};t?.loginMethods?(r=t.loginMethods.includes("email"),n=t.loginMethods.includes("sms"),i=t.loginMethods.includes("wallet"),o=t.loginMethods.includes("google"),s=t.loginMethods.includes("twitter"),p=t.loginMethods.includes("discord"),u=t.loginMethods.includes("spotify"),h=t.loginMethods.includes("instagram"),c=t.loginMethods.includes("tiktok"),m=t.loginMethods.includes("github"),d=t.loginMethods.includes("linkedin"),f=t.loginMethods.includes("apple"),g=t.loginMethods.includes("farcaster"),y=t.loginMethods.includes("telegram")):(r=e.emailAuth,n=e.smsAuth,i=e.walletAuth||e.solanaWalletAuth,o=e.googleOAuth,s=e.twitterOAuth,p=e.discordOAuth,m=e.githubOAuth,u=e.spotifyOAuth,h=e.instagramOAuth,c=e.tiktokOAuth,d=e.linkedinOAuth,f=e.appleOAuth,g=e.farcasterAuth,y=e.telegramAuth),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential?l=!1:e.passkeyAuth&&(l=!0);let v=[r,n].filter(Boolean),C=[o,s,p,m,u,h,c,d,f,g,y].filter(Boolean),k=[i].filter(Boolean);if(v.length+C.length+k.length===0)throw Error("You must enable at least one login method");let E=void 0!==t?.appearance?.showWalletLoginFirst?t?.appearance?.showWalletLoginFirst:e.showWalletLoginFirst;E&&0===k.length?(w("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),E=!1):E||C.length+v.length!==0||(w("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),E=!0);let W=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&w("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let S=Fe({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),U=(({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],a=[];for(let a of(e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`"),e.primary.slice(1)))t.includes(a)?console.warn(`Duplicated login method: ${a}`):t.push(a);for(let r of e.overflow??[])t.includes(r)||a.includes(r)?console.warn(`Duplicated login method: ${r}`):a.push(r);return{primary:t,overflow:a}})({input:t?.loginMethodsAndOrder}),x=t?.intl?.defaultCountry??"US",{chains:O,defaultChain:A}=function({additionalChains:e,supportedChains:t,defaultChainFromConfig:a,hasRpcConfigDefined:r}){let n;if(e&&t&&console.warn("You should only specify one of `additionalChains` or `supportedChains`. Using `supportedChains`."),t){if(0===t.length)throw Error("`supportedChains` must contain at least one chain");t.filter((e=>e.rpcUrls.privyWalletOverride)).length>0&&r&&console.warn("You have specified at least one `supportedChain` with `privyWalletOverride` but also have `rpcConfig` defined. The `rpcConfig` will be ignored. `rpcConfig` is deprecated and you should use `privyWalletOverride` in a `supportedChain`."),n=t.map((e=>{if(e.rpcUrls.privyWalletOverride)return e;let t=Ue.find((t=>t.id===e.id)),a=t?.rpcUrls.privy?.http[0];return a?He(e,a):e}))}else n=Ue.concat(e??[]);let l=t?n[0]:we,i=a??l;if(!n.find((e=>e.id===i.id)))throw Error("`defaultChain` must be included in `supportedChains`");return{chains:n,defaultChain:i}}({additionalChains:t?.additionalChains,supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain,hasRpcConfigDefined:Object.keys(t?.rpcConfig?.rpcUrls??{}).length>0}),M=!!t?.defaultChain,T=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,F=!(e.enforceWalletUis??1);if(b=e.legacyWalletUiConfig??1?T?t?.embeddedWallets?.noPromptOnSignature??!0:t?.embeddedWallets?.noPromptOnSignature??F:F,!1===t?.embeddedWallets?.waitForTransactionConfirmation&&!0!==b)throw Error("Overriding `config.embeddedWallets.waitForTransactionConfirmation` requires that you disable wallet UIs in the dashboard.");let{requireUserPasswordOnCreate:P,...L}=t?.embeddedWallets??{};return{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,legacyWalletUiConfig:e.legacyWalletUiConfig,appearance:{logo:t?.appearance?.logo??e.logoUrl,landingHeader:t?.appearance?.landingHeader??Oe.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,palette:De({backgroundTheme:t?.appearance?.theme??Oe.appearance.theme,accentHex:t?.appearance?.accentColor??e.accentColor??Oe.appearance.accentColor}),loginGroupPriority:E?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:S,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.walletAuth??!1,solanaWalletAuth:e.solanaWalletAuth??!1})},loginMethods:{wallet:i,email:r,sms:n,passkey:l,google:o,twitter:s,discord:p,github:m,spotify:u,instagram:h,tiktok:c,linkedin:d,apple:f,farcaster:g,telegram:y},disablePlusEmails:e.disablePlusEmails,loginMethodsAndOrder:U,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.termsAndConditionsUrl,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacyPolicyUrl,requireUsersAcceptTerms:e.requireUsersAcceptTerms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.walletConnectCloudProjectId??Oe.walletConnectCloudProjectId,rpcConfig:{rpcUrls:t?.rpcConfig?.rpcUrls??Oe.rpcConfig.rpcUrls,rpcTimeouts:t?.rpcConfig?.rpcTimeouts??Oe.rpcConfig.rpcTimeouts},chains:O,defaultChain:A,intl:{defaultCountry:x},shouldEnforceDefaultChainOnConnect:M,captchaEnabled:e.captchaEnabled??Oe.captchaEnabled,captchaSiteKey:e.captchaSiteKey,externalWallets:{coinbaseWallet:{connectionOptions:t?.externalWallets?.coinbaseWallet?.connectionOptions??Oe.externalWallets.coinbaseWallet.connectionOptions},walletConnect:{enabled:W},solana:{connectors:t?.externalWallets?.solana?.connectors}},embeddedWallets:{...e.embeddedWalletConfig,..."boolean"==typeof P?{requireUserOwnedRecoveryOnCreate:P}:{},...T?{createOnLogin:"all-users",requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]}:{},waitForTransactionConfirmation:!0,priceDisplay:{primary:"fiat-currency",secondary:"native-token"},...L,noPromptOnSignature:b,showWalletUIs:t?.embeddedWallets?.showWalletUIs},mfa:{methods:e.mfaMethods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},customAuth:T?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:e.telegramAuthConfiguration},headless:!!t?.headless,render:{standalone:t?._render?.standalone??Oe._render.standalone},fundingConfig:e.fundingConfig,fundingMethodConfig:{...t?.fundingMethodConfig??Oe.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??Oe.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??Oe.fundingMethodConfig.moonpay.useSandbox}}}}let Be={showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,linkedinOAuth:!1,appleOAuth:!1,disablePlusEmails:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{createOnLogin:"off",requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]},fiatOnRampEnabled:!1,captchaEnabled:!1,captchaSiteKey:""};const ze=je(Be,void 0,!1);let Re=o({appConfig:ze,isServerConfigLoaded:!1});const Ke=({children:e,legacyCreateEmbeddedWalletFlag:t,client:i,clientConfig:o})=>{let[s,p]=r(null),c=n((()=>je(s??Be,o,!!s)),[s,o]);return l((()=>{if(!s)return;let e=function(e,t){if(!e)return{legacyCreateEmbeddedWalletFlag:t};let{appearance:a,additionalChains:r,supportedChains:n,defaultChain:l,externalWallets:i,...o}=e;return{...o,...r?{additionalChains:r.map((e=>e.id))}:void 0,...n?{supportedChains:n.map((e=>e.id))}:void 0,...l?{defaultChain:l.id}:void 0,...i?{walletConnect:i.walletConnect,coinbaseWallet:i.coinbaseWallet,solana:{connectors:i.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0,legacyCreateEmbeddedWalletFlag:t}}(o,t),a=function(e,t=0){let a=3735928559^t,r=1103547991^t;for(let t,n=0;n<e.length;n++)a=Math.imul(a^(t=e.charCodeAt(n)),2654435761),r=Math.imul(r^t,1597334677);return a=Math.imul(a^a>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),4294967296*(2097151&(r=Math.imul(r^r>>>16,2246822507)^Math.imul(a^a>>>13,3266489909)))+(a>>>0)}(JSON.stringify(e)).toString(),r=`privy:sent:${s.id}:${a}`;localStorage.getItem(r)||(i.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(r,"t"))}),[o,t,s]),l((()=>{s||(async()=>{try{let e=await i.getServerConfig();e.customApiUrl&&i.updateApiUrl(e.customApiUrl),p(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),a(Re.Provider,{value:{appConfig:c,isServerConfigLoaded:!!s},children:e})},$e=()=>{let{appConfig:e}=i(Re);return e},qe=()=>{let{isServerConfigLoaded:e}=i(Re);return e},Ze=o(null);function Ne(){let e=i(Ze);if(null===e)throw Error("`useWallets` was called outside the PrivyProvider component");return e}export{we as $,L as A,h as B,Y as C,ae as D,g as E,q as F,b as G,J as H,R as I,H as J,C as K,f as L,T as M,Le as N,V as O,re as P,x as Q,B as R,X as S,D as T,ue as U,I as V,le as W,de as X,fe as Y,ye as Z,be as _,A as a,ve as a0,ke as a1,Se as a2,Ne as a3,_ as a4,y as a5,oe as a6,ie as a7,pe as a8,se as a9,m as aa,d as ab,We as ac,Ce as ad,Ee as ae,ge as af,me as ag,he as ah,Ke as ai,qe as aj,Ze as ak,Ue as al,Pe as am,He as an,O as ao,ze as ap,M as b,Q as c,ne as d,xe as e,S as f,N as g,U as h,v as i,ee as j,W as k,u as l,te as m,G as n,$ as o,w as p,ce as q,j as r,k as s,E as t,z as u,K as v,F as w,P as x,Z as y,$e as z};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/react-auth",
3
- "version": "1.92.2",
3
+ "version": "1.92.3-beta-20241024200145",
4
4
  "description": "React client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",
@@ -107,7 +107,7 @@
107
107
  "@heroicons/react": "^2.1.1",
108
108
  "@marsidev/react-turnstile": "^0.4.1",
109
109
  "@metamask/eth-sig-util": "^6.0.0",
110
- "@privy-io/js-sdk-core": "0.29.3",
110
+ "@privy-io/js-sdk-core": "0.30.0-beta-20241024200145",
111
111
  "@simplewebauthn/browser": "^9.0.1",
112
112
  "@solana/wallet-adapter-base": "^0.9.23",
113
113
  "@solana/wallet-standard-wallet-adapter-base": "^1.1.2",
@@ -146,7 +146,7 @@
146
146
  "@babel/preset-typescript": "^7.24.7",
147
147
  "@jest/globals": "^29.7.0",
148
148
  "@privy-io/eslint-config-custom": "*",
149
- "@privy-io/public-api": "2.11.2",
149
+ "@privy-io/public-api": "2.11.3-beta-20241024200145",
150
150
  "@rollup/plugin-commonjs": "^26.0.1",
151
151
  "@rollup/plugin-node-resolve": "^15.2.3",
152
152
  "@rollup/plugin-replace": "^5.0.5",
@@ -1 +0,0 @@
1
- "use strict";var e=require("@ethersproject/address"),t=require("react");function i(e){return e?new Date(1e3*e):null}function r(e,t){return e.slice().sort(((e,t)=>(t.firstVerifiedAt??t.verifiedAt).getTime()-(e.firstVerifiedAt??e.verifiedAt).getTime())).find((e=>e.type===t))}const a=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType&&0===e.walletIndex))||null,s=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType&&0===e.walletIndex))||null;const l=t.createContext(void 0);let n=()=>t.useContext(l);function d(e,t,i,...r){for(let a of e.current[t][i])a(...r)}exports.PrivyEventsContext=l,exports.convertUserResponseToUser=function(e){if(!e)return null;let t=function(e){let t=[];for(let r of e){let e=r.type;switch(r.type){case"wallet":let a={address:r.address,type:r.type,imported:r.imported,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at),chainType:r.chain_type,chainId:r.chain_id,walletClient:"privy"===r.wallet_client_type?"privy":"unknown",walletClientType:r.wallet_client_type,connectorType:r.connector_type,recoveryMethod:r.recovery_method,walletIndex:r.wallet_index};t.push(a);break;case"smart_wallet":let s={address:r.address,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at),smartWalletType:r.smart_wallet_type};t.push(s);break;case"cross_app":let l={type:r.type,subject:r.subject,embeddedWallets:r.embedded_wallets,smartWallets:r.smart_wallets,providerApp:{id:r.provider_app_id},verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(l);break;case"email":let n={address:r.address,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(n);break;case"phone":let d={number:r.phoneNumber,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(d);break;case"google_oauth":let o={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(o);break;case"spotify_oauth":let u={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(u);break;case"instagram_oauth":let f={subject:r.subject,username:r.username,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(f);break;case"twitter_oauth":let c={subject:r.subject,username:r.username,name:r.name,type:r.type,profilePictureUrl:r.profile_picture_url,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(c);break;case"discord_oauth":let p={subject:r.subject,username:r.username,email:r.email,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(p);break;case"github_oauth":let m={subject:r.subject,username:r.username,name:r.name,email:r.email,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(m);break;case"tiktok_oauth":let _={subject:r.subject,username:r.username,name:r.name,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(_);break;case"linkedin_oauth":let y={subject:r.subject,name:r.name,email:r.email,vanityName:r.vanity_name,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(y);break;case"apple_oauth":let v={subject:r.subject,email:r.email,type:r.type,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(v);break;case"custom_auth":t.push({type:r.type,customUserId:r.custom_user_id,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)});break;case"farcaster":let h={type:r.type,fid:r.fid,ownerAddress:r.owner_address,displayName:r.display_name,username:r.username,bio:r.bio,pfp:r.profile_picture_url,url:r.homepage_url,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at),signerPublicKey:r.signer_public_key};t.push(h);break;case"passkey":let A={type:r.type,enrolledInMfa:r.enrolled_in_mfa,credentialId:r.credential_id,authenticatorName:r.authenticator_name,createdWithDevice:r.created_with_device,createdWithOs:r.created_with_os,createdWithBrowser:r.created_with_browser,verifiedAt:i(r.verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(A);break;case"telegram":let b={type:r.type,telegramUserId:r.telegram_user_id,firstName:r.first_name,lastName:r.last_name,username:r.username,photoUrl:r.photo_url,verifiedAt:i(r.first_verified_at),firstVerifiedAt:i(r.first_verified_at),latestVerifiedAt:i(r.latest_verified_at)};t.push(b);break;default:console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),a=r(t,"wallet"),s=r(t,"smart_wallet"),l=r(t,"email"),n=r(t,"phone"),d=r(t,"google_oauth"),o=r(t,"twitter_oauth"),u=r(t,"discord_oauth"),f=r(t,"github_oauth"),c=r(t,"spotify_oauth"),p=r(t,"instagram_oauth"),m=r(t,"tiktok_oauth"),_=r(t,"linkedin_oauth"),y=r(t,"apple_oauth"),v=r(t,"farcaster"),h=r(t,"telegram"),A=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:i(t)})));return{id:e.id,createdAt:i(e.created_at),linkedAccounts:t,email:l&&{address:l?.address},phone:n&&{number:n?.number},wallet:a&&{address:a.address,chainType:a.chainType,chainId:a.chainId,walletClient:a.walletClient,walletClientType:a.walletClientType,connectorType:a.connectorType,recoveryMethod:a.recoveryMethod,imported:a.imported,walletIndex:a.walletIndex},smartWallet:s&&{address:s.address,smartWalletType:s.smartWalletType},google:d&&{subject:d.subject,email:d.email,name:d.name},twitter:o&&{subject:o.subject,username:o.username,name:o.name,profilePictureUrl:o.profilePictureUrl},discord:u&&{subject:u.subject,username:u.username,email:u.email},github:f&&{subject:f.subject,username:f.username,name:f.name,email:f.email},spotify:c&&{subject:c.subject,email:c.email,name:c.name},instagram:p&&{subject:p.subject,username:p.username},tiktok:m&&{subject:m.subject,username:m.username,name:m.name},linkedin:_&&{subject:_.subject,name:_.name,email:_.email,vanityName:_.vanityName},apple:y&&{subject:y.subject,email:y.email},farcaster:v&&{fid:v.fid,ownerAddress:v.ownerAddress,displayName:v.displayName,username:v.username,bio:v.bio,pfp:v.pfp,url:v.url,signerPublicKey:v.signerPublicKey},telegram:h&&{telegramUserId:h.telegramUserId,firstName:h.firstName,lastName:h.lastName,username:h.username,photoUrl:h.photoUrl},mfaMethods:A.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}},exports.emitPrivyEvent=d,exports.getEthereumSigningAndRootWallet=(t,i)=>{let r=(s=t,s?.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&"ethereum"===e.chainType))).find((t=>e.getAddress(t.address)===e.getAddress(i)));var s;return{signingWallet:r,rootWallet:r?r.imported?r:a(t):void 0}},exports.getImportedPrivyEthereumWallet=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType))||null,exports.getPrivyEthereumHDWallets=e=>e?.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType)),exports.getPrivyEthereumWallet=a,exports.getPrivySolanaWallet=s,exports.getSolanaSigningAndRootWallet=(e,t)=>{let i=(e=>e?.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType)))(e).find((e=>e.address.toLowerCase()===t.toLowerCase()));return{signingWallet:i,rootWallet:0===i?.walletIndex?i:s(e)}},exports.privyEventsDefault={login:{onComplete:[],onError:[],onOAuthLoginComplete:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},update:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},setWalletRecovery:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},sendSolanaTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]},oAuthAuthorization:{onOAuthTokenGrant:[]},fundWallet:{onUserExited:[]},fundSolanaWallet:{onUserExited:[]},customAuth:{onAuthenticated:[],onUnauthenticated:[]}},exports.shouldProceedtoEmbeddedWalletCreationFlow=(e,t)=>!(a(e)||s(e)||"all-users"!==t&&("users-without-wallets"!==t||(e=>e.linkedAccounts.filter((e=>"wallet"===e.type)))(e)?.length)),exports.useEmitPrivyEvent=function(){let e=n();return(t,i,...r)=>d(e,t,i,...r)},exports.usePrivyEventSubscription=function(e,i){if(!i)return;let r=n().current[e];return t.useEffect((()=>{for(let[t,a]of Object.entries(i))r.hasOwnProperty(t)||console.warn(`Invalid event type "${t}" for action "${e}"`),r[t]?.push(a);return()=>{for(let[t,a]of Object.entries(i))r.hasOwnProperty(t)||console.warn(`Invalid event type "${t}" for action "${e}"`),r[t]=r[t]?.filter((e=>e!==a))}}),[i])};
@@ -1 +0,0 @@
1
- "use strict";var E,e=require("viem"),_=require("viem/actions"),N=require("viem/chains"),A=require("./privy-context-Do1698Nd.js"),S=require("react/jsx-runtime"),a=require("react"),T=require("./useWallets-Db8wjylW.js");function t({src:E,...e}){return S.jsx("img",{src:E,...e,style:{display:"none"}})}exports.ModalScreen=void 0,(E=exports.ModalScreen||(exports.ModalScreen={})).LANDING="LANDING",E.CONNECT_OR_CREATE="CONNECT_OR_CREATE",E.AWAITING_CONNECTION="AWAITING_CONNECTION",E.AWAITING_FARCASTER_CONNECTION="AWAITING_FARCASTER_CONNECTION",E.AWAITING_FARCASTER_SIGNER="AWAITING_FARCASTER_SIGNER",E.AWAITING_OAUTH_SCREEN="AWAITING_OAUTH_SCREEN",E.CROSS_APP_AUTH_SCREEN="CROSS_APP_AUTH_SCREEN",E.AWAITING_PASSWORDLESS_CODE="AWAITING_PASSWORDLESS_CODE",E.AWAITING_PASSKEY_SYSTEM_DIALOGUE="AWAITING_PASSKEY_SYSTEM_DIALOGUE",E.LINK_EMAIL_SCREEN="LINK_EMAIL_SCREEN",E.LINK_PHONE_SCREEN="LINK_PHONE_SCREEN",E.LINK_WALLET_SCREEN="LINK_WALLET_SCREEN",E.LINK_PASSKEY_SCREEN="LINK_PASSKEY_SCREEN",E.UPDATE_EMAIL_SCREEN="UPDATE_EMAIL_SCREEN",E.UPDATE_PHONE_SCREEN="UPDATE_PHONE_SCREEN",E.AWAITING_CONNECT_ONLY_CONNECTION="AWAITING_CONNECT_ONLY_CONNECTION",E.CONNECT_ONLY_LANDING_SCREEN="CONNECT_ONLY_LANDING_SCREEN",E.CONNECT_ONLY_AUTHENTICATED_SCREEN="CONNECT_ONLY_AUTHENTICATED_SCREEN",E.LOGIN_FAILED_SCREEN="LOGIN_FAILED_SCREEN",E.ALLOWLIST_REJECTION_SCREEN="ALLOWLIST_REJECTION_SCREEN",E.ACCOUNT_NOT_FOUND_SCREEN="ACCOUNT_NOT_FOUND_SCREEN",E.USER_LIMIT_REACHED_SCREEN="USER_LIMIT_REACHED_SCREEN",E.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN="EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN",E.EMBEDDED_WALLET_CREATED_SCREEN="EMBEDDED_WALLET_CREATED_SCREEN",E.EMBEDDED_WALLET_CONNECTING_SCREEN="EMBEDDED_WALLET_CONNECTING_SCREEN",E.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN="EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN",E.EMBEDDED_WALLET_KEY_EXPORT_SCREEN="EMBEDDED_WALLET_KEY_EXPORT_SCREEN",E.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN="EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",E.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN="EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN",E.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN="EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",E.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN="EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN",E.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN="EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN",E.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN="EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN",E.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN="EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN",E.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN="EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN",E.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN="EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN",E.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN="EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN",E.INSTALL_PHANTOM_SCREEN="INSTALL_PHANTOM_SCREEN",E.PHANTOM_INTERSTITIAL_SCREEN="PHANTOM_INTERSTITIAL_SCREEN",E.AFFIRMATIVE_CONSENT_SCREEN="AFFIRMATIVE_CONSENT_SCREEN",E.FUNDING_METHOD_SELECTION_SCREEN="FUNDING_METHOD_SELECTION_SCREEN",E.FUNDING_TRANSFER_FROM_WALLET_SCREEN="FUNDING_TRANSFER_FROM_WALLET_SCREEN",E.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN="FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN",E.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN="FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN",E.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN="FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN",E.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN="FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN",E.FUNDING_MANUAL_TRANSFER_SCREEN="FUNDING_MANUAL_TRANSFER_SCREEN",E.MOONPAY_PROMPT_SCREEN="MOONPAY_PROMPT_SCREEN",E.MOONPAY_STATUS_SCREEN="MOONPAY_STATUS_SCREEN",E.COINBASE_ONRAMP_STATUS_SCREEN="COINBASE_ONRAMP_STATUS_SCREEN",E.MFA_ENROLLMENT_FLOW_SCREEN="MFA_ENROLLMENT_FLOW_SCREEN",E.CAPTCHA_SCREEN="CAPTCHA_SCREEN",E.ERROR_SCREEN="ERROR_SCREEN",E.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE="IN_APP_BROWSER_LOGIN_NOT_POSSIBLE",E.TELEGRAM_AUTH_SCREEN="TELEGRAM_AUTH_SCREEN",E.LINK_CONFLICT_SCREEN="LINK_CONFLICT_SCREEN";const R=a.createContext({ready:!1,app:T.DEFAULT_APP_CONFIG,currentScreen:null,lastScreen:null,navigate:A.notImplemented,navigateBack:A.notImplemented,resetNavigation:A.notImplemented,setModalData:A.notImplemented,onUserCloseViaDialogOrKeybindRef:void 0});let C=[exports.ModalScreen.LANDING,exports.ModalScreen.CONNECT_ONLY_LANDING_SCREEN,null];const n=()=>a.useContext(R);function r(E){return E?e.pad(e.numberToHex(BigInt(E)),{dir:"left",size:20}):"0x"}exports.ModalProvider=E=>{let e=T.useAppConfig(),_=E.authenticated,[N,A]=a.useState(E.initialScreen);a.useEffect((()=>{_||C.includes(E.initialScreen)||E.setInitialScreen(null)}),[_]);let n=a.useRef(null);a.useEffect((()=>{E.open||(n.current=null)}),[E.open]),a.useEffect((()=>{n.current=null}),[E.initialScreen]);let r={ready:!!e.id,app:e,data:E.data,setModalData:E.setModalData,currentScreen:E.initialScreen,lastScreen:N,navigate:(e,_=!0)=>{E.setInitialScreen(e),_&&A(E.initialScreen)},navigateBack:()=>{E.setInitialScreen(N)},resetNavigation:()=>{E.setInitialScreen(null),A(null)},onUserCloseViaDialogOrKeybindRef:n};return S.jsxs(R.Provider,{value:r,children:[("string"==typeof e.appearance.logo||"img"===e.appearance.logo?.type)&&S.jsx(t,{src:"string"==typeof e.appearance.logo?e.appearance.logo:e.appearance.logo.props.src}),E.children]})},exports.getEmbeddedConnectedWallet=function(E){return E.find((E=>"privy"===E.walletClientType&&"embedded"===E.connectorType&&!E.imported))??null},exports.useAbstractSmartWallets=function(){let{noPromptOnSignature:E,openPrivyModal:S,chains:a}=A.usePrivyInternal(),{signTypedData:t}=A.usePrivy(),{setModalData:R}=n(),C=a.find((E=>E.id===N.abstractTestnet.id));return{sendTransaction:(N,A,a,n,s)=>{A.to=r(A.to);let I=T.generateTypedDataWithDomainType(((E,e)=>{let _="string"==typeof E?JSON.parse(E):E,N=e.custom?.getEip712Domain?.({..._,chainId:e.id,from:_.from,type:"eip712"});return N.domain.name="zkSync",Object.entries(N.message).forEach((([E,e])=>{"bigint"==typeof e&&(N.message[E]=String(e))})),N})(A,C));return new Promise((async(T,D)=>{E.current=!0,R({connectWallet:{onCompleteNavigateTo:exports.ModalScreen.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN,onFailure:()=>{}},sendTransaction:{transactionRequests:a.map((E=>({to:r(I.message.to),value:"string"==typeof E.value?e.isHex(E.value)?E.value:e.numberToHex(BigInt(E.value)):E.value,data:E.data??"0x",chainId:I.domain.chainId,maxPriorityFeePerGas:BigInt(I.message.maxPriorityFeePerGas),maxFeePerGas:BigInt(I.message.maxFeePerGas),gasLimit:BigInt(I.message.gasLimit),nonce:I.message.nonce}))),rootWallet:{address:N.address},transactingWallet:{address:N.address,walletIndex:null},getIsSponsored:async()=>Number(I.message.paymaster)>0,onConfirm:async()=>{let E=await t(I),N={to:BigInt(I.message.to),value:BigInt(I.message.value),data:I.message.data??void 0,chainId:I.domain.chainId,maxPriorityFeePerGas:BigInt(I.message.maxPriorityFeePerGas),maxFeePerGas:BigInt(I.message.maxFeePerGas),gas:BigInt(I.message.gasLimit),paymaster:r(I.message.paymaster),paymasterInput:I.message.paymasterInput},S=e.encodeAbiParameters(e.parseAbiParameters(["bytes","address","bytes[]"]),[E,"0xC894DE2894e2F84C0C2944FDcce9490eC22A92b6",[]]),a={...N,factoryDeps:A.factoryDeps,to:r(I.message.to),chainId:C.id,from:e.numberToHex(BigInt(I.message.from)),customSignature:S,type:"eip712",data:I.message.data,nonce:Number(I.message.nonce)},T=C.serializers?.transaction(a,{r:"0x0",s:"0x0",v:0n}),R=e.createPublicClient({chain:C,transport:e.http(`https://abs-testnet.rpc.privy.systems?privyAppId=${n}`)});return await _.sendRawTransaction(R,{serializedTransaction:T})},onSuccess:E=>T(E.hash),onFailure:D,uiOptions:s}}),S(exports.ModalScreen.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{E.current=!1}))}}},exports.usePrivyModal=n;
@@ -1 +0,0 @@
1
- import{getAddress as e}from"@ethersproject/address";import{createContext as t,useEffect as i,useContext as a}from"react";function r(e){return e?new Date(1e3*e):null}function s(e,t){return e.slice().sort(((e,t)=>(t.firstVerifiedAt??t.verifiedAt).getTime()-(e.firstVerifiedAt??e.verifiedAt).getTime())).find((e=>e.type===t))}const l=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType&&0===e.walletIndex))||null,n=e=>e?.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType)),d=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType&&0===e.walletIndex))||null,o=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType))||null,f=(t,i)=>{let a=(r=t,r?.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&"ethereum"===e.chainType))).find((t=>e(t.address)===e(i)));var r;return{signingWallet:a,rootWallet:a?a.imported?a:l(t):void 0}},u=(e,t)=>{let i=(e=>e?.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType)))(e).find((e=>e.address.toLowerCase()===t.toLowerCase()));return{signingWallet:i,rootWallet:0===i?.walletIndex?i:d(e)}};const c=(e,t)=>!(l(e)||d(e)||"all-users"!==t&&("users-without-wallets"!==t||(e=>e.linkedAccounts.filter((e=>"wallet"===e.type)))(e)?.length));function p(e){if(!e)return null;let t=function(e){let t=[];for(let i of e){let e=i.type;switch(i.type){case"wallet":let a={address:i.address,type:i.type,imported:i.imported,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at),chainType:i.chain_type,chainId:i.chain_id,walletClient:"privy"===i.wallet_client_type?"privy":"unknown",walletClientType:i.wallet_client_type,connectorType:i.connector_type,recoveryMethod:i.recovery_method,walletIndex:i.wallet_index};t.push(a);break;case"smart_wallet":let s={address:i.address,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at),smartWalletType:i.smart_wallet_type};t.push(s);break;case"cross_app":let l={type:i.type,subject:i.subject,embeddedWallets:i.embedded_wallets,smartWallets:i.smart_wallets,providerApp:{id:i.provider_app_id},verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(l);break;case"email":let n={address:i.address,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(n);break;case"phone":let d={number:i.phoneNumber,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(d);break;case"google_oauth":let o={subject:i.subject,email:i.email,name:i.name,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(o);break;case"spotify_oauth":let f={subject:i.subject,email:i.email,name:i.name,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(f);break;case"instagram_oauth":let u={subject:i.subject,username:i.username,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(u);break;case"twitter_oauth":let c={subject:i.subject,username:i.username,name:i.name,type:i.type,profilePictureUrl:i.profile_picture_url,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(c);break;case"discord_oauth":let p={subject:i.subject,username:i.username,email:i.email,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(p);break;case"github_oauth":let _={subject:i.subject,username:i.username,name:i.name,email:i.email,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(_);break;case"tiktok_oauth":let m={subject:i.subject,username:i.username,name:i.name,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(m);break;case"linkedin_oauth":let y={subject:i.subject,name:i.name,email:i.email,vanityName:i.vanity_name,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(y);break;case"apple_oauth":let v={subject:i.subject,email:i.email,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(v);break;case"custom_auth":t.push({type:i.type,customUserId:i.custom_user_id,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)});break;case"farcaster":let h={type:i.type,fid:i.fid,ownerAddress:i.owner_address,displayName:i.display_name,username:i.username,bio:i.bio,pfp:i.profile_picture_url,url:i.homepage_url,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at),signerPublicKey:i.signer_public_key};t.push(h);break;case"passkey":let A={type:i.type,enrolledInMfa:i.enrolled_in_mfa,credentialId:i.credential_id,authenticatorName:i.authenticator_name,createdWithDevice:i.created_with_device,createdWithOs:i.created_with_os,createdWithBrowser:i.created_with_browser,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(A);break;case"telegram":let b={type:i.type,telegramUserId:i.telegram_user_id,firstName:i.first_name,lastName:i.last_name,username:i.username,photoUrl:i.photo_url,verifiedAt:r(i.first_verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(b);break;default:console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),i=s(t,"wallet"),a=s(t,"smart_wallet"),l=s(t,"email"),n=s(t,"phone"),d=s(t,"google_oauth"),o=s(t,"twitter_oauth"),f=s(t,"discord_oauth"),u=s(t,"github_oauth"),c=s(t,"spotify_oauth"),p=s(t,"instagram_oauth"),_=s(t,"tiktok_oauth"),m=s(t,"linkedin_oauth"),y=s(t,"apple_oauth"),v=s(t,"farcaster"),h=s(t,"telegram"),A=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:r(t)})));return{id:e.id,createdAt:r(e.created_at),linkedAccounts:t,email:l&&{address:l?.address},phone:n&&{number:n?.number},wallet:i&&{address:i.address,chainType:i.chainType,chainId:i.chainId,walletClient:i.walletClient,walletClientType:i.walletClientType,connectorType:i.connectorType,recoveryMethod:i.recoveryMethod,imported:i.imported,walletIndex:i.walletIndex},smartWallet:a&&{address:a.address,smartWalletType:a.smartWalletType},google:d&&{subject:d.subject,email:d.email,name:d.name},twitter:o&&{subject:o.subject,username:o.username,name:o.name,profilePictureUrl:o.profilePictureUrl},discord:f&&{subject:f.subject,username:f.username,email:f.email},github:u&&{subject:u.subject,username:u.username,name:u.name,email:u.email},spotify:c&&{subject:c.subject,email:c.email,name:c.name},instagram:p&&{subject:p.subject,username:p.username},tiktok:_&&{subject:_.subject,username:_.username,name:_.name},linkedin:m&&{subject:m.subject,name:m.name,email:m.email,vanityName:m.vanityName},apple:y&&{subject:y.subject,email:y.email},farcaster:v&&{fid:v.fid,ownerAddress:v.ownerAddress,displayName:v.displayName,username:v.username,bio:v.bio,pfp:v.pfp,url:v.url,signerPublicKey:v.signerPublicKey},telegram:h&&{telegramUserId:h.telegramUserId,firstName:h.firstName,lastName:h.lastName,username:h.username,photoUrl:h.photoUrl},mfaMethods:A.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}}const _={login:{onComplete:[],onError:[],onOAuthLoginComplete:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},update:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},setWalletRecovery:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},sendSolanaTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]},oAuthAuthorization:{onOAuthTokenGrant:[]},fundWallet:{onUserExited:[]},fundSolanaWallet:{onUserExited:[]},customAuth:{onAuthenticated:[],onUnauthenticated:[]}},m=t(void 0);let y=()=>a(m);function v(e,t){if(!t)return;let a=y().current[e];return i((()=>{for(let[i,r]of Object.entries(t))a.hasOwnProperty(i)||console.warn(`Invalid event type "${i}" for action "${e}"`),a[i]?.push(r);return()=>{for(let[i,r]of Object.entries(t))a.hasOwnProperty(i)||console.warn(`Invalid event type "${i}" for action "${e}"`),a[i]=a[i]?.filter((e=>e!==r))}}),[t])}function h(e,t,i,...a){for(let r of e.current[t][i])r(...a)}function A(){let e=y();return(t,i,...a)=>h(e,t,i,...a)}export{m as P,d as a,A as b,p as c,o as d,h as e,n as f,l as g,f as h,u as i,_ as p,c as s,v as u};
@@ -1 +0,0 @@
1
- import{isHex as E,numberToHex as _,encodeAbiParameters as N,parseAbiParameters as e,createPublicClient as A,http as S,pad as a}from"viem";import{sendRawTransaction as T}from"viem/actions";import{abstractTestnet as R}from"viem/chains";import{n as C,u as t,h as I}from"./privy-context-QVrL4VJ3.mjs";import{jsx as D,jsxs as n}from"react/jsx-runtime";import{useState as L,useEffect as O,useRef as s,useContext as r,createContext as i}from"react";import{z as o,ap as l,b as c}from"./useWallets-BQQjDV6b.mjs";function M({src:E,..._}){return D("img",{src:E,..._,style:{display:"none"}})}var W,m;(W=m||(m={})).LANDING="LANDING",W.CONNECT_OR_CREATE="CONNECT_OR_CREATE",W.AWAITING_CONNECTION="AWAITING_CONNECTION",W.AWAITING_FARCASTER_CONNECTION="AWAITING_FARCASTER_CONNECTION",W.AWAITING_FARCASTER_SIGNER="AWAITING_FARCASTER_SIGNER",W.AWAITING_OAUTH_SCREEN="AWAITING_OAUTH_SCREEN",W.CROSS_APP_AUTH_SCREEN="CROSS_APP_AUTH_SCREEN",W.AWAITING_PASSWORDLESS_CODE="AWAITING_PASSWORDLESS_CODE",W.AWAITING_PASSKEY_SYSTEM_DIALOGUE="AWAITING_PASSKEY_SYSTEM_DIALOGUE",W.LINK_EMAIL_SCREEN="LINK_EMAIL_SCREEN",W.LINK_PHONE_SCREEN="LINK_PHONE_SCREEN",W.LINK_WALLET_SCREEN="LINK_WALLET_SCREEN",W.LINK_PASSKEY_SCREEN="LINK_PASSKEY_SCREEN",W.UPDATE_EMAIL_SCREEN="UPDATE_EMAIL_SCREEN",W.UPDATE_PHONE_SCREEN="UPDATE_PHONE_SCREEN",W.AWAITING_CONNECT_ONLY_CONNECTION="AWAITING_CONNECT_ONLY_CONNECTION",W.CONNECT_ONLY_LANDING_SCREEN="CONNECT_ONLY_LANDING_SCREEN",W.CONNECT_ONLY_AUTHENTICATED_SCREEN="CONNECT_ONLY_AUTHENTICATED_SCREEN",W.LOGIN_FAILED_SCREEN="LOGIN_FAILED_SCREEN",W.ALLOWLIST_REJECTION_SCREEN="ALLOWLIST_REJECTION_SCREEN",W.ACCOUNT_NOT_FOUND_SCREEN="ACCOUNT_NOT_FOUND_SCREEN",W.USER_LIMIT_REACHED_SCREEN="USER_LIMIT_REACHED_SCREEN",W.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN="EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN",W.EMBEDDED_WALLET_CREATED_SCREEN="EMBEDDED_WALLET_CREATED_SCREEN",W.EMBEDDED_WALLET_CONNECTING_SCREEN="EMBEDDED_WALLET_CONNECTING_SCREEN",W.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN="EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN",W.EMBEDDED_WALLET_KEY_EXPORT_SCREEN="EMBEDDED_WALLET_KEY_EXPORT_SCREEN",W.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN="EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",W.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN="EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN",W.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN="EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",W.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN="EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN",W.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN="EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN",W.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN="EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN",W.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN="EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN",W.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN="EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN",W.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN="EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN",W.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN="EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN",W.INSTALL_PHANTOM_SCREEN="INSTALL_PHANTOM_SCREEN",W.PHANTOM_INTERSTITIAL_SCREEN="PHANTOM_INTERSTITIAL_SCREEN",W.AFFIRMATIVE_CONSENT_SCREEN="AFFIRMATIVE_CONSENT_SCREEN",W.FUNDING_METHOD_SELECTION_SCREEN="FUNDING_METHOD_SELECTION_SCREEN",W.FUNDING_TRANSFER_FROM_WALLET_SCREEN="FUNDING_TRANSFER_FROM_WALLET_SCREEN",W.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN="FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN",W.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN="FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN",W.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN="FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN",W.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN="FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN",W.FUNDING_MANUAL_TRANSFER_SCREEN="FUNDING_MANUAL_TRANSFER_SCREEN",W.MOONPAY_PROMPT_SCREEN="MOONPAY_PROMPT_SCREEN",W.MOONPAY_STATUS_SCREEN="MOONPAY_STATUS_SCREEN",W.COINBASE_ONRAMP_STATUS_SCREEN="COINBASE_ONRAMP_STATUS_SCREEN",W.MFA_ENROLLMENT_FLOW_SCREEN="MFA_ENROLLMENT_FLOW_SCREEN",W.CAPTCHA_SCREEN="CAPTCHA_SCREEN",W.ERROR_SCREEN="ERROR_SCREEN",W.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE="IN_APP_BROWSER_LOGIN_NOT_POSSIBLE",W.TELEGRAM_AUTH_SCREEN="TELEGRAM_AUTH_SCREEN",W.LINK_CONFLICT_SCREEN="LINK_CONFLICT_SCREEN";const G=i({ready:!1,app:l,currentScreen:null,lastScreen:null,navigate:C,navigateBack:C,resetNavigation:C,setModalData:C,onUserCloseViaDialogOrKeybindRef:void 0});let P=[m.LANDING,m.CONNECT_ONLY_LANDING_SCREEN,null];const p=E=>{let _=o(),N=E.authenticated,[e,A]=L(E.initialScreen);O((()=>{N||P.includes(E.initialScreen)||E.setInitialScreen(null)}),[N]);let S=s(null);O((()=>{E.open||(S.current=null)}),[E.open]),O((()=>{S.current=null}),[E.initialScreen]);let a={ready:!!_.id,app:_,data:E.data,setModalData:E.setModalData,currentScreen:E.initialScreen,lastScreen:e,navigate:(_,N=!0)=>{E.setInitialScreen(_),N&&A(E.initialScreen)},navigateBack:()=>{E.setInitialScreen(e)},resetNavigation:()=>{E.setInitialScreen(null),A(null)},onUserCloseViaDialogOrKeybindRef:S};return n(G.Provider,{value:a,children:[("string"==typeof _.appearance.logo||"img"===_.appearance.logo?.type)&&D(M,{src:"string"==typeof _.appearance.logo?_.appearance.logo:_.appearance.logo.props.src}),E.children]})},g=()=>r(G);function d(E){return E?a(_(BigInt(E)),{dir:"left",size:20}):"0x"}function F(){let{noPromptOnSignature:a,openPrivyModal:C,chains:D}=t(),{signTypedData:n}=I(),{setModalData:L}=g(),O=D.find((E=>E.id===R.id));return{sendTransaction:(R,t,I,D,s)=>{t.to=d(t.to);let r=c(((E,_)=>{let N="string"==typeof E?JSON.parse(E):E,e=_.custom?.getEip712Domain?.({...N,chainId:_.id,from:N.from,type:"eip712"});return e.domain.name="zkSync",Object.entries(e.message).forEach((([E,_])=>{"bigint"==typeof _&&(e.message[E]=String(_))})),e})(t,O));return new Promise((async(i,o)=>{a.current=!0,L({connectWallet:{onCompleteNavigateTo:m.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN,onFailure:()=>{}},sendTransaction:{transactionRequests:I.map((N=>({to:d(r.message.to),value:"string"==typeof N.value?E(N.value)?N.value:_(BigInt(N.value)):N.value,data:N.data??"0x",chainId:r.domain.chainId,maxPriorityFeePerGas:BigInt(r.message.maxPriorityFeePerGas),maxFeePerGas:BigInt(r.message.maxFeePerGas),gasLimit:BigInt(r.message.gasLimit),nonce:r.message.nonce}))),rootWallet:{address:R.address},transactingWallet:{address:R.address,walletIndex:null},getIsSponsored:async()=>Number(r.message.paymaster)>0,onConfirm:async()=>{let E=await n(r),a={to:BigInt(r.message.to),value:BigInt(r.message.value),data:r.message.data??void 0,chainId:r.domain.chainId,maxPriorityFeePerGas:BigInt(r.message.maxPriorityFeePerGas),maxFeePerGas:BigInt(r.message.maxFeePerGas),gas:BigInt(r.message.gasLimit),paymaster:d(r.message.paymaster),paymasterInput:r.message.paymasterInput},R=N(e(["bytes","address","bytes[]"]),[E,"0xC894DE2894e2F84C0C2944FDcce9490eC22A92b6",[]]),C={...a,factoryDeps:t.factoryDeps,to:d(r.message.to),chainId:O.id,from:_(BigInt(r.message.from)),customSignature:R,type:"eip712",data:r.message.data,nonce:Number(r.message.nonce)},I=O.serializers?.transaction(C,{r:"0x0",s:"0x0",v:0n}),L=A({chain:O,transport:S(`https://abs-testnet.rpc.privy.systems?privyAppId=${D}`)});return await T(L,{serializedTransaction:I})},onSuccess:E=>i(E.hash),onFailure:o,uiOptions:s}}),C(m.EMBEDDED_WALLET_CONNECTING_SCREEN)})).finally((()=>{a.current=!1}))}}}function u(E){return E.find((E=>"privy"===E.walletClientType&&"embedded"===E.connectorType&&!E.imported))??null}export{m as M,p as a,F as b,u as g,g as u};
@@ -1 +0,0 @@
1
- import{FetchError as e}from"ofetch";import{createContext as t,useContext as i}from"react";var n;class a extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(e,t,i){super(e),t instanceof Error&&(this.cause=t),this.privyErrorCode=i}}class s extends a{constructor(e,t,i,n,a,s){super(i,n,a),this.type=e,this.status=t,this.data=s}}class r extends a{constructor(e,t,i){super(e,t,i),this.type="client_error"}}class l extends r{constructor(){super("Request timed out",void 0,"client_request_timeout")}}class o extends a{constructor(e,t,i){super(e,t,i),this.type="connector_error"}}const _=t=>{if(t instanceof a)return t;if(!(t instanceof e))return u(t);if(!t.response)return new s("api_error",null,t.message,t);let{type:i,message:n,error:r,code:l}=t.data;return new s(i||"ApiError",t.response.status,n||r,t,l,t.data)},u=e=>e instanceof a?e:e instanceof Error?new r(e.message,e):new r(`Internal error: ${e}`);var d;(n=d||(d={})).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",n.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",n.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",n.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",n.INVALID_DATA="invalid_data",n.INVALID_CAPTCHA="invalid_captcha",n.LINKED_TO_ANOTHER_USER="linked_to_another_user",n.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",n.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",n.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",n.USER_EXITED_UPDATE_FLOW="exited_update_flow",n.ALLOWLIST_REJECTED="allowlist_rejected",n.OAUTH_USER_DENIED="oauth_user_denied",n.OAUTH_UNEXPECTED="oauth_unexpected",n.UNKNOWN_AUTH_ERROR="unknown_auth_error",n.USER_EXITED_AUTH_FLOW="exited_auth_flow",n.USER_EXITED_LINK_FLOW="exited_link_flow",n.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",n.MUST_BE_AUTHENTICATED="must_be_authenticated",n.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",n.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",n.CLIENT_REQUEST_TIMEOUT="client_request_timeout",n.INVALID_CREDENTIALS="invalid_credentials",n.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",n.UNKNOWN_MFA_ERROR="unknown_mfa_error",n.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",n.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",n.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",n.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",n.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",n.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",n.TRANSACTION_FAILURE="transaction_failure",n.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",n.NOT_SUPPORTED="not_supported",n.CAPTCHA_TIMEOUT="captcha_timeout",n.INVALID_MESSAGE="invalid_message",n.UNABLE_TO_SIGN="unable_to_sign",n.CAPTCHA_FAILURE="captcha_failure",n.CAPTCHA_DISABLED="captcha_disabled",n.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",n.TOO_MANY_REQUESTS="too_many_requests",n.USER_LIMIT_REACHED="max_accounts_reached",n.DISALLOWED_LOGIN_METHOD="disallowed_login_method",n.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",n.PASSKEY_NOT_ALLOWED="passkey_not_allowed",n.USER_DOES_NOT_EXIST="user_does_not_exist",n.INSUFFICIENT_BALANCE="insufficient_balance",n.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required";class c extends r{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}}class E extends r{constructor(e="Embedded wallet error",t){super(e,t,"unknown_embedded_wallet_error")}}class A extends r{constructor(e="User must be authenticated"){super(e,void 0,"must_be_authenticated")}}class p extends r{constructor(e){super("This application is in development mode and must be upgraded to production to log in new users.",e,"max_accounts_reached")}}const S=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},h=e=>()=>{throw Error(e.trim())},T=t({isNewUserThisSession:!1,walletConnectionStatus:null,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,appId:"notAdded",customAuthStatus:{status:"not-enabled"},noPromptOnSignature:{current:!1},nativeTokenSymbolForChainId:S,initializeWalletProxy:S,getAuthMeta:S,getAuthFlow:S,closePrivyModal:S,openPrivyModal:S,connectWallet:S,initLoginWithWallet:S,loginWithWallet:S,initLoginWithFarcaster:S,loginWithFarcaster:S,loginWithCode:S,initLoginWithEmail:S,initLoginWithSms:S,initUpdateEmail:S,initUpdatePhone:S,resendEmailCode:S,resendSmsCode:S,initLoginWithHeadlessOAuth:S,loginWithHeadlessOAuth:S,crossAppAuthFlow:S,initLoginWithOAuth:S,recoveryOAuthFlow:S,loginWithOAuth:S,passkeyAuthState:{status:"initial"},setPasskeyAuthState:S,initLoginWithPasskey:S,loginWithPasskey:S,initLinkWithPasskey:S,linkWithPasskey:S,refreshUser:S,loginWithGuestAccountFlow:S,walletProxy:null,createAnalyticsEvent:S,acceptTerms:S,getUsdTokenPrice:S,getUsdPriceForSol:S,recoverEmbeddedEthereumWallet:S,getMoonpaySignedUrl:S,initCoinbaseOnRamp:S,getCoinbaseOnRampStatus:S,updateWallets:S,fundWallet:S,fundSolanaWallet:S,setReadyToTrue:S,requestFarcasterSignerStatus:S,initLoginWithTelegram:S,loginWithTelegram:S,generateSiweMessage:S,generateSiweMessageForSmartWallet:S,linkWithSiwe:S,linkSmartWallet:S,initDelegateAction:S,embeddedSolanaWallet:null,createEmbeddedSolanaWallet:S,recoverEmbeddedSolanaWallet:S,exportSolanaWallet:S,solanaSignMessage:S,connectCoinbaseSmartWallet:S,initiateAccountTransfer:S,emailOtpState:{status:"initial"},setEmailOtpState:S,smsOtpState:{status:"initial"},setSmsOtpState:S,siweState:{status:"initial"},setSiweState:S,oAuthState:{status:"initial"},setOAuthState:S}),m=()=>i(T),W=t({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:S,login:S,connectOrCreateWallet:S,linkEmail:S,linkPhone:S,linkFarcaster:S,linkWallet:S,startCrossAppAuthFlow:S,linkGoogle:S,linkTwitter:S,linkDiscord:S,linkGithub:S,linkSpotify:S,linkInstagram:S,linkTelegram:S,linkTiktok:S,linkLinkedIn:S,linkApple:S,linkPasskey:S,updateEmail:S,updatePhone:S,logout:S,getAccessToken:S,getEthereumProvider:S,getEthersProvider:S,getWeb3jsProvider:S,unlinkEmail:S,unlinkPhone:S,unlinkWallet:S,unlinkGoogle:S,unlinkTwitter:S,unlinkDiscord:S,unlinkGithub:S,unlinkSpotify:S,unlinkInstagram:S,unlinkTiktok:S,unlinkLinkedIn:S,unlinkApple:S,unlinkCrossAppAccount:S,unlinkFarcaster:S,unlinkTelegram:S,unlinkPasskey:S,setActiveWallet:S,forkSession:S,createWallet:S,importWallet:S,signMessage:S,signTypedData:S,enrollInMfa:S,initEnrollmentWithSms:S,initEnrollmentWithTotp:S,initEnrollmentWithPasskey:S,promptMfa:S,init:S,submitEnrollmentWithSms:S,submitEnrollmentWithTotp:S,submitEnrollmentWithPasskey:S,unenroll:S,submit:S,cancel:S,sendTransaction:S,sendSolanaTransaction:S,exportWallet:S,setWalletPassword:S,setWalletRecovery:S,requestFarcasterSignerFromWarpcast:S,getFarcasterSignerPublicKey:S,signFarcasterMessage:S,createGuestAccount:S,initLoginWithEmail:S,initLoginWithSms:S,otpState:{status:"initial"},loginWithCode:S,fundWallet:S,initLoginWithHeadlessOAuth:S,loginWithHeadlessOAuth:S,generateSiweMessage:S,linkWithSiwe:S,signMessageWithCrossAppWallet:S,signTypedDataWithCrossAppWallet:S,sendTransactionWithCrossAppWallet:S,isHeadlessOAuthLoading:!1,isModalOpen:!1,mfaMethods:[]}),g=()=>i(W);export{T as I,r as P,d as a,a as b,o as c,l as d,u as e,_ as f,s as g,g as h,p as i,E as j,A as k,W as l,c as m,S as n,h as o,m as u};
@@ -1 +0,0 @@
1
- import{StaticJsonRpcProvider as e}from"@ethersproject/providers";import{c as t}from"./privy-context-QVrL4VJ3.mjs";import{jsx as a}from"react/jsx-runtime";import{useState as r,useMemo as n,useEffect as l,useContext as i,createContext as o}from"react";import s from"tinycolor2";const p=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,c=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==p(e))return!1;if(e.providers)for(let t of e.providers)if(!c(t))return!1;return!0},u=()=>{if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId)return!0}return!1},h=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers)for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0;return!1},d=(e,t)=>{let a=[],r=[];for(let[n,l]of e.entries())n<t?a.push(l):r.push(l);return[a,r]},m=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),f=(e,t)=>{let a=e.slice(0),r=[];for(;a.length;)r.push(a.splice(0,t));return r},g=(e,t=3,a=4,r="ethereum")=>{if(!e)return"";let n="ethereum"===r?2:0;return t+a+n+3>=e.length?e:`${e.slice(0,n+t)}...${e.slice(e.length-a,e.length)}`},y=(e,t=3,a=4)=>g(e,t,a,"solana"),b=e=>new Promise((t=>setTimeout(t,e)));function w(e,{interval:t=100,timeout:a=5e3}={}){return new Promise(((r,n)=>{let l,i=0,o=()=>{i>=a?n("Max attempts reached without result"):(l=e(),i+=t,null==l?setTimeout(o,t):r(l))};o()}))}const v=(e,t={})=>{let a=t.delayMs||150,r=t.maxAttempts||270;return new Promise((async(n,l)=>{let i=!1,o=0;for(;!i&&o<r;){if(t.abortSignal?.aborted)return;e().then((e=>{i=!0,n(e)}),((...e)=>{i=!0,l(...e)})),o+=1,await b(a)}i||l(Error("Exceeded max attempts before resolving function"))}))},C=(e,t,a={},r={})=>{let n=new URL(t,e);for(let[e,t]of Object.entries(a))void 0!==t&&n.searchParams.set(e,t);let l=Object.entries(r);if(l.length>0){let e=new URLSearchParams;for(let[t,a]of l)e.append(t,a);n.hash=e.toString()}return n.href},k=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),E=e=>"string"==typeof e?e:"0x"+e.toString(16);async function W({store:e,walletList:t,externalWalletConfig:a,walletChainType:r,timeout:n=3e3}){let l=!1,i=window;return new Promise((o=>{function s(){if(l)return;l=!0,window.removeEventListener("ethereum#initialized",s);let n=e.getProviders();console.debug("Detected injected providers:",n.map((e=>e.info)));let i=[];for(let e of n)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===r&&"app.phantom"===e.info.rdns||i.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==r)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let a=[];if(t.providers?.length)for(let e of t.providers)e&&a.push(e);return a.push(e.ethereum),a}()){let t=p(e);if(!n.some((e=>e.info.name===t))){if(c(e,!0)&&!i.find((e=>"metamask"===e.type))){i.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!i.find((e=>"phantom"===e.type))){i.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!i.find((e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==a.coinbaseWallet?.connectionOptions))){i.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}i.find((e=>"unknown_browser_extension"===e.type))||i.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}o(i)}i.ethereum?s():(window.addEventListener("ethereum#initialized",s,{once:!0}),setTimeout((()=>{s()}),n))}))}function S(e){return`eip155:${String(Number(e))}`}const U=(e,a,r,n)=>{let l=Number(e),i=a.find((e=>e.id===l));if(!i)throw new t(`Unsupported chainId ${e}`,4901);return x(i,r,n)},x=(e,a,r)=>{let n,l=e.id,i=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])n=e.rpcUrls.privyWalletOverride.http[0];else if(a.rpcUrls&&a.rpcUrls[i])n=a.rpcUrls[i];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",r),n=t.toString()}else n=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!n)throw new t(`No RPC url found for ${l}`);return n},O=(e,a)=>{let r=Number(e),n=a.find((e=>e.id===r));if(!n)throw new t(`Unsupported chainId ${e}`,4901);return n.blockExplorers?.default.url},A=(a,r,n,l)=>{let i=Number(a),o=r.find((e=>e.id===i));if(!o)throw new t(`Unsupported chainId ${a}`,4901);return new e(o.rpcUrls.privyWalletOverride&&o.rpcUrls.privyWalletOverride.http[0]?o.rpcUrls.privyWalletOverride.http[0]:n.rpcUrls&&n.rpcUrls[i]?n.rpcUrls[i]:o.rpcUrls.privy?.http[0]?{url:o.rpcUrls.privy.http[0],headers:{"privy-app-id":l.appId}}:o.rpcUrls.public?.http[0]?o.rpcUrls.public.http[0]:o.rpcUrls.default?.http[0])},M=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},a=e.types.EIP712Domain??Object.entries(e.domain).map((([e,a])=>{if(null!=a&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:a}}};function T(e,{min:t,max:a}){return Math.min(Math.max(e,t),a)}const F="https://auth.privy.io",P=2e4,L=1400,H=2500,_=4e3,I="1.92.2",D="privy:token",j="privy-token",B="privy:refresh_token",z="privy-refresh-token",R="privy:id_token",K="privy-id-token",$="privy-session",q="privy:session_transfer_token",Z="privy:caid",N=e=>`privy:guest:${e}`,G=e=>`privy:cross-app:${e}`,X="privy:state_code",Y="privy:code_verifier",J="privy:headless_oauth",V="privy:oauth_disable_signup",Q=e=>`privy:wallet:${e}`,ee="privy:connectors",te="privy:connections",ae=12e4,re=1,ne="0x1",le=3e4,ie="https://api.moonpay.com/v1",oe="https://api.moonpay.com/v1",se="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",pe="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",ce="deprecated",ue={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-mainnet.rpc.privy.systems"]},alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}},he={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0},de={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}},me={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0},fe={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-mainnet.rpc.privy.systems"]},blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}}},ge={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0},ye={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1},be={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1},we={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://mainnet.rpc.privy.systems"]},alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}},ve={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-mainnet.rpc.privy.systems"]},alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}},Ce={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0},ke={id:137,name:"Polygon Mainnet",network:"polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-mainnet.rpc.privy.systems"]},alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}},Ee={id:80002,name:"Polygon Amoy",network:"polygon-amoy",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-amoy.rpc.privy.systems"]},infura:{http:["https://polygon-amoy.infura.io/v3"],webSocket:["wss://polygon-amoy.infura.io/ws/v3"]},default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"OK LINK",url:"https://www.oklink.com/amoy"}},testnet:!0},We={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{privy:{http:["https://sepolia.rpc.privy.systems"]},alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0},Se={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}},Ue=[ue,he,We,we,ve,Ce,ke,Ee,ye,{id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0},{id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}},{id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}},fe,ge,{id:80085,network:"berachain-artio",name:"Berachain Artio",nativeCurrency:{name:"BERA",symbol:"BERA",decimals:18},rpcUrls:{default:{http:["https://berachain-artio.rpc.privy.systems"]},public:{http:["https://berachain-artio.rpc.privy.systems"]}},blockExplorers:{default:{name:"Beratrail",url:"https://artio.beratrail.io"}},testnet:!0},{id:42,network:"lukso",name:"LUKSO",nativeCurrency:{name:"LUKSO",symbol:"LYX",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.lukso.network"],webSocket:["wss://ws-rpc.mainnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Mainnet Explorer",url:"https://explorer.execution.mainnet.lukso.network"}}},be,{id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0},de,me,Se,{id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0},{id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0},{id:17e3,name:"Holesky",network:"holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://ethereum-holesky.publicnode.com"]},public:{http:["https://ethereum-holesky.publicnode.com"]}},blockExplorers:{etherscan:{name:"EtherScan",url:"https://holesky.etherscan.io"},default:{name:"EtherScan",url:"https://holesky.etherscan.io"}}},{id:690,name:"Redstone",network:"redstone",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.redstonechain.com"]},public:{http:["https://rpc.redstonechain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.redstone.xyz/"}}},{id:17069,name:"Garnet Holesky",network:"garnet-holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.garnetchain.com"]},public:{http:["https://rpc.garnetchain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.garnetchain.com"}}}],xe=new Set(Ue.map((e=>e.id))),Oe={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",rpcConfig:{rpcUrls:{},rpcTimeouts:{}},externalWallets:{coinbaseWallet:{connectionOptions:"all"}},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}};let Ae=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","wallet_connect","detected_wallets","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe"]),Me=e=>Ae.has(e),Te=(e,t,a)=>a.indexOf(e)===t;const Fe=({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(Me).filter(Te):e?e.filter(Me).filter(Te):Oe.appearance.walletList;function Pe(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}}function Le(e){let t=e.filter((e=>!xe.has(e.id)));return Ue.concat(t)}function He(e,t){return{...e,rpcUrls:{...e.rpcUrls,privy:{http:[t]}}}}let _e="#FFFFFF";function Ie(e,t){let a=Math.max(0,Math.min(1,e.toHsl().l+t));return s({...e.toHsl(),l:a})}function De({backgroundTheme:e,accentHex:t}){let a;switch(e){case"light":a=_e;break;case"dark":a="#1E1E1D";break;default:a=e}let r=s(a),n=s(t),l=s("#51BA81"),i=s("#FFB74D"),o=s("#EC6351"),p=function(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}(r.getLuminance()),c=Ie(r,"light"===p?-.04:.11),u=Ie(r,"light"===p?-.88:.87),h=Ie(r,"light"===p?-.7:.75),d=Ie(r,"light"===p?-.43:.45).desaturate("light"===p?60:20),m=Ie(r,"light"===p?-.08:.25).desaturate("light"===p?60:20),f=Ie(n,.15),g=Ie(n,-.06),y=Ie(o,.3),b=Ie(i,.3),w=s(n.getLuminance()>.5?"#040217":_e),v=Ie(l,-.16),C=Ie(l,.4);return{colorScheme:p,background:r.toHslString(),background2:c.toHslString(),foreground:u.toHslString(),foreground2:h.toHslString(),foreground3:d.toHslString(),foreground4:m.toHslString(),accent:n.toHslString(),accentLight:f.toHslString(),accentDark:g.toHslString(),foregroundAccent:w.toHslString(),success:l.toHslString(),successDark:v.toHslString(),successLight:C.toHslString(),error:o.toHslString(),errorLight:y.toHslString(),warn:i.toHslString(),warnLight:b.toHslString()}}function je(e,t,a){let r,n,l,i,o,s,p,c,u,h,d,m,f,g,y,b,w=a?console.warn:()=>{};t?.loginMethods?(r=t.loginMethods.includes("email"),n=t.loginMethods.includes("sms"),i=t.loginMethods.includes("wallet"),o=t.loginMethods.includes("google"),s=t.loginMethods.includes("twitter"),p=t.loginMethods.includes("discord"),u=t.loginMethods.includes("spotify"),h=t.loginMethods.includes("instagram"),c=t.loginMethods.includes("tiktok"),m=t.loginMethods.includes("github"),d=t.loginMethods.includes("linkedin"),f=t.loginMethods.includes("apple"),g=t.loginMethods.includes("farcaster"),y=t.loginMethods.includes("telegram")):(r=e.emailAuth,n=e.smsAuth,i=e.walletAuth||e.solanaWalletAuth,o=e.googleOAuth,s=e.twitterOAuth,p=e.discordOAuth,m=e.githubOAuth,u=e.spotifyOAuth,h=e.instagramOAuth,c=e.tiktokOAuth,d=e.linkedinOAuth,f=e.appleOAuth,g=e.farcasterAuth,y=e.telegramAuth),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential?l=!1:e.passkeyAuth&&(l=!0);let v=[r,n].filter(Boolean),C=[o,s,p,m,u,h,c,d,f,g,y].filter(Boolean),k=[i].filter(Boolean);if(v.length+C.length+k.length===0)throw Error("You must enable at least one login method");let E=void 0!==t?.appearance?.showWalletLoginFirst?t?.appearance?.showWalletLoginFirst:e.showWalletLoginFirst;E&&0===k.length?(w("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),E=!1):E||C.length+v.length!==0||(w("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),E=!0);let W=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&w("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let S=Fe({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),U=(({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],a=[];for(let a of(e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`"),e.primary.slice(1)))t.includes(a)?console.warn(`Duplicated login method: ${a}`):t.push(a);for(let r of e.overflow??[])t.includes(r)||a.includes(r)?console.warn(`Duplicated login method: ${r}`):a.push(r);return{primary:t,overflow:a}})({input:t?.loginMethodsAndOrder}),x=t?.intl?.defaultCountry??"US",{chains:O,defaultChain:A}=function({additionalChains:e,supportedChains:t,defaultChainFromConfig:a,hasRpcConfigDefined:r}){let n;if(e&&t&&console.warn("You should only specify one of `additionalChains` or `supportedChains`. Using `supportedChains`."),t){if(0===t.length)throw Error("`supportedChains` must contain at least one chain");t.filter((e=>e.rpcUrls.privyWalletOverride)).length>0&&r&&console.warn("You have specified at least one `supportedChain` with `privyWalletOverride` but also have `rpcConfig` defined. The `rpcConfig` will be ignored. `rpcConfig` is deprecated and you should use `privyWalletOverride` in a `supportedChain`."),n=t.map((e=>{if(e.rpcUrls.privyWalletOverride)return e;let t=Ue.find((t=>t.id===e.id)),a=t?.rpcUrls.privy?.http[0];return a?He(e,a):e}))}else n=Ue.concat(e??[]);let l=t?n[0]:we,i=a??l;if(!n.find((e=>e.id===i.id)))throw Error("`defaultChain` must be included in `supportedChains`");return{chains:n,defaultChain:i}}({additionalChains:t?.additionalChains,supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain,hasRpcConfigDefined:Object.keys(t?.rpcConfig?.rpcUrls??{}).length>0}),M=!!t?.defaultChain,T=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,F=!(e.enforceWalletUis??1);if(b=e.legacyWalletUiConfig??1?T?t?.embeddedWallets?.noPromptOnSignature??!0:t?.embeddedWallets?.noPromptOnSignature??F:F,!1===t?.embeddedWallets?.waitForTransactionConfirmation&&!0!==b)throw Error("Overriding `config.embeddedWallets.waitForTransactionConfirmation` requires that you disable wallet UIs in the dashboard.");let{requireUserPasswordOnCreate:P,...L}=t?.embeddedWallets??{};return{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,legacyWalletUiConfig:e.legacyWalletUiConfig,appearance:{logo:t?.appearance?.logo??e.logoUrl,landingHeader:t?.appearance?.landingHeader??Oe.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,palette:De({backgroundTheme:t?.appearance?.theme??Oe.appearance.theme,accentHex:t?.appearance?.accentColor??e.accentColor??Oe.appearance.accentColor}),loginGroupPriority:E?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:S,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.walletAuth??!1,solanaWalletAuth:e.solanaWalletAuth??!1})},loginMethods:{wallet:i,email:r,sms:n,passkey:l,google:o,twitter:s,discord:p,github:m,spotify:u,instagram:h,tiktok:c,linkedin:d,apple:f,farcaster:g,telegram:y},disablePlusEmails:e.disablePlusEmails,loginMethodsAndOrder:U,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.termsAndConditionsUrl,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacyPolicyUrl,requireUsersAcceptTerms:e.requireUsersAcceptTerms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.walletConnectCloudProjectId??Oe.walletConnectCloudProjectId,rpcConfig:{rpcUrls:t?.rpcConfig?.rpcUrls??Oe.rpcConfig.rpcUrls,rpcTimeouts:t?.rpcConfig?.rpcTimeouts??Oe.rpcConfig.rpcTimeouts},chains:O,defaultChain:A,intl:{defaultCountry:x},shouldEnforceDefaultChainOnConnect:M,captchaEnabled:e.captchaEnabled??Oe.captchaEnabled,captchaSiteKey:e.captchaSiteKey,externalWallets:{coinbaseWallet:{connectionOptions:t?.externalWallets?.coinbaseWallet?.connectionOptions??Oe.externalWallets.coinbaseWallet.connectionOptions},walletConnect:{enabled:W},solana:{connectors:t?.externalWallets?.solana?.connectors}},embeddedWallets:{...e.embeddedWalletConfig,..."boolean"==typeof P?{requireUserOwnedRecoveryOnCreate:P}:{},...T?{createOnLogin:"all-users",requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]}:{},waitForTransactionConfirmation:!0,priceDisplay:{primary:"fiat-currency",secondary:"native-token"},...L,noPromptOnSignature:b,showWalletUIs:t?.embeddedWallets?.showWalletUIs},mfa:{methods:e.mfaMethods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},customAuth:T?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:e.telegramAuthConfiguration},headless:!!t?.headless,render:{standalone:t?._render?.standalone??Oe._render.standalone},fundingConfig:e.fundingConfig,fundingMethodConfig:{...t?.fundingMethodConfig??Oe.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??Oe.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??Oe.fundingMethodConfig.moonpay.useSandbox}}}}let Be={showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,linkedinOAuth:!1,appleOAuth:!1,disablePlusEmails:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{createOnLogin:"off",requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]},fiatOnRampEnabled:!1,captchaEnabled:!1,captchaSiteKey:""};const ze=je(Be,void 0,!1);let Re=o({appConfig:ze,isServerConfigLoaded:!1});const Ke=({children:e,legacyCreateEmbeddedWalletFlag:t,client:i,clientConfig:o})=>{let[s,p]=r(null),c=n((()=>je(s??Be,o,!!s)),[s,o]);return l((()=>{if(!s)return;let e=function(e,t){if(!e)return{legacyCreateEmbeddedWalletFlag:t};let{appearance:a,additionalChains:r,supportedChains:n,defaultChain:l,externalWallets:i,...o}=e;return{...o,...r?{additionalChains:r.map((e=>e.id))}:void 0,...n?{supportedChains:n.map((e=>e.id))}:void 0,...l?{defaultChain:l.id}:void 0,...i?{walletConnect:i.walletConnect,coinbaseWallet:i.coinbaseWallet,solana:{connectors:i.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0,legacyCreateEmbeddedWalletFlag:t}}(o,t),a=function(e,t=0){let a=3735928559^t,r=1103547991^t;for(let t,n=0;n<e.length;n++)a=Math.imul(a^(t=e.charCodeAt(n)),2654435761),r=Math.imul(r^t,1597334677);return a=Math.imul(a^a>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),4294967296*(2097151&(r=Math.imul(r^r>>>16,2246822507)^Math.imul(a^a>>>13,3266489909)))+(a>>>0)}(JSON.stringify(e)).toString(),r=`privy:sent:${s.id}:${a}`;localStorage.getItem(r)||(i.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(r,"t"))}),[o,t,s]),l((()=>{s||(async()=>{try{let e=await i.getServerConfig();e.customApiUrl&&i.updateApiUrl(e.customApiUrl),p(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),a(Re.Provider,{value:{appConfig:c,isServerConfigLoaded:!!s},children:e})},$e=()=>{let{appConfig:e}=i(Re);return e},qe=()=>{let{isServerConfigLoaded:e}=i(Re);return e},Ze=o(null);function Ne(){let e=i(Ze);if(null===e)throw Error("`useWallets` was called outside the PrivyProvider component");return e}export{we as $,L as A,h as B,Y as C,ae as D,g as E,q as F,b as G,J as H,R as I,H as J,C as K,f as L,T as M,Le as N,V as O,re as P,x as Q,B as R,X as S,D as T,ue as U,I as V,le as W,de as X,fe as Y,ye as Z,be as _,A as a,ve as a0,ke as a1,Se as a2,Ne as a3,_ as a4,y as a5,oe as a6,ie as a7,pe as a8,se as a9,m as aa,d as ab,We as ac,Ce as ad,Ee as ae,ge as af,me as ag,he as ah,Ke as ai,qe as aj,Ze as ak,Ue as al,Pe as am,He as an,O as ao,ze as ap,M as b,Q as c,ne as d,xe as e,S as f,N as g,U as h,v as i,ee as j,W as k,u as l,te as m,G as n,$ as o,w as p,ce as q,j as r,k as s,E as t,z as u,K as v,F as w,P as x,Z as y,$e as z};