@privy-io/react-auth 2.19.2 → 2.20.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 (43) hide show
  1. package/dist/cjs/abstract-smart-wallets.js +1 -1
  2. package/dist/cjs/extended-chains.js +1 -1
  3. package/dist/cjs/index.js +1 -1
  4. package/dist/cjs/{privy-provider-DSwXDdcX.js → privy-provider-C10uh7jj.js} +28 -28
  5. package/dist/cjs/smart-wallets-BZ1m1NrG.js +1 -0
  6. package/dist/cjs/smart-wallets.js +1 -1
  7. package/dist/cjs/solana.js +1 -1
  8. package/dist/cjs/ui.js +1 -1
  9. package/dist/cjs/use-sign-with-user-signer-pdwGPuUl.js +1 -0
  10. package/dist/cjs/{useActiveWallet-Dv_ZghMS.js → useActiveWallet-Bwo1C1JJ.js} +1 -1
  11. package/dist/cjs/{useFundWallet-B6An-q7Z.js → useFundWallet-w17P8l1R.js} +1 -1
  12. package/dist/dts/extended-chains.d.mts +1 -1
  13. package/dist/dts/extended-chains.d.ts +1 -1
  14. package/dist/dts/farcaster.d.mts +1 -1
  15. package/dist/dts/farcaster.d.ts +1 -1
  16. package/dist/dts/index.d.mts +7 -5
  17. package/dist/dts/index.d.ts +7 -5
  18. package/dist/dts/smart-wallets.d.mts +3 -2
  19. package/dist/dts/smart-wallets.d.ts +3 -2
  20. package/dist/dts/solana.d.mts +4 -4
  21. package/dist/dts/solana.d.ts +4 -4
  22. package/dist/dts/{types-ZqHmGCwO.d.mts → types-Dmys-XR7.d.mts} +3 -0
  23. package/dist/dts/{types-ZqHmGCwO.d.ts → types-Dmys-XR7.d.ts} +3 -0
  24. package/dist/dts/ui.d.mts +1 -1
  25. package/dist/dts/ui.d.ts +1 -1
  26. package/dist/dts/{useSolanaWallets-idhSZbQC.d.mts → useSolanaWallets-C9c0550h.d.mts} +1 -1
  27. package/dist/dts/{useSolanaWallets-idhSZbQC.d.ts → useSolanaWallets-C9c0550h.d.ts} +1 -1
  28. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  29. package/dist/esm/extended-chains.mjs +1 -1
  30. package/dist/esm/index.mjs +1 -1
  31. package/dist/esm/{privy-provider-B0E_t4-_.mjs → privy-provider-DRh_qFir.mjs} +28 -28
  32. package/dist/esm/smart-wallets-BVE7Yf57.mjs +1 -0
  33. package/dist/esm/smart-wallets.mjs +1 -1
  34. package/dist/esm/solana.mjs +1 -1
  35. package/dist/esm/ui.mjs +1 -1
  36. package/dist/esm/use-sign-with-user-signer-CyFzXla-.mjs +1 -0
  37. package/dist/esm/{useActiveWallet-Cqbk2Bwf.mjs → useActiveWallet-BrSwJdVC.mjs} +1 -1
  38. package/dist/esm/{useFundWallet-BjGzb-ri.mjs → useFundWallet-Ca0OzIi8.mjs} +1 -1
  39. package/package.json +7 -7
  40. package/dist/cjs/smart-wallets-IHcyZonv.js +0 -1
  41. package/dist/cjs/use-sign-with-user-signer-BQ_24mRh.js +0 -1
  42. package/dist/esm/smart-wallets-BuX2Ltru.mjs +0 -1
  43. package/dist/esm/use-sign-with-user-signer-DnNPDfxp.mjs +0 -1
@@ -1 +1 @@
1
- import{useCallback as e}from"react";import{aY as a,aX as t,u as n,o as s,e as r,aU as o,aZ as c,a_ as i}from"./privy-provider-B0E_t4-_.mjs";import{getAssociatedTokenAddressSync as l,createAssociatedTokenAccountIdempotentInstruction as d,createTransferInstruction as m}from"@solana/spl-token";import{Connection as u,PublicKey as p,Transaction as w,SystemProgram as f,TransactionInstruction as h,VersionedTransaction as k,TransactionMessage as y}from"@solana/web3.js";import{getSolanaRpcEndpointForCluster as g,SolanaClient as b}from"@privy-io/js-sdk-core";import{u as B}from"./internal-context-qdNgTV5f.mjs";var T={id:a,getBalance:({address:e,cluster:a})=>new u(g(a)).getBalance(new p(e)),getTokenBalance:async({address:e,cluster:a,mintAddress:t})=>await new b({...a,rpcUrl:g(a)}).getTokenAccountsByOwner(e,t)||{amount:BigInt(0),decimals:9},createTransferTransaction:async({from:e,to:a,amount:t,cluster:n})=>{let s=new p(e),r=new w;r.add(f.transfer({fromPubkey:s,toPubkey:new p(a),lamports:t}));let o=new u(g(n)),c=await o.getLatestBlockhash();return r.recentBlockhash=c.blockhash,r.feePayer=s,{transaction:r,connection:o}},createSplTransferTransaction:async({from:e,to:a,amount:t,cluster:n,mintAddress:s})=>{let r=new p(s),o=new p(e),c=new p(a),i=new w,f=l(r,o),h=l(r,c);i.add(d(o,h,c,r)),i.add(m(f,h,o,t));let k=new u(g(n)),y=await k.getLatestBlockhash();return i.recentBlockhash=y.blockhash,i.feePayer=o,{transaction:i,connection:k}},createBridgeTransactionFromRelayQuote:async({quote:e,from:a,cluster:n})=>{let s=e.steps[0]?.items?.[0];if(!s)return;let r=s.data.instructions.map((({keys:e,programId:a,data:n})=>new h({keys:e.map((({pubkey:e,isSigner:a,isWritable:t})=>({pubkey:new p(e),isSigner:a,isWritable:t}))),programId:new p(a),data:t(n,"hex")}))),o=s.data.addressLookupTableAddresses?.map((e=>new p(e))),c=new u(g(n)),i=await Promise.all((o??[]).map((async e=>c.getAddressLookupTable(e).then((e=>e.value))))),{blockhash:l}=await c.getLatestBlockhash();return{transaction:new k(new y({payerKey:new p(a),instructions:r,recentBlockhash:l}).compileToV0Message(i)),connection:c}}};const v=a=>{n("fundSolanaWallet",a);let t=s(),{setModalData:l}=r(),{openModal:d}=B();return o(T),{fundWallet:e((async(e,a)=>{l({funding:c({address:e,appConfig:t,fundWalletConfig:a,methodScreen:i})}),d(i)}),[t,l,d])}};export{T as t,v as u};
1
+ import{useCallback as e}from"react";import{aY as a,aX as t,u as n,o as s,e as r,aU as o,aZ as c,a_ as i}from"./privy-provider-DRh_qFir.mjs";import{getAssociatedTokenAddressSync as l,createAssociatedTokenAccountIdempotentInstruction as d,createTransferInstruction as m}from"@solana/spl-token";import{Connection as u,PublicKey as p,Transaction as w,SystemProgram as f,TransactionInstruction as h,VersionedTransaction as k,TransactionMessage as y}from"@solana/web3.js";import{getSolanaRpcEndpointForCluster as g,SolanaClient as b}from"@privy-io/js-sdk-core";import{u as B}from"./internal-context-qdNgTV5f.mjs";var T={id:a,getBalance:({address:e,cluster:a})=>new u(g(a)).getBalance(new p(e)),getTokenBalance:async({address:e,cluster:a,mintAddress:t})=>await new b({...a,rpcUrl:g(a)}).getTokenAccountsByOwner(e,t)||{amount:BigInt(0),decimals:9},createTransferTransaction:async({from:e,to:a,amount:t,cluster:n})=>{let s=new p(e),r=new w;r.add(f.transfer({fromPubkey:s,toPubkey:new p(a),lamports:t}));let o=new u(g(n)),c=await o.getLatestBlockhash();return r.recentBlockhash=c.blockhash,r.feePayer=s,{transaction:r,connection:o}},createSplTransferTransaction:async({from:e,to:a,amount:t,cluster:n,mintAddress:s})=>{let r=new p(s),o=new p(e),c=new p(a),i=new w,f=l(r,o),h=l(r,c);i.add(d(o,h,c,r)),i.add(m(f,h,o,t));let k=new u(g(n)),y=await k.getLatestBlockhash();return i.recentBlockhash=y.blockhash,i.feePayer=o,{transaction:i,connection:k}},createBridgeTransactionFromRelayQuote:async({quote:e,from:a,cluster:n})=>{let s=e.steps[0]?.items?.[0];if(!s)return;let r=s.data.instructions.map((({keys:e,programId:a,data:n})=>new h({keys:e.map((({pubkey:e,isSigner:a,isWritable:t})=>({pubkey:new p(e),isSigner:a,isWritable:t}))),programId:new p(a),data:t(n,"hex")}))),o=s.data.addressLookupTableAddresses?.map((e=>new p(e))),c=new u(g(n)),i=await Promise.all((o??[]).map((async e=>c.getAddressLookupTable(e).then((e=>e.value))))),{blockhash:l}=await c.getLatestBlockhash();return{transaction:new k(new y({payerKey:new p(a),instructions:r,recentBlockhash:l}).compileToV0Message(i)),connection:c}}};const v=a=>{n("fundSolanaWallet",a);let t=s(),{setModalData:l}=r(),{openModal:d}=B();return o(T),{fundWallet:e((async(e,a)=>{l({funding:c({address:e,appConfig:t,fundWalletConfig:a,methodScreen:i})}),d(i)}),[t,l,d])}};export{T as t,v as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/react-auth",
3
- "version": "2.19.2",
3
+ "version": "2.20.0",
4
4
  "description": "React client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",
@@ -144,7 +144,7 @@
144
144
  "not op_mini all"
145
145
  ],
146
146
  "dependencies": {
147
- "@base-org/account": "^1.0.0",
147
+ "@base-org/account": "^1.1.0",
148
148
  "@coinbase/wallet-sdk": "4.3.2",
149
149
  "@floating-ui/react": "^0.26.22",
150
150
  "@headlessui/react": "^2.2.0",
@@ -152,9 +152,9 @@
152
152
  "@marsidev/react-turnstile": "^0.4.1",
153
153
  "@metamask/eth-sig-util": "^6.0.0",
154
154
  "@privy-io/chains": "0.0.2",
155
- "@privy-io/js-sdk-core": "0.52.9",
155
+ "@privy-io/js-sdk-core": "0.53.0",
156
156
  "@privy-io/ethereum": "0.0.2",
157
- "@privy-io/public-api": "2.40.0",
157
+ "@privy-io/public-api": "2.40.1",
158
158
  "@privy-io/api-base": "1.5.2",
159
159
  "@reown/appkit": "^1.7.11",
160
160
  "@scure/base": "^1.2.5",
@@ -164,7 +164,7 @@
164
164
  "@solana/wallet-standard-wallet-adapter-react": "^1.1.2",
165
165
  "@tanstack/react-virtual": "^3.13.10",
166
166
  "@wallet-standard/app": "^1.0.1",
167
- "@walletconnect/ethereum-provider": "2.19.2",
167
+ "@walletconnect/ethereum-provider": "2.21.5",
168
168
  "base64-js": "^1.5.1",
169
169
  "dotenv": "^16.0.3",
170
170
  "encoding": "^0.1.13",
@@ -184,7 +184,7 @@
184
184
  "stylis": "^4.3.4",
185
185
  "tinycolor2": "^1.6.0",
186
186
  "uuid": ">=8 <10",
187
- "viem": "^2.30.6",
187
+ "viem": "^2.32.0",
188
188
  "zustand": "^5.0.0"
189
189
  },
190
190
  "devDependencies": {
@@ -197,7 +197,7 @@
197
197
  "@privy-io/build-config": "*",
198
198
  "@privy-io/eslint-config-custom": "*",
199
199
  "@privy-io/eslint-plugin-privy-rules": "*",
200
- "@privy-io/public-api": "2.40.0",
200
+ "@privy-io/public-api": "2.40.1",
201
201
  "@privy-io/testing": "*",
202
202
  "@rollup/plugin-commonjs": "^26.0.1",
203
203
  "@rollup/plugin-node-resolve": "^15.3.0",
@@ -1 +0,0 @@
1
- "use strict";var e=require("react"),t=require("viem"),r=require("./use-sign-with-user-signer-BQ_24mRh.js"),n=require("./privy-provider-DSwXDdcX.js"),a=require("./paths-B00ZrFQm.js"),i=require("./internal-context-B_aIJuQh.js"),s=require("./getEmbeddedConnectedWallet-DTU4T9TJ.js"),o=require("permissionless"),l=require("permissionless/accounts"),c=require("permissionless/clients/pimlico"),d=require("viem/account-abstraction"),u=require("@privy-io/js-sdk-core");let p={address:d.entryPoint06Address,version:"0.6"},y={address:d.entryPoint07Address,version:"0.7"},m=({owner:e,smartWalletType:t,publicClient:r})=>{switch(t){case u.SAFE:return l.toSafeSmartAccount({client:r,entryPoint:y,owners:[e],version:"1.4.1"});case u.KERNEL:return l.toKernelSmartAccount({client:r,version:"0.3.1",entryPoint:y,useMetaFactory:"optional",owners:[e]});case u.BICONOMY:return l.toBiconomySmartAccount({client:r,owners:[e],entryPoint:p});case u.LIGHT_ACCOUNT:return l.toLightSmartAccount({client:r,entryPoint:p,owner:e,version:"1.1.0"});case u.COINBASE_SMART_WALLET:return async function({client:e,owner:t}){let[r]=await t.request({method:"eth_accounts"});if(!r)throw Error("Unable to request embedded owner for eth_accounts");return await d.toCoinbaseSmartAccount({client:e,version:"1",owners:[{type:"local",source:"privy",address:r,sign:async({hash:e})=>await t.request({method:"secp256k1_sign",params:[e]})}]})}({client:r,owner:e});case u.THIRDWEB:return l.toThirdwebSmartAccount({client:r,entryPoint:y,owner:e});default:throw Error(`Invalid smart account type: ${t}.`)}};const g=({calls:e,chain:t,maxPriorityFeePerGas:r,maxFeePerGas:n,nonce:a})=>e.map((e=>({to:e.to||void 0,data:e.data,value:e.value,chainId:t.id,nonce:a,maxFeePerGas:n,maxPriorityFeePerGas:r}))),h=async({chain:e,paymasterContext:r,account:i,signer:s,user:l,smartWalletsConfig:d,rpcConfig:u,privyAppId:p})=>{if(!(d?.enabled&&l&&i&&s))return;let y=d?.configuredNetworks.find((t=>t.chainId===`eip155:${e.id}`));if(!y)throw new a.PrivyClientError(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let g=l.smartWallet?.smartWalletType??d.smartWalletType,h=n.getJsonRpcEndpointFromChain(e,u,p),P=t.createPublicClient({chain:e,transport:t.http(h)}),f=r??y.paymasterContext,w=await(async({owner:e,smartWalletType:r,chain:n,publicClient:a,bundlerUrl:i,paymasterUrl:s,paymasterContext:l})=>{let d=await m({owner:e,smartWalletType:r,publicClient:a}),u=c.createPimlicoClient({transport:t.http(i),entryPoint:d.entryPoint}),p=s?c.createPimlicoClient({transport:t.http(s),entryPoint:d.entryPoint}):void 0;return o.createSmartAccountClient({account:d,chain:n,paymaster:p,paymasterContext:l,bundlerTransport:t.http(i),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>i.includes(e))))return await u.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>i.includes(e))))return(await u.request({method:"zd_getUserOperationGasPrice",params:[]})).fast;if(["g.alchemy.com"].some((e=>i.includes(e)))){let[e,t]=await Promise.all([a.getBlock({blockTag:"latest"}),u.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 a.estimateFeesPerGas(),t=i.includes("api.developer.coinbase.com")?175n:150n;return{...e,maxFeePerGas:e.maxFeePerGas*t/100n,maxPriorityFeePerGas:e.maxPriorityFeePerGas*t/100n}}}}})})({owner:s,smartWalletType:g,chain:e,publicClient:P,paymasterContext:f,...y});if(!w)throw new a.PrivyClientError(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return w};exports.callsToTransactionRequests=g,exports.getSmartWalletClient=h,exports.useSmartWalletsUIWrapper=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:a}=i.usePrivyInternal(),{setModalData:s}=n.usePrivyModal(),{user:o}=r.usePrivyContext(),l=r.getPrivyEthereumWallet(o),c=!!l&&r.getIsUnifiedWallet(l);return{wrapSmartAccountClientWithUIs:r=>({...r,sendTransaction:async(i,d)=>{if(a({showWalletUIs:d?.uiOptions?.showWalletUIs}))return e.current=!0,await r.sendTransaction(i).finally((()=>e.current=!1));let u=[];"calls"in i&&void 0!==i.calls?u=[...i.calls]:"to"in i&&(u=[{to:i.to,value:i.value||BigInt(0),data:i.data||"0x"}]);let p=async()=>{if(!r.paymaster)return!1;let{paymasterData:e,paymasterAndData:t}=await r.prepareUserOperation({calls:u,maxFeePerGas:i.maxFeePerGas,maxPriorityFeePerGas:i.maxPriorityFeePerGas,nonce:i.nonce?BigInt(i.nonce):void 0});return Number(t??e??0)>0};return new Promise((async(a,y)=>{e.current=!0;let{entropyId:m,entropyIdVerifier:h}=n.getEntropyDetailsForUser(o);s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:m,entropyIdVerifier:h,onCompleteNavigateTo:n.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:u,chain:r.chain,maxPriorityFeePerGas:i.maxPriorityFeePerGas,maxFeePerGas:i.maxFeePerGas,nonce:i.nonce?BigInt(i.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:m,entropyIdVerifier:h,getIsSponsored:p,signOnly:!1,onConfirm:()=>r.sendTransaction(i),onSuccess:e=>a(e.hash),onFailure:y,uiOptions:d?.uiOptions??{}}}),t(n.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))},signMessage:async(i,d)=>a({showWalletUIs:d?.uiOptions?.showWalletUIs})?(e.current=!0,await r.signMessage(i).finally((()=>e.current=!1))):new Promise((async(a,u)=>{let{entropyId:p,entropyIdVerifier:y}=n.getEntropyDetailsForUser(o);e.current=!0,s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof i.message?i.message:i.message.raw.toString(),confirmAndSign:()=>r.signMessage(i),onSuccess:e=>a(e),onFailure:u,uiOptions:d?.uiOptions??{}}}),t(n.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1})),signTypedData:async(i,d)=>a({showWalletUIs:d?.uiOptions?.showWalletUIs})?(e.current=!0,await r.signTypedData(i).finally((()=>e.current=!1))):new Promise((async(a,u)=>{e.current=!0;let{entropyId:p,entropyIdVerifier:y}=n.getEntropyDetailsForUser(o);s({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:i,confirmAndSign:()=>r.signTypedData(i),onSuccess:e=>a(e),onFailure:u,uiOptions:d?.uiOptions??{}}}),t(n.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))})}},exports.useSmartWalletsWrapper=({clientConfig:t,smartWalletsConfig:o})=>{let{hideWalletUIs:l,openPrivyModal:c,appId:d,isHeadlessSigning:u}=i.usePrivyInternal(),p=n.useAppConfig(),{setModalData:y}=n.usePrivyModal(),{user:m}=r.usePrivyContext(),{chains:P}=n.useAppConfig(),{chainId:f,clients:w,setChainId:I,chainIdState:v}=(()=>{let t=e.useRef(),[r,n]=e.useState();return{clients:e.useRef({}),setChainId:e=>{t.current=e,n(e)},chainId:t,chainIdState:r}})(),W=P.find((e=>e.id===v)),{wallets:C}=n.useWallets(),S=r.getPrivyEthereumWallet(m),F=s.getEmbeddedConnectedWallet(C),x=!!S&&r.getIsUnifiedWallet(S),T=e.useCallback((async()=>f.current),[f]),U=e.useCallback((async({id:e})=>{if(!w.current[e]){let r=await h({chain:P.find((t=>t.id===e)),account:S,signer:await(F?.getEthereumProvider()),user:m,paymasterContext:t?.paymasterContext,smartWalletsConfig:o,rpcConfig:p.rpcConfig,privyAppId:d});r&&(w.current[e]=r)}I(e)}),[P,t,C,m,o]);return{wrapSmartAccountClient:e=>{w.current[e.chain.id]=e,v||I(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let r=w.current[f.current];if(!r)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);if(delete e.account,u({showWalletUIs:t?.uiOptions?.showWalletUIs}))return l.current=!0,await r.sendTransaction(e).finally((()=>l.current=!1));let i=[];"calls"in e&&void 0!==e.calls?i=[...e.calls]:"to"in e&&(i=[{to:e.to,value:e.value||BigInt(0),data:e.data||"0x"}]);let s=async()=>{let{paymasterAndData:t,paymasterData:n,maxFeePerGas:a,maxPriorityFeePerGas:s}=await r.prepareUserOperation({calls:i,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return 0===Number(a)&&0===Number(s)||Number(t??n??0)>0};return new Promise((async(a,o)=>{l.current=!0;let{entropyId:d,entropyIdVerifier:u}=n.getEntropyDetailsForUser(m);y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:d,entropyIdVerifier:u,onCompleteNavigateTo:n.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:g({calls:i,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:d,entropyIdVerifier:u,getIsSponsored:s,signOnly:!1,onConfirm:()=>r.sendTransaction(e),onSuccess:e=>a(e.hash),onFailure:o,uiOptions:t?.uiOptions??{}}}),c(n.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},signMessage:async(e,t)=>{let r=w.current[f.current];if(!r)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);return u({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await r.signMessage(e).finally((()=>l.current=!1))):new Promise((async(a,i)=>{let{entropyId:s,entropyIdVerifier:o}=n.getEntropyDetailsForUser(m);l.current=!0,y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:s,entropyIdVerifier:o,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof e.message?e.message:e.message.raw.toString(),confirmAndSign:()=>r.signMessage(e),onSuccess:e=>a(e),onFailure:i,uiOptions:t?.uiOptions??{}}}),c(n.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},signTypedData:async(e,t)=>{let r=w.current[f.current];if(!r)throw new a.PrivyClientError(`Smart wallet client for chain (eip155:${f.current}) not found`);return delete e.account,u({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await r.signTypedData(e).finally((()=>l.current=!1))):new Promise((async(a,i)=>{l.current=!0;let{entropyId:s,entropyIdVerifier:o}=n.getEntropyDetailsForUser(m);y({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:x,entropyId:s,entropyIdVerifier:o,onCompleteNavigateTo:n.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>a(e),onFailure:i,uiOptions:t?.uiOptions??{}}}),c(n.EmbeddedWalletConnectingScreen)})).finally((()=>{l.current=!1}))},getChainId:T,chain:W,switchChain:U}}}};
@@ -1 +0,0 @@
1
- "use strict";var e=require("viem"),t=require("react"),i=require("./internal-context-B_aIJuQh.js");function r(e){return e?new Date(1e3*e):null}function a(e,t){return e.slice().sort(((e,t)=>(e.firstVerifiedAt??e.verifiedAt).getTime()-(t.firstVerifiedAt??t.verifiedAt).getTime())).find((e=>e.type===t))}const l=e=>e?n(e).find((e=>0===e.walletIndex))??null:null,n=e=>e?s(e,"ethereum"):[],s=(e,t)=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&e.chainType===t)),d=e=>e?s(e,"solana"):[],m=e=>e?d(e).find((e=>0===e.walletIndex))??null:null;let o=(t,i)=>t===i||!(!t.startsWith("0x")||!i.startsWith("0x"))&&e.getAddress(t)===e.getAddress(i);const p=/*#__PURE__*/t.createContext({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:i.notImplemented,login:i.notImplemented,connectOrCreateWallet:i.notImplemented,linkEmail:i.notImplemented,linkPhone:i.notImplemented,linkFarcaster:i.notImplemented,linkWallet:i.notImplemented,startCrossAppAuthFlow:i.notImplemented,linkGoogle:i.notImplemented,linkTwitter:i.notImplemented,linkDiscord:i.notImplemented,linkGithub:i.notImplemented,linkSpotify:i.notImplemented,linkInstagram:i.notImplemented,linkTelegram:i.notImplemented,linkTiktok:i.notImplemented,linkLine:i.notImplemented,linkLinkedIn:i.notImplemented,linkApple:i.notImplemented,linkPasskey:i.notImplemented,updateEmail:i.notImplemented,updatePhone:i.notImplemented,logout:i.notImplemented,getAccessToken:i.notImplemented,unlinkEmail:i.notImplemented,unlinkPhone:i.notImplemented,unlinkWallet:i.notImplemented,unlinkGoogle:i.notImplemented,unlinkTwitter:i.notImplemented,unlinkDiscord:i.notImplemented,unlinkGithub:i.notImplemented,unlinkSpotify:i.notImplemented,unlinkInstagram:i.notImplemented,unlinkTiktok:i.notImplemented,unlinkLine:i.notImplemented,unlinkLinkedIn:i.notImplemented,unlinkApple:i.notImplemented,unlinkCrossAppAccount:i.notImplemented,unlinkFarcaster:i.notImplemented,unlinkTelegram:i.notImplemented,unlinkPasskey:i.notImplemented,signMessage:i.notImplemented,signTypedData:i.notImplemented,enrollInMfa:i.notImplemented,initEnrollmentWithSms:i.notImplemented,initEnrollmentWithTotp:i.notImplemented,initEnrollmentWithPasskey:i.notImplemented,promptMfa:i.notImplemented,init:i.notImplemented,submitEnrollmentWithSms:i.notImplemented,submitEnrollmentWithTotp:i.notImplemented,submitEnrollmentWithPasskey:i.notImplemented,unenroll:i.notImplemented,submit:i.notImplemented,cancel:i.notImplemented,sendTransaction:i.notImplemented,signTransaction:i.notImplemented,exportWallet:i.notImplemented,setWalletPassword:i.notImplemented,setWalletRecovery:i.notImplemented,requestFarcasterSignerFromWarpcast:i.notImplemented,getFarcasterSignerPublicKey:i.notImplemented,signFarcasterMessage:i.notImplemented,signMessageWithCrossAppWallet:i.notImplemented,signTypedDataWithCrossAppWallet:i.notImplemented,sendTransactionWithCrossAppWallet:i.notImplemented,isModalOpen:!1,mfaMethods:[]}),u=()=>t.useContext(p);exports.PrivyContext=p,exports.convertUserResponseToUser=function(e){if(!e)return null;let t=function(e){let t=[];for(let i of e){let e=i.type;switch(i.type){case"wallet":let a={id:i.id,address:i.address,type:i.type,imported:i.imported,delegated:i.delegated,verifiedAt:r(i.verified_at),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 l={address:i.address,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at),smartWalletType:i.smart_wallet_type};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},verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(n);break;case"email":let s={address:i.address,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(s);break;case"phone":let d={number:i.phoneNumber,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(d);break;case"google_oauth":let m={subject:i.subject,email:i.email,name:i.name,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(m);break;case"spotify_oauth":let o={subject:i.subject,email:i.email,name:i.name,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(o);break;case"instagram_oauth":let p={subject:i.subject,username:i.username,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(p);break;case"twitter_oauth":let u={subject:i.subject,username:i.username,name:i.name,type:i.type,profilePictureUrl:i.profile_picture_url,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(u);break;case"discord_oauth":let f={subject:i.subject,username:i.username,email:i.email,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(f);break;case"github_oauth":let c={subject:i.subject,username:i.username,name:i.name,email:i.email,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(c);break;case"tiktok_oauth":let _={subject:i.subject,username:i.username,name:i.name,type:i.type,verifiedAt:r(i.verified_at),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,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(y);break;case"linkedin_oauth":let v={subject:i.subject,name:i.name,email:i.email,vanityName:i.vanity_name,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(v);break;case"apple_oauth":let h={subject:i.subject,email:i.email,type:i.type,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(h);break;case"custom_auth":t.push({type:i.type,customUserId:i.custom_user_id,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)});break;case"farcaster":let A={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,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at),signerPublicKey:i.signer_public_key};t.push(A);break;case"passkey":let b={type:i.type,enrolledInMfa:i.enrolled_in_mfa,credentialId:i.credential_id,authenticatorName:i.authenticator_name,createdWithDevice:i.created_with_device,createdWithOs:i.created_with_os,createdWithBrowser:i.created_with_browser,verifiedAt:r(i.verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(b);break;case"telegram":let I={type:i.type,telegramUserId:i.telegram_user_id,firstName:i.first_name,lastName:i.last_name,username:i.username,photoUrl:i.photo_url,verifiedAt:r(i.first_verified_at),firstVerifiedAt:r(i.first_verified_at),latestVerifiedAt:r(i.latest_verified_at)};t.push(I);break;default:console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),i=a(t,"wallet"),l=a(t,"smart_wallet"),n=a(t,"email"),s=a(t,"phone"),d=a(t,"google_oauth"),m=a(t,"twitter_oauth"),o=a(t,"discord_oauth"),p=a(t,"github_oauth"),u=a(t,"spotify_oauth"),f=a(t,"instagram_oauth"),c=a(t,"tiktok_oauth"),_=a(t,"line_oauth"),y=a(t,"linkedin_oauth"),v=a(t,"apple_oauth"),h=a(t,"farcaster"),A=a(t,"telegram"),b=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:n&&{address:n?.address},phone:s&&{number:s?.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:l&&{address:l.address,smartWalletType:l.smartWalletType},google:d&&{subject:d.subject,email:d.email,name:d.name},twitter:m&&{subject:m.subject,username:m.username,name:m.name,profilePictureUrl:m.profilePictureUrl},discord:o&&{subject:o.subject,username:o.username,email:o.email},github:p&&{subject:p.subject,username:p.username,name:p.name,email:p.email},spotify:u&&{subject:u.subject,email:u.email,name:u.name},instagram:f&&{subject:f.subject,username:f.username},tiktok:c&&{subject:c.subject,username:c.username,name:c.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:v&&{subject:v.subject,email:v.email},farcaster:h&&{fid:h.fid,ownerAddress:h.ownerAddress,displayName:h.displayName,username:h.username,bio:h.bio,pfp:h.pfp,url:h.url,signerPublicKey:h.signerPublicKey},telegram:A&&{telegramUserId:A.telegramUserId,firstName:A.firstName,lastName:A.lastName,username:A.username,photoUrl:A.photoUrl},delegatedWallets:[],mfaMethods:b.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}},exports.getAllPrivyWalletsForChainType=s,exports.getConnectedWalletWithAddress=(e,t)=>e.find((e=>o(e.address,t)))||null,exports.getImportedPrivyEthereumWallet=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType))||null,exports.getImportedPrivySolanaWallet=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType))||null,exports.getIsUnifiedWallet=e=>!!e.id&&"privy-v2"===e.recoveryMethod,exports.getPrivyEthereumHDWallets=n,exports.getPrivyEthereumWallet=l,exports.getPrivyPrimaryWallet=e=>l(e)??m(e),exports.getPrivySolanaHDWallets=d,exports.getPrivySolanaWallet=m,exports.getPrivyWalletWithAddress=(e,t)=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&o(e.address,t)))||null,exports.usePrivyContext=u,exports.useSignWithUserSigner=()=>{let{getAccessToken:e}=u(),{walletProxy:r}=i.usePrivyInternal();return t.useMemo((()=>({signWithUserSigner:async({message:t})=>{if(!r)throw Error("Wallet proxy not initialized");let i=await e();if(!i)throw Error("User must be authenticated");let{signature:a}=await r.signWithUserSigner({accessToken:i,message:t});return{signature:a}}})),[r,e])};
@@ -1 +0,0 @@
1
- import{useRef as e,useState as t,useCallback as r}from"react";import{http as n,createPublicClient as a}from"viem";import{u as i,g as s,c as o}from"./use-sign-with-user-signer-DnNPDfxp.mjs";import{x as l,o as c,e as d,w as u,a as p,b1 as m,b0 as y,a$ as g}from"./privy-provider-B0E_t4-_.mjs";import{P as h}from"./paths-DCwuPDUk.mjs";import{u as f}from"./internal-context-qdNgTV5f.mjs";import{g as w}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import{createSmartAccountClient as P}from"permissionless";import{toThirdwebSmartAccount as I,toLightSmartAccount as v,toBiconomySmartAccount as F,toKernelSmartAccount as W,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 M,COINBASE_SMART_WALLET as b,LIGHT_ACCOUNT as O,BICONOMY as S,KERNEL as A,SAFE as D}from"@privy-io/js-sdk-core";let V={address:T,version:"0.6"},N={address:U,version:"0.7"},_=({owner:e,smartWalletType:t,publicClient:r})=>{switch(t){case D:return x({client:r,entryPoint:N,owners:[e],version:"1.4.1"});case A:return W({client:r,version:"0.3.1",entryPoint:N,useMetaFactory:"optional",owners:[e]});case S:return F({client:r,owners:[e],entryPoint:V});case O:return v({client:r,entryPoint:V,owner:e,version:"1.1.0"});case b:return async function({client:e,owner:t}){let[r]=await t.request({method:"eth_accounts"});if(!r)throw Error("Unable to request embedded owner for eth_accounts");return await C({client:e,version:"1",owners:[{type:"local",source:"privy",address:r,sign:async({hash:e})=>await t.request({method:"secp256k1_sign",params:[e]})}]})}({client:r,owner:e});case M:return I({client:r,entryPoint:N,owner:e});default:throw Error(`Invalid smart account type: ${t}.`)}};const $=({calls:e,chain:t,maxPriorityFeePerGas:r,maxFeePerGas:n,nonce:a})=>e.map((e=>({to:e.to||void 0,data:e.data,value:e.value,chainId:t.id,nonce:a,maxFeePerGas:n,maxPriorityFeePerGas:r}))),B=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 h(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let p=s.smartWallet?.smartWalletType??o.smartWalletType,m=l(e,c,d),y=a({chain:e,transport:n(m)}),g=t??u.paymasterContext,f=await(async({owner:e,smartWalletType:t,chain:r,publicClient:a,bundlerUrl:i,paymasterUrl:s,paymasterContext:o})=>{let l=await _({owner:e,smartWalletType:t,publicClient:a}),c=G({transport:n(i),entryPoint:l.entryPoint}),d=s?G({transport:n(s),entryPoint:l.entryPoint}):void 0;return P({account:l,chain:r,paymaster:d,paymasterContext:o,bundlerTransport:n(i),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>i.includes(e))))return await c.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>i.includes(e))))return(await c.request({method:"zd_getUserOperationGasPrice",params:[]})).fast;if(["g.alchemy.com"].some((e=>i.includes(e)))){let[e,t]=await Promise.all([a.getBlock({blockTag:"latest"}),c.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 a.estimateFeesPerGas(),t=i.includes("api.developer.coinbase.com")?175n:150n;return{...e,maxFeePerGas:e.maxFeePerGas*t/100n,maxPriorityFeePerGas:e.maxPriorityFeePerGas*t/100n}}}}})})({owner:i,smartWalletType:p,chain:e,publicClient:y,paymasterContext:g,...u});if(!f)throw new h(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return f},q=({clientConfig:n,smartWalletsConfig:a})=>{let{hideWalletUIs:l,openPrivyModal:P,appId:I,isHeadlessSigning:v}=f(),F=c(),{setModalData:W}=d(),{user:x}=i(),{chains:G}=c(),{chainId:C,clients:T,setChainId:U,chainIdState:M}=(()=>{let r=e(),[n,a]=t();return{clients:e({}),setChainId:e=>{r.current=e,a(e)},chainId:r,chainIdState:n}})(),b=G.find((e=>e.id===M)),{wallets:O}=u(),S=s(x),A=w(O),D=!!S&&o(S),V=r((async()=>C.current),[C]),N=r((async({id:e})=>{if(!T.current[e]){let t=await B({chain:G.find((t=>t.id===e)),account:S,signer:await(A?.getEthereumProvider()),user:x,paymasterContext:n?.paymasterContext,smartWalletsConfig:a,rpcConfig:F.rpcConfig,privyAppId:I});t&&(T.current[e]=t)}U(e)}),[G,n,O,x,a]);return{wrapSmartAccountClient:e=>{T.current[e.chain.id]=e,M||U(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let r=T.current[C.current];if(!r)throw new h(`Smart wallet client for chain (eip155:${C.current}) not found`);if(delete e.account,v({showWalletUIs:t?.uiOptions?.showWalletUIs}))return l.current=!0,await r.sendTransaction(e).finally((()=>l.current=!1));let n=[];"calls"in e&&void 0!==e.calls?n=[...e.calls]:"to"in e&&(n=[{to:e.to,value:e.value||BigInt(0),data:e.data||"0x"}]);let a=async()=>{let{paymasterAndData:t,paymasterData:a,maxFeePerGas:i,maxPriorityFeePerGas:s}=await r.prepareUserOperation({calls:n,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return 0===Number(i)&&0===Number(s)||Number(t??a??0)>0};return new Promise((async(i,s)=>{l.current=!0;let{entropyId:o,entropyIdVerifier:c}=p(x);W({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:D,entropyId:o,entropyIdVerifier:c,onCompleteNavigateTo:m,onFailure:()=>{}},sendTransaction:{transactionRequests:$({calls:n,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:o,entropyIdVerifier:c,getIsSponsored:a,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 h(`Smart wallet client for chain (eip155:${C.current}) not found`);return v({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await r.signMessage(e).finally((()=>l.current=!1))):new Promise((async(n,a)=>{let{entropyId:i,entropyIdVerifier:s}=p(x);l.current=!0,W({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:D,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=>n(e),onFailure:a,uiOptions:t?.uiOptions??{}}}),P(y)})).finally((()=>{l.current=!1}))},signTypedData:async(e,t)=>{let r=T.current[C.current];if(!r)throw new h(`Smart wallet client for chain (eip155:${C.current}) not found`);return delete e.account,v({showWalletUIs:t?.uiOptions?.showWalletUIs})?(l.current=!0,await r.signTypedData(e).finally((()=>l.current=!1))):new Promise((async(n,a)=>{l.current=!0;let{entropyId:i,entropyIdVerifier:s}=p(x);W({connectWallet:{recoveryMethod:S.recoveryMethod,connectingWalletAddress:S.address,isUnifiedWallet:D,entropyId:i,entropyIdVerifier:s,onCompleteNavigateTo:g,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>n(e),onFailure:a,uiOptions:t?.uiOptions??{}}}),P(y)})).finally((()=>{l.current=!1}))},getChainId:V,chain:b,switchChain:N}}}},j=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:r}=f(),{setModalData:n}=d(),{user:a}=i(),l=s(a),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:h,entropyIdVerifier:f}=p(a);n({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:h,entropyIdVerifier:f,onCompleteNavigateTo:m,onFailure:()=>{}},sendTransaction:{transactionRequests:$({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:h,entropyIdVerifier:f,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:m}=p(a);e.current=!0,n({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:u,entropyIdVerifier:m,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:m}=p(a);n({connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:l.address,isUnifiedWallet:c,entropyId:u,entropyIdVerifier:m,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,$ as c,B as g,j as u};
@@ -1 +0,0 @@
1
- import{getAddress as e}from"viem";import{createContext as t,useContext as i,useMemo as a}from"react";import{a as r,u as s}from"./internal-context-qdNgTV5f.mjs";function l(e){return e?new Date(1e3*e):null}function n(e,t){return e.slice().sort(((e,t)=>(e.firstVerifiedAt??e.verifiedAt).getTime()-(t.firstVerifiedAt??t.verifiedAt).getTime())).find((e=>e.type===t))}const d=e=>e?u(e).find((e=>0===e.walletIndex))??null:null,u=e=>e?f(e,"ethereum"):[],f=(e,t)=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&e.chainType===t)),o=e=>e?f(e,"solana"):[],m=e=>e?o(e).find((e=>0===e.walletIndex))??null:null,p=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType))||null,c=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType))||null;let _=(t,i)=>t===i||!(!t.startsWith("0x")||!i.startsWith("0x"))&&e(t)===e(i);const y=(e,t)=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&_(e.address,t)))||null,h=(e,t)=>e.find((e=>_(e.address,t)))||null,v=e=>d(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,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(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 r={address:i.address,type:i.type,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at),smartWalletType:i.smart_wallet_type};t.push(r);break;case"cross_app":let s={type:i.type,subject:i.subject,embeddedWallets:i.embedded_wallets,smartWallets:i.smart_wallets,providerApp:{id:i.provider_app_id},verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(s);break;case"email":let n={address:i.address,type:i.type,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(n);break;case"phone":let d={number:i.phoneNumber,type:i.type,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(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,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(u);break;case"spotify_oauth":let f={subject:i.subject,email:i.email,name:i.name,type:i.type,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(f);break;case"instagram_oauth":let o={subject:i.subject,username:i.username,type:i.type,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(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,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(m);break;case"discord_oauth":let p={subject:i.subject,username:i.username,email:i.email,type:i.type,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(p);break;case"github_oauth":let c={subject:i.subject,username:i.username,name:i.name,email:i.email,type:i.type,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(c);break;case"tiktok_oauth":let _={subject:i.subject,username:i.username,name:i.name,type:i.type,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(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,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(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,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(h);break;case"apple_oauth":let v={subject:i.subject,email:i.email,type:i.type,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(v);break;case"custom_auth":t.push({type:i.type,customUserId:i.custom_user_id,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)});break;case"farcaster":let b={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,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at),signerPublicKey:i.signer_public_key};t.push(b);break;case"passkey":let A={type:i.type,enrolledInMfa:i.enrolled_in_mfa,credentialId:i.credential_id,authenticatorName:i.authenticator_name,createdWithDevice:i.created_with_device,createdWithOs:i.created_with_os,createdWithBrowser:i.created_with_browser,verifiedAt:l(i.verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(A);break;case"telegram":let k={type:i.type,telegramUserId:i.telegram_user_id,firstName:i.first_name,lastName:i.last_name,username:i.username,photoUrl:i.photo_url,verifiedAt:l(i.first_verified_at),firstVerifiedAt:l(i.first_verified_at),latestVerifiedAt:l(i.latest_verified_at)};t.push(k);break;default:console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),i=n(t,"wallet"),a=n(t,"smart_wallet"),r=n(t,"email"),s=n(t,"phone"),d=n(t,"google_oauth"),u=n(t,"twitter_oauth"),f=n(t,"discord_oauth"),o=n(t,"github_oauth"),m=n(t,"spotify_oauth"),p=n(t,"instagram_oauth"),c=n(t,"tiktok_oauth"),_=n(t,"line_oauth"),y=n(t,"linkedin_oauth"),h=n(t,"apple_oauth"),v=n(t,"farcaster"),b=n(t,"telegram"),A=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:l(t)})));return{id:e.id,createdAt:l(e.created_at),linkedAccounts:t,email:r&&{address:r?.address},phone:s&&{number:s?.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},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:f&&{subject:f.subject,username:f.username,email:f.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:p&&{subject:p.subject,username:p.username},tiktok:c&&{subject:c.subject,username:c.username,name:c.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:v&&{fid:v.fid,ownerAddress:v.ownerAddress,displayName:v.displayName,username:v.username,bio:v.bio,pfp:v.pfp,url:v.url,signerPublicKey:v.signerPublicKey},telegram:b&&{telegramUserId:b.telegramUserId,firstName:b.firstName,lastName:b.lastName,username:b.username,photoUrl:b.photoUrl},delegatedWallets:[],mfaMethods:A.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}}const A=e=>!!e.id&&"privy-v2"===e.recoveryMethod,k=/*#__PURE__*/t({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:r,login:r,connectOrCreateWallet:r,linkEmail:r,linkPhone:r,linkFarcaster:r,linkWallet:r,startCrossAppAuthFlow:r,linkGoogle:r,linkTwitter:r,linkDiscord:r,linkGithub:r,linkSpotify:r,linkInstagram:r,linkTelegram:r,linkTiktok:r,linkLine:r,linkLinkedIn:r,linkApple:r,linkPasskey:r,updateEmail:r,updatePhone:r,logout:r,getAccessToken:r,unlinkEmail:r,unlinkPhone:r,unlinkWallet:r,unlinkGoogle:r,unlinkTwitter:r,unlinkDiscord:r,unlinkGithub:r,unlinkSpotify:r,unlinkInstagram:r,unlinkTiktok:r,unlinkLine:r,unlinkLinkedIn:r,unlinkApple:r,unlinkCrossAppAccount:r,unlinkFarcaster:r,unlinkTelegram:r,unlinkPasskey:r,signMessage:r,signTypedData:r,enrollInMfa:r,initEnrollmentWithSms:r,initEnrollmentWithTotp:r,initEnrollmentWithPasskey:r,promptMfa:r,init:r,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:r,submitEnrollmentWithPasskey:r,unenroll:r,submit:r,cancel:r,sendTransaction:r,signTransaction:r,exportWallet:r,setWalletPassword:r,setWalletRecovery:r,requestFarcasterSignerFromWarpcast:r,getFarcasterSignerPublicKey:r,signFarcasterMessage:r,signMessageWithCrossAppWallet:r,signTypedDataWithCrossAppWallet:r,sendTransactionWithCrossAppWallet:r,isModalOpen:!1,mfaMethods:[]}),g=()=>i(k),w=()=>{let{getAccessToken:e}=g(),{walletProxy:t}=s();return a((()=>({signWithUserSigner:async({message:i})=>{if(!t)throw Error("Wallet proxy not initialized");let a=await e();if(!a)throw Error("User must be authenticated");let{signature:r}=await t.signWithUserSigner({accessToken:a,message:i});return{signature:r}}})),[t,e])};export{k as P,w as a,y as b,A as c,o as d,c as e,f,d as g,v as h,b as i,m as j,p as k,u as l,h as m,g as u};