@privy-io/react-auth 3.3.0 → 3.4.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 (42) hide show
  1. package/dist/cjs/{SignRequestScreen-CvBcoZRA.js → SignRequestScreen-BtiA_kjR.js} +19 -19
  2. package/dist/cjs/abstract-smart-wallets.js +1 -1
  3. package/dist/cjs/index.js +7 -7
  4. package/dist/cjs/{smart-wallets-Cgmp6lBz.js → smart-wallets-CT6HYICU.js} +1 -1
  5. package/dist/cjs/smart-wallets.js +1 -1
  6. package/dist/cjs/solana.js +1 -1
  7. package/dist/cjs/ui.js +1 -1
  8. package/dist/cjs/use-export-wallet-C_4yZPUM.js +2 -0
  9. package/dist/cjs/{useActiveWallet-DAK4USsc.js → useActiveWallet-DygS7fQB.js} +1 -1
  10. package/dist/cjs/{usePrivy-BQiDRA6a.js → usePrivy-8s4mCLcX.js} +1 -1
  11. package/dist/dts/extended-chains.d.mts +1 -1
  12. package/dist/dts/extended-chains.d.ts +1 -1
  13. package/dist/dts/farcaster.d.mts +1 -1
  14. package/dist/dts/farcaster.d.ts +1 -1
  15. package/dist/dts/index.d.mts +6 -4
  16. package/dist/dts/index.d.ts +6 -4
  17. package/dist/dts/smart-wallets.d.mts +2 -2
  18. package/dist/dts/smart-wallets.d.ts +2 -2
  19. package/dist/dts/solana.d.mts +4 -5
  20. package/dist/dts/solana.d.ts +4 -5
  21. package/dist/dts/{types-C97UOzaM.d.mts → types-tFJ_e9u8.d.mts} +5 -5
  22. package/dist/dts/{types-C97UOzaM.d.ts → types-tFJ_e9u8.d.ts} +5 -5
  23. package/dist/dts/ui.d.mts +1 -1
  24. package/dist/dts/ui.d.ts +1 -1
  25. package/dist/esm/{SignRequestScreen-Dnn_x6kV.mjs → SignRequestScreen-Dkx-HBRI.mjs} +17 -17
  26. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  27. package/dist/esm/extended-chains.mjs +1 -1
  28. package/dist/esm/farcaster.mjs +1 -1
  29. package/dist/esm/index.mjs +4 -4
  30. package/dist/esm/{internal-context-LlMdpfkb.mjs → internal-context-CfE_S5P-.mjs} +1 -1
  31. package/dist/esm/{privy-context-C7K3ZBW-.mjs → privy-context-DDSW3jEM.mjs} +1 -1
  32. package/dist/esm/{smart-wallets-D86YXRN5.mjs → smart-wallets-BElFh8An.mjs} +1 -1
  33. package/dist/esm/smart-wallets.mjs +1 -1
  34. package/dist/esm/solana.mjs +1 -1
  35. package/dist/esm/ui.mjs +2 -2
  36. package/dist/esm/use-export-wallet-OoiI5as_.mjs +1 -0
  37. package/dist/esm/{use-sign-with-user-signer-DwqsbciW.mjs → use-sign-with-user-signer-DVcbjNtZ.mjs} +1 -1
  38. package/dist/esm/{useActiveWallet-YrSgEFNG.mjs → useActiveWallet-BjD-txC9.mjs} +1 -1
  39. package/dist/esm/{usePrivy-CYAVrCyA.mjs → usePrivy-BJYprMT0.mjs} +1 -1
  40. package/package.json +6 -6
  41. package/dist/cjs/use-export-wallet-Crjmwv6E.js +0 -2
  42. package/dist/esm/use-export-wallet-DVZxxj2x.mjs +0 -1
@@ -1 +1 @@
1
- import{createContext as t,useContext as e}from"react";const i=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},a=t=>()=>{throw Error(t.trim())},n=/*#__PURE__*/t({setAuthenticated:i,setUser:i,setIsNewUser:i,isNewUserThisSession:!1,walletConnectionStatus:null,setWalletConnectionStatus:i,connectors:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,privy:null,appId:"notAdded",onCustomAuthAuthenticated:i,hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:i,initializeWalletProxy:i,getAuthMeta:i,getAuthFlow:i,closePrivyModal:i,openPrivyModal:i,connectWallet:i,initLoginWithWallet:i,loginWithWallet:i,initLoginWithFarcaster:i,loginWithFarcaster:i,loginWithCode:i,initLoginWithEmail:i,initLoginWithSms:i,initUpdateEmail:i,initUpdatePhone:i,resendEmailCode:i,resendSmsCode:i,initLoginWithHeadlessOAuth:i,loginWithHeadlessOAuth:i,crossAppAuthFlow:i,initLoginWithOAuth:i,loginWithOAuth:i,passkeyAuthState:{status:"initial"},setPasskeyAuthState:i,initSignupWithPasskey:i,signupWithPasskey:i,initLoginWithPasskey:i,loginWithPasskey:i,initLinkWithPasskey:i,linkWithPasskey:i,refreshSessionAndUser:i,walletProxy:null,createAnalyticsEvent:i,acceptTerms:i,getUsdTokenPrice:i,getUsdPriceForSol:i,getSplTokenMetadata:i,recoverEmbeddedWallet:i,updateWallets:i,fundWallet:i,openModal:i,setReadyToTrue:i,requestFarcasterSignerStatus:i,initLoginWithTelegram:i,loginWithTelegram:i,generateSiweMessage:i,generateSiweMessageForSmartWallet:i,loginWithSiwe:i,linkWithSiwe:i,linkSmartWallet:i,delegateWallet:i,revokeDelegatedWallets:i,connectCoinbaseSmartWallet:i,connectBaseAccount:i,initiateAccountTransfer:i,emailOtpState:{status:"initial"},setEmailOtpState:i,smsOtpState:{status:"initial"},setSmsOtpState:i,siweState:{status:"initial"},setSiweState:i,oAuthState:{status:"initial"},setOAuthState:i,telegramAuthState:{status:"initial"},setTelegramAuthState:i,isHeadlessOAuthLoading:!1,isHeadlessSigning:i,inProgressAuthFlowRef:{current:null},inProgressLoginOrLinkMethodRef:{current:null},baseAccountSdk:void 0,setBaseAccountSdk:i}),s=()=>e(n);export{n as I,a,i as n,s as u};
1
+ import{useContext as t,createContext as e}from"react";const i=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},a=t=>()=>{throw Error(t.trim())},n=/*#__PURE__*/e({setAuthenticated:i,setUser:i,setIsNewUser:i,isNewUserThisSession:!1,walletConnectionStatus:null,setWalletConnectionStatus:i,connectors:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,privy:null,appId:"notAdded",onCustomAuthAuthenticated:i,hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:i,initializeWalletProxy:i,getAuthMeta:i,getAuthFlow:i,closePrivyModal:i,openPrivyModal:i,connectWallet:i,initLoginWithWallet:i,loginWithWallet:i,initLoginWithFarcaster:i,loginWithFarcaster:i,loginWithCode:i,initLoginWithEmail:i,initLoginWithSms:i,initUpdateEmail:i,initUpdatePhone:i,resendEmailCode:i,resendSmsCode:i,initLoginWithHeadlessOAuth:i,loginWithHeadlessOAuth:i,crossAppAuthFlow:i,initLoginWithOAuth:i,loginWithOAuth:i,passkeyAuthState:{status:"initial"},setPasskeyAuthState:i,initSignupWithPasskey:i,signupWithPasskey:i,initLoginWithPasskey:i,loginWithPasskey:i,initLinkWithPasskey:i,linkWithPasskey:i,refreshSessionAndUser:i,walletProxy:null,createAnalyticsEvent:i,acceptTerms:i,getUsdTokenPrice:i,getUsdPriceForSol:i,getSplTokenMetadata:i,recoverEmbeddedWallet:i,updateWallets:i,fundWallet:i,openModal:i,setReadyToTrue:i,requestFarcasterSignerStatus:i,initLoginWithTelegram:i,loginWithTelegram:i,generateSiweMessage:i,generateSiweMessageForSmartWallet:i,loginWithSiwe:i,linkWithSiwe:i,linkSmartWallet:i,delegateWallet:i,revokeDelegatedWallets:i,connectCoinbaseSmartWallet:i,connectBaseAccount:i,initiateAccountTransfer:i,emailOtpState:{status:"initial"},setEmailOtpState:i,smsOtpState:{status:"initial"},setSmsOtpState:i,siweState:{status:"initial"},setSiweState:i,oAuthState:{status:"initial"},setOAuthState:i,telegramAuthState:{status:"initial"},setTelegramAuthState:i,isHeadlessOAuthLoading:!1,isHeadlessSigning:i,inProgressAuthFlowRef:{current:null},inProgressLoginOrLinkMethodRef:{current:null},baseAccountSdk:void 0,setBaseAccountSdk:i}),s=()=>t(n);export{n as I,a,i as n,s as u};
@@ -1 +1 @@
1
- import{getAddress as e}from"viem";import{createContext as t,useContext as i}from"react";import{n as a}from"./internal-context-LlMdpfkb.mjs";function r(e){return"string"==typeof e&&/^custom:[a-zA-Z0-9_-]+$/i.test(e)}function s(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?d(e).find((e=>0===e.walletIndex))??null:null,d=e=>e?u(e,"ethereum"):[],u=(e,t)=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&e.chainType===t)),p=e=>e?u(e,"solana"):[],m=e=>e?p(e).find((e=>0===e.walletIndex))??null:null,c=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType)),o=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType));let f=(t,i)=>t===i||!(!t.startsWith("0x")||!i.startsWith("0x"))&&e(t)===e(i);const _=(e,t)=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&f(e.address,t)))||null,y=(e,t)=>e.find((e=>f(e.address,t)))||null,h=e=>n(e)??m(e);function b(e){if(!e)return null;let t=function(e){let t=[];for(let i of e){let e=i.type;switch(i.type){case"wallet":let a={id:i.id,address:i.address,type:i.type,imported:i.imported,delegated:i.delegated,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(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(a);break;case"smart_wallet":let l={address:i.address,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at),smartWalletType:i.smart_wallet_type,smartWalletVersion:i.smart_wallet_version};t.push(l);break;case"cross_app":let n={type:i.type,subject:i.subject,embeddedWallets:i.embedded_wallets,smartWallets:i.smart_wallets,providerApp:{id:i.provider_app_id},firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(n);break;case"email":let d={address:i.address,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(d);break;case"phone":let u={number:i.phoneNumber,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(u);break;case"google_oauth":let p={subject:i.subject,email:i.email,name:i.name,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(p);break;case"spotify_oauth":let m={subject:i.subject,email:i.email,name:i.name,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(m);break;case"instagram_oauth":let c={subject:i.subject,username:i.username,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(c);break;case"twitter_oauth":let o={subject:i.subject,username:i.username,name:i.name,type:i.type,profilePictureUrl:i.profile_picture_url,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(o);break;case"discord_oauth":let f={subject:i.subject,username:i.username,email:i.email,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(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:s(i.first_verified_at),latestVerifiedAt:s(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:s(i.first_verified_at),latestVerifiedAt:s(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:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(h);break;case"twitch_oauth":let b={subject:i.subject,username:i.username,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(b);break;case"linkedin_oauth":let k={subject:i.subject,name:i.name,email:i.email,vanityName:i.vanity_name,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(k);break;case"apple_oauth":let A={subject:i.subject,email:i.email,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(A);break;case"custom_auth":t.push({type:i.type,customUserId:i.custom_user_id,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(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:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at),signerPublicKey:i.signer_public_key};t.push(v);break;case"passkey":let g={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:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(g);break;case"telegram":let w={type:i.type,telegramUserId:i.telegram_user_id,firstName:i.first_name,lastName:i.last_name,username:i.username,photoUrl:i.photo_url,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(w);break;default:if(r(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:s(i.first_verified_at),latestVerifiedAt:s(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"),a=l(t,"smart_wallet"),n=l(t,"email"),d=l(t,"phone"),u=l(t,"google_oauth"),p=l(t,"twitter_oauth"),m=l(t,"discord_oauth"),c=l(t,"github_oauth"),o=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"),k=l(t,"apple_oauth"),A=l(t,"farcaster"),v=l(t,"telegram"),g=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:s(t)})));return{id:e.id,createdAt:s(e.created_at),linkedAccounts:t,email:n&&{address:n?.address},phone:d&&{number:d?.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:a&&{address:a.address,smartWalletType:a.smartWalletType,smartWalletVersion:a.smartWalletVersion},google:u&&{subject:u.subject,email:u.email,name:u.name},twitter:p&&{subject:p.subject,username:p.username,name:p.name,profilePictureUrl:p.profilePictureUrl},discord:m&&{subject:m.subject,username:m.username,email:m.email},github:c&&{subject:c.subject,username:c.username,name:c.name,email:c.email},spotify:o&&{subject:o.subject,email:o.email,name:o.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:k&&{subject:k.subject,email:k.email},farcaster:A&&{fid:A.fid,ownerAddress:A.ownerAddress,displayName:A.displayName,username:A.username,bio:A.bio,pfp:A.pfp,url:A.url,signerPublicKey:A.signerPublicKey},telegram:v&&{telegramUserId:v.telegramUserId,firstName:v.firstName,lastName:v.lastName,username:v.username,photoUrl:v.photoUrl},delegatedWallets:[],mfaMethods:g.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}}const k=e=>!!e.id&&"privy-v2"===e.recoveryMethod,A=/*#__PURE__*/t({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:a,login:a,connectOrCreateWallet:a,linkEmail:a,linkPhone:a,linkFarcaster:a,linkWallet:a,startCrossAppAuthFlow:a,linkGoogle:a,linkTwitter:a,linkTwitch:a,linkDiscord:a,linkGithub:a,linkSpotify:a,linkInstagram:a,linkTelegram:a,linkTiktok:a,linkLine:a,linkLinkedIn:a,linkApple:a,linkPasskey:a,updateEmail:a,updatePhone:a,logout:a,getAccessToken:a,unlinkEmail:a,unlinkPhone:a,unlinkWallet:a,unlinkGoogle:a,unlinkTwitter:a,unlinkTwitch:a,unlinkDiscord:a,unlinkGithub:a,unlinkSpotify:a,unlinkInstagram:a,unlinkTiktok:a,unlinkLine:a,unlinkLinkedIn:a,unlinkApple:a,unlinkCrossAppAccount:a,unlinkFarcaster:a,unlinkTelegram:a,unlinkPasskey:a,signMessage:a,signTypedData:a,enrollInMfa:a,initEnrollmentWithSms:a,initEnrollmentWithTotp:a,initEnrollmentWithPasskey:a,promptMfa:a,init:a,submitEnrollmentWithSms:a,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:a,unenroll:a,submit:a,cancel:a,sendTransaction:a,signTransaction:a,exportWallet:a,setWalletPassword:a,setWalletRecovery:a,requestFarcasterSignerFromWarpcast:a,getFarcasterSignerPublicKey:a,signFarcasterMessage:a,signMessageWithCrossAppWallet:a,signTypedDataWithCrossAppWallet:a,sendTransactionWithCrossAppWallet:a,signTransactionWithCrossAppWallet:a,isModalOpen:!1,mfaMethods:[]}),v=()=>i(A);export{A as P,h as a,n as b,b as c,d,c as e,_ as f,k as g,y as h,r as i,o as j,p as k,m as l,u as m,v as u};
1
+ import{getAddress as e}from"viem";import{createContext as t,useContext as i}from"react";import{n as a}from"./internal-context-CfE_S5P-.mjs";function r(e){return"string"==typeof e&&/^custom:[a-zA-Z0-9_-]+$/i.test(e)}function s(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?d(e).find((e=>0===e.walletIndex))??null:null,d=e=>e?u(e,"ethereum"):[],u=(e,t)=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&e.chainType===t)),p=e=>e?u(e,"solana"):[],m=e=>e?p(e).find((e=>0===e.walletIndex))??null:null,c=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType)),o=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType));let f=(t,i)=>t===i||!(!t.startsWith("0x")||!i.startsWith("0x"))&&e(t)===e(i);const _=(e,t)=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&f(e.address,t)))||null,y=(e,t)=>e.find((e=>f(e.address,t)))||null,h=e=>n(e)??m(e);function b(e){if(!e)return null;let t=function(e){let t=[];for(let i of e){let e=i.type;switch(i.type){case"wallet":let a={id:i.id,address:i.address,type:i.type,imported:i.imported,delegated:i.delegated,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(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(a);break;case"smart_wallet":let l={address:i.address,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at),smartWalletType:i.smart_wallet_type,smartWalletVersion:i.smart_wallet_version};t.push(l);break;case"cross_app":let n={type:i.type,subject:i.subject,embeddedWallets:i.embedded_wallets,smartWallets:i.smart_wallets,providerApp:{id:i.provider_app_id},firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(n);break;case"email":let d={address:i.address,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(d);break;case"phone":let u={number:i.phoneNumber,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(u);break;case"google_oauth":let p={subject:i.subject,email:i.email,name:i.name,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(p);break;case"spotify_oauth":let m={subject:i.subject,email:i.email,name:i.name,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(m);break;case"instagram_oauth":let c={subject:i.subject,username:i.username,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(c);break;case"twitter_oauth":let o={subject:i.subject,username:i.username,name:i.name,type:i.type,profilePictureUrl:i.profile_picture_url,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(o);break;case"discord_oauth":let f={subject:i.subject,username:i.username,email:i.email,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(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:s(i.first_verified_at),latestVerifiedAt:s(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:s(i.first_verified_at),latestVerifiedAt:s(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:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(h);break;case"twitch_oauth":let b={subject:i.subject,username:i.username,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(b);break;case"linkedin_oauth":let k={subject:i.subject,name:i.name,email:i.email,vanityName:i.vanity_name,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(k);break;case"apple_oauth":let A={subject:i.subject,email:i.email,type:i.type,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(A);break;case"custom_auth":t.push({type:i.type,customUserId:i.custom_user_id,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(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:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at),signerPublicKey:i.signer_public_key};t.push(v);break;case"passkey":let g={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:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(g);break;case"telegram":let w={type:i.type,telegramUserId:i.telegram_user_id,firstName:i.first_name,lastName:i.last_name,username:i.username,photoUrl:i.photo_url,firstVerifiedAt:s(i.first_verified_at),latestVerifiedAt:s(i.latest_verified_at)};t.push(w);break;default:if(r(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:s(i.first_verified_at),latestVerifiedAt:s(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"),a=l(t,"smart_wallet"),n=l(t,"email"),d=l(t,"phone"),u=l(t,"google_oauth"),p=l(t,"twitter_oauth"),m=l(t,"discord_oauth"),c=l(t,"github_oauth"),o=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"),k=l(t,"apple_oauth"),A=l(t,"farcaster"),v=l(t,"telegram"),g=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:s(t)})));return{id:e.id,createdAt:s(e.created_at),linkedAccounts:t,email:n&&{address:n?.address},phone:d&&{number:d?.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:a&&{address:a.address,smartWalletType:a.smartWalletType,smartWalletVersion:a.smartWalletVersion},google:u&&{subject:u.subject,email:u.email,name:u.name},twitter:p&&{subject:p.subject,username:p.username,name:p.name,profilePictureUrl:p.profilePictureUrl},discord:m&&{subject:m.subject,username:m.username,email:m.email},github:c&&{subject:c.subject,username:c.username,name:c.name,email:c.email},spotify:o&&{subject:o.subject,email:o.email,name:o.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:k&&{subject:k.subject,email:k.email},farcaster:A&&{fid:A.fid,ownerAddress:A.ownerAddress,displayName:A.displayName,username:A.username,bio:A.bio,pfp:A.pfp,url:A.url,signerPublicKey:A.signerPublicKey},telegram:v&&{telegramUserId:v.telegramUserId,firstName:v.firstName,lastName:v.lastName,username:v.username,photoUrl:v.photoUrl},delegatedWallets:[],mfaMethods:g.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}}const k=e=>!!e.id&&"privy-v2"===e.recoveryMethod,A=/*#__PURE__*/t({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:a,login:a,connectOrCreateWallet:a,linkEmail:a,linkPhone:a,linkFarcaster:a,linkWallet:a,startCrossAppAuthFlow:a,linkGoogle:a,linkTwitter:a,linkTwitch:a,linkDiscord:a,linkGithub:a,linkSpotify:a,linkInstagram:a,linkTelegram:a,linkTiktok:a,linkLine:a,linkLinkedIn:a,linkApple:a,linkPasskey:a,updateEmail:a,updatePhone:a,logout:a,getAccessToken:a,unlinkEmail:a,unlinkPhone:a,unlinkWallet:a,unlinkGoogle:a,unlinkTwitter:a,unlinkTwitch:a,unlinkDiscord:a,unlinkGithub:a,unlinkSpotify:a,unlinkInstagram:a,unlinkTiktok:a,unlinkLine:a,unlinkLinkedIn:a,unlinkApple:a,unlinkCrossAppAccount:a,unlinkFarcaster:a,unlinkTelegram:a,unlinkPasskey:a,signMessage:a,signTypedData:a,enrollInMfa:a,initEnrollmentWithSms:a,initEnrollmentWithTotp:a,initEnrollmentWithPasskey:a,promptMfa:a,init:a,submitEnrollmentWithSms:a,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:a,unenroll:a,submit:a,cancel:a,sendTransaction:a,signTransaction:a,exportWallet:a,setWalletPassword:a,setWalletRecovery:a,requestFarcasterSignerFromWarpcast:a,getFarcasterSignerPublicKey:a,signFarcasterMessage:a,signMessageWithCrossAppWallet:a,signTypedDataWithCrossAppWallet:a,sendTransactionWithCrossAppWallet:a,signTransactionWithCrossAppWallet:a,isModalOpen:!1,mfaMethods:[]}),v=()=>i(A);export{A as P,h as a,n as b,b as c,d,c as e,_ as f,k as g,o as h,r as i,y as j,p as k,m as l,u as m,v as u};
@@ -1 +1 @@
1
- import{useRef as e,useState as t,useCallback as r}from"react";import{http as a,createPublicClient as n}from"viem";import{u as i,b as s,g as o}from"./privy-context-C7K3ZBW-.mjs";import{c3 as l,an as c,as as d,af as u,F as m,bU as p,bV as y,bx as g}from"./SignRequestScreen-Dnn_x6kV.mjs";import{P as f}from"./paths-B891YjWw.mjs";import{u as h}from"./internal-context-LlMdpfkb.mjs";import{a as w}from"./getEmbeddedConnectedWallet-CM6cDQCS.mjs";import{createSmartAccountClient as P}from"permissionless";import{toThirdwebSmartAccount as I,toLightSmartAccount as W,toBiconomySmartAccount as v,toKernelSmartAccount as F,toSafeSmartAccount as x}from"permissionless/accounts";import{createPimlicoClient as G}from"permissionless/clients/pimlico";import{toCoinbaseSmartAccount as C,entryPoint06Address as T,entryPoint07Address as U}from"viem/account-abstraction";import{THIRDWEB as b,COINBASE_SMART_WALLET as M,LIGHT_ACCOUNT as S,BICONOMY as O,KERNEL as V,SAFE as A}from"@privy-io/js-sdk-core";let D={address:T,version:"0.6"},N={address:U,version:"0.7"},_=({owner:e,smartWalletType:t,smartWalletVersion:r,publicClient:a})=>{switch(t){case A:return x({client:a,entryPoint:N,owners:[e],version:"1.4.1"});case V:return F({client:a,version:"0.3.1",entryPoint:N,useMetaFactory:"optional",owners:[e]});case O:return v({client:a,owners:[e],entryPoint:D});case S:return W({client:a,entryPoint:D,owner:e,version:"1.1.0"});case M:return async function({client:e,owner:t,version:r}){let[a]=await t.request({method:"eth_accounts"});if(!a)throw Error("Unable to request embedded owner for eth_accounts");return await C({client:e,owners:[{type:"local",source:"privy",address:a,sign:async({hash:e})=>await t.request({method:"secp256k1_sign",params:[e]})}],version:r})}({client:a,owner:e,version:r??"1"});case b:return I({client:a,entryPoint:N,owner:e});default:throw Error(`Invalid smart account type: ${t}.`)}};const B=({calls:e,chain:t,maxPriorityFeePerGas:r,maxFeePerGas:a,nonce:n})=>e.map((e=>({to:e.to||void 0,data:e.data,value:e.value,chainId:t.id,nonce:n,maxFeePerGas:a,maxPriorityFeePerGas:r}))),$=async({chain:e,paymasterContext:t,account:r,signer:i,user:s,smartWalletsConfig:o,rpcConfig:c,privyAppId:d})=>{if(!(o?.enabled&&s&&r&&i))return;let u=o?.configuredNetworks.find((t=>t.chainId===`eip155:${e.id}`));if(!u)throw new f(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let m=s.smartWallet?s.smartWallet.smartWalletType:o.smartWalletType,p=s.smartWallet?s.smartWallet.smartWalletVersion:o.smartWalletVersion,y=l(e,c,d),g=n({chain:e,transport:a(y)}),h=t??u.paymasterContext,w=await(async({owner:e,smartWalletType:t,smartWalletVersion:r,chain:n,publicClient:i,bundlerUrl:s,paymasterUrl:o,paymasterContext:l})=>{let c=await _({owner:e,smartWalletType:t,publicClient:i,smartWalletVersion:r}),d=G({transport:a(s),entryPoint:c.entryPoint}),u=o?G({transport:a(o),entryPoint:c.entryPoint}):void 0;return P({account:c,chain:n,paymaster:u,paymasterContext:l,bundlerTransport:a(s),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>s.includes(e))))return await d.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>s.includes(e))))return(await d.request({method:"zd_getUserOperationGasPrice",params:[]})).fast;if(["g.alchemy.com"].some((e=>s.includes(e)))){let[e,t]=await Promise.all([i.getBlock({blockTag:"latest"}),d.request({method:"rundler_maxPriorityFeePerGas",params:[]})]);if(!e.baseFeePerGas||!t)throw Error("Failed to get block or maxPriorityFeePerGasEstimate");return{maxFeePerGas:150n*e.baseFeePerGas/100n+BigInt(t.toString()),maxPriorityFeePerGas:BigInt(t.toString())}}{let e=await i.estimateFeesPerGas(),t=s.includes("api.developer.coinbase.com")?175n:150n;return{...e,maxFeePerGas:e.maxFeePerGas*t/100n,maxPriorityFeePerGas:e.maxPriorityFeePerGas*t/100n}}}}})})({owner:i,smartWalletType:m,smartWalletVersion:p,chain:e,publicClient:g,paymasterContext:h,...u});if(!w)throw new f(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return w},q=({clientConfig:a,smartWalletsConfig:n})=>{let{hideWalletUIs:l,openPrivyModal:P,appId:I,isHeadlessSigning:W}=h(),v=c(),{setModalData:F}=d(),{user:x}=i(),{chains:G}=c(),{chainId:C,clients:T,setChainId:U,chainIdState:b}=(()=>{let r=e(),[a,n]=t();return{clients:e({}),setChainId:e=>{r.current=e,n(e)},chainId:r,chainIdState:a}})(),M=G.find((e=>e.id===b)),{wallets:S}=u(),O=s(x),V=w(S,O?.address),A=!!O&&o(O),D=r((async()=>C.current),[C]),N=r((async({id:e})=>{if(!T.current[e]){let t=await $({chain:G.find((t=>t.id===e)),account:O,signer:await(V?.getEthereumProvider()),user:x,paymasterContext:a?.paymasterContext,smartWalletsConfig:n,rpcConfig:v.rpcConfig,privyAppId:I});t&&(T.current[e]=t)}U(e)}),[G,a,S,x,n]);return{wrapSmartAccountClient:e=>{T.current[e.chain.id]=e,b||U(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);if(delete e.account,W({showWalletUIs:t?.uiOptions?.showWalletUIs}))return l.current=!0,await r.sendTransaction(e).finally((()=>l.current=!1));let a=[];"calls"in e&&void 0!==e.calls?a=[...e.calls]:"to"in e&&(a=[{to:e.to,value:e.value||BigInt(0),data:e.data||"0x"}]);let n=async()=>{let{paymasterAndData:t,paymasterData:n,maxFeePerGas:i,maxPriorityFeePerGas:s}=await r.prepareUserOperation({calls:a,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return 0===Number(i)&&0===Number(s)||Number(t??n??0)>0};return new Promise((async(i,s)=>{l.current=!0;let{entropyId:o,entropyIdVerifier:c}=m(x);F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:o,entropyIdVerifier:c,onCompleteNavigateTo:p,onFailure:()=>{}},sendTransaction:{transactionRequests:B({calls:a,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:o,entropyIdVerifier:c,getIsSponsored:n,signOnly:!1,onConfirm:()=>r.sendTransaction(e),onSuccess:e=>i(e.hash),onFailure:s,uiOptions:t?.uiOptions??{}}}),P(y)})).finally((()=>{l.current=!1}))},signMessage:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);return W({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await r.signMessage(e).finally((()=>l.current=!1))):new Promise((async(a,n)=>{let{entropyId:i,entropyIdVerifier:s}=m(x);l.current=!0,F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:i,entropyIdVerifier:s,onCompleteNavigateTo:g,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:n,uiOptions:t?.uiOptions??{}}}),P(y)})).finally((()=>{l.current=!1}))},signTypedData:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);return delete e.account,W({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await r.signTypedData(e).finally((()=>l.current=!1))):new Promise((async(a,n)=>{l.current=!0;let{entropyId:i,entropyIdVerifier:s}=m(x);F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:i,entropyIdVerifier:s,onCompleteNavigateTo:g,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>a(e),onFailure:n,uiOptions:t?.uiOptions??{}}}),P(y)})).finally((()=>{l.current=!1}))},getChainId:D,chain:M,switchChain:N}}}},j=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:r}=h(),{setModalData:a}=d(),{user:n}=i(),l=s(n),c=!!l&&o(l);return{wrapSmartAccountClientWithUIs:i=>({...i,sendTransaction:async(s,o)=>{if(r({showWalletUIs:o?.uiOptions?.showWalletUIs}))return e.current=!0,await i.sendTransaction(s).finally((()=>e.current=!1));let d=[];"calls"in s&&void 0!==s.calls?d=[...s.calls]:"to"in s&&(d=[{to:s.to,value:s.value||BigInt(0),data:s.data||"0x"}]);let u=async()=>{if(!i.paymaster)return!1;let{paymasterData:e,paymasterAndData:t}=await i.prepareUserOperation({calls:d,maxFeePerGas:s.maxFeePerGas,maxPriorityFeePerGas:s.maxPriorityFeePerGas,nonce:s.nonce?BigInt(s.nonce):void 0});return Number(t??e??0)>0};return new Promise((async(r,g)=>{e.current=!0;let{entropyId:f,entropyIdVerifier:h}=m(n);a({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:f,entropyIdVerifier:h,onCompleteNavigateTo:p,onFailure:()=>{}},sendTransaction:{transactionRequests:B({calls:d,chain:i.chain,maxPriorityFeePerGas:s.maxPriorityFeePerGas,maxFeePerGas:s.maxFeePerGas,nonce:s.nonce?BigInt(s.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:i.account.address,entropyId:f,entropyIdVerifier:h,getIsSponsored:u,signOnly:!1,onConfirm:()=>i.sendTransaction(s),onSuccess:e=>r(e.hash),onFailure:g,uiOptions:o?.uiOptions??{}}}),t(y)})).finally((()=>{e.current=!1}))},signMessage:async(s,o)=>r({showWalletUIs:o?.uiOptions?.showWalletUIs})?(e.current=!0,await i.signMessage(s).finally((()=>e.current=!1))):new Promise((async(r,d)=>{let{entropyId:u,entropyIdVerifier:p}=m(n);e.current=!0,a({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:u,entropyIdVerifier:p,onCompleteNavigateTo:g,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof s.message?s.message:s.message.raw.toString(),confirmAndSign:()=>i.signMessage(s),onSuccess:e=>r(e),onFailure:d,uiOptions:o?.uiOptions??{}}}),t(y)})).finally((()=>{e.current=!1})),signTypedData:async(s,o)=>r({showWalletUIs:o?.uiOptions?.showWalletUIs})?(e.current=!0,await i.signTypedData(s).finally((()=>e.current=!1))):new Promise((async(r,d)=>{e.current=!0;let{entropyId:u,entropyIdVerifier:p}=m(n);a({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:u,entropyIdVerifier:p,onCompleteNavigateTo:g,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:s,confirmAndSign:()=>i.signTypedData(s),onSuccess:e=>r(e),onFailure:d,uiOptions:o?.uiOptions??{}}}),t(y)})).finally((()=>{e.current=!1}))})}};export{q as a,B as c,$ as g,j as u};
1
+ import{useRef as e,useState as t,useCallback as r}from"react";import{http as a,createPublicClient as n}from"viem";import{u as i,b as s,g as o}from"./privy-context-DDSW3jEM.mjs";import{as as l,c3 as c,an as d,af as u,F as m,bQ as p,bO as y,bW as g}from"./SignRequestScreen-Dkx-HBRI.mjs";import{P as f}from"./paths-B891YjWw.mjs";import{u as h}from"./internal-context-CfE_S5P-.mjs";import{a as w}from"./getEmbeddedConnectedWallet-CM6cDQCS.mjs";import{createSmartAccountClient as P}from"permissionless";import{toThirdwebSmartAccount as I,toLightSmartAccount as W,toBiconomySmartAccount as v,toKernelSmartAccount as F,toSafeSmartAccount as x}from"permissionless/accounts";import{createPimlicoClient as G}from"permissionless/clients/pimlico";import{entryPoint07Address as C,entryPoint06Address as T,toCoinbaseSmartAccount as U}from"viem/account-abstraction";import{THIRDWEB as b,COINBASE_SMART_WALLET as M,LIGHT_ACCOUNT as S,BICONOMY as O,KERNEL as V,SAFE as A}from"@privy-io/js-sdk-core";let D={address:T,version:"0.6"},N={address:C,version:"0.7"},_=({owner:e,smartWalletType:t,smartWalletVersion:r,publicClient:a})=>{switch(t){case A:return x({client:a,entryPoint:N,owners:[e],version:"1.4.1"});case V:return F({client:a,version:"0.3.1",entryPoint:N,useMetaFactory:"optional",owners:[e]});case O:return v({client:a,owners:[e],entryPoint:D});case S:return W({client:a,entryPoint:D,owner:e,version:"1.1.0"});case M:return async function({client:e,owner:t,version:r}){let[a]=await t.request({method:"eth_accounts"});if(!a)throw Error("Unable to request embedded owner for eth_accounts");return await U({client:e,owners:[{type:"local",source:"privy",address:a,sign:async({hash:e})=>await t.request({method:"secp256k1_sign",params:[e]})}],version:r})}({client:a,owner:e,version:r??"1"});case b:return I({client:a,entryPoint:N,owner:e});default:throw Error(`Invalid smart account type: ${t}.`)}};const B=({calls:e,chain:t,maxPriorityFeePerGas:r,maxFeePerGas:a,nonce:n})=>e.map((e=>({to:e.to||void 0,data:e.data,value:e.value,chainId:t.id,nonce:n,maxFeePerGas:a,maxPriorityFeePerGas:r}))),$=async({chain:e,paymasterContext:t,account:r,signer:i,user:s,smartWalletsConfig:o,rpcConfig:l,privyAppId:d})=>{if(!(o?.enabled&&s&&r&&i))return;let u=o?.configuredNetworks.find((t=>t.chainId===`eip155:${e.id}`));if(!u)throw new f(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let m=s.smartWallet?s.smartWallet.smartWalletType:o.smartWalletType,p=s.smartWallet?s.smartWallet.smartWalletVersion:o.smartWalletVersion,y=c(e,l,d),g=n({chain:e,transport:a(y)}),h=t??u.paymasterContext,w=await(async({owner:e,smartWalletType:t,smartWalletVersion:r,chain:n,publicClient:i,bundlerUrl:s,paymasterUrl:o,paymasterContext:l})=>{let c=await _({owner:e,smartWalletType:t,publicClient:i,smartWalletVersion:r}),d=G({transport:a(s),entryPoint:c.entryPoint}),u=o?G({transport:a(o),entryPoint:c.entryPoint}):void 0;return P({account:c,chain:n,paymaster:u,paymasterContext:l,bundlerTransport:a(s),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>s.includes(e))))return await d.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>s.includes(e))))return(await d.request({method:"zd_getUserOperationGasPrice",params:[]})).fast;if(["g.alchemy.com"].some((e=>s.includes(e)))){let[e,t]=await Promise.all([i.getBlock({blockTag:"latest"}),d.request({method:"rundler_maxPriorityFeePerGas",params:[]})]);if(!e.baseFeePerGas||!t)throw Error("Failed to get block or maxPriorityFeePerGasEstimate");return{maxFeePerGas:150n*e.baseFeePerGas/100n+BigInt(t.toString()),maxPriorityFeePerGas:BigInt(t.toString())}}{let e=await i.estimateFeesPerGas(),t=s.includes("api.developer.coinbase.com")?175n:150n;return{...e,maxFeePerGas:e.maxFeePerGas*t/100n,maxPriorityFeePerGas:e.maxPriorityFeePerGas*t/100n}}}}})})({owner:i,smartWalletType:m,smartWalletVersion:p,chain:e,publicClient:g,paymasterContext:h,...u});if(!w)throw new f(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return w},q=({clientConfig:a,smartWalletsConfig:n})=>{let{hideWalletUIs:c,openPrivyModal:P,appId:I,isHeadlessSigning:W}=h(),v=d(),{setModalData:F}=l(),{user:x}=i(),{chains:G}=d(),{chainId:C,clients:T,setChainId:U,chainIdState:b}=(()=>{let r=e(),[a,n]=t();return{clients:e({}),setChainId:e=>{r.current=e,n(e)},chainId:r,chainIdState:a}})(),M=G.find((e=>e.id===b)),{wallets:S}=u(),O=s(x),V=w(S,O?.address),A=!!O&&o(O),D=r((async()=>C.current),[C]),N=r((async({id:e})=>{if(!T.current[e]){let t=await $({chain:G.find((t=>t.id===e)),account:O,signer:await(V?.getEthereumProvider()),user:x,paymasterContext:a?.paymasterContext,smartWalletsConfig:n,rpcConfig:v.rpcConfig,privyAppId:I});t&&(T.current[e]=t)}U(e)}),[G,a,S,x,n]);return{wrapSmartAccountClient:e=>{T.current[e.chain.id]=e,b||U(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);if(delete e.account,W({showWalletUIs:t?.uiOptions?.showWalletUIs}))return c.current=!0,await r.sendTransaction(e).finally((()=>c.current=!1));let a=[];"calls"in e&&void 0!==e.calls?a=[...e.calls]:"to"in e&&(a=[{to:e.to,value:e.value||BigInt(0),data:e.data||"0x"}]);let n=async()=>{let{paymasterAndData:t,paymasterData:n,maxFeePerGas:i,maxPriorityFeePerGas:s}=await r.prepareUserOperation({calls:a,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return 0===Number(i)&&0===Number(s)||Number(t??n??0)>0};return new Promise((async(i,s)=>{c.current=!0;let{entropyId:o,entropyIdVerifier:l}=m(x);F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:o,entropyIdVerifier:l,onCompleteNavigateTo:g,onFailure:()=>{}},sendTransaction:{transactionRequests:B({calls:a,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:o,entropyIdVerifier:l,getIsSponsored:n,signOnly:!1,onConfirm:()=>r.sendTransaction(e),onSuccess:e=>i(e.hash),onFailure:s,uiOptions:t?.uiOptions??{}}}),P(y)})).finally((()=>{c.current=!1}))},signMessage:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);return W({showWalletUIs:t?.uiOptions?.showWalletUIs})?(c.current=!0,await r.signMessage(e).finally((()=>c.current=!1))):new Promise((async(a,n)=>{let{entropyId:i,entropyIdVerifier:s}=m(x);c.current=!0,F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:i,entropyIdVerifier:s,onCompleteNavigateTo:p,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:n,uiOptions:t?.uiOptions??{}}}),P(y)})).finally((()=>{c.current=!1}))},signTypedData:async(e,t)=>{let r=T.current[C.current];if(!r)throw new f(`Smart wallet client for chain (eip155:${C.current}) not found`);return delete e.account,W({showWalletUIs:t?.uiOptions?.showWalletUIs})?(c.current=!0,await r.signTypedData(e).finally((()=>c.current=!1))):new Promise((async(a,n)=>{c.current=!0;let{entropyId:i,entropyIdVerifier:s}=m(x);F({connectWallet:{recoveryMethod:O.recoveryMethod,connectingWalletAddress:O.address,isUnifiedWallet:A,entropyId:i,entropyIdVerifier:s,onCompleteNavigateTo:p,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>a(e),onFailure:n,uiOptions:t?.uiOptions??{}}}),P(y)})).finally((()=>{c.current=!1}))},getChainId:D,chain:M,switchChain:N}}}},j=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:r}=h(),{setModalData:a}=l(),{user:n}=i(),c=s(n),d=!!c&&o(c);return{wrapSmartAccountClientWithUIs:i=>({...i,sendTransaction:async(s,o)=>{if(r({showWalletUIs:o?.uiOptions?.showWalletUIs}))return e.current=!0,await i.sendTransaction(s).finally((()=>e.current=!1));let l=[];"calls"in s&&void 0!==s.calls?l=[...s.calls]:"to"in s&&(l=[{to:s.to,value:s.value||BigInt(0),data:s.data||"0x"}]);let u=async()=>{if(!i.paymaster)return!1;let{paymasterData:e,paymasterAndData:t}=await i.prepareUserOperation({calls:l,maxFeePerGas:s.maxFeePerGas,maxPriorityFeePerGas:s.maxPriorityFeePerGas,nonce:s.nonce?BigInt(s.nonce):void 0});return Number(t??e??0)>0};return new Promise((async(r,p)=>{e.current=!0;let{entropyId:f,entropyIdVerifier:h}=m(n);a({connectWallet:{recoveryMethod:c.recoveryMethod,connectingWalletAddress:c.address,isUnifiedWallet:d,entropyId:f,entropyIdVerifier:h,onCompleteNavigateTo:g,onFailure:()=>{}},sendTransaction:{transactionRequests:B({calls:l,chain:i.chain,maxPriorityFeePerGas:s.maxPriorityFeePerGas,maxFeePerGas:s.maxFeePerGas,nonce:s.nonce?BigInt(s.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:i.account.address,entropyId:f,entropyIdVerifier:h,getIsSponsored:u,signOnly:!1,onConfirm:()=>i.sendTransaction(s),onSuccess:e=>r(e.hash),onFailure:p,uiOptions:o?.uiOptions??{}}}),t(y)})).finally((()=>{e.current=!1}))},signMessage:async(s,o)=>r({showWalletUIs:o?.uiOptions?.showWalletUIs})?(e.current=!0,await i.signMessage(s).finally((()=>e.current=!1))):new Promise((async(r,l)=>{let{entropyId:u,entropyIdVerifier:g}=m(n);e.current=!0,a({connectWallet:{recoveryMethod:c.recoveryMethod,connectingWalletAddress:c.address,isUnifiedWallet:d,entropyId:u,entropyIdVerifier:g,onCompleteNavigateTo:p,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof s.message?s.message:s.message.raw.toString(),confirmAndSign:()=>i.signMessage(s),onSuccess:e=>r(e),onFailure:l,uiOptions:o?.uiOptions??{}}}),t(y)})).finally((()=>{e.current=!1})),signTypedData:async(s,o)=>r({showWalletUIs:o?.uiOptions?.showWalletUIs})?(e.current=!0,await i.signTypedData(s).finally((()=>e.current=!1))):new Promise((async(r,l)=>{e.current=!0;let{entropyId:u,entropyIdVerifier:g}=m(n);a({connectWallet:{recoveryMethod:c.recoveryMethod,connectingWalletAddress:c.address,isUnifiedWallet:d,entropyId:u,entropyIdVerifier:g,onCompleteNavigateTo:p,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:s,confirmAndSign:()=>i.signTypedData(s),onSuccess:e=>r(e),onFailure:l,uiOptions:o?.uiOptions??{}}}),t(y)})).finally((()=>{e.current=!1}))})}};export{q as a,B as c,$ as g,j as u};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useContext as o,useState as t,useEffect as r,createContext as i}from"react";import{u as n,b as c}from"./privy-context-C7K3ZBW-.mjs";import{an as a,af as l}from"./SignRequestScreen-Dnn_x6kV.mjs";import{P as s}from"./paths-B891YjWw.mjs";import{a as m}from"./getEmbeddedConnectedWallet-CM6cDQCS.mjs";import{u as p,g as h,a as u}from"./smart-wallets-D86YXRN5.mjs";import{u as d,n as g}from"./internal-context-LlMdpfkb.mjs";import"viem";import"lucide-react";import"styled-components";import"@privy-io/urls";import"@scure/base";import"@privy-io/js-sdk-core";import"tinycolor2";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/PhoneIcon";import"react-device-detect";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"jose";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"viem/utils";import"eventemitter3";import"zustand";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@privy-io/ethereum";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"ofetch";import"@heroicons/react/24/outline/FingerPrintIcon";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";let f=/*#__PURE__*/i({client:void 0,getClientForChain:g});const C=({config:o,children:t})=>/*#__PURE__*/e(y,{children:/*#__PURE__*/e(W,{config:o,children:/*#__PURE__*/e(b,{children:t})})}),I=()=>{let{client:e,getClientForChain:t}=o(f);return{client:e,getClientForChain:t}};let w=/*#__PURE__*/i({config:void 0}),v=()=>{let{config:e}=o(w);return{config:e}},y=({children:o})=>{let[i,n]=t(void 0),{client:c}=d();return r((()=>{!i&&c&&(async()=>{try{if(!c)return void console.warn("No client found");let e=await c.getSmartWalletsConfig();n(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!c]),/*#__PURE__*/e(w.Provider,{value:{config:i},children:o})},W=({config:o,children:i})=>{let{config:u}=v(),{appId:g}=d(),{chains:f,defaultChain:C,rpcConfig:I}=a(),{wallets:w}=l(),{user:y}=n(),[W,b]=t(),{wrapSmartAccountClientWithUIs:P}=p(),S=c(y),F=m(w,S?.address);r((()=>{(async()=>{if(!u?.enabled)return;let e=u.configuredNetworks.find((e=>e.chainId===`eip155:${C.id}`))?C:f.find((e=>u.configuredNetworks.map((e=>e.chainId)).includes(`eip155:${e.id}`)));if(!e)throw new s("Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.");b(await h({chain:e,privyAppId:g,paymasterContext:o?.paymasterContext,rpcConfig:I,account:S,signer:await(F?.getEthereumProvider()),user:y,smartWalletsConfig:u}))})()}),[!!u?.enabled,!!y?.smartWallet,!!F,!!S]);/*#__PURE__*/return e(k.Provider,{value:{client:W,config:o,getClientForChain:async({id:e})=>{let t=await h({chain:f.find((o=>o.id===e)),privyAppId:g,paymasterContext:o?.paymasterContext,rpcConfig:I,account:S,signer:await(F?.getEthereumProvider()),user:y,smartWalletsConfig:u});if(!t)throw new s(`Failed to create smart wallet client for chain id: ${e}`);return P(t)}},children:i})},k=/*#__PURE__*/i({client:void 0,config:void 0,getClientForChain:g}),b=({children:t})=>{let{client:i,config:c,getClientForChain:a}=(()=>{let{client:e,config:t,getClientForChain:r}=o(k);return{client:e,config:t,getClientForChain:r}})(),{config:l}=v(),{wrapSmartAccountClient:s}=u({clientConfig:c,smartWalletsConfig:l}),{user:m}=n(),{generateSiweMessageForSmartWallet:p,linkSmartWallet:h,hideWalletUIs:g}=d();return r((()=>{(async()=>{if(i&&m&&!m?.smartWallet&&l?.enabled)try{let e=await p({address:i.account.address,chainId:`eip155:${i.chain.id}`});g.current=!0;let o=await i.signMessage({message:e});await h({signature:o,message:e,smartWalletType:l.smartWalletType,smartWalletVersion:l.smartWalletVersion})}catch(e){console.error("Error creating smart wallet:",e)}finally{g.current=!1}})()}),[!!i,!!m?.smartWallet,!!l?.enabled]),/*#__PURE__*/e(f.Provider,{value:{client:m?.smartWallet&&i?s(i):void 0,getClientForChain:a},children:t})};export{C as SmartWalletsProvider,I as useSmartWallets};
1
+ import{jsx as e}from"react/jsx-runtime";import{useContext as o,createContext as t,useState as r,useEffect as i}from"react";import{u as n,b as c}from"./privy-context-DDSW3jEM.mjs";import{an as a,af as l}from"./SignRequestScreen-Dkx-HBRI.mjs";import{P as s}from"./paths-B891YjWw.mjs";import{a as m}from"./getEmbeddedConnectedWallet-CM6cDQCS.mjs";import{u as p,g as h,a as u}from"./smart-wallets-BElFh8An.mjs";import{u as d,n as g}from"./internal-context-CfE_S5P-.mjs";import"viem";import"lucide-react";import"styled-components";import"@privy-io/urls";import"@scure/base";import"@privy-io/js-sdk-core";import"tinycolor2";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/PhoneIcon";import"react-device-detect";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"jose";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"viem/utils";import"eventemitter3";import"zustand";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@privy-io/ethereum";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"ofetch";import"@heroicons/react/24/outline/FingerPrintIcon";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";let f=/*#__PURE__*/t({client:void 0,getClientForChain:g});const C=({config:o,children:t})=>/*#__PURE__*/e(y,{children:/*#__PURE__*/e(W,{config:o,children:/*#__PURE__*/e(b,{children:t})})}),I=()=>{let{client:e,getClientForChain:t}=o(f);return{client:e,getClientForChain:t}};let w=/*#__PURE__*/t({config:void 0}),v=()=>{let{config:e}=o(w);return{config:e}},y=({children:o})=>{let[t,n]=r(void 0),{client:c}=d();return i((()=>{!t&&c&&(async()=>{try{if(!c)return void console.warn("No client found");let e=await c.getSmartWalletsConfig();n(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!c]),/*#__PURE__*/e(w.Provider,{value:{config:t},children:o})},W=({config:o,children:t})=>{let{config:u}=v(),{appId:g}=d(),{chains:f,defaultChain:C,rpcConfig:I}=a(),{wallets:w}=l(),{user:y}=n(),[W,b]=r(),{wrapSmartAccountClientWithUIs:P}=p(),S=c(y),F=m(w,S?.address);i((()=>{(async()=>{if(!u?.enabled)return;let e=u.configuredNetworks.find((e=>e.chainId===`eip155:${C.id}`))?C:f.find((e=>u.configuredNetworks.map((e=>e.chainId)).includes(`eip155:${e.id}`)));if(!e)throw new s("Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.");b(await h({chain:e,privyAppId:g,paymasterContext:o?.paymasterContext,rpcConfig:I,account:S,signer:await(F?.getEthereumProvider()),user:y,smartWalletsConfig:u}))})()}),[!!u?.enabled,!!y?.smartWallet,!!F,!!S]);/*#__PURE__*/return e(k.Provider,{value:{client:W,config:o,getClientForChain:async({id:e})=>{let t=await h({chain:f.find((o=>o.id===e)),privyAppId:g,paymasterContext:o?.paymasterContext,rpcConfig:I,account:S,signer:await(F?.getEthereumProvider()),user:y,smartWalletsConfig:u});if(!t)throw new s(`Failed to create smart wallet client for chain id: ${e}`);return P(t)}},children:t})},k=/*#__PURE__*/t({client:void 0,config:void 0,getClientForChain:g}),b=({children:t})=>{let{client:r,config:c,getClientForChain:a}=(()=>{let{client:e,config:t,getClientForChain:r}=o(k);return{client:e,config:t,getClientForChain:r}})(),{config:l}=v(),{wrapSmartAccountClient:s}=u({clientConfig:c,smartWalletsConfig:l}),{user:m}=n(),{generateSiweMessageForSmartWallet:p,linkSmartWallet:h,hideWalletUIs:g}=d();return i((()=>{(async()=>{if(r&&m&&!m?.smartWallet&&l?.enabled)try{let e=await p({address:r.account.address,chainId:`eip155:${r.chain.id}`});g.current=!0;let o=await r.signMessage({message:e});await h({signature:o,message:e,smartWalletType:l.smartWalletType,smartWalletVersion:l.smartWalletVersion})}catch(e){console.error("Error creating smart wallet:",e)}finally{g.current=!1}})()}),[!!r,!!m?.smartWallet,!!l?.enabled]),/*#__PURE__*/e(f.Provider,{value:{client:m?.smartWallet&&r?s(r):void 0,getClientForChain:a},children:t})};export{C as SmartWalletsProvider,I as useSmartWallets};
@@ -1 +1 @@
1
- import{useCallback as e}from"react";import{d as o,a as r}from"./usePrivy-CYAVrCyA.mjs";import{cy as t,aA as n,an as i,bz as s,cz as l,c1 as m,bO as p}from"./SignRequestScreen-Dnn_x6kV.mjs";import{u as h}from"./internal-context-LlMdpfkb.mjs";import{u as f}from"./privy-context-C7K3ZBW-.mjs";import{pipe as g,createTransactionMessage as y,setTransactionMessageFeePayerSigner as I,setTransactionMessageLifetimeUsingBlockhash as w,appendTransactionMessageInstructions as v,compileTransaction as C,getTransactionEncoder as A,address as k,setTransactionMessageFeePayer as S,blockhash as T,getTransactionDecoder as W}from"@solana/kit";import{g as x,s as E,b,f as j}from"./use-export-wallet-DVZxxj2x.mjs";export{a as useExportWallet,u as useFundWallet,d as useStandardWallets,c as useWallets}from"./use-export-wallet-DVZxxj2x.mjs";import{base64 as P}from"@scure/base";import{getAddMemoInstruction as F}from"@solana-program/memo";import{getWallets as M}from"@wallet-standard/app";import"./paths-B891YjWw.mjs";import"ofetch";import"@privy-io/js-sdk-core";import"react/jsx-runtime";import"lucide-react";import"styled-components";import"@privy-io/urls";import"viem";import"tinycolor2";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/PhoneIcon";import"react-device-detect";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"jose";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"viem/utils";import"eventemitter3";import"zustand";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@privy-io/ethereum";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"@heroicons/react/24/outline/FingerPrintIcon";import"./use-sign-with-user-signer-DwqsbciW.mjs";import"@solana-program/system";import"@solana-program/token";const U=e=>{let o,{get:r,on:n}=M(),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 t(e,i))),o?.(s)}function l(...e){Array.from(a.values()).forEach((o=>!e.includes(o)&&a.delete(o.name))),s=Array.from(a.values()).map((e=>new t(e,i))),o?.(s)}let m=[n("register",c),n("unregister",l)];return c(...r()),{_setOnConnectorsUpdated:e=>{o=e},onMount:()=>{m[0]||(m[0]=n("register",c)),m[1]||(m[1]=n("unregister",l))},onUnmount:()=>{let e=m.pop();for(;e;)e(),e=m.pop()},get:()=>s}},D=()=>{let{user:r}=f(),{client:t,refreshSessionAndUser:a,initializeWalletProxy:s}=h(),c=n(),l=i();return{importWallet:e((({privateKey:e,additionalSigners:n})=>o({getAccessToken:()=>t.getAccessToken(),user:r,initializeWalletProxy:s,refreshSessionAndUser:a,emitPrivyEvent:c,appConfig:l},{privateKey:e,chainType:"solana",additionalSigners:n})),[r,t,a,s,c,l])}};var R={id:s,getSolanaRpcClient:x,createTransactionFromRelayQuote:async function({solanaClient:e,quote:o,source:r}){let t=o.steps[0]?.items?.[0];if(!t)throw Error("Invalid quote");let n=t.data.instructions.map((({keys:e,programId:o,data:r})=>({accounts:e.map((({pubkey:e,isSigner:o,isWritable:r})=>({address:e,role:o&&r?3:o&&!r?2:!o&&r?1:0}))),programAddress:o,data:new Uint8Array(Buffer.from(r,"hex"))}))),{value:i}=await e.rpc.getLatestBlockhash().send(),a=g(y({version:0}),(e=>I({address:r},e)),(e=>w(i,e)),(e=>v(n,e)),(e=>C(e)));return new Uint8Array(A().encode(a))},simulateTransaction:E,getAddressFromBuffer:b,fetchTransactionEstimatedFees:j},q=()=>l(R);var z={id:p,createSiwsMemoTransaction:({address:e,nonce:o})=>{let r=F({memo:m({address:k(e),nonce:o})});return g(y({version:"legacy"}),(o=>S(k(e),o)),(e=>w({blockhash:T("GfVcyD5fWFJ6hRm8bsy7CoVPsLSoJhtJKRJYk8T2VVFN"),lastValidBlockHeight:0n},e)),(e=>v([r],e)),(e=>C(e)),(e=>P.encode(Uint8Array.from(A().encode(e)))))},getSignatureFromTransaction:(e,o)=>{let r=W().decode(e).signatures[o];if(!r)throw Error(`Missing transaction signature for address: ${o}`);return P.encode(r)}},L=()=>l(z);function V(){let{create:e}=r();return{createWallet:async o=>{o&&"target"in o&&o&&(o=void 0);let{account:r}=await e({chainType:"solana",options:o});return{wallet:r}}}}function B(){return{signMessage:async function(...e){let o=[];for(let r of e)o.push(await r.wallet.signMessage({...r,options:r.options}));return 1===e.length?o[0]:[...o]}}}function J(){return{signTransaction:async function(...e){let o=[];for(let r of e)o.push(await r.wallet.signTransaction({...r,chain:r.chain||"solana:mainnet"}));return 1===e.length?o[0]:[...o]}}}function K(){return{signAndSendTransaction:async function(...e){let o=[];for(let r of e)o.push(await r.wallet.signAndSendTransaction({...r,chain:r.chain||"solana:mainnet"}));return 1===e.length?o[0]:[...o]}}}export{t as SolanaAdapterConnector,U as toSolanaWalletConnectors,V as useCreateWallet,D as useImportWallet,K as useSignAndSendTransaction,B as useSignMessage,J as useSignTransaction,q as useSolanaFundingPlugin,L as useSolanaLedgerPlugin};
1
+ import{useCallback as e}from"react";import{d as o,a as r}from"./usePrivy-BJYprMT0.mjs";import{cy as t,aA as n,an as i,bC as s,cz as l,c1 as m,bL as p}from"./SignRequestScreen-Dkx-HBRI.mjs";import{u as h}from"./internal-context-CfE_S5P-.mjs";import{u as f}from"./privy-context-DDSW3jEM.mjs";import{pipe as g,createTransactionMessage as y,setTransactionMessageFeePayerSigner as I,setTransactionMessageLifetimeUsingBlockhash as w,appendTransactionMessageInstructions as v,compileTransaction as C,getTransactionEncoder as A,address as k,setTransactionMessageFeePayer as S,blockhash as T,getTransactionDecoder as W}from"@solana/kit";import{f as x,g as E,s as b,b as j}from"./use-export-wallet-OoiI5as_.mjs";export{a as useExportWallet,u as useFundWallet,d as useStandardWallets,c as useWallets}from"./use-export-wallet-OoiI5as_.mjs";import{base64 as P}from"@scure/base";import{getAddMemoInstruction as F}from"@solana-program/memo";import{getWallets as M}from"@wallet-standard/app";import"./paths-B891YjWw.mjs";import"ofetch";import"@privy-io/js-sdk-core";import"react/jsx-runtime";import"lucide-react";import"styled-components";import"@privy-io/urls";import"viem";import"tinycolor2";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/PhoneIcon";import"react-device-detect";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"jose";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"viem/utils";import"eventemitter3";import"zustand";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@privy-io/ethereum";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"@heroicons/react/24/outline/FingerPrintIcon";import"./use-sign-with-user-signer-DVcbjNtZ.mjs";import"@solana-program/system";import"@solana-program/token";const U=e=>{let o,{get:r,on:n}=M(),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 t(e,i))),o?.(s)}function l(...e){Array.from(a.values()).forEach((o=>!e.includes(o)&&a.delete(o.name))),s=Array.from(a.values()).map((e=>new t(e,i))),o?.(s)}let m=[n("register",c),n("unregister",l)];return c(...r()),{_setOnConnectorsUpdated:e=>{o=e},onMount:()=>{m[0]||(m[0]=n("register",c)),m[1]||(m[1]=n("unregister",l))},onUnmount:()=>{let e=m.pop();for(;e;)e(),e=m.pop()},get:()=>s}},D=()=>{let{user:r}=f(),{client:t,refreshSessionAndUser:a,initializeWalletProxy:s}=h(),c=n(),l=i();return{importWallet:e((({privateKey:e,additionalSigners:n})=>o({getAccessToken:()=>t.getAccessToken(),user:r,initializeWalletProxy:s,refreshSessionAndUser:a,emitPrivyEvent:c,appConfig:l},{privateKey:e,chainType:"solana",additionalSigners:n})),[r,t,a,s,c,l])}};var R={id:s,getSolanaRpcClient:j,createTransactionFromRelayQuote:async function({solanaClient:e,quote:o,source:r}){let t=o.steps[0]?.items?.[0];if(!t)throw Error("Invalid quote");let n=t.data.instructions.map((({keys:e,programId:o,data:r})=>({accounts:e.map((({pubkey:e,isSigner:o,isWritable:r})=>({address:e,role:o&&r?3:o&&!r?2:!o&&r?1:0}))),programAddress:o,data:new Uint8Array(Buffer.from(r,"hex"))}))),{value:i}=await e.rpc.getLatestBlockhash().send(),a=g(y({version:0}),(e=>I({address:r},e)),(e=>w(i,e)),(e=>v(n,e)),(e=>C(e)));return new Uint8Array(A().encode(a))},simulateTransaction:b,getAddressFromBuffer:E,fetchTransactionEstimatedFees:x},q=()=>l(R);var L={id:p,createSiwsMemoTransaction:({address:e,nonce:o})=>{let r=F({memo:m({address:k(e),nonce:o})});return g(y({version:"legacy"}),(o=>S(k(e),o)),(e=>w({blockhash:T("GfVcyD5fWFJ6hRm8bsy7CoVPsLSoJhtJKRJYk8T2VVFN"),lastValidBlockHeight:0n},e)),(e=>v([r],e)),(e=>C(e)),(e=>P.encode(Uint8Array.from(A().encode(e)))))},getSignatureFromTransaction:(e,o)=>{let r=W().decode(e).signatures[o];if(!r)throw Error(`Missing transaction signature for address: ${o}`);return P.encode(r)}},V=()=>l(L);function z(){let{create:e}=r();return{createWallet:async o=>{o&&"target"in o&&o&&(o=void 0);let{account:r}=await e({chainType:"solana",options:o});return{wallet:r}}}}function B(){return{signMessage:async function(...e){let o=[];for(let r of e)o.push(await r.wallet.signMessage({...r,options:r.options}));return 1===e.length?o[0]:[...o]}}}function J(){return{signTransaction:async function(...e){let o=[];for(let r of e)o.push(await r.wallet.signTransaction({...r,chain:r.chain||"solana:mainnet"}));return 1===e.length?o[0]:[...o]}}}function K(){return{signAndSendTransaction:async function(...e){let o=[];for(let r of e)o.push(await r.wallet.signAndSendTransaction({...r,chain:r.chain||"solana:mainnet"}));return 1===e.length?o[0]:[...o]}}}export{t as SolanaAdapterConnector,U as toSolanaWalletConnectors,z as useCreateWallet,D as useImportWallet,K as useSignAndSendTransaction,B as useSignMessage,J as useSignTransaction,q as useSolanaFundingPlugin,V as useSolanaLedgerPlugin};