@privy-io/react-auth 3.2.1 → 3.3.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 (48) hide show
  1. package/dist/cjs/SignRequestScreen-CvBcoZRA.js +27 -0
  2. package/dist/cjs/abstract-smart-wallets.js +1 -1
  3. package/dist/cjs/extended-chains.js +1 -1
  4. package/dist/cjs/getEmbeddedConnectedWallet-6TsVZJkD.js +1 -0
  5. package/dist/cjs/index.js +5 -5
  6. package/dist/cjs/privy-context-NMR-GjnL.js +1 -0
  7. package/dist/cjs/{smart-wallets-7Aqc5Nzs.js → smart-wallets-Cgmp6lBz.js} +1 -1
  8. package/dist/cjs/smart-wallets.js +1 -1
  9. package/dist/cjs/solana.js +1 -1
  10. package/dist/cjs/ui.js +2 -2
  11. package/dist/cjs/{use-export-wallet-sK7TOD-_.js → use-export-wallet-Crjmwv6E.js} +1 -1
  12. package/dist/cjs/{useActiveWallet-BtCoqsEN.js → useActiveWallet-DAK4USsc.js} +1 -1
  13. package/dist/cjs/{usePrivy-B_0-uaxv.js → usePrivy-BQiDRA6a.js} +1 -1
  14. package/dist/dts/extended-chains.d.mts +1 -1
  15. package/dist/dts/extended-chains.d.ts +1 -1
  16. package/dist/dts/farcaster.d.mts +1 -1
  17. package/dist/dts/farcaster.d.ts +1 -1
  18. package/dist/dts/index.d.mts +25 -3
  19. package/dist/dts/index.d.ts +25 -3
  20. package/dist/dts/smart-wallets.d.mts +1 -1
  21. package/dist/dts/smart-wallets.d.ts +1 -1
  22. package/dist/dts/solana.d.mts +2 -2
  23. package/dist/dts/solana.d.ts +2 -2
  24. package/dist/dts/{types-DbYYrJGX.d.mts → types-C97UOzaM.d.mts} +18 -3
  25. package/dist/dts/{types-DbYYrJGX.d.ts → types-C97UOzaM.d.ts} +18 -3
  26. package/dist/dts/ui.d.mts +1 -1
  27. package/dist/dts/ui.d.ts +1 -1
  28. package/dist/esm/{SignRequestScreen-BFYRKL3N.mjs → SignRequestScreen-Dnn_x6kV.mjs} +21 -21
  29. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  30. package/dist/esm/extended-chains.mjs +1 -1
  31. package/dist/esm/getEmbeddedConnectedWallet-CM6cDQCS.mjs +1 -0
  32. package/dist/esm/index.mjs +6 -6
  33. package/dist/esm/privy-context-C7K3ZBW-.mjs +1 -0
  34. package/dist/esm/smart-wallets-D86YXRN5.mjs +1 -0
  35. package/dist/esm/smart-wallets.mjs +1 -1
  36. package/dist/esm/solana.mjs +1 -1
  37. package/dist/esm/ui.mjs +2 -2
  38. package/dist/esm/use-export-wallet-DVZxxj2x.mjs +1 -0
  39. package/dist/esm/{useActiveWallet-LdKZteNM.mjs → useActiveWallet-YrSgEFNG.mjs} +1 -1
  40. package/dist/esm/{usePrivy-DPEbjcra.mjs → usePrivy-CYAVrCyA.mjs} +1 -1
  41. package/package.json +4 -4
  42. package/dist/cjs/SignRequestScreen-BbqNYmhD.js +0 -27
  43. package/dist/cjs/getEmbeddedConnectedWallet-DTU4T9TJ.js +0 -1
  44. package/dist/cjs/privy-context-CJzQZH6s.js +0 -1
  45. package/dist/esm/getEmbeddedConnectedWallet-CSSBWE2p.mjs +0 -1
  46. package/dist/esm/privy-context-CTKe79J4.mjs +0 -1
  47. package/dist/esm/smart-wallets-kAXh6Vvw.mjs +0 -1
  48. package/dist/esm/use-export-wallet-BxcU5zVQ.mjs +0 -1
@@ -0,0 +1 @@
1
+ "use strict";var e=require("viem"),t=require("react"),i=require("./internal-context-DNWjSiYq.js");function a(e){return"string"==typeof e&&/^custom:[a-zA-Z0-9_-]+$/i.test(e)}function r(e){return e?new Date(1e3*e):null}function l(e,t){return e.slice().sort(((e,t)=>(e.firstVerifiedAt?.getTime()??0)-(t.firstVerifiedAt?.getTime()??0))).find((e=>e.type===t))}const n=e=>e?s(e).find((e=>0===e.walletIndex))??null:null,s=e=>e?m(e,"ethereum"):[],m=(e,t)=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&e.chainType===t)),d=e=>e?m(e,"solana"):[],p=e=>e?d(e).find((e=>0===e.walletIndex))??null:null;let o=(t,i)=>t===i||!(!t.startsWith("0x")||!i.startsWith("0x"))&&e.getAddress(t)===e.getAddress(i);const u=/*#__PURE__*/t.createContext({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:i.notImplemented,login:i.notImplemented,connectOrCreateWallet:i.notImplemented,linkEmail:i.notImplemented,linkPhone:i.notImplemented,linkFarcaster:i.notImplemented,linkWallet:i.notImplemented,startCrossAppAuthFlow:i.notImplemented,linkGoogle:i.notImplemented,linkTwitter:i.notImplemented,linkTwitch:i.notImplemented,linkDiscord:i.notImplemented,linkGithub:i.notImplemented,linkSpotify:i.notImplemented,linkInstagram:i.notImplemented,linkTelegram:i.notImplemented,linkTiktok:i.notImplemented,linkLine:i.notImplemented,linkLinkedIn:i.notImplemented,linkApple:i.notImplemented,linkPasskey:i.notImplemented,updateEmail:i.notImplemented,updatePhone:i.notImplemented,logout:i.notImplemented,getAccessToken:i.notImplemented,unlinkEmail:i.notImplemented,unlinkPhone:i.notImplemented,unlinkWallet:i.notImplemented,unlinkGoogle:i.notImplemented,unlinkTwitter:i.notImplemented,unlinkTwitch:i.notImplemented,unlinkDiscord:i.notImplemented,unlinkGithub:i.notImplemented,unlinkSpotify:i.notImplemented,unlinkInstagram:i.notImplemented,unlinkTiktok:i.notImplemented,unlinkLine:i.notImplemented,unlinkLinkedIn:i.notImplemented,unlinkApple:i.notImplemented,unlinkCrossAppAccount:i.notImplemented,unlinkFarcaster:i.notImplemented,unlinkTelegram:i.notImplemented,unlinkPasskey:i.notImplemented,signMessage:i.notImplemented,signTypedData:i.notImplemented,enrollInMfa:i.notImplemented,initEnrollmentWithSms:i.notImplemented,initEnrollmentWithTotp:i.notImplemented,initEnrollmentWithPasskey:i.notImplemented,promptMfa:i.notImplemented,init:i.notImplemented,submitEnrollmentWithSms:i.notImplemented,submitEnrollmentWithTotp:i.notImplemented,submitEnrollmentWithPasskey:i.notImplemented,unenroll:i.notImplemented,submit:i.notImplemented,cancel:i.notImplemented,sendTransaction:i.notImplemented,signTransaction:i.notImplemented,exportWallet:i.notImplemented,setWalletPassword:i.notImplemented,setWalletRecovery:i.notImplemented,requestFarcasterSignerFromWarpcast:i.notImplemented,getFarcasterSignerPublicKey:i.notImplemented,signFarcasterMessage:i.notImplemented,signMessageWithCrossAppWallet:i.notImplemented,signTypedDataWithCrossAppWallet:i.notImplemented,sendTransactionWithCrossAppWallet:i.notImplemented,signTransactionWithCrossAppWallet:i.notImplemented,isModalOpen:!1,mfaMethods:[]});exports.PrivyContext=u,exports.convertUserResponseToUser=function(e){if(!e)return null;let t=function(e){let t=[];for(let i of e){let e=i.type;switch(i.type){case"wallet":let l={id:i.id,address:i.address,type:i.type,imported:i.imported,delegated:i.delegated,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at),chainType:i.chain_type,walletClientType:i.wallet_client_type,connectorType:i.connector_type,recoveryMethod:i.recovery_method,walletIndex:i.wallet_index,publicKey:i.public_key};t.push(l);break;case"smart_wallet":let n={address:i.address,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at),smartWalletType:i.smart_wallet_type,smartWalletVersion:i.smart_wallet_version};t.push(n);break;case"cross_app":let s={type:i.type,subject:i.subject,embeddedWallets:i.embedded_wallets,smartWallets:i.smart_wallets,providerApp:{id:i.provider_app_id},firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(s);break;case"email":let m={address:i.address,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(m);break;case"phone":let d={number:i.phoneNumber,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(d);break;case"google_oauth":let p={subject:i.subject,email:i.email,name:i.name,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(p);break;case"spotify_oauth":let o={subject:i.subject,email:i.email,name:i.name,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(o);break;case"instagram_oauth":let u={subject:i.subject,username:i.username,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(u);break;case"twitter_oauth":let c={subject:i.subject,username:i.username,name:i.name,type:i.type,profilePictureUrl:i.profile_picture_url,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(c);break;case"discord_oauth":let f={subject:i.subject,username:i.username,email:i.email,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(f);break;case"github_oauth":let _={subject:i.subject,username:i.username,name:i.name,email:i.email,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(_);break;case"tiktok_oauth":let y={subject:i.subject,username:i.username,name:i.name,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(y);break;case"line_oauth":let h={subject:i.subject,name:i.name,email:i.email,profilePictureUrl:i.profile_picture_url,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(h);break;case"twitch_oauth":let b={subject:i.subject,username:i.username,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(b);break;case"linkedin_oauth":let I={subject:i.subject,name:i.name,email:i.email,vanityName:i.vanity_name,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(I);break;case"apple_oauth":let k={subject:i.subject,email:i.email,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(k);break;case"custom_auth":t.push({type:i.type,customUserId:i.custom_user_id,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)});break;case"farcaster":let v={type:i.type,fid:i.fid,ownerAddress:i.owner_address,displayName:i.display_name,username:i.username,bio:i.bio,pfp:i.profile_picture_url,url:i.homepage_url,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at),signerPublicKey:i.signer_public_key};t.push(v);break;case"passkey":let A={type:i.type,enrolledInMfa:i.enrolled_in_mfa,credentialId:i.credential_id,publicKey:i.public_key,authenticatorName:i.authenticator_name,createdWithDevice:i.created_with_device,createdWithOs:i.created_with_os,createdWithBrowser:i.created_with_browser,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(A);break;case"telegram":let g={type:i.type,telegramUserId:i.telegram_user_id,firstName:i.first_name,lastName:i.last_name,username:i.username,photoUrl:i.photo_url,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(g);break;default:if(a(i.type)){let e={type:i.type,subject:i.subject,name:i.name,username:i.username,email:i.email,profilePictureUrl:i.profile_picture_url,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(e);break}console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),i=l(t,"wallet"),n=l(t,"smart_wallet"),s=l(t,"email"),m=l(t,"phone"),d=l(t,"google_oauth"),p=l(t,"twitter_oauth"),o=l(t,"discord_oauth"),u=l(t,"github_oauth"),c=l(t,"spotify_oauth"),f=l(t,"instagram_oauth"),_=l(t,"tiktok_oauth"),y=l(t,"line_oauth"),h=l(t,"twitch_oauth"),b=l(t,"linkedin_oauth"),I=l(t,"apple_oauth"),k=l(t,"farcaster"),v=l(t,"telegram"),A=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:r(t)})));return{id:e.id,createdAt:r(e.created_at),linkedAccounts:t,email:s&&{address:s?.address},phone:m&&{number:m?.number},wallet:i&&{id:i.id,address:i.address,chainType:i.chainType,walletClientType:i.walletClientType,connectorType:i.connectorType,recoveryMethod:i.recoveryMethod,imported:i.imported,delegated:i.delegated,walletIndex:i.walletIndex,publicKey:i.publicKey},smartWallet:n&&{address:n.address,smartWalletType:n.smartWalletType,smartWalletVersion:n.smartWalletVersion},google:d&&{subject:d.subject,email:d.email,name:d.name},twitter:p&&{subject:p.subject,username:p.username,name:p.name,profilePictureUrl:p.profilePictureUrl},discord:o&&{subject:o.subject,username:o.username,email:o.email},github:u&&{subject:u.subject,username:u.username,name:u.name,email:u.email},spotify:c&&{subject:c.subject,email:c.email,name:c.name},instagram:f&&{subject:f.subject,username:f.username},tiktok:_&&{subject:_.subject,username:_.username,name:_.name},line:y&&{subject:y.subject,name:y.name,email:y.email,profilePictureUrl:y.profilePictureUrl},twitch:h&&{subject:h.subject,username:h.username},linkedin:b&&{subject:b.subject,name:b.name,email:b.email,vanityName:b.vanityName},apple:I&&{subject:I.subject,email:I.email},farcaster:k&&{fid:k.fid,ownerAddress:k.ownerAddress,displayName:k.displayName,username:k.username,bio:k.bio,pfp:k.pfp,url:k.url,signerPublicKey:k.signerPublicKey},telegram:v&&{telegramUserId:v.telegramUserId,firstName:v.firstName,lastName:v.lastName,username:v.username,photoUrl:v.photoUrl},delegatedWallets:[],mfaMethods:A.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}},exports.getAllPrivyWalletsForChainType=m,exports.getConnectedWalletWithAddress=(e,t)=>e.find((e=>o(e.address,t)))||null,exports.getImportedPrivyEthereumWallets=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType)),exports.getImportedPrivySolanaWallets=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType)),exports.getIsUnifiedWallet=e=>!!e.id&&"privy-v2"===e.recoveryMethod,exports.getPrivyEthereumHDWallets=s,exports.getPrivyEthereumWallet=n,exports.getPrivyPrimaryWallet=e=>n(e)??p(e),exports.getPrivySolanaHDWallets=d,exports.getPrivySolanaWallet=p,exports.getPrivyWalletWithAddress=(e,t)=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&o(e.address,t)))||null,exports.isCustomOAuthProvider=a,exports.usePrivyContext=()=>t.useContext(u);
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("viem"),r=require("./privy-context-CJzQZH6s.js"),n=require("./SignRequestScreen-BbqNYmhD.js"),a=require("./paths-B00ZrFQm.js"),i=require("./internal-context-DNWjSiYq.js"),s=require("./getEmbeddedConnectedWallet-DTU4T9TJ.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:r,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=n.getJsonRpcEndpointFromChain(e,u,p),f=t.createPublicClient({chain:e,transport:t.http(P)}),w=r??y.paymasterContext,I=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(!I)throw new a.PrivyClientError(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return I};exports.callsToTransactionRequests=g,exports.getSmartWalletClient=h,exports.useSmartWalletsUIWrapper=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:a}=i.usePrivyInternal(),{setModalData:s}=n.usePrivyModal(),{user:o}=r.usePrivyContext(),l=r.getPrivyEthereumWallet(o),c=!!l&&r.getIsUnifiedWallet(l);return{wrapSmartAccountClientWithUIs:r=>({...r,sendTransaction:async(i,d)=>{if(a({showWalletUIs:d?.uiOptions?.showWalletUIs}))return e.current=!0,await r.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(!r.paymaster)return!1;let{paymasterData:e,paymasterAndData:t}=await r.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(a,y)=>{e.current=!0;let{entropyId:m,entropyIdVerifier:h}=n.getEntropyDetailsForUser(o);s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:m,entropyIdVerifier:h,onCompleteNavigateTo:n.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:u,chain:r.chain,maxPriorityFeePerGas:i.maxPriorityFeePerGas,maxFeePerGas:i.maxFeePerGas,nonce:i.nonce?BigInt(i.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:m,entropyIdVerifier:h,getIsSponsored:p,signOnly:!1,onConfirm:()=>r.sendTransaction(i),onSuccess:e=>a(e.hash),onFailure:y,uiOptions:d?.uiOptions??{}}}),t(n.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))},signMessage:async(i,d)=>a({showWalletUIs:d?.uiOptions?.showWalletUIs})?(e.current=!0,await r.signMessage(i).finally((()=>e.current=!1))):new Promise((async(a,u)=>{let{entropyId:p,entropyIdVerifier:y}=n.getEntropyDetailsForUser(o);e.current=!0,s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof i.message?i.message:i.message.raw.toString(),confirmAndSign:()=>r.signMessage(i),onSuccess:e=>a(e),onFailure:u,uiOptions:d?.uiOptions??{}}}),t(n.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1})),signTypedData:async(i,d)=>a({showWalletUIs:d?.uiOptions?.showWalletUIs})?(e.current=!0,await r.signTypedData(i).finally((()=>e.current=!1))):new Promise((async(a,u)=>{e.current=!0;let{entropyId:p,entropyIdVerifier:y}=n.getEntropyDetailsForUser(o);s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:i,confirmAndSign:()=>r.signTypedData(i),onSuccess:e=>a(e),onFailure:u,uiOptions:d?.uiOptions??{}}}),t(n.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))})}},exports.useSmartWalletsWrapper=({clientConfig:t,smartWalletsConfig:o})=>{let{hideWalletUIs:l,openPrivyModal:c,appId:d,isHeadlessSigning:u}=i.usePrivyInternal(),p=n.useAppConfig(),{setModalData:y}=n.usePrivyModal(),{user:m}=r.usePrivyContext(),{chains:P}=n.useAppConfig(),{chainId:f,clients:w,setChainId:I,chainIdState:W}=(()=>{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===W)),{wallets:C}=n.useWallets(),S=r.getPrivyEthereumWallet(m),F=s.getEmbeddedConnectedWallet(C),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)}I(e)}),[P,t,C,m,o]);return{wrapSmartAccountClient:e=>{w.current[e.chain.id]=e,W||I(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let r=w.current[f.current];if(!r)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 r.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:n,maxFeePerGas:a,maxPriorityFeePerGas:s}=await r.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??n??0)>0};return new Promise((async(a,o)=>{l.current=!0;let{entropyId:d,entropyIdVerifier:u}=n.getEntropyDetailsForUser(m);y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:d,entropyIdVerifier:u,onCompleteNavigateTo:n.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:i,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:d,entropyIdVerifier:u,getIsSponsored:s,signOnly:!1,onConfirm:()=>r.sendTransaction(e),onSuccess:e=>a(e.hash),onFailure:o,uiOptions:t?.uiOptions??{}}}),c(n.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},signMessage:async(e,t)=>{let r=w.current[f.current];if(!r)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);return u({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await r.signMessage(e).finally((()=>l.current=!1))):new Promise((async(a,i)=>{let{entropyId:s,entropyIdVerifier:o}=n.getEntropyDetailsForUser(m);l.current=!0,y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:s,entropyIdVerifier:o,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof e.message?e.message:e.message.raw.toString(),confirmAndSign:()=>r.signMessage(e),onSuccess:e=>a(e),onFailure:i,uiOptions:t?.uiOptions??{}}}),c(n.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},signTypedData:async(e,t)=>{let r=w.current[f.current];if(!r)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 r.signTypedData(e).finally((()=>l.current=!1))):new Promise((async(a,i)=>{l.current=!0;let{entropyId:s,entropyIdVerifier:o}=n.getEntropyDetailsForUser(m);y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:s,entropyIdVerifier:o,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>a(e),onFailure:i,uiOptions:t?.uiOptions??{}}}),c(n.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},getChainId:T,chain:v,switchChain:U}}}};
1
+ "use strict";var e=require("react"),t=require("viem"),r=require("./privy-context-NMR-GjnL.js"),n=require("./SignRequestScreen-CvBcoZRA.js"),a=require("./paths-B00ZrFQm.js"),i=require("./internal-context-DNWjSiYq.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:r,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=n.getJsonRpcEndpointFromChain(e,u,p),f=t.createPublicClient({chain:e,transport:t.http(P)}),w=r??y.paymasterContext,I=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(!I)throw new a.PrivyClientError(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return I};exports.callsToTransactionRequests=g,exports.getSmartWalletClient=h,exports.useSmartWalletsUIWrapper=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:a}=i.usePrivyInternal(),{setModalData:s}=n.usePrivyModal(),{user:o}=r.usePrivyContext(),l=r.getPrivyEthereumWallet(o),c=!!l&&r.getIsUnifiedWallet(l);return{wrapSmartAccountClientWithUIs:r=>({...r,sendTransaction:async(i,d)=>{if(a({showWalletUIs:d?.uiOptions?.showWalletUIs}))return e.current=!0,await r.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(!r.paymaster)return!1;let{paymasterData:e,paymasterAndData:t}=await r.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(a,y)=>{e.current=!0;let{entropyId:m,entropyIdVerifier:h}=n.getEntropyDetailsForUser(o);s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:m,entropyIdVerifier:h,onCompleteNavigateTo:n.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:u,chain:r.chain,maxPriorityFeePerGas:i.maxPriorityFeePerGas,maxFeePerGas:i.maxFeePerGas,nonce:i.nonce?BigInt(i.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:m,entropyIdVerifier:h,getIsSponsored:p,signOnly:!1,onConfirm:()=>r.sendTransaction(i),onSuccess:e=>a(e.hash),onFailure:y,uiOptions:d?.uiOptions??{}}}),t(n.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))},signMessage:async(i,d)=>a({showWalletUIs:d?.uiOptions?.showWalletUIs})?(e.current=!0,await r.signMessage(i).finally((()=>e.current=!1))):new Promise((async(a,u)=>{let{entropyId:p,entropyIdVerifier:y}=n.getEntropyDetailsForUser(o);e.current=!0,s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof i.message?i.message:i.message.raw.toString(),confirmAndSign:()=>r.signMessage(i),onSuccess:e=>a(e),onFailure:u,uiOptions:d?.uiOptions??{}}}),t(n.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1})),signTypedData:async(i,d)=>a({showWalletUIs:d?.uiOptions?.showWalletUIs})?(e.current=!0,await r.signTypedData(i).finally((()=>e.current=!1))):new Promise((async(a,u)=>{e.current=!0;let{entropyId:p,entropyIdVerifier:y}=n.getEntropyDetailsForUser(o);s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:i,confirmAndSign:()=>r.signTypedData(i),onSuccess:e=>a(e),onFailure:u,uiOptions:d?.uiOptions??{}}}),t(n.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))})}},exports.useSmartWalletsWrapper=({clientConfig:t,smartWalletsConfig:o})=>{let{hideWalletUIs:l,openPrivyModal:c,appId:d,isHeadlessSigning:u}=i.usePrivyInternal(),p=n.useAppConfig(),{setModalData:y}=n.usePrivyModal(),{user:m}=r.usePrivyContext(),{chains:P}=n.useAppConfig(),{chainId:f,clients:w,setChainId:I,chainIdState:W}=(()=>{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===W)),{wallets:C}=n.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)}I(e)}),[P,t,C,m,o]);return{wrapSmartAccountClient:e=>{w.current[e.chain.id]=e,W||I(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let r=w.current[f.current];if(!r)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 r.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:n,maxFeePerGas:a,maxPriorityFeePerGas:s}=await r.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??n??0)>0};return new Promise((async(a,o)=>{l.current=!0;let{entropyId:d,entropyIdVerifier:u}=n.getEntropyDetailsForUser(m);y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:d,entropyIdVerifier:u,onCompleteNavigateTo:n.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:i,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:d,entropyIdVerifier:u,getIsSponsored:s,signOnly:!1,onConfirm:()=>r.sendTransaction(e),onSuccess:e=>a(e.hash),onFailure:o,uiOptions:t?.uiOptions??{}}}),c(n.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},signMessage:async(e,t)=>{let r=w.current[f.current];if(!r)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);return u({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await r.signMessage(e).finally((()=>l.current=!1))):new Promise((async(a,i)=>{let{entropyId:s,entropyIdVerifier:o}=n.getEntropyDetailsForUser(m);l.current=!0,y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:s,entropyIdVerifier:o,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof e.message?e.message:e.message.raw.toString(),confirmAndSign:()=>r.signMessage(e),onSuccess:e=>a(e),onFailure:i,uiOptions:t?.uiOptions??{}}}),c(n.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},signTypedData:async(e,t)=>{let r=w.current[f.current];if(!r)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 r.signTypedData(e).finally((()=>l.current=!1))):new Promise((async(a,i)=>{l.current=!0;let{entropyId:s,entropyIdVerifier:o}=n.getEntropyDetailsForUser(m);y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:s,entropyIdVerifier:o,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>a(e),onFailure:i,uiOptions:t?.uiOptions??{}}}),c(n.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("./privy-context-CJzQZH6s.js"),t=require("./SignRequestScreen-BbqNYmhD.js"),n=require("./paths-B00ZrFQm.js"),o=require("./getEmbeddedConnectedWallet-DTU4T9TJ.js"),c=require("./smart-wallets-7Aqc5Nzs.js"),a=require("./internal-context-DNWjSiYq.js");require("viem"),require("lucide-react"),require("styled-components"),require("@privy-io/urls"),require("@scure/base"),require("@privy-io/js-sdk-core"),require("tinycolor2"),require("@heroicons/react/24/outline/UserCircleIcon"),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("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),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/solid/CheckCircleIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("@heroicons/react/24/outline/CheckIcon"),require("qrcode"),require("viem/utils"),require("eventemitter3"),require("zustand"),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/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("ofetch"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("permissionless"),require("permissionless/accounts"),require("permissionless/clients/pimlico"),require("viem/account-abstraction");let l=/*#__PURE__*/r.createContext({client:void 0,getClientForChain:a.notImplemented});let s=/*#__PURE__*/r.createContext({config:void 0}),u=()=>{let{config:e}=r.useContext(s);return{config:e}},h=({children:i})=>{let[t,n]=r.useState(void 0),{client:o}=a.usePrivyInternal();return r.useEffect((()=>{!t&&o&&(async()=>{try{if(!o)return void console.warn("No client found");let e=await o.getSmartWalletsConfig();n(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!o]),/*#__PURE__*/e.jsx(s.Provider,{value:{config:t},children:i})},d=({config:l,children:s})=>{let{config:h}=u(),{appId:d}=a.usePrivyInternal(),{chains:C,defaultChain:g,rpcConfig:m}=t.useAppConfig(),{wallets:f}=t.useWallets(),{user:p}=i.usePrivyContext(),[I,v]=r.useState(),{wrapSmartAccountClientWithUIs:w}=c.useSmartWalletsUIWrapper(),y=i.getPrivyEthereumWallet(p),W=o.getEmbeddedConnectedWallet(f);r.useEffect((()=>{(async()=>{if(!h?.enabled)return;let e=h.configuredNetworks.find((e=>e.chainId===`eip155:${g.id}`))?g:C.find((e=>h.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.");v(await c.getSmartWalletClient({chain:e,privyAppId:d,paymasterContext:l?.paymasterContext,rpcConfig:m,account:y,signer:await(W?.getEthereumProvider()),user:p,smartWalletsConfig:h}))})()}),[!!h?.enabled,!!p?.smartWallet,!!W,!!y]);/*#__PURE__*/return e.jsx(q.Provider,{value:{client:I,config:l,getClientForChain:async({id:e})=>{let r=await c.getSmartWalletClient({chain:C.find((r=>r.id===e)),privyAppId:d,paymasterContext:l?.paymasterContext,rpcConfig:m,account:y,signer:await(W?.getEthereumProvider()),user:p,smartWalletsConfig:h});if(!r)throw new n.PrivyClientError(`Failed to create smart wallet client for chain id: ${e}`);return w(r)}},children:s})},q=/*#__PURE__*/r.createContext({client:void 0,config:void 0,getClientForChain:a.notImplemented}),C=({children:t})=>{let{client:n,config:o,getClientForChain:s}=(()=>{let{client:e,config:i,getClientForChain:t}=r.useContext(q);return{client:e,config:i,getClientForChain:t}})(),{config:h}=u(),{wrapSmartAccountClient:d}=c.useSmartWalletsWrapper({clientConfig:o,smartWalletsConfig:h}),{user:C}=i.usePrivyContext(),{generateSiweMessageForSmartWallet:g,linkSmartWallet:m,hideWalletUIs:f}=a.usePrivyInternal();return r.useEffect((()=>{(async()=>{if(n&&C&&!C?.smartWallet&&h?.enabled)try{let e=await g({address:n.account.address,chainId:`eip155:${n.chain.id}`});f.current=!0;let r=await n.signMessage({message:e});await m({signature:r,message:e,smartWalletType:h.smartWalletType,smartWalletVersion:h.smartWalletVersion})}catch(e){console.error("Error creating smart wallet:",e)}finally{f.current=!1}})()}),[!!n,!!C?.smartWallet,!!h?.enabled]),/*#__PURE__*/e.jsx(l.Provider,{value:{client:C?.smartWallet&&n?d(n):void 0,getClientForChain:s},children:t})};exports.SmartWalletsProvider=({config:r,children:i})=>/*#__PURE__*/e.jsx(h,{children:/*#__PURE__*/e.jsx(d,{config:r,children:/*#__PURE__*/e.jsx(C,{children:i})})}),exports.useSmartWallets=()=>{let{client:e,getClientForChain:i}=r.useContext(l);return{client:e,getClientForChain:i}};
1
+ "use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("./privy-context-NMR-GjnL.js"),t=require("./SignRequestScreen-CvBcoZRA.js"),n=require("./paths-B00ZrFQm.js"),o=require("./getEmbeddedConnectedWallet-6TsVZJkD.js"),c=require("./smart-wallets-Cgmp6lBz.js"),a=require("./internal-context-DNWjSiYq.js");require("viem"),require("lucide-react"),require("styled-components"),require("@privy-io/urls"),require("@scure/base"),require("@privy-io/js-sdk-core"),require("tinycolor2"),require("@heroicons/react/24/outline/UserCircleIcon"),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("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),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/solid/CheckCircleIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("@heroicons/react/24/outline/CheckIcon"),require("qrcode"),require("viem/utils"),require("eventemitter3"),require("zustand"),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/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("ofetch"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("permissionless"),require("permissionless/accounts"),require("permissionless/clients/pimlico"),require("viem/account-abstraction");let l=/*#__PURE__*/r.createContext({client:void 0,getClientForChain:a.notImplemented});let s=/*#__PURE__*/r.createContext({config:void 0}),u=()=>{let{config:e}=r.useContext(s);return{config:e}},d=({children:i})=>{let[t,n]=r.useState(void 0),{client:o}=a.usePrivyInternal();return r.useEffect((()=>{!t&&o&&(async()=>{try{if(!o)return void console.warn("No client found");let e=await o.getSmartWalletsConfig();n(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!o]),/*#__PURE__*/e.jsx(s.Provider,{value:{config:t},children:i})},h=({config:l,children:s})=>{let{config:d}=u(),{appId:h}=a.usePrivyInternal(),{chains:C,defaultChain:g,rpcConfig:m}=t.useAppConfig(),{wallets:f}=t.useWallets(),{user:p}=i.usePrivyContext(),[I,v]=r.useState(),{wrapSmartAccountClientWithUIs:w}=c.useSmartWalletsUIWrapper(),y=i.getPrivyEthereumWallet(p),W=o.getEmbeddedConnectedWalletWithAddress(f,y?.address);r.useEffect((()=>{(async()=>{if(!d?.enabled)return;let e=d.configuredNetworks.find((e=>e.chainId===`eip155:${g.id}`))?g:C.find((e=>d.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.");v(await c.getSmartWalletClient({chain:e,privyAppId:h,paymasterContext:l?.paymasterContext,rpcConfig:m,account:y,signer:await(W?.getEthereumProvider()),user:p,smartWalletsConfig:d}))})()}),[!!d?.enabled,!!p?.smartWallet,!!W,!!y]);/*#__PURE__*/return e.jsx(q.Provider,{value:{client:I,config:l,getClientForChain:async({id:e})=>{let r=await c.getSmartWalletClient({chain:C.find((r=>r.id===e)),privyAppId:h,paymasterContext:l?.paymasterContext,rpcConfig:m,account:y,signer:await(W?.getEthereumProvider()),user:p,smartWalletsConfig:d});if(!r)throw new n.PrivyClientError(`Failed to create smart wallet client for chain id: ${e}`);return w(r)}},children:s})},q=/*#__PURE__*/r.createContext({client:void 0,config:void 0,getClientForChain:a.notImplemented}),C=({children:t})=>{let{client:n,config:o,getClientForChain:s}=(()=>{let{client:e,config:i,getClientForChain:t}=r.useContext(q);return{client:e,config:i,getClientForChain:t}})(),{config:d}=u(),{wrapSmartAccountClient:h}=c.useSmartWalletsWrapper({clientConfig:o,smartWalletsConfig:d}),{user:C}=i.usePrivyContext(),{generateSiweMessageForSmartWallet:g,linkSmartWallet:m,hideWalletUIs:f}=a.usePrivyInternal();return r.useEffect((()=>{(async()=>{if(n&&C&&!C?.smartWallet&&d?.enabled)try{let e=await g({address:n.account.address,chainId:`eip155:${n.chain.id}`});f.current=!0;let r=await n.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}})()}),[!!n,!!C?.smartWallet,!!d?.enabled]),/*#__PURE__*/e.jsx(l.Provider,{value:{client:C?.smartWallet&&n?h(n):void 0,getClientForChain:s},children:t})};exports.SmartWalletsProvider=({config:r,children:i})=>/*#__PURE__*/e.jsx(d,{children:/*#__PURE__*/e.jsx(h,{config:r,children:/*#__PURE__*/e.jsx(C,{children:i})})}),exports.useSmartWallets=()=>{let{client:e,getClientForChain:i}=r.useContext(l);return{client:e,getClientForChain:i}};
@@ -1 +1 @@
1
- "use strict";var e=require("react"),r=require("./usePrivy-B_0-uaxv.js"),n=require("./SignRequestScreen-BbqNYmhD.js"),t=require("./internal-context-DNWjSiYq.js"),o=require("./privy-context-CJzQZH6s.js"),i=require("@solana/kit"),a=require("./use-export-wallet-sK7TOD-_.js"),s=require("@scure/base"),c=require("@solana-program/memo"),u=require("@wallet-standard/app");require("./paths-B00ZrFQm.js"),require("ofetch"),require("@privy-io/js-sdk-core"),require("react/jsx-runtime"),require("lucide-react"),require("styled-components"),require("@privy-io/urls"),require("viem"),require("tinycolor2"),require("@heroicons/react/24/outline/UserCircleIcon"),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("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),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/solid/CheckCircleIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("@heroicons/react/24/outline/CheckIcon"),require("qrcode"),require("viem/utils"),require("eventemitter3"),require("zustand"),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/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/outline/FingerPrintIcon"),require("./use-sign-with-user-signer-Q0_LRVtz.js"),require("@solana-program/system"),require("@solana-program/token");var l={id:n.SOLANA_FUNDING_PLUGIN_ID,getSolanaRpcClient:a.getSolanaRpcClient,createTransactionFromRelayQuote:async function({solanaClient:e,quote:r,source:n}){let t=r.steps[0]?.items?.[0];if(!t)throw Error("Invalid quote");let o=t.data.instructions.map((({keys:e,programId:r,data:n})=>({accounts:e.map((({pubkey:e,isSigner:r,isWritable:n})=>({address:e,role:r&&n?3:r&&!n?2:!r&&n?1:0}))),programAddress:r,data:new Uint8Array(Buffer.from(n,"hex"))}))),{value:a}=await e.rpc.getLatestBlockhash().send(),s=i.pipe(i.createTransactionMessage({version:0}),(e=>i.setTransactionMessageFeePayerSigner({address:n},e)),(e=>i.setTransactionMessageLifetimeUsingBlockhash(a,e)),(e=>i.appendTransactionMessageInstructions(o,e)),(e=>i.compileTransaction(e)));return new Uint8Array(i.getTransactionEncoder().encode(s))},simulateTransaction:a.simulateTransaction,getAddressFromBuffer:a.getAddressFromBuffer,fetchTransactionEstimatedFees:a.fetchTransactionEstimatedFees};var d={id:n.SOLANA_LEDGER_PLUGIN_ID,createSiwsMemoTransaction:({address:e,nonce:r})=>{let t=c.getAddMemoInstruction({memo:n.prepareSiwsMessageWithNonce({address:i.address(e),nonce:r})});return i.pipe(i.createTransactionMessage({version:"legacy"}),(r=>i.setTransactionMessageFeePayer(i.address(e),r)),(e=>i.setTransactionMessageLifetimeUsingBlockhash({blockhash:i.blockhash("GfVcyD5fWFJ6hRm8bsy7CoVPsLSoJhtJKRJYk8T2VVFN"),lastValidBlockHeight:0n},e)),(e=>i.appendTransactionMessageInstructions([t],e)),(e=>i.compileTransaction(e)),(e=>s.base64.encode(Uint8Array.from(i.getTransactionEncoder().encode(e)))))},getSignatureFromTransaction:(e,r)=>{let n=i.getTransactionDecoder().decode(e).signatures[r];if(!n)throw Error(`Missing transaction signature for address: ${r}`);return s.base64.encode(n)}};exports.SolanaAdapterConnector=n.SolanaWalletConnector,exports.useExportWallet=a.useExportWallet,exports.useFundWallet=a.useFundWallet,exports.useStandardWallets=a.useSolanaStandardWallets,exports.useWallets=a.useWallets,exports.toSolanaWalletConnectors=e=>{let r,{get:t,on:o}=u.getWallets(),i=e?.shouldAutoConnect??!0,a=new Map,s=[];function c(...e){e.forEach((e=>!(e.features["privy:"]&&"isPrivyWallet"in e&&e.isPrivyWallet)&&!a.has(e.name)&&a.set(e.name,e))),s=Array.from(a.values()).map((e=>new n.SolanaWalletConnector(e,i))),r?.(s)}function l(...e){Array.from(a.values()).forEach((r=>!e.includes(r)&&a.delete(r.name))),s=Array.from(a.values()).map((e=>new n.SolanaWalletConnector(e,i))),r?.(s)}let d=[o("register",c),o("unregister",l)];return c(...t()),{_setOnConnectorsUpdated:e=>{r=e},onMount:()=>{d[0]||(d[0]=o("register",c)),d[1]||(d[1]=o("unregister",l))},onUnmount:()=>{let e=d.pop();for(;e;)e(),e=d.pop()},get:()=>s}},exports.useCreateWallet=function(){let{create:e}=r.useCreateWalletInternal();return{createWallet:async r=>{r&&"target"in r&&r&&(r=void 0);let{account:n}=await e({chainType:"solana",options:r});return{wallet:n}}}},exports.useImportWallet=()=>{let{user:i}=o.usePrivyContext(),{client:a,refreshSessionAndUser:s,initializeWalletProxy:c}=t.usePrivyInternal(),u=n.useEmitPrivyEvent(),l=n.useAppConfig();return{importWallet:e.useCallback((({privateKey:e,additionalSigners:n})=>r.importWallet({getAccessToken:()=>a.getAccessToken(),user:i,initializeWalletProxy:c,refreshSessionAndUser:s,emitPrivyEvent:u,appConfig:l},{privateKey:e,chainType:"solana",additionalSigners:n})),[i,a,s,c,u,l])}},exports.useSignAndSendTransaction=function(){return{signAndSendTransaction:async function(...e){let r=[];for(let n of e)r.push(await n.wallet.signAndSendTransaction({...n,chain:n.chain||"solana:mainnet"}));return 1===e.length?r[0]:[...r]}}},exports.useSignMessage=function(){return{signMessage:async function(...e){let r=[];for(let n of e)r.push(await n.wallet.signMessage({...n,options:n.options}));return 1===e.length?r[0]:[...r]}}},exports.useSignTransaction=function(){return{signTransaction:async function(...e){let r=[];for(let n of e)r.push(await n.wallet.signTransaction({...n,chain:n.chain||"solana:mainnet"}));return 1===e.length?r[0]:[...r]}}},exports.useSolanaFundingPlugin=()=>n.useRegisterPlugin(l),exports.useSolanaLedgerPlugin=()=>n.useRegisterPlugin(d);
1
+ "use strict";var e=require("react"),r=require("./usePrivy-BQiDRA6a.js"),n=require("./SignRequestScreen-CvBcoZRA.js"),t=require("./internal-context-DNWjSiYq.js"),o=require("./privy-context-NMR-GjnL.js"),i=require("@solana/kit"),a=require("./use-export-wallet-Crjmwv6E.js"),s=require("@scure/base"),c=require("@solana-program/memo"),u=require("@wallet-standard/app");require("./paths-B00ZrFQm.js"),require("ofetch"),require("@privy-io/js-sdk-core"),require("react/jsx-runtime"),require("lucide-react"),require("styled-components"),require("@privy-io/urls"),require("viem"),require("tinycolor2"),require("@heroicons/react/24/outline/UserCircleIcon"),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("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),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/solid/CheckCircleIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("@heroicons/react/24/outline/CheckIcon"),require("qrcode"),require("viem/utils"),require("eventemitter3"),require("zustand"),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/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/outline/FingerPrintIcon"),require("./use-sign-with-user-signer-Q0_LRVtz.js"),require("@solana-program/system"),require("@solana-program/token");var l={id:n.SOLANA_FUNDING_PLUGIN_ID,getSolanaRpcClient:a.getSolanaRpcClient,createTransactionFromRelayQuote:async function({solanaClient:e,quote:r,source:n}){let t=r.steps[0]?.items?.[0];if(!t)throw Error("Invalid quote");let o=t.data.instructions.map((({keys:e,programId:r,data:n})=>({accounts:e.map((({pubkey:e,isSigner:r,isWritable:n})=>({address:e,role:r&&n?3:r&&!n?2:!r&&n?1:0}))),programAddress:r,data:new Uint8Array(Buffer.from(n,"hex"))}))),{value:a}=await e.rpc.getLatestBlockhash().send(),s=i.pipe(i.createTransactionMessage({version:0}),(e=>i.setTransactionMessageFeePayerSigner({address:n},e)),(e=>i.setTransactionMessageLifetimeUsingBlockhash(a,e)),(e=>i.appendTransactionMessageInstructions(o,e)),(e=>i.compileTransaction(e)));return new Uint8Array(i.getTransactionEncoder().encode(s))},simulateTransaction:a.simulateTransaction,getAddressFromBuffer:a.getAddressFromBuffer,fetchTransactionEstimatedFees:a.fetchTransactionEstimatedFees};var d={id:n.SOLANA_LEDGER_PLUGIN_ID,createSiwsMemoTransaction:({address:e,nonce:r})=>{let t=c.getAddMemoInstruction({memo:n.prepareSiwsMessageWithNonce({address:i.address(e),nonce:r})});return i.pipe(i.createTransactionMessage({version:"legacy"}),(r=>i.setTransactionMessageFeePayer(i.address(e),r)),(e=>i.setTransactionMessageLifetimeUsingBlockhash({blockhash:i.blockhash("GfVcyD5fWFJ6hRm8bsy7CoVPsLSoJhtJKRJYk8T2VVFN"),lastValidBlockHeight:0n},e)),(e=>i.appendTransactionMessageInstructions([t],e)),(e=>i.compileTransaction(e)),(e=>s.base64.encode(Uint8Array.from(i.getTransactionEncoder().encode(e)))))},getSignatureFromTransaction:(e,r)=>{let n=i.getTransactionDecoder().decode(e).signatures[r];if(!n)throw Error(`Missing transaction signature for address: ${r}`);return s.base64.encode(n)}};exports.SolanaAdapterConnector=n.SolanaWalletConnector,exports.useExportWallet=a.useExportWallet,exports.useFundWallet=a.useFundWallet,exports.useStandardWallets=a.useSolanaStandardWallets,exports.useWallets=a.useWallets,exports.toSolanaWalletConnectors=e=>{let r,{get:t,on:o}=u.getWallets(),i=e?.shouldAutoConnect??!0,a=new Map,s=[];function c(...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)})),s=Array.from(a.values()).map((e=>new n.SolanaWalletConnector(e,i))),r?.(s)}function l(...e){Array.from(a.values()).forEach((r=>!e.includes(r)&&a.delete(r.name))),s=Array.from(a.values()).map((e=>new n.SolanaWalletConnector(e,i))),r?.(s)}let d=[o("register",c),o("unregister",l)];return c(...t()),{_setOnConnectorsUpdated:e=>{r=e},onMount:()=>{d[0]||(d[0]=o("register",c)),d[1]||(d[1]=o("unregister",l))},onUnmount:()=>{let e=d.pop();for(;e;)e(),e=d.pop()},get:()=>s}},exports.useCreateWallet=function(){let{create:e}=r.useCreateWalletInternal();return{createWallet:async r=>{r&&"target"in r&&r&&(r=void 0);let{account:n}=await e({chainType:"solana",options:r});return{wallet:n}}}},exports.useImportWallet=()=>{let{user:i}=o.usePrivyContext(),{client:a,refreshSessionAndUser:s,initializeWalletProxy:c}=t.usePrivyInternal(),u=n.useEmitPrivyEvent(),l=n.useAppConfig();return{importWallet:e.useCallback((({privateKey:e,additionalSigners:n})=>r.importWallet({getAccessToken:()=>a.getAccessToken(),user:i,initializeWalletProxy:c,refreshSessionAndUser:s,emitPrivyEvent:u,appConfig:l},{privateKey:e,chainType:"solana",additionalSigners:n})),[i,a,s,c,u,l])}},exports.useSignAndSendTransaction=function(){return{signAndSendTransaction:async function(...e){let r=[];for(let n of e)r.push(await n.wallet.signAndSendTransaction({...n,chain:n.chain||"solana:mainnet"}));return 1===e.length?r[0]:[...r]}}},exports.useSignMessage=function(){return{signMessage:async function(...e){let r=[];for(let n of e)r.push(await n.wallet.signMessage({...n,options:n.options}));return 1===e.length?r[0]:[...r]}}},exports.useSignTransaction=function(){return{signTransaction:async function(...e){let r=[];for(let n of e)r.push(await n.wallet.signTransaction({...n,chain:n.chain||"solana:mainnet"}));return 1===e.length?r[0]:[...r]}}},exports.useSolanaFundingPlugin=()=>n.useRegisterPlugin(l),exports.useSolanaLedgerPlugin=()=>n.useRegisterPlugin(d);