@privy-io/expo 0.76.2 → 0.76.3
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/cards.d.ts +121 -0
- package/dist/cards.js +1 -0
- package/dist/{chunk-FJGLXYQV.js → chunk-6D3SMMVW.js} +1 -1
- package/dist/chunk-HNRKZKAW.js +12 -0
- package/dist/chunk-KPLYSDTS.js +299 -0
- package/dist/esm/cards.js +1 -0
- package/dist/esm/{chunk-FJGLXYQV.js → chunk-6D3SMMVW.js} +1 -1
- package/dist/esm/chunk-HNRKZKAW.js +12 -0
- package/dist/esm/chunk-KPLYSDTS.js +299 -0
- package/dist/esm/extended-chains.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/passkey.js +1 -1
- package/dist/esm/smart-wallets.js +1 -1
- package/dist/esm/ui.js +1 -251
- package/dist/extended-chains.js +1 -1
- package/dist/index.js +1 -1
- package/dist/passkey.js +1 -1
- package/dist/smart-wallets.js +1 -1
- package/dist/ui.js +1 -251
- package/package.json +10 -4
- package/dist/chunk-6GY37RNT.js +0 -12
- package/dist/esm/chunk-6GY37RNT.js +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as M}from"./chunk-QSWCX5XI.js";import{b as _,d as g,i as v,ka as w,m as k}from"./chunk-
|
|
1
|
+
import{a as M}from"./chunk-QSWCX5XI.js";import{b as _,d as g,i as v,ka as w,m as k}from"./chunk-HNRKZKAW.js";import{a as h,b as A,c as I,e as m}from"./chunk-K5SPDXVF.js";import p,{createContext as x,useCallback as Z,useContext as f,useEffect as T,useState as L}from"react";import{getDataSuffixPlugin as O,getUserSmartWallet as S,PrivyClientError as u}from"@privy-io/js-sdk-core";import{createPublicClient as Y,http as H}from"viem";import{getJsonRpcEndpointFromChain as X,getUserSmartWallet as j,PrivyClientError as N}from"@privy-io/js-sdk-core";import{signerToSmartAccountClient as J}from"@privy-io/js-sdk-core/smart-wallets";var P=y=>m(void 0,[y],function*({chain:t,privyAppId:e,user:a,embeddedWallet:r,smartWalletsConfig:n,client:i,dataSuffix:c}){if(!(n!=null&&n.enabled)||!r||!M(r))return;let s=yield i.embeddedWallet.getProvider(r.account),o=n==null?void 0:n.configured_networks.find(B=>B.chain_id===`eip155:${t.id}`);if(!o)throw new N({code:"chain_not_supported",error:`The chain ${t.name} (eip155:${t.id}) must be configured in the smart wallet configuration in your dashboard`});let l=j(a),C=l?l.smart_wallet_type:n.smart_wallet_type,W=l?l.smart_wallet_version:n.smart_wallet_version,F=X(t,{rpcUrls:[]},e),G=Y({chain:t,transport:H(F)}),E=yield J({owner:s,smartWalletType:C,smartWalletVersion:W,chain:t,publicClient:G,paymasterContext:Q(o.paymaster_url,o.paymaster_context),bundlerUrl:o.bundler_url,paymasterUrl:o.paymaster_url});if(!E)throw new N({code:"smart_wallet_client_error",error:`Failed to create smart wallet client for chain ${t.name} (eip155:${t.id})`});return K(E,c)});function K(t,e){return e?t.extend(a=>({sendTransaction:r=>a.sendTransaction(I(A({},r),{dataSuffix:e}))})):t}var V=/paymaster\.biconomy\.io\/api/i;function q(t){return V.test(t)}var z={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}},Q=(t,e)=>{if(t&&q(t))return z;if(e&&e.policy_id)return{policyId:e.policy_id}};var U=3,tt=500,et=({children:t})=>p.createElement(at,null,p.createElement(it,null,p.createElement(lt,null,t))),D=x({config:void 0}),b=()=>{let{config:t}=f(D);return{config:t}},R=x({smartWalletClient:void 0}),rt=()=>{let{smartWalletClient:t}=f(R);return{smartWalletClient:t}},$=x({client:void 0}),nt=()=>{let{client:t}=f($),e=ot();return{client:t,getClientForChain:e}},at=({children:t})=>{let[e,a]=L(void 0),r=k();return T(()=>{!e&&r&&(()=>m(void 0,null,function*(){try{if(!r){console.warn("No client found");return}let i=yield r.app.getSmartWalletConfig();a(i)}catch(i){console.warn("Error generating smart wallet config: ",i)}}))()},[r,e]),p.createElement(D.Provider,{value:{config:e}},t)},it=({children:t})=>{let{config:e}=b(),{client:a,wallet:r}=f(w),n=g(),[i,c]=L();return T(()=>{(()=>m(void 0,null,function*(){var l;if(!n&&i&&c(void 0),!(e!=null&&e.enabled)||!n||r.status!=="connected"||n&&i&&r.status==="connected")return;let s=a.embeddedWallet.chains.find(C=>e.configured_networks.map(W=>W.chain_id).includes(`eip155:${C.id}`));if(!s)throw new u({error:"Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.",code:"chain_not_supported"});let o=yield P({chain:s,privyAppId:a.app.appId,user:n,embeddedWallet:r,smartWalletsConfig:e,client:a,dataSuffix:(l=O(a.plugins))==null?void 0:l.suffix});if(!o)throw new u({error:"Could not create smart wallet client",code:"smart_wallet_client_error"});c(o)}))()},[!!(e!=null&&e.enabled),!!a,!!n,r.status]),p.createElement(R.Provider,{value:{smartWalletClient:i}},t)},lt=({children:t})=>{let{client:e,wallet:a}=f(w),r=g(),{smartWalletClient:n}=rt(),{config:i}=b();return T(()=>{let c=!1;return(()=>m(void 0,null,function*(){var d;if(!(!n||!r||S(r)||!(i!=null&&i.enabled)||a.status!=="connected"))for(let s=0;s<U;s++){if(c||S((d=_())!=null?d:r))return;let o=!1;for(let l=0;l<5;l++){if(c)return;if(yield e.embeddedWallet.ping(tt)){o=!0;break}yield v(200*h(2,l))}if(o)try{let{message:l}=yield e.auth.smartWallet.init({address:n.account.address,chainId:`eip155:${n.chain.id}`}),C=yield n.signMessage({message:l});yield e.auth.smartWallet.link(l,C,i.smart_wallet_type,i.smart_wallet_version);return}catch(l){s===U-1?console.error("Error creating smart wallet:",l):yield v(500*h(2,s))}}}))(),()=>{c=!0}},[!!n,!!r,!!S(r),i,a.status]),p.createElement($.Provider,{value:{client:S(r)?n:void 0}},t)},ot=()=>{let{client:t,wallet:e}=f(w),{config:a}=b();return Z(n=>m(void 0,[n],function*({chainId:r}){var s;let i=_();if(!i)throw new u({error:"Must be logged in to get a smart wallet client",code:"smart_wallet_client_error"});if(!a||!a.enabled)throw new u({error:"Must have smart wallets enabled to get a smart wallet client",code:"smart_wallet_client_error"});let y=t.embeddedWallet.chains.find(o=>o.id===r);if(!y)throw new u({error:`Could not find chain with id: ${r}`,code:"chain_not_supported"});let d=yield P({chain:y,privyAppId:t.app.appId,user:i,embeddedWallet:e,smartWalletsConfig:a,client:t,dataSuffix:(s=O(t.plugins))==null?void 0:s.suffix});if(!d)throw new u({error:`Could not create smart wallet client for chain ${r}`,code:"smart_wallet_client_error"});return d}),[a,e,t])};export{et as SmartWalletsProvider,nt as useSmartWallets};
|