@wagmi/connectors 0.3.5 → 0.3.6
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.
|
@@ -102,7 +102,7 @@ function getInjectedName(ethereum) {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
// src/injected.ts
|
|
105
|
-
var _provider
|
|
105
|
+
var _provider;
|
|
106
106
|
var InjectedConnector = class extends Connector {
|
|
107
107
|
constructor({
|
|
108
108
|
chains,
|
|
@@ -110,7 +110,6 @@ var InjectedConnector = class extends Connector {
|
|
|
110
110
|
} = {}) {
|
|
111
111
|
const options = {
|
|
112
112
|
shimDisconnect: true,
|
|
113
|
-
shimChainChangedDisconnect: true,
|
|
114
113
|
getProvider: () => typeof window !== "undefined" ? window.ethereum : void 0,
|
|
115
114
|
...options_
|
|
116
115
|
};
|
|
@@ -119,7 +118,6 @@ var InjectedConnector = class extends Connector {
|
|
|
119
118
|
__publicField(this, "name");
|
|
120
119
|
__publicField(this, "ready");
|
|
121
120
|
__privateAdd(this, _provider, void 0);
|
|
122
|
-
__privateAdd(this, _switchingChains, void 0);
|
|
123
121
|
__publicField(this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
|
|
124
122
|
__publicField(this, "onAccountsChanged", (accounts) => {
|
|
125
123
|
if (accounts.length === 0)
|
|
@@ -134,10 +132,14 @@ var InjectedConnector = class extends Connector {
|
|
|
134
132
|
const unsupported = this.isChainUnsupported(id);
|
|
135
133
|
this.emit("change", { chain: { id, unsupported } });
|
|
136
134
|
});
|
|
137
|
-
__publicField(this, "onDisconnect", () => {
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
__publicField(this, "onDisconnect", async (error) => {
|
|
136
|
+
if (error.code === 1013) {
|
|
137
|
+
const provider = await this.getProvider();
|
|
138
|
+
if (provider) {
|
|
139
|
+
const isAuthorized = await this.getAccount();
|
|
140
|
+
if (isAuthorized)
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
141
143
|
}
|
|
142
144
|
this.emit("disconnect");
|
|
143
145
|
if (this.options.shimDisconnect)
|
|
@@ -248,8 +250,6 @@ var InjectedConnector = class extends Connector {
|
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
252
|
async switchChain(chainId) {
|
|
251
|
-
if (this.options.shimChainChangedDisconnect)
|
|
252
|
-
__privateSet(this, _switchingChains, true);
|
|
253
253
|
const provider = await this.getProvider();
|
|
254
254
|
if (!provider)
|
|
255
255
|
throw new ConnectorNotFoundError();
|
|
@@ -331,7 +331,6 @@ var InjectedConnector = class extends Connector {
|
|
|
331
331
|
}
|
|
332
332
|
};
|
|
333
333
|
_provider = new WeakMap();
|
|
334
|
-
_switchingChains = new WeakMap();
|
|
335
334
|
|
|
336
335
|
export {
|
|
337
336
|
InjectedConnector
|
package/dist/injected.d.ts
CHANGED
|
@@ -16,11 +16,6 @@ type InjectedConnectorOptions = {
|
|
|
16
16
|
* () => typeof window !== 'undefined' ? window.ethereum : undefined
|
|
17
17
|
*/
|
|
18
18
|
getProvider?: () => Ethereum | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* MetaMask 10.9.3 emits disconnect event when chain is changed.
|
|
21
|
-
* This flag prevents the `"disconnect"` event from being emitted upon switching chains. See [GitHub issue](https://github.com/MetaMask/metamask-extension/issues/13375#issuecomment-1027663334) for more info.
|
|
22
|
-
*/
|
|
23
|
-
shimChainChangedDisconnect?: boolean;
|
|
24
19
|
/**
|
|
25
20
|
* MetaMask and other injected providers do not support programmatic disconnect.
|
|
26
21
|
* This flag simulates the disconnect behavior by keeping track of connection status in storage. See [GitHub issue](https://github.com/MetaMask/metamask-extension/issues/10353) for more info.
|
|
@@ -66,7 +61,7 @@ declare class InjectedConnector extends Connector<Ethereum | undefined, Connecto
|
|
|
66
61
|
}): Promise<boolean>;
|
|
67
62
|
protected onAccountsChanged: (accounts: string[]) => void;
|
|
68
63
|
protected onChainChanged: (chainId: number | string) => void;
|
|
69
|
-
protected onDisconnect: () => void
|
|
64
|
+
protected onDisconnect: (error: Error) => Promise<void>;
|
|
70
65
|
protected isUserRejectedRequestError(error: unknown): boolean;
|
|
71
66
|
}
|
|
72
67
|
|
package/dist/injected.js
CHANGED
package/dist/metaMask.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import './base-84a689bb.js';
|
|
|
7
7
|
import 'eventemitter3';
|
|
8
8
|
import 'abitype';
|
|
9
9
|
|
|
10
|
-
type MetaMaskConnectorOptions = Pick<InjectedConnectorOptions, '
|
|
10
|
+
type MetaMaskConnectorOptions = Pick<InjectedConnectorOptions, 'shimDisconnect'> & {
|
|
11
11
|
/**
|
|
12
12
|
* While "disconnected" with `shimDisconnect`, allows user to select a different MetaMask account (than the currently connected account) when trying to connect.
|
|
13
13
|
*/
|
package/dist/metaMask.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
InjectedConnector
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QM3JMJ34.js";
|
|
4
4
|
import {
|
|
5
5
|
__privateAdd,
|
|
6
6
|
__privateGet,
|
|
@@ -25,7 +25,6 @@ var MetaMaskConnector = class extends InjectedConnector {
|
|
|
25
25
|
const options = {
|
|
26
26
|
name: "MetaMask",
|
|
27
27
|
shimDisconnect: true,
|
|
28
|
-
shimChainChangedDisconnect: true,
|
|
29
28
|
getProvider() {
|
|
30
29
|
function getReady(ethereum2) {
|
|
31
30
|
const isMetaMask = !!ethereum2?.isMetaMask;
|