@wagmi/connectors 2.6.2-cjs → 2.6.3
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/coinbaseWallet/package.json +1 -1
- package/dist/chunk-OQILYQDO.js +4 -4
- package/dist/chunk-QRUHVNWK.js +73 -73
- package/dist/chunk-QYMCVNHT.js +14 -14
- package/dist/chunk-ZCAPXGBX.js +10 -10
- package/dist/coinbaseWallet.js +58 -58
- package/dist/index.js +16 -16
- package/dist/injected.js +9 -9
- package/dist/ledger.js +83 -83
- package/dist/metaMask.js +37 -37
- package/dist/mock/index.js +63 -63
- package/dist/safe.js +46 -46
- package/dist/walletConnect.d.ts +6 -1
- package/dist/walletConnect.js +109 -111
- package/dist/walletConnectLegacy.js +58 -58
- package/injected/package.json +1 -1
- package/ledger/package.json +1 -1
- package/metaMask/package.json +1 -1
- package/mock/package.json +1 -1
- package/package.json +44 -4
- package/safe/package.json +1 -1
- package/walletConnect/package.json +1 -1
- package/walletConnectLegacy/package.json +1 -1
package/dist/metaMask.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import {
|
|
2
|
+
InjectedConnector
|
|
3
|
+
} from "./chunk-QRUHVNWK.js";
|
|
4
|
+
import {
|
|
5
|
+
ConnectorNotFoundError
|
|
6
|
+
} from "./chunk-ZCAPXGBX.js";
|
|
7
|
+
import "./chunk-OQILYQDO.js";
|
|
8
|
+
import {
|
|
9
|
+
__privateAdd,
|
|
10
|
+
__privateGet,
|
|
11
|
+
__privateSet,
|
|
12
|
+
__publicField
|
|
13
|
+
} from "./chunk-QYMCVNHT.js";
|
|
14
14
|
|
|
15
15
|
// src/metaMask.ts
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
import {
|
|
17
|
+
ResourceUnavailableRpcError,
|
|
18
|
+
UserRejectedRequestError,
|
|
19
|
+
getAddress
|
|
20
|
+
} from "viem";
|
|
21
21
|
var _UNSTABLE_shimOnConnectSelectAccount;
|
|
22
|
-
var MetaMaskConnector = class extends
|
|
22
|
+
var MetaMaskConnector = class extends InjectedConnector {
|
|
23
23
|
constructor({
|
|
24
24
|
chains,
|
|
25
25
|
options: options_
|
|
@@ -29,7 +29,7 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
|
|
|
29
29
|
shimDisconnect: true,
|
|
30
30
|
getProvider() {
|
|
31
31
|
function getReady(ethereum2) {
|
|
32
|
-
const isMetaMask = !!
|
|
32
|
+
const isMetaMask = !!ethereum2?.isMetaMask;
|
|
33
33
|
if (!isMetaMask)
|
|
34
34
|
return;
|
|
35
35
|
if (ethereum2.isBraveWallet && !ethereum2._events && !ethereum2._state)
|
|
@@ -67,23 +67,23 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
|
|
|
67
67
|
if (typeof window === "undefined")
|
|
68
68
|
return;
|
|
69
69
|
const ethereum = window.ethereum;
|
|
70
|
-
if (
|
|
70
|
+
if (ethereum?.providers)
|
|
71
71
|
return ethereum.providers.find(getReady);
|
|
72
72
|
return getReady(ethereum);
|
|
73
73
|
},
|
|
74
74
|
...options_
|
|
75
75
|
};
|
|
76
76
|
super({ chains, options });
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
__publicField(this, "id", "metaMask");
|
|
78
|
+
__publicField(this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
|
|
79
|
+
__privateAdd(this, _UNSTABLE_shimOnConnectSelectAccount, void 0);
|
|
80
|
+
__privateSet(this, _UNSTABLE_shimOnConnectSelectAccount, options.UNSTABLE_shimOnConnectSelectAccount);
|
|
81
81
|
}
|
|
82
82
|
async connect({ chainId } = {}) {
|
|
83
83
|
try {
|
|
84
84
|
const provider = await this.getProvider();
|
|
85
85
|
if (!provider)
|
|
86
|
-
throw new
|
|
86
|
+
throw new ConnectorNotFoundError();
|
|
87
87
|
if (provider.on) {
|
|
88
88
|
provider.on("accountsChanged", this.onAccountsChanged);
|
|
89
89
|
provider.on("chainChanged", this.onChainChanged);
|
|
@@ -91,7 +91,7 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
|
|
|
91
91
|
}
|
|
92
92
|
this.emit("message", { type: "connecting" });
|
|
93
93
|
let account = null;
|
|
94
|
-
if (
|
|
94
|
+
if (__privateGet(this, _UNSTABLE_shimOnConnectSelectAccount) && this.options?.shimDisconnect && !this.storage?.getItem(this.shimDisconnectKey)) {
|
|
95
95
|
account = await this.getAccount().catch(() => null);
|
|
96
96
|
const isConnected = !!account;
|
|
97
97
|
if (isConnected)
|
|
@@ -103,8 +103,8 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
|
|
|
103
103
|
account = await this.getAccount();
|
|
104
104
|
} catch (error) {
|
|
105
105
|
if (this.isUserRejectedRequestError(error))
|
|
106
|
-
throw new
|
|
107
|
-
if (error.code === new
|
|
106
|
+
throw new UserRejectedRequestError(error);
|
|
107
|
+
if (error.code === new ResourceUnavailableRpcError(error).code)
|
|
108
108
|
throw error;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
@@ -112,7 +112,7 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
|
|
|
112
112
|
const accounts = await provider.request({
|
|
113
113
|
method: "eth_requestAccounts"
|
|
114
114
|
});
|
|
115
|
-
account =
|
|
115
|
+
account = getAddress(accounts[0]);
|
|
116
116
|
}
|
|
117
117
|
let id = await this.getChainId();
|
|
118
118
|
let unsupported = this.isChainUnsupported(id);
|
|
@@ -121,19 +121,19 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
|
|
|
121
121
|
id = chain.id;
|
|
122
122
|
unsupported = this.isChainUnsupported(id);
|
|
123
123
|
}
|
|
124
|
-
if (
|
|
125
|
-
|
|
124
|
+
if (this.options?.shimDisconnect)
|
|
125
|
+
this.storage?.setItem(this.shimDisconnectKey, true);
|
|
126
126
|
return { account, chain: { id, unsupported }, provider };
|
|
127
127
|
} catch (error) {
|
|
128
128
|
if (this.isUserRejectedRequestError(error))
|
|
129
|
-
throw new
|
|
129
|
+
throw new UserRejectedRequestError(error);
|
|
130
130
|
if (error.code === -32002)
|
|
131
|
-
throw new
|
|
131
|
+
throw new ResourceUnavailableRpcError(error);
|
|
132
132
|
throw error;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
_UNSTABLE_shimOnConnectSelectAccount = new WeakMap();
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
export {
|
|
138
|
+
MetaMaskConnector
|
|
139
|
+
};
|
package/dist/mock/index.js
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import {
|
|
2
|
+
normalizeChainId
|
|
3
|
+
} from "../chunk-OQILYQDO.js";
|
|
4
|
+
import {
|
|
5
|
+
Connector,
|
|
6
|
+
__privateAdd,
|
|
7
|
+
__privateGet,
|
|
8
|
+
__privateMethod,
|
|
9
|
+
__privateSet,
|
|
10
|
+
__publicField
|
|
11
|
+
} from "../chunk-QYMCVNHT.js";
|
|
12
12
|
|
|
13
13
|
// src/mock/connector.ts
|
|
14
|
-
|
|
14
|
+
import { getAddress as getAddress2 } from "viem";
|
|
15
15
|
|
|
16
16
|
// src/mock/provider.ts
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
import { default as EventEmitter } from "eventemitter3";
|
|
18
|
+
import { UserRejectedRequestError, getAddress } from "viem";
|
|
19
19
|
var _options, _walletClient;
|
|
20
20
|
var MockProvider = class {
|
|
21
21
|
constructor(options) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
__publicField(this, "events", new EventEmitter());
|
|
23
|
+
__publicField(this, "chainId");
|
|
24
|
+
__privateAdd(this, _options, void 0);
|
|
25
|
+
__privateAdd(this, _walletClient, void 0);
|
|
26
26
|
this.chainId = options.chainId;
|
|
27
|
-
|
|
27
|
+
__privateSet(this, _options, options);
|
|
28
28
|
}
|
|
29
29
|
async enable() {
|
|
30
|
-
if (
|
|
31
|
-
throw new
|
|
32
|
-
if (!
|
|
33
|
-
|
|
34
|
-
const address =
|
|
30
|
+
if (__privateGet(this, _options).flags?.failConnect)
|
|
31
|
+
throw new UserRejectedRequestError(new Error("Failed to connect."));
|
|
32
|
+
if (!__privateGet(this, _walletClient))
|
|
33
|
+
__privateSet(this, _walletClient, __privateGet(this, _options).walletClient);
|
|
34
|
+
const address = __privateGet(this, _walletClient).account.address;
|
|
35
35
|
this.events.emit("accountsChanged", [address]);
|
|
36
36
|
return [address];
|
|
37
37
|
}
|
|
38
38
|
async disconnect() {
|
|
39
39
|
this.events.emit("disconnect");
|
|
40
|
-
|
|
40
|
+
__privateSet(this, _walletClient, void 0);
|
|
41
41
|
}
|
|
42
42
|
async getAccounts() {
|
|
43
|
-
const address =
|
|
43
|
+
const address = __privateGet(this, _walletClient)?.account.address;
|
|
44
44
|
if (!address)
|
|
45
45
|
return [];
|
|
46
|
-
return [
|
|
46
|
+
return [getAddress(address)];
|
|
47
47
|
}
|
|
48
48
|
getWalletClient() {
|
|
49
|
-
const walletClient =
|
|
49
|
+
const walletClient = __privateGet(this, _walletClient);
|
|
50
50
|
if (!walletClient)
|
|
51
51
|
throw new Error("walletClient not found");
|
|
52
52
|
return walletClient;
|
|
53
53
|
}
|
|
54
54
|
async switchChain(chainId) {
|
|
55
|
-
if (
|
|
56
|
-
throw new
|
|
57
|
-
|
|
55
|
+
if (__privateGet(this, _options).flags?.failSwitchChain)
|
|
56
|
+
throw new UserRejectedRequestError(new Error("Failed to switch chain."));
|
|
57
|
+
__privateGet(this, _options).chainId = chainId;
|
|
58
58
|
this.chainId = chainId;
|
|
59
59
|
this.events.emit("chainChanged", chainId);
|
|
60
60
|
}
|
|
61
61
|
async switchWalletClient(walletClient) {
|
|
62
62
|
const address = walletClient.account.address;
|
|
63
|
-
|
|
63
|
+
__privateSet(this, _walletClient, walletClient);
|
|
64
64
|
this.events.emit("accountsChanged", [address]);
|
|
65
65
|
}
|
|
66
66
|
async watchAsset(_asset) {
|
|
67
67
|
return true;
|
|
68
68
|
}
|
|
69
69
|
async request({ method, params }) {
|
|
70
|
-
return
|
|
70
|
+
return __privateGet(this, _walletClient)?.transport.request({ method, params });
|
|
71
71
|
}
|
|
72
72
|
on(event, listener) {
|
|
73
73
|
this.events.on(event, listener);
|
|
@@ -86,7 +86,7 @@ _walletClient = new WeakMap();
|
|
|
86
86
|
|
|
87
87
|
// src/mock/connector.ts
|
|
88
88
|
var _provider, _switchChain, switchChain_fn;
|
|
89
|
-
var MockConnector = class extends
|
|
89
|
+
var MockConnector = class extends Connector {
|
|
90
90
|
constructor({
|
|
91
91
|
chains,
|
|
92
92
|
options
|
|
@@ -95,26 +95,26 @@ var MockConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
95
95
|
chains,
|
|
96
96
|
options: {
|
|
97
97
|
...options,
|
|
98
|
-
chainId:
|
|
98
|
+
chainId: options.chainId ?? chains?.[0]?.id
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
__privateAdd(this, _switchChain);
|
|
102
|
+
__publicField(this, "id", "mock");
|
|
103
|
+
__publicField(this, "name", "Mock");
|
|
104
|
+
__publicField(this, "ready", true);
|
|
105
|
+
__privateAdd(this, _provider, void 0);
|
|
106
|
+
__publicField(this, "onAccountsChanged", (accounts) => {
|
|
107
107
|
if (accounts.length === 0)
|
|
108
108
|
this.emit("disconnect");
|
|
109
109
|
else
|
|
110
|
-
this.emit("change", { account:
|
|
110
|
+
this.emit("change", { account: getAddress2(accounts[0]) });
|
|
111
111
|
});
|
|
112
|
-
|
|
113
|
-
const id =
|
|
112
|
+
__publicField(this, "onChainChanged", (chainId) => {
|
|
113
|
+
const id = normalizeChainId(chainId);
|
|
114
114
|
const unsupported = this.isChainUnsupported(id);
|
|
115
115
|
this.emit("change", { chain: { id, unsupported } });
|
|
116
116
|
});
|
|
117
|
-
|
|
117
|
+
__publicField(this, "onDisconnect", () => {
|
|
118
118
|
this.emit("disconnect");
|
|
119
119
|
});
|
|
120
120
|
}
|
|
@@ -125,12 +125,12 @@ var MockConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
125
125
|
provider.on("disconnect", this.onDisconnect);
|
|
126
126
|
this.emit("message", { type: "connecting" });
|
|
127
127
|
const accounts = await provider.enable();
|
|
128
|
-
const account =
|
|
129
|
-
const id =
|
|
128
|
+
const account = getAddress2(accounts[0]);
|
|
129
|
+
const id = normalizeChainId(provider.chainId);
|
|
130
130
|
const unsupported = this.isChainUnsupported(id);
|
|
131
131
|
const data = { account, chain: { id, unsupported }, provider };
|
|
132
|
-
if (!
|
|
133
|
-
this.switchChain =
|
|
132
|
+
if (!this.options.flags?.noSwitchChain)
|
|
133
|
+
this.switchChain = __privateMethod(this, _switchChain, switchChain_fn);
|
|
134
134
|
return new Promise(
|
|
135
135
|
(res) => setTimeout(() => res(data), 100)
|
|
136
136
|
);
|
|
@@ -148,19 +148,19 @@ var MockConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
148
148
|
const account = accounts[0];
|
|
149
149
|
if (!account)
|
|
150
150
|
throw new Error("Failed to get account");
|
|
151
|
-
return
|
|
151
|
+
return getAddress2(account);
|
|
152
152
|
}
|
|
153
153
|
async getChainId() {
|
|
154
154
|
const provider = await this.getProvider();
|
|
155
|
-
return
|
|
155
|
+
return normalizeChainId(provider.chainId);
|
|
156
156
|
}
|
|
157
157
|
async getProvider({ chainId } = {}) {
|
|
158
|
-
if (!
|
|
159
|
-
|
|
158
|
+
if (!__privateGet(this, _provider) || chainId)
|
|
159
|
+
__privateSet(this, _provider, new MockProvider({
|
|
160
160
|
...this.options,
|
|
161
|
-
chainId:
|
|
161
|
+
chainId: chainId ?? this.options.chainId ?? this.chains[0].id
|
|
162
162
|
}));
|
|
163
|
-
return
|
|
163
|
+
return __privateGet(this, _provider);
|
|
164
164
|
}
|
|
165
165
|
async getWalletClient() {
|
|
166
166
|
const provider = await this.getProvider();
|
|
@@ -170,8 +170,8 @@ var MockConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
170
170
|
try {
|
|
171
171
|
const provider = await this.getProvider();
|
|
172
172
|
const account = await provider.getAccounts();
|
|
173
|
-
return
|
|
174
|
-
} catch
|
|
173
|
+
return this.options.flags?.isAuthorized ?? !!account;
|
|
174
|
+
} catch {
|
|
175
175
|
return false;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
@@ -188,15 +188,15 @@ _switchChain = new WeakSet();
|
|
|
188
188
|
switchChain_fn = async function(chainId) {
|
|
189
189
|
const provider = await this.getProvider();
|
|
190
190
|
await provider.switchChain(chainId);
|
|
191
|
-
return
|
|
191
|
+
return this.chains.find((x) => x.id === chainId) ?? {
|
|
192
192
|
id: chainId,
|
|
193
193
|
name: `Chain ${chainId}`,
|
|
194
194
|
network: `${chainId}`,
|
|
195
195
|
nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
|
|
196
196
|
rpcUrls: { default: { http: [""] }, public: { http: [""] } }
|
|
197
|
-
}
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
export {
|
|
200
|
+
MockConnector,
|
|
201
|
+
MockProvider
|
|
198
202
|
};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
exports.MockConnector = MockConnector; exports.MockProvider = MockProvider;
|
package/dist/safe.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import {
|
|
2
|
+
ConnectorNotFoundError
|
|
3
|
+
} from "./chunk-ZCAPXGBX.js";
|
|
4
|
+
import {
|
|
5
|
+
normalizeChainId
|
|
6
|
+
} from "./chunk-OQILYQDO.js";
|
|
7
|
+
import {
|
|
8
|
+
Connector,
|
|
9
|
+
__privateAdd,
|
|
10
|
+
__privateGet,
|
|
11
|
+
__privateSet,
|
|
12
|
+
__publicField
|
|
13
|
+
} from "./chunk-QYMCVNHT.js";
|
|
14
14
|
|
|
15
15
|
// src/safe.ts
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
import { SafeAppProvider } from "@safe-global/safe-apps-provider";
|
|
17
|
+
import { default as SafeAppsSDK } from "@safe-global/safe-apps-sdk";
|
|
18
|
+
import { createWalletClient, custom, getAddress } from "viem";
|
|
19
19
|
var _provider, _sdk;
|
|
20
|
-
var SafeConnector = class extends
|
|
20
|
+
var SafeConnector = class extends Connector {
|
|
21
21
|
constructor({
|
|
22
22
|
chains,
|
|
23
23
|
options: options_
|
|
@@ -27,21 +27,21 @@ var SafeConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
27
27
|
...options_
|
|
28
28
|
};
|
|
29
29
|
super({ chains, options });
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let SDK =
|
|
37
|
-
if (typeof
|
|
38
|
-
SDK =
|
|
39
|
-
|
|
30
|
+
__publicField(this, "id", "safe");
|
|
31
|
+
__publicField(this, "name", "Safe");
|
|
32
|
+
__publicField(this, "ready", !(typeof window === "undefined") && window?.parent !== window);
|
|
33
|
+
__privateAdd(this, _provider, void 0);
|
|
34
|
+
__privateAdd(this, _sdk, void 0);
|
|
35
|
+
__publicField(this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
|
|
36
|
+
let SDK = SafeAppsSDK;
|
|
37
|
+
if (typeof SafeAppsSDK !== "function" && typeof SafeAppsSDK.default === "function")
|
|
38
|
+
SDK = SafeAppsSDK.default;
|
|
39
|
+
__privateSet(this, _sdk, new SDK(options));
|
|
40
40
|
}
|
|
41
41
|
async connect() {
|
|
42
42
|
const provider = await this.getProvider();
|
|
43
43
|
if (!provider)
|
|
44
|
-
throw new
|
|
44
|
+
throw new ConnectorNotFoundError();
|
|
45
45
|
if (provider.on) {
|
|
46
46
|
provider.on("accountsChanged", this.onAccountsChanged);
|
|
47
47
|
provider.on("chainChanged", this.onChainChanged);
|
|
@@ -51,7 +51,7 @@ var SafeConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
51
51
|
const account = await this.getAccount();
|
|
52
52
|
const id = await this.getChainId();
|
|
53
53
|
if (this.options.shimDisconnect)
|
|
54
|
-
|
|
54
|
+
this.storage?.setItem(this.shimDisconnectKey, true);
|
|
55
55
|
return {
|
|
56
56
|
account,
|
|
57
57
|
chain: { id, unsupported: this.isChainUnsupported(id) }
|
|
@@ -59,37 +59,37 @@ var SafeConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
59
59
|
}
|
|
60
60
|
async disconnect() {
|
|
61
61
|
const provider = await this.getProvider();
|
|
62
|
-
if (!
|
|
62
|
+
if (!provider?.removeListener)
|
|
63
63
|
return;
|
|
64
64
|
provider.removeListener("accountsChanged", this.onAccountsChanged);
|
|
65
65
|
provider.removeListener("chainChanged", this.onChainChanged);
|
|
66
66
|
provider.removeListener("disconnect", this.onDisconnect);
|
|
67
67
|
if (this.options.shimDisconnect)
|
|
68
|
-
|
|
68
|
+
this.storage?.removeItem(this.shimDisconnectKey);
|
|
69
69
|
}
|
|
70
70
|
async getAccount() {
|
|
71
71
|
const provider = await this.getProvider();
|
|
72
72
|
if (!provider)
|
|
73
|
-
throw new
|
|
73
|
+
throw new ConnectorNotFoundError();
|
|
74
74
|
const accounts = await provider.request({
|
|
75
75
|
method: "eth_accounts"
|
|
76
76
|
});
|
|
77
|
-
return
|
|
77
|
+
return getAddress(accounts[0]);
|
|
78
78
|
}
|
|
79
79
|
async getChainId() {
|
|
80
80
|
const provider = await this.getProvider();
|
|
81
81
|
if (!provider)
|
|
82
|
-
throw new
|
|
83
|
-
return
|
|
82
|
+
throw new ConnectorNotFoundError();
|
|
83
|
+
return normalizeChainId(provider.chainId);
|
|
84
84
|
}
|
|
85
85
|
async getProvider() {
|
|
86
|
-
if (!
|
|
87
|
-
const safe = await
|
|
86
|
+
if (!__privateGet(this, _provider)) {
|
|
87
|
+
const safe = await __privateGet(this, _sdk).safe.getInfo();
|
|
88
88
|
if (!safe)
|
|
89
89
|
throw new Error("Could not load Safe information");
|
|
90
|
-
|
|
90
|
+
__privateSet(this, _provider, new SafeAppProvider(safe, __privateGet(this, _sdk)));
|
|
91
91
|
}
|
|
92
|
-
return
|
|
92
|
+
return __privateGet(this, _provider);
|
|
93
93
|
}
|
|
94
94
|
async getWalletClient({
|
|
95
95
|
chainId
|
|
@@ -99,19 +99,19 @@ var SafeConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
99
99
|
const chain = this.chains.find((x) => x.id === chainId);
|
|
100
100
|
if (!provider)
|
|
101
101
|
throw new Error("provider is required.");
|
|
102
|
-
return
|
|
102
|
+
return createWalletClient({
|
|
103
103
|
account,
|
|
104
104
|
chain,
|
|
105
|
-
transport:
|
|
105
|
+
transport: custom(provider)
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
async isAuthorized() {
|
|
109
109
|
try {
|
|
110
|
-
if (this.options.shimDisconnect && !
|
|
110
|
+
if (this.options.shimDisconnect && !this.storage?.getItem(this.shimDisconnectKey))
|
|
111
111
|
return false;
|
|
112
112
|
const account = await this.getAccount();
|
|
113
113
|
return !!account;
|
|
114
|
-
} catch
|
|
114
|
+
} catch {
|
|
115
115
|
return false;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
@@ -125,6 +125,6 @@ var SafeConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
125
125
|
};
|
|
126
126
|
_provider = new WeakMap();
|
|
127
127
|
_sdk = new WeakMap();
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
export {
|
|
129
|
+
SafeConnector
|
|
130
|
+
};
|
package/dist/walletConnect.d.ts
CHANGED
|
@@ -57,9 +57,14 @@ type WalletConnectOptions = {
|
|
|
57
57
|
showQrModal?: EthereumProviderOptions['showQrModal'];
|
|
58
58
|
/**
|
|
59
59
|
* Options of QR code modal.
|
|
60
|
-
* @link https://docs.walletconnect.com/2.0/
|
|
60
|
+
* @link https://docs.walletconnect.com/2.0/web/walletConnectModal/modal/options
|
|
61
61
|
*/
|
|
62
62
|
qrModalOptions?: EthereumProviderOptions['qrModalOptions'];
|
|
63
|
+
/**
|
|
64
|
+
* Option to override default relay url.
|
|
65
|
+
* @link https://docs.walletconnect.com/2.0/web/providers/ethereum
|
|
66
|
+
*/
|
|
67
|
+
relayUrl?: string;
|
|
63
68
|
};
|
|
64
69
|
type ConnectConfig = {
|
|
65
70
|
/** Target chain to connect to. */
|