@wagmi/connectors 3.1.1-cjs → 4.0.0-alpha.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/dist/esm/coinbaseWallet.js +141 -0
- package/dist/esm/coinbaseWallet.js.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.test-d.js +4 -0
- package/dist/esm/index.test-d.js.map +1 -0
- package/dist/esm/injected.js +372 -0
- package/dist/esm/injected.js.map +1 -0
- package/dist/esm/ledger.js +162 -0
- package/dist/esm/ledger.js.map +1 -0
- package/dist/esm/safe.js +88 -0
- package/dist/esm/safe.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/esm/walletConnect.js +280 -0
- package/dist/esm/walletConnect.js.map +1 -0
- package/dist/types/coinbaseWallet.d.ts +21 -0
- package/dist/types/coinbaseWallet.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.test-d.d.ts +2 -0
- package/dist/types/index.test-d.d.ts.map +1 -0
- package/dist/types/injected.d.ts +382 -0
- package/dist/types/injected.d.ts.map +1 -0
- package/dist/types/ledger.d.ts +18 -0
- package/dist/types/ledger.d.ts.map +1 -0
- package/dist/types/safe.d.ts +18 -0
- package/dist/types/safe.d.ts.map +1 -0
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/dist/types/walletConnect.d.ts +63 -0
- package/dist/types/walletConnect.d.ts.map +1 -0
- package/package.json +44 -82
- package/src/coinbaseWallet.ts +207 -0
- package/src/index.ts +17 -0
- package/src/injected.ts +535 -0
- package/src/ledger.ts +210 -0
- package/src/safe.ts +114 -0
- package/src/version.ts +1 -0
- package/src/walletConnect.ts +394 -0
- package/README.md +0 -46
- package/coinbaseWallet/package.json +0 -4
- package/dist/base-70e3a8a9.d.ts +0 -142
- package/dist/chunk-2UFLHRLT.js +0 -391
- package/dist/chunk-OQILYQDO.js +0 -15
- package/dist/chunk-UGBGYVBH.js +0 -22
- package/dist/chunk-W65LBPLT.js +0 -58
- package/dist/coinbaseWallet.d.ts +0 -62
- package/dist/coinbaseWallet.js +0 -216
- package/dist/index.d.ts +0 -20
- package/dist/index.js +0 -16
- package/dist/injected.d.ts +0 -64
- package/dist/injected.js +0 -9
- package/dist/ledger.d.ts +0 -69
- package/dist/ledger.js +0 -261
- package/dist/metaMask.d.ts +0 -33
- package/dist/metaMask.js +0 -144
- package/dist/mock/index.d.ts +0 -80
- package/dist/mock/index.js +0 -200
- package/dist/safe.d.ts +0 -53
- package/dist/safe.js +0 -129
- package/dist/walletConnect.d.ts +0 -109
- package/dist/walletConnect.js +0 -325
- package/dist/walletConnectLegacy.d.ts +0 -38
- package/dist/walletConnectLegacy.js +0 -179
- package/injected/package.json +0 -4
- package/ledger/package.json +0 -4
- package/metaMask/package.json +0 -4
- package/mock/package.json +0 -4
- package/safe/package.json +0 -4
- package/walletConnect/package.json +0 -4
- package/walletConnectLegacy/package.json +0 -4
package/dist/coinbaseWallet.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
var _chunkUGBGYVBHjs = require('./chunk-UGBGYVBH.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkOQILYQDOjs = require('./chunk-OQILYQDO.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkW65LBPLTjs = require('./chunk-W65LBPLT.js');
|
|
13
|
-
|
|
14
|
-
// src/coinbaseWallet.ts
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var _viem = require('viem');
|
|
23
|
-
var _client, _provider;
|
|
24
|
-
var CoinbaseWalletConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
25
|
-
constructor({ chains, options }) {
|
|
26
|
-
super({
|
|
27
|
-
chains,
|
|
28
|
-
options: {
|
|
29
|
-
reloadOnDisconnect: false,
|
|
30
|
-
...options
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
this.id = "coinbaseWallet";
|
|
34
|
-
this.name = "Coinbase Wallet";
|
|
35
|
-
this.ready = true;
|
|
36
|
-
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _client, void 0);
|
|
37
|
-
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _provider, void 0);
|
|
38
|
-
this.onAccountsChanged = (accounts) => {
|
|
39
|
-
if (accounts.length === 0)
|
|
40
|
-
this.emit("disconnect");
|
|
41
|
-
else
|
|
42
|
-
this.emit("change", { account: _viem.getAddress.call(void 0, accounts[0]) });
|
|
43
|
-
};
|
|
44
|
-
this.onChainChanged = (chainId) => {
|
|
45
|
-
const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
|
|
46
|
-
const unsupported = this.isChainUnsupported(id);
|
|
47
|
-
this.emit("change", { chain: { id, unsupported } });
|
|
48
|
-
};
|
|
49
|
-
this.onDisconnect = () => {
|
|
50
|
-
this.emit("disconnect");
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
async connect({ chainId } = {}) {
|
|
54
|
-
try {
|
|
55
|
-
const provider = await this.getProvider();
|
|
56
|
-
provider.on("accountsChanged", this.onAccountsChanged);
|
|
57
|
-
provider.on("chainChanged", this.onChainChanged);
|
|
58
|
-
provider.on("disconnect", this.onDisconnect);
|
|
59
|
-
this.emit("message", { type: "connecting" });
|
|
60
|
-
const accounts = await provider.enable();
|
|
61
|
-
const account = _viem.getAddress.call(void 0, accounts[0]);
|
|
62
|
-
let id = await this.getChainId();
|
|
63
|
-
let unsupported = this.isChainUnsupported(id);
|
|
64
|
-
if (chainId && id !== chainId) {
|
|
65
|
-
const chain = await this.switchChain(chainId);
|
|
66
|
-
id = chain.id;
|
|
67
|
-
unsupported = this.isChainUnsupported(id);
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
account,
|
|
71
|
-
chain: { id, unsupported }
|
|
72
|
-
};
|
|
73
|
-
} catch (error) {
|
|
74
|
-
if (/(user closed modal|accounts received is empty)/i.test(
|
|
75
|
-
error.message
|
|
76
|
-
))
|
|
77
|
-
throw new (0, _viem.UserRejectedRequestError)(error);
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async disconnect() {
|
|
82
|
-
if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider))
|
|
83
|
-
return;
|
|
84
|
-
const provider = await this.getProvider();
|
|
85
|
-
provider.removeListener("accountsChanged", this.onAccountsChanged);
|
|
86
|
-
provider.removeListener("chainChanged", this.onChainChanged);
|
|
87
|
-
provider.removeListener("disconnect", this.onDisconnect);
|
|
88
|
-
provider.disconnect();
|
|
89
|
-
provider.close();
|
|
90
|
-
}
|
|
91
|
-
async getAccount() {
|
|
92
|
-
const provider = await this.getProvider();
|
|
93
|
-
const accounts = await provider.request({
|
|
94
|
-
method: "eth_accounts"
|
|
95
|
-
});
|
|
96
|
-
return _viem.getAddress.call(void 0, accounts[0]);
|
|
97
|
-
}
|
|
98
|
-
async getChainId() {
|
|
99
|
-
const provider = await this.getProvider();
|
|
100
|
-
const chainId = _chunkOQILYQDOjs.normalizeChainId.call(void 0, provider.chainId);
|
|
101
|
-
return chainId;
|
|
102
|
-
}
|
|
103
|
-
async getProvider() {
|
|
104
|
-
if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider)) {
|
|
105
|
-
let CoinbaseWalletSDK = (await Promise.resolve().then(() => _interopRequireWildcard(require("@coinbase/wallet-sdk")))).default;
|
|
106
|
-
if (typeof CoinbaseWalletSDK !== "function" && typeof CoinbaseWalletSDK.default === "function")
|
|
107
|
-
CoinbaseWalletSDK = CoinbaseWalletSDK.default;
|
|
108
|
-
_chunkW65LBPLTjs.__privateSet.call(void 0, this, _client, new CoinbaseWalletSDK(this.options));
|
|
109
|
-
class WalletProvider {
|
|
110
|
-
}
|
|
111
|
-
class Client {
|
|
112
|
-
}
|
|
113
|
-
const walletExtensionChainId = _optionalChain([_chunkW65LBPLTjs.__privateGet.call(void 0, this, _client), 'access', _ => _.walletExtension, 'optionalAccess', _2 => _2.getChainId, 'call', _3 => _3()]);
|
|
114
|
-
const chain = this.chains.find(
|
|
115
|
-
(chain2) => this.options.chainId ? chain2.id === this.options.chainId : chain2.id === walletExtensionChainId
|
|
116
|
-
) || this.chains[0];
|
|
117
|
-
const chainId = this.options.chainId || _optionalChain([chain, 'optionalAccess', _4 => _4.id]);
|
|
118
|
-
const jsonRpcUrl = this.options.jsonRpcUrl || _optionalChain([chain, 'optionalAccess', _5 => _5.rpcUrls, 'access', _6 => _6.default, 'access', _7 => _7.http, 'access', _8 => _8[0]]);
|
|
119
|
-
_chunkW65LBPLTjs.__privateSet.call(void 0, this, _provider, _chunkW65LBPLTjs.__privateGet.call(void 0, this, _client).makeWeb3Provider(jsonRpcUrl, chainId));
|
|
120
|
-
}
|
|
121
|
-
return _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider);
|
|
122
|
-
}
|
|
123
|
-
async getWalletClient({
|
|
124
|
-
chainId
|
|
125
|
-
} = {}) {
|
|
126
|
-
const [provider, account] = await Promise.all([
|
|
127
|
-
this.getProvider(),
|
|
128
|
-
this.getAccount()
|
|
129
|
-
]);
|
|
130
|
-
const chain = this.chains.find((x) => x.id === chainId);
|
|
131
|
-
if (!provider)
|
|
132
|
-
throw new Error("provider is required.");
|
|
133
|
-
return _viem.createWalletClient.call(void 0, {
|
|
134
|
-
account,
|
|
135
|
-
chain,
|
|
136
|
-
transport: _viem.custom.call(void 0, provider)
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
async isAuthorized() {
|
|
140
|
-
try {
|
|
141
|
-
const account = await this.getAccount();
|
|
142
|
-
return !!account;
|
|
143
|
-
} catch (e) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
async switchChain(chainId) {
|
|
148
|
-
const provider = await this.getProvider();
|
|
149
|
-
const id = _viem.numberToHex.call(void 0, chainId);
|
|
150
|
-
try {
|
|
151
|
-
await provider.request({
|
|
152
|
-
method: "wallet_switchEthereumChain",
|
|
153
|
-
params: [{ chainId: id }]
|
|
154
|
-
});
|
|
155
|
-
return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
|
|
156
|
-
id: chainId,
|
|
157
|
-
name: `Chain ${id}`,
|
|
158
|
-
network: `${id}`,
|
|
159
|
-
nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
|
|
160
|
-
rpcUrls: { default: { http: [""] }, public: { http: [""] } }
|
|
161
|
-
}));
|
|
162
|
-
} catch (error) {
|
|
163
|
-
const chain = this.chains.find((x) => x.id === chainId);
|
|
164
|
-
if (!chain)
|
|
165
|
-
throw new (0, _chunkUGBGYVBHjs.ChainNotConfiguredForConnectorError)({
|
|
166
|
-
chainId,
|
|
167
|
-
connectorId: this.id
|
|
168
|
-
});
|
|
169
|
-
if (error.code === 4902) {
|
|
170
|
-
try {
|
|
171
|
-
await provider.request({
|
|
172
|
-
method: "wallet_addEthereumChain",
|
|
173
|
-
params: [
|
|
174
|
-
{
|
|
175
|
-
chainId: id,
|
|
176
|
-
chainName: chain.name,
|
|
177
|
-
nativeCurrency: chain.nativeCurrency,
|
|
178
|
-
rpcUrls: [_nullishCoalesce(_optionalChain([chain, 'access', _9 => _9.rpcUrls, 'access', _10 => _10.public, 'optionalAccess', _11 => _11.http, 'access', _12 => _12[0]]), () => ( ""))],
|
|
179
|
-
blockExplorerUrls: this.getBlockExplorerUrls(chain)
|
|
180
|
-
}
|
|
181
|
-
]
|
|
182
|
-
});
|
|
183
|
-
return chain;
|
|
184
|
-
} catch (error2) {
|
|
185
|
-
throw new (0, _viem.UserRejectedRequestError)(error2);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
throw new (0, _viem.SwitchChainError)(error);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
async watchAsset({
|
|
192
|
-
address,
|
|
193
|
-
decimals = 18,
|
|
194
|
-
image,
|
|
195
|
-
symbol
|
|
196
|
-
}) {
|
|
197
|
-
const provider = await this.getProvider();
|
|
198
|
-
return provider.request({
|
|
199
|
-
method: "wallet_watchAsset",
|
|
200
|
-
params: {
|
|
201
|
-
type: "ERC20",
|
|
202
|
-
options: {
|
|
203
|
-
address,
|
|
204
|
-
decimals,
|
|
205
|
-
image,
|
|
206
|
-
symbol
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
_client = new WeakMap();
|
|
213
|
-
_provider = new WeakMap();
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
exports.CoinbaseWalletConnector = CoinbaseWalletConnector;
|
package/dist/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export { C as Connector, a as ConnectorData, b as ConnectorEvents, W as WindowProvider } from './base-70e3a8a9.js';
|
|
2
|
-
import 'eventemitter3';
|
|
3
|
-
import 'viem';
|
|
4
|
-
import 'viem/chains';
|
|
5
|
-
|
|
6
|
-
declare class ChainNotConfiguredForConnectorError extends Error {
|
|
7
|
-
name: string;
|
|
8
|
-
constructor({ chainId, connectorId, }: {
|
|
9
|
-
chainId: number;
|
|
10
|
-
connectorId?: string;
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
declare class ConnectorNotFoundError extends Error {
|
|
14
|
-
name: string;
|
|
15
|
-
message: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
declare function normalizeChainId(chainId: string | number | bigint): number;
|
|
19
|
-
|
|
20
|
-
export { ChainNotConfiguredForConnectorError, ConnectorNotFoundError, normalizeChainId };
|
package/dist/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkUGBGYVBHjs = require('./chunk-UGBGYVBH.js');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _chunkOQILYQDOjs = require('./chunk-OQILYQDO.js');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunkW65LBPLTjs = require('./chunk-W65LBPLT.js');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.ChainNotConfiguredForConnectorError = _chunkUGBGYVBHjs.ChainNotConfiguredForConnectorError; exports.Connector = _chunkW65LBPLTjs.Connector; exports.ConnectorNotFoundError = _chunkUGBGYVBHjs.ConnectorNotFoundError; exports.normalizeChainId = _chunkOQILYQDOjs.normalizeChainId;
|
package/dist/injected.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Address } from 'viem';
|
|
2
|
-
import { Chain } from 'viem/chains';
|
|
3
|
-
import { W as WindowProvider, C as Connector, c as WalletClient } from './base-70e3a8a9.js';
|
|
4
|
-
import 'eventemitter3';
|
|
5
|
-
|
|
6
|
-
type InjectedConnectorOptions = {
|
|
7
|
-
/** Name of connector */
|
|
8
|
-
name?: string | ((detectedName: string | string[]) => string);
|
|
9
|
-
/**
|
|
10
|
-
* [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) Ethereum Provider to target
|
|
11
|
-
*
|
|
12
|
-
* @default
|
|
13
|
-
* () => typeof window !== 'undefined' ? window.ethereum : undefined
|
|
14
|
-
*/
|
|
15
|
-
getProvider?: () => WindowProvider | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* MetaMask and other injected providers do not support programmatic disconnect.
|
|
18
|
-
* 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.
|
|
19
|
-
* @default true
|
|
20
|
-
*/
|
|
21
|
-
shimDisconnect?: boolean;
|
|
22
|
-
};
|
|
23
|
-
type ConnectorOptions = InjectedConnectorOptions & Required<Pick<InjectedConnectorOptions, 'getProvider'>>;
|
|
24
|
-
declare class InjectedConnector extends Connector<WindowProvider | undefined, ConnectorOptions> {
|
|
25
|
-
#private;
|
|
26
|
-
readonly id: string;
|
|
27
|
-
readonly name: string;
|
|
28
|
-
readonly ready: boolean;
|
|
29
|
-
protected shimDisconnectKey: string;
|
|
30
|
-
constructor({ chains, options: options_, }?: {
|
|
31
|
-
chains?: Chain[];
|
|
32
|
-
options?: InjectedConnectorOptions;
|
|
33
|
-
});
|
|
34
|
-
connect({ chainId }?: {
|
|
35
|
-
chainId?: number;
|
|
36
|
-
}): Promise<{
|
|
37
|
-
account: `0x${string}`;
|
|
38
|
-
chain: {
|
|
39
|
-
id: number;
|
|
40
|
-
unsupported: boolean;
|
|
41
|
-
};
|
|
42
|
-
}>;
|
|
43
|
-
disconnect(): Promise<void>;
|
|
44
|
-
getAccount(): Promise<`0x${string}`>;
|
|
45
|
-
getChainId(): Promise<number>;
|
|
46
|
-
getProvider(): Promise<WindowProvider | undefined>;
|
|
47
|
-
getWalletClient({ chainId, }?: {
|
|
48
|
-
chainId?: number;
|
|
49
|
-
}): Promise<WalletClient>;
|
|
50
|
-
isAuthorized(): Promise<boolean>;
|
|
51
|
-
switchChain(chainId: number): Promise<Chain>;
|
|
52
|
-
watchAsset({ address, decimals, image, symbol, }: {
|
|
53
|
-
address: Address;
|
|
54
|
-
decimals?: number;
|
|
55
|
-
image?: string;
|
|
56
|
-
symbol: string;
|
|
57
|
-
}): Promise<boolean>;
|
|
58
|
-
protected onAccountsChanged: (accounts: string[]) => void;
|
|
59
|
-
protected onChainChanged: (chainId: number | string) => void;
|
|
60
|
-
protected onDisconnect: (error: Error) => Promise<void>;
|
|
61
|
-
protected isUserRejectedRequestError(error: unknown): boolean;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { InjectedConnector, InjectedConnectorOptions };
|
package/dist/injected.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunk2UFLHRLTjs = require('./chunk-2UFLHRLT.js');
|
|
4
|
-
require('./chunk-UGBGYVBH.js');
|
|
5
|
-
require('./chunk-OQILYQDO.js');
|
|
6
|
-
require('./chunk-W65LBPLT.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.InjectedConnector = _chunk2UFLHRLTjs.InjectedConnector;
|
package/dist/ledger.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { EthereumProvider } from '@ledgerhq/connect-kit-loader';
|
|
2
|
-
import { EthereumProviderOptions } from '@walletconnect/ethereum-provider/dist/types/EthereumProvider';
|
|
3
|
-
import { Chain } from 'viem/chains';
|
|
4
|
-
import { C as Connector, c as WalletClient } from './base-70e3a8a9.js';
|
|
5
|
-
import 'eventemitter3';
|
|
6
|
-
import 'viem';
|
|
7
|
-
|
|
8
|
-
type LedgerConnectorWcV1Options = {
|
|
9
|
-
walletConnectVersion?: 1;
|
|
10
|
-
bridge?: string;
|
|
11
|
-
chainId?: number;
|
|
12
|
-
projectId?: never;
|
|
13
|
-
rpc?: {
|
|
14
|
-
[chainId: number]: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
type LedgerConnectorWcV2Options = {
|
|
18
|
-
walletConnectVersion?: 2;
|
|
19
|
-
projectId?: EthereumProviderOptions['projectId'];
|
|
20
|
-
requiredChains?: number[];
|
|
21
|
-
requiredMethods?: string[];
|
|
22
|
-
optionalMethods?: string[];
|
|
23
|
-
requiredEvents?: string[];
|
|
24
|
-
optionalEvents?: string[];
|
|
25
|
-
};
|
|
26
|
-
type LedgerConnectorOptions = {
|
|
27
|
-
enableDebugLogs?: boolean;
|
|
28
|
-
} & (LedgerConnectorWcV1Options | LedgerConnectorWcV2Options);
|
|
29
|
-
type ConnectConfig = {
|
|
30
|
-
/** Target chain to connect to. */
|
|
31
|
-
chainId?: number;
|
|
32
|
-
};
|
|
33
|
-
declare class LedgerConnector extends Connector<EthereumProvider, LedgerConnectorOptions> {
|
|
34
|
-
#private;
|
|
35
|
-
readonly id = "ledger";
|
|
36
|
-
readonly name = "Ledger";
|
|
37
|
-
readonly ready = true;
|
|
38
|
-
get walletConnectVersion(): 1 | 2;
|
|
39
|
-
constructor(config: {
|
|
40
|
-
chains?: Chain[];
|
|
41
|
-
options: LedgerConnectorOptions;
|
|
42
|
-
});
|
|
43
|
-
connect({ chainId }?: ConnectConfig): Promise<{
|
|
44
|
-
account: `0x${string}`;
|
|
45
|
-
chain: {
|
|
46
|
-
id: number;
|
|
47
|
-
unsupported: boolean;
|
|
48
|
-
};
|
|
49
|
-
provider: EthereumProvider;
|
|
50
|
-
}>;
|
|
51
|
-
disconnect(): Promise<void>;
|
|
52
|
-
getAccount(): Promise<`0x${string}`>;
|
|
53
|
-
getChainId(): Promise<number>;
|
|
54
|
-
getProvider({ chainId, create }?: {
|
|
55
|
-
chainId?: number;
|
|
56
|
-
create?: boolean;
|
|
57
|
-
}): Promise<EthereumProvider>;
|
|
58
|
-
getWalletClient({ chainId, }?: {
|
|
59
|
-
chainId?: number;
|
|
60
|
-
}): Promise<WalletClient>;
|
|
61
|
-
isAuthorized(): Promise<boolean>;
|
|
62
|
-
switchChain(chainId: number): Promise<Chain>;
|
|
63
|
-
protected onAccountsChanged: (accounts: string[]) => void;
|
|
64
|
-
protected onChainChanged: (chainId: number | string) => void;
|
|
65
|
-
protected onDisconnect: () => void;
|
|
66
|
-
protected onConnect: () => void;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export { LedgerConnector };
|
package/dist/ledger.js
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
var _chunkOQILYQDOjs = require('./chunk-OQILYQDO.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunkW65LBPLTjs = require('./chunk-W65LBPLT.js');
|
|
11
|
-
|
|
12
|
-
// src/ledger.ts
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _connectkitloader = require('@ledgerhq/connect-kit-loader');
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var _viem = require('viem');
|
|
25
|
-
var _provider, _initProviderPromise, _isV1, _createProvider, createProvider_fn, _initProvider, initProvider_fn, _setupListeners, setupListeners_fn, _removeListeners, removeListeners_fn;
|
|
26
|
-
var LedgerConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
27
|
-
constructor(config) {
|
|
28
|
-
super({
|
|
29
|
-
...config,
|
|
30
|
-
options: { ...config.options }
|
|
31
|
-
});
|
|
32
|
-
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _createProvider);
|
|
33
|
-
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _initProvider);
|
|
34
|
-
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _setupListeners);
|
|
35
|
-
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _removeListeners);
|
|
36
|
-
this.id = "ledger";
|
|
37
|
-
this.name = "Ledger";
|
|
38
|
-
this.ready = true;
|
|
39
|
-
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _provider, void 0);
|
|
40
|
-
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _initProviderPromise, void 0);
|
|
41
|
-
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _isV1, void 0);
|
|
42
|
-
this.onAccountsChanged = (accounts) => {
|
|
43
|
-
if (accounts.length === 0)
|
|
44
|
-
this.emit("disconnect");
|
|
45
|
-
else
|
|
46
|
-
this.emit("change", { account: _viem.getAddress.call(void 0, accounts[0]) });
|
|
47
|
-
};
|
|
48
|
-
this.onChainChanged = (chainId) => {
|
|
49
|
-
const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
|
|
50
|
-
const unsupported = this.isChainUnsupported(id);
|
|
51
|
-
this.emit("change", { chain: { id, unsupported } });
|
|
52
|
-
};
|
|
53
|
-
this.onDisconnect = () => {
|
|
54
|
-
this.emit("disconnect");
|
|
55
|
-
};
|
|
56
|
-
this.onConnect = () => {
|
|
57
|
-
this.emit("connect", {});
|
|
58
|
-
};
|
|
59
|
-
_chunkW65LBPLTjs.__privateSet.call(void 0, this, _isV1, this.walletConnectVersion === 1);
|
|
60
|
-
}
|
|
61
|
-
get walletConnectVersion() {
|
|
62
|
-
if (this.options.walletConnectVersion)
|
|
63
|
-
return this.options.walletConnectVersion;
|
|
64
|
-
else if (this.options.projectId)
|
|
65
|
-
return 2;
|
|
66
|
-
return 1;
|
|
67
|
-
}
|
|
68
|
-
async connect({ chainId } = {}) {
|
|
69
|
-
try {
|
|
70
|
-
const provider = await this.getProvider({ create: true });
|
|
71
|
-
_chunkW65LBPLTjs.__privateMethod.call(void 0, this, _setupListeners, setupListeners_fn).call(this);
|
|
72
|
-
if (!provider.session) {
|
|
73
|
-
this.emit("message", { type: "connecting" });
|
|
74
|
-
await provider.request({
|
|
75
|
-
method: "eth_requestAccounts"
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
const account = await this.getAccount();
|
|
79
|
-
let id = await this.getChainId();
|
|
80
|
-
let unsupported = this.isChainUnsupported(id);
|
|
81
|
-
if (chainId && id !== chainId) {
|
|
82
|
-
const chain = await this.switchChain(chainId);
|
|
83
|
-
id = chain.id;
|
|
84
|
-
unsupported = this.isChainUnsupported(id);
|
|
85
|
-
}
|
|
86
|
-
return {
|
|
87
|
-
account,
|
|
88
|
-
chain: { id, unsupported },
|
|
89
|
-
provider
|
|
90
|
-
};
|
|
91
|
-
} catch (error) {
|
|
92
|
-
if (/user rejected/i.test(_optionalChain([error, 'optionalAccess', _ => _.message]))) {
|
|
93
|
-
throw new (0, _viem.UserRejectedRequestError)(error);
|
|
94
|
-
}
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
async disconnect() {
|
|
99
|
-
const provider = await this.getProvider();
|
|
100
|
-
try {
|
|
101
|
-
if (_optionalChain([provider, 'optionalAccess', _2 => _2.disconnect]))
|
|
102
|
-
await provider.disconnect();
|
|
103
|
-
} catch (error) {
|
|
104
|
-
if (!/No matching key/i.test(error.message))
|
|
105
|
-
throw error;
|
|
106
|
-
} finally {
|
|
107
|
-
_chunkW65LBPLTjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
|
|
108
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _isV1) && typeof localStorage !== "undefined" && localStorage.removeItem("walletconnect");
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
async getAccount() {
|
|
112
|
-
const provider = await this.getProvider();
|
|
113
|
-
const accounts = await provider.request({
|
|
114
|
-
method: "eth_accounts"
|
|
115
|
-
});
|
|
116
|
-
const account = _viem.getAddress.call(void 0, accounts[0]);
|
|
117
|
-
return account;
|
|
118
|
-
}
|
|
119
|
-
async getChainId() {
|
|
120
|
-
const provider = await this.getProvider();
|
|
121
|
-
const chainId = await provider.request({
|
|
122
|
-
method: "eth_chainId"
|
|
123
|
-
});
|
|
124
|
-
return _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
|
|
125
|
-
}
|
|
126
|
-
async getProvider({ chainId, create } = {
|
|
127
|
-
create: false
|
|
128
|
-
}) {
|
|
129
|
-
if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider) || _chunkW65LBPLTjs.__privateGet.call(void 0, this, _isV1) && create) {
|
|
130
|
-
await _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _createProvider, createProvider_fn).call(this);
|
|
131
|
-
}
|
|
132
|
-
if (chainId)
|
|
133
|
-
await this.switchChain(chainId);
|
|
134
|
-
return _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider);
|
|
135
|
-
}
|
|
136
|
-
async getWalletClient({
|
|
137
|
-
chainId
|
|
138
|
-
} = {}) {
|
|
139
|
-
const [provider, account] = await Promise.all([
|
|
140
|
-
this.getProvider({ chainId }),
|
|
141
|
-
this.getAccount()
|
|
142
|
-
]);
|
|
143
|
-
const chain = this.chains.find((x) => x.id === chainId);
|
|
144
|
-
if (!provider)
|
|
145
|
-
throw new Error("provider is required.");
|
|
146
|
-
return _viem.createWalletClient.call(void 0, { account, chain, transport: _viem.custom.call(void 0, provider) });
|
|
147
|
-
}
|
|
148
|
-
async isAuthorized() {
|
|
149
|
-
try {
|
|
150
|
-
const account = await this.getAccount();
|
|
151
|
-
return !!account;
|
|
152
|
-
} catch (e) {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
async switchChain(chainId) {
|
|
157
|
-
const chain = this.chains.find((chain2) => chain2.id === chainId);
|
|
158
|
-
if (!chain)
|
|
159
|
-
throw new (0, _viem.SwitchChainError)(new Error("chain not found on connector."));
|
|
160
|
-
try {
|
|
161
|
-
const provider = await this.getProvider();
|
|
162
|
-
await provider.request({
|
|
163
|
-
method: "wallet_switchEthereumChain",
|
|
164
|
-
params: [{ chainId: _viem.numberToHex.call(void 0, chainId) }]
|
|
165
|
-
});
|
|
166
|
-
return chain;
|
|
167
|
-
} catch (error) {
|
|
168
|
-
const message = typeof error === "string" ? error : _optionalChain([error, 'optionalAccess', _3 => _3.message]);
|
|
169
|
-
if (/user rejected request/i.test(message)) {
|
|
170
|
-
throw new (0, _viem.UserRejectedRequestError)(error);
|
|
171
|
-
}
|
|
172
|
-
throw new (0, _viem.SwitchChainError)(error);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
_provider = new WeakMap();
|
|
177
|
-
_initProviderPromise = new WeakMap();
|
|
178
|
-
_isV1 = new WeakMap();
|
|
179
|
-
_createProvider = new WeakSet();
|
|
180
|
-
createProvider_fn = async function() {
|
|
181
|
-
if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _initProviderPromise) && typeof window !== "undefined") {
|
|
182
|
-
_chunkW65LBPLTjs.__privateSet.call(void 0, this, _initProviderPromise, _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _initProvider, initProvider_fn).call(this));
|
|
183
|
-
}
|
|
184
|
-
return _chunkW65LBPLTjs.__privateGet.call(void 0, this, _initProviderPromise);
|
|
185
|
-
};
|
|
186
|
-
_initProvider = new WeakSet();
|
|
187
|
-
initProvider_fn = async function() {
|
|
188
|
-
const connectKit = await _connectkitloader.loadConnectKit.call(void 0, );
|
|
189
|
-
if (this.options.enableDebugLogs) {
|
|
190
|
-
connectKit.enableDebugLogs();
|
|
191
|
-
}
|
|
192
|
-
let checkSupportOptions;
|
|
193
|
-
if (_chunkW65LBPLTjs.__privateGet.call(void 0, this, _isV1)) {
|
|
194
|
-
const { chainId, bridge } = this.options;
|
|
195
|
-
checkSupportOptions = {
|
|
196
|
-
providerType: _connectkitloader.SupportedProviders.Ethereum,
|
|
197
|
-
walletConnectVersion: 1,
|
|
198
|
-
chainId,
|
|
199
|
-
bridge,
|
|
200
|
-
rpc: Object.fromEntries(
|
|
201
|
-
this.chains.map((chain) => [
|
|
202
|
-
chain.id,
|
|
203
|
-
chain.rpcUrls.default.http[0]
|
|
204
|
-
])
|
|
205
|
-
)
|
|
206
|
-
};
|
|
207
|
-
} else {
|
|
208
|
-
const {
|
|
209
|
-
projectId,
|
|
210
|
-
requiredChains,
|
|
211
|
-
requiredMethods,
|
|
212
|
-
optionalMethods,
|
|
213
|
-
requiredEvents,
|
|
214
|
-
optionalEvents
|
|
215
|
-
} = this.options;
|
|
216
|
-
const optionalChains = this.chains.map(({ id }) => id);
|
|
217
|
-
checkSupportOptions = {
|
|
218
|
-
providerType: _connectkitloader.SupportedProviders.Ethereum,
|
|
219
|
-
walletConnectVersion: 2,
|
|
220
|
-
projectId,
|
|
221
|
-
chains: requiredChains,
|
|
222
|
-
optionalChains,
|
|
223
|
-
methods: requiredMethods,
|
|
224
|
-
optionalMethods,
|
|
225
|
-
events: requiredEvents,
|
|
226
|
-
optionalEvents,
|
|
227
|
-
rpcMap: Object.fromEntries(
|
|
228
|
-
this.chains.map((chain) => [
|
|
229
|
-
chain.id,
|
|
230
|
-
chain.rpcUrls.default.http[0]
|
|
231
|
-
])
|
|
232
|
-
)
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
connectKit.checkSupport(checkSupportOptions);
|
|
236
|
-
_chunkW65LBPLTjs.__privateSet.call(void 0, this, _provider, await connectKit.getProvider());
|
|
237
|
-
};
|
|
238
|
-
_setupListeners = new WeakSet();
|
|
239
|
-
setupListeners_fn = function() {
|
|
240
|
-
if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider))
|
|
241
|
-
return;
|
|
242
|
-
_chunkW65LBPLTjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
|
|
243
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("accountsChanged", this.onAccountsChanged);
|
|
244
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("chainChanged", this.onChainChanged);
|
|
245
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("disconnect", this.onDisconnect);
|
|
246
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("session_delete", this.onDisconnect);
|
|
247
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("connect", this.onConnect);
|
|
248
|
-
};
|
|
249
|
-
_removeListeners = new WeakSet();
|
|
250
|
-
removeListeners_fn = function() {
|
|
251
|
-
if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider))
|
|
252
|
-
return;
|
|
253
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
|
|
254
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("chainChanged", this.onChainChanged);
|
|
255
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("disconnect", this.onDisconnect);
|
|
256
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("session_delete", this.onDisconnect);
|
|
257
|
-
_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("connect", this.onConnect);
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
exports.LedgerConnector = LedgerConnector;
|
package/dist/metaMask.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Chain } from 'viem/chains';
|
|
2
|
-
import { InjectedConnectorOptions, InjectedConnector } from './injected.js';
|
|
3
|
-
import { W as WindowProvider } from './base-70e3a8a9.js';
|
|
4
|
-
import 'viem';
|
|
5
|
-
import 'eventemitter3';
|
|
6
|
-
|
|
7
|
-
type MetaMaskConnectorOptions = Pick<InjectedConnectorOptions, 'shimDisconnect'> & {
|
|
8
|
-
/**
|
|
9
|
-
* While "disconnected" with `shimDisconnect`, allows user to select a different MetaMask account (than the currently connected account) when trying to connect.
|
|
10
|
-
*/
|
|
11
|
-
UNSTABLE_shimOnConnectSelectAccount?: boolean;
|
|
12
|
-
};
|
|
13
|
-
declare class MetaMaskConnector extends InjectedConnector {
|
|
14
|
-
#private;
|
|
15
|
-
readonly id = "metaMask";
|
|
16
|
-
protected shimDisconnectKey: string;
|
|
17
|
-
constructor({ chains, options: options_, }?: {
|
|
18
|
-
chains?: Chain[];
|
|
19
|
-
options?: MetaMaskConnectorOptions;
|
|
20
|
-
});
|
|
21
|
-
connect({ chainId }?: {
|
|
22
|
-
chainId?: number;
|
|
23
|
-
}): Promise<{
|
|
24
|
-
account: `0x${string}`;
|
|
25
|
-
chain: {
|
|
26
|
-
id: number;
|
|
27
|
-
unsupported: boolean;
|
|
28
|
-
};
|
|
29
|
-
provider: WindowProvider;
|
|
30
|
-
}>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { MetaMaskConnector, MetaMaskConnectorOptions };
|