@privy-io/react-auth 2.11.0 → 2.11.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/abstract-smart-wallets.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{privy-provider-DwACoZxD.js → privy-provider-Cddj6OMJ.js} +2 -2
- package/dist/cjs/{smart-wallets-C6WSci1J.js → smart-wallets-CyVw0HIK.js} +1 -1
- package/dist/cjs/smart-wallets.js +1 -1
- package/dist/cjs/solana.js +1 -1
- package/dist/cjs/ui.js +1 -1
- package/dist/cjs/{useActiveWallet-OTRzJC3E.js → useActiveWallet-BJPtwRwN.js} +1 -1
- package/dist/cjs/{useFundWallet-DwAuhWQY.js → useFundWallet-CHZEiRO4.js} +1 -1
- package/dist/esm/abstract-smart-wallets.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{privy-provider-ByLlzrb6.mjs → privy-provider-B9IzlOpv.mjs} +2 -2
- package/dist/esm/{smart-wallets-CaacWb0W.mjs → smart-wallets-D0LqwcPM.mjs} +1 -1
- package/dist/esm/smart-wallets.mjs +1 -1
- package/dist/esm/solana.mjs +1 -1
- package/dist/esm/ui.mjs +1 -1
- package/dist/esm/{useActiveWallet-AqaQS33S.mjs → useActiveWallet-Cvm0O_EX.mjs} +1 -1
- package/dist/esm/{useFundWallet-DWvzm1Lq.mjs → useFundWallet-CCbN4yzN.mjs} +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),t=require("viem"),r=require("./privy-provider-DwACoZxD.js"),n=require("./internal-context-MaZRiWRJ.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,embeddedWallet:s,user:l,smartWalletsConfig:c,rpcConfig:d,privyAppId:u})=>{if(!c?.enabled||!l||!s)return;let y=await s.getEthereumProvider(),m=c?.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=l.smartWallet?.smartWalletType??c.smartWalletType,h=r.getJsonRpcEndpointFromChain(e,d,u),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:y,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);return{wrapSmartAccountClientWithUIs:n=>({...n,sendTransaction:async(l,c)=>{if(a({showWalletUIs:c?.uiOptions?.showWalletUIs}))return e.current=!0,await n.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(!n.paymaster)return!1;let{paymasterAndData:e,paymasterData:t}=await n.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(a,p)=>{e.current=!0;let{entropyId:m,entropyIdVerifier:g}=r.getEntropyDetailsForUser(s);i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:m,entropyIdVerifier:g,onCompleteNavigateTo:r.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:y({calls:d,chain:n.chain,maxPriorityFeePerGas:l.maxPriorityFeePerGas,maxFeePerGas:l.maxFeePerGas,nonce:l.nonce?BigInt(l.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:n.account.address,entropyId:m,entropyIdVerifier:g,getIsSponsored:u,signOnly:!1,onConfirm:()=>n.sendTransaction(l),onSuccess:e=>a(e.hash),onFailure:p,uiOptions:c?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))},signMessage:async(l,c)=>a({showWalletUIs:c?.uiOptions?.showWalletUIs})?(e.current=!0,await n.signMessage(l).finally((()=>e.current=!1))):new Promise((async(a,d)=>{let{entropyId:u,entropyIdVerifier:p}=r.getEntropyDetailsForUser(s);e.current=!0,i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:u,entropyIdVerifier:p,onCompleteNavigateTo:r.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof l.message?l.message:l.message.raw.toString(),confirmAndSign:()=>n.signMessage(l),onSuccess:e=>a(e),onFailure:d,uiOptions:c?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1})),signTypedData:async(l,c)=>a({showWalletUIs:c?.uiOptions?.showWalletUIs})?(e.current=!0,await n.signTypedData(l).finally((()=>e.current=!1))):new Promise((async(a,d)=>{e.current=!0;let{entropyId:u,entropyIdVerifier:p}=r.getEntropyDetailsForUser(s);i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:u,entropyIdVerifier:p,onCompleteNavigateTo:r.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:l,confirmAndSign:()=>n.signTypedData(l),onSuccess:e=>a(e),onFailure:d,uiOptions:c?.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(),C=a.getEmbeddedConnectedWallet(v),W=r.getPrivyEthereumWallet(p),S=e.useCallback((async()=>h.current),[h]),F=e.useCallback((async({id:e})=>{if(!P.current[e]){let r=await m({chain:g.find((t=>t.id===e)),embeddedWallet:C,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,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,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,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:S,chain:I,switchChain:F}}}};
|
|
1
|
+
"use strict";var e=require("react"),t=require("viem"),r=require("./privy-provider-Cddj6OMJ.js"),n=require("./internal-context-MaZRiWRJ.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,embeddedWallet:s,user:l,smartWalletsConfig:c,rpcConfig:d,privyAppId:u})=>{if(!c?.enabled||!l||!s)return;let y=await s.getEthereumProvider(),m=c?.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=l.smartWallet?.smartWalletType??c.smartWalletType,h=r.getJsonRpcEndpointFromChain(e,d,u),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:y,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);return{wrapSmartAccountClientWithUIs:n=>({...n,sendTransaction:async(l,c)=>{if(a({showWalletUIs:c?.uiOptions?.showWalletUIs}))return e.current=!0,await n.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(!n.paymaster)return!1;let{paymasterAndData:e,paymasterData:t}=await n.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(a,p)=>{e.current=!0;let{entropyId:m,entropyIdVerifier:g}=r.getEntropyDetailsForUser(s);i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:m,entropyIdVerifier:g,onCompleteNavigateTo:r.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:y({calls:d,chain:n.chain,maxPriorityFeePerGas:l.maxPriorityFeePerGas,maxFeePerGas:l.maxFeePerGas,nonce:l.nonce?BigInt(l.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:n.account.address,entropyId:m,entropyIdVerifier:g,getIsSponsored:u,signOnly:!1,onConfirm:()=>n.sendTransaction(l),onSuccess:e=>a(e.hash),onFailure:p,uiOptions:c?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1}))},signMessage:async(l,c)=>a({showWalletUIs:c?.uiOptions?.showWalletUIs})?(e.current=!0,await n.signMessage(l).finally((()=>e.current=!1))):new Promise((async(a,d)=>{let{entropyId:u,entropyIdVerifier:p}=r.getEntropyDetailsForUser(s);e.current=!0,i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:u,entropyIdVerifier:p,onCompleteNavigateTo:r.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof l.message?l.message:l.message.raw.toString(),confirmAndSign:()=>n.signMessage(l),onSuccess:e=>a(e),onFailure:d,uiOptions:c?.uiOptions??{}}}),t(r.EmbeddedWalletConnectingScreen)})).finally((()=>{e.current=!1})),signTypedData:async(l,c)=>a({showWalletUIs:c?.uiOptions?.showWalletUIs})?(e.current=!0,await n.signTypedData(l).finally((()=>e.current=!1))):new Promise((async(a,d)=>{e.current=!0;let{entropyId:u,entropyIdVerifier:p}=r.getEntropyDetailsForUser(s);i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:u,entropyIdVerifier:p,onCompleteNavigateTo:r.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:l,confirmAndSign:()=>n.signTypedData(l),onSuccess:e=>a(e),onFailure:d,uiOptions:c?.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(),C=a.getEmbeddedConnectedWallet(v),W=r.getPrivyEthereumWallet(p),S=e.useCallback((async()=>h.current),[h]),F=e.useCallback((async({id:e})=>{if(!P.current[e]){let r=await m({chain:g.find((t=>t.id===e)),embeddedWallet:C,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,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,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,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:S,chain:I,switchChain:F}}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("./privy-provider-
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("./privy-provider-Cddj6OMJ.js"),o=require("./internal-context-MaZRiWRJ.js"),t=require("./getEmbeddedConnectedWallet-DTU4T9TJ.js"),n=require("./smart-wallets-CyVw0HIK.js");require("mipd"),require("react-device-detect"),require("viem/utils"),require("@privy-io/js-sdk-core"),require("viem"),require("uuid"),require("jose"),require("eventemitter3"),require("@coinbase/wallet-sdk"),require("@marsidev/react-turnstile"),require("styled-components"),require("tinycolor2"),require("@heroicons/react/24/outline/DevicePhoneMobileIcon"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/24/outline/ChevronDownIcon"),require("@heroicons/react/24/outline/CalendarIcon"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@headlessui/react"),require("@walletconnect/ethereum-provider"),require("zustand"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/UserCircleIcon"),require("@heroicons/react/24/outline/EnvelopeIcon"),require("@heroicons/react/20/solid/CheckIcon"),require("@heroicons/react/24/outline/WalletIcon"),require("@heroicons/react/24/outline/CheckIcon"),require("@heroicons/react/24/outline/Square2StackIcon"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("@heroicons/react/24/outline/ArrowTopRightOnSquareIcon"),require("@heroicons/react/24/solid/DocumentCheckIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("qrcode"),require("@heroicons/react/24/outline/ChevronRightIcon"),require("@heroicons/react/24/outline/LockClosedIcon"),require("@heroicons/react/24/outline/PencilSquareIcon"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/LockClosedIcon"),require("@heroicons/react/24/outline/CheckCircleIcon"),require("@heroicons/react/24/outline/InformationCircleIcon"),require("@heroicons/react/24/outline/CreditCardIcon"),require("@heroicons/react/24/outline/QrCodeIcon"),require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),require("@heroicons/react/24/outline/GlobeAltIcon"),require("ofetch"),require("@heroicons/react/24/outline"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("@heroicons/react/24/outline/CloudArrowUpIcon"),require("@heroicons/react/24/outline/NoSymbolIcon"),require("@heroicons/react/24/outline/ClockIcon"),require("@heroicons/react/24/outline/TrashIcon"),require("@heroicons/react/24/solid/CheckBadgeIcon"),require("@heroicons/react/24/solid/IdentificationIcon"),require("@heroicons/react/24/outline/MinusCircleIcon"),require("@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon"),require("@heroicons/react/24/solid/ShieldCheckIcon"),require("js-cookie"),require("permissionless"),require("permissionless/accounts"),require("permissionless/clients/pimlico"),require("viem/account-abstraction");let c=/*#__PURE__*/r.createContext({client:void 0,getClientForChain:o.notImplemented});let a=/*#__PURE__*/r.createContext({config:void 0}),l=()=>{let{config:e}=r.useContext(a);return{config:e}},s=({children:i})=>{let[t,n]=r.useState(void 0),{client:c}=o.usePrivyInternal();return r.useEffect((()=>{!t&&c&&(async()=>{try{if(!c)return void console.warn("No client found");let e=await c.getSmartWalletsConfig();n(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()}),[!!c]),/*#__PURE__*/e.jsx(a.Provider,{value:{config:t},children:i})},u=({config:c,children:a})=>{let{config:s}=l(),{appId:u}=o.usePrivyInternal(),{chains:h,defaultChain:q,rpcConfig:C}=i.useAppConfig(),{wallets:I}=i.useWallets(),{user:g}=i.usePrivyContext(),[m,f]=r.useState(),{wrapSmartAccountClientWithUIs:p}=n.useSmartWalletsUIWrapper(),v=t.getEmbeddedConnectedWallet(I);r.useEffect((()=>{(async()=>{if(!s?.enabled)return;let e=s.configuredNetworks.find((e=>e.chainId===`eip155:${q.id}`))?q:h.find((e=>s.configuredNetworks.map((e=>e.chainId)).includes(`eip155:${e.id}`)));if(!e)throw new o.PrivyClientError("Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.");f(await n.getSmartWalletClient({chain:e,privyAppId:u,paymasterContext:c?.paymasterContext,rpcConfig:C,embeddedWallet:v,user:g,smartWalletsConfig:s}))})()}),[!!s?.enabled,!!g?.smartWallet,!!v]);/*#__PURE__*/return e.jsx(d.Provider,{value:{client:m,config:c,getClientForChain:async({id:e})=>{let r=t.getEmbeddedConnectedWallet(I),i=await n.getSmartWalletClient({chain:h.find((r=>r.id===e)),privyAppId:u,paymasterContext:c?.paymasterContext,rpcConfig:C,embeddedWallet:r,user:g,smartWalletsConfig:s});if(!i)throw new o.PrivyClientError(`Failed to create smart wallet client for chain id: ${e}`);return p(i)}},children:a})},d=/*#__PURE__*/r.createContext({client:void 0,config:void 0,getClientForChain:o.notImplemented}),h=({children:t})=>{let{client:a,config:s,getClientForChain:u}=(()=>{let{client:e,config:i,getClientForChain:o}=r.useContext(d);return{client:e,config:i,getClientForChain:o}})(),{config:h}=l(),{wrapSmartAccountClient:q}=n.useSmartWalletsWrapper({clientConfig:s,smartWalletsConfig:h}),{user:C}=i.usePrivyContext(),{generateSiweMessageForSmartWallet:I,linkSmartWallet:g,hideWalletUIs:m}=o.usePrivyInternal();return r.useEffect((()=>{(async()=>{if(a&&C&&!C?.smartWallet&&h?.enabled)try{let e=await I({address:a.account.address,chainId:`eip155:${a.chain.id}`});m.current=!0;let r=await a.signMessage({message:e});await g({signature:r,message:e,smartWalletType:h.smartWalletType})}catch(e){console.error("Error creating smart wallet:",e)}finally{m.current=!1}})()}),[!!a,!!C?.smartWallet,!!h?.enabled]),/*#__PURE__*/e.jsx(c.Provider,{value:{client:C?.smartWallet&&a?q(a):void 0,getClientForChain:u},children:t})};exports.SmartWalletsProvider=({config:r,children:i})=>/*#__PURE__*/e.jsx(s,{children:/*#__PURE__*/e.jsx(u,{config:r,children:/*#__PURE__*/e.jsx(h,{children:i})})}),exports.useSmartWallets=()=>{let{client:e,getClientForChain:i}=r.useContext(c);return{client:e,getClientForChain:i}};
|
package/dist/cjs/solana.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@solana/wallet-adapter-base"),r=require("@solana/wallet-standard-wallet-adapter-base"),o=require("@wallet-standard/app"),i=require("./privy-provider-
|
|
1
|
+
"use strict";var e=require("@solana/wallet-adapter-base"),r=require("@solana/wallet-standard-wallet-adapter-base"),o=require("@wallet-standard/app"),i=require("./privy-provider-Cddj6OMJ.js"),n=require("react"),t=require("./internal-context-MaZRiWRJ.js"),c=require("./useFundWallet-CHZEiRO4.js");require("react/jsx-runtime"),require("mipd"),require("react-device-detect"),require("viem/utils"),require("@privy-io/js-sdk-core"),require("viem"),require("uuid"),require("jose"),require("eventemitter3"),require("@coinbase/wallet-sdk"),require("@marsidev/react-turnstile"),require("styled-components"),require("tinycolor2"),require("@heroicons/react/24/outline/DevicePhoneMobileIcon"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/24/outline/ChevronDownIcon"),require("@heroicons/react/24/outline/CalendarIcon"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@headlessui/react"),require("@walletconnect/ethereum-provider"),require("zustand"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/UserCircleIcon"),require("@heroicons/react/24/outline/EnvelopeIcon"),require("@heroicons/react/20/solid/CheckIcon"),require("@heroicons/react/24/outline/WalletIcon"),require("@heroicons/react/24/outline/CheckIcon"),require("@heroicons/react/24/outline/Square2StackIcon"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("@heroicons/react/24/outline/ArrowTopRightOnSquareIcon"),require("@heroicons/react/24/solid/DocumentCheckIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("qrcode"),require("@heroicons/react/24/outline/ChevronRightIcon"),require("@heroicons/react/24/outline/LockClosedIcon"),require("@heroicons/react/24/outline/PencilSquareIcon"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/LockClosedIcon"),require("@heroicons/react/24/outline/CheckCircleIcon"),require("@heroicons/react/24/outline/InformationCircleIcon"),require("@heroicons/react/24/outline/CreditCardIcon"),require("@heroicons/react/24/outline/QrCodeIcon"),require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),require("@heroicons/react/24/outline/GlobeAltIcon"),require("ofetch"),require("@heroicons/react/24/outline"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("@heroicons/react/24/outline/CloudArrowUpIcon"),require("@heroicons/react/24/outline/NoSymbolIcon"),require("@heroicons/react/24/outline/ClockIcon"),require("@heroicons/react/24/outline/TrashIcon"),require("@heroicons/react/24/solid/CheckBadgeIcon"),require("@heroicons/react/24/solid/IdentificationIcon"),require("@heroicons/react/24/outline/MinusCircleIcon"),require("@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon"),require("@heroicons/react/24/solid/ShieldCheckIcon"),require("js-cookie"),require("@solana/spl-token"),require("@solana/web3.js");let a=o=>o.filter(e.isWalletAdapterCompatibleStandardWallet).map((e=>new r.StandardWalletAdapter({wallet:e})));exports.SolanaAdapterConnector=i.SolanaWalletConnector,exports.useSendTransaction=i.useSendTransaction,exports.useSignMessage=i.useSignMessage,exports.useSolanaWallets=i.useSolanaWallets,exports.useFundWallet=c.useFundWallet,exports.toSolanaWalletConnectors=e=>{let r,{get:n,on:t}=o.getWallets(),c=e?.shouldAutoConnect??!0,s=[],l=[];function u(...e){l=(s=s.concat(...a(e))).map((e=>new i.SolanaWalletConnector(e,c))),r?.(l)}function q(...e){l=(s=s.filter((r=>e.some((e=>r.wallet===e))))).map((e=>new i.SolanaWalletConnector(e,c))),r?.(l)}let h=[t("register",u),t("unregister",q)];return l=(s=a(n())).map((e=>new i.SolanaWalletConnector(e,c))),{_setOnConnectorsUpdated:e=>{r=e},onMount:()=>{h[0]||(h[0]=t("register",u)),h[1]||(h[1]=t("unregister",q))},onUnmount:()=>{let e=h.pop();for(;e;)e(),e=h.pop()},get:()=>l}},exports.useImportWallet=()=>{let{getAccessToken:e,user:r}=i.usePrivyContext(),{refreshSessionAndUser:o,initializeWalletProxy:c}=t.usePrivyInternal(),a=i.useEmitPrivyEvent();return{importWallet:n.useCallback((({privateKey:n})=>i.importWallet({getAccessToken:e,user:r,initializeWalletProxy:c,refreshSessionAndUser:o,emitPrivyEvent:a},{privateKey:n,chainType:"solana"})),[r,e,o,c,a])}},exports.useSignTransaction=function(e){let r=i.useAppConfig(),{getAccessToken:o,user:n}=i.usePrivy(),{setModalData:c}=i.usePrivyModal(),{isHeadlessSigning:a,openModal:s,walletProxy:l,recoverPrimaryWallet:u,privy:q}=t.usePrivyInternal(),h=i.useEmitPrivyEvent();return i.usePrivyEventSubscription("signSolanaTransaction",e),{signTransaction:async({transaction:e,connection:t,uiOptions:d,transactionOptions:p,address:I})=>{let{signedTransaction:C}=await i.signOrSendSolanaTransactionInternal({privy:q,appConfig:r,getAccessToken:o,isHeadlessSigning:a,emitPrivyEvent:h,setModalData:c,openModal:s,walletProxy:l,user:n,recoverPrimaryWallet:u},{transaction:e,connection:t,transactionOptions:p,uiOptions:d,address:I,signOnly:!0});return C}}},exports.useSolanaFundingPlugin=()=>i.useRegisterPlugin(c.t);
|