@wagmi/connectors 2.3.0-cjs → 2.4.0
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/{base-0473abd3.d.ts → base-2dd7facf.d.ts} +1 -0
- package/dist/chunk-OQILYQDO.js +4 -4
- package/dist/chunk-QYMCVNHT.js +14 -14
- package/dist/{chunk-4BSCIAHY.js → chunk-Z2P63ELM.js} +75 -73
- package/dist/chunk-ZCAPXGBX.js +10 -10
- package/dist/coinbaseWallet.d.ts +1 -1
- package/dist/coinbaseWallet.js +58 -58
- package/dist/index.d.ts +4 -2
- package/dist/index.js +16 -12
- package/dist/injected.d.ts +1 -1
- package/dist/injected.js +9 -9
- package/dist/ledger.d.ts +33 -6
- package/dist/ledger.js +194 -126
- package/dist/metaMask.d.ts +1 -1
- package/dist/metaMask.js +37 -37
- package/dist/mock/index.d.ts +1 -1
- package/dist/mock/index.js +63 -63
- package/dist/safe.d.ts +1 -1
- package/dist/safe.js +46 -46
- package/dist/walletConnect.d.ts +1 -1
- package/dist/walletConnect.js +105 -105
- package/dist/walletConnectLegacy.d.ts +1 -1
- 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 +46 -6
- package/safe/package.json +1 -1
- package/walletConnect/package.json +1 -1
- package/walletConnectLegacy/package.json +1 -1
package/dist/coinbaseWallet.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import {
|
|
2
|
+
ChainNotConfiguredForConnectorError
|
|
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/coinbaseWallet.ts
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
import {
|
|
17
|
+
SwitchChainError,
|
|
18
|
+
UserRejectedRequestError,
|
|
19
|
+
createWalletClient,
|
|
20
|
+
custom,
|
|
21
|
+
getAddress,
|
|
22
|
+
numberToHex
|
|
23
|
+
} from "viem";
|
|
24
24
|
var _client, _provider;
|
|
25
|
-
var CoinbaseWalletConnector = class extends
|
|
25
|
+
var CoinbaseWalletConnector = class extends Connector {
|
|
26
26
|
constructor({ chains, options }) {
|
|
27
27
|
super({
|
|
28
28
|
chains,
|
|
@@ -31,23 +31,23 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
31
31
|
...options
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
__publicField(this, "id", "coinbaseWallet");
|
|
35
|
+
__publicField(this, "name", "Coinbase Wallet");
|
|
36
|
+
__publicField(this, "ready", true);
|
|
37
|
+
__privateAdd(this, _client, void 0);
|
|
38
|
+
__privateAdd(this, _provider, void 0);
|
|
39
|
+
__publicField(this, "onAccountsChanged", (accounts) => {
|
|
40
40
|
if (accounts.length === 0)
|
|
41
41
|
this.emit("disconnect");
|
|
42
42
|
else
|
|
43
|
-
this.emit("change", { account:
|
|
43
|
+
this.emit("change", { account: getAddress(accounts[0]) });
|
|
44
44
|
});
|
|
45
|
-
|
|
46
|
-
const id =
|
|
45
|
+
__publicField(this, "onChainChanged", (chainId) => {
|
|
46
|
+
const id = normalizeChainId(chainId);
|
|
47
47
|
const unsupported = this.isChainUnsupported(id);
|
|
48
48
|
this.emit("change", { chain: { id, unsupported } });
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
__publicField(this, "onDisconnect", () => {
|
|
51
51
|
this.emit("disconnect");
|
|
52
52
|
});
|
|
53
53
|
}
|
|
@@ -59,7 +59,7 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
59
59
|
provider.on("disconnect", this.onDisconnect);
|
|
60
60
|
this.emit("message", { type: "connecting" });
|
|
61
61
|
const accounts = await provider.enable();
|
|
62
|
-
const account =
|
|
62
|
+
const account = getAddress(accounts[0]);
|
|
63
63
|
let id = await this.getChainId();
|
|
64
64
|
let unsupported = this.isChainUnsupported(id);
|
|
65
65
|
if (chainId && id !== chainId) {
|
|
@@ -75,12 +75,12 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
75
75
|
if (/(user closed modal|accounts received is empty)/i.test(
|
|
76
76
|
error.message
|
|
77
77
|
))
|
|
78
|
-
throw new
|
|
78
|
+
throw new UserRejectedRequestError(error);
|
|
79
79
|
throw error;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
async disconnect() {
|
|
83
|
-
if (!
|
|
83
|
+
if (!__privateGet(this, _provider))
|
|
84
84
|
return;
|
|
85
85
|
const provider = await this.getProvider();
|
|
86
86
|
provider.removeListener("accountsChanged", this.onAccountsChanged);
|
|
@@ -94,32 +94,32 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
94
94
|
const accounts = await provider.request({
|
|
95
95
|
method: "eth_accounts"
|
|
96
96
|
});
|
|
97
|
-
return
|
|
97
|
+
return getAddress(accounts[0]);
|
|
98
98
|
}
|
|
99
99
|
async getChainId() {
|
|
100
100
|
const provider = await this.getProvider();
|
|
101
|
-
const chainId =
|
|
101
|
+
const chainId = normalizeChainId(provider.chainId);
|
|
102
102
|
return chainId;
|
|
103
103
|
}
|
|
104
104
|
async getProvider() {
|
|
105
|
-
if (!
|
|
106
|
-
let CoinbaseWalletSDK = (await
|
|
105
|
+
if (!__privateGet(this, _provider)) {
|
|
106
|
+
let CoinbaseWalletSDK = (await import("@coinbase/wallet-sdk")).default;
|
|
107
107
|
if (typeof CoinbaseWalletSDK !== "function" && typeof CoinbaseWalletSDK.default === "function")
|
|
108
108
|
CoinbaseWalletSDK = CoinbaseWalletSDK.default;
|
|
109
|
-
|
|
109
|
+
__privateSet(this, _client, new CoinbaseWalletSDK(this.options));
|
|
110
110
|
class WalletProvider {
|
|
111
111
|
}
|
|
112
112
|
class Client {
|
|
113
113
|
}
|
|
114
|
-
const walletExtensionChainId =
|
|
114
|
+
const walletExtensionChainId = __privateGet(this, _client).walletExtension?.getChainId();
|
|
115
115
|
const chain = this.chains.find(
|
|
116
116
|
(chain2) => this.options.chainId ? chain2.id === this.options.chainId : chain2.id === walletExtensionChainId
|
|
117
117
|
) || this.chains[0];
|
|
118
|
-
const chainId = this.options.chainId ||
|
|
119
|
-
const jsonRpcUrl = this.options.jsonRpcUrl ||
|
|
120
|
-
|
|
118
|
+
const chainId = this.options.chainId || chain?.id;
|
|
119
|
+
const jsonRpcUrl = this.options.jsonRpcUrl || chain?.rpcUrls.default.http[0];
|
|
120
|
+
__privateSet(this, _provider, __privateGet(this, _client).makeWeb3Provider(jsonRpcUrl, chainId));
|
|
121
121
|
}
|
|
122
|
-
return
|
|
122
|
+
return __privateGet(this, _provider);
|
|
123
123
|
}
|
|
124
124
|
async getWalletClient({ chainId } = {}) {
|
|
125
125
|
const [provider, account] = await Promise.all([
|
|
@@ -129,39 +129,39 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
129
129
|
const chain = this.chains.find((x) => x.id === chainId);
|
|
130
130
|
if (!provider)
|
|
131
131
|
throw new Error("provider is required.");
|
|
132
|
-
return
|
|
132
|
+
return createWalletClient({
|
|
133
133
|
account,
|
|
134
134
|
chain,
|
|
135
|
-
transport:
|
|
135
|
+
transport: custom(provider)
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
async isAuthorized() {
|
|
139
139
|
try {
|
|
140
140
|
const account = await this.getAccount();
|
|
141
141
|
return !!account;
|
|
142
|
-
} catch
|
|
142
|
+
} catch {
|
|
143
143
|
return false;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
async switchChain(chainId) {
|
|
147
147
|
const provider = await this.getProvider();
|
|
148
|
-
const id =
|
|
148
|
+
const id = numberToHex(chainId);
|
|
149
149
|
try {
|
|
150
150
|
await provider.request({
|
|
151
151
|
method: "wallet_switchEthereumChain",
|
|
152
152
|
params: [{ chainId: id }]
|
|
153
153
|
});
|
|
154
|
-
return
|
|
154
|
+
return this.chains.find((x) => x.id === chainId) ?? {
|
|
155
155
|
id: chainId,
|
|
156
156
|
name: `Chain ${id}`,
|
|
157
157
|
network: `${id}`,
|
|
158
158
|
nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
|
|
159
159
|
rpcUrls: { default: { http: [""] }, public: { http: [""] } }
|
|
160
|
-
}
|
|
160
|
+
};
|
|
161
161
|
} catch (error) {
|
|
162
162
|
const chain = this.chains.find((x) => x.id === chainId);
|
|
163
163
|
if (!chain)
|
|
164
|
-
throw new
|
|
164
|
+
throw new ChainNotConfiguredForConnectorError({
|
|
165
165
|
chainId,
|
|
166
166
|
connectorId: this.id
|
|
167
167
|
});
|
|
@@ -174,17 +174,17 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
174
174
|
chainId: id,
|
|
175
175
|
chainName: chain.name,
|
|
176
176
|
nativeCurrency: chain.nativeCurrency,
|
|
177
|
-
rpcUrls: [
|
|
177
|
+
rpcUrls: [chain.rpcUrls.public?.http[0] ?? ""],
|
|
178
178
|
blockExplorerUrls: this.getBlockExplorerUrls(chain)
|
|
179
179
|
}
|
|
180
180
|
]
|
|
181
181
|
});
|
|
182
182
|
return chain;
|
|
183
183
|
} catch (error2) {
|
|
184
|
-
throw new
|
|
184
|
+
throw new UserRejectedRequestError(error2);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
throw new
|
|
187
|
+
throw new SwitchChainError(error);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
async watchAsset({
|
|
@@ -210,6 +210,6 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
|
210
210
|
};
|
|
211
211
|
_client = new WeakMap();
|
|
212
212
|
_provider = new WeakMap();
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
export {
|
|
214
|
+
CoinbaseWalletConnector
|
|
215
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as Connector, a as ConnectorData, b as ConnectorEvents, W as WindowProvider } from './base-
|
|
1
|
+
export { C as Connector, a as ConnectorData, b as ConnectorEvents, W as WindowProvider } from './base-2dd7facf.js';
|
|
2
2
|
import '@wagmi/chains';
|
|
3
3
|
import 'eventemitter3';
|
|
4
4
|
import 'viem';
|
|
@@ -15,4 +15,6 @@ declare class ConnectorNotFoundError extends Error {
|
|
|
15
15
|
message: string;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
declare function normalizeChainId(chainId: string | number | bigint): number;
|
|
19
|
+
|
|
20
|
+
export { ChainNotConfiguredForConnectorError, ConnectorNotFoundError, normalizeChainId };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import {
|
|
2
|
+
ChainNotConfiguredForConnectorError,
|
|
3
|
+
ConnectorNotFoundError
|
|
4
|
+
} from "./chunk-ZCAPXGBX.js";
|
|
5
|
+
import {
|
|
6
|
+
normalizeChainId
|
|
7
|
+
} from "./chunk-OQILYQDO.js";
|
|
8
|
+
import {
|
|
9
|
+
Connector
|
|
10
|
+
} from "./chunk-QYMCVNHT.js";
|
|
11
|
+
export {
|
|
12
|
+
ChainNotConfiguredForConnectorError,
|
|
13
|
+
Connector,
|
|
14
|
+
ConnectorNotFoundError,
|
|
15
|
+
normalizeChainId
|
|
16
|
+
};
|
package/dist/injected.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { Address } from 'viem';
|
|
3
3
|
import { Chain } from '@wagmi/chains';
|
|
4
|
-
import { W as WindowProvider, C as Connector } from './base-
|
|
4
|
+
import { W as WindowProvider, C as Connector } from './base-2dd7facf.js';
|
|
5
5
|
import 'eventemitter3';
|
|
6
6
|
|
|
7
7
|
type InjectedConnectorOptions = {
|
package/dist/injected.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import {
|
|
2
|
+
InjectedConnector
|
|
3
|
+
} from "./chunk-Z2P63ELM.js";
|
|
4
|
+
import "./chunk-ZCAPXGBX.js";
|
|
5
|
+
import "./chunk-OQILYQDO.js";
|
|
6
|
+
import "./chunk-QYMCVNHT.js";
|
|
7
|
+
export {
|
|
8
|
+
InjectedConnector
|
|
9
|
+
};
|
package/dist/ledger.d.ts
CHANGED
|
@@ -1,27 +1,52 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { EthereumProvider } from '@ledgerhq/connect-kit-loader';
|
|
3
3
|
import { Chain } from '@wagmi/chains';
|
|
4
|
-
import {
|
|
4
|
+
import { EthereumProviderOptions } from '@walletconnect/ethereum-provider/dist/types/EthereumProvider';
|
|
5
|
+
import { C as Connector } from './base-2dd7facf.js';
|
|
5
6
|
import 'eventemitter3';
|
|
6
7
|
|
|
7
|
-
type
|
|
8
|
+
type LedgerConnectorWcV1Options = {
|
|
9
|
+
walletConnectVersion?: 1;
|
|
8
10
|
bridge?: string;
|
|
9
11
|
chainId?: number;
|
|
10
|
-
enableDebugLogs?: boolean;
|
|
11
12
|
rpc?: {
|
|
12
13
|
[chainId: number]: string;
|
|
13
14
|
};
|
|
14
15
|
};
|
|
16
|
+
type LedgerConnectorWcV2Options = {
|
|
17
|
+
walletConnectVersion?: 2;
|
|
18
|
+
projectId?: EthereumProviderOptions['projectId'];
|
|
19
|
+
requiredChains?: number[];
|
|
20
|
+
requiredMethods?: string[];
|
|
21
|
+
optionalMethods?: string[];
|
|
22
|
+
requiredEvents?: string[];
|
|
23
|
+
optionalEvents?: string[];
|
|
24
|
+
};
|
|
25
|
+
type LedgerConnectorOptions = {
|
|
26
|
+
enableDebugLogs?: boolean;
|
|
27
|
+
} & (LedgerConnectorWcV1Options | LedgerConnectorWcV2Options);
|
|
28
|
+
type ConnectConfig = {
|
|
29
|
+
/** Target chain to connect to. */
|
|
30
|
+
chainId?: number;
|
|
31
|
+
};
|
|
15
32
|
declare class LedgerConnector extends Connector<EthereumProvider, LedgerConnectorOptions> {
|
|
16
33
|
#private;
|
|
17
34
|
readonly id = "ledger";
|
|
18
35
|
readonly name = "Ledger";
|
|
19
36
|
readonly ready = true;
|
|
20
|
-
|
|
37
|
+
get walletConnectVersion(): 1 | 2;
|
|
38
|
+
constructor(config: {
|
|
21
39
|
chains?: Chain[];
|
|
22
|
-
options
|
|
40
|
+
options: LedgerConnectorOptions;
|
|
23
41
|
});
|
|
24
|
-
connect(): Promise<
|
|
42
|
+
connect({ chainId }?: ConnectConfig): Promise<{
|
|
43
|
+
account: `0x${string}`;
|
|
44
|
+
chain: {
|
|
45
|
+
id: number;
|
|
46
|
+
unsupported: boolean;
|
|
47
|
+
};
|
|
48
|
+
provider: EthereumProvider;
|
|
49
|
+
}>;
|
|
25
50
|
disconnect(): Promise<void>;
|
|
26
51
|
getAccount(): Promise<`0x${string}`>;
|
|
27
52
|
getChainId(): Promise<number>;
|
|
@@ -284,9 +309,11 @@ declare class LedgerConnector extends Connector<EthereumProvider, LedgerConnecto
|
|
|
284
309
|
};
|
|
285
310
|
}>;
|
|
286
311
|
isAuthorized(): Promise<boolean>;
|
|
312
|
+
switchChain(chainId: number): Promise<Chain>;
|
|
287
313
|
protected onAccountsChanged: (accounts: string[]) => void;
|
|
288
314
|
protected onChainChanged: (chainId: number | string) => void;
|
|
289
315
|
protected onDisconnect: () => void;
|
|
316
|
+
protected onConnect: () => void;
|
|
290
317
|
}
|
|
291
318
|
|
|
292
319
|
export { LedgerConnector };
|