@privy-io/wagmi 0.2.4 → 0.2.5-beta-20240509000602
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/esm/index.js +1 -1
- package/dist/index.d.ts +12 -3
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WagmiProvider as
|
|
1
|
+
import{WagmiProvider as L}from"wagmi";import{useEffect as C}from"react";import{useReconnect as P}from"wagmi";import{usePrivy as A,useWallets as S}from"@privy-io/react-auth";var f=()=>{let{ready:t}=A(),{ready:r}=S(),{reconnect:o}=P();C(()=>{t&&r&&o()},[t&&r])};import{useEffect as w}from"react";import{useConfig as x}from"wagmi";import{injected as h}from"wagmi/connectors";import{useConnectWallet as E,useLogin as I,usePrivy as _,useWallets as T}from"@privy-io/react-auth";var u=({selectWalletsForWagmi:t})=>{let{wallets:r}=T(),o=t(r),{user:m}=_(),c=x();E({onSuccess:async n=>{await c.storage?.removeItem(`${n.meta.id}.disconnected`)}}),I({onComplete:async(n,a,l,d,e)=>{!e||e.type==="wallet"||!n.linkedAccounts.find(s=>s.type==="wallet"&&s.walletClientType==="privy")||await c.storage?.removeItem("io.privy.disconnected")}}),w(()=>{let n=m?.linkedAccounts.filter(e=>e.latestVerifiedAt!==null&&!(e.type==="wallet"&&e.walletClientType==="privy")).sort((e,i)=>i.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime())[0],a=n?.type==="wallet"?n:void 0,l=e=>{if(!a)return e[0];let i=o.findIndex(s=>s.address===a.address);return e[i]??e[0]},d=o.map(async e=>{let i=await e.getEthereumProvider(),s=c.connectors.find(W=>W.id===e.meta.id);if(s)return s;let g=h({target:{provider:i,id:e.meta.id,name:e.meta.name,icon:e.meta.icon}});return c._internal.connectors.setup(g)});Promise.all(d).then(async e=>{c._internal.connectors.setState(e);let i=l(e);i&&await c.storage?.setItem("recentConnectorId",i.id)}).catch(console.error)},[o])};import{Fragment as R,jsx as F}from"react/jsx-runtime";var b=t=>t,y=({children:t,selectWalletsForWagmi:r})=>(u({selectWalletsForWagmi:r??b}),f(),F(R,{children:t}));import{jsx as v}from"react/jsx-runtime";var k=({children:t,selectWalletsForWagmi:r,...o})=>v(L,{...o,reconnectOnMount:!1,children:v(y,{selectWalletsForWagmi:r,children:t})});import{createConfig as V}from"wagmi";var $=t=>V({ssr:!0,...t,connectors:t.connectors?.filter(r=>r.type==="mock"),multiInjectedProviderDiscovery:!1});import{useCallback as B}from"react";import{useSwitchAccount as j,useConfig as D,useConnect as M}from"wagmi";var p=()=>{let{switchAccount:t}=j(),{connect:r}=M(),o=D();return{setActiveWallet:B(async c=>{for(let n of o.connectors)if(n.id===c.meta.id&&(await n.getAccounts()).includes(c.address)){await o.storage?.removeItem(`${c.meta.id}.disconnected`),o.state.connections.get(n.uid)?t({connector:n}):r({connector:n});return}},[o.connectors,o.state.connections,r,t])}};var N=()=>{let{setActiveWallet:t}=p();return{setActiveWallet:t,activeWallet:void 0}};import{useEffect as O}from"react";import{useConfig as U,useConnectors as q,useReconnect as z}from"wagmi";import{injected as G}from"wagmi/connectors";var H=({getSmartAccountFromSigner:t})=>{let r=q(),o=U(),{reconnect:m}=z();O(()=>{(async()=>{if(r.find(s=>s.id==="io.privy.smart_wallet"))return;let a=r.find(s=>s.id==="io.privy.wallet");if(!a)return;let l=await a.getProvider(),d=await t({signer:l}),e=G({target:{provider:d,id:"io.privy.smart_wallet",name:"io.privy.smart_wallet",icon:""}}),i=o._internal.connectors.setup(e);o._internal.connectors.setState([i]),await o.storage?.setItem("recentConnectorId",i.id),m()})()},[r,o,t])};export{k as WagmiProvider,$ as createConfig,H as useEmbeddedSmartAccountConnector,N as usePrivyWagmi,p as useSetActiveWallet};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as wagmi from 'wagmi';
|
|
3
3
|
import { WagmiProviderProps, CreateConfigParameters } from 'wagmi';
|
|
4
|
-
import { Chain, Transport, EIP1193Provider } from 'viem';
|
|
5
4
|
import * as _privy_io_react_auth from '@privy-io/react-auth';
|
|
6
5
|
import { ConnectedWallet } from '@privy-io/react-auth';
|
|
6
|
+
import { Chain, Transport, EIP1193Provider } from 'viem';
|
|
7
|
+
|
|
8
|
+
type SelectWalletsForWagmiType = (wallets: ConnectedWallet[]) => ConnectedWallet[];
|
|
9
|
+
|
|
10
|
+
interface PrivyWagmiConnectorProps {
|
|
11
|
+
/**
|
|
12
|
+
* @experimental Filter the connected wallets (including the embedded wallet) that are passed to wagmi state.
|
|
13
|
+
*/
|
|
14
|
+
selectWalletsForWagmi?: SelectWalletsForWagmiType;
|
|
15
|
+
}
|
|
7
16
|
|
|
8
|
-
declare const WagmiProvider: ({ children, ...props }: React.PropsWithChildren<WagmiProviderProps>) => react_jsx_runtime.JSX.Element;
|
|
17
|
+
declare const WagmiProvider: ({ children, selectWalletsForWagmi, ...props }: React.PropsWithChildren<WagmiProviderProps & PrivyWagmiConnectorProps>) => react_jsx_runtime.JSX.Element;
|
|
9
18
|
|
|
10
19
|
declare const createConfig: <const chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]["id"], Transport>>(args: CreateConfigParameters<chains, transports>) => wagmi.Config<chains, transports>;
|
|
11
20
|
|
|
@@ -72,4 +81,4 @@ type useEmbeddedSmartAccountConnectorParams = {
|
|
|
72
81
|
*/
|
|
73
82
|
declare const useEmbeddedSmartAccountConnector: ({ getSmartAccountFromSigner, }: useEmbeddedSmartAccountConnectorParams) => void;
|
|
74
83
|
|
|
75
|
-
export { WagmiProvider, createConfig, useEmbeddedSmartAccountConnector, usePrivyWagmi, useSetActiveWallet };
|
|
84
|
+
export { SelectWalletsForWagmiType, WagmiProvider, createConfig, useEmbeddedSmartAccountConnector, usePrivyWagmi, useSetActiveWallet };
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.2.
|
|
2
|
+
"version": "0.2.5-beta-20240509000602",
|
|
3
3
|
"name": "@privy-io/wagmi",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "Wagmi bindings for the react client",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": "^5.0.4"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@privy-io/react-auth": "
|
|
49
|
+
"@privy-io/react-auth": "1.64.1-beta-20240509000602",
|
|
50
50
|
"viem": "^2",
|
|
51
51
|
"wagmi": "^2",
|
|
52
52
|
"react": "^18",
|