@wagmi/connectors 0.3.3 → 0.3.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/dist/{chunk-RAYRYMYO.js → chunk-QZI7EFXH.js} +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/injected.d.ts +1 -1
- package/dist/injected.js +1 -1
- package/dist/ledger.js +37 -2
- package/dist/metaMask.d.ts +1 -1
- package/dist/metaMask.js +1 -1
- package/dist/{types-372079e0.d.ts → types-87c188c3.d.ts} +3 -0
- package/dist/walletConnectLegacy.js +1 -1
- package/package.json +3 -2
|
@@ -29,6 +29,8 @@ function getInjectedName(ethereum) {
|
|
|
29
29
|
return "Apex Wallet";
|
|
30
30
|
if (provider.isAvalanche)
|
|
31
31
|
return "Core Wallet";
|
|
32
|
+
if (provider.isBackpack)
|
|
33
|
+
return "Backpack";
|
|
32
34
|
if (provider.isBifrost)
|
|
33
35
|
return "Bifrost Wallet";
|
|
34
36
|
if (provider.isBitKeep)
|
|
@@ -75,6 +77,8 @@ function getInjectedName(ethereum) {
|
|
|
75
77
|
return "MetaMask";
|
|
76
78
|
if (provider.isXDEFI)
|
|
77
79
|
return "XDEFI Wallet";
|
|
80
|
+
if (provider.isOkxWallet || provider.isOKExWallet)
|
|
81
|
+
return "OKX Wallet";
|
|
78
82
|
};
|
|
79
83
|
if (ethereum.providers?.length) {
|
|
80
84
|
const nameSet = /* @__PURE__ */ new Set();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { C as Connector, a as ConnectorData, b as ConnectorEvents } from './base-84a689bb.js';
|
|
2
|
-
export { E as Ethereum } from './types-
|
|
2
|
+
export { E as Ethereum } from './types-87c188c3.js';
|
|
3
3
|
import '@wagmi/core';
|
|
4
4
|
import '@wagmi/core/chains';
|
|
5
5
|
import 'eventemitter3';
|
package/dist/injected.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Address } from '@wagmi/core';
|
|
|
2
2
|
import { Chain } from '@wagmi/core/chains';
|
|
3
3
|
import { providers } from 'ethers';
|
|
4
4
|
import { C as Connector } from './base-84a689bb.js';
|
|
5
|
-
import { E as Ethereum } from './types-
|
|
5
|
+
import { E as Ethereum } from './types-87c188c3.js';
|
|
6
6
|
import 'eventemitter3';
|
|
7
7
|
import 'abitype';
|
|
8
8
|
|
package/dist/injected.js
CHANGED
package/dist/ledger.js
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
Connector,
|
|
3
3
|
__privateAdd,
|
|
4
4
|
__privateGet,
|
|
5
|
+
__privateMethod,
|
|
5
6
|
__privateSet,
|
|
6
7
|
__publicField
|
|
7
8
|
} from "./chunk-5NCTPR6C.js";
|
|
@@ -12,18 +13,20 @@ import {
|
|
|
12
13
|
loadConnectKit
|
|
13
14
|
} from "@ledgerhq/connect-kit-loader";
|
|
14
15
|
import {
|
|
16
|
+
SwitchChainError,
|
|
15
17
|
UserRejectedRequestError,
|
|
16
18
|
normalizeChainId
|
|
17
19
|
} from "@wagmi/core";
|
|
18
20
|
import { providers } from "ethers";
|
|
19
|
-
import { getAddress } from "ethers/lib/utils.js";
|
|
20
|
-
var _provider;
|
|
21
|
+
import { getAddress, hexValue } from "ethers/lib/utils.js";
|
|
22
|
+
var _provider, _switchChain, switchChain_fn;
|
|
21
23
|
var LedgerConnector = class extends Connector {
|
|
22
24
|
constructor({
|
|
23
25
|
chains,
|
|
24
26
|
options = { enableDebugLogs: false }
|
|
25
27
|
} = {}) {
|
|
26
28
|
super({ chains, options });
|
|
29
|
+
__privateAdd(this, _switchChain);
|
|
27
30
|
__publicField(this, "id", "ledger");
|
|
28
31
|
__publicField(this, "name", "Ledger");
|
|
29
32
|
__publicField(this, "ready", true);
|
|
@@ -58,6 +61,7 @@ var LedgerConnector = class extends Connector {
|
|
|
58
61
|
const account = getAddress(accounts[0]);
|
|
59
62
|
const id = await this.getChainId();
|
|
60
63
|
const unsupported = this.isChainUnsupported(id);
|
|
64
|
+
this.switchChain = __privateMethod(this, _switchChain, switchChain_fn);
|
|
61
65
|
return {
|
|
62
66
|
account,
|
|
63
67
|
chain: { id, unsupported },
|
|
@@ -147,6 +151,37 @@ var LedgerConnector = class extends Connector {
|
|
|
147
151
|
}
|
|
148
152
|
};
|
|
149
153
|
_provider = new WeakMap();
|
|
154
|
+
_switchChain = new WeakSet();
|
|
155
|
+
switchChain_fn = async function(chainId) {
|
|
156
|
+
const provider = await this.getProvider();
|
|
157
|
+
const id = hexValue(chainId);
|
|
158
|
+
try {
|
|
159
|
+
await Promise.race([
|
|
160
|
+
provider.request({
|
|
161
|
+
method: "wallet_switchEthereumChain",
|
|
162
|
+
params: [{ chainId: id }]
|
|
163
|
+
}),
|
|
164
|
+
new Promise(
|
|
165
|
+
(res) => this.on("change", ({ chain }) => {
|
|
166
|
+
if (chain?.id === chainId)
|
|
167
|
+
res(chainId);
|
|
168
|
+
})
|
|
169
|
+
)
|
|
170
|
+
]);
|
|
171
|
+
return this.chains.find((x) => x.id === chainId) ?? {
|
|
172
|
+
id: chainId,
|
|
173
|
+
name: `Chain ${id}`,
|
|
174
|
+
network: `${id}`,
|
|
175
|
+
nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
|
|
176
|
+
rpcUrls: { default: { http: [""] }, public: { http: [""] } }
|
|
177
|
+
};
|
|
178
|
+
} catch (error) {
|
|
179
|
+
const message = typeof error === "string" ? error : error?.message;
|
|
180
|
+
if (/user rejected request/i.test(message))
|
|
181
|
+
throw new UserRejectedRequestError(error);
|
|
182
|
+
throw new SwitchChainError(error);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
150
185
|
export {
|
|
151
186
|
LedgerConnector
|
|
152
187
|
};
|
package/dist/metaMask.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Chain } from '@wagmi/core/chains';
|
|
2
2
|
import { InjectedConnectorOptions, InjectedConnector } from './injected.js';
|
|
3
|
-
import { E as Ethereum } from './types-
|
|
3
|
+
import { E as Ethereum } from './types-87c188c3.js';
|
|
4
4
|
import '@wagmi/core';
|
|
5
5
|
import 'ethers';
|
|
6
6
|
import './base-84a689bb.js';
|
package/dist/metaMask.js
CHANGED
|
@@ -43,6 +43,7 @@ type WatchAssetParams = {
|
|
|
43
43
|
type InjectedProviderFlags = {
|
|
44
44
|
isApexWallet?: true;
|
|
45
45
|
isAvalanche?: true;
|
|
46
|
+
isBackpack?: true;
|
|
46
47
|
isBifrost?: true;
|
|
47
48
|
isBitKeep?: true;
|
|
48
49
|
isBitski?: true;
|
|
@@ -68,6 +69,8 @@ type InjectedProviderFlags = {
|
|
|
68
69
|
isTrustWallet?: true;
|
|
69
70
|
isHyperPay?: true;
|
|
70
71
|
isXDEFI?: true;
|
|
72
|
+
isOkxWallet?: true;
|
|
73
|
+
isOKExWallet?: true;
|
|
71
74
|
};
|
|
72
75
|
type InjectedProviders = InjectedProviderFlags & {
|
|
73
76
|
isMetaMask: true;
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "@wagmi/core";
|
|
17
17
|
import { providers } from "ethers";
|
|
18
18
|
import { getAddress, hexValue } from "ethers/lib/utils.js";
|
|
19
|
-
var switchChainAllowedRegex = /(imtoken|metamask|rainbow|trust wallet|uniswap wallet)/i;
|
|
19
|
+
var switchChainAllowedRegex = /(imtoken|metamask|rainbow|trust wallet|uniswap wallet|ledger)/i;
|
|
20
20
|
var _provider, _switchChain, switchChain_fn;
|
|
21
21
|
var WalletConnectLegacyConnector = class extends Connector {
|
|
22
22
|
constructor(config) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@wagmi/connectors",
|
|
3
3
|
"description": "A collection of connectors for wagmi",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.4",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@wagmi/core": ">=0.9.x",
|
|
8
8
|
"ethers": ">=5.5.1 <6",
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@coinbase/wallet-sdk": "^3.5.4",
|
|
21
21
|
"@ledgerhq/connect-kit-loader": "^1.0.1",
|
|
22
|
-
"@walletconnect/ethereum-provider": "^2.
|
|
22
|
+
"@walletconnect/ethereum-provider": "^2.5.1",
|
|
23
23
|
"@walletconnect/legacy-provider": "^2.0.0",
|
|
24
|
+
"@web3modal/standalone": "^2.2.1",
|
|
24
25
|
"@safe-global/safe-apps-provider": "^0.15.2",
|
|
25
26
|
"@safe-global/safe-apps-sdk": "^7.9.0",
|
|
26
27
|
"abitype": "^0.3.0",
|