@wagmi/core 0.4.3 → 0.4.4
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/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +1 -1
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +72 -1
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +72 -1
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +73 -2
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +1 -1
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +1 -1
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +1 -1
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +2 -2
- package/dist/{base-e66f9622.esm.js → base-68ec937e.esm.js} +1 -1
- package/dist/{client-1feb9121.cjs.prod.js → client-0140ab1f.cjs.prod.js} +23 -22
- package/dist/{client-ffba0e25.esm.js → client-5df5c2eb.esm.js} +20 -20
- package/dist/{client-53f2119c.cjs.dev.js → client-90ae4735.cjs.dev.js} +23 -22
- package/dist/declarations/src/connectors/injected.d.ts +2 -0
- package/dist/declarations/src/connectors/metaMask.d.ts +16 -1
- package/dist/declarations/src/types/index.d.ts +24 -0
- package/dist/wagmi-core.cjs.dev.js +8 -7
- package/dist/wagmi-core.cjs.prod.js +8 -7
- package/dist/wagmi-core.esm.js +5 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as Connector,
|
|
1
|
+
import { d as Connector, l as _classPrivateMethodInitSpec, _ as _defineProperty, i as _classPrivateFieldInitSpec, n as normalizeChainId, U as UserRejectedRequestError, j as _classPrivateFieldGet, k as _classPrivateFieldSet, e as ChainNotConfiguredError, m as _classPrivateMethodGet, A as AddChainError, h as SwitchChainError } from '../../../dist/base-68ec937e.esm.js';
|
|
2
2
|
import { providers } from 'ethers';
|
|
3
3
|
import { getAddress, hexValue } from 'ethers/lib/utils';
|
|
4
4
|
import 'eventemitter3';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var base = require('../../../dist/base-e71ae4b2.cjs.dev.js');
|
|
6
|
-
var client = require('../../../dist/client-
|
|
6
|
+
var client = require('../../../dist/client-90ae4735.cjs.dev.js');
|
|
7
7
|
require('eventemitter3');
|
|
8
8
|
require('../../../dist/chains-d970ee8d.cjs.dev.js');
|
|
9
9
|
require('../../../dist/rpcs-f1d24f0e.cjs.dev.js');
|
|
@@ -14,6 +14,8 @@ require('ethers/lib/utils');
|
|
|
14
14
|
|
|
15
15
|
var _provider = /*#__PURE__*/new WeakMap();
|
|
16
16
|
|
|
17
|
+
var _UNSTABLE_shimOnConnectSelectAccount = /*#__PURE__*/new WeakMap();
|
|
18
|
+
|
|
17
19
|
var _getReady = /*#__PURE__*/new WeakSet();
|
|
18
20
|
|
|
19
21
|
var _findProvider = /*#__PURE__*/new WeakSet();
|
|
@@ -47,6 +49,75 @@ class MetaMaskConnector extends client.InjectedConnector {
|
|
|
47
49
|
writable: true,
|
|
48
50
|
value: void 0
|
|
49
51
|
});
|
|
52
|
+
|
|
53
|
+
base._classPrivateFieldInitSpec(this, _UNSTABLE_shimOnConnectSelectAccount, {
|
|
54
|
+
writable: true,
|
|
55
|
+
value: void 0
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
base._classPrivateFieldSet(this, _UNSTABLE_shimOnConnectSelectAccount, options.UNSTABLE_shimOnConnectSelectAccount);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async connect() {
|
|
62
|
+
let {
|
|
63
|
+
chainId
|
|
64
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
var _this$options, _getClient$storage, _this$options2, _getClient$storage2;
|
|
68
|
+
|
|
69
|
+
const provider = await this.getProvider();
|
|
70
|
+
if (!provider) throw new base.ConnectorNotFoundError();
|
|
71
|
+
|
|
72
|
+
if (provider.on) {
|
|
73
|
+
provider.on('accountsChanged', this.onAccountsChanged);
|
|
74
|
+
provider.on('chainChanged', this.onChainChanged);
|
|
75
|
+
provider.on('disconnect', this.onDisconnect);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
this.emit('message', {
|
|
79
|
+
type: 'connecting'
|
|
80
|
+
}); // Attempt to show wallet select prompt with `wallet_requestPermissions` when
|
|
81
|
+
// `shimDisconnect` is active and account is in disconnected state (flag in storage)
|
|
82
|
+
|
|
83
|
+
if (base._classPrivateFieldGet(this, _UNSTABLE_shimOnConnectSelectAccount) && (_this$options = this.options) !== null && _this$options !== void 0 && _this$options.shimDisconnect && !((_getClient$storage = client.getClient().storage) !== null && _getClient$storage !== void 0 && _getClient$storage.getItem(client.shimDisconnectKey))) {
|
|
84
|
+
const accounts = await provider.request({
|
|
85
|
+
method: 'eth_accounts'
|
|
86
|
+
}).catch(() => []);
|
|
87
|
+
const isConnected = !!accounts[0];
|
|
88
|
+
if (isConnected) await provider.request({
|
|
89
|
+
method: 'wallet_requestPermissions',
|
|
90
|
+
params: [{
|
|
91
|
+
eth_accounts: {}
|
|
92
|
+
}]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const account = await this.getAccount(); // Switch to chain if provided
|
|
97
|
+
|
|
98
|
+
let id = await this.getChainId();
|
|
99
|
+
let unsupported = this.isChainUnsupported(id);
|
|
100
|
+
|
|
101
|
+
if (chainId && id !== chainId) {
|
|
102
|
+
const chain = await this.switchChain(chainId);
|
|
103
|
+
id = chain.id;
|
|
104
|
+
unsupported = this.isChainUnsupported(id);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.shimDisconnect) (_getClient$storage2 = client.getClient().storage) === null || _getClient$storage2 === void 0 ? void 0 : _getClient$storage2.setItem(client.shimDisconnectKey, true);
|
|
108
|
+
return {
|
|
109
|
+
account,
|
|
110
|
+
chain: {
|
|
111
|
+
id,
|
|
112
|
+
unsupported
|
|
113
|
+
},
|
|
114
|
+
provider
|
|
115
|
+
};
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (this.isUserRejectedRequestError(error)) throw new base.UserRejectedRequestError(error);
|
|
118
|
+
if (error.code === -32002) throw new base.ResourceUnavailableError(error);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
50
121
|
}
|
|
51
122
|
|
|
52
123
|
async getProvider() {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var base = require('../../../dist/base-2d484f6c.cjs.prod.js');
|
|
6
|
-
var client = require('../../../dist/client-
|
|
6
|
+
var client = require('../../../dist/client-0140ab1f.cjs.prod.js');
|
|
7
7
|
require('eventemitter3');
|
|
8
8
|
require('../../../dist/chains-865492ea.cjs.prod.js');
|
|
9
9
|
require('../../../dist/rpcs-1fd0a12f.cjs.prod.js');
|
|
@@ -14,6 +14,8 @@ require('ethers/lib/utils');
|
|
|
14
14
|
|
|
15
15
|
var _provider = /*#__PURE__*/new WeakMap();
|
|
16
16
|
|
|
17
|
+
var _UNSTABLE_shimOnConnectSelectAccount = /*#__PURE__*/new WeakMap();
|
|
18
|
+
|
|
17
19
|
var _getReady = /*#__PURE__*/new WeakSet();
|
|
18
20
|
|
|
19
21
|
var _findProvider = /*#__PURE__*/new WeakSet();
|
|
@@ -47,6 +49,75 @@ class MetaMaskConnector extends client.InjectedConnector {
|
|
|
47
49
|
writable: true,
|
|
48
50
|
value: void 0
|
|
49
51
|
});
|
|
52
|
+
|
|
53
|
+
base._classPrivateFieldInitSpec(this, _UNSTABLE_shimOnConnectSelectAccount, {
|
|
54
|
+
writable: true,
|
|
55
|
+
value: void 0
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
base._classPrivateFieldSet(this, _UNSTABLE_shimOnConnectSelectAccount, options.UNSTABLE_shimOnConnectSelectAccount);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async connect() {
|
|
62
|
+
let {
|
|
63
|
+
chainId
|
|
64
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
var _this$options, _getClient$storage, _this$options2, _getClient$storage2;
|
|
68
|
+
|
|
69
|
+
const provider = await this.getProvider();
|
|
70
|
+
if (!provider) throw new base.ConnectorNotFoundError();
|
|
71
|
+
|
|
72
|
+
if (provider.on) {
|
|
73
|
+
provider.on('accountsChanged', this.onAccountsChanged);
|
|
74
|
+
provider.on('chainChanged', this.onChainChanged);
|
|
75
|
+
provider.on('disconnect', this.onDisconnect);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
this.emit('message', {
|
|
79
|
+
type: 'connecting'
|
|
80
|
+
}); // Attempt to show wallet select prompt with `wallet_requestPermissions` when
|
|
81
|
+
// `shimDisconnect` is active and account is in disconnected state (flag in storage)
|
|
82
|
+
|
|
83
|
+
if (base._classPrivateFieldGet(this, _UNSTABLE_shimOnConnectSelectAccount) && (_this$options = this.options) !== null && _this$options !== void 0 && _this$options.shimDisconnect && !((_getClient$storage = client.getClient().storage) !== null && _getClient$storage !== void 0 && _getClient$storage.getItem(client.shimDisconnectKey))) {
|
|
84
|
+
const accounts = await provider.request({
|
|
85
|
+
method: 'eth_accounts'
|
|
86
|
+
}).catch(() => []);
|
|
87
|
+
const isConnected = !!accounts[0];
|
|
88
|
+
if (isConnected) await provider.request({
|
|
89
|
+
method: 'wallet_requestPermissions',
|
|
90
|
+
params: [{
|
|
91
|
+
eth_accounts: {}
|
|
92
|
+
}]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const account = await this.getAccount(); // Switch to chain if provided
|
|
97
|
+
|
|
98
|
+
let id = await this.getChainId();
|
|
99
|
+
let unsupported = this.isChainUnsupported(id);
|
|
100
|
+
|
|
101
|
+
if (chainId && id !== chainId) {
|
|
102
|
+
const chain = await this.switchChain(chainId);
|
|
103
|
+
id = chain.id;
|
|
104
|
+
unsupported = this.isChainUnsupported(id);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.shimDisconnect) (_getClient$storage2 = client.getClient().storage) === null || _getClient$storage2 === void 0 ? void 0 : _getClient$storage2.setItem(client.shimDisconnectKey, true);
|
|
108
|
+
return {
|
|
109
|
+
account,
|
|
110
|
+
chain: {
|
|
111
|
+
id,
|
|
112
|
+
unsupported
|
|
113
|
+
},
|
|
114
|
+
provider
|
|
115
|
+
};
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (this.isUserRejectedRequestError(error)) throw new base.UserRejectedRequestError(error);
|
|
118
|
+
if (error.code === -32002) throw new base.ResourceUnavailableError(error);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
50
121
|
}
|
|
51
122
|
|
|
52
123
|
async getProvider() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { I as InjectedConnector } from '../../../dist/client-
|
|
1
|
+
import { l as _classPrivateMethodInitSpec, _ as _defineProperty, m as _classPrivateMethodGet, i as _classPrivateFieldInitSpec, k as _classPrivateFieldSet, b as ConnectorNotFoundError, j as _classPrivateFieldGet, U as UserRejectedRequestError, R as ResourceUnavailableError } from '../../../dist/base-68ec937e.esm.js';
|
|
2
|
+
import { I as InjectedConnector, g as getClient, s as shimDisconnectKey } from '../../../dist/client-5df5c2eb.esm.js';
|
|
3
3
|
import 'eventemitter3';
|
|
4
4
|
import '../../../dist/chains-c389721d.esm.js';
|
|
5
5
|
import '../../../dist/rpcs-b73a8f60.esm.js';
|
|
@@ -10,6 +10,8 @@ import 'ethers/lib/utils';
|
|
|
10
10
|
|
|
11
11
|
var _provider = /*#__PURE__*/new WeakMap();
|
|
12
12
|
|
|
13
|
+
var _UNSTABLE_shimOnConnectSelectAccount = /*#__PURE__*/new WeakMap();
|
|
14
|
+
|
|
13
15
|
var _getReady = /*#__PURE__*/new WeakSet();
|
|
14
16
|
|
|
15
17
|
var _findProvider = /*#__PURE__*/new WeakSet();
|
|
@@ -43,6 +45,75 @@ class MetaMaskConnector extends InjectedConnector {
|
|
|
43
45
|
writable: true,
|
|
44
46
|
value: void 0
|
|
45
47
|
});
|
|
48
|
+
|
|
49
|
+
_classPrivateFieldInitSpec(this, _UNSTABLE_shimOnConnectSelectAccount, {
|
|
50
|
+
writable: true,
|
|
51
|
+
value: void 0
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
_classPrivateFieldSet(this, _UNSTABLE_shimOnConnectSelectAccount, options.UNSTABLE_shimOnConnectSelectAccount);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async connect() {
|
|
58
|
+
let {
|
|
59
|
+
chainId
|
|
60
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
var _this$options, _getClient$storage, _this$options2, _getClient$storage2;
|
|
64
|
+
|
|
65
|
+
const provider = await this.getProvider();
|
|
66
|
+
if (!provider) throw new ConnectorNotFoundError();
|
|
67
|
+
|
|
68
|
+
if (provider.on) {
|
|
69
|
+
provider.on('accountsChanged', this.onAccountsChanged);
|
|
70
|
+
provider.on('chainChanged', this.onChainChanged);
|
|
71
|
+
provider.on('disconnect', this.onDisconnect);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.emit('message', {
|
|
75
|
+
type: 'connecting'
|
|
76
|
+
}); // Attempt to show wallet select prompt with `wallet_requestPermissions` when
|
|
77
|
+
// `shimDisconnect` is active and account is in disconnected state (flag in storage)
|
|
78
|
+
|
|
79
|
+
if (_classPrivateFieldGet(this, _UNSTABLE_shimOnConnectSelectAccount) && (_this$options = this.options) !== null && _this$options !== void 0 && _this$options.shimDisconnect && !((_getClient$storage = getClient().storage) !== null && _getClient$storage !== void 0 && _getClient$storage.getItem(shimDisconnectKey))) {
|
|
80
|
+
const accounts = await provider.request({
|
|
81
|
+
method: 'eth_accounts'
|
|
82
|
+
}).catch(() => []);
|
|
83
|
+
const isConnected = !!accounts[0];
|
|
84
|
+
if (isConnected) await provider.request({
|
|
85
|
+
method: 'wallet_requestPermissions',
|
|
86
|
+
params: [{
|
|
87
|
+
eth_accounts: {}
|
|
88
|
+
}]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const account = await this.getAccount(); // Switch to chain if provided
|
|
93
|
+
|
|
94
|
+
let id = await this.getChainId();
|
|
95
|
+
let unsupported = this.isChainUnsupported(id);
|
|
96
|
+
|
|
97
|
+
if (chainId && id !== chainId) {
|
|
98
|
+
const chain = await this.switchChain(chainId);
|
|
99
|
+
id = chain.id;
|
|
100
|
+
unsupported = this.isChainUnsupported(id);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.shimDisconnect) (_getClient$storage2 = getClient().storage) === null || _getClient$storage2 === void 0 ? void 0 : _getClient$storage2.setItem(shimDisconnectKey, true);
|
|
104
|
+
return {
|
|
105
|
+
account,
|
|
106
|
+
chain: {
|
|
107
|
+
id,
|
|
108
|
+
unsupported
|
|
109
|
+
},
|
|
110
|
+
provider
|
|
111
|
+
};
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (this.isUserRejectedRequestError(error)) throw new UserRejectedRequestError(error);
|
|
114
|
+
if (error.code === -32002) throw new ResourceUnavailableError(error);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
46
117
|
}
|
|
47
118
|
|
|
48
119
|
async getProvider() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as _defineProperty, i as _classPrivateFieldInitSpec, k as _classPrivateFieldSet, j as _classPrivateFieldGet, U as UserRejectedRequestError, d as Connector, l as _classPrivateMethodInitSpec, n as normalizeChainId, m as _classPrivateMethodGet } from '../../../dist/base-68ec937e.esm.js';
|
|
2
2
|
import { getAddress } from 'ethers/lib/utils';
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
4
|
import { providers } from 'ethers';
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var base = require('../../../dist/base-e71ae4b2.cjs.dev.js');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
|
-
var client = require('../../../dist/client-
|
|
8
|
+
var client = require('../../../dist/client-90ae4735.cjs.dev.js');
|
|
9
9
|
require('eventemitter3');
|
|
10
10
|
require('../../../dist/chains-d970ee8d.cjs.dev.js');
|
|
11
11
|
require('../../../dist/rpcs-f1d24f0e.cjs.dev.js');
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var base = require('../../../dist/base-2d484f6c.cjs.prod.js');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
|
-
var client = require('../../../dist/client-
|
|
8
|
+
var client = require('../../../dist/client-0140ab1f.cjs.prod.js');
|
|
9
9
|
require('eventemitter3');
|
|
10
10
|
require('../../../dist/chains-865492ea.cjs.prod.js');
|
|
11
11
|
require('../../../dist/rpcs-1fd0a12f.cjs.prod.js');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as Connector,
|
|
1
|
+
import { d as Connector, l as _classPrivateMethodInitSpec, _ as _defineProperty, i as _classPrivateFieldInitSpec, n as normalizeChainId, m as _classPrivateMethodGet, U as UserRejectedRequestError, j as _classPrivateFieldGet, k as _classPrivateFieldSet, h as SwitchChainError } from '../../../dist/base-68ec937e.esm.js';
|
|
2
2
|
import { providers } from 'ethers';
|
|
3
3
|
import { getAddress, hexValue } from 'ethers/lib/utils';
|
|
4
|
-
import { g as getClient } from '../../../dist/client-
|
|
4
|
+
import { g as getClient } from '../../../dist/client-5df5c2eb.esm.js';
|
|
5
5
|
import 'eventemitter3';
|
|
6
6
|
import '../../../dist/chains-c389721d.esm.js';
|
|
7
7
|
import '../../../dist/rpcs-b73a8f60.esm.js';
|
|
@@ -300,4 +300,4 @@ class Connector extends EventEmitter {
|
|
|
300
300
|
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
export { AddChainError as A, ConnectorAlreadyConnectedError as C, ProviderChainsNotFound as P, ResourceUnavailableError as R, SwitchChainNotSupportedError as S, UserRejectedRequestError as U,
|
|
303
|
+
export { AddChainError as A, ConnectorAlreadyConnectedError as C, ProviderChainsNotFound as P, ResourceUnavailableError as R, SwitchChainNotSupportedError as S, UserRejectedRequestError as U, _defineProperty as _, ChainDoesNotSupportMulticallError as a, ConnectorNotFoundError as b, ChainMismatchError as c, Connector as d, ChainNotConfiguredError as e, ProviderRpcError as f, RpcError as g, SwitchChainError as h, _classPrivateFieldInitSpec as i, _classPrivateFieldGet as j, _classPrivateFieldSet as k, _classPrivateMethodInitSpec as l, _classPrivateMethodGet as m, normalizeChainId as n };
|
|
@@ -56,14 +56,12 @@ function getInjectedName(ethereum) {
|
|
|
56
56
|
return (_getName = getName(ethereum)) !== null && _getName !== void 0 ? _getName : 'Injected';
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const
|
|
59
|
+
const shimDisconnectKey = 'injected.shimDisconnect';
|
|
60
60
|
|
|
61
61
|
var _provider = /*#__PURE__*/new WeakMap();
|
|
62
62
|
|
|
63
63
|
var _switchingChains = /*#__PURE__*/new WeakMap();
|
|
64
64
|
|
|
65
|
-
var _isUserRejectedRequestError = /*#__PURE__*/new WeakSet();
|
|
66
|
-
|
|
67
65
|
class InjectedConnector extends base.Connector {
|
|
68
66
|
constructor() {
|
|
69
67
|
let {
|
|
@@ -77,8 +75,6 @@ class InjectedConnector extends base.Connector {
|
|
|
77
75
|
options
|
|
78
76
|
});
|
|
79
77
|
|
|
80
|
-
base._classPrivateMethodInitSpec(this, _isUserRejectedRequestError);
|
|
81
|
-
|
|
82
78
|
base._defineProperty(this, "id", void 0);
|
|
83
79
|
|
|
84
80
|
base._defineProperty(this, "name", void 0);
|
|
@@ -124,8 +120,9 @@ class InjectedConnector extends base.Connector {
|
|
|
124
120
|
return;
|
|
125
121
|
}
|
|
126
122
|
|
|
127
|
-
this.emit('disconnect');
|
|
128
|
-
|
|
123
|
+
this.emit('disconnect'); // Remove shim signalling wallet is disconnected
|
|
124
|
+
|
|
125
|
+
if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.shimDisconnect) (_getClient$storage = getClient().storage) === null || _getClient$storage === void 0 ? void 0 : _getClient$storage.removeItem(shimDisconnectKey);
|
|
129
126
|
});
|
|
130
127
|
|
|
131
128
|
let name = 'Injected';
|
|
@@ -169,9 +166,10 @@ class InjectedConnector extends base.Connector {
|
|
|
169
166
|
const chain = await this.switchChain(chainId);
|
|
170
167
|
id = chain.id;
|
|
171
168
|
unsupported = this.isChainUnsupported(id);
|
|
172
|
-
}
|
|
169
|
+
} // Add shim to storage signalling wallet is connected
|
|
173
170
|
|
|
174
|
-
|
|
171
|
+
|
|
172
|
+
if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.shimDisconnect) (_getClient$storage2 = getClient().storage) === null || _getClient$storage2 === void 0 ? void 0 : _getClient$storage2.setItem(shimDisconnectKey, true);
|
|
175
173
|
return {
|
|
176
174
|
account,
|
|
177
175
|
chain: {
|
|
@@ -181,7 +179,7 @@ class InjectedConnector extends base.Connector {
|
|
|
181
179
|
provider
|
|
182
180
|
};
|
|
183
181
|
} catch (error) {
|
|
184
|
-
if (
|
|
182
|
+
if (this.isUserRejectedRequestError(error)) throw new base.UserRejectedRequestError(error);
|
|
185
183
|
if (error.code === -32002) throw new base.ResourceUnavailableError(error);
|
|
186
184
|
throw error;
|
|
187
185
|
}
|
|
@@ -194,8 +192,9 @@ class InjectedConnector extends base.Connector {
|
|
|
194
192
|
if (!(provider !== null && provider !== void 0 && provider.removeListener)) return;
|
|
195
193
|
provider.removeListener('accountsChanged', this.onAccountsChanged);
|
|
196
194
|
provider.removeListener('chainChanged', this.onChainChanged);
|
|
197
|
-
provider.removeListener('disconnect', this.onDisconnect);
|
|
198
|
-
|
|
195
|
+
provider.removeListener('disconnect', this.onDisconnect); // Remove shim signalling wallet is disconnected
|
|
196
|
+
|
|
197
|
+
if ((_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.shimDisconnect) (_getClient$storage3 = getClient().storage) === null || _getClient$storage3 === void 0 ? void 0 : _getClient$storage3.removeItem(shimDisconnectKey);
|
|
199
198
|
}
|
|
200
199
|
|
|
201
200
|
async getAccount() {
|
|
@@ -230,7 +229,8 @@ class InjectedConnector extends base.Connector {
|
|
|
230
229
|
try {
|
|
231
230
|
var _this$options5, _getClient$storage4;
|
|
232
231
|
|
|
233
|
-
if ((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.shimDisconnect &&
|
|
232
|
+
if ((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.shimDisconnect && // If shim does not exist in storage, wallet is disconnected
|
|
233
|
+
!((_getClient$storage4 = getClient().storage) !== null && _getClient$storage4 !== void 0 && _getClient$storage4.getItem(shimDisconnectKey))) return false;
|
|
234
234
|
const provider = await this.getProvider();
|
|
235
235
|
if (!provider) throw new base.ConnectorNotFoundError();
|
|
236
236
|
const accounts = await provider.request({
|
|
@@ -292,12 +292,12 @@ class InjectedConnector extends base.Connector {
|
|
|
292
292
|
});
|
|
293
293
|
return chain;
|
|
294
294
|
} catch (addError) {
|
|
295
|
-
if (
|
|
295
|
+
if (this.isUserRejectedRequestError(addError)) throw new base.UserRejectedRequestError(error);
|
|
296
296
|
throw new base.AddChainError();
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
if (
|
|
300
|
+
if (this.isUserRejectedRequestError(error)) throw new base.UserRejectedRequestError(error);
|
|
301
301
|
throw new base.SwitchChainError(error);
|
|
302
302
|
}
|
|
303
303
|
}
|
|
@@ -325,10 +325,10 @@ class InjectedConnector extends base.Connector {
|
|
|
325
325
|
});
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
-
|
|
328
|
+
isUserRejectedRequestError(error) {
|
|
329
|
+
return error.code === 4001;
|
|
330
|
+
}
|
|
329
331
|
|
|
330
|
-
function _isUserRejectedRequestError2(error) {
|
|
331
|
-
return error.code === 4001;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
const noopStorage = {
|
|
@@ -636,18 +636,18 @@ function _addEffects2() {
|
|
|
636
636
|
});
|
|
637
637
|
}
|
|
638
638
|
|
|
639
|
-
|
|
639
|
+
let client;
|
|
640
640
|
function createClient(config) {
|
|
641
641
|
const client_ = new Client(config);
|
|
642
|
-
|
|
642
|
+
client = client_;
|
|
643
643
|
return client_;
|
|
644
644
|
}
|
|
645
645
|
function getClient() {
|
|
646
|
-
if (!
|
|
646
|
+
if (!client) {
|
|
647
647
|
throw new Error('No wagmi client found. Ensure you have set up a client: https://wagmi.sh/docs/client');
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
-
return
|
|
650
|
+
return client;
|
|
651
651
|
}
|
|
652
652
|
|
|
653
653
|
exports.Client = Client;
|
|
@@ -656,3 +656,4 @@ exports.createClient = createClient;
|
|
|
656
656
|
exports.createStorage = createStorage;
|
|
657
657
|
exports.getClient = getClient;
|
|
658
658
|
exports.noopStorage = noopStorage;
|
|
659
|
+
exports.shimDisconnectKey = shimDisconnectKey;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as Connector, _ as
|
|
1
|
+
import { d as Connector, _ as _defineProperty, i as _classPrivateFieldInitSpec, n as normalizeChainId, j as _classPrivateFieldGet, k as _classPrivateFieldSet, b as ConnectorNotFoundError, U as UserRejectedRequestError, R as ResourceUnavailableError, e as ChainNotConfiguredError, A as AddChainError, h as SwitchChainError, l as _classPrivateMethodInitSpec, m as _classPrivateMethodGet } from './base-68ec937e.esm.js';
|
|
2
2
|
import create from 'zustand/vanilla';
|
|
3
3
|
import { subscribeWithSelector, persist } from 'zustand/middleware';
|
|
4
4
|
import { providers } from 'ethers';
|
|
@@ -50,14 +50,12 @@ function getInjectedName(ethereum) {
|
|
|
50
50
|
return (_getName = getName(ethereum)) !== null && _getName !== void 0 ? _getName : 'Injected';
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const
|
|
53
|
+
const shimDisconnectKey = 'injected.shimDisconnect';
|
|
54
54
|
|
|
55
55
|
var _provider = /*#__PURE__*/new WeakMap();
|
|
56
56
|
|
|
57
57
|
var _switchingChains = /*#__PURE__*/new WeakMap();
|
|
58
58
|
|
|
59
|
-
var _isUserRejectedRequestError = /*#__PURE__*/new WeakSet();
|
|
60
|
-
|
|
61
59
|
class InjectedConnector extends Connector {
|
|
62
60
|
constructor() {
|
|
63
61
|
let {
|
|
@@ -71,8 +69,6 @@ class InjectedConnector extends Connector {
|
|
|
71
69
|
options
|
|
72
70
|
});
|
|
73
71
|
|
|
74
|
-
_classPrivateMethodInitSpec(this, _isUserRejectedRequestError);
|
|
75
|
-
|
|
76
72
|
_defineProperty(this, "id", void 0);
|
|
77
73
|
|
|
78
74
|
_defineProperty(this, "name", void 0);
|
|
@@ -118,8 +114,9 @@ class InjectedConnector extends Connector {
|
|
|
118
114
|
return;
|
|
119
115
|
}
|
|
120
116
|
|
|
121
|
-
this.emit('disconnect');
|
|
122
|
-
|
|
117
|
+
this.emit('disconnect'); // Remove shim signalling wallet is disconnected
|
|
118
|
+
|
|
119
|
+
if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.shimDisconnect) (_getClient$storage = getClient().storage) === null || _getClient$storage === void 0 ? void 0 : _getClient$storage.removeItem(shimDisconnectKey);
|
|
123
120
|
});
|
|
124
121
|
|
|
125
122
|
let name = 'Injected';
|
|
@@ -163,9 +160,10 @@ class InjectedConnector extends Connector {
|
|
|
163
160
|
const chain = await this.switchChain(chainId);
|
|
164
161
|
id = chain.id;
|
|
165
162
|
unsupported = this.isChainUnsupported(id);
|
|
166
|
-
}
|
|
163
|
+
} // Add shim to storage signalling wallet is connected
|
|
167
164
|
|
|
168
|
-
|
|
165
|
+
|
|
166
|
+
if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.shimDisconnect) (_getClient$storage2 = getClient().storage) === null || _getClient$storage2 === void 0 ? void 0 : _getClient$storage2.setItem(shimDisconnectKey, true);
|
|
169
167
|
return {
|
|
170
168
|
account,
|
|
171
169
|
chain: {
|
|
@@ -175,7 +173,7 @@ class InjectedConnector extends Connector {
|
|
|
175
173
|
provider
|
|
176
174
|
};
|
|
177
175
|
} catch (error) {
|
|
178
|
-
if (
|
|
176
|
+
if (this.isUserRejectedRequestError(error)) throw new UserRejectedRequestError(error);
|
|
179
177
|
if (error.code === -32002) throw new ResourceUnavailableError(error);
|
|
180
178
|
throw error;
|
|
181
179
|
}
|
|
@@ -188,8 +186,9 @@ class InjectedConnector extends Connector {
|
|
|
188
186
|
if (!(provider !== null && provider !== void 0 && provider.removeListener)) return;
|
|
189
187
|
provider.removeListener('accountsChanged', this.onAccountsChanged);
|
|
190
188
|
provider.removeListener('chainChanged', this.onChainChanged);
|
|
191
|
-
provider.removeListener('disconnect', this.onDisconnect);
|
|
192
|
-
|
|
189
|
+
provider.removeListener('disconnect', this.onDisconnect); // Remove shim signalling wallet is disconnected
|
|
190
|
+
|
|
191
|
+
if ((_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.shimDisconnect) (_getClient$storage3 = getClient().storage) === null || _getClient$storage3 === void 0 ? void 0 : _getClient$storage3.removeItem(shimDisconnectKey);
|
|
193
192
|
}
|
|
194
193
|
|
|
195
194
|
async getAccount() {
|
|
@@ -224,7 +223,8 @@ class InjectedConnector extends Connector {
|
|
|
224
223
|
try {
|
|
225
224
|
var _this$options5, _getClient$storage4;
|
|
226
225
|
|
|
227
|
-
if ((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.shimDisconnect &&
|
|
226
|
+
if ((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.shimDisconnect && // If shim does not exist in storage, wallet is disconnected
|
|
227
|
+
!((_getClient$storage4 = getClient().storage) !== null && _getClient$storage4 !== void 0 && _getClient$storage4.getItem(shimDisconnectKey))) return false;
|
|
228
228
|
const provider = await this.getProvider();
|
|
229
229
|
if (!provider) throw new ConnectorNotFoundError();
|
|
230
230
|
const accounts = await provider.request({
|
|
@@ -286,12 +286,12 @@ class InjectedConnector extends Connector {
|
|
|
286
286
|
});
|
|
287
287
|
return chain;
|
|
288
288
|
} catch (addError) {
|
|
289
|
-
if (
|
|
289
|
+
if (this.isUserRejectedRequestError(addError)) throw new UserRejectedRequestError(error);
|
|
290
290
|
throw new AddChainError();
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
if (
|
|
294
|
+
if (this.isUserRejectedRequestError(error)) throw new UserRejectedRequestError(error);
|
|
295
295
|
throw new SwitchChainError(error);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
@@ -319,10 +319,10 @@ class InjectedConnector extends Connector {
|
|
|
319
319
|
});
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
|
|
322
|
+
isUserRejectedRequestError(error) {
|
|
323
|
+
return error.code === 4001;
|
|
324
|
+
}
|
|
323
325
|
|
|
324
|
-
function _isUserRejectedRequestError2(error) {
|
|
325
|
-
return error.code === 4001;
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
const noopStorage = {
|
|
@@ -644,4 +644,4 @@ function getClient() {
|
|
|
644
644
|
return client;
|
|
645
645
|
}
|
|
646
646
|
|
|
647
|
-
export { Client as C, InjectedConnector as I,
|
|
647
|
+
export { Client as C, InjectedConnector as I, createStorage as a, createClient as c, getClient as g, noopStorage as n, shimDisconnectKey as s };
|
|
@@ -56,14 +56,12 @@ function getInjectedName(ethereum) {
|
|
|
56
56
|
return (_getName = getName(ethereum)) !== null && _getName !== void 0 ? _getName : 'Injected';
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const
|
|
59
|
+
const shimDisconnectKey = 'injected.shimDisconnect';
|
|
60
60
|
|
|
61
61
|
var _provider = /*#__PURE__*/new WeakMap();
|
|
62
62
|
|
|
63
63
|
var _switchingChains = /*#__PURE__*/new WeakMap();
|
|
64
64
|
|
|
65
|
-
var _isUserRejectedRequestError = /*#__PURE__*/new WeakSet();
|
|
66
|
-
|
|
67
65
|
class InjectedConnector extends base.Connector {
|
|
68
66
|
constructor() {
|
|
69
67
|
let {
|
|
@@ -77,8 +75,6 @@ class InjectedConnector extends base.Connector {
|
|
|
77
75
|
options
|
|
78
76
|
});
|
|
79
77
|
|
|
80
|
-
base._classPrivateMethodInitSpec(this, _isUserRejectedRequestError);
|
|
81
|
-
|
|
82
78
|
base._defineProperty(this, "id", void 0);
|
|
83
79
|
|
|
84
80
|
base._defineProperty(this, "name", void 0);
|
|
@@ -124,8 +120,9 @@ class InjectedConnector extends base.Connector {
|
|
|
124
120
|
return;
|
|
125
121
|
}
|
|
126
122
|
|
|
127
|
-
this.emit('disconnect');
|
|
128
|
-
|
|
123
|
+
this.emit('disconnect'); // Remove shim signalling wallet is disconnected
|
|
124
|
+
|
|
125
|
+
if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.shimDisconnect) (_getClient$storage = getClient().storage) === null || _getClient$storage === void 0 ? void 0 : _getClient$storage.removeItem(shimDisconnectKey);
|
|
129
126
|
});
|
|
130
127
|
|
|
131
128
|
let name = 'Injected';
|
|
@@ -169,9 +166,10 @@ class InjectedConnector extends base.Connector {
|
|
|
169
166
|
const chain = await this.switchChain(chainId);
|
|
170
167
|
id = chain.id;
|
|
171
168
|
unsupported = this.isChainUnsupported(id);
|
|
172
|
-
}
|
|
169
|
+
} // Add shim to storage signalling wallet is connected
|
|
173
170
|
|
|
174
|
-
|
|
171
|
+
|
|
172
|
+
if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.shimDisconnect) (_getClient$storage2 = getClient().storage) === null || _getClient$storage2 === void 0 ? void 0 : _getClient$storage2.setItem(shimDisconnectKey, true);
|
|
175
173
|
return {
|
|
176
174
|
account,
|
|
177
175
|
chain: {
|
|
@@ -181,7 +179,7 @@ class InjectedConnector extends base.Connector {
|
|
|
181
179
|
provider
|
|
182
180
|
};
|
|
183
181
|
} catch (error) {
|
|
184
|
-
if (
|
|
182
|
+
if (this.isUserRejectedRequestError(error)) throw new base.UserRejectedRequestError(error);
|
|
185
183
|
if (error.code === -32002) throw new base.ResourceUnavailableError(error);
|
|
186
184
|
throw error;
|
|
187
185
|
}
|
|
@@ -194,8 +192,9 @@ class InjectedConnector extends base.Connector {
|
|
|
194
192
|
if (!(provider !== null && provider !== void 0 && provider.removeListener)) return;
|
|
195
193
|
provider.removeListener('accountsChanged', this.onAccountsChanged);
|
|
196
194
|
provider.removeListener('chainChanged', this.onChainChanged);
|
|
197
|
-
provider.removeListener('disconnect', this.onDisconnect);
|
|
198
|
-
|
|
195
|
+
provider.removeListener('disconnect', this.onDisconnect); // Remove shim signalling wallet is disconnected
|
|
196
|
+
|
|
197
|
+
if ((_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.shimDisconnect) (_getClient$storage3 = getClient().storage) === null || _getClient$storage3 === void 0 ? void 0 : _getClient$storage3.removeItem(shimDisconnectKey);
|
|
199
198
|
}
|
|
200
199
|
|
|
201
200
|
async getAccount() {
|
|
@@ -230,7 +229,8 @@ class InjectedConnector extends base.Connector {
|
|
|
230
229
|
try {
|
|
231
230
|
var _this$options5, _getClient$storage4;
|
|
232
231
|
|
|
233
|
-
if ((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.shimDisconnect &&
|
|
232
|
+
if ((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.shimDisconnect && // If shim does not exist in storage, wallet is disconnected
|
|
233
|
+
!((_getClient$storage4 = getClient().storage) !== null && _getClient$storage4 !== void 0 && _getClient$storage4.getItem(shimDisconnectKey))) return false;
|
|
234
234
|
const provider = await this.getProvider();
|
|
235
235
|
if (!provider) throw new base.ConnectorNotFoundError();
|
|
236
236
|
const accounts = await provider.request({
|
|
@@ -292,12 +292,12 @@ class InjectedConnector extends base.Connector {
|
|
|
292
292
|
});
|
|
293
293
|
return chain;
|
|
294
294
|
} catch (addError) {
|
|
295
|
-
if (
|
|
295
|
+
if (this.isUserRejectedRequestError(addError)) throw new base.UserRejectedRequestError(error);
|
|
296
296
|
throw new base.AddChainError();
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
if (
|
|
300
|
+
if (this.isUserRejectedRequestError(error)) throw new base.UserRejectedRequestError(error);
|
|
301
301
|
throw new base.SwitchChainError(error);
|
|
302
302
|
}
|
|
303
303
|
}
|
|
@@ -325,10 +325,10 @@ class InjectedConnector extends base.Connector {
|
|
|
325
325
|
});
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
-
|
|
328
|
+
isUserRejectedRequestError(error) {
|
|
329
|
+
return error.code === 4001;
|
|
330
|
+
}
|
|
329
331
|
|
|
330
|
-
function _isUserRejectedRequestError2(error) {
|
|
331
|
-
return error.code === 4001;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
const noopStorage = {
|
|
@@ -636,18 +636,18 @@ function _addEffects2() {
|
|
|
636
636
|
});
|
|
637
637
|
}
|
|
638
638
|
|
|
639
|
-
|
|
639
|
+
let client;
|
|
640
640
|
function createClient(config) {
|
|
641
641
|
const client_ = new Client(config);
|
|
642
|
-
|
|
642
|
+
client = client_;
|
|
643
643
|
return client_;
|
|
644
644
|
}
|
|
645
645
|
function getClient() {
|
|
646
|
-
if (!
|
|
646
|
+
if (!client) {
|
|
647
647
|
throw new Error('No wagmi client found. Ensure you have set up a client: https://wagmi.sh/docs/client');
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
-
return
|
|
650
|
+
return client;
|
|
651
651
|
}
|
|
652
652
|
|
|
653
653
|
exports.Client = Client;
|
|
@@ -656,3 +656,4 @@ exports.createClient = createClient;
|
|
|
656
656
|
exports.createStorage = createStorage;
|
|
657
657
|
exports.getClient = getClient;
|
|
658
658
|
exports.noopStorage = noopStorage;
|
|
659
|
+
exports.shimDisconnectKey = shimDisconnectKey;
|
|
@@ -18,6 +18,7 @@ export declare type InjectedConnectorOptions = {
|
|
|
18
18
|
*/
|
|
19
19
|
shimDisconnect?: boolean;
|
|
20
20
|
};
|
|
21
|
+
export declare const shimDisconnectKey = "injected.shimDisconnect";
|
|
21
22
|
export declare class InjectedConnector extends Connector<Window['ethereum'], InjectedConnectorOptions | undefined> {
|
|
22
23
|
#private;
|
|
23
24
|
readonly id: string;
|
|
@@ -53,4 +54,5 @@ export declare class InjectedConnector extends Connector<Window['ethereum'], Inj
|
|
|
53
54
|
protected onAccountsChanged: (accounts: string[]) => void;
|
|
54
55
|
protected onChainChanged: (chainId: number | string) => void;
|
|
55
56
|
protected onDisconnect: () => void;
|
|
57
|
+
protected isUserRejectedRequestError(error: unknown): boolean;
|
|
56
58
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Chain } from '../types';
|
|
2
2
|
import { InjectedConnector, InjectedConnectorOptions } from './injected';
|
|
3
|
-
export declare type MetaMaskConnectorOptions = Pick<InjectedConnectorOptions, 'shimChainChangedDisconnect' | 'shimDisconnect'
|
|
3
|
+
export declare type MetaMaskConnectorOptions = Pick<InjectedConnectorOptions, 'shimChainChangedDisconnect' | 'shimDisconnect'> & {
|
|
4
|
+
/**
|
|
5
|
+
* While "disconnected" with `shimDisconnect`, allows user to select a different MetaMask account (than the currently connected account) when trying to connect.
|
|
6
|
+
*/
|
|
7
|
+
UNSTABLE_shimOnConnectSelectAccount?: boolean;
|
|
8
|
+
};
|
|
4
9
|
export declare class MetaMaskConnector extends InjectedConnector {
|
|
5
10
|
#private;
|
|
6
11
|
readonly id = "metaMask";
|
|
@@ -9,5 +14,15 @@ export declare class MetaMaskConnector extends InjectedConnector {
|
|
|
9
14
|
chains?: Chain[];
|
|
10
15
|
options?: MetaMaskConnectorOptions;
|
|
11
16
|
});
|
|
17
|
+
connect({ chainId }?: {
|
|
18
|
+
chainId?: number;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
account: string;
|
|
21
|
+
chain: {
|
|
22
|
+
id: number;
|
|
23
|
+
unsupported: boolean;
|
|
24
|
+
};
|
|
25
|
+
provider: Ethereum;
|
|
26
|
+
}>;
|
|
12
27
|
getProvider(): Promise<Ethereum | undefined>;
|
|
13
28
|
}
|
|
@@ -65,6 +65,17 @@ declare global {
|
|
|
65
65
|
/** Currently ignored. */
|
|
66
66
|
iconUrls?: string[];
|
|
67
67
|
};
|
|
68
|
+
type WalletPermissionCaveat = {
|
|
69
|
+
type: string;
|
|
70
|
+
value: any;
|
|
71
|
+
};
|
|
72
|
+
type WalletPermission = {
|
|
73
|
+
caveats: WalletPermissionCaveat[];
|
|
74
|
+
date: number;
|
|
75
|
+
id: string;
|
|
76
|
+
invoker: `http://${string}` | `https://${string}`;
|
|
77
|
+
parentCapability: 'eth_accounts' | string;
|
|
78
|
+
};
|
|
68
79
|
type WatchAssetParams = {
|
|
69
80
|
/** In the future, other standards will be supported */
|
|
70
81
|
type: 'ERC20';
|
|
@@ -138,6 +149,19 @@ declare global {
|
|
|
138
149
|
request(args: {
|
|
139
150
|
method: 'web3_clientVersion';
|
|
140
151
|
}): Promise<string>;
|
|
152
|
+
/**
|
|
153
|
+
* EIP-2255: Wallet Permissions System
|
|
154
|
+
* https://eips.ethereum.org/EIPS/eip-2255
|
|
155
|
+
*/
|
|
156
|
+
request(args: {
|
|
157
|
+
method: 'wallet_requestPermissions';
|
|
158
|
+
params: [{
|
|
159
|
+
eth_accounts: Record<string, any>;
|
|
160
|
+
}];
|
|
161
|
+
}): Promise<WalletPermission[]>;
|
|
162
|
+
request(args: {
|
|
163
|
+
method: 'wallet_getPermissions';
|
|
164
|
+
}): Promise<WalletPermission[]>;
|
|
141
165
|
/**
|
|
142
166
|
* EIP-3085: Wallet Add Ethereum Chain RPC Method
|
|
143
167
|
* https://eips.ethereum.org/EIPS/eip-3085
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var client = require('./client-
|
|
5
|
+
var client = require('./client-90ae4735.cjs.dev.js');
|
|
6
6
|
var base = require('./base-e71ae4b2.cjs.dev.js');
|
|
7
7
|
var ethers$1 = require('ethers/lib/ethers');
|
|
8
8
|
var utils = require('ethers/lib/utils');
|
|
@@ -183,29 +183,30 @@ async function connect(_ref) {
|
|
|
183
183
|
chainId,
|
|
184
184
|
connector
|
|
185
185
|
} = _ref;
|
|
186
|
-
const
|
|
186
|
+
const client$1 = client.getClient();
|
|
187
|
+
const activeConnector = client$1.connector;
|
|
187
188
|
if (connector.id === (activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.id)) throw new base.ConnectorAlreadyConnectedError();
|
|
188
189
|
|
|
189
190
|
try {
|
|
190
|
-
client.
|
|
191
|
+
client$1.setState(x => ({ ...x,
|
|
191
192
|
status: 'connecting'
|
|
192
193
|
}));
|
|
193
194
|
const data = await connector.connect({
|
|
194
195
|
chainId
|
|
195
196
|
});
|
|
196
|
-
client.
|
|
197
|
-
client.
|
|
197
|
+
client$1.setLastUsedConnector(connector.id);
|
|
198
|
+
client$1.setState(x => ({ ...x,
|
|
198
199
|
connector,
|
|
199
200
|
chains: connector === null || connector === void 0 ? void 0 : connector.chains,
|
|
200
201
|
data,
|
|
201
202
|
status: 'connected'
|
|
202
203
|
}));
|
|
203
|
-
client.
|
|
204
|
+
client$1.storage.setItem('connected', true);
|
|
204
205
|
return { ...data,
|
|
205
206
|
connector
|
|
206
207
|
};
|
|
207
208
|
} catch (err) {
|
|
208
|
-
client.
|
|
209
|
+
client$1.setState(x => ({ ...x,
|
|
209
210
|
status: 'disconnected'
|
|
210
211
|
}));
|
|
211
212
|
throw err;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var client = require('./client-
|
|
5
|
+
var client = require('./client-0140ab1f.cjs.prod.js');
|
|
6
6
|
var base = require('./base-2d484f6c.cjs.prod.js');
|
|
7
7
|
var ethers$1 = require('ethers/lib/ethers');
|
|
8
8
|
var utils = require('ethers/lib/utils');
|
|
@@ -183,29 +183,30 @@ async function connect(_ref) {
|
|
|
183
183
|
chainId,
|
|
184
184
|
connector
|
|
185
185
|
} = _ref;
|
|
186
|
-
const
|
|
186
|
+
const client$1 = client.getClient();
|
|
187
|
+
const activeConnector = client$1.connector;
|
|
187
188
|
if (connector.id === (activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.id)) throw new base.ConnectorAlreadyConnectedError();
|
|
188
189
|
|
|
189
190
|
try {
|
|
190
|
-
client.
|
|
191
|
+
client$1.setState(x => ({ ...x,
|
|
191
192
|
status: 'connecting'
|
|
192
193
|
}));
|
|
193
194
|
const data = await connector.connect({
|
|
194
195
|
chainId
|
|
195
196
|
});
|
|
196
|
-
client.
|
|
197
|
-
client.
|
|
197
|
+
client$1.setLastUsedConnector(connector.id);
|
|
198
|
+
client$1.setState(x => ({ ...x,
|
|
198
199
|
connector,
|
|
199
200
|
chains: connector === null || connector === void 0 ? void 0 : connector.chains,
|
|
200
201
|
data,
|
|
201
202
|
status: 'connected'
|
|
202
203
|
}));
|
|
203
|
-
client.
|
|
204
|
+
client$1.storage.setItem('connected', true);
|
|
204
205
|
return { ...data,
|
|
205
206
|
connector
|
|
206
207
|
};
|
|
207
208
|
} catch (err) {
|
|
208
|
-
client.
|
|
209
|
+
client$1.setState(x => ({ ...x,
|
|
209
210
|
status: 'disconnected'
|
|
210
211
|
}));
|
|
211
212
|
throw err;
|
package/dist/wagmi-core.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as Client, I as InjectedConnector,
|
|
3
|
-
import { C as ConnectorAlreadyConnectedError, P as ProviderChainsNotFound, a as ChainDoesNotSupportMulticallError, b as ConnectorNotFoundError, c as ChainMismatchError, U as UserRejectedRequestError, n as normalizeChainId, S as SwitchChainNotSupportedError } from './base-
|
|
4
|
-
export { A as AddChainError, a as ChainDoesNotSupportMulticallError, c as ChainMismatchError, e as ChainNotConfiguredError, d as Connector, C as ConnectorAlreadyConnectedError, b as ConnectorNotFoundError, P as ProviderChainsNotFound, f as ProviderRpcError, R as ResourceUnavailableError, g as RpcError, h as SwitchChainError, S as SwitchChainNotSupportedError, U as UserRejectedRequestError, n as normalizeChainId } from './base-
|
|
1
|
+
import { g as getClient } from './client-5df5c2eb.esm.js';
|
|
2
|
+
export { C as Client, I as InjectedConnector, c as createClient, a as createStorage, n as noopStorage } from './client-5df5c2eb.esm.js';
|
|
3
|
+
import { C as ConnectorAlreadyConnectedError, P as ProviderChainsNotFound, a as ChainDoesNotSupportMulticallError, b as ConnectorNotFoundError, c as ChainMismatchError, U as UserRejectedRequestError, n as normalizeChainId, S as SwitchChainNotSupportedError } from './base-68ec937e.esm.js';
|
|
4
|
+
export { A as AddChainError, a as ChainDoesNotSupportMulticallError, c as ChainMismatchError, e as ChainNotConfiguredError, d as Connector, C as ConnectorAlreadyConnectedError, b as ConnectorNotFoundError, P as ProviderChainsNotFound, f as ProviderRpcError, R as ResourceUnavailableError, g as RpcError, h as SwitchChainError, S as SwitchChainNotSupportedError, U as UserRejectedRequestError, n as normalizeChainId } from './base-68ec937e.esm.js';
|
|
5
5
|
import { logger, Contract as Contract$1 } from 'ethers/lib/ethers';
|
|
6
6
|
import { isAddress, Logger, formatUnits, getAddress } from 'ethers/lib/utils';
|
|
7
7
|
import { providers, Contract } from 'ethers';
|
|
@@ -177,6 +177,7 @@ async function connect(_ref) {
|
|
|
177
177
|
chainId,
|
|
178
178
|
connector
|
|
179
179
|
} = _ref;
|
|
180
|
+
const client = getClient();
|
|
180
181
|
const activeConnector = client.connector;
|
|
181
182
|
if (connector.id === (activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.id)) throw new ConnectorAlreadyConnectedError();
|
|
182
183
|
|