@privy-io/react-auth 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{SignRequestScreen-cKtBaDI7.js → SignRequestScreen-CN1o6lNS.js} +3 -3
- package/dist/cjs/abstract-smart-wallets.js +1 -1
- package/dist/cjs/extended-chains.js +1 -1
- package/dist/cjs/farcaster.js +1 -1
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/{internal-context-KhEoJA7w.js → internal-context-DNWjSiYq.js} +1 -1
- package/dist/cjs/{privy-context-CIEj0Pa8.js → privy-context-C4y2c3Ko.js} +1 -1
- package/dist/cjs/{smart-wallets-B822d9Kk.js → smart-wallets-y1iwNp9C.js} +1 -1
- package/dist/cjs/smart-wallets.js +1 -1
- package/dist/cjs/solana.js +1 -1
- package/dist/cjs/ui.js +2 -2
- package/dist/cjs/use-export-wallet-BCC4davd.js +2 -0
- package/dist/cjs/{use-sign-with-user-signer-ThMn4Vgi.js → use-sign-with-user-signer-Q0_LRVtz.js} +1 -1
- package/dist/cjs/{useActiveWallet-Cv3I_On0.js → useActiveWallet-B5PAGqSK.js} +1 -1
- package/dist/cjs/{usePrivy-B4cuW5Bf.js → usePrivy-D-rpmVV5.js} +1 -1
- package/dist/dts/extended-chains.d.mts +1 -1
- package/dist/dts/extended-chains.d.ts +1 -1
- package/dist/dts/farcaster.d.mts +1 -1
- package/dist/dts/farcaster.d.ts +1 -1
- package/dist/dts/index.d.mts +2 -2
- package/dist/dts/index.d.ts +2 -2
- package/dist/dts/smart-wallets.d.mts +1 -1
- package/dist/dts/smart-wallets.d.ts +1 -1
- package/dist/dts/solana.d.mts +2 -2
- package/dist/dts/solana.d.ts +2 -2
- package/dist/dts/{types-BQI70hRv.d.mts → types-D0jOlnAF.d.mts} +1 -0
- package/dist/dts/{types-BQI70hRv.d.ts → types-D0jOlnAF.d.ts} +1 -0
- package/dist/dts/ui.d.mts +1 -1
- package/dist/dts/ui.d.ts +1 -1
- package/dist/esm/{SignRequestScreen-C_hOFegy.mjs → SignRequestScreen-NOqdMm22.mjs} +1 -1
- package/dist/esm/abstract-smart-wallets.mjs +1 -1
- package/dist/esm/extended-chains.mjs +1 -1
- package/dist/esm/farcaster.mjs +1 -1
- package/dist/esm/index.mjs +6 -6
- package/dist/esm/{internal-context-B0qoKMVz.mjs → internal-context-LlMdpfkb.mjs} +1 -1
- package/dist/esm/{privy-context-DvKRpqkM.mjs → privy-context-V2csHgUI.mjs} +1 -1
- package/dist/esm/{smart-wallets-CAnrtQOj.mjs → smart-wallets-DXnL6fHN.mjs} +1 -1
- package/dist/esm/smart-wallets.mjs +1 -1
- package/dist/esm/solana.mjs +1 -1
- package/dist/esm/ui.mjs +2 -2
- package/dist/esm/use-export-wallet-Duyde2UB.mjs +1 -0
- package/dist/esm/{use-sign-with-user-signer-Bwzp21df.mjs → use-sign-with-user-signer-DwqsbciW.mjs} +1 -1
- package/dist/esm/{useActiveWallet-CbqIRPmU.mjs → useActiveWallet-58s-VNmj.mjs} +1 -1
- package/dist/esm/{usePrivy-BVeHvDov.mjs → usePrivy-ZXeOLg-E.mjs} +1 -1
- package/package.json +4 -4
- package/dist/cjs/useFundWallet-F-byjhI0.js +0 -2
- package/dist/esm/useFundWallet-CkgUMUp9.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,
|
|
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 +1 @@
|
|
|
1
|
-
import{getAddress as e}from"viem";import{createContext as t,useContext as i}from"react";import{n as a}from"./internal-context-
|
|
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 e?new Date(1e3*e):null}function s(e,t){return e.slice().sort(((e,t)=>(e.firstVerifiedAt?.getTime()??0)-(t.firstVerifiedAt?.getTime()??0))).find((e=>e.type===t))}const l=e=>e?n(e).find((e=>0===e.walletIndex))??null:null,n=e=>e?d(e,"ethereum"):[],d=(e,t)=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&e.chainType===t)),u=e=>e?d(e,"solana"):[],p=e=>e?u(e).find((e=>0===e.walletIndex))??null:null,o=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType))||null,m=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType))||null;let c=(t,i)=>t===i||!(!t.startsWith("0x")||!i.startsWith("0x"))&&e(t)===e(i);const f=(e,t)=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&c(e.address,t)))||null,_=(e,t)=>e.find((e=>c(e.address,t)))||null,y=e=>l(e)??p(e);function h(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: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};t.push(a);break;case"smart_wallet":let s={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(s);break;case"cross_app":let l={type:i.type,subject:i.subject,embeddedWallets:i.embedded_wallets,smartWallets:i.smart_wallets,providerApp:{id:i.provider_app_id},firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(l);break;case"email":let n={address:i.address,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(n);break;case"phone":let d={number:i.phoneNumber,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(d);break;case"google_oauth":let u={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(u);break;case"spotify_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"instagram_oauth":let o={subject:i.subject,username:i.username,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(o);break;case"twitter_oauth":let m={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(m);break;case"discord_oauth":let c={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(c);break;case"github_oauth":let f={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(f);break;case"tiktok_oauth":let _={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(_);break;case"line_oauth":let y={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(y);break;case"linkedin_oauth":let h={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(h);break;case"apple_oauth":let b={subject:i.subject,email:i.email,type:i.type,firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(b);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 k={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(k);break;case"passkey":let v={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(v);break;case"telegram":let A={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(A);break;default:console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),i=s(t,"wallet"),a=s(t,"smart_wallet"),l=s(t,"email"),n=s(t,"phone"),d=s(t,"google_oauth"),u=s(t,"twitter_oauth"),p=s(t,"discord_oauth"),o=s(t,"github_oauth"),m=s(t,"spotify_oauth"),c=s(t,"instagram_oauth"),f=s(t,"tiktok_oauth"),_=s(t,"line_oauth"),y=s(t,"linkedin_oauth"),h=s(t,"apple_oauth"),b=s(t,"farcaster"),k=s(t,"telegram"),v=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:r(t)})));return{id:e.id,createdAt:r(e.created_at),linkedAccounts:t,email:l&&{address:l?.address},phone:n&&{number:n?.number},wallet:i&&{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},smartWallet:a&&{address:a.address,smartWalletType:a.smartWalletType,smartWalletVersion:a.smartWalletVersion},google:d&&{subject:d.subject,email:d.email,name:d.name},twitter:u&&{subject:u.subject,username:u.username,name:u.name,profilePictureUrl:u.profilePictureUrl},discord:p&&{subject:p.subject,username:p.username,email:p.email},github:o&&{subject:o.subject,username:o.username,name:o.name,email:o.email},spotify:m&&{subject:m.subject,email:m.email,name:m.name},instagram:c&&{subject:c.subject,username:c.username},tiktok:f&&{subject:f.subject,username:f.username,name:f.name},line:_&&{subject:_.subject,name:_.name,email:_.email,profilePictureUrl:_.profilePictureUrl},linkedin:y&&{subject:y.subject,name:y.name,email:y.email,vanityName:y.vanityName},apple:h&&{subject:h.subject,email:h.email},farcaster:b&&{fid:b.fid,ownerAddress:b.ownerAddress,displayName:b.displayName,username:b.username,bio:b.bio,pfp:b.pfp,url:b.url,signerPublicKey:b.signerPublicKey},telegram:k&&{telegramUserId:k.telegramUserId,firstName:k.firstName,lastName:k.lastName,username:k.username,photoUrl:k.photoUrl},delegatedWallets:[],mfaMethods:v.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}}const b=e=>!!e.id&&"privy-v2"===e.recoveryMethod,k=/*#__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,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,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(k);export{k as P,y as a,l as b,h as c,n as d,o as e,f,b as g,_ as h,m as i,u as j,p as k,d as l,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-DvKRpqkM.mjs";import{c3 as l,ar as c,am as d,ae as u,z as m,bU as p,bV as y,bx as g}from"./SignRequestScreen-C_hOFegy.mjs";import{P as f}from"./paths-B891YjWw.mjs";import{u as h}from"./internal-context-B0qoKMVz.mjs";import{g as w}from"./getEmbeddedConnectedWallet-CSSBWE2p.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),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-V2csHgUI.mjs";import{c3 as l,ar as c,am as d,ae as u,z as m,bU as p,bV as y,bx as g}from"./SignRequestScreen-NOqdMm22.mjs";import{P as f}from"./paths-B891YjWw.mjs";import{u as h}from"./internal-context-LlMdpfkb.mjs";import{g as w}from"./getEmbeddedConnectedWallet-CSSBWE2p.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),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 +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-
|
|
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-V2csHgUI.mjs";import{ar as a,ae as l}from"./SignRequestScreen-NOqdMm22.mjs";import{P as s}from"./paths-B891YjWw.mjs";import{g as m}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import{u as p,g as h,a as u}from"./smart-wallets-DXnL6fHN.mjs";import{u as d,n as g}from"./internal-context-LlMdpfkb.mjs";import"viem";import"@heroicons/react/24/outline/CheckCircleIcon";import"@privy-io/js-sdk-core";import"@heroicons/react/24/outline/InformationCircleIcon";import"styled-components";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"viem/utils";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"@heroicons/react/24/outline/ChevronDownIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"ofetch";import"@heroicons/react/24/outline";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@privy-io/ethereum";import"lucide-react";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@scure/base";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/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/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"eventemitter3";import"zustand";import"@walletconnect/ethereum-provider";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);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};
|
package/dist/esm/solana.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as o}from"react";import{
|
|
1
|
+
import{useCallback as o}from"react";import{d as e,a as r}from"./usePrivy-ZXeOLg-E.mjs";import{cy as t,az as n,ar as i,bz as s,cz as l,c1 as m,bO as p}from"./SignRequestScreen-NOqdMm22.mjs";import{u as h}from"./internal-context-LlMdpfkb.mjs";import{u as d}from"./privy-context-V2csHgUI.mjs";import{pipe as f,createTransactionMessage as g,setTransactionMessageFeePayerSigner as y,setTransactionMessageLifetimeUsingBlockhash as I,appendTransactionMessageInstructions as w,compileTransaction as v,getTransactionEncoder as C,address as k,setTransactionMessageFeePayer as A,blockhash as S,getTransactionDecoder as T}from"@solana/kit";import{g as x,s as E,b as W,f as b}from"./use-export-wallet-Duyde2UB.mjs";export{a as useExportWallet,u as useFundWallet,c as useWallets}from"./use-export-wallet-Duyde2UB.mjs";import{base64 as j}from"@scure/base";import{getAddMemoInstruction as P}from"@solana-program/memo";import{getWallets as F}from"@wallet-standard/app";import"./paths-B891YjWw.mjs";import"ofetch";import"@privy-io/js-sdk-core";import"react/jsx-runtime";import"@heroicons/react/24/outline/CheckCircleIcon";import"viem";import"@heroicons/react/24/outline/InformationCircleIcon";import"styled-components";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"viem/utils";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@headlessui/react";import"@heroicons/react/24/outline/ChevronDownIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@privy-io/ethereum";import"lucide-react";import"@heroicons/react/24/outline/ExclamationTriangleIcon";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/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/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"eventemitter3";import"zustand";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/FingerPrintIcon";import"./use-sign-with-user-signer-DwqsbciW.mjs";import"@solana-program/system";import"@solana-program/token";const M=o=>{let e,{get:r,on:n}=F(),i=o?.shouldAutoConnect??!0,a=new Map,s=[];function c(...o){o.forEach((o=>!(o.features["privy:"]&&"isPrivyWallet"in o&&o.isPrivyWallet)&&!a.has(o.name)&&a.set(o.name,o))),s=Array.from(a.values()).map((o=>new t(o,i))),e?.(s)}function l(...o){Array.from(a.values()).forEach((e=>!o.includes(e)&&a.delete(e.name))),s=Array.from(a.values()).map((o=>new t(o,i))),e?.(s)}let m=[n("register",c),n("unregister",l)];return c(...r()),{_setOnConnectorsUpdated:o=>{e=o},onMount:()=>{m[0]||(m[0]=n("register",c)),m[1]||(m[1]=n("unregister",l))},onUnmount:()=>{let o=m.pop();for(;o;)o(),o=m.pop()},get:()=>s}},U=()=>{let{user:r}=d(),{client:t,refreshSessionAndUser:a,initializeWalletProxy:s}=h(),c=n(),l=i();return{importWallet:o((({privateKey:o})=>e({getAccessToken:()=>t.getAccessToken(),user:r,initializeWalletProxy:s,refreshSessionAndUser:a,emitPrivyEvent:c,appConfig:l},{privateKey:o,chainType:"solana"})),[r,t,a,s,c])}};var D={id:s,getSolanaRpcClient:x,createTransactionFromRelayQuote:async function({solanaClient:o,quote:e,source:r}){let t=e.steps[0]?.items?.[0];if(!t)throw Error("Invalid quote");let n=t.data.instructions.map((({keys:o,programId:e,data:r})=>({accounts:o.map((({pubkey:o,isSigner:e,isWritable:r})=>({address:o,role:e&&r?3:e&&!r?2:!e&&r?1:0}))),programAddress:e,data:new Uint8Array(Buffer.from(r,"hex"))}))),{value:i}=await o.rpc.getLatestBlockhash().send(),a=f(g({version:0}),(o=>y({address:r},o)),(o=>I(i,o)),(o=>w(n,o)),(o=>v(o)));return new Uint8Array(C().encode(a))},simulateTransaction:E,getAddressFromBuffer:W,fetchTransactionEstimatedFees:b},R=()=>l(D);var q={id:p,createSiwsMemoTransaction:({address:o,nonce:e})=>{let r=P({memo:m({address:k(o),nonce:e})});return f(g({version:"legacy"}),(e=>A(k(o),e)),(o=>I({blockhash:S("GfVcyD5fWFJ6hRm8bsy7CoVPsLSoJhtJKRJYk8T2VVFN"),lastValidBlockHeight:0n},o)),(o=>w([r],o)),(o=>v(o)),(o=>j.encode(Uint8Array.from(C().encode(o)))))},getSignatureFromTransaction:(o,e)=>{let r=T().decode(o).signatures[e];if(!r)throw Error(`Missing transaction signature for address: ${e}`);return j.encode(r)}},z=()=>l(q);function L(){let{create:o}=r();return{createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let{account:r}=await o({chainType:"solana",options:e});return{wallet:r}}}}function V(){return{signMessage:async({message:o,wallet:e,options:r})=>await e.signMessage({message:o,options:r})}}function B(){return{signTransaction:async({transaction:o,wallet:e,chain:r="solana:mainnet",options:t})=>await e.signTransaction({transaction:o,chain:r,options:t})}}function J(){return{signAndSendTransaction:async({transaction:o,wallet:e,chain:r="solana:mainnet",options:t})=>await e.signAndSendTransaction({transaction:o,chain:r,options:t})}}export{t as SolanaAdapterConnector,M as toSolanaWalletConnectors,L as useCreateWallet,U as useImportWallet,J as useSignAndSendTransaction,V as useSignMessage,B as useSignTransaction,R as useSolanaFundingPlugin,z as useSolanaLedgerPlugin};
|