@privy-io/wagmi 0.0.2-beta-20240214223510
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/README.md +59 -0
- package/dist/esm/index.js +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +1 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @privy-io/wagmi
|
|
2
|
+
|
|
3
|
+
`wagmi` bindings for the `@privy-io/react-auth` library.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install -S @privy-io/wagmi
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
### Configuration
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import {http, createConfig} from 'wagmi';
|
|
17
|
+
import {mainnet} from 'wagmi/chains';
|
|
18
|
+
|
|
19
|
+
export const config = createConfig({
|
|
20
|
+
chains: [mainnet],
|
|
21
|
+
multiInjectedProviderDiscovery: false,
|
|
22
|
+
transports: {
|
|
23
|
+
[mainnet.id]: http(),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
declare module 'wagmi' {
|
|
28
|
+
interface Register {
|
|
29
|
+
config: typeof config;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Providers
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
|
|
38
|
+
import {type ReactNode} from 'react';
|
|
39
|
+
import {http, createConfig} from 'wagmi';
|
|
40
|
+
import {WagmiProvider} from 'wagmi';
|
|
41
|
+
|
|
42
|
+
import config from './config';
|
|
43
|
+
|
|
44
|
+
const queryClient = new QueryClient();
|
|
45
|
+
|
|
46
|
+
export const Providers = (props: {children: ReactNode}) => (
|
|
47
|
+
<PrivyProvider appId="<your-app-id">
|
|
48
|
+
<WagmiProvider config={config} reconnectOnMount={false}>
|
|
49
|
+
<QueryClientProvider client={queryClient}>
|
|
50
|
+
<PrivyWagmiConnector>{props.children}</PrivyWagmiConnector>
|
|
51
|
+
</QueryClientProvider>
|
|
52
|
+
</WagmiProvider>
|
|
53
|
+
</PrivyProvider>
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
Use `wagmi` as you normally would!
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEffect as m}from"react";import{useReconnect as a}from"wagmi";import{usePrivy as p,useWallets as f}from"@privy-io/react-auth";var t=()=>{let{ready:o}=p(),{ready:e}=f(),{reconnect:r}=a();m(()=>{o&&e&&r()},[o&&e])};import{useEffect as P}from"react";import{useConfig as y}from"wagmi";import{injected as l}from"wagmi/connectors";import{useWallets as v}from"@privy-io/react-auth";var n=()=>{let{wallets:o}=v(),e=y();P(()=>{let r=o.map(async c=>{let i=await c.getEthereumProvider(),s=l({target:{provider:i,id:"",name:"",icon:""}});return e._internal.connectors.setup(s)});Promise.all(r).then(e._internal.connectors.setState)},[o])};import{Fragment as d,jsx as g}from"react/jsx-runtime";var u=({children:o})=>(n(),t(),g(d,{children:o}));export{u as PrivyWagmiConnector};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface PrivyWagmiConnectorProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Initialize a wagmi connector for each of the connected wallets in the Privy SDK.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* export const Providers = (props: {children: ReactNode}) => (
|
|
11
|
+
* <PrivyProvider appId="<your-app-id">
|
|
12
|
+
* <WagmiProvider config={config} reconnectOnMount={false}>
|
|
13
|
+
* <QueryClientProvider client={queryClient}>
|
|
14
|
+
* <PrivyWagmiConnector>{props.children}</PrivyWagmiConnector>
|
|
15
|
+
* </QueryClientProvider>
|
|
16
|
+
* </WagmiProvider>
|
|
17
|
+
* </PrivyProvider>
|
|
18
|
+
* );
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
declare const PrivyWagmiConnector: ({ children }: PrivyWagmiConnectorProps) => react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { PrivyWagmiConnector, PrivyWagmiConnectorProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var r in e)s(o,r,{get:e[r],enumerable:!0})},x=(o,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of W(e))!R.call(o,t)&&t!==r&&s(o,t,{get:()=>e[t],enumerable:!(n=g(e,t))||n.enumerable});return o};var E=o=>x(s({},"__esModule",{value:!0}),o);var h={};C(h,{PrivyWagmiConnector:()=>u});module.exports=E(h);var m=require("react"),a=require("wagmi"),c=require("@privy-io/react-auth"),p=()=>{let{ready:o}=(0,c.usePrivy)(),{ready:e}=(0,c.useWallets)(),{reconnect:r}=(0,a.useReconnect)();(0,m.useEffect)(()=>{o&&e&&r()},[o&&e])};var f=require("react"),P=require("wagmi"),y=require("wagmi/connectors"),l=require("@privy-io/react-auth"),v=()=>{let{wallets:o}=(0,l.useWallets)(),e=(0,P.useConfig)();(0,f.useEffect)(()=>{let r=o.map(async n=>{let t=await n.getEthereumProvider(),d=(0,y.injected)({target:{provider:t,id:"",name:"",icon:""}});return e._internal.connectors.setup(d)});Promise.all(r).then(e._internal.connectors.setState)},[o])};var i=require("react/jsx-runtime"),u=({children:o})=>(v(),p(),(0,i.jsx)(i.Fragment,{children:o}));0&&(module.exports={PrivyWagmiConnector});
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.0.2-beta-20240214223510",
|
|
3
|
+
"name": "@privy-io/wagmi",
|
|
4
|
+
"description": "Wagmi bindings for the react client",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"privy",
|
|
7
|
+
"wagmi"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/orgs/privy-io/discussions",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/esm/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"typings": "./dist/index",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"require": "./dist/index.js",
|
|
18
|
+
"import": "./dist/esm/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/**/*",
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "npx tsup --clean --minify",
|
|
29
|
+
"generate-types": "npx tsup --dts-only",
|
|
30
|
+
"clean": "rm -rf dist",
|
|
31
|
+
"dev": "npx tsup --watch",
|
|
32
|
+
"test": "jest --testMatch \"**/*(?!.*integration).test.ts\"",
|
|
33
|
+
"test-integration": "jest --testMatch \"**/test/integration/**/*.test.ts\"",
|
|
34
|
+
"test:ci": "npm run test",
|
|
35
|
+
"lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\" && npx tsc --noEmit",
|
|
36
|
+
"format": "eslint \"src/**/*.{ts,tsx,js,jsx}\" --fix"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@privy-io/eslint-config-custom": "*",
|
|
40
|
+
"@tsconfig/node16-strictest-esm": "^1.0.3",
|
|
41
|
+
"@types/jest": "^29.1.2",
|
|
42
|
+
"@types/react": "^18.2.15",
|
|
43
|
+
"@types/react-dom": "^18.2.7",
|
|
44
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
45
|
+
"ts-jest": "^29.0.3",
|
|
46
|
+
"tsup": "^6.2.3",
|
|
47
|
+
"typescript": "^5.0.4"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@privy-io/react-auth": "1.57.0-beta-20240214223510",
|
|
51
|
+
"viem": "^2",
|
|
52
|
+
"wagmi": "^2",
|
|
53
|
+
"react": "^18",
|
|
54
|
+
"react-dom": "^18"
|
|
55
|
+
},
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/orgs/privy-io/discussions"
|
|
58
|
+
},
|
|
59
|
+
"directories": {
|
|
60
|
+
"test": "test"
|
|
61
|
+
},
|
|
62
|
+
"author": "privy.io",
|
|
63
|
+
"browserslist": [
|
|
64
|
+
"defaults",
|
|
65
|
+
"node >= 18",
|
|
66
|
+
"not op_mini all"
|
|
67
|
+
],
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public"
|
|
70
|
+
}
|
|
71
|
+
}
|