@privy-io/react-auth 2.13.8 → 2.14.1-beta-20250606202852

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.
@@ -1 +1 @@
1
- import{useCallback as e}from"react";import{aE as a,aD as t,b as n,f as s,au as r,aA as o,aF as c,aG as i}from"./privy-provider-CngOPdtE.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-pX7RZwl3.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 A=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,A as u};
1
+ import{useCallback as e}from"react";import{aE as a,aD as t,b as n,f as s,au as r,aA as o,aF as c,aG as i}from"./privy-provider-D3Q6gwBn.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-pX7RZwl3.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 A=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,A as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/react-auth",
3
- "version": "2.13.8",
3
+ "version": "2.14.1-beta-20250606202852",
4
4
  "description": "React client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",
@@ -130,16 +130,16 @@
130
130
  "not op_mini all"
131
131
  ],
132
132
  "dependencies": {
133
- "@coinbase/wallet-sdk": "^4.3.2",
133
+ "@coinbase/wallet-sdk": "4.3.2",
134
134
  "@floating-ui/react": "^0.26.22",
135
135
  "@headlessui/react": "^2.2.0",
136
136
  "@heroicons/react": "^2.1.1",
137
137
  "@marsidev/react-turnstile": "^0.4.1",
138
138
  "@metamask/eth-sig-util": "^6.0.0",
139
139
  "@privy-io/chains": "0.0.1",
140
- "@privy-io/js-sdk-core": "0.50.8",
141
140
  "@privy-io/ethereum": "0.0.1",
142
- "@reown/appkit": "^1.7.4",
141
+ "@privy-io/js-sdk-core": "0.50.10-beta-20250606202852",
142
+ "@reown/appkit": "^1.7.8",
143
143
  "@scure/base": "^1.2.5",
144
144
  "@simplewebauthn/browser": "^9.0.1",
145
145
  "@solana/wallet-adapter-base": "0.9.23",
@@ -166,7 +166,7 @@
166
166
  "stylis": "^4.3.4",
167
167
  "tinycolor2": "^1.6.0",
168
168
  "uuid": ">=8 <10",
169
- "viem": "^2.24.1",
169
+ "viem": "^2.30.6",
170
170
  "zustand": "^5.0.0"
171
171
  },
172
172
  "devDependencies": {
@@ -178,7 +178,7 @@
178
178
  "@jest/globals": "^29.7.0",
179
179
  "@privy-io/build-config": "*",
180
180
  "@privy-io/eslint-config-custom": "*",
181
- "@privy-io/public-api": "2.32.0",
181
+ "@privy-io/public-api": "2.33.0",
182
182
  "@privy-io/testing": "*",
183
183
  "@rollup/plugin-commonjs": "^26.0.1",
184
184
  "@rollup/plugin-node-resolve": "^15.3.0",
@@ -224,7 +224,7 @@
224
224
  "@abstract-foundation/agw-client": "^1.0.0",
225
225
  "@solana/spl-token": "^0.4.9",
226
226
  "@solana/web3.js": "^1.95.8",
227
- "permissionless": "^0.2.10",
227
+ "permissionless": "^0.2.47",
228
228
  "react": "^18 || ^19",
229
229
  "react-dom": "^18 || ^19"
230
230
  },
@@ -1 +0,0 @@
1
- "use strict";var e=require("react"),t=require("viem"),r=require("./privy-provider-CmQLEp8p.js"),n=require("./internal-context-VGU3duZo.js"),a=require("./getEmbeddedConnectedWallet-DTU4T9TJ.js"),i=require("permissionless"),s=require("permissionless/accounts"),o=require("permissionless/clients/pimlico"),l=require("viem/account-abstraction"),c=require("@privy-io/js-sdk-core");let d={address:l.entryPoint06Address,version:"0.6"},u={address:l.entryPoint07Address,version:"0.7"},p=({owner:e,smartWalletType:t,publicClient:r})=>{switch(t){case c.SAFE:return s.toSafeSmartAccount({client:r,entryPoint:u,owners:[e],version:"1.4.1"});case c.KERNEL:return s.toEcdsaKernelSmartAccount({client:r,version:"0.3.1",entryPoint:u,owners:[e]});case c.BICONOMY:return s.toBiconomySmartAccount({client:r,owners:[e],entryPoint:d});case c.LIGHT_ACCOUNT:return s.toLightSmartAccount({client:r,entryPoint:d,owner:e,version:"1.1.0"});case c.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 l.toCoinbaseSmartAccount({client:e,owners:[{type:"local",source:"privy",address:r,sign:async({hash:e})=>await t.request({method:"secp256k1_sign",params:[e]})}]})}({client:r,owner:e});case c.THIRDWEB:return s.toThirdwebSmartAccount({client:r,entryPoint:u,owner:e});default:throw Error(`Invalid smart account type: ${t}.`)}};const y=({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}))),m=async({chain:e,paymasterContext:a,account:s,signer:l,user:c,smartWalletsConfig:d,rpcConfig:u,privyAppId:y})=>{if(!(d?.enabled&&c&&s&&l))return;let m=d?.configuredNetworks.find((t=>t.chainId===`eip155:${e.id}`));if(!m)throw new n.PrivyClientError(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let g=c.smartWallet?.smartWalletType??d.smartWalletType,h=r.getJsonRpcEndpointFromChain(e,u,y),P=t.createPublicClient({chain:e,transport:t.http(h)}),f=a??m.paymasterContext,w=await(async({owner:e,smartWalletType:r,chain:n,publicClient:a,bundlerUrl:s,paymasterUrl:l,paymasterContext:c})=>{let d=await p({owner:e,smartWalletType:r,publicClient:a}),u=o.createPimlicoClient({transport:t.http(s),entryPoint:d.entryPoint}),y=l?o.createPimlicoClient({transport:t.http(l),entryPoint:d.entryPoint}):void 0;return i.createSmartAccountClient({account:d,chain:n,paymaster:y,paymasterContext:c,bundlerTransport:t.http(s),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some((e=>s.includes(e))))return await u.getUserOperationGasPrice().then((e=>e.fast));if(["rpc.zerodev.app"].some((e=>s.includes(e))))return(await u.request({method:"zd_getUserOperationGasPrice",params:[]})).fast;if(["g.alchemy.com"].some((e=>s.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=s.includes("api.developer.coinbase.com")?175n:150n;return{...e,maxFeePerGas:e.maxFeePerGas*t/100n,maxPriorityFeePerGas:e.maxPriorityFeePerGas*t/100n}}}}})})({owner:l,smartWalletType:g,chain:e,publicClient:P,paymasterContext:f,...m});if(!w)throw new n.PrivyClientError(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return w};exports.callsToTransactionRequests=y,exports.getSmartWalletClient=m,exports.useSmartWalletsUIWrapper=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:a}=n.usePrivyInternal(),{setModalData:i}=r.usePrivyModal(),{user:s}=r.usePrivyContext(),o=r.getPrivyEthereumWallet(s),l=!!o&&r.getIsUnifiedWallet(o);return{wrapSmartAccountClientWithUIs:n=>({...n,sendTransaction:async(c,d)=>{if(a({showWalletUIs:d?.uiOptions?.showWalletUIs}))return e.current=!0,await n.sendTransaction(c).finally((()=>e.current=!1));let u=[];"calls"in c&&void 0!==c.calls?u=[...c.calls]:"to"in c&&(u=[{to:c.to,value:c.value||BigInt(0),data:c.data||"0x"}]);let p=async()=>{if(!n.paymaster)return!1;let{paymasterAndData:e,paymasterData:t}=await n.prepareUserOperation({calls:u,maxFeePerGas:c.maxFeePerGas,maxPriorityFeePerGas:c.maxPriorityFeePerGas,nonce:c.nonce?BigInt(c.nonce):void 0});return Number(e??t??0)>0};return new Promise((async(a,m)=>{e.current=!0;let{entropyId:g,entropyIdVerifier:h}=r.getEntropyDetailsForUser(s);i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,isUnifiedWallet:l,entropyId:g,entropyIdVerifier:h,onCompleteNavigateTo:r.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:y({calls:u,chain:n.chain,maxPriorityFeePerGas:c.maxPriorityFeePerGas,maxFeePerGas:c.maxFeePerGas,nonce:c.nonce?BigInt(c.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:n.account.address,entropyId:g,entropyIdVerifier:h,getIsSponsored:p,signOnly:!1,onConfirm:()=>n.sendTransaction(c),onSuccess:e=>a(e.hash),onFailure:m,uiOptions:d?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))},signMessage:async(c,d)=>a({showWalletUIs:d?.uiOptions?.showWalletUIs})?(e.current=!0,await n.signMessage(c).finally((()=>e.current=!1))):new Promise((async(a,u)=>{let{entropyId:p,entropyIdVerifier:y}=r.getEntropyDetailsForUser(s);e.current=!0,i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,isUnifiedWallet:l,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:r.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof c.message?c.message:c.message.raw.toString(),confirmAndSign:()=>n.signMessage(c),onSuccess:e=>a(e),onFailure:u,uiOptions:d?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1})),signTypedData:async(c,d)=>a({showWalletUIs:d?.uiOptions?.showWalletUIs})?(e.current=!0,await n.signTypedData(c).finally((()=>e.current=!1))):new Promise((async(a,u)=>{e.current=!0;let{entropyId:p,entropyIdVerifier:y}=r.getEntropyDetailsForUser(s);i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,isUnifiedWallet:l,entropyId:p,entropyIdVerifier:y,onCompleteNavigateTo:r.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:c,confirmAndSign:()=>n.signTypedData(c),onSuccess:e=>a(e),onFailure:u,uiOptions:d?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))})}},exports.useSmartWalletsWrapper=({clientConfig:t,smartWalletsConfig:i})=>{let{hideWalletUIs:s,openPrivyModal:o,appId:l,isHeadlessSigning:c}=n.usePrivyInternal(),d=r.useAppConfig(),{setModalData:u}=r.usePrivyModal(),{user:p}=r.usePrivyContext(),{chains:g}=r.useAppConfig(),{chainId:h,clients:P,setChainId:f,chainIdState:w}=(()=>{let t=e.useRef(),[r,n]=e.useState();return{clients:e.useRef({}),setChainId:e=>{t.current=e,n(e)},chainId:t,chainIdState:r}})(),I=g.find((e=>e.id===w)),{wallets:v}=r.useWallets(),W=r.getPrivyEthereumWallet(p),C=a.getEmbeddedConnectedWallet(v),S=!!W&&r.getIsUnifiedWallet(W),F=e.useCallback((async()=>h.current),[h]),x=e.useCallback((async({id:e})=>{if(!P.current[e]){let r=await m({chain:g.find((t=>t.id===e)),account:W,signer:await(C?.getEthereumProvider()),user:p,paymasterContext:t?.paymasterContext,smartWalletsConfig:i,rpcConfig:d.rpcConfig,privyAppId:l});r&&(P.current[e]=r)}f(e)}),[g,t,v,p,i]);return{wrapSmartAccountClient:e=>{P.current[e.chain.id]=e,w||f(e.chain.id);return{...e,sendTransaction:async(e,t)=>{let a=P.current[h.current];if(!a)throw new n.PrivyClientError(`Smart wallet client for chain (eip155:${h.current}) not found`);if(delete e.account,c({showWalletUIs:t?.uiOptions?.showWalletUIs}))return s.current=!0,await a.sendTransaction(e).finally((()=>s.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 l=async()=>{let{paymasterAndData:t,paymasterData:r,maxFeePerGas:n,maxPriorityFeePerGas:s}=await a.prepareUserOperation({calls:i,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return 0===Number(n)&&0===Number(s)||Number(t??r??0)>0};return new Promise((async(n,c)=>{s.current=!0;let{entropyId:d,entropyIdVerifier:m}=r.getEntropyDetailsForUser(p);u({connectWallet:{recoveryMethod:W.recoveryMethod,connectingWalletAddress:W.address,isUnifiedWallet:S,entropyId:d,entropyIdVerifier:m,onCompleteNavigateTo:r.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:y({calls:i,chain:a.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:a.account.address,entropyId:d,entropyIdVerifier:m,getIsSponsored:l,signOnly:!1,onConfirm:()=>a.sendTransaction(e),onSuccess:e=>n(e.hash),onFailure:c,uiOptions:t?.uiOptions??{}}}),o(r.EmbeddedWalletConnectingScreen)})).finally((()=>{s.current=!1}))},signMessage:async(e,t)=>{let a=P.current[h.current];if(!a)throw new n.PrivyClientError(`Smart wallet client for chain (eip155:${h.current}) not found`);return c({showWalletUIs:t?.uiOptions?.showWalletUIs})?(s.current=!0,await a.signMessage(e).finally((()=>s.current=!1))):new Promise((async(n,i)=>{let{entropyId:l,entropyIdVerifier:c}=r.getEntropyDetailsForUser(p);s.current=!0,u({connectWallet:{recoveryMethod:W.recoveryMethod,connectingWalletAddress:W.address,isUnifiedWallet:S,entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:r.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof e.message?e.message:e.message.raw.toString(),confirmAndSign:()=>a.signMessage(e),onSuccess:e=>n(e),onFailure:i,uiOptions:t?.uiOptions??{}}}),o(r.EmbeddedWalletConnectingScreen)})).finally((()=>{s.current=!1}))},signTypedData:async(e,t)=>{let a=P.current[h.current];if(!a)throw new n.PrivyClientError(`Smart wallet client for chain (eip155:${h.current}) not found`);return delete e.account,c({showWalletUIs:t?.uiOptions?.showWalletUIs})?(s.current=!0,await a.signTypedData(e).finally((()=>s.current=!1))):new Promise((async(n,i)=>{s.current=!0;let{entropyId:l,entropyIdVerifier:c}=r.getEntropyDetailsForUser(p);u({connectWallet:{recoveryMethod:W.recoveryMethod,connectingWalletAddress:W.address,isUnifiedWallet:S,entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:r.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>a.signTypedData(e),onSuccess:e=>n(e),onFailure:i,uiOptions:t?.uiOptions??{}}}),o(r.EmbeddedWalletConnectingScreen)})).finally((()=>{s.current=!1}))},getChainId:F,chain:I,switchChain:x}}}};
@@ -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{n as i,f as s,au as o,u as l,l as c,m as d,v as u,a as p,aJ as m,aI as y,aH as g}from"./privy-provider-CngOPdtE.mjs";import{P as f,u as h}from"./internal-context-pX7RZwl3.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,toEcdsaKernelSmartAccount 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 O,LIGHT_ACCOUNT as S,BICONOMY as b,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,owners:[e]});case b:return F({client:r,owners:[e],entryPoint:V});case S:return v({client:r,entryPoint:V,owner:e,version:"1.1.0"});case O: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,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 B=({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}))),$=async({chain:e,paymasterContext:t,account:r,signer:s,user:o,smartWalletsConfig:l,rpcConfig:c,privyAppId:d})=>{if(!(l?.enabled&&o&&r&&s))return;let u=l?.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 p=o.smartWallet?.smartWalletType??l.smartWalletType,m=i(e,c,d),y=a({chain:e,transport:n(m)}),g=t??u.paymasterContext,h=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:s,smartWalletType:p,chain:e,publicClient:y,paymasterContext:g,...u});if(!h)throw new f(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return h},q=({clientConfig:n,smartWalletsConfig:a})=>{let{hideWalletUIs:i,openPrivyModal:P,appId:I,isHeadlessSigning:v}=h(),F=s(),{setModalData:W}=o(),{user:x}=l(),{chains:G}=s(),{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}})(),O=G.find((e=>e.id===M)),{wallets:S}=c(),b=d(x),A=w(S),D=!!b&&u(b),V=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:b,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,S,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 f(`Smart wallet client for chain (eip155:${C.current}) not found`);if(delete e.account,v({showWalletUIs:t?.uiOptions?.showWalletUIs}))return i.current=!0,await r.sendTransaction(e).finally((()=>i.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(s,o)=>{i.current=!0;let{entropyId:l,entropyIdVerifier:c}=p(x);W({connectWallet:{recoveryMethod:b.recoveryMethod,connectingWalletAddress:b.address,isUnifiedWallet:D,entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:m,onFailure:()=>{}},sendTransaction:{transactionRequests:B({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:l,entropyIdVerifier:c,getIsSponsored:a,signOnly:!1,onConfirm:()=>r.sendTransaction(e),onSuccess:e=>s(e.hash),onFailure:o,uiOptions:t?.uiOptions??{}}}),P(y)})).finally((()=>{i.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 v({showWalletUIs:t?.uiOptions?.showWalletUIs})?(i.current=!0,await r.signMessage(e).finally((()=>i.current=!1))):new Promise((async(n,a)=>{let{entropyId:s,entropyIdVerifier:o}=p(x);i.current=!0,W({connectWallet:{recoveryMethod:b.recoveryMethod,connectingWalletAddress:b.address,isUnifiedWallet:D,entropyId:s,entropyIdVerifier:o,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((()=>{i.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,v({showWalletUIs:t?.uiOptions?.showWalletUIs})?(i.current=!0,await r.signTypedData(e).finally((()=>i.current=!1))):new Promise((async(n,a)=>{i.current=!0;let{entropyId:s,entropyIdVerifier:o}=p(x);W({connectWallet:{recoveryMethod:b.recoveryMethod,connectingWalletAddress:b.address,isUnifiedWallet:D,entropyId:s,entropyIdVerifier:o,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((()=>{i.current=!1}))},getChainId:V,chain:O,switchChain:N}}}},k=()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:r}=h(),{setModalData:n}=o(),{user:a}=l(),i=d(a),s=!!i&&u(i);return{wrapSmartAccountClientWithUIs:o=>({...o,sendTransaction:async(l,c)=>{if(r({showWalletUIs:c?.uiOptions?.showWalletUIs}))return e.current=!0,await o.sendTransaction(l).finally((()=>e.current=!1));let d=[];"calls"in l&&void 0!==l.calls?d=[...l.calls]:"to"in l&&(d=[{to:l.to,value:l.value||BigInt(0),data:l.data||"0x"}]);let u=async()=>{if(!o.paymaster)return!1;let{paymasterAndData:e,paymasterData:t}=await o.prepareUserOperation({calls:d,maxFeePerGas:l.maxFeePerGas,maxPriorityFeePerGas:l.maxPriorityFeePerGas,nonce:l.nonce?BigInt(l.nonce):void 0});return Number(e??t??0)>0};return new Promise((async(r,g)=>{e.current=!0;let{entropyId:f,entropyIdVerifier:h}=p(a);n({connectWallet:{recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,isUnifiedWallet:s,entropyId:f,entropyIdVerifier:h,onCompleteNavigateTo:m,onFailure:()=>{}},sendTransaction:{transactionRequests:B({calls:d,chain:o.chain,maxPriorityFeePerGas:l.maxPriorityFeePerGas,maxFeePerGas:l.maxFeePerGas,nonce:l.nonce?BigInt(l.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:o.account.address,entropyId:f,entropyIdVerifier:h,getIsSponsored:u,signOnly:!1,onConfirm:()=>o.sendTransaction(l),onSuccess:e=>r(e.hash),onFailure:g,uiOptions:c?.uiOptions??{}}}),t(y)})).finally((()=>{e.current=!1}))},signMessage:async(l,c)=>r({showWalletUIs:c?.uiOptions?.showWalletUIs})?(e.current=!0,await o.signMessage(l).finally((()=>e.current=!1))):new Promise((async(r,d)=>{let{entropyId:u,entropyIdVerifier:m}=p(a);e.current=!0,n({connectWallet:{recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,isUnifiedWallet:s,entropyId:u,entropyIdVerifier:m,onCompleteNavigateTo:g,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof l.message?l.message:l.message.raw.toString(),confirmAndSign:()=>o.signMessage(l),onSuccess:e=>r(e),onFailure:d,uiOptions:c?.uiOptions??{}}}),t(y)})).finally((()=>{e.current=!1})),signTypedData:async(l,c)=>r({showWalletUIs:c?.uiOptions?.showWalletUIs})?(e.current=!0,await o.signTypedData(l).finally((()=>e.current=!1))):new Promise((async(r,d)=>{e.current=!0;let{entropyId:u,entropyIdVerifier:m}=p(a);n({connectWallet:{recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,isUnifiedWallet:s,entropyId:u,entropyIdVerifier:m,onCompleteNavigateTo:g,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:l,confirmAndSign:()=>o.signTypedData(l),onSuccess:e=>r(e),onFailure:d,uiOptions:c?.uiOptions??{}}}),t(y)})).finally((()=>{e.current=!1}))})}};export{q as a,B as c,$ as g,k as u};