@privy-io/react-auth 3.5.0 → 3.5.1

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/{EmbeddedWalletConnectingScreen-D_YsihzO.js → EmbeddedWalletConnectingScreen-i0UDHMDq.js} +1 -1
  2. package/dist/cjs/{SignRequestScreen-MGUrxay9.js → SignRequestScreen-H5r467q6.js} +1 -1
  3. package/dist/cjs/abstract-smart-wallets.js +1 -1
  4. package/dist/cjs/{events-context-Dn0fJZ2h.js → events-context-Cgq8fGB0.js} +1 -1
  5. package/dist/cjs/extended-chains.js +1 -1
  6. package/dist/cjs/index.js +2 -2
  7. package/dist/cjs/internal.js +1 -1
  8. package/dist/cjs/{smart-wallets-5q-XiLac.js → smart-wallets-B0bTYa6G.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-C7R1A29C.js → use-export-wallet-BhYG6ocQ.js} +1 -1
  13. package/dist/cjs/{useActiveWallet-E94x91YD.js → useActiveWallet-BoPIudwB.js} +1 -1
  14. package/dist/cjs/{usePrivy-BEZb4Uky.js → usePrivy-CLLJiDdU.js} +1 -1
  15. package/dist/dts/index.d.mts +1 -1
  16. package/dist/dts/index.d.ts +1 -1
  17. package/dist/esm/{EmbeddedWalletConnectingScreen-ilL_GaJO.mjs → EmbeddedWalletConnectingScreen-BehtOUIO.mjs} +1 -1
  18. package/dist/esm/{SignRequestScreen-B3UhThlp.mjs → SignRequestScreen-W1brL2hg.mjs} +1 -1
  19. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  20. package/dist/esm/{events-context-CB7CF-OC.mjs → events-context-BKqrDYHW.mjs} +1 -1
  21. package/dist/esm/extended-chains.mjs +1 -1
  22. package/dist/esm/index.mjs +2 -2
  23. package/dist/esm/internal.mjs +1 -1
  24. package/dist/esm/{smart-wallets-DINPJbZr.mjs → smart-wallets-CZ7EzP9s.mjs} +1 -1
  25. package/dist/esm/smart-wallets.mjs +1 -1
  26. package/dist/esm/solana.mjs +1 -1
  27. package/dist/esm/ui.mjs +1 -1
  28. package/dist/esm/{use-export-wallet-CED1-6Km.mjs → use-export-wallet-CPxLgKFx.mjs} +1 -1
  29. package/dist/esm/{useActiveWallet-2NxrDpZU.mjs → useActiveWallet-Bw1ry9JQ.mjs} +1 -1
  30. package/dist/esm/{usePrivy-DhsfOIjx.mjs → usePrivy-BJ3NMQui.mjs} +1 -1
  31. package/package.json +4 -4
@@ -1 +1 @@
1
- "use strict";var e=require("./internal-context-CeWKmK5u.js"),t=require("./events-context-Dn0fJZ2h.js");require("ofetch"),require("react"),require("react/jsx-runtime"),require("@privy-io/js-sdk-core"),require("tinycolor2");class r{async authenticate(){if(!this.api)throw new e.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(e.ssoAuthenticatePath,{})}catch(t){throw e.formatApiError(t)}}async link(){throw new e.PrivyClientError("Linking is not supported for the SSO token flow")}constructor(){this.meta={}}}exports.useLoginWithSsoToken=function(){let i=t.useAppConfig(),n=t.useEmitPrivyEvent(),{client:o,setUser:s,setAuthenticated:a,setIsNewUser:u}=e.usePrivyInternal();return{loginWithSsoToken:async()=>{if(!i.id||!o)throw new e.PrivyClientError("SDK not yet ready");try{let t=new r;o.startAuthFlow(t);let i=await o.authenticate(),c=i.user,h=i.isNewUser??!1;if(!c)throw new e.PrivyClientError("Unable to authenticate with SSO response");return s(c),u(h),a(!0),n("login","onComplete",{user:c,isNewUser:h,wasAlreadyAuthenticated:!1,loginMethod:"sso",loginAccount:null}),c}catch(t){throw n("login","onError",t.privyErrorCode||e.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}}};
1
+ "use strict";var e=require("./internal-context-CeWKmK5u.js"),t=require("./events-context-Cgq8fGB0.js");require("ofetch"),require("react"),require("react/jsx-runtime"),require("@privy-io/js-sdk-core"),require("tinycolor2");class r{async authenticate(){if(!this.api)throw new e.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(e.ssoAuthenticatePath,{})}catch(t){throw e.formatApiError(t)}}async link(){throw new e.PrivyClientError("Linking is not supported for the SSO token flow")}constructor(){this.meta={}}}exports.useLoginWithSsoToken=function(){let i=t.useAppConfig(),n=t.useEmitPrivyEvent(),{client:o,setUser:s,setAuthenticated:a,setIsNewUser:u}=e.usePrivyInternal();return{loginWithSsoToken:async()=>{if(!i.id||!o)throw new e.PrivyClientError("SDK not yet ready");try{let t=new r;o.startAuthFlow(t);let i=await o.authenticate(),c=i.user,h=i.isNewUser??!1;if(!c)throw new e.PrivyClientError("Unable to authenticate with SSO response");return s(c),u(h),a(!0),n("login","onComplete",{user:c,isNewUser:h,wasAlreadyAuthenticated:!1,loginMethod:"sso",loginAccount:null}),c}catch(t){throw n("login","onError",t.privyErrorCode||e.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}}};
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("viem"),r=require("./EmbeddedWalletConnectingScreen-D_YsihzO.js"),n=require("./events-context-Dn0fJZ2h.js"),a=require("./internal-context-CeWKmK5u.js"),i=require("./SignRequestScreen-MGUrxay9.js"),s=require("./getEmbeddedConnectedWallet-6TsVZJkD.js"),o=require("permissionless"),l=require("permissionless/accounts"),c=require("permissionless/clients/pimlico"),d=require("viem/account-abstraction"),u=require("@privy-io/js-sdk-core");let p={address:d.entryPoint06Address,version:"0.6"},y={address:d.entryPoint07Address,version:"0.7"},m=({owner:e,smartWalletType:t,smartWalletVersion:r,publicClient:n})=>{switch(t){case u.SAFE:return l.toSafeSmartAccount({client:n,entryPoint:y,owners:[e],version:"1.4.1"});case u.KERNEL:return l.toKernelSmartAccount({client:n,version:"0.3.1",entryPoint:y,useMetaFactory:"optional",owners:[e]});case u.BICONOMY:return l.toBiconomySmartAccount({client:n,owners:[e],entryPoint:p});case u.LIGHT_ACCOUNT:return l.toLightSmartAccount({client:n,entryPoint:p,owner:e,version:"1.1.0"});case u.COINBASE_SMART_WALLET: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 d.toCoinbaseSmartAccount({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 u.THIRDWEB:return l.toThirdwebSmartAccount({client:n,entryPoint:y,owner:e});default:throw Error(`Invalid smart account type: ${t}.`)}};const g=({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}))),h=async({chain:e,paymasterContext:n,account:i,signer:s,user:l,smartWalletsConfig:d,rpcConfig:u,privyAppId:p})=>{if(!(d?.enabled&&l&&i&&s))return;let y=d?.configuredNetworks.find((t=>t.chainId===`eip155:${e.id}`));if(!y)throw new a.PrivyClientError(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let g=l.smartWallet?l.smartWallet.smartWalletType:d.smartWalletType,h=l.smartWallet?l.smartWallet.smartWalletVersion:d.smartWalletVersion,P=r.getJsonRpcEndpointFromChain(e,u,p),f=t.createPublicClient({chain:e,transport:t.http(P)}),W=n??y.paymasterContext,w=await(async({owner:e,smartWalletType:r,smartWalletVersion:n,chain:a,publicClient:i,bundlerUrl:s,paymasterUrl:l,paymasterContext:d})=>{let u=await m({owner:e,smartWalletType:r,publicClient:i,smartWalletVersion:n}),p=c.createPimlicoClient({transport:t.http(s),entryPoint:u.entryPoint}),y=l?c.createPimlicoClient({transport:t.http(l),entryPoint:u.entryPoint}):void 0;return o.createSmartAccountClient({account:u,chain:a,paymaster:y,paymasterContext:d,bundlerTransport:t.http(s),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>s.includes(e))))return await p.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>s.includes(e))))return(await p.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"}),p.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:s,smartWalletType:g,smartWalletVersion:h,chain:e,publicClient:f,paymasterContext:W,...y});if(!w)throw new a.PrivyClientError(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return w};exports.callsToTransactionRequests=g,exports.getSmartWalletClient=h,exports.useSmartWalletsUIWrapper=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:n}=a.usePrivyInternal(),{setModalData:s}=r.usePrivyModal(),{user:o}=r.usePrivyContext(),l=r.getPrivyEthereumWallet(o),c=!!l&&r.getIsUnifiedWallet(l);return{wrapSmartAccountClientWithUIs:a=>({...a,sendTransaction:async(i,d)=>{if(n({showWalletUIs:d?.uiOptions?.showWalletUIs}))return e.current=!0,await a.sendTransaction(i).finally((()=>e.current=!1));let u=[];"calls"in i&&void 0!==i.calls?u=[...i.calls]:"to"in i&&(u=[{to:i.to,value:i.value||BigInt(0),data:i.data||"0x"}]);let p=async()=>{if(!a.paymaster)return!1;let{paymasterData:e,paymasterAndData:t}=await a.prepareUserOperation({calls:u,maxFeePerGas:i.maxFeePerGas,maxPriorityFeePerGas:i.maxPriorityFeePerGas,nonce:i.nonce?BigInt(i.nonce):void 0});return Number(t??e??0)>0};return new Promise((async(n,y)=>{e.current=!0;let{entropyId:m,entropyIdVerifier:h}=r.getEntropyDetailsForUser(o);s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:m,entropyIdVerifier:h,onCompleteNavigateTo:r.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:u,chain:a.chain,maxPriorityFeePerGas:i.maxPriorityFeePerGas,maxFeePerGas:i.maxFeePerGas,nonce:i.nonce?BigInt(i.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:a.account.address,entropyId:m,entropyIdVerifier:h,getIsSponsored:p,signOnly:!1,onConfirm:()=>a.sendTransaction(i),onSuccess:e=>n(e.hash),onFailure:y,uiOptions:d?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))},signMessage:async(d,u)=>n({showWalletUIs:u?.uiOptions?.showWalletUIs})?(e.current=!0,await a.signMessage(d).finally((()=>e.current=!1))):new Promise((async(n,p)=>{let{entropyId:y,entropyIdVerifier:m}=r.getEntropyDetailsForUser(o);e.current=!0,s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:y,entropyIdVerifier:m,onCompleteNavigateTo:i.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof d.message?d.message:d.message.raw.toString(),confirmAndSign:()=>a.signMessage(d),onSuccess:e=>n(e),onFailure:p,uiOptions:u?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1})),signTypedData:async(d,u)=>n({showWalletUIs:u?.uiOptions?.showWalletUIs})?(e.current=!0,await a.signTypedData(d).finally((()=>e.current=!1))):new Promise((async(n,p)=>{e.current=!0;let{entropyId:y,entropyIdVerifier:m}=r.getEntropyDetailsForUser(o);s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:y,entropyIdVerifier:m,onCompleteNavigateTo:i.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:d,confirmAndSign:()=>a.signTypedData(d),onSuccess:e=>n(e),onFailure:p,uiOptions:u?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))})}},exports.useSmartWalletsWrapper=({clientConfig:t,smartWalletsConfig:o})=>{let{hideWalletUIs:l,openPrivyModal:c,appId:d,isHeadlessSigning:u}=a.usePrivyInternal(),p=n.useAppConfig(),{setModalData:y}=r.usePrivyModal(),{user:m}=r.usePrivyContext(),{chains:P}=n.useAppConfig(),{chainId:f,clients:W,setChainId:w,chainIdState:I}=(()=>{let t=e.useRef(),[r,n]=e.useState();return{clients:e.useRef({}),setChainId:e=>{t.current=e,n(e)},chainId:t,chainIdState:r}})(),v=P.find((e=>e.id===I)),{wallets:C}=r.useWallets(),S=r.getPrivyEthereumWallet(m),F=s.getEmbeddedConnectedWalletWithAddress(C,S?.address),x=!!S&&r.getIsUnifiedWallet(S),T=e.useCallback((async()=>f.current),[f]),U=e.useCallback((async({id:e})=>{if(!W.current[e]){let r=await h({chain:P.find((t=>t.id===e)),account:S,signer:await(F?.getEthereumProvider()),user:m,paymasterContext:t?.paymasterContext,smartWalletsConfig:o,rpcConfig:p.rpcConfig,privyAppId:d});r&&(W.current[e]=r)}w(e)}),[P,t,C,m,o]);return{wrapSmartAccountClient:e=>{W.current[e.chain.id]=e,I||w(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let n=W.current[f.current];if(!n)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);if(delete e.account,u({showWalletUIs:t?.uiOptions?.showWalletUIs}))return l.current=!0,await n.sendTransaction(e).finally((()=>l.current=!1));let i=[];"calls"in e&&void 0!==e.calls?i=[...e.calls]:"to"in e&&(i=[{to:e.to,value:e.value||BigInt(0),data:e.data||"0x"}]);let s=async()=>{let{paymasterAndData:t,paymasterData:r,maxFeePerGas:a,maxPriorityFeePerGas:s}=await n.prepareUserOperation({calls:i,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return 0===Number(a)&&0===Number(s)||Number(t??r??0)>0};return new Promise((async(a,o)=>{l.current=!0;let{entropyId:d,entropyIdVerifier:u}=r.getEntropyDetailsForUser(m);y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:d,entropyIdVerifier:u,onCompleteNavigateTo:r.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:i,chain:n.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:n.account.address,entropyId:d,entropyIdVerifier:u,getIsSponsored:s,signOnly:!1,onConfirm:()=>n.sendTransaction(e),onSuccess:e=>a(e.hash),onFailure:o,uiOptions:t?.uiOptions??{}}}),c(r.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},signMessage:async(e,t)=>{let n=W.current[f.current];if(!n)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);return u({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await n.signMessage(e).finally((()=>l.current=!1))):new Promise((async(a,s)=>{let{entropyId:o,entropyIdVerifier:d}=r.getEntropyDetailsForUser(m);l.current=!0,y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:o,entropyIdVerifier:d,onCompleteNavigateTo:i.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof e.message?e.message:e.message.raw.toString(),confirmAndSign:()=>n.signMessage(e),onSuccess:e=>a(e),onFailure:s,uiOptions:t?.uiOptions??{}}}),c(r.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},signTypedData:async(e,t)=>{let n=W.current[f.current];if(!n)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);return delete e.account,u({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await n.signTypedData(e).finally((()=>l.current=!1))):new Promise((async(a,s)=>{l.current=!0;let{entropyId:o,entropyIdVerifier:d}=r.getEntropyDetailsForUser(m);y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:o,entropyIdVerifier:d,onCompleteNavigateTo:i.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>n.signTypedData(e),onSuccess:e=>a(e),onFailure:s,uiOptions:t?.uiOptions??{}}}),c(r.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},getChainId:T,chain:v,switchChain:U}}}};
1
+ "use strict";var e=require("react"),t=require("viem"),r=require("./EmbeddedWalletConnectingScreen-i0UDHMDq.js"),n=require("./events-context-Cgq8fGB0.js"),a=require("./internal-context-CeWKmK5u.js"),i=require("./SignRequestScreen-H5r467q6.js"),s=require("./getEmbeddedConnectedWallet-6TsVZJkD.js"),o=require("permissionless"),l=require("permissionless/accounts"),c=require("permissionless/clients/pimlico"),d=require("viem/account-abstraction"),u=require("@privy-io/js-sdk-core");let p={address:d.entryPoint06Address,version:"0.6"},y={address:d.entryPoint07Address,version:"0.7"},m=({owner:e,smartWalletType:t,smartWalletVersion:r,publicClient:n})=>{switch(t){case u.SAFE:return l.toSafeSmartAccount({client:n,entryPoint:y,owners:[e],version:"1.4.1"});case u.KERNEL:return l.toKernelSmartAccount({client:n,version:"0.3.1",entryPoint:y,useMetaFactory:"optional",owners:[e]});case u.BICONOMY:return l.toBiconomySmartAccount({client:n,owners:[e],entryPoint:p});case u.LIGHT_ACCOUNT:return l.toLightSmartAccount({client:n,entryPoint:p,owner:e,version:"1.1.0"});case u.COINBASE_SMART_WALLET: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 d.toCoinbaseSmartAccount({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 u.THIRDWEB:return l.toThirdwebSmartAccount({client:n,entryPoint:y,owner:e});default:throw Error(`Invalid smart account type: ${t}.`)}};const g=({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}))),h=async({chain:e,paymasterContext:n,account:i,signer:s,user:l,smartWalletsConfig:d,rpcConfig:u,privyAppId:p})=>{if(!(d?.enabled&&l&&i&&s))return;let y=d?.configuredNetworks.find((t=>t.chainId===`eip155:${e.id}`));if(!y)throw new a.PrivyClientError(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let g=l.smartWallet?l.smartWallet.smartWalletType:d.smartWalletType,h=l.smartWallet?l.smartWallet.smartWalletVersion:d.smartWalletVersion,P=r.getJsonRpcEndpointFromChain(e,u,p),f=t.createPublicClient({chain:e,transport:t.http(P)}),W=n??y.paymasterContext,w=await(async({owner:e,smartWalletType:r,smartWalletVersion:n,chain:a,publicClient:i,bundlerUrl:s,paymasterUrl:l,paymasterContext:d})=>{let u=await m({owner:e,smartWalletType:r,publicClient:i,smartWalletVersion:n}),p=c.createPimlicoClient({transport:t.http(s),entryPoint:u.entryPoint}),y=l?c.createPimlicoClient({transport:t.http(l),entryPoint:u.entryPoint}):void 0;return o.createSmartAccountClient({account:u,chain:a,paymaster:y,paymasterContext:d,bundlerTransport:t.http(s),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>s.includes(e))))return await p.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>s.includes(e))))return(await p.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"}),p.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:s,smartWalletType:g,smartWalletVersion:h,chain:e,publicClient:f,paymasterContext:W,...y});if(!w)throw new a.PrivyClientError(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return w};exports.callsToTransactionRequests=g,exports.getSmartWalletClient=h,exports.useSmartWalletsUIWrapper=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:n}=a.usePrivyInternal(),{setModalData:s}=r.usePrivyModal(),{user:o}=r.usePrivyContext(),l=r.getPrivyEthereumWallet(o),c=!!l&&r.getIsUnifiedWallet(l);return{wrapSmartAccountClientWithUIs:a=>({...a,sendTransaction:async(i,d)=>{if(n({showWalletUIs:d?.uiOptions?.showWalletUIs}))return e.current=!0,await a.sendTransaction(i).finally((()=>e.current=!1));let u=[];"calls"in i&&void 0!==i.calls?u=[...i.calls]:"to"in i&&(u=[{to:i.to,value:i.value||BigInt(0),data:i.data||"0x"}]);let p=async()=>{if(!a.paymaster)return!1;let{paymasterData:e,paymasterAndData:t}=await a.prepareUserOperation({calls:u,maxFeePerGas:i.maxFeePerGas,maxPriorityFeePerGas:i.maxPriorityFeePerGas,nonce:i.nonce?BigInt(i.nonce):void 0});return Number(t??e??0)>0};return new Promise((async(n,y)=>{e.current=!0;let{entropyId:m,entropyIdVerifier:h}=r.getEntropyDetailsForUser(o);s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:m,entropyIdVerifier:h,onCompleteNavigateTo:r.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:u,chain:a.chain,maxPriorityFeePerGas:i.maxPriorityFeePerGas,maxFeePerGas:i.maxFeePerGas,nonce:i.nonce?BigInt(i.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:a.account.address,entropyId:m,entropyIdVerifier:h,getIsSponsored:p,signOnly:!1,onConfirm:()=>a.sendTransaction(i),onSuccess:e=>n(e.hash),onFailure:y,uiOptions:d?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))},signMessage:async(d,u)=>n({showWalletUIs:u?.uiOptions?.showWalletUIs})?(e.current=!0,await a.signMessage(d).finally((()=>e.current=!1))):new Promise((async(n,p)=>{let{entropyId:y,entropyIdVerifier:m}=r.getEntropyDetailsForUser(o);e.current=!0,s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:y,entropyIdVerifier:m,onCompleteNavigateTo:i.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof d.message?d.message:d.message.raw.toString(),confirmAndSign:()=>a.signMessage(d),onSuccess:e=>n(e),onFailure:p,uiOptions:u?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1})),signTypedData:async(d,u)=>n({showWalletUIs:u?.uiOptions?.showWalletUIs})?(e.current=!0,await a.signTypedData(d).finally((()=>e.current=!1))):new Promise((async(n,p)=>{e.current=!0;let{entropyId:y,entropyIdVerifier:m}=r.getEntropyDetailsForUser(o);s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:y,entropyIdVerifier:m,onCompleteNavigateTo:i.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:d,confirmAndSign:()=>a.signTypedData(d),onSuccess:e=>n(e),onFailure:p,uiOptions:u?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))})}},exports.useSmartWalletsWrapper=({clientConfig:t,smartWalletsConfig:o})=>{let{hideWalletUIs:l,openPrivyModal:c,appId:d,isHeadlessSigning:u}=a.usePrivyInternal(),p=n.useAppConfig(),{setModalData:y}=r.usePrivyModal(),{user:m}=r.usePrivyContext(),{chains:P}=n.useAppConfig(),{chainId:f,clients:W,setChainId:w,chainIdState:I}=(()=>{let t=e.useRef(),[r,n]=e.useState();return{clients:e.useRef({}),setChainId:e=>{t.current=e,n(e)},chainId:t,chainIdState:r}})(),v=P.find((e=>e.id===I)),{wallets:C}=r.useWallets(),S=r.getPrivyEthereumWallet(m),F=s.getEmbeddedConnectedWalletWithAddress(C,S?.address),x=!!S&&r.getIsUnifiedWallet(S),T=e.useCallback((async()=>f.current),[f]),U=e.useCallback((async({id:e})=>{if(!W.current[e]){let r=await h({chain:P.find((t=>t.id===e)),account:S,signer:await(F?.getEthereumProvider()),user:m,paymasterContext:t?.paymasterContext,smartWalletsConfig:o,rpcConfig:p.rpcConfig,privyAppId:d});r&&(W.current[e]=r)}w(e)}),[P,t,C,m,o]);return{wrapSmartAccountClient:e=>{W.current[e.chain.id]=e,I||w(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let n=W.current[f.current];if(!n)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);if(delete e.account,u({showWalletUIs:t?.uiOptions?.showWalletUIs}))return l.current=!0,await n.sendTransaction(e).finally((()=>l.current=!1));let i=[];"calls"in e&&void 0!==e.calls?i=[...e.calls]:"to"in e&&(i=[{to:e.to,value:e.value||BigInt(0),data:e.data||"0x"}]);let s=async()=>{let{paymasterAndData:t,paymasterData:r,maxFeePerGas:a,maxPriorityFeePerGas:s}=await n.prepareUserOperation({calls:i,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return 0===Number(a)&&0===Number(s)||Number(t??r??0)>0};return new Promise((async(a,o)=>{l.current=!0;let{entropyId:d,entropyIdVerifier:u}=r.getEntropyDetailsForUser(m);y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:d,entropyIdVerifier:u,onCompleteNavigateTo:r.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:i,chain:n.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:n.account.address,entropyId:d,entropyIdVerifier:u,getIsSponsored:s,signOnly:!1,onConfirm:()=>n.sendTransaction(e),onSuccess:e=>a(e.hash),onFailure:o,uiOptions:t?.uiOptions??{}}}),c(r.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},signMessage:async(e,t)=>{let n=W.current[f.current];if(!n)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);return u({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await n.signMessage(e).finally((()=>l.current=!1))):new Promise((async(a,s)=>{let{entropyId:o,entropyIdVerifier:d}=r.getEntropyDetailsForUser(m);l.current=!0,y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:o,entropyIdVerifier:d,onCompleteNavigateTo:i.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof e.message?e.message:e.message.raw.toString(),confirmAndSign:()=>n.signMessage(e),onSuccess:e=>a(e),onFailure:s,uiOptions:t?.uiOptions??{}}}),c(r.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},signTypedData:async(e,t)=>{let n=W.current[f.current];if(!n)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);return delete e.account,u({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await n.signTypedData(e).finally((()=>l.current=!1))):new Promise((async(a,s)=>{l.current=!0;let{entropyId:o,entropyIdVerifier:d}=r.getEntropyDetailsForUser(m);y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:o,entropyIdVerifier:d,onCompleteNavigateTo:i.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>n.signTypedData(e),onSuccess:e=>a(e),onFailure:s,uiOptions:t?.uiOptions??{}}}),c(r.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},getChainId:T,chain:v,switchChain:U}}}};
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("./EmbeddedWalletConnectingScreen-D_YsihzO.js"),t=require("./events-context-Dn0fJZ2h.js"),n=require("./internal-context-CeWKmK5u.js"),o=require("./getEmbeddedConnectedWallet-6TsVZJkD.js"),c=require("./smart-wallets-5q-XiLac.js");require("lucide-react"),require("viem"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/UserCircleIcon"),require("styled-components"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/20/solid/CheckIcon"),require("@heroicons/react/24/outline/EnvelopeIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("react-device-detect"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@heroicons/react/24/outline/WalletIcon"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("@heroicons/react/24/outline/Square2StackIcon"),require("@privy-io/js-sdk-core"),require("zustand"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("@heroicons/react/24/outline/CheckIcon"),require("qrcode"),require("viem/utils"),require("eventemitter3"),require("@scure/base"),require("@walletconnect/ethereum-provider"),require("@heroicons/react/24/outline/CreditCardIcon"),require("@heroicons/react/24/outline/QrCodeIcon"),require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),require("@heroicons/react/24/outline/InformationCircleIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("@heroicons/react/24/outline/ChevronDownIcon"),require("@privy-io/ethereum"),require("@heroicons/react/24/outline/CheckCircleIcon"),require("@heroicons/react/24/outline/GlobeAltIcon"),require("@headlessui/react"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("ofetch"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("@heroicons/react/24/outline/LockClosedIcon"),require("@heroicons/react/24/outline/PencilSquareIcon"),require("jose"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@privy-io/urls"),require("tinycolor2"),require("./SignRequestScreen-MGUrxay9.js"),require("permissionless"),require("permissionless/accounts"),require("permissionless/clients/pimlico"),require("viem/account-abstraction");let a=/*#__PURE__*/r.createContext({client:void 0,getClientForChain:n.notImplemented});let l=/*#__PURE__*/r.createContext({config:void 0}),s=()=>{let{config:e}=r.useContext(l);return{config:e}},u=({children:i})=>{let[t,o]=r.useState(void 0),{client:c}=n.usePrivyInternal();return r.useEffect((()=>{!t&&c&&(async()=>{try{if(!c)return void console.warn("No client found");let e=await c.getSmartWalletsConfig();o(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!c]),/*#__PURE__*/e.jsx(l.Provider,{value:{config:t},children:i})},d=({config:a,children:l})=>{let{config:u}=s(),{appId:d}=n.usePrivyInternal(),{chains:q,defaultChain:C,rpcConfig:g}=t.useAppConfig(),{wallets:m}=i.useWallets(),{user:f}=i.usePrivyContext(),[p,I]=r.useState(),{wrapSmartAccountClientWithUIs:v}=c.useSmartWalletsUIWrapper(),w=i.getPrivyEthereumWallet(f),y=o.getEmbeddedConnectedWalletWithAddress(m,w?.address);r.useEffect((()=>{(async()=>{if(!u?.enabled)return;let e=u.configuredNetworks.find((e=>e.chainId===`eip155:${C.id}`))?C:q.find((e=>u.configuredNetworks.map((e=>e.chainId)).includes(`eip155:${e.id}`)));if(!e)throw new n.PrivyClientError("Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.");I(await c.getSmartWalletClient({chain:e,privyAppId:d,paymasterContext:a?.paymasterContext,rpcConfig:g,account:w,signer:await(y?.getEthereumProvider()),user:f,smartWalletsConfig:u}))})()}),[!!u?.enabled,!!f?.smartWallet,!!y,!!w]);/*#__PURE__*/return e.jsx(h.Provider,{value:{client:p,config:a,getClientForChain:async({id:e})=>{let r=await c.getSmartWalletClient({chain:q.find((r=>r.id===e)),privyAppId:d,paymasterContext:a?.paymasterContext,rpcConfig:g,account:w,signer:await(y?.getEthereumProvider()),user:f,smartWalletsConfig:u});if(!r)throw new n.PrivyClientError(`Failed to create smart wallet client for chain id: ${e}`);return v(r)}},children:l})},h=/*#__PURE__*/r.createContext({client:void 0,config:void 0,getClientForChain:n.notImplemented}),q=({children:t})=>{let{client:o,config:l,getClientForChain:u}=(()=>{let{client:e,config:i,getClientForChain:t}=r.useContext(h);return{client:e,config:i,getClientForChain:t}})(),{config:d}=s(),{wrapSmartAccountClient:q}=c.useSmartWalletsWrapper({clientConfig:l,smartWalletsConfig:d}),{user:C}=i.usePrivyContext(),{generateSiweMessageForSmartWallet:g,linkSmartWallet:m,hideWalletUIs:f}=n.usePrivyInternal();return r.useEffect((()=>{(async()=>{if(o&&C&&!C?.smartWallet&&d?.enabled)try{let e=await g({address:o.account.address,chainId:`eip155:${o.chain.id}`});f.current=!0;let r=await o.signMessage({message:e});await m({signature:r,message:e,smartWalletType:d.smartWalletType,smartWalletVersion:d.smartWalletVersion})}catch(e){console.error("Error creating smart wallet:",e)}finally{f.current=!1}})()}),[!!o,!!C?.smartWallet,!!d?.enabled]),/*#__PURE__*/e.jsx(a.Provider,{value:{client:C?.smartWallet&&o?q(o):void 0,getClientForChain:u},children:t})};exports.SmartWalletsProvider=({config:r,children:i})=>/*#__PURE__*/e.jsx(u,{children:/*#__PURE__*/e.jsx(d,{config:r,children:/*#__PURE__*/e.jsx(q,{children:i})})}),exports.useSmartWallets=()=>{let{client:e,getClientForChain:i}=r.useContext(a);return{client:e,getClientForChain:i}};
1
+ "use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("./EmbeddedWalletConnectingScreen-i0UDHMDq.js"),t=require("./events-context-Cgq8fGB0.js"),n=require("./internal-context-CeWKmK5u.js"),o=require("./getEmbeddedConnectedWallet-6TsVZJkD.js"),c=require("./smart-wallets-B0bTYa6G.js");require("lucide-react"),require("viem"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/UserCircleIcon"),require("styled-components"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/20/solid/CheckIcon"),require("@heroicons/react/24/outline/EnvelopeIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("react-device-detect"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@heroicons/react/24/outline/WalletIcon"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("@heroicons/react/24/outline/Square2StackIcon"),require("@privy-io/js-sdk-core"),require("zustand"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("@heroicons/react/24/outline/CheckIcon"),require("qrcode"),require("viem/utils"),require("eventemitter3"),require("@scure/base"),require("@walletconnect/ethereum-provider"),require("@heroicons/react/24/outline/CreditCardIcon"),require("@heroicons/react/24/outline/QrCodeIcon"),require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),require("@heroicons/react/24/outline/InformationCircleIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("@heroicons/react/24/outline/ChevronDownIcon"),require("@privy-io/ethereum"),require("@heroicons/react/24/outline/CheckCircleIcon"),require("@heroicons/react/24/outline/GlobeAltIcon"),require("@headlessui/react"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("ofetch"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("@heroicons/react/24/outline/LockClosedIcon"),require("@heroicons/react/24/outline/PencilSquareIcon"),require("jose"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@privy-io/urls"),require("tinycolor2"),require("./SignRequestScreen-H5r467q6.js"),require("permissionless"),require("permissionless/accounts"),require("permissionless/clients/pimlico"),require("viem/account-abstraction");let a=/*#__PURE__*/r.createContext({client:void 0,getClientForChain:n.notImplemented});let l=/*#__PURE__*/r.createContext({config:void 0}),s=()=>{let{config:e}=r.useContext(l);return{config:e}},u=({children:i})=>{let[t,o]=r.useState(void 0),{client:c}=n.usePrivyInternal();return r.useEffect((()=>{!t&&c&&(async()=>{try{if(!c)return void console.warn("No client found");let e=await c.getSmartWalletsConfig();o(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!c]),/*#__PURE__*/e.jsx(l.Provider,{value:{config:t},children:i})},d=({config:a,children:l})=>{let{config:u}=s(),{appId:d}=n.usePrivyInternal(),{chains:q,defaultChain:C,rpcConfig:g}=t.useAppConfig(),{wallets:m}=i.useWallets(),{user:f}=i.usePrivyContext(),[p,I]=r.useState(),{wrapSmartAccountClientWithUIs:v}=c.useSmartWalletsUIWrapper(),w=i.getPrivyEthereumWallet(f),y=o.getEmbeddedConnectedWalletWithAddress(m,w?.address);r.useEffect((()=>{(async()=>{if(!u?.enabled)return;let e=u.configuredNetworks.find((e=>e.chainId===`eip155:${C.id}`))?C:q.find((e=>u.configuredNetworks.map((e=>e.chainId)).includes(`eip155:${e.id}`)));if(!e)throw new n.PrivyClientError("Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.");I(await c.getSmartWalletClient({chain:e,privyAppId:d,paymasterContext:a?.paymasterContext,rpcConfig:g,account:w,signer:await(y?.getEthereumProvider()),user:f,smartWalletsConfig:u}))})()}),[!!u?.enabled,!!f?.smartWallet,!!y,!!w]);/*#__PURE__*/return e.jsx(h.Provider,{value:{client:p,config:a,getClientForChain:async({id:e})=>{let r=await c.getSmartWalletClient({chain:q.find((r=>r.id===e)),privyAppId:d,paymasterContext:a?.paymasterContext,rpcConfig:g,account:w,signer:await(y?.getEthereumProvider()),user:f,smartWalletsConfig:u});if(!r)throw new n.PrivyClientError(`Failed to create smart wallet client for chain id: ${e}`);return v(r)}},children:l})},h=/*#__PURE__*/r.createContext({client:void 0,config:void 0,getClientForChain:n.notImplemented}),q=({children:t})=>{let{client:o,config:l,getClientForChain:u}=(()=>{let{client:e,config:i,getClientForChain:t}=r.useContext(h);return{client:e,config:i,getClientForChain:t}})(),{config:d}=s(),{wrapSmartAccountClient:q}=c.useSmartWalletsWrapper({clientConfig:l,smartWalletsConfig:d}),{user:C}=i.usePrivyContext(),{generateSiweMessageForSmartWallet:g,linkSmartWallet:m,hideWalletUIs:f}=n.usePrivyInternal();return r.useEffect((()=>{(async()=>{if(o&&C&&!C?.smartWallet&&d?.enabled)try{let e=await g({address:o.account.address,chainId:`eip155:${o.chain.id}`});f.current=!0;let r=await o.signMessage({message:e});await m({signature:r,message:e,smartWalletType:d.smartWalletType,smartWalletVersion:d.smartWalletVersion})}catch(e){console.error("Error creating smart wallet:",e)}finally{f.current=!1}})()}),[!!o,!!C?.smartWallet,!!d?.enabled]),/*#__PURE__*/e.jsx(a.Provider,{value:{client:C?.smartWallet&&o?q(o):void 0,getClientForChain:u},children:t})};exports.SmartWalletsProvider=({config:r,children:i})=>/*#__PURE__*/e.jsx(u,{children:/*#__PURE__*/e.jsx(d,{config:r,children:/*#__PURE__*/e.jsx(q,{children:i})})}),exports.useSmartWallets=()=>{let{client:e,getClientForChain:i}=r.useContext(a);return{client:e,getClientForChain:i}};
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("./usePrivy-BEZb4Uky.js"),i=require("./events-context-Dn0fJZ2h.js"),r=require("./internal-context-CeWKmK5u.js"),n=require("./EmbeddedWalletConnectingScreen-D_YsihzO.js"),s=require("@solana/kit"),a=require("./use-export-wallet-C7R1A29C.js"),o=require("@scure/base"),c=require("@solana-program/memo"),l=require("@wallet-standard/app"),u=require("@walletconnect/universal-provider");require("@privy-io/js-sdk-core"),require("react/jsx-runtime"),require("tinycolor2"),require("ofetch"),require("lucide-react"),require("viem"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/UserCircleIcon"),require("styled-components"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/20/solid/CheckIcon"),require("@heroicons/react/24/outline/EnvelopeIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("react-device-detect"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@heroicons/react/24/outline/WalletIcon"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("@heroicons/react/24/outline/Square2StackIcon"),require("zustand"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("@heroicons/react/24/outline/CheckIcon"),require("qrcode"),require("viem/utils"),require("eventemitter3"),require("@walletconnect/ethereum-provider"),require("@heroicons/react/24/outline/CreditCardIcon"),require("@heroicons/react/24/outline/QrCodeIcon"),require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),require("@heroicons/react/24/outline/InformationCircleIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("@heroicons/react/24/outline/ChevronDownIcon"),require("@privy-io/ethereum"),require("@heroicons/react/24/outline/CheckCircleIcon"),require("@heroicons/react/24/outline/GlobeAltIcon"),require("@headlessui/react"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("@heroicons/react/24/outline/LockClosedIcon"),require("@heroicons/react/24/outline/PencilSquareIcon"),require("jose"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@privy-io/urls"),require("./use-sign-with-user-signer-BtJVKMQr.js"),require("./SignRequestScreen-MGUrxay9.js"),require("@solana-program/system"),require("@solana-program/token");function d(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var h=0;function p(e){return"__private_"+h+++"_"+e}var g=/*#__PURE__*/p("_address"),v=/*#__PURE__*/p("_publicKey"),f=/*#__PURE__*/p("_chains"),y=/*#__PURE__*/p("_features"),b=/*#__PURE__*/p("_label"),w=/*#__PURE__*/p("_icon");class m{get address(){return d(this,g)[g]}get publicKey(){return d(this,v)[v].slice()}get chains(){return d(this,f)[f].slice()}get features(){return d(this,y)[y].slice()}get label(){return d(this,b)[b]}get icon(){return d(this,w)[w]}constructor({address:e,publicKey:t,label:i,icon:r}){Object.defineProperty(this,g,{writable:!0,value:void 0}),Object.defineProperty(this,v,{writable:!0,value:void 0}),Object.defineProperty(this,f,{writable:!0,value:void 0}),Object.defineProperty(this,y,{writable:!0,value:void 0}),Object.defineProperty(this,b,{writable:!0,value:void 0}),Object.defineProperty(this,w,{writable:!0,value:void 0}),d(this,g)[g]=e,d(this,v)[v]=t,d(this,f)[f]=a.SOLANA_CHAINS,d(this,y)[y]=["solana:signAndSendTransaction","solana:signTransaction","solana:signMessage"],d(this,b)[b]=i,d(this,w)[w]=r}}function q(e){if("string"==typeof e)return o.base58.decode(e);if(e instanceof Uint8Array)return e;let t=e.signature;return"string"==typeof t?o.base58.decode(t):t}function P(e){if("string"==typeof e){try{return o.base58.decode(e)}catch{}return o.base64.decode(e)}if(e instanceof Uint8Array)return e;let t=e.transaction;if("string"==typeof t){try{return o.base58.decode(t)}catch{}return o.base64.decode(t)}return t}function _(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var S=0;function C(e){return"__private_"+S+++"_"+e}let T="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",I="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";var A=/*#__PURE__*/C("_listeners"),j=/*#__PURE__*/C("_version"),O=/*#__PURE__*/C("_name"),W=/*#__PURE__*/C("_icon"),E=/*#__PURE__*/C("_provider"),k=/*#__PURE__*/C("_accounts"),M=/*#__PURE__*/C("_privyAppName"),x=/*#__PURE__*/C("_walletConnectCloudProjectId"),U=/*#__PURE__*/C("_walletEntry"),L=/*#__PURE__*/C("_onDisplayUriCallback"),F=/*#__PURE__*/C("_providerEventListeners"),N=/*#__PURE__*/C("_on"),R=/*#__PURE__*/C("_emit"),D=/*#__PURE__*/C("_off"),K=/*#__PURE__*/C("_connected"),B=/*#__PURE__*/C("_disconnected"),V=/*#__PURE__*/C("_connect"),G=/*#__PURE__*/C("_disconnect"),z=/*#__PURE__*/C("_signMessage"),J=/*#__PURE__*/C("_signAndSendTransaction"),Y=/*#__PURE__*/C("_signTransaction"),H=/*#__PURE__*/C("_getOrCreateProvider"),Q=/*#__PURE__*/C("_getOrCreateSession"),X=/*#__PURE__*/C("_restoreSession"),Z=/*#__PURE__*/C("_addProviderEventListener"),$=/*#__PURE__*/C("_destroySession"),ee=/*#__PURE__*/C("_makeRpcRequest"),te=/*#__PURE__*/C("_onDisplayUri"),ie=/*#__PURE__*/C("_onSessionDelete");class re{get version(){return _(this,j)[j]}get name(){return _(this,O)[O]}get icon(){return _(this,W)[W]}get chains(){return a.SOLANA_CHAINS.slice()}get features(){return{"standard:connect":{version:"1.0.0",connect:_(this,V)[V]},"standard:disconnect":{version:"1.0.0",disconnect:_(this,G)[G]},"standard:events":{version:"1.0.0",on:_(this,N)[N]},"solana:signAndSendTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:_(this,J)[J]},"solana:signTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:_(this,Y)[Y]},"solana:signMessage":{version:"1.0.0",signMessage:_(this,z)[z]}}}get accounts(){return _(this,k)[k].slice()}get isWalletConnectSolana(){return!0}async initialize({walletConnectCloudProjectId:e,privyAppName:t}){_(this,x)[x]=e,_(this,M)[M]=t,await _(this,H)[H](),await _(this,X)[X]()}setWalletEntry(e,t){_(this,U)[U]=e,_(this,L)[L]=t}constructor(){Object.defineProperty(this,R,{value:ne}),Object.defineProperty(this,D,{value:se}),Object.defineProperty(this,A,{writable:!0,value:void 0}),Object.defineProperty(this,j,{writable:!0,value:void 0}),Object.defineProperty(this,O,{writable:!0,value:void 0}),Object.defineProperty(this,W,{writable:!0,value:void 0}),Object.defineProperty(this,E,{writable:!0,value:void 0}),Object.defineProperty(this,k,{writable:!0,value:void 0}),Object.defineProperty(this,M,{writable:!0,value:void 0}),Object.defineProperty(this,x,{writable:!0,value:void 0}),Object.defineProperty(this,U,{writable:!0,value:void 0}),Object.defineProperty(this,L,{writable:!0,value:void 0}),Object.defineProperty(this,F,{writable:!0,value:void 0}),Object.defineProperty(this,N,{writable:!0,value:void 0}),Object.defineProperty(this,K,{writable:!0,value:void 0}),Object.defineProperty(this,B,{writable:!0,value:void 0}),Object.defineProperty(this,V,{writable:!0,value:void 0}),Object.defineProperty(this,G,{writable:!0,value:void 0}),Object.defineProperty(this,z,{writable:!0,value:void 0}),Object.defineProperty(this,J,{writable:!0,value:void 0}),Object.defineProperty(this,Y,{writable:!0,value:void 0}),Object.defineProperty(this,H,{writable:!0,value:void 0}),Object.defineProperty(this,Q,{writable:!0,value:void 0}),Object.defineProperty(this,X,{writable:!0,value:void 0}),Object.defineProperty(this,Z,{writable:!0,value:void 0}),Object.defineProperty(this,$,{writable:!0,value:void 0}),Object.defineProperty(this,ee,{writable:!0,value:void 0}),Object.defineProperty(this,te,{writable:!0,value:void 0}),Object.defineProperty(this,ie,{writable:!0,value:void 0}),_(this,A)[A]={},_(this,j)[j]="1.0.0",_(this,O)[O]="WalletConnect",_(this,W)[W]=n.WALLET_CONNECT_LOGO_DATA_URI,_(this,E)[E]=null,_(this,k)[k]=[],_(this,M)[M]="",_(this,x)[x]="",_(this,F)[F]=new Map,_(this,N)[N]=(e,t)=>(_(this,A)[A][e]?.push(t)||(_(this,A)[A][e]=[t]),()=>_(this,D)[D](e,t)),_(this,K)[K]=e=>{_(this,O)[O]=_(this,E)[E]?.session?.peer?.metadata?.name||_(this,U)[U]?.name||"WalletConnect",_(this,W)[W]=_(this,E)[E]?.session?.peer?.metadata?.icons?.[0]||_(this,U)[U]?.image_url?.sm||_(this,W)[W],_(this,k)[k]=e.map((e=>new m({address:e,publicKey:o.base58.decode(e),label:_(this,O)[O],icon:_(this,W)[W]}))),_(this,R)[R]("change",{accounts:this.accounts})},_(this,B)[B]=()=>{_(this,k)[k]=[],_(this,R)[R]("change",{accounts:this.accounts})},_(this,V)[V]=async()=>(this.accounts.length||await _(this,Q)[Q](),{accounts:this.accounts}),_(this,G)[G]=async()=>{await _(this,$)[$](),_(this,R)[R]("change",{accounts:this.accounts})},_(this,z)[z]=async(...e)=>{let t=[];for(let{account:i,message:r}of e){let e=o.base58.encode(r);try{let n=await _(this,ee)[ee]("solana_signMessage",{message:e,pubkey:i.address},oe("solana:mainnet"));t.push({signedMessage:r,signature:q(n)})}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await _(this,ee)[ee]("solana:signMessage",{message:e,pubkey:i.address},oe("solana:mainnet"));t.push({signedMessage:r,signature:q(n)})}throw n}}return t},_(this,J)[J]=async(...e)=>{let t=[];for(let{account:i,chain:r,transaction:n,options:s}of e){let e=o.base64.encode(n);try{let n=await _(this,ee)[ee]("solana_signAndSendTransaction",{transaction:e,pubkey:i.address,sendOptions:s},oe(r));t.push({signature:q(n)})}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await _(this,ee)[ee]("solana:signAndSendTransaction",{transaction:e,pubkey:i.address,sendOptions:s},oe(r));t.push({signature:q(n)})}}}return t},_(this,Y)[Y]=async(...e)=>{let t=[];for(let{account:i,chain:r,transaction:n}of e){let e=o.base64.encode(n);try{let n=await _(this,ee)[ee]("solana_signTransaction",{transaction:e,pubkey:i.address},oe(r||"solana:mainnet"));t.push({signedTransaction:P(n)})}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await _(this,ee)[ee]("solana:signTransaction",{transaction:e,pubkey:i.address},oe(r||"solana:mainnet"));t.push({signedTransaction:P(n)})}}}return t},_(this,H)[H]=async()=>{if(_(this,E)[E])return _(this,E)[E];if(!_(this,x)[x])throw Error("WalletConnect Cloud Project ID is required");return _(this,E)[E]=await u.UniversalProvider.init({projectId:_(this,x)[x],metadata:{name:_(this,M)[M],description:_(this,M)[M],url:window.location.origin,icons:[]},relayUrl:"wss://relay.walletconnect.com",telemetryEnabled:!1}),_(this,Z)[Z]("display_uri",_(this,te)[te]),_(this,Z)[Z]("session_delete",_(this,ie)[ie]),_(this,Z)[Z]("session_ping",(()=>{})),_(this,Z)[Z]("session_event",(()=>{})),_(this,Z)[Z]("session_update",(()=>{})),_(this,E)[E]},_(this,Q)[Q]=async()=>{if(!_(this,E)[E])throw Error("WalletConnectSolana: Failed to get or create session. Provider not initialized");if(_(this,E)[E].session)return _(this,E)[E].session;let e=await _(this,E)[E].connect({optionalNamespaces:{solana:{chains:[T,I],methods:["solana_signMessage","solana_signTransaction","solana_signAndSendTransaction"],events:[]}}});if(!e)throw Error("WalletConnectSolana: Failed to create new session");return _(this,K)[K](ae(e)),e},_(this,X)[X]=async()=>{let e=_(this,E)[E]?.session;if(e){if(!e.namespaces?.solana)return await(_(this,E)[E]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),void(_(this,E)[E].session=void 0);_(this,K)[K](ae(e))}},_(this,Z)[Z]=(e,t)=>{let i=_(this,F)[F].get(e);i&&(_(this,E)[E]?.off(e,i),_(this,F)[F].delete(e)),_(this,E)[E]?.on(e,t),_(this,F)[F].set(e,t)},_(this,$)[$]=async()=>{try{if(_(this,E)[E]?.session&&await(_(this,E)[E]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),_(this,E)[E]?.client){let e=_(this,E)[E].client.proposal.getAll();await Promise.allSettled(e.map((e=>_(this,E)[E]?.client.proposal.delete(e.id,{code:6e3,message:"User disconnected"}))));let t=_(this,E)[E].client.pairing.getAll();await Promise.allSettled(t.map((e=>_(this,E)[E]?.client.pairing.delete(e.topic,{code:6e3,message:"User disconnected"}))))}_(this,B)[B]()}catch(e){console.error("WalletConnectSolana: Error destroying session",e)}},_(this,ee)[ee]=async(e,t,i)=>{try{return await _(this,E)[E].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}},_(this,te)[te]=e=>{null==_(this,L)[L]||_(this,L)[L].call(this,{native:e,universal:void 0})},_(this,ie)[ie]=()=>{_(this,B)[B]()}}}function ne(e,...t){_(this,A)[A][e]?.forEach((e=>e.apply(null,t)))}function se(e,t){_(this,A)[A][e]=_(this,A)[A][e]?.filter((e=>t!==e))}function ae(e){return e.namespaces.solana.accounts.reduce(((e,t)=>{let i=t.split(":").at(-1);return e.includes(i)||e.push(i),e}),[])}function oe(e){switch(e){case"solana:mainnet":return T;case"solana:devnet":return I;default:return e}}var ce={id:n.SOLANA_FUNDING_PLUGIN_ID,getSolanaRpcClient:a.getSolanaRpcClient,createTransactionFromRelayQuote:async function({solanaClient:e,quote:t,source:i}){let r=t.steps[0]?.items?.[0];if(!r)throw Error("Invalid quote");let n=r.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:a}=await e.rpc.getLatestBlockhash().send(),o=s.pipe(s.createTransactionMessage({version:0}),(e=>s.setTransactionMessageFeePayerSigner({address:i},e)),(e=>s.setTransactionMessageLifetimeUsingBlockhash(a,e)),(e=>s.appendTransactionMessageInstructions(n,e)),(e=>s.compileTransaction(e)));return new Uint8Array(s.getTransactionEncoder().encode(o))},simulateTransaction:a.simulateTransaction,getAddressFromBuffer:a.getAddressFromBuffer,fetchTransactionEstimatedFees:a.fetchTransactionEstimatedFees};var le={id:n.SOLANA_LEDGER_PLUGIN_ID,createSiwsMemoTransaction:({address:e,nonce:t})=>{let i=c.getAddMemoInstruction({memo:n.prepareSiwsMessageWithNonce({address:s.address(e),nonce:t})});return s.pipe(s.createTransactionMessage({version:"legacy"}),(t=>s.setTransactionMessageFeePayer(s.address(e),t)),(e=>s.setTransactionMessageLifetimeUsingBlockhash({blockhash:s.blockhash("GfVcyD5fWFJ6hRm8bsy7CoVPsLSoJhtJKRJYk8T2VVFN"),lastValidBlockHeight:0n},e)),(e=>s.appendTransactionMessageInstructions([i],e)),(e=>s.compileTransaction(e)),(e=>o.base64.encode(Uint8Array.from(s.getTransactionEncoder().encode(e)))))},getSignatureFromTransaction:(e,t)=>{let i=s.getTransactionDecoder().decode(e).signatures[t];if(!i)throw Error(`Missing transaction signature for address: ${t}`);return o.base64.encode(i)}};exports.SolanaAdapterConnector=n.SolanaWalletConnector,exports.useExportWallet=a.useExportWallet,exports.useFundWallet=a.useFundWallet,exports.useStandardWallets=a.useSolanaStandardWallets,exports.useWallets=a.useWallets,exports.toSolanaWalletConnectors=e=>{let t,{get:i,on:r}=l.getWallets(),s=e?.shouldAutoConnect??!0,a=new n.SolanaWalletConnector(new re,s),o=new Map,c=[];function u(...e){e.forEach((e=>{!(e.features["privy:"]&&"isPrivyWallet"in e&&e.isPrivyWallet||o.has(e.name))&&e.chains.some((e=>"string"==typeof e&&e.startsWith("solana:")))&&o.set(e.name,e)})),c=Array.from(o.values()).map((e=>new n.SolanaWalletConnector(e,s))).concat(a),t?.(c)}function d(...e){Array.from(o.values()).forEach((t=>!e.includes(t)&&o.delete(t.name))),c=Array.from(o.values()).map((e=>new n.SolanaWalletConnector(e,s))).concat(a),t?.(c)}let h=[r("register",u),r("unregister",d)];return u(...i()),{_setOnConnectorsUpdated:e=>{t=e},onMount:()=>{h[0]||(h[0]=r("register",u)),h[1]||(h[1]=r("unregister",d))},onUnmount:()=>{let e=h.pop();for(;e;)e(),e=h.pop()},get:()=>c}},exports.useCreateWallet=function(){let{create:e}=t.useCreateWalletInternal();return{createWallet:async t=>{t&&"target"in t&&t&&(t=void 0);let{account:i}=await e({chainType:"solana",options:t});return{wallet:i}}}},exports.useImportWallet=()=>{let{user:s}=n.usePrivyContext(),{client:a,refreshSessionAndUser:o,initializeWalletProxy:c}=r.usePrivyInternal(),l=i.useEmitPrivyEvent(),u=i.useAppConfig();return{importWallet:e.useCallback((({privateKey:e,additionalSigners:i})=>t.importWallet({getAccessToken:()=>a.getAccessToken(),user:s,initializeWalletProxy:c,refreshSessionAndUser:o,emitPrivyEvent:l,appConfig:u},{privateKey:e,chainType:"solana",additionalSigners:i})),[s,a,o,c,l,u])}},exports.useSignAndSendTransaction=function(){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]}}},exports.useSignMessage=function(){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]}}},exports.useSignTransaction=function(){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]}}},exports.useSolanaFundingPlugin=()=>n.useRegisterPlugin(ce),exports.useSolanaLedgerPlugin=()=>n.useRegisterPlugin(le);
1
+ "use strict";var e=require("react"),t=require("./usePrivy-CLLJiDdU.js"),i=require("./events-context-Cgq8fGB0.js"),r=require("./internal-context-CeWKmK5u.js"),n=require("./EmbeddedWalletConnectingScreen-i0UDHMDq.js"),s=require("@solana/kit"),a=require("./use-export-wallet-BhYG6ocQ.js"),o=require("@scure/base"),c=require("@solana-program/memo"),l=require("@wallet-standard/app"),u=require("@walletconnect/universal-provider");require("@privy-io/js-sdk-core"),require("react/jsx-runtime"),require("tinycolor2"),require("ofetch"),require("lucide-react"),require("viem"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/UserCircleIcon"),require("styled-components"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/20/solid/CheckIcon"),require("@heroicons/react/24/outline/EnvelopeIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("react-device-detect"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@heroicons/react/24/outline/WalletIcon"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("@heroicons/react/24/outline/Square2StackIcon"),require("zustand"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("@heroicons/react/24/outline/CheckIcon"),require("qrcode"),require("viem/utils"),require("eventemitter3"),require("@walletconnect/ethereum-provider"),require("@heroicons/react/24/outline/CreditCardIcon"),require("@heroicons/react/24/outline/QrCodeIcon"),require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),require("@heroicons/react/24/outline/InformationCircleIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("@heroicons/react/24/outline/ChevronDownIcon"),require("@privy-io/ethereum"),require("@heroicons/react/24/outline/CheckCircleIcon"),require("@heroicons/react/24/outline/GlobeAltIcon"),require("@headlessui/react"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("@heroicons/react/24/outline/LockClosedIcon"),require("@heroicons/react/24/outline/PencilSquareIcon"),require("jose"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@privy-io/urls"),require("./use-sign-with-user-signer-BtJVKMQr.js"),require("./SignRequestScreen-H5r467q6.js"),require("@solana-program/system"),require("@solana-program/token");function d(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var h=0;function p(e){return"__private_"+h+++"_"+e}var g=/*#__PURE__*/p("_address"),v=/*#__PURE__*/p("_publicKey"),f=/*#__PURE__*/p("_chains"),y=/*#__PURE__*/p("_features"),b=/*#__PURE__*/p("_label"),w=/*#__PURE__*/p("_icon");class m{get address(){return d(this,g)[g]}get publicKey(){return d(this,v)[v].slice()}get chains(){return d(this,f)[f].slice()}get features(){return d(this,y)[y].slice()}get label(){return d(this,b)[b]}get icon(){return d(this,w)[w]}constructor({address:e,publicKey:t,label:i,icon:r}){Object.defineProperty(this,g,{writable:!0,value:void 0}),Object.defineProperty(this,v,{writable:!0,value:void 0}),Object.defineProperty(this,f,{writable:!0,value:void 0}),Object.defineProperty(this,y,{writable:!0,value:void 0}),Object.defineProperty(this,b,{writable:!0,value:void 0}),Object.defineProperty(this,w,{writable:!0,value:void 0}),d(this,g)[g]=e,d(this,v)[v]=t,d(this,f)[f]=a.SOLANA_CHAINS,d(this,y)[y]=["solana:signAndSendTransaction","solana:signTransaction","solana:signMessage"],d(this,b)[b]=i,d(this,w)[w]=r}}function q(e){if("string"==typeof e)return o.base58.decode(e);if(e instanceof Uint8Array)return e;let t=e.signature;return"string"==typeof t?o.base58.decode(t):t}function P(e){if("string"==typeof e){try{return o.base58.decode(e)}catch{}return o.base64.decode(e)}if(e instanceof Uint8Array)return e;let t=e.transaction;if("string"==typeof t){try{return o.base58.decode(t)}catch{}return o.base64.decode(t)}return t}function _(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var S=0;function C(e){return"__private_"+S+++"_"+e}let T="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",I="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";var A=/*#__PURE__*/C("_listeners"),j=/*#__PURE__*/C("_version"),O=/*#__PURE__*/C("_name"),W=/*#__PURE__*/C("_icon"),E=/*#__PURE__*/C("_provider"),k=/*#__PURE__*/C("_accounts"),M=/*#__PURE__*/C("_privyAppName"),x=/*#__PURE__*/C("_walletConnectCloudProjectId"),U=/*#__PURE__*/C("_walletEntry"),L=/*#__PURE__*/C("_onDisplayUriCallback"),F=/*#__PURE__*/C("_providerEventListeners"),N=/*#__PURE__*/C("_on"),R=/*#__PURE__*/C("_emit"),D=/*#__PURE__*/C("_off"),K=/*#__PURE__*/C("_connected"),B=/*#__PURE__*/C("_disconnected"),V=/*#__PURE__*/C("_connect"),G=/*#__PURE__*/C("_disconnect"),z=/*#__PURE__*/C("_signMessage"),J=/*#__PURE__*/C("_signAndSendTransaction"),Y=/*#__PURE__*/C("_signTransaction"),H=/*#__PURE__*/C("_getOrCreateProvider"),Q=/*#__PURE__*/C("_getOrCreateSession"),X=/*#__PURE__*/C("_restoreSession"),Z=/*#__PURE__*/C("_addProviderEventListener"),$=/*#__PURE__*/C("_destroySession"),ee=/*#__PURE__*/C("_makeRpcRequest"),te=/*#__PURE__*/C("_onDisplayUri"),ie=/*#__PURE__*/C("_onSessionDelete");class re{get version(){return _(this,j)[j]}get name(){return _(this,O)[O]}get icon(){return _(this,W)[W]}get chains(){return a.SOLANA_CHAINS.slice()}get features(){return{"standard:connect":{version:"1.0.0",connect:_(this,V)[V]},"standard:disconnect":{version:"1.0.0",disconnect:_(this,G)[G]},"standard:events":{version:"1.0.0",on:_(this,N)[N]},"solana:signAndSendTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:_(this,J)[J]},"solana:signTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:_(this,Y)[Y]},"solana:signMessage":{version:"1.0.0",signMessage:_(this,z)[z]}}}get accounts(){return _(this,k)[k].slice()}get isWalletConnectSolana(){return!0}async initialize({walletConnectCloudProjectId:e,privyAppName:t}){_(this,x)[x]=e,_(this,M)[M]=t,await _(this,H)[H](),await _(this,X)[X]()}setWalletEntry(e,t){_(this,U)[U]=e,_(this,L)[L]=t}constructor(){Object.defineProperty(this,R,{value:ne}),Object.defineProperty(this,D,{value:se}),Object.defineProperty(this,A,{writable:!0,value:void 0}),Object.defineProperty(this,j,{writable:!0,value:void 0}),Object.defineProperty(this,O,{writable:!0,value:void 0}),Object.defineProperty(this,W,{writable:!0,value:void 0}),Object.defineProperty(this,E,{writable:!0,value:void 0}),Object.defineProperty(this,k,{writable:!0,value:void 0}),Object.defineProperty(this,M,{writable:!0,value:void 0}),Object.defineProperty(this,x,{writable:!0,value:void 0}),Object.defineProperty(this,U,{writable:!0,value:void 0}),Object.defineProperty(this,L,{writable:!0,value:void 0}),Object.defineProperty(this,F,{writable:!0,value:void 0}),Object.defineProperty(this,N,{writable:!0,value:void 0}),Object.defineProperty(this,K,{writable:!0,value:void 0}),Object.defineProperty(this,B,{writable:!0,value:void 0}),Object.defineProperty(this,V,{writable:!0,value:void 0}),Object.defineProperty(this,G,{writable:!0,value:void 0}),Object.defineProperty(this,z,{writable:!0,value:void 0}),Object.defineProperty(this,J,{writable:!0,value:void 0}),Object.defineProperty(this,Y,{writable:!0,value:void 0}),Object.defineProperty(this,H,{writable:!0,value:void 0}),Object.defineProperty(this,Q,{writable:!0,value:void 0}),Object.defineProperty(this,X,{writable:!0,value:void 0}),Object.defineProperty(this,Z,{writable:!0,value:void 0}),Object.defineProperty(this,$,{writable:!0,value:void 0}),Object.defineProperty(this,ee,{writable:!0,value:void 0}),Object.defineProperty(this,te,{writable:!0,value:void 0}),Object.defineProperty(this,ie,{writable:!0,value:void 0}),_(this,A)[A]={},_(this,j)[j]="1.0.0",_(this,O)[O]="WalletConnect",_(this,W)[W]=n.WALLET_CONNECT_LOGO_DATA_URI,_(this,E)[E]=null,_(this,k)[k]=[],_(this,M)[M]="",_(this,x)[x]="",_(this,F)[F]=new Map,_(this,N)[N]=(e,t)=>(_(this,A)[A][e]?.push(t)||(_(this,A)[A][e]=[t]),()=>_(this,D)[D](e,t)),_(this,K)[K]=e=>{_(this,O)[O]=_(this,E)[E]?.session?.peer?.metadata?.name||_(this,U)[U]?.name||"WalletConnect",_(this,W)[W]=_(this,E)[E]?.session?.peer?.metadata?.icons?.[0]||_(this,U)[U]?.image_url?.sm||_(this,W)[W],_(this,k)[k]=e.map((e=>new m({address:e,publicKey:o.base58.decode(e),label:_(this,O)[O],icon:_(this,W)[W]}))),_(this,R)[R]("change",{accounts:this.accounts})},_(this,B)[B]=()=>{_(this,k)[k]=[],_(this,R)[R]("change",{accounts:this.accounts})},_(this,V)[V]=async()=>(this.accounts.length||await _(this,Q)[Q](),{accounts:this.accounts}),_(this,G)[G]=async()=>{await _(this,$)[$](),_(this,R)[R]("change",{accounts:this.accounts})},_(this,z)[z]=async(...e)=>{let t=[];for(let{account:i,message:r}of e){let e=o.base58.encode(r);try{let n=await _(this,ee)[ee]("solana_signMessage",{message:e,pubkey:i.address},oe("solana:mainnet"));t.push({signedMessage:r,signature:q(n)})}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await _(this,ee)[ee]("solana:signMessage",{message:e,pubkey:i.address},oe("solana:mainnet"));t.push({signedMessage:r,signature:q(n)})}throw n}}return t},_(this,J)[J]=async(...e)=>{let t=[];for(let{account:i,chain:r,transaction:n,options:s}of e){let e=o.base64.encode(n);try{let n=await _(this,ee)[ee]("solana_signAndSendTransaction",{transaction:e,pubkey:i.address,sendOptions:s},oe(r));t.push({signature:q(n)})}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await _(this,ee)[ee]("solana:signAndSendTransaction",{transaction:e,pubkey:i.address,sendOptions:s},oe(r));t.push({signature:q(n)})}}}return t},_(this,Y)[Y]=async(...e)=>{let t=[];for(let{account:i,chain:r,transaction:n}of e){let e=o.base64.encode(n);try{let n=await _(this,ee)[ee]("solana_signTransaction",{transaction:e,pubkey:i.address},oe(r||"solana:mainnet"));t.push({signedTransaction:P(n)})}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await _(this,ee)[ee]("solana:signTransaction",{transaction:e,pubkey:i.address},oe(r||"solana:mainnet"));t.push({signedTransaction:P(n)})}}}return t},_(this,H)[H]=async()=>{if(_(this,E)[E])return _(this,E)[E];if(!_(this,x)[x])throw Error("WalletConnect Cloud Project ID is required");return _(this,E)[E]=await u.UniversalProvider.init({projectId:_(this,x)[x],metadata:{name:_(this,M)[M],description:_(this,M)[M],url:window.location.origin,icons:[]},relayUrl:"wss://relay.walletconnect.com",telemetryEnabled:!1}),_(this,Z)[Z]("display_uri",_(this,te)[te]),_(this,Z)[Z]("session_delete",_(this,ie)[ie]),_(this,Z)[Z]("session_ping",(()=>{})),_(this,Z)[Z]("session_event",(()=>{})),_(this,Z)[Z]("session_update",(()=>{})),_(this,E)[E]},_(this,Q)[Q]=async()=>{if(!_(this,E)[E])throw Error("WalletConnectSolana: Failed to get or create session. Provider not initialized");if(_(this,E)[E].session)return _(this,E)[E].session;let e=await _(this,E)[E].connect({optionalNamespaces:{solana:{chains:[T,I],methods:["solana_signMessage","solana_signTransaction","solana_signAndSendTransaction"],events:[]}}});if(!e)throw Error("WalletConnectSolana: Failed to create new session");return _(this,K)[K](ae(e)),e},_(this,X)[X]=async()=>{let e=_(this,E)[E]?.session;if(e){if(!e.namespaces?.solana)return await(_(this,E)[E]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),void(_(this,E)[E].session=void 0);_(this,K)[K](ae(e))}},_(this,Z)[Z]=(e,t)=>{let i=_(this,F)[F].get(e);i&&(_(this,E)[E]?.off(e,i),_(this,F)[F].delete(e)),_(this,E)[E]?.on(e,t),_(this,F)[F].set(e,t)},_(this,$)[$]=async()=>{try{if(_(this,E)[E]?.session&&await(_(this,E)[E]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),_(this,E)[E]?.client){let e=_(this,E)[E].client.proposal.getAll();await Promise.allSettled(e.map((e=>_(this,E)[E]?.client.proposal.delete(e.id,{code:6e3,message:"User disconnected"}))));let t=_(this,E)[E].client.pairing.getAll();await Promise.allSettled(t.map((e=>_(this,E)[E]?.client.pairing.delete(e.topic,{code:6e3,message:"User disconnected"}))))}_(this,B)[B]()}catch(e){console.error("WalletConnectSolana: Error destroying session",e)}},_(this,ee)[ee]=async(e,t,i)=>{try{return await _(this,E)[E].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}},_(this,te)[te]=e=>{null==_(this,L)[L]||_(this,L)[L].call(this,{native:e,universal:void 0})},_(this,ie)[ie]=()=>{_(this,B)[B]()}}}function ne(e,...t){_(this,A)[A][e]?.forEach((e=>e.apply(null,t)))}function se(e,t){_(this,A)[A][e]=_(this,A)[A][e]?.filter((e=>t!==e))}function ae(e){return e.namespaces.solana.accounts.reduce(((e,t)=>{let i=t.split(":").at(-1);return e.includes(i)||e.push(i),e}),[])}function oe(e){switch(e){case"solana:mainnet":return T;case"solana:devnet":return I;default:return e}}var ce={id:n.SOLANA_FUNDING_PLUGIN_ID,getSolanaRpcClient:a.getSolanaRpcClient,createTransactionFromRelayQuote:async function({solanaClient:e,quote:t,source:i}){let r=t.steps[0]?.items?.[0];if(!r)throw Error("Invalid quote");let n=r.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:a}=await e.rpc.getLatestBlockhash().send(),o=s.pipe(s.createTransactionMessage({version:0}),(e=>s.setTransactionMessageFeePayerSigner({address:i},e)),(e=>s.setTransactionMessageLifetimeUsingBlockhash(a,e)),(e=>s.appendTransactionMessageInstructions(n,e)),(e=>s.compileTransaction(e)));return new Uint8Array(s.getTransactionEncoder().encode(o))},simulateTransaction:a.simulateTransaction,getAddressFromBuffer:a.getAddressFromBuffer,fetchTransactionEstimatedFees:a.fetchTransactionEstimatedFees};var le={id:n.SOLANA_LEDGER_PLUGIN_ID,createSiwsMemoTransaction:({address:e,nonce:t})=>{let i=c.getAddMemoInstruction({memo:n.prepareSiwsMessageWithNonce({address:s.address(e),nonce:t})});return s.pipe(s.createTransactionMessage({version:"legacy"}),(t=>s.setTransactionMessageFeePayer(s.address(e),t)),(e=>s.setTransactionMessageLifetimeUsingBlockhash({blockhash:s.blockhash("GfVcyD5fWFJ6hRm8bsy7CoVPsLSoJhtJKRJYk8T2VVFN"),lastValidBlockHeight:0n},e)),(e=>s.appendTransactionMessageInstructions([i],e)),(e=>s.compileTransaction(e)),(e=>o.base64.encode(Uint8Array.from(s.getTransactionEncoder().encode(e)))))},getSignatureFromTransaction:(e,t)=>{let i=s.getTransactionDecoder().decode(e).signatures[t];if(!i)throw Error(`Missing transaction signature for address: ${t}`);return o.base64.encode(i)}};exports.SolanaAdapterConnector=n.SolanaWalletConnector,exports.useExportWallet=a.useExportWallet,exports.useFundWallet=a.useFundWallet,exports.useStandardWallets=a.useSolanaStandardWallets,exports.useWallets=a.useWallets,exports.toSolanaWalletConnectors=e=>{let t,{get:i,on:r}=l.getWallets(),s=e?.shouldAutoConnect??!0,a=new n.SolanaWalletConnector(new re,s),o=new Map,c=[];function u(...e){e.forEach((e=>{!(e.features["privy:"]&&"isPrivyWallet"in e&&e.isPrivyWallet||o.has(e.name))&&e.chains.some((e=>"string"==typeof e&&e.startsWith("solana:")))&&o.set(e.name,e)})),c=Array.from(o.values()).map((e=>new n.SolanaWalletConnector(e,s))).concat(a),t?.(c)}function d(...e){Array.from(o.values()).forEach((t=>!e.includes(t)&&o.delete(t.name))),c=Array.from(o.values()).map((e=>new n.SolanaWalletConnector(e,s))).concat(a),t?.(c)}let h=[r("register",u),r("unregister",d)];return u(...i()),{_setOnConnectorsUpdated:e=>{t=e},onMount:()=>{h[0]||(h[0]=r("register",u)),h[1]||(h[1]=r("unregister",d))},onUnmount:()=>{let e=h.pop();for(;e;)e(),e=h.pop()},get:()=>c}},exports.useCreateWallet=function(){let{create:e}=t.useCreateWalletInternal();return{createWallet:async t=>{t&&"target"in t&&t&&(t=void 0);let{account:i}=await e({chainType:"solana",options:t});return{wallet:i}}}},exports.useImportWallet=()=>{let{user:s}=n.usePrivyContext(),{client:a,refreshSessionAndUser:o,initializeWalletProxy:c}=r.usePrivyInternal(),l=i.useEmitPrivyEvent(),u=i.useAppConfig();return{importWallet:e.useCallback((({privateKey:e,additionalSigners:i})=>t.importWallet({getAccessToken:()=>a.getAccessToken(),user:s,initializeWalletProxy:c,refreshSessionAndUser:o,emitPrivyEvent:l,appConfig:u},{privateKey:e,chainType:"solana",additionalSigners:i})),[s,a,o,c,l,u])}},exports.useSignAndSendTransaction=function(){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]}}},exports.useSignMessage=function(){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]}}},exports.useSignTransaction=function(){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]}}},exports.useSolanaFundingPlugin=()=>n.useRegisterPlugin(ce),exports.useSolanaLedgerPlugin=()=>n.useRegisterPlugin(le);