@dynamic-labs/wagmi-connector 0.14.7 → 0.14.9
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/index.cjs +20 -6
- package/index.js +22 -8
- package/package.json +3 -2
- package/src/lib/DynamicWagmiConnector.d.ts +2 -4
- package/src/lib/SyncDynamicWagmi.d.ts +6 -0
package/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var wagmi = require('wagmi');
|
|
7
|
+
var _public = require('wagmi/providers/public');
|
|
7
8
|
var sdkReact = require('@dynamic-labs/sdk-react');
|
|
8
9
|
var utils = require('ethers/lib/utils.js');
|
|
9
10
|
|
|
@@ -129,7 +130,7 @@ class Connector extends wagmi.Connector {
|
|
|
129
130
|
if (!this.walletConnector) {
|
|
130
131
|
throw new Error('WalletConnector is not defined');
|
|
131
132
|
}
|
|
132
|
-
const network = yield
|
|
133
|
+
const network = yield this.walletConnector.getNetwork();
|
|
133
134
|
if (!network) {
|
|
134
135
|
throw new Error('Network is not defined');
|
|
135
136
|
}
|
|
@@ -177,7 +178,7 @@ class Connector extends wagmi.Connector {
|
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
180
|
|
|
180
|
-
const
|
|
181
|
+
const SyncDynamicWagmi = ({
|
|
181
182
|
children
|
|
182
183
|
}) => {
|
|
183
184
|
const {
|
|
@@ -219,10 +220,23 @@ const DynamicWagmiConnector = ({
|
|
|
219
220
|
}, [connect, disconnect, handleLogOut, status, walletConnector]);
|
|
220
221
|
// use React.createElement to prevent bunding react/jsx-runtime,
|
|
221
222
|
// which is not compatible when bundling apps using React 17
|
|
222
|
-
|
|
223
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
|
|
224
|
-
children
|
|
225
|
-
});
|
|
223
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, children);
|
|
226
224
|
};
|
|
227
225
|
|
|
226
|
+
const {
|
|
227
|
+
provider
|
|
228
|
+
} = wagmi.configureChains(wagmi.defaultChains, [_public.publicProvider()]);
|
|
229
|
+
const client = wagmi.createClient({
|
|
230
|
+
provider
|
|
231
|
+
});
|
|
232
|
+
const DynamicWagmiConnector = ({
|
|
233
|
+
children
|
|
234
|
+
}) =>
|
|
235
|
+
/*#__PURE__*/
|
|
236
|
+
// use React.createElement to prevent bunding react/jsx-runtime,
|
|
237
|
+
// which is not compatible when bundling apps using React 17
|
|
238
|
+
React__default["default"].createElement(wagmi.WagmiConfig, {
|
|
239
|
+
client: client
|
|
240
|
+
}, /*#__PURE__*/React__default["default"].createElement(SyncDynamicWagmi, null, children));
|
|
241
|
+
|
|
228
242
|
exports.DynamicWagmiConnector = DynamicWagmiConnector;
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useRef, useEffect } from 'react';
|
|
2
|
-
import { Connector as Connector$1, useConnect, useDisconnect } from 'wagmi';
|
|
3
|
-
import {
|
|
2
|
+
import { Connector as Connector$1, useConnect, useDisconnect, configureChains, defaultChains, createClient, WagmiConfig } from 'wagmi';
|
|
3
|
+
import { publicProvider } from 'wagmi/providers/public';
|
|
4
|
+
import { useDynamicContext } from '@dynamic-labs/sdk-react';
|
|
4
5
|
import { getAddress, hexValue } from 'ethers/lib/utils.js';
|
|
5
6
|
|
|
6
7
|
/******************************************************************************
|
|
@@ -121,7 +122,7 @@ class Connector extends Connector$1 {
|
|
|
121
122
|
if (!this.walletConnector) {
|
|
122
123
|
throw new Error('WalletConnector is not defined');
|
|
123
124
|
}
|
|
124
|
-
const network = yield
|
|
125
|
+
const network = yield this.walletConnector.getNetwork();
|
|
125
126
|
if (!network) {
|
|
126
127
|
throw new Error('Network is not defined');
|
|
127
128
|
}
|
|
@@ -169,7 +170,7 @@ class Connector extends Connector$1 {
|
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
|
|
172
|
-
const
|
|
173
|
+
const SyncDynamicWagmi = ({
|
|
173
174
|
children
|
|
174
175
|
}) => {
|
|
175
176
|
const {
|
|
@@ -211,10 +212,23 @@ const DynamicWagmiConnector = ({
|
|
|
211
212
|
}, [connect, disconnect, handleLogOut, status, walletConnector]);
|
|
212
213
|
// use React.createElement to prevent bunding react/jsx-runtime,
|
|
213
214
|
// which is not compatible when bundling apps using React 17
|
|
214
|
-
|
|
215
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
216
|
-
children
|
|
217
|
-
});
|
|
215
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
218
216
|
};
|
|
219
217
|
|
|
218
|
+
const {
|
|
219
|
+
provider
|
|
220
|
+
} = configureChains(defaultChains, [publicProvider()]);
|
|
221
|
+
const client = createClient({
|
|
222
|
+
provider
|
|
223
|
+
});
|
|
224
|
+
const DynamicWagmiConnector = ({
|
|
225
|
+
children
|
|
226
|
+
}) =>
|
|
227
|
+
/*#__PURE__*/
|
|
228
|
+
// use React.createElement to prevent bunding react/jsx-runtime,
|
|
229
|
+
// which is not compatible when bundling apps using React 17
|
|
230
|
+
React.createElement(WagmiConfig, {
|
|
231
|
+
client: client
|
|
232
|
+
}, /*#__PURE__*/React.createElement(SyncDynamicWagmi, null, children));
|
|
233
|
+
|
|
220
234
|
export { DynamicWagmiConnector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/wagmi-connector",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
"directory": "packages/wagmi-connector"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
|
+
"@wagmi/core": "~0.7.9",
|
|
11
12
|
"react": "^17.0.2 || ^18.0.0",
|
|
12
13
|
"ethers": "^5.7.2",
|
|
13
14
|
"wagmi": "^0.8.10",
|
|
14
|
-
"@dynamic-labs/sdk-react": "0.14.
|
|
15
|
+
"@dynamic-labs/sdk-react": "0.14.9"
|
|
15
16
|
},
|
|
16
17
|
"license": "Apache-2.0",
|
|
17
18
|
"module": "./index.js",
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
export declare const DynamicWagmiConnector: ({ children
|
|
2
|
+
export declare const DynamicWagmiConnector: ({ children }: {
|
|
3
3
|
children: ReactNode;
|
|
4
|
-
}) => React.FunctionComponentElement<
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
}>;
|
|
4
|
+
}) => React.FunctionComponentElement<React.PropsWithChildren<import("wagmi").WagmiConfigProps<import("@wagmi/core/dist/index-58cffc47").P, import("@wagmi/core/dist/index-58cffc47").W>>>;
|