@privy-io/react-auth 3.6.0 → 3.7.0

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 (51) hide show
  1. package/dist/cjs/EmbeddedWalletConnectingScreen-JRafXI8d.js +27 -0
  2. package/dist/cjs/{SignRequestScreen-DBTM8mH6.js → SignRequestScreen-Dy02euV9.js} +1 -1
  3. package/dist/cjs/abstract-smart-wallets.js +1 -1
  4. package/dist/cjs/{events-context-B1SQ9SZZ.js → events-context-7-Gs8c_9.js} +1 -1
  5. package/dist/cjs/extended-chains.js +1 -1
  6. package/dist/cjs/index.js +6 -7
  7. package/dist/cjs/internal.js +1 -1
  8. package/dist/cjs/{smart-wallets-DS5H3O_R.js → smart-wallets-DaqaXBrW.js} +1 -1
  9. package/dist/cjs/smart-wallets.js +1 -1
  10. package/dist/cjs/solana.js +1 -1
  11. package/dist/cjs/ui.js +1 -1
  12. package/dist/cjs/use-export-wallet-Cz8MVlvJ.js +2 -0
  13. package/dist/cjs/{useActiveWallet-DSa22Ge3.js → useActiveWallet-C5D3a-je.js} +1 -1
  14. package/dist/cjs/{usePrivy-BRFNEdKI.js → usePrivy-BdYU4BZI.js} +1 -1
  15. package/dist/dts/{events-context-B1q54lAU.d.mts → events-context-CCElA92Y.d.mts} +1 -1
  16. package/dist/dts/{events-context-B1q54lAU.d.ts → events-context-CCElA92Y.d.ts} +1 -1
  17. package/dist/dts/extended-chains.d.mts +1 -1
  18. package/dist/dts/extended-chains.d.ts +1 -1
  19. package/dist/dts/farcaster.d.mts +1 -1
  20. package/dist/dts/farcaster.d.ts +1 -1
  21. package/dist/dts/index.d.mts +93 -6
  22. package/dist/dts/index.d.ts +93 -6
  23. package/dist/dts/internal.d.mts +1 -1
  24. package/dist/dts/internal.d.ts +1 -1
  25. package/dist/dts/smart-wallets.d.mts +1 -1
  26. package/dist/dts/smart-wallets.d.ts +1 -1
  27. package/dist/dts/solana.d.mts +3 -3
  28. package/dist/dts/solana.d.ts +3 -3
  29. package/dist/dts/{types-BSeKsLfK.d.mts → types-B6UNnZ2P.d.mts} +8 -1
  30. package/dist/dts/{types-BSeKsLfK.d.ts → types-B6UNnZ2P.d.ts} +8 -1
  31. package/dist/dts/ui.d.mts +1 -1
  32. package/dist/dts/ui.d.ts +1 -1
  33. package/dist/esm/EmbeddedWalletConnectingScreen-D50stmJi.mjs +25 -0
  34. package/dist/esm/{SignRequestScreen-B2NV0Hvv.mjs → SignRequestScreen-D9o7VhNz.mjs} +1 -1
  35. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  36. package/dist/esm/{events-context-DpXp5E_5.mjs → events-context-ClaboIDc.mjs} +1 -1
  37. package/dist/esm/extended-chains.mjs +1 -1
  38. package/dist/esm/index.mjs +5 -6
  39. package/dist/esm/internal.mjs +1 -1
  40. package/dist/esm/{smart-wallets-X-vN2hVx.mjs → smart-wallets-BXT3GZwg.mjs} +1 -1
  41. package/dist/esm/smart-wallets.mjs +1 -1
  42. package/dist/esm/solana.mjs +1 -1
  43. package/dist/esm/ui.mjs +2 -2
  44. package/dist/esm/use-export-wallet-DTiEdSYz.mjs +1 -0
  45. package/dist/esm/{useActiveWallet-6VCN4YGN.mjs → useActiveWallet-B8DSbnuu.mjs} +1 -1
  46. package/dist/esm/{usePrivy-DLA1ZqHR.mjs → usePrivy-BCcRF869.mjs} +1 -1
  47. package/package.json +8 -6
  48. package/dist/cjs/EmbeddedWalletConnectingScreen-fhtSGmI2.js +0 -27
  49. package/dist/cjs/use-export-wallet-DPcrptkc.js +0 -2
  50. package/dist/esm/EmbeddedWalletConnectingScreen-DNdaS6u7.mjs +0 -25
  51. package/dist/esm/use-export-wallet-CPIcGGw7.mjs +0 -1
@@ -1 +1 @@
1
- import{P as t,aq as e,f as o,aa as r,h as n}from"./internal-context-eGSwROSk.mjs";import{k as s,n as i}from"./events-context-DpXp5E_5.mjs";import"ofetch";import"react";import"react/jsx-runtime";import"@privy-io/js-sdk-core";import"tinycolor2";class a{async authenticate(){if(!this.api)throw new t("Auth flow has no API instance");try{return await this.api.post(e,{})}catch(t){throw o(t)}}async link(){throw new t("Linking is not supported for the SSO token flow")}constructor(){this.meta={}}}function c(){let e=s(),o=i(),{client:c,setUser:h,setAuthenticated:l,setIsNewUser:w}=r();return{loginWithSsoToken:async()=>{if(!e.id||!c)throw new t("SDK not yet ready");try{let e=new a;c.startAuthFlow(e);let r=await c.authenticate(),n=r.user,s=r.isNewUser??!1;if(!n)throw new t("Unable to authenticate with SSO response");return h(n),w(s),l(!0),o("login","onComplete",{user:n,isNewUser:s,wasAlreadyAuthenticated:!1,loginMethod:"sso",loginAccount:null}),n}catch(t){throw o("login","onError",t.privyErrorCode||n.UNKNOWN_AUTH_ERROR),t}}}}export{c as useLoginWithSsoToken};
1
+ import{P as t,aq as e,f as o,aa as r,h as n}from"./internal-context-eGSwROSk.mjs";import{k as s,n as i}from"./events-context-ClaboIDc.mjs";import"ofetch";import"react";import"react/jsx-runtime";import"@privy-io/js-sdk-core";import"tinycolor2";class a{async authenticate(){if(!this.api)throw new t("Auth flow has no API instance");try{return await this.api.post(e,{})}catch(t){throw o(t)}}async link(){throw new t("Linking is not supported for the SSO token flow")}constructor(){this.meta={}}}function c(){let e=s(),o=i(),{client:c,setUser:h,setAuthenticated:l,setIsNewUser:w}=r();return{loginWithSsoToken:async()=>{if(!e.id||!c)throw new t("SDK not yet ready");try{let e=new a;c.startAuthFlow(e);let r=await c.authenticate(),n=r.user,s=r.isNewUser??!1;if(!n)throw new t("Unable to authenticate with SSO response");return h(n),w(s),l(!0),o("login","onComplete",{user:n,isNewUser:s,wasAlreadyAuthenticated:!1,loginMethod:"sso",loginAccount:null}),n}catch(t){throw o("login","onError",t.privyErrorCode||n.UNKNOWN_AUTH_ERROR),t}}}}export{c as useLoginWithSsoToken};
@@ -1 +1 @@
1
- import{useRef as e,useState as t,useCallback as r}from"react";import{http as n,createPublicClient as a}from"viem";import{ab as i,aa as s,b5 as o,q as l,bL as c,_ as d,F as m,bv as u,bD as p}from"./EmbeddedWalletConnectingScreen-DNdaS6u7.mjs";import{k as y}from"./events-context-DpXp5E_5.mjs";import{aa as g,P as f}from"./internal-context-eGSwROSk.mjs";import{S as h}from"./SignRequestScreen-B2NV0Hvv.mjs";import{a as w}from"./getEmbeddedConnectedWallet-CM6cDQCS.mjs";import{createSmartAccountClient as P}from"permissionless";import{toThirdwebSmartAccount as I,toLightSmartAccount as W,toBiconomySmartAccount as v,toKernelSmartAccount as F,toSafeSmartAccount as x}from"permissionless/accounts";import{createPimlicoClient as G}from"permissionless/clients/pimlico";import{entryPoint07Address as C,entryPoint06Address as T,toCoinbaseSmartAccount as b}from"viem/account-abstraction";import{THIRDWEB as S,COINBASE_SMART_WALLET as U,LIGHT_ACCOUNT as M,BICONOMY as O,KERNEL as V,SAFE as A}from"@privy-io/js-sdk-core";let D={address:T,version:"0.6"},_={address:C,version:"0.7"},N=({owner:e,smartWalletType:t,smartWalletVersion:r,publicClient:n})=>{switch(t){case A:return x({client:n,entryPoint:_,owners:[e],version:"1.4.1"});case V:return F({client:n,version:"0.3.1",entryPoint:_,useMetaFactory:"optional",owners:[e]});case O:return v({client:n,owners:[e],entryPoint:D});case M:return W({client:n,entryPoint:D,owner:e,version:"1.1.0"});case U:return async function({client:e,owner:t,version:r}){let[n]=await t.request({method:"eth_accounts"});if(!n)throw Error("Unable to request embedded owner for eth_accounts");return await b({client:e,owners:[{type:"local",source:"privy",address:n,sign:async({hash:e})=>await t.request({method:"secp256k1_sign",params:[e]})}],version:r})}({client:n,owner:e,version:r??"1"});case S:return I({client:n,entryPoint:_,owner:e});default:throw Error(`Invalid smart account type: ${t}.`)}};const q=({calls:e,chain:t,maxPriorityFeePerGas:r,maxFeePerGas:n,nonce:a})=>e.map((e=>({to:e.to||void 0,data:e.data,value:e.value,chainId:t.id,nonce:a,maxFeePerGas:n,maxPriorityFeePerGas:r}))),B=async({chain:e,paymasterContext:t,account:r,signer:i,user:s,smartWalletsConfig:o,rpcConfig:l,privyAppId:d})=>{if(!(o?.enabled&&s&&r&&i))return;let m=o?.configuredNetworks.find((t=>t.chainId===`eip155:${e.id}`));if(!m)throw new f(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let u=s.smartWallet?s.smartWallet.smartWalletType:o.smartWalletType,p=s.smartWallet?s.smartWallet.smartWalletVersion:o.smartWalletVersion,y=c(e,l,d),g=a({chain:e,transport:n(y)}),h=t??m.paymasterContext,w=await(async({owner:e,smartWalletType:t,smartWalletVersion:r,chain:a,publicClient:i,bundlerUrl:s,paymasterUrl:o,paymasterContext:l})=>{let c=await N({owner:e,smartWalletType:t,publicClient:i,smartWalletVersion:r}),d=G({transport:n(s),entryPoint:c.entryPoint}),m=o?G({transport:n(o),entryPoint:c.entryPoint}):void 0;return P({account:c,chain:a,paymaster:m,paymasterContext:l,bundlerTransport:n(s),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>s.includes(e))))return await d.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>s.includes(e))))return(await d.request({method:"zd_getUserOperationGasPrice",params:[]})).fast;if(["g.alchemy.com"].some((e=>s.includes(e)))){let[e,t]=await Promise.all([i.getBlock({blockTag:"latest"}),d.request({method:"rundler_maxPriorityFeePerGas",params:[]})]);if(!e.baseFeePerGas||!t)throw Error("Failed to get block or maxPriorityFeePerGasEstimate");return{maxFeePerGas:150n*e.baseFeePerGas/100n+BigInt(t.toString()),maxPriorityFeePerGas:BigInt(t.toString())}}{let e=await i.estimateFeesPerGas(),t=s.includes("api.developer.coinbase.com")?175n:150n;return{...e,maxFeePerGas:e.maxFeePerGas*t/100n,maxPriorityFeePerGas:e.maxPriorityFeePerGas*t/100n}}}}})})({owner:i,smartWalletType:u,smartWalletVersion:p,chain:e,publicClient:g,paymasterContext:h,...m});if(!w)throw new f(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return w},$=({clientConfig:n,smartWalletsConfig:a})=>{let{hideWalletUIs:c,openPrivyModal:P,appId:I,isHeadlessSigning:W}=g(),v=y(),{setModalData:F}=i(),{user:x}=s(),{chains:G}=y(),{chainId:C,clients:T,setChainId:b,chainIdState:S}=(()=>{let r=e(),[n,a]=t();return{clients:e({}),setChainId:e=>{r.current=e,a(e)},chainId:r,chainIdState:n}})(),U=G.find((e=>e.id===S)),{wallets:M}=d(),O=o(x),V=w(M,O?.address),A=!!O&&l(O),D=r((async()=>C.current),[C]),_=r((async({id:e})=>{if(!T.current[e]){let t=await B({chain:G.find((t=>t.id===e)),account:O,signer:await(V?.getEthereumProvider()),user:x,paymasterContext:n?.paymasterContext,smartWalletsConfig:a,rpcConfig:v.rpcConfig,privyAppId:I});t&&(T.current[e]=t)}b(e)}),[G,n,M,x,a]);return{wrapSmartAccountClient:e=>{T.current[e.chain.id]=e,S||b(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);if(delete e.account,W({showWalletUIs:t?.uiOptions?.showWalletUIs}))return c.current=!0,await r.sendTransaction(e).finally((()=>c.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 a=async()=>{let{paymasterAndData:t,paymasterData:a,maxFeePerGas:i,maxPriorityFeePerGas:s}=await r.prepareUserOperation({calls:n,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return 0===Number(i)&&0===Number(s)||Number(t??a??0)>0};return new Promise((async(i,s)=>{c.current=!0;let{entropyId:o,entropyIdVerifier:l}=m(x);F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:o,entropyIdVerifier:l,onCompleteNavigateTo:p,onFailure:()=>{}},sendTransaction:{transactionRequests:q({calls:n,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:o,entropyIdVerifier:l,getIsSponsored:a,signOnly:!1,onConfirm:()=>r.sendTransaction(e),onSuccess:e=>i(e.hash),onFailure:s,uiOptions:t?.uiOptions??{}}}),P(u)})).finally((()=>{c.current=!1}))},signMessage:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);return W({showWalletUIs:t?.uiOptions?.showWalletUIs})?(c.current=!0,await r.signMessage(e).finally((()=>c.current=!1))):new Promise((async(n,a)=>{let{entropyId:i,entropyIdVerifier:s}=m(x);c.current=!0,F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:i,entropyIdVerifier:s,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof e.message?e.message:e.message.raw.toString(),confirmAndSign:()=>r.signMessage(e),onSuccess:e=>n(e),onFailure:a,uiOptions:t?.uiOptions??{}}}),P(u)})).finally((()=>{c.current=!1}))},signTypedData:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);return delete e.account,W({showWalletUIs:t?.uiOptions?.showWalletUIs})?(c.current=!0,await r.signTypedData(e).finally((()=>c.current=!1))):new Promise((async(n,a)=>{c.current=!0;let{entropyId:i,entropyIdVerifier:s}=m(x);F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:i,entropyIdVerifier:s,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>n(e),onFailure:a,uiOptions:t?.uiOptions??{}}}),P(u)})).finally((()=>{c.current=!1}))},getChainId:D,chain:U,switchChain:_}}}},k=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:r}=g(),{setModalData:n}=i(),{user:a}=s(),c=o(a),d=!!c&&l(c);return{wrapSmartAccountClientWithUIs:i=>({...i,sendTransaction:async(s,o)=>{if(r({showWalletUIs:o?.uiOptions?.showWalletUIs}))return e.current=!0,await i.sendTransaction(s).finally((()=>e.current=!1));let l=[];"calls"in s&&void 0!==s.calls?l=[...s.calls]:"to"in s&&(l=[{to:s.to,value:s.value||BigInt(0),data:s.data||"0x"}]);let y=async()=>{if(!i.paymaster)return!1;let{paymasterData:e,paymasterAndData:t}=await i.prepareUserOperation({calls:l,maxFeePerGas:s.maxFeePerGas,maxPriorityFeePerGas:s.maxPriorityFeePerGas,nonce:s.nonce?BigInt(s.nonce):void 0});return Number(t??e??0)>0};return new Promise((async(r,g)=>{e.current=!0;let{entropyId:f,entropyIdVerifier:h}=m(a);n({connectWallet:{recoveryMethod:c.recoveryMethod,connectingWalletAddress:c.address,isUnifiedWallet:d,entropyId:f,entropyIdVerifier:h,onCompleteNavigateTo:p,onFailure:()=>{}},sendTransaction:{transactionRequests:q({calls:l,chain:i.chain,maxPriorityFeePerGas:s.maxPriorityFeePerGas,maxFeePerGas:s.maxFeePerGas,nonce:s.nonce?BigInt(s.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:i.account.address,entropyId:f,entropyIdVerifier:h,getIsSponsored:y,signOnly:!1,onConfirm:()=>i.sendTransaction(s),onSuccess:e=>r(e.hash),onFailure:g,uiOptions:o?.uiOptions??{}}}),t(u)})).finally((()=>{e.current=!1}))},signMessage:async(s,o)=>r({showWalletUIs:o?.uiOptions?.showWalletUIs})?(e.current=!0,await i.signMessage(s).finally((()=>e.current=!1))):new Promise((async(r,l)=>{let{entropyId:p,entropyIdVerifier:y}=m(a);e.current=!0,n({connectWallet:{recoveryMethod:c.recoveryMethod,connectingWalletAddress:c.address,isUnifiedWallet:d,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof s.message?s.message:s.message.raw.toString(),confirmAndSign:()=>i.signMessage(s),onSuccess:e=>r(e),onFailure:l,uiOptions:o?.uiOptions??{}}}),t(u)})).finally((()=>{e.current=!1})),signTypedData:async(s,o)=>r({showWalletUIs:o?.uiOptions?.showWalletUIs})?(e.current=!0,await i.signTypedData(s).finally((()=>e.current=!1))):new Promise((async(r,l)=>{e.current=!0;let{entropyId:p,entropyIdVerifier:y}=m(a);n({connectWallet:{recoveryMethod:c.recoveryMethod,connectingWalletAddress:c.address,isUnifiedWallet:d,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:s,confirmAndSign:()=>i.signTypedData(s),onSuccess:e=>r(e),onFailure:l,uiOptions:o?.uiOptions??{}}}),t(u)})).finally((()=>{e.current=!1}))})}};export{$ as a,q as c,B as g,k as u};
1
+ import{useRef as e,useState as t,useCallback as r}from"react";import{http as n,createPublicClient as a}from"viem";import{ac as i,ab as s,b5 as o,q as l,bM as c,$ as d,H as m,bw as u,bE as p}from"./EmbeddedWalletConnectingScreen-D50stmJi.mjs";import{k as y}from"./events-context-ClaboIDc.mjs";import{aa as g,P as f}from"./internal-context-eGSwROSk.mjs";import{S as h}from"./SignRequestScreen-D9o7VhNz.mjs";import{a as w}from"./getEmbeddedConnectedWallet-CM6cDQCS.mjs";import{createSmartAccountClient as P}from"permissionless";import{toThirdwebSmartAccount as I,toLightSmartAccount as W,toBiconomySmartAccount as v,toKernelSmartAccount as F,toSafeSmartAccount as x}from"permissionless/accounts";import{createPimlicoClient as G}from"permissionless/clients/pimlico";import{entryPoint07Address as C,entryPoint06Address as T,toCoinbaseSmartAccount as b}from"viem/account-abstraction";import{THIRDWEB as S,COINBASE_SMART_WALLET as M,LIGHT_ACCOUNT as U,BICONOMY as O,KERNEL as V,SAFE as A}from"@privy-io/js-sdk-core";let D={address:T,version:"0.6"},N={address:C,version:"0.7"},_=({owner:e,smartWalletType:t,smartWalletVersion:r,publicClient:n})=>{switch(t){case A:return x({client:n,entryPoint:N,owners:[e],version:"1.4.1"});case V:return F({client:n,version:"0.3.1",entryPoint:N,useMetaFactory:"optional",owners:[e]});case O:return v({client:n,owners:[e],entryPoint:D});case U:return W({client:n,entryPoint:D,owner:e,version:"1.1.0"});case M:return async function({client:e,owner:t,version:r}){let[n]=await t.request({method:"eth_accounts"});if(!n)throw Error("Unable to request embedded owner for eth_accounts");return await b({client:e,owners:[{type:"local",source:"privy",address:n,sign:async({hash:e})=>await t.request({method:"secp256k1_sign",params:[e]})}],version:r})}({client:n,owner:e,version:r??"1"});case S:return I({client:n,entryPoint:N,owner:e});default:throw Error(`Invalid smart account type: ${t}.`)}};const $=({calls:e,chain:t,maxPriorityFeePerGas:r,maxFeePerGas:n,nonce:a})=>e.map((e=>({to:e.to||void 0,data:e.data,value:e.value,chainId:t.id,nonce:a,maxFeePerGas:n,maxPriorityFeePerGas:r}))),q=async({chain:e,paymasterContext:t,account:r,signer:i,user:s,smartWalletsConfig:o,rpcConfig:l,privyAppId:d})=>{if(!(o?.enabled&&s&&r&&i))return;let m=o?.configuredNetworks.find((t=>t.chainId===`eip155:${e.id}`));if(!m)throw new f(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let u=s.smartWallet?s.smartWallet.smartWalletType:o.smartWalletType,p=s.smartWallet?s.smartWallet.smartWalletVersion:o.smartWalletVersion,y=c(e,l,d),g=a({chain:e,transport:n(y)}),h=t??m.paymasterContext,w=await(async({owner:e,smartWalletType:t,smartWalletVersion:r,chain:a,publicClient:i,bundlerUrl:s,paymasterUrl:o,paymasterContext:l})=>{let c=await _({owner:e,smartWalletType:t,publicClient:i,smartWalletVersion:r}),d=G({transport:n(s),entryPoint:c.entryPoint}),m=o?G({transport:n(o),entryPoint:c.entryPoint}):void 0;return P({account:c,chain:a,paymaster:m,paymasterContext:l,bundlerTransport:n(s),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>s.includes(e))))return await d.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>s.includes(e))))return(await d.request({method:"zd_getUserOperationGasPrice",params:[]})).fast;if(["g.alchemy.com"].some((e=>s.includes(e)))){let[e,t]=await Promise.all([i.getBlock({blockTag:"latest"}),d.request({method:"rundler_maxPriorityFeePerGas",params:[]})]);if(!e.baseFeePerGas||!t)throw Error("Failed to get block or maxPriorityFeePerGasEstimate");return{maxFeePerGas:150n*e.baseFeePerGas/100n+BigInt(t.toString()),maxPriorityFeePerGas:BigInt(t.toString())}}{let e=await i.estimateFeesPerGas(),t=s.includes("api.developer.coinbase.com")?175n:150n;return{...e,maxFeePerGas:e.maxFeePerGas*t/100n,maxPriorityFeePerGas:e.maxPriorityFeePerGas*t/100n}}}}})})({owner:i,smartWalletType:u,smartWalletVersion:p,chain:e,publicClient:g,paymasterContext:h,...m});if(!w)throw new f(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return w},B=({clientConfig:n,smartWalletsConfig:a})=>{let{hideWalletUIs:c,openPrivyModal:P,appId:I,isHeadlessSigning:W}=g(),v=y(),{setModalData:F}=i(),{user:x}=s(),{chains:G}=y(),{chainId:C,clients:T,setChainId:b,chainIdState:S}=(()=>{let r=e(),[n,a]=t();return{clients:e({}),setChainId:e=>{r.current=e,a(e)},chainId:r,chainIdState:n}})(),M=G.find((e=>e.id===S)),{wallets:U}=d(),O=o(x),V=w(U,O?.address),A=!!O&&l(O),D=r((async()=>C.current),[C]),N=r((async({id:e})=>{if(!T.current[e]){let t=await q({chain:G.find((t=>t.id===e)),account:O,signer:await(V?.getEthereumProvider()),user:x,paymasterContext:n?.paymasterContext,smartWalletsConfig:a,rpcConfig:v.rpcConfig,privyAppId:I});t&&(T.current[e]=t)}b(e)}),[G,n,U,x,a]);return{wrapSmartAccountClient:e=>{T.current[e.chain.id]=e,S||b(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);if(delete e.account,W({showWalletUIs:t?.uiOptions?.showWalletUIs}))return c.current=!0,await r.sendTransaction(e).finally((()=>c.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 a=async()=>{let{paymasterAndData:t,paymasterData:a,maxFeePerGas:i,maxPriorityFeePerGas:s}=await r.prepareUserOperation({calls:n,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return 0===Number(i)&&0===Number(s)||Number(t??a??0)>0};return new Promise((async(i,s)=>{c.current=!0;let{entropyId:o,entropyIdVerifier:l}=m(x);F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:o,entropyIdVerifier:l,onCompleteNavigateTo:p,onFailure:()=>{}},sendTransaction:{transactionRequests:$({calls:n,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:o,entropyIdVerifier:l,getIsSponsored:a,signOnly:!1,onConfirm:()=>r.sendTransaction(e),onSuccess:e=>i(e.hash),onFailure:s,uiOptions:t?.uiOptions??{}}}),P(u)})).finally((()=>{c.current=!1}))},signMessage:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);return W({showWalletUIs:t?.uiOptions?.showWalletUIs})?(c.current=!0,await r.signMessage(e).finally((()=>c.current=!1))):new Promise((async(n,a)=>{let{entropyId:i,entropyIdVerifier:s}=m(x);c.current=!0,F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:i,entropyIdVerifier:s,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof e.message?e.message:e.message.raw.toString(),confirmAndSign:()=>r.signMessage(e),onSuccess:e=>n(e),onFailure:a,uiOptions:t?.uiOptions??{}}}),P(u)})).finally((()=>{c.current=!1}))},signTypedData:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);return delete e.account,W({showWalletUIs:t?.uiOptions?.showWalletUIs})?(c.current=!0,await r.signTypedData(e).finally((()=>c.current=!1))):new Promise((async(n,a)=>{c.current=!0;let{entropyId:i,entropyIdVerifier:s}=m(x);F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:i,entropyIdVerifier:s,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>n(e),onFailure:a,uiOptions:t?.uiOptions??{}}}),P(u)})).finally((()=>{c.current=!1}))},getChainId:D,chain:M,switchChain:N}}}},E=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:r}=g(),{setModalData:n}=i(),{user:a}=s(),c=o(a),d=!!c&&l(c);return{wrapSmartAccountClientWithUIs:i=>({...i,sendTransaction:async(s,o)=>{if(r({showWalletUIs:o?.uiOptions?.showWalletUIs}))return e.current=!0,await i.sendTransaction(s).finally((()=>e.current=!1));let l=[];"calls"in s&&void 0!==s.calls?l=[...s.calls]:"to"in s&&(l=[{to:s.to,value:s.value||BigInt(0),data:s.data||"0x"}]);let y=async()=>{if(!i.paymaster)return!1;let{paymasterData:e,paymasterAndData:t}=await i.prepareUserOperation({calls:l,maxFeePerGas:s.maxFeePerGas,maxPriorityFeePerGas:s.maxPriorityFeePerGas,nonce:s.nonce?BigInt(s.nonce):void 0});return Number(t??e??0)>0};return new Promise((async(r,g)=>{e.current=!0;let{entropyId:f,entropyIdVerifier:h}=m(a);n({connectWallet:{recoveryMethod:c.recoveryMethod,connectingWalletAddress:c.address,isUnifiedWallet:d,entropyId:f,entropyIdVerifier:h,onCompleteNavigateTo:p,onFailure:()=>{}},sendTransaction:{transactionRequests:$({calls:l,chain:i.chain,maxPriorityFeePerGas:s.maxPriorityFeePerGas,maxFeePerGas:s.maxFeePerGas,nonce:s.nonce?BigInt(s.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:i.account.address,entropyId:f,entropyIdVerifier:h,getIsSponsored:y,signOnly:!1,onConfirm:()=>i.sendTransaction(s),onSuccess:e=>r(e.hash),onFailure:g,uiOptions:o?.uiOptions??{}}}),t(u)})).finally((()=>{e.current=!1}))},signMessage:async(s,o)=>r({showWalletUIs:o?.uiOptions?.showWalletUIs})?(e.current=!0,await i.signMessage(s).finally((()=>e.current=!1))):new Promise((async(r,l)=>{let{entropyId:p,entropyIdVerifier:y}=m(a);e.current=!0,n({connectWallet:{recoveryMethod:c.recoveryMethod,connectingWalletAddress:c.address,isUnifiedWallet:d,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof s.message?s.message:s.message.raw.toString(),confirmAndSign:()=>i.signMessage(s),onSuccess:e=>r(e),onFailure:l,uiOptions:o?.uiOptions??{}}}),t(u)})).finally((()=>{e.current=!1})),signTypedData:async(s,o)=>r({showWalletUIs:o?.uiOptions?.showWalletUIs})?(e.current=!0,await i.signTypedData(s).finally((()=>e.current=!1))):new Promise((async(r,l)=>{e.current=!0;let{entropyId:p,entropyIdVerifier:y}=m(a);n({connectWallet:{recoveryMethod:c.recoveryMethod,connectingWalletAddress:c.address,isUnifiedWallet:d,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:s,confirmAndSign:()=>i.signTypedData(s),onSuccess:e=>r(e),onFailure:l,uiOptions:o?.uiOptions??{}}}),t(u)})).finally((()=>{e.current=!1}))})}};export{B as a,$ as c,q as g,E as u};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useContext as o,createContext as t,useState as r,useEffect as i}from"react";import{_ as n,aa as c,b5 as a}from"./EmbeddedWalletConnectingScreen-DNdaS6u7.mjs";import{k as l}from"./events-context-DpXp5E_5.mjs";import{aa as s,P as m,ad as p}from"./internal-context-eGSwROSk.mjs";import{a as h}from"./getEmbeddedConnectedWallet-CM6cDQCS.mjs";import{u,g as d,a as g}from"./smart-wallets-X-vN2hVx.mjs";import"lucide-react";import"viem";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"styled-components";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/PhoneIcon";import"react-device-detect";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@privy-io/js-sdk-core";import"zustand";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"viem/utils";import"eventemitter3";import"@scure/base";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@privy-io/ethereum";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"@heroicons/react/24/solid/CheckCircleIcon";import"ofetch";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"jose";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@privy-io/urls";import"tinycolor2";import"./SignRequestScreen-B2NV0Hvv.mjs";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";let C=/*#__PURE__*/t({client:void 0,getClientForChain:p});const f=({config:o,children:t})=>/*#__PURE__*/e(y,{children:/*#__PURE__*/e(W,{config:o,children:/*#__PURE__*/e(b,{children:t})})}),I=()=>{let{client:e,getClientForChain:t}=o(C);return{client:e,getClientForChain:t}};let w=/*#__PURE__*/t({config:void 0}),v=()=>{let{config:e}=o(w);return{config:e}},y=({children:o})=>{let[t,n]=r(void 0),{client:c}=s();return i((()=>{!t&&c&&(async()=>{try{if(!c)return void console.warn("No client found");let e=await c.getSmartWalletsConfig();n(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!c]),/*#__PURE__*/e(w.Provider,{value:{config:t},children:o})},W=({config:o,children:t})=>{let{config:p}=v(),{appId:g}=s(),{chains:C,defaultChain:f,rpcConfig:I}=l(),{wallets:w}=n(),{user:y}=c(),[W,b]=r(),{wrapSmartAccountClientWithUIs:S}=u(),P=a(y),F=h(w,P?.address);i((()=>{(async()=>{if(!p?.enabled)return;let e=p.configuredNetworks.find((e=>e.chainId===`eip155:${f.id}`))?f:C.find((e=>p.configuredNetworks.map((e=>e.chainId)).includes(`eip155:${e.id}`)));if(!e)throw new m("Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.");b(await d({chain:e,privyAppId:g,paymasterContext:o?.paymasterContext,rpcConfig:I,account:P,signer:await(F?.getEthereumProvider()),user:y,smartWalletsConfig:p}))})()}),[!!p?.enabled,!!y?.smartWallet,!!F,!!P]);/*#__PURE__*/return e(k.Provider,{value:{client:W,config:o,getClientForChain:async({id:e})=>{let t=await d({chain:C.find((o=>o.id===e)),privyAppId:g,paymasterContext:o?.paymasterContext,rpcConfig:I,account:P,signer:await(F?.getEthereumProvider()),user:y,smartWalletsConfig:p});if(!t)throw new m(`Failed to create smart wallet client for chain id: ${e}`);return S(t)}},children:t})},k=/*#__PURE__*/t({client:void 0,config:void 0,getClientForChain:p}),b=({children:t})=>{let{client:r,config:n,getClientForChain:a}=(()=>{let{client:e,config:t,getClientForChain:r}=o(k);return{client:e,config:t,getClientForChain:r}})(),{config:l}=v(),{wrapSmartAccountClient:m}=g({clientConfig:n,smartWalletsConfig:l}),{user:p}=c(),{generateSiweMessageForSmartWallet:h,linkSmartWallet:u,hideWalletUIs:d}=s();return i((()=>{(async()=>{if(r&&p&&!p?.smartWallet&&l?.enabled)try{let e=await h({address:r.account.address,chainId:`eip155:${r.chain.id}`});d.current=!0;let o=await r.signMessage({message:e});await u({signature:o,message:e,smartWalletType:l.smartWalletType,smartWalletVersion:l.smartWalletVersion})}catch(e){console.error("Error creating smart wallet:",e)}finally{d.current=!1}})()}),[!!r,!!p?.smartWallet,!!l?.enabled]),/*#__PURE__*/e(C.Provider,{value:{client:p?.smartWallet&&r?m(r):void 0,getClientForChain:a},children:t})};export{f as SmartWalletsProvider,I as useSmartWallets};
1
+ import{jsx as e}from"react/jsx-runtime";import{useContext as o,createContext as t,useState as r,useEffect as i}from"react";import{$ as n,ab as c,b5 as a}from"./EmbeddedWalletConnectingScreen-D50stmJi.mjs";import{k as l}from"./events-context-ClaboIDc.mjs";import{aa as s,P as m,ad as p}from"./internal-context-eGSwROSk.mjs";import{a as h}from"./getEmbeddedConnectedWallet-CM6cDQCS.mjs";import{u,g as d,a as g}from"./smart-wallets-BXT3GZwg.mjs";import"lucide-react";import"viem";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"styled-components";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/PhoneIcon";import"react-device-detect";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@privy-io/js-sdk-core";import"zustand";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"viem/utils";import"eventemitter3";import"@scure/base";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@privy-io/ethereum";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"@privy-io/popup";import"@heroicons/react/24/solid/CheckCircleIcon";import"ofetch";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"jose";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@privy-io/urls";import"tinycolor2";import"./SignRequestScreen-D9o7VhNz.mjs";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";let C=/*#__PURE__*/t({client:void 0,getClientForChain:p});const f=({config:o,children:t})=>/*#__PURE__*/e(y,{children:/*#__PURE__*/e(W,{config:o,children:/*#__PURE__*/e(b,{children:t})})}),I=()=>{let{client:e,getClientForChain:t}=o(C);return{client:e,getClientForChain:t}};let w=/*#__PURE__*/t({config:void 0}),v=()=>{let{config:e}=o(w);return{config:e}},y=({children:o})=>{let[t,n]=r(void 0),{client:c}=s();return i((()=>{!t&&c&&(async()=>{try{if(!c)return void console.warn("No client found");let e=await c.getSmartWalletsConfig();n(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!c]),/*#__PURE__*/e(w.Provider,{value:{config:t},children:o})},W=({config:o,children:t})=>{let{config:p}=v(),{appId:g}=s(),{chains:C,defaultChain:f,rpcConfig:I}=l(),{wallets:w}=n(),{user:y}=c(),[W,b]=r(),{wrapSmartAccountClientWithUIs:S}=u(),P=a(y),F=h(w,P?.address);i((()=>{(async()=>{if(!p?.enabled)return;let e=p.configuredNetworks.find((e=>e.chainId===`eip155:${f.id}`))?f:C.find((e=>p.configuredNetworks.map((e=>e.chainId)).includes(`eip155:${e.id}`)));if(!e)throw new m("Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.");b(await d({chain:e,privyAppId:g,paymasterContext:o?.paymasterContext,rpcConfig:I,account:P,signer:await(F?.getEthereumProvider()),user:y,smartWalletsConfig:p}))})()}),[!!p?.enabled,!!y?.smartWallet,!!F,!!P]);/*#__PURE__*/return e(k.Provider,{value:{client:W,config:o,getClientForChain:async({id:e})=>{let t=await d({chain:C.find((o=>o.id===e)),privyAppId:g,paymasterContext:o?.paymasterContext,rpcConfig:I,account:P,signer:await(F?.getEthereumProvider()),user:y,smartWalletsConfig:p});if(!t)throw new m(`Failed to create smart wallet client for chain id: ${e}`);return S(t)}},children:t})},k=/*#__PURE__*/t({client:void 0,config:void 0,getClientForChain:p}),b=({children:t})=>{let{client:r,config:n,getClientForChain:a}=(()=>{let{client:e,config:t,getClientForChain:r}=o(k);return{client:e,config:t,getClientForChain:r}})(),{config:l}=v(),{wrapSmartAccountClient:m}=g({clientConfig:n,smartWalletsConfig:l}),{user:p}=c(),{generateSiweMessageForSmartWallet:h,linkSmartWallet:u,hideWalletUIs:d}=s();return i((()=>{(async()=>{if(r&&p&&!p?.smartWallet&&l?.enabled)try{let e=await h({address:r.account.address,chainId:`eip155:${r.chain.id}`});d.current=!0;let o=await r.signMessage({message:e});await u({signature:o,message:e,smartWalletType:l.smartWalletType,smartWalletVersion:l.smartWalletVersion})}catch(e){console.error("Error creating smart wallet:",e)}finally{d.current=!1}})()}),[!!r,!!p?.smartWallet,!!l?.enabled]),/*#__PURE__*/e(C.Provider,{value:{client:p?.smartWallet&&r?m(r):void 0,getClientForChain:a},children:t})};export{f as SmartWalletsProvider,I as useSmartWallets};
@@ -1 +1 @@
1
- import{useCallback as e}from"react";import{d as t,a as i}from"./usePrivy-DLA1ZqHR.mjs";import{n,k as r}from"./events-context-DpXp5E_5.mjs";import{aa as s}from"./internal-context-eGSwROSk.mjs";import{ce as o,cf as l,aa as h,bk as p,cg as m,bK as f,bs as v}from"./EmbeddedWalletConnectingScreen-DNdaS6u7.mjs";import{pipe as g,createTransactionMessage as y,setTransactionMessageFeePayerSigner as w,setTransactionMessageLifetimeUsingBlockhash as b,appendTransactionMessageInstructions as P,compileTransaction as _,getTransactionEncoder as j,address as C,setTransactionMessageFeePayer as O,blockhash as S,getTransactionDecoder as I}from"@solana/kit";import{S as T,f as A,g as k,s as E,b as W}from"./use-export-wallet-CPIcGGw7.mjs";export{a as useExportWallet,u as useFundWallet,d as useStandardWallets,c as useWallets}from"./use-export-wallet-CPIcGGw7.mjs";import{base58 as M,base64 as U}from"@scure/base";import{getAddMemoInstruction as x}from"@solana-program/memo";import{getWallets as q}from"@wallet-standard/app";import{UniversalProvider as R}from"@walletconnect/universal-provider";import"@privy-io/js-sdk-core";import"react/jsx-runtime";import"tinycolor2";import"ofetch";import"lucide-react";import"viem";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"styled-components";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/PhoneIcon";import"react-device-detect";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"zustand";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"viem/utils";import"eventemitter3";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@privy-io/ethereum";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"jose";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@privy-io/urls";import"./use-sign-with-user-signer-DaTvrd5T.mjs";import"./SignRequestScreen-B2NV0Hvv.mjs";import"@solana-program/system";import"@solana-program/token";const K=e=>{let t,{get:i,on:n}=q(),r=e?.shouldAutoConnect??!0,s=new o(new Ee,r),a=new Map,c=[];function l(...e){e.forEach((e=>{!(e.features["privy:"]&&"isPrivyWallet"in e&&e.isPrivyWallet||a.has(e.name))&&e.chains.some((e=>"string"==typeof e&&e.startsWith("solana:")))&&a.set(e.name,e)})),c=Array.from(a.values()).map((e=>new o(e,r))).concat(s),t?.(c)}function h(...e){Array.from(a.values()).forEach((t=>!e.includes(t)&&a.delete(t.name))),c=Array.from(a.values()).map((e=>new o(e,r))).concat(s),t?.(c)}let d=[n("register",l),n("unregister",h)];return l(...i()),{_setOnConnectorsUpdated:e=>{t=e},onMount:()=>{d[0]||(d[0]=n("register",l)),d[1]||(d[1]=n("unregister",h))},onUnmount:()=>{let e=d.pop();for(;e;)e(),e=d.pop()},get:()=>c}};function D(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var F=0;function V(e){return"__private_"+F+++"_"+e}var L=/*#__PURE__*/V("_address"),z=/*#__PURE__*/V("_publicKey"),B=/*#__PURE__*/V("_chains"),J=/*#__PURE__*/V("_features"),N=/*#__PURE__*/V("_label"),Y=/*#__PURE__*/V("_icon");class Q{get address(){return D(this,L)[L]}get publicKey(){return D(this,z)[z].slice()}get chains(){return D(this,B)[B].slice()}get features(){return D(this,J)[J].slice()}get label(){return D(this,N)[N]}get icon(){return D(this,Y)[Y]}constructor({address:e,publicKey:t,label:i,icon:n}){Object.defineProperty(this,L,{writable:!0,value:void 0}),Object.defineProperty(this,z,{writable:!0,value:void 0}),Object.defineProperty(this,B,{writable:!0,value:void 0}),Object.defineProperty(this,J,{writable:!0,value:void 0}),Object.defineProperty(this,N,{writable:!0,value:void 0}),Object.defineProperty(this,Y,{writable:!0,value:void 0}),D(this,L)[L]=e,D(this,z)[z]=t,D(this,B)[B]=T,D(this,J)[J]=["solana:signAndSendTransaction","solana:signTransaction","solana:signMessage"],D(this,N)[N]=i,D(this,Y)[Y]=n}}function G(e){if("string"==typeof e)return M.decode(e);if(e instanceof Uint8Array)return e;let t=e.signature;return"string"==typeof t?M.decode(t):t}function X(e){if("string"==typeof e){try{return M.decode(e)}catch{}return U.decode(e)}if(e instanceof Uint8Array)return e;let t=e.transaction;if("string"==typeof t){try{return M.decode(t)}catch{}return U.decode(t)}return t}function Z(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var $=0;function H(e){return"__private_"+$+++"_"+e}let ee="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",te="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";var ie=/*#__PURE__*/H("_listeners"),ne=/*#__PURE__*/H("_version"),re=/*#__PURE__*/H("_name"),se=/*#__PURE__*/H("_icon"),oe=/*#__PURE__*/H("_provider"),ae=/*#__PURE__*/H("_accounts"),ce=/*#__PURE__*/H("_privyAppName"),le=/*#__PURE__*/H("_walletConnectCloudProjectId"),he=/*#__PURE__*/H("_walletEntry"),de=/*#__PURE__*/H("_onDisplayUriCallback"),ue=/*#__PURE__*/H("_providerEventListeners"),pe=/*#__PURE__*/H("_on"),me=/*#__PURE__*/H("_emit"),fe=/*#__PURE__*/H("_off"),ve=/*#__PURE__*/H("_connected"),ge=/*#__PURE__*/H("_disconnected"),ye=/*#__PURE__*/H("_connect"),we=/*#__PURE__*/H("_disconnect"),be=/*#__PURE__*/H("_signMessage"),Pe=/*#__PURE__*/H("_signAndSendTransaction"),_e=/*#__PURE__*/H("_signTransaction"),je=/*#__PURE__*/H("_getOrCreateProvider"),Ce=/*#__PURE__*/H("_getOrCreateSession"),Oe=/*#__PURE__*/H("_restoreSession"),Se=/*#__PURE__*/H("_addProviderEventListener"),Ie=/*#__PURE__*/H("_destroySession"),Te=/*#__PURE__*/H("_makeRpcRequest"),Ae=/*#__PURE__*/H("_onDisplayUri"),ke=/*#__PURE__*/H("_onSessionDelete");class Ee{get version(){return Z(this,ne)[ne]}get name(){return Z(this,re)[re]}get icon(){return Z(this,se)[se]}get chains(){return T.slice()}get features(){return{"standard:connect":{version:"1.0.0",connect:Z(this,ye)[ye]},"standard:disconnect":{version:"1.0.0",disconnect:Z(this,we)[we]},"standard:events":{version:"1.0.0",on:Z(this,pe)[pe]},"solana:signAndSendTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:Z(this,Pe)[Pe]},"solana:signTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:Z(this,_e)[_e]},"solana:signMessage":{version:"1.0.0",signMessage:Z(this,be)[be]}}}get accounts(){return Z(this,ae)[ae].slice()}get isWalletConnectSolana(){return!0}async initialize({walletConnectCloudProjectId:e,privyAppName:t}){Z(this,le)[le]=e,Z(this,ce)[ce]=t,await Z(this,je)[je](),await Z(this,Oe)[Oe]()}setWalletEntry(e,t){Z(this,he)[he]=e,Z(this,de)[de]=t}constructor(){Object.defineProperty(this,me,{value:We}),Object.defineProperty(this,fe,{value:Me}),Object.defineProperty(this,ie,{writable:!0,value:void 0}),Object.defineProperty(this,ne,{writable:!0,value:void 0}),Object.defineProperty(this,re,{writable:!0,value:void 0}),Object.defineProperty(this,se,{writable:!0,value:void 0}),Object.defineProperty(this,oe,{writable:!0,value:void 0}),Object.defineProperty(this,ae,{writable:!0,value:void 0}),Object.defineProperty(this,ce,{writable:!0,value:void 0}),Object.defineProperty(this,le,{writable:!0,value:void 0}),Object.defineProperty(this,he,{writable:!0,value:void 0}),Object.defineProperty(this,de,{writable:!0,value:void 0}),Object.defineProperty(this,ue,{writable:!0,value:void 0}),Object.defineProperty(this,pe,{writable:!0,value:void 0}),Object.defineProperty(this,ve,{writable:!0,value:void 0}),Object.defineProperty(this,ge,{writable:!0,value:void 0}),Object.defineProperty(this,ye,{writable:!0,value:void 0}),Object.defineProperty(this,we,{writable:!0,value:void 0}),Object.defineProperty(this,be,{writable:!0,value:void 0}),Object.defineProperty(this,Pe,{writable:!0,value:void 0}),Object.defineProperty(this,_e,{writable:!0,value:void 0}),Object.defineProperty(this,je,{writable:!0,value:void 0}),Object.defineProperty(this,Ce,{writable:!0,value:void 0}),Object.defineProperty(this,Oe,{writable:!0,value:void 0}),Object.defineProperty(this,Se,{writable:!0,value:void 0}),Object.defineProperty(this,Ie,{writable:!0,value:void 0}),Object.defineProperty(this,Te,{writable:!0,value:void 0}),Object.defineProperty(this,Ae,{writable:!0,value:void 0}),Object.defineProperty(this,ke,{writable:!0,value:void 0}),Z(this,ie)[ie]={},Z(this,ne)[ne]="1.0.0",Z(this,re)[re]="WalletConnect",Z(this,se)[se]=l,Z(this,oe)[oe]=null,Z(this,ae)[ae]=[],Z(this,ce)[ce]="",Z(this,le)[le]="",Z(this,ue)[ue]=new Map,Z(this,pe)[pe]=(e,t)=>(Z(this,ie)[ie][e]?.push(t)||(Z(this,ie)[ie][e]=[t]),()=>Z(this,fe)[fe](e,t)),Z(this,ve)[ve]=e=>{Z(this,re)[re]=Z(this,oe)[oe]?.session?.peer?.metadata?.name||Z(this,he)[he]?.name||"WalletConnect",Z(this,se)[se]=Z(this,oe)[oe]?.session?.peer?.metadata?.icons?.[0]||Z(this,he)[he]?.image_url?.sm||Z(this,se)[se],Z(this,ae)[ae]=e.map((e=>new Q({address:e,publicKey:M.decode(e),label:Z(this,re)[re],icon:Z(this,se)[se]}))),Z(this,me)[me]("change",{accounts:this.accounts})},Z(this,ge)[ge]=()=>{Z(this,ae)[ae]=[],Z(this,me)[me]("change",{accounts:this.accounts})},Z(this,ye)[ye]=async()=>(this.accounts.length||await Z(this,Ce)[Ce](),{accounts:this.accounts}),Z(this,we)[we]=async()=>{await Z(this,Ie)[Ie](),Z(this,me)[me]("change",{accounts:this.accounts})},Z(this,be)[be]=async(...e)=>{let t=[];for(let{account:i,message:n}of e){let e=M.encode(n);try{let r=await Z(this,Te)[Te]("solana_signMessage",{message:e,pubkey:i.address},xe("solana:mainnet"));t.push({signedMessage:n,signature:G(r)})}catch(r){if(r?.message?.includes("Missing or invalid")){let r=await Z(this,Te)[Te]("solana:signMessage",{message:e,pubkey:i.address},xe("solana:mainnet"));t.push({signedMessage:n,signature:G(r)})}throw r}}return t},Z(this,Pe)[Pe]=async(...e)=>{let t=[];for(let{account:i,chain:n,transaction:r,options:s}of e){let e=U.encode(r);try{let r=await Z(this,Te)[Te]("solana_signAndSendTransaction",{transaction:e,pubkey:i.address,sendOptions:s},xe(n));t.push({signature:G(r)})}catch(r){if(r?.message?.includes("Missing or invalid")){let r=await Z(this,Te)[Te]("solana:signAndSendTransaction",{transaction:e,pubkey:i.address,sendOptions:s},xe(n));t.push({signature:G(r)})}}}return t},Z(this,_e)[_e]=async(...e)=>{let t=[];for(let{account:i,chain:n,transaction:r}of e){let e=U.encode(r);try{let r=await Z(this,Te)[Te]("solana_signTransaction",{transaction:e,pubkey:i.address},xe(n||"solana:mainnet"));t.push({signedTransaction:X(r)})}catch(r){if(r?.message?.includes("Missing or invalid")){let r=await Z(this,Te)[Te]("solana:signTransaction",{transaction:e,pubkey:i.address},xe(n||"solana:mainnet"));t.push({signedTransaction:X(r)})}}}return t},Z(this,je)[je]=async()=>{if(Z(this,oe)[oe])return Z(this,oe)[oe];if(!Z(this,le)[le])throw Error("WalletConnect Cloud Project ID is required");return Z(this,oe)[oe]=await R.init({projectId:Z(this,le)[le],metadata:{name:Z(this,ce)[ce],description:Z(this,ce)[ce],url:window.location.origin,icons:[]},relayUrl:"wss://relay.walletconnect.com",telemetryEnabled:!1}),Z(this,Se)[Se]("display_uri",Z(this,Ae)[Ae]),Z(this,Se)[Se]("session_delete",Z(this,ke)[ke]),Z(this,Se)[Se]("session_ping",(()=>{})),Z(this,Se)[Se]("session_event",(()=>{})),Z(this,Se)[Se]("session_update",(()=>{})),Z(this,oe)[oe]},Z(this,Ce)[Ce]=async()=>{if(!Z(this,oe)[oe])throw Error("WalletConnectSolana: Failed to get or create session. Provider not initialized");if(Z(this,oe)[oe].session)return Z(this,oe)[oe].session;let e=await Z(this,oe)[oe].connect({optionalNamespaces:{solana:{chains:[ee,te],methods:["solana_signMessage","solana_signTransaction","solana_signAndSendTransaction"],events:[]}}});if(!e)throw Error("WalletConnectSolana: Failed to create new session");return Z(this,ve)[ve](Ue(e)),e},Z(this,Oe)[Oe]=async()=>{let e=Z(this,oe)[oe]?.session;if(e){if(!e.namespaces?.solana)return await(Z(this,oe)[oe]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),void(Z(this,oe)[oe].session=void 0);Z(this,ve)[ve](Ue(e))}},Z(this,Se)[Se]=(e,t)=>{let i=Z(this,ue)[ue].get(e);i&&(Z(this,oe)[oe]?.off(e,i),Z(this,ue)[ue].delete(e)),Z(this,oe)[oe]?.on(e,t),Z(this,ue)[ue].set(e,t)},Z(this,Ie)[Ie]=async()=>{try{if(Z(this,oe)[oe]?.session&&await(Z(this,oe)[oe]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),Z(this,oe)[oe]?.client){let e=Z(this,oe)[oe].client.proposal.getAll();await Promise.allSettled(e.map((e=>Z(this,oe)[oe]?.client.proposal.delete(e.id,{code:6e3,message:"User disconnected"}))));let t=Z(this,oe)[oe].client.pairing.getAll();await Promise.allSettled(t.map((e=>Z(this,oe)[oe]?.client.pairing.delete(e.topic,{code:6e3,message:"User disconnected"}))))}Z(this,ge)[ge]()}catch(e){console.error("WalletConnectSolana: Error destroying session",e)}},Z(this,Te)[Te]=async(e,t,i)=>{try{return await Z(this,oe)[oe].request({method:e,params:t},i)}catch(t){if(console.error(`WalletConnectSolana: RPC Error - ${e}:`,t),t?.message?.includes("without any listeners")&&t.result)return t.result;if(t?.message?.includes("session topic does not exist in keychain"))throw Error("WalletConnectSolana: Wallet connection lost. Please reconnect.");throw t}},Z(this,Ae)[Ae]=e=>{null==Z(this,de)[de]||Z(this,de)[de].call(this,{native:e,universal:void 0})},Z(this,ke)[ke]=()=>{Z(this,ge)[ge]()}}}function We(e,...t){Z(this,ie)[ie][e]?.forEach((e=>e.apply(null,t)))}function Me(e,t){Z(this,ie)[ie][e]=Z(this,ie)[ie][e]?.filter((e=>t!==e))}function Ue(e){return e.namespaces.solana.accounts.reduce(((e,t)=>{let i=t.split(":").at(-1);return e.includes(i)||e.push(i),e}),[])}function xe(e){switch(e){case"solana:mainnet":return ee;case"solana:devnet":return te;default:return e}}const qe=()=>{let{user:i}=h(),{client:o,refreshSessionAndUser:a,initializeWalletProxy:c}=s(),l=n(),d=r();return{importWallet:e((({privateKey:e,additionalSigners:n})=>t({getAccessToken:()=>o.getAccessToken(),user:i,initializeWalletProxy:c,refreshSessionAndUser:a,emitPrivyEvent:l,appConfig:d},{privateKey:e,chainType:"solana",additionalSigners:n})),[i,o,a,c,l,d])}};var Re={id:p,getSolanaRpcClient:W,createTransactionFromRelayQuote:async function({solanaClient:e,quote:t,source:i}){let n=t.steps[0]?.items?.[0];if(!n)throw Error("Invalid quote");let r=n.data.instructions.map((({keys:e,programId:t,data:i})=>({accounts:e.map((({pubkey:e,isSigner:t,isWritable:i})=>({address:e,role:t&&i?3:t&&!i?2:!t&&i?1:0}))),programAddress:t,data:new Uint8Array(Buffer.from(i,"hex"))}))),{value:s}=await e.rpc.getLatestBlockhash().send(),o=g(y({version:0}),(e=>w({address:i},e)),(e=>b(s,e)),(e=>P(r,e)),(e=>_(e)));return new Uint8Array(j().encode(o))},simulateTransaction:E,getAddressFromBuffer:k,fetchTransactionEstimatedFees:A},Ke=()=>m(Re);var De={id:v,createSiwsMemoTransaction:({address:e,nonce:t})=>{let i=x({memo:f({address:C(e),nonce:t})});return g(y({version:"legacy"}),(t=>O(C(e),t)),(e=>b({blockhash:S("GfVcyD5fWFJ6hRm8bsy7CoVPsLSoJhtJKRJYk8T2VVFN"),lastValidBlockHeight:0n},e)),(e=>P([i],e)),(e=>_(e)),(e=>U.encode(Uint8Array.from(j().encode(e)))))},getSignatureFromTransaction:(e,t)=>{let i=I().decode(e).signatures[t];if(!i)throw Error(`Missing transaction signature for address: ${t}`);return U.encode(i)}},Fe=()=>m(De);function Ve(){let{create:e}=i();return{createWallet:async t=>{t&&"target"in t&&t&&(t=void 0);let{account:i}=await e({chainType:"solana",options:t});return{wallet:i}}}}function Le(){return{signMessage:async function(...e){let t=[];for(let i of e)t.push(await i.wallet.signMessage({...i,options:i.options}));return 1===e.length?t[0]:[...t]}}}function ze(){return{signTransaction:async function(...e){let t=[];for(let i of e)t.push(await i.wallet.signTransaction({...i,chain:i.chain||"solana:mainnet"}));return 1===e.length?t[0]:[...t]}}}function Be(){return{signAndSendTransaction:async function(...e){let t=[];for(let i of e)t.push(await i.wallet.signAndSendTransaction({...i,chain:i.chain||"solana:mainnet"}));return 1===e.length?t[0]:[...t]}}}export{o as SolanaAdapterConnector,K as toSolanaWalletConnectors,Ve as useCreateWallet,qe as useImportWallet,Be as useSignAndSendTransaction,Le as useSignMessage,ze as useSignTransaction,Ke as useSolanaFundingPlugin,Fe as useSolanaLedgerPlugin};
1
+ import{useCallback as e}from"react";import{d as t,a as i}from"./usePrivy-BCcRF869.mjs";import{n,k as r}from"./events-context-ClaboIDc.mjs";import{aa as s}from"./internal-context-eGSwROSk.mjs";import{cg as o,ch as l,ab as h,bl as p,ci as m,bL as f,bt as v}from"./EmbeddedWalletConnectingScreen-D50stmJi.mjs";import{pipe as g,createTransactionMessage as y,setTransactionMessageFeePayerSigner as w,setTransactionMessageLifetimeUsingBlockhash as b,appendTransactionMessageInstructions as P,compileTransaction as _,getTransactionEncoder as j,address as C,setTransactionMessageFeePayer as O,blockhash as S,getTransactionDecoder as I}from"@solana/kit";import{S as T,f as A,g as k,s as E,b as W}from"./use-export-wallet-DTiEdSYz.mjs";export{a as useExportWallet,u as useFundWallet,d as useStandardWallets,c as useWallets}from"./use-export-wallet-DTiEdSYz.mjs";import{base58 as M,base64 as U}from"@scure/base";import{getAddMemoInstruction as x}from"@solana-program/memo";import{getWallets as q}from"@wallet-standard/app";import{UniversalProvider as R}from"@walletconnect/universal-provider";import"@privy-io/js-sdk-core";import"react/jsx-runtime";import"tinycolor2";import"ofetch";import"lucide-react";import"viem";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"styled-components";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/PhoneIcon";import"react-device-detect";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"zustand";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"viem/utils";import"eventemitter3";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@privy-io/ethereum";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"@privy-io/popup";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"jose";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@privy-io/urls";import"./use-sign-with-user-signer-DaTvrd5T.mjs";import"./SignRequestScreen-D9o7VhNz.mjs";import"@solana-program/system";import"@solana-program/token";const D=e=>{let t,{get:i,on:n}=q(),r=e?.shouldAutoConnect??!0,s=new o(new Ee,r),a=new Map,c=[];function l(...e){e.forEach((e=>{!(e.features["privy:"]&&"isPrivyWallet"in e&&e.isPrivyWallet||a.has(e.name))&&e.chains.some((e=>"string"==typeof e&&e.startsWith("solana:")))&&a.set(e.name,e)})),c=Array.from(a.values()).map((e=>new o(e,r))).concat(s),t?.(c)}function h(...e){Array.from(a.values()).forEach((t=>!e.includes(t)&&a.delete(t.name))),c=Array.from(a.values()).map((e=>new o(e,r))).concat(s),t?.(c)}let d=[n("register",l),n("unregister",h)];return l(...i()),{_setOnConnectorsUpdated:e=>{t=e},onMount:()=>{d[0]||(d[0]=n("register",l)),d[1]||(d[1]=n("unregister",h))},onUnmount:()=>{let e=d.pop();for(;e;)e(),e=d.pop()},get:()=>c}};function F(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var K=0;function L(e){return"__private_"+K+++"_"+e}var V=/*#__PURE__*/L("_address"),z=/*#__PURE__*/L("_publicKey"),B=/*#__PURE__*/L("_chains"),J=/*#__PURE__*/L("_features"),N=/*#__PURE__*/L("_label"),Y=/*#__PURE__*/L("_icon");class Q{get address(){return F(this,V)[V]}get publicKey(){return F(this,z)[z].slice()}get chains(){return F(this,B)[B].slice()}get features(){return F(this,J)[J].slice()}get label(){return F(this,N)[N]}get icon(){return F(this,Y)[Y]}constructor({address:e,publicKey:t,label:i,icon:n}){Object.defineProperty(this,V,{writable:!0,value:void 0}),Object.defineProperty(this,z,{writable:!0,value:void 0}),Object.defineProperty(this,B,{writable:!0,value:void 0}),Object.defineProperty(this,J,{writable:!0,value:void 0}),Object.defineProperty(this,N,{writable:!0,value:void 0}),Object.defineProperty(this,Y,{writable:!0,value:void 0}),F(this,V)[V]=e,F(this,z)[z]=t,F(this,B)[B]=T,F(this,J)[J]=["solana:signAndSendTransaction","solana:signTransaction","solana:signMessage"],F(this,N)[N]=i,F(this,Y)[Y]=n}}function G(e){if("string"==typeof e)return M.decode(e);if(e instanceof Uint8Array)return e;let t=e.signature;return"string"==typeof t?M.decode(t):t}function X(e){if("string"==typeof e){try{return M.decode(e)}catch{}return U.decode(e)}if(e instanceof Uint8Array)return e;let t=e.transaction;if("string"==typeof t){try{return M.decode(t)}catch{}return U.decode(t)}return t}function Z(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var $=0;function H(e){return"__private_"+$+++"_"+e}let ee="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",te="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";var ie=/*#__PURE__*/H("_listeners"),ne=/*#__PURE__*/H("_version"),re=/*#__PURE__*/H("_name"),se=/*#__PURE__*/H("_icon"),oe=/*#__PURE__*/H("_provider"),ae=/*#__PURE__*/H("_accounts"),ce=/*#__PURE__*/H("_privyAppName"),le=/*#__PURE__*/H("_walletConnectCloudProjectId"),he=/*#__PURE__*/H("_walletEntry"),de=/*#__PURE__*/H("_onDisplayUriCallback"),ue=/*#__PURE__*/H("_providerEventListeners"),pe=/*#__PURE__*/H("_on"),me=/*#__PURE__*/H("_emit"),fe=/*#__PURE__*/H("_off"),ve=/*#__PURE__*/H("_connected"),ge=/*#__PURE__*/H("_disconnected"),ye=/*#__PURE__*/H("_connect"),we=/*#__PURE__*/H("_disconnect"),be=/*#__PURE__*/H("_signMessage"),Pe=/*#__PURE__*/H("_signAndSendTransaction"),_e=/*#__PURE__*/H("_signTransaction"),je=/*#__PURE__*/H("_getOrCreateProvider"),Ce=/*#__PURE__*/H("_getOrCreateSession"),Oe=/*#__PURE__*/H("_restoreSession"),Se=/*#__PURE__*/H("_addProviderEventListener"),Ie=/*#__PURE__*/H("_destroySession"),Te=/*#__PURE__*/H("_makeRpcRequest"),Ae=/*#__PURE__*/H("_onDisplayUri"),ke=/*#__PURE__*/H("_onSessionDelete");class Ee{get version(){return Z(this,ne)[ne]}get name(){return Z(this,re)[re]}get icon(){return Z(this,se)[se]}get chains(){return T.slice()}get features(){return{"standard:connect":{version:"1.0.0",connect:Z(this,ye)[ye]},"standard:disconnect":{version:"1.0.0",disconnect:Z(this,we)[we]},"standard:events":{version:"1.0.0",on:Z(this,pe)[pe]},"solana:signAndSendTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:Z(this,Pe)[Pe]},"solana:signTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:Z(this,_e)[_e]},"solana:signMessage":{version:"1.0.0",signMessage:Z(this,be)[be]}}}get accounts(){return Z(this,ae)[ae].slice()}get isWalletConnectSolana(){return!0}async initialize({walletConnectCloudProjectId:e,privyAppName:t}){Z(this,le)[le]=e,Z(this,ce)[ce]=t,await Z(this,je)[je](),await Z(this,Oe)[Oe]()}setWalletEntry(e,t){Z(this,he)[he]=e,Z(this,de)[de]=t}constructor(){Object.defineProperty(this,me,{value:We}),Object.defineProperty(this,fe,{value:Me}),Object.defineProperty(this,ie,{writable:!0,value:void 0}),Object.defineProperty(this,ne,{writable:!0,value:void 0}),Object.defineProperty(this,re,{writable:!0,value:void 0}),Object.defineProperty(this,se,{writable:!0,value:void 0}),Object.defineProperty(this,oe,{writable:!0,value:void 0}),Object.defineProperty(this,ae,{writable:!0,value:void 0}),Object.defineProperty(this,ce,{writable:!0,value:void 0}),Object.defineProperty(this,le,{writable:!0,value:void 0}),Object.defineProperty(this,he,{writable:!0,value:void 0}),Object.defineProperty(this,de,{writable:!0,value:void 0}),Object.defineProperty(this,ue,{writable:!0,value:void 0}),Object.defineProperty(this,pe,{writable:!0,value:void 0}),Object.defineProperty(this,ve,{writable:!0,value:void 0}),Object.defineProperty(this,ge,{writable:!0,value:void 0}),Object.defineProperty(this,ye,{writable:!0,value:void 0}),Object.defineProperty(this,we,{writable:!0,value:void 0}),Object.defineProperty(this,be,{writable:!0,value:void 0}),Object.defineProperty(this,Pe,{writable:!0,value:void 0}),Object.defineProperty(this,_e,{writable:!0,value:void 0}),Object.defineProperty(this,je,{writable:!0,value:void 0}),Object.defineProperty(this,Ce,{writable:!0,value:void 0}),Object.defineProperty(this,Oe,{writable:!0,value:void 0}),Object.defineProperty(this,Se,{writable:!0,value:void 0}),Object.defineProperty(this,Ie,{writable:!0,value:void 0}),Object.defineProperty(this,Te,{writable:!0,value:void 0}),Object.defineProperty(this,Ae,{writable:!0,value:void 0}),Object.defineProperty(this,ke,{writable:!0,value:void 0}),Z(this,ie)[ie]={},Z(this,ne)[ne]="1.0.0",Z(this,re)[re]="WalletConnect",Z(this,se)[se]=l,Z(this,oe)[oe]=null,Z(this,ae)[ae]=[],Z(this,ce)[ce]="",Z(this,le)[le]="",Z(this,ue)[ue]=new Map,Z(this,pe)[pe]=(e,t)=>(Z(this,ie)[ie][e]?.push(t)||(Z(this,ie)[ie][e]=[t]),()=>Z(this,fe)[fe](e,t)),Z(this,ve)[ve]=e=>{Z(this,re)[re]=Z(this,oe)[oe]?.session?.peer?.metadata?.name||Z(this,he)[he]?.name||"WalletConnect",Z(this,se)[se]=Z(this,oe)[oe]?.session?.peer?.metadata?.icons?.[0]||Z(this,he)[he]?.image_url?.sm||Z(this,se)[se],Z(this,ae)[ae]=e.map((e=>new Q({address:e,publicKey:M.decode(e),label:Z(this,re)[re],icon:Z(this,se)[se]}))),Z(this,me)[me]("change",{accounts:this.accounts})},Z(this,ge)[ge]=()=>{Z(this,ae)[ae]=[],Z(this,me)[me]("change",{accounts:this.accounts})},Z(this,ye)[ye]=async()=>(this.accounts.length||await Z(this,Ce)[Ce](),{accounts:this.accounts}),Z(this,we)[we]=async()=>{await Z(this,Ie)[Ie](),Z(this,me)[me]("change",{accounts:this.accounts})},Z(this,be)[be]=async(...e)=>{let t=[];for(let{account:i,message:n}of e){let e=M.encode(n);try{let r=await Z(this,Te)[Te]("solana_signMessage",{message:e,pubkey:i.address},xe("solana:mainnet"));t.push({signedMessage:n,signature:G(r)})}catch(r){if(r?.message?.includes("Missing or invalid")){let r=await Z(this,Te)[Te]("solana:signMessage",{message:e,pubkey:i.address},xe("solana:mainnet"));t.push({signedMessage:n,signature:G(r)})}throw r}}return t},Z(this,Pe)[Pe]=async(...e)=>{let t=[];for(let{account:i,chain:n,transaction:r,options:s}of e){let e=U.encode(r);try{let r=await Z(this,Te)[Te]("solana_signAndSendTransaction",{transaction:e,pubkey:i.address,sendOptions:s},xe(n));t.push({signature:G(r)})}catch(r){if(r?.message?.includes("Missing or invalid")){let r=await Z(this,Te)[Te]("solana:signAndSendTransaction",{transaction:e,pubkey:i.address,sendOptions:s},xe(n));t.push({signature:G(r)})}}}return t},Z(this,_e)[_e]=async(...e)=>{let t=[];for(let{account:i,chain:n,transaction:r}of e){let e=U.encode(r);try{let r=await Z(this,Te)[Te]("solana_signTransaction",{transaction:e,pubkey:i.address},xe(n||"solana:mainnet"));t.push({signedTransaction:X(r)})}catch(r){if(r?.message?.includes("Missing or invalid")){let r=await Z(this,Te)[Te]("solana:signTransaction",{transaction:e,pubkey:i.address},xe(n||"solana:mainnet"));t.push({signedTransaction:X(r)})}}}return t},Z(this,je)[je]=async()=>{if(Z(this,oe)[oe])return Z(this,oe)[oe];if(!Z(this,le)[le])throw Error("WalletConnect Cloud Project ID is required");return Z(this,oe)[oe]=await R.init({projectId:Z(this,le)[le],metadata:{name:Z(this,ce)[ce],description:Z(this,ce)[ce],url:window.location.origin,icons:[]},relayUrl:"wss://relay.walletconnect.com",telemetryEnabled:!1}),Z(this,Se)[Se]("display_uri",Z(this,Ae)[Ae]),Z(this,Se)[Se]("session_delete",Z(this,ke)[ke]),Z(this,Se)[Se]("session_ping",(()=>{})),Z(this,Se)[Se]("session_event",(()=>{})),Z(this,Se)[Se]("session_update",(()=>{})),Z(this,oe)[oe]},Z(this,Ce)[Ce]=async()=>{if(!Z(this,oe)[oe])throw Error("WalletConnectSolana: Failed to get or create session. Provider not initialized");if(Z(this,oe)[oe].session)return Z(this,oe)[oe].session;let e=await Z(this,oe)[oe].connect({optionalNamespaces:{solana:{chains:[ee,te],methods:["solana_signMessage","solana_signTransaction","solana_signAndSendTransaction"],events:[]}}});if(!e)throw Error("WalletConnectSolana: Failed to create new session");return Z(this,ve)[ve](Ue(e)),e},Z(this,Oe)[Oe]=async()=>{let e=Z(this,oe)[oe]?.session;if(e){if(!e.namespaces?.solana)return await(Z(this,oe)[oe]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),void(Z(this,oe)[oe].session=void 0);Z(this,ve)[ve](Ue(e))}},Z(this,Se)[Se]=(e,t)=>{let i=Z(this,ue)[ue].get(e);i&&(Z(this,oe)[oe]?.off(e,i),Z(this,ue)[ue].delete(e)),Z(this,oe)[oe]?.on(e,t),Z(this,ue)[ue].set(e,t)},Z(this,Ie)[Ie]=async()=>{try{if(Z(this,oe)[oe]?.session&&await(Z(this,oe)[oe]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),Z(this,oe)[oe]?.client){let e=Z(this,oe)[oe].client.proposal.getAll();await Promise.allSettled(e.map((e=>Z(this,oe)[oe]?.client.proposal.delete(e.id,{code:6e3,message:"User disconnected"}))));let t=Z(this,oe)[oe].client.pairing.getAll();await Promise.allSettled(t.map((e=>Z(this,oe)[oe]?.client.pairing.delete(e.topic,{code:6e3,message:"User disconnected"}))))}Z(this,ge)[ge]()}catch(e){console.error("WalletConnectSolana: Error destroying session",e)}},Z(this,Te)[Te]=async(e,t,i)=>{try{return await Z(this,oe)[oe].request({method:e,params:t},i)}catch(t){if(console.error(`WalletConnectSolana: RPC Error - ${e}:`,t),t?.message?.includes("without any listeners")&&t.result)return t.result;if(t?.message?.includes("session topic does not exist in keychain"))throw Error("WalletConnectSolana: Wallet connection lost. Please reconnect.");throw t}},Z(this,Ae)[Ae]=e=>{null==Z(this,de)[de]||Z(this,de)[de].call(this,{native:e,universal:void 0})},Z(this,ke)[ke]=()=>{Z(this,ge)[ge]()}}}function We(e,...t){Z(this,ie)[ie][e]?.forEach((e=>e.apply(null,t)))}function Me(e,t){Z(this,ie)[ie][e]=Z(this,ie)[ie][e]?.filter((e=>t!==e))}function Ue(e){return e.namespaces.solana.accounts.reduce(((e,t)=>{let i=t.split(":").at(-1);return e.includes(i)||e.push(i),e}),[])}function xe(e){switch(e){case"solana:mainnet":return ee;case"solana:devnet":return te;default:return e}}const qe=()=>{let{user:i}=h(),{client:o,refreshSessionAndUser:a,initializeWalletProxy:c}=s(),l=n(),d=r();return{importWallet:e((({privateKey:e,additionalSigners:n})=>t({getAccessToken:()=>o.getAccessToken(),user:i,initializeWalletProxy:c,refreshSessionAndUser:a,emitPrivyEvent:l,appConfig:d},{privateKey:e,chainType:"solana",additionalSigners:n})),[i,o,a,c,l,d])}};var Re={id:p,getSolanaRpcClient:W,createTransactionFromRelayQuote:async function({solanaClient:e,quote:t,source:i}){let n=t.steps[0]?.items?.[0];if(!n)throw Error("Invalid quote");let r=n.data.instructions.map((({keys:e,programId:t,data:i})=>({accounts:e.map((({pubkey:e,isSigner:t,isWritable:i})=>({address:e,role:t&&i?3:t&&!i?2:!t&&i?1:0}))),programAddress:t,data:new Uint8Array(Buffer.from(i,"hex"))}))),{value:s}=await e.rpc.getLatestBlockhash().send(),o=g(y({version:0}),(e=>w({address:i},e)),(e=>b(s,e)),(e=>P(r,e)),(e=>_(e)));return new Uint8Array(j().encode(o))},simulateTransaction:E,getAddressFromBuffer:k,fetchTransactionEstimatedFees:A},De=()=>m(Re);var Fe={id:v,createSiwsMemoTransaction:({address:e,nonce:t})=>{let i=x({memo:f({address:C(e),nonce:t})});return g(y({version:"legacy"}),(t=>O(C(e),t)),(e=>b({blockhash:S("GfVcyD5fWFJ6hRm8bsy7CoVPsLSoJhtJKRJYk8T2VVFN"),lastValidBlockHeight:0n},e)),(e=>P([i],e)),(e=>_(e)),(e=>U.encode(Uint8Array.from(j().encode(e)))))},getSignatureFromTransaction:(e,t)=>{let i=I().decode(e).signatures[t];if(!i)throw Error(`Missing transaction signature for address: ${t}`);return U.encode(i)}},Ke=()=>m(Fe);function Le(){let{create:e}=i();return{createWallet:async t=>{t&&"target"in t&&t&&(t=void 0);let{account:i}=await e({chainType:"solana",options:t});return{wallet:i}}}}function Ve(){return{signMessage:async function(...e){let t=[];for(let i of e)t.push(await i.wallet.signMessage({...i,options:i.options}));return 1===e.length?t[0]:[...t]}}}function ze(){return{signTransaction:async function(...e){let t=[];for(let i of e)t.push(await i.wallet.signTransaction({...i,chain:i.chain||"solana:mainnet"}));return 1===e.length?t[0]:[...t]}}}function Be(){return{signAndSendTransaction:async function(...e){let t=[];for(let i of e)t.push(await i.wallet.signAndSendTransaction({...i,chain:i.chain||"solana:mainnet"}));return 1===e.length?t[0]:[...t]}}}export{o as SolanaAdapterConnector,D as toSolanaWalletConnectors,Le as useCreateWallet,qe as useImportWallet,Be as useSignAndSendTransaction,Ve as useSignMessage,ze as useSignTransaction,De as useSolanaFundingPlugin,Ke as useSolanaLedgerPlugin};