@lydianpay/lydianconnect 1.1.4 → 1.2.1
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/README.md +16 -13
- package/dist/index.cjs +811 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +811 -98
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/dist/index.cjs
CHANGED
|
@@ -36,18 +36,23 @@ var ConnectManager = class {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* WalletConnect for a non-EVM chain
|
|
39
|
+
* The connector claiming this walletId if it serves the requested namespace
|
|
40
|
+
* AND is currently available, else the fallback. So an EVM-only SDK connector
|
|
41
|
+
* is bypassed to WalletConnect for a non-EVM chain, and the injected connector
|
|
42
|
+
* is bypassed when the wallet's extension hasn't announced a provider. The host
|
|
43
|
+
* app is oblivious. SDK connectors report `isAvailable` synchronously as `true`,
|
|
44
|
+
* so this only awaits for connectors that actually probe (e.g. injected).
|
|
42
45
|
*/
|
|
43
|
-
resolve(walletId, namespaceName) {
|
|
46
|
+
async resolve(walletId, namespaceName) {
|
|
44
47
|
const claimed = this.byWallet.get(walletId);
|
|
45
|
-
if (claimed && claimed.servesNamespace(namespaceName)
|
|
48
|
+
if (claimed && claimed.servesNamespace(namespaceName) && await claimed.isAvailable(walletId))
|
|
49
|
+
return claimed;
|
|
46
50
|
return this.fallback;
|
|
47
51
|
}
|
|
48
52
|
async connect(req) {
|
|
49
53
|
if (!this.started) await this.init();
|
|
50
|
-
const
|
|
54
|
+
const connector = await this.resolve(req.walletId, req.namespace.name);
|
|
55
|
+
const connection = await connector.connect(req);
|
|
51
56
|
this.connections.set(req.walletId, connection);
|
|
52
57
|
this.emit({ type: "connect", walletId: req.walletId, connection });
|
|
53
58
|
return connection;
|
|
@@ -74,7 +79,9 @@ var ConnectManager = class {
|
|
|
74
79
|
this.connections.delete(walletId);
|
|
75
80
|
return;
|
|
76
81
|
}
|
|
77
|
-
await Promise.allSettled(
|
|
82
|
+
await Promise.allSettled(
|
|
83
|
+
[...this.connections.values()].map((c) => c.disconnect())
|
|
84
|
+
);
|
|
78
85
|
this.connections.clear();
|
|
79
86
|
}
|
|
80
87
|
async reset() {
|
|
@@ -106,7 +113,11 @@ var NAMESPACE_DEFAULTS = {
|
|
|
106
113
|
events: ["chainChanged", "accountsChanged"]
|
|
107
114
|
},
|
|
108
115
|
solana: {
|
|
109
|
-
methods: [
|
|
116
|
+
methods: [
|
|
117
|
+
"solana_signTransaction",
|
|
118
|
+
"solana_signMessage",
|
|
119
|
+
"solana_signAndSendTransaction"
|
|
120
|
+
],
|
|
110
121
|
events: []
|
|
111
122
|
},
|
|
112
123
|
bip122: {
|
|
@@ -124,14 +135,114 @@ function buildNamespace(chainId) {
|
|
|
124
135
|
);
|
|
125
136
|
}
|
|
126
137
|
if (name === "eip155" && !(/^\d+$/.test(reference) && Number(reference) > 0)) {
|
|
127
|
-
throw new Error(
|
|
138
|
+
throw new Error(
|
|
139
|
+
`Invalid eip155 chain "${caip}" \u2014 the reference must be a positive integer.`
|
|
140
|
+
);
|
|
128
141
|
}
|
|
129
142
|
return {
|
|
130
143
|
name,
|
|
131
|
-
value: {
|
|
144
|
+
value: {
|
|
145
|
+
chains: [caip],
|
|
146
|
+
methods: defaults.methods,
|
|
147
|
+
events: defaults.events
|
|
148
|
+
}
|
|
132
149
|
};
|
|
133
150
|
}
|
|
134
151
|
|
|
152
|
+
// node_modules/@lydianpay/lydianconnect-catalog/dist/index.js
|
|
153
|
+
var ICON_BASE = "https://wallet-assets.lydian.com/wallets";
|
|
154
|
+
var WALLETS = [
|
|
155
|
+
{ id: "metamask", name: "MetaMask", namespaces: ["eip155"] },
|
|
156
|
+
{ id: "trust", name: "Trust", namespaces: ["eip155", "solana"] },
|
|
157
|
+
{ id: "rainbow", name: "Rainbow", namespaces: ["eip155"] },
|
|
158
|
+
{ id: "coinbase", name: "Coinbase", namespaces: ["eip155", "solana"] },
|
|
159
|
+
{ id: "zerion", name: "Zerion", namespaces: ["eip155"] },
|
|
160
|
+
{ id: "tokenpocket", name: "Token Pocket", namespaces: ["eip155", "solana"] },
|
|
161
|
+
{ id: "blockchaincom", name: "Blockchain.com", namespaces: ["bip122", "eip155", "solana"] },
|
|
162
|
+
{ id: "exodus", name: "Exodus", namespaces: ["eip155", "solana"] },
|
|
163
|
+
{ id: "phantom", name: "Phantom", namespaces: ["bip122", "eip155", "solana"] },
|
|
164
|
+
{ id: "okx", name: "OKX", namespaces: ["bip122", "eip155", "solana"] },
|
|
165
|
+
{ id: "cryptocom", name: "Crypto.com", namespaces: ["bip122", "eip155", "solana"] },
|
|
166
|
+
{ id: "argent", name: "Argent", namespaces: ["eip155"] },
|
|
167
|
+
{ id: "safepal", name: "SafePal", namespaces: ["eip155", "solana", "ton"] },
|
|
168
|
+
{ id: "imtoken", name: "imToken", namespaces: ["eip155"] },
|
|
169
|
+
{ id: "ronin", name: "Ronin", namespaces: ["eip155"] },
|
|
170
|
+
{ id: "coin98", name: "Coin98", namespaces: ["eip155", "solana"] },
|
|
171
|
+
{ id: "bitkeep", name: "Bitget Wallet", namespaces: ["eip155", "solana"] },
|
|
172
|
+
{ id: "1inch", name: "1inch", namespaces: ["eip155", "solana"] },
|
|
173
|
+
{ id: "ledgerlive", name: "Ledger Live", namespaces: ["bip122", "eip155", "solana"] },
|
|
174
|
+
{ id: "atomic", name: "Atomic", namespaces: ["bip122", "eip155", "solana"] },
|
|
175
|
+
{ id: "alpha", name: "Alpha", namespaces: ["eip155"] },
|
|
176
|
+
{ id: "math", name: "Math", namespaces: ["eip155", "solana"] },
|
|
177
|
+
{ id: "bitpay", name: "BitPay", namespaces: ["eip155"] },
|
|
178
|
+
{ id: "rabby", name: "Rabby", namespaces: ["eip155"] },
|
|
179
|
+
{ id: "bybit", name: "Bybit", namespaces: ["eip155", "solana"] },
|
|
180
|
+
{ id: "binance", name: "Binance", namespaces: ["eip155", "solana"] },
|
|
181
|
+
{ id: "gate", name: "Gate Wallet", namespaces: ["eip155"] },
|
|
182
|
+
{ id: "core", name: "Core", namespaces: ["eip155", "solana"] },
|
|
183
|
+
{ id: "backpack", name: "Backpack", namespaces: ["eip155", "solana"] },
|
|
184
|
+
{ id: "frontier", name: "Frontier", namespaces: ["eip155"] },
|
|
185
|
+
{ id: "onekey", name: "OneKey", namespaces: ["eip155"] },
|
|
186
|
+
{ id: "kraken", name: "Kraken", namespaces: ["eip155", "solana"] },
|
|
187
|
+
{ id: "uniswap", name: "Uniswap Wallet", namespaces: ["eip155"] },
|
|
188
|
+
{ id: "omni", name: "Omni", namespaces: ["eip155"] },
|
|
189
|
+
{ id: "mew", name: "MEW Wallet", namespaces: ["eip155"] },
|
|
190
|
+
{ id: "foxwallet", name: "FoxWallet", namespaces: ["eip155"] },
|
|
191
|
+
{ id: "nova", name: "Nova Wallet", namespaces: ["eip155"] },
|
|
192
|
+
{ id: "subwallet", name: "SubWallet", namespaces: ["eip155"] },
|
|
193
|
+
{ id: "safe", name: "Safe", namespaces: ["eip155"] },
|
|
194
|
+
{ id: "robinhood", name: "Robinhood Wallet", namespaces: ["eip155"] },
|
|
195
|
+
{ id: "tangem", name: "Tangem", namespaces: ["eip155", "solana"] },
|
|
196
|
+
{ id: "trezor", name: "Trezor", namespaces: ["bip122", "eip155", "solana"] },
|
|
197
|
+
{ id: "kucoin", name: "KuCoin", namespaces: ["eip155", "solana"] },
|
|
198
|
+
{ id: "jupiter", name: "Jupiter", namespaces: ["solana"] },
|
|
199
|
+
{ id: "zengo", name: "Zengo", namespaces: ["eip155"] },
|
|
200
|
+
{ id: "bitcoincom", name: "Bitcoin.com", namespaces: ["eip155"] },
|
|
201
|
+
{ id: "keplr", name: "Keplr", namespaces: ["eip155"] },
|
|
202
|
+
{ id: "cake", name: "Cake Wallet", namespaces: ["eip155", "solana"] },
|
|
203
|
+
{ id: "unstoppable", name: "Unstoppable", namespaces: ["eip155"] },
|
|
204
|
+
{ id: "bifrost", name: "Bifrost", namespaces: ["bip122", "eip155"] },
|
|
205
|
+
{ id: "pintu", name: "Pintu", namespaces: ["eip155"] },
|
|
206
|
+
{ id: "hot", name: "HOT Wallet", namespaces: ["eip155", "solana"] },
|
|
207
|
+
{ id: "arculus", name: "Arculus", namespaces: ["bip122", "eip155", "solana"] }
|
|
208
|
+
];
|
|
209
|
+
var EXTENSIONS = {
|
|
210
|
+
metamask: {
|
|
211
|
+
rdns: "io.metamask",
|
|
212
|
+
extensionUrl: "https://chromewebstore.google.com/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn"
|
|
213
|
+
},
|
|
214
|
+
trust: {
|
|
215
|
+
rdns: "com.trustwallet.app",
|
|
216
|
+
extensionUrl: "https://chromewebstore.google.com/detail/trust-wallet/egjidjbpglichdcondbcbdnbeeppgdph"
|
|
217
|
+
},
|
|
218
|
+
rabby: {
|
|
219
|
+
rdns: "io.rabby",
|
|
220
|
+
extensionUrl: "https://chromewebstore.google.com/detail/rabby-wallet/acmacodkjbdgmoleebolmdjonilkdbch"
|
|
221
|
+
},
|
|
222
|
+
okx: {
|
|
223
|
+
// Legacy "okex" brand retained in the extension's rdns after the 2022 rebrand.
|
|
224
|
+
rdns: "com.okex.wallet",
|
|
225
|
+
extensionUrl: "https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge"
|
|
226
|
+
},
|
|
227
|
+
phantom: {
|
|
228
|
+
rdns: "app.phantom",
|
|
229
|
+
extensionUrl: "https://chromewebstore.google.com/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa"
|
|
230
|
+
},
|
|
231
|
+
zerion: {
|
|
232
|
+
rdns: "io.zerion",
|
|
233
|
+
extensionUrl: "https://chromewebstore.google.com/detail/zerion-wallet-crypto-defi/klghhnkeealcohjjanjjdaeeggmfmlpl"
|
|
234
|
+
},
|
|
235
|
+
rainbow: {
|
|
236
|
+
rdns: "me.rainbow",
|
|
237
|
+
extensionUrl: "https://chromewebstore.google.com/detail/rainbow/opfgelmcmbiajamepnmloijbpoleiama"
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
var WALLET_CATALOG = WALLETS.map((w) => ({
|
|
241
|
+
...w,
|
|
242
|
+
iconUrl: `${ICON_BASE}/${w.id}.png`,
|
|
243
|
+
...EXTENSIONS[w.id] ?? {}
|
|
244
|
+
}));
|
|
245
|
+
|
|
135
246
|
// src/core/connector.ts
|
|
136
247
|
var BaseConnector = class {
|
|
137
248
|
constructor() {
|
|
@@ -199,22 +310,34 @@ var MetaMaskConnector = class extends BaseConnector {
|
|
|
199
310
|
if (this.listenersBound) return;
|
|
200
311
|
this.listenersBound = true;
|
|
201
312
|
provider.on("chainChanged", (hex) => {
|
|
202
|
-
this.emit({
|
|
313
|
+
this.emit({
|
|
314
|
+
type: "chainChanged",
|
|
315
|
+
walletId: WALLET_ID,
|
|
316
|
+
chainId: toCaip(String(hex))
|
|
317
|
+
});
|
|
203
318
|
});
|
|
204
319
|
provider.on("accountsChanged", (accounts) => {
|
|
205
320
|
const account = Array.isArray(accounts) ? accounts[0] : void 0;
|
|
206
|
-
if (account)
|
|
321
|
+
if (account)
|
|
322
|
+
this.emit({ type: "accountsChanged", walletId: WALLET_ID, account });
|
|
207
323
|
else this.emit({ type: "disconnect", walletId: WALLET_ID });
|
|
208
324
|
});
|
|
209
|
-
provider.on(
|
|
325
|
+
provider.on(
|
|
326
|
+
"disconnect",
|
|
327
|
+
() => this.emit({ type: "disconnect", walletId: WALLET_ID })
|
|
328
|
+
);
|
|
210
329
|
}
|
|
211
330
|
async connect(req) {
|
|
212
331
|
const provider = await this.getProvider();
|
|
213
|
-
const accounts = await provider.request({
|
|
332
|
+
const accounts = await provider.request({
|
|
333
|
+
method: "eth_requestAccounts"
|
|
334
|
+
});
|
|
214
335
|
const account = accounts?.[0];
|
|
215
336
|
if (!account) throw new Error("MetaMask returned no account");
|
|
216
337
|
await this.ensureChain(provider, req);
|
|
217
|
-
const chainId = toCaip(
|
|
338
|
+
const chainId = toCaip(
|
|
339
|
+
await provider.request({ method: "eth_chainId" })
|
|
340
|
+
);
|
|
218
341
|
return this.toConnection(provider, account, chainId);
|
|
219
342
|
}
|
|
220
343
|
async restore() {
|
|
@@ -254,7 +377,10 @@ var MetaMaskConnector = class extends BaseConnector {
|
|
|
254
377
|
walletId: WALLET_ID,
|
|
255
378
|
account,
|
|
256
379
|
chainId,
|
|
257
|
-
request: async (args) => await provider.request({
|
|
380
|
+
request: async (args) => await provider.request({
|
|
381
|
+
method: args.method,
|
|
382
|
+
params: args.params
|
|
383
|
+
}),
|
|
258
384
|
openWallet: () => {
|
|
259
385
|
},
|
|
260
386
|
// MetaMask SDK foregrounds the wallet on request
|
|
@@ -275,7 +401,10 @@ function toCaip(hexChainId) {
|
|
|
275
401
|
|
|
276
402
|
// src/connectors/coinbase/connector.ts
|
|
277
403
|
function rpc(provider, method, params) {
|
|
278
|
-
return provider.request({
|
|
404
|
+
return provider.request({
|
|
405
|
+
method,
|
|
406
|
+
params
|
|
407
|
+
});
|
|
279
408
|
}
|
|
280
409
|
var WALLET_ID2 = "coinbase";
|
|
281
410
|
var CoinbaseConnector = class extends BaseConnector {
|
|
@@ -311,14 +440,22 @@ var CoinbaseConnector = class extends BaseConnector {
|
|
|
311
440
|
if (this.listenersBound) return;
|
|
312
441
|
this.listenersBound = true;
|
|
313
442
|
provider.on("chainChanged", (hex) => {
|
|
314
|
-
this.emit({
|
|
443
|
+
this.emit({
|
|
444
|
+
type: "chainChanged",
|
|
445
|
+
walletId: WALLET_ID2,
|
|
446
|
+
chainId: toCaip2(String(hex))
|
|
447
|
+
});
|
|
315
448
|
});
|
|
316
449
|
provider.on("accountsChanged", (accounts) => {
|
|
317
450
|
const account = Array.isArray(accounts) ? accounts[0] : void 0;
|
|
318
|
-
if (account)
|
|
451
|
+
if (account)
|
|
452
|
+
this.emit({ type: "accountsChanged", walletId: WALLET_ID2, account });
|
|
319
453
|
else this.emit({ type: "disconnect", walletId: WALLET_ID2 });
|
|
320
454
|
});
|
|
321
|
-
provider.on(
|
|
455
|
+
provider.on(
|
|
456
|
+
"disconnect",
|
|
457
|
+
() => this.emit({ type: "disconnect", walletId: WALLET_ID2 })
|
|
458
|
+
);
|
|
322
459
|
}
|
|
323
460
|
async connect(req) {
|
|
324
461
|
const provider = await this.getProvider(evmChainIds(req));
|
|
@@ -332,10 +469,14 @@ var CoinbaseConnector = class extends BaseConnector {
|
|
|
332
469
|
async restore() {
|
|
333
470
|
const provider = await this.getProvider().catch(() => null);
|
|
334
471
|
if (!provider) return [];
|
|
335
|
-
const accounts = await rpc(provider, "eth_accounts").catch(
|
|
472
|
+
const accounts = await rpc(provider, "eth_accounts").catch(
|
|
473
|
+
() => []
|
|
474
|
+
);
|
|
336
475
|
const account = accounts?.[0];
|
|
337
476
|
if (!account) return [];
|
|
338
|
-
const chainId = toCaip2(
|
|
477
|
+
const chainId = toCaip2(
|
|
478
|
+
await rpc(provider, "eth_chainId").catch(() => "0x1")
|
|
479
|
+
);
|
|
339
480
|
return [this.toConnection(provider, account, chainId)];
|
|
340
481
|
}
|
|
341
482
|
async reset() {
|
|
@@ -353,10 +494,10 @@ var CoinbaseConnector = class extends BaseConnector {
|
|
|
353
494
|
16
|
|
354
495
|
);
|
|
355
496
|
if (current === wantedNum) return;
|
|
356
|
-
await rpc(provider, "wallet_switchEthereumChain", [
|
|
357
|
-
()
|
|
358
|
-
|
|
359
|
-
);
|
|
497
|
+
await rpc(provider, "wallet_switchEthereumChain", [
|
|
498
|
+
{ chainId: `0x${wantedNum.toString(16)}` }
|
|
499
|
+
]).catch(() => {
|
|
500
|
+
});
|
|
360
501
|
}
|
|
361
502
|
toConnection(provider, account, chainId) {
|
|
362
503
|
return {
|
|
@@ -388,67 +529,609 @@ function evmChainIds(req) {
|
|
|
388
529
|
return Number.isFinite(n) && n > 0 ? [n] : void 0;
|
|
389
530
|
}
|
|
390
531
|
|
|
532
|
+
// src/connectors/injected/connector.ts
|
|
533
|
+
var DISCOVERY_WAIT_MS = 100;
|
|
534
|
+
var InjectedConnector = class extends BaseConnector {
|
|
535
|
+
constructor(rdnsByWallet) {
|
|
536
|
+
super();
|
|
537
|
+
this.rdnsByWallet = rdnsByWallet;
|
|
538
|
+
this.type = "injected";
|
|
539
|
+
/** rdns -> the provider it announced. Populated by EIP-6963 discovery. */
|
|
540
|
+
this.discovered = /* @__PURE__ */ new Map();
|
|
541
|
+
/**
|
|
542
|
+
* Providers we've already attached listeners to. Bind once and keep for the
|
|
543
|
+
* page's life (never remove) so a reconnect doesn't stack duplicate listeners.
|
|
544
|
+
* EIP-6963 announces exactly one provider per rdns, so a given provider maps to
|
|
545
|
+
* a single walletId — closing over walletId in bindEvents is safe.
|
|
546
|
+
*/
|
|
547
|
+
this.bound = /* @__PURE__ */ new WeakSet();
|
|
548
|
+
this.listening = false;
|
|
549
|
+
this.walletIds = Object.keys(rdnsByWallet);
|
|
550
|
+
this.startDiscovery();
|
|
551
|
+
}
|
|
552
|
+
/** Listen for provider announcements, then ask installed extensions to announce. */
|
|
553
|
+
startDiscovery() {
|
|
554
|
+
if (this.listening || typeof window === "undefined") return;
|
|
555
|
+
this.listening = true;
|
|
556
|
+
window.addEventListener("eip6963:announceProvider", (event) => {
|
|
557
|
+
const detail = event.detail;
|
|
558
|
+
if (detail?.info?.rdns && detail.provider)
|
|
559
|
+
this.discovered.set(detail.info.rdns, detail);
|
|
560
|
+
});
|
|
561
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
562
|
+
}
|
|
563
|
+
servesNamespace(name) {
|
|
564
|
+
return name === "eip155";
|
|
565
|
+
}
|
|
566
|
+
/** Available iff the wallet's extension has announced an injected provider. */
|
|
567
|
+
async isAvailable(walletId) {
|
|
568
|
+
if (typeof window === "undefined") return false;
|
|
569
|
+
const rdns = this.rdnsByWallet[walletId];
|
|
570
|
+
if (!rdns) return false;
|
|
571
|
+
if (this.discovered.has(rdns)) return true;
|
|
572
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
573
|
+
await new Promise((resolve) => setTimeout(resolve, DISCOVERY_WAIT_MS));
|
|
574
|
+
return this.discovered.has(rdns);
|
|
575
|
+
}
|
|
576
|
+
async connect(req) {
|
|
577
|
+
const provider = this.providerFor(req.walletId);
|
|
578
|
+
if (!provider)
|
|
579
|
+
throw new Error(`No injected provider announced for "${req.walletId}"`);
|
|
580
|
+
const accounts = await withSignal(
|
|
581
|
+
provider.request({ method: "eth_requestAccounts" }),
|
|
582
|
+
// triggers the extension popup
|
|
583
|
+
req.signal
|
|
584
|
+
);
|
|
585
|
+
const account = accounts?.[0];
|
|
586
|
+
if (!account)
|
|
587
|
+
throw new Error(`${req.walletId} extension returned no account`);
|
|
588
|
+
await this.ensureChain(provider, req);
|
|
589
|
+
const chainId = toCaip3(
|
|
590
|
+
await provider.request({ method: "eth_chainId" })
|
|
591
|
+
);
|
|
592
|
+
this.bindEvents(provider, req.walletId);
|
|
593
|
+
return this.toConnection(provider, req.walletId, account, chainId);
|
|
594
|
+
}
|
|
595
|
+
async restore() {
|
|
596
|
+
if (typeof window === "undefined") return [];
|
|
597
|
+
if (this.discovered.size === 0) {
|
|
598
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
599
|
+
await new Promise((resolve) => setTimeout(resolve, DISCOVERY_WAIT_MS));
|
|
600
|
+
}
|
|
601
|
+
const out = [];
|
|
602
|
+
for (const walletId of this.walletIds) {
|
|
603
|
+
const provider = this.providerFor(walletId);
|
|
604
|
+
if (!provider) continue;
|
|
605
|
+
const accounts = await provider.request({ method: "eth_accounts" }).catch(() => []);
|
|
606
|
+
const account = accounts?.[0];
|
|
607
|
+
if (!account) continue;
|
|
608
|
+
const chainId = toCaip3(
|
|
609
|
+
await provider.request({ method: "eth_chainId" }).catch(() => "0x1")
|
|
610
|
+
);
|
|
611
|
+
this.bindEvents(provider, walletId);
|
|
612
|
+
out.push(this.toConnection(provider, walletId, account, chainId));
|
|
613
|
+
}
|
|
614
|
+
return out;
|
|
615
|
+
}
|
|
616
|
+
providerFor(walletId) {
|
|
617
|
+
const rdns = this.rdnsByWallet[walletId];
|
|
618
|
+
return rdns ? this.discovered.get(rdns)?.provider : void 0;
|
|
619
|
+
}
|
|
620
|
+
bindEvents(provider, walletId) {
|
|
621
|
+
if (this.bound.has(provider)) return;
|
|
622
|
+
this.bound.add(provider);
|
|
623
|
+
provider.on("chainChanged", (hex) => {
|
|
624
|
+
this.emit({
|
|
625
|
+
type: "chainChanged",
|
|
626
|
+
walletId,
|
|
627
|
+
chainId: toCaip3(String(hex))
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
provider.on("accountsChanged", (accounts) => {
|
|
631
|
+
const account = Array.isArray(accounts) ? accounts[0] : void 0;
|
|
632
|
+
if (account) this.emit({ type: "accountsChanged", walletId, account });
|
|
633
|
+
else this.emit({ type: "disconnect", walletId });
|
|
634
|
+
});
|
|
635
|
+
provider.on(
|
|
636
|
+
"disconnect",
|
|
637
|
+
() => this.emit({ type: "disconnect", walletId })
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
/** Best-effort switch to the requested chain; leaves the wallet as-is if it's unknown to it. */
|
|
641
|
+
async ensureChain(provider, req) {
|
|
642
|
+
const wanted = req.namespace.value.chains?.[0];
|
|
643
|
+
const wantedNum = wanted ? Number(wanted.split(":")[1]) : NaN;
|
|
644
|
+
if (!Number.isFinite(wantedNum) || wantedNum <= 0) return;
|
|
645
|
+
const current = parseInt(
|
|
646
|
+
await provider.request({ method: "eth_chainId" }).catch(() => "0x0") ?? "0x0",
|
|
647
|
+
16
|
|
648
|
+
);
|
|
649
|
+
if (current === wantedNum) return;
|
|
650
|
+
await provider.request({
|
|
651
|
+
method: "wallet_switchEthereumChain",
|
|
652
|
+
params: [{ chainId: `0x${wantedNum.toString(16)}` }]
|
|
653
|
+
}).catch(() => {
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
toConnection(provider, walletId, account, chainId) {
|
|
657
|
+
return {
|
|
658
|
+
walletId,
|
|
659
|
+
account,
|
|
660
|
+
chainId,
|
|
661
|
+
request: async (args) => await provider.request({
|
|
662
|
+
method: args.method,
|
|
663
|
+
params: args.params
|
|
664
|
+
}),
|
|
665
|
+
openWallet: () => {
|
|
666
|
+
},
|
|
667
|
+
// the extension foregrounds its own popup on request
|
|
668
|
+
disconnect: async () => {
|
|
669
|
+
await provider.request({
|
|
670
|
+
method: "wallet_revokePermissions",
|
|
671
|
+
params: [{ eth_accounts: {} }]
|
|
672
|
+
}).catch(() => {
|
|
673
|
+
});
|
|
674
|
+
this.emit({ type: "disconnect", walletId });
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
function toCaip3(hexChainId) {
|
|
680
|
+
if (!hexChainId) return "eip155:1";
|
|
681
|
+
const num = hexChainId.startsWith("0x") ? parseInt(hexChainId, 16) : Number(hexChainId);
|
|
682
|
+
return `eip155:${Number.isFinite(num) ? num : 1}`;
|
|
683
|
+
}
|
|
684
|
+
function withSignal(promise, signal) {
|
|
685
|
+
if (!signal) return promise;
|
|
686
|
+
if (signal.aborted)
|
|
687
|
+
return Promise.reject(new DOMException("Aborted", "AbortError"));
|
|
688
|
+
return new Promise((resolve, reject) => {
|
|
689
|
+
const onAbort = () => reject(new DOMException("Aborted", "AbortError"));
|
|
690
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
691
|
+
promise.then(
|
|
692
|
+
(value) => {
|
|
693
|
+
signal.removeEventListener("abort", onAbort);
|
|
694
|
+
resolve(value);
|
|
695
|
+
},
|
|
696
|
+
(error) => {
|
|
697
|
+
signal.removeEventListener("abort", onAbort);
|
|
698
|
+
reject(error);
|
|
699
|
+
}
|
|
700
|
+
);
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
|
|
391
704
|
// src/connectors/walletconnect/wallet-links.ts
|
|
392
705
|
var WALLET_LINKS = {
|
|
393
|
-
metamask: {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
706
|
+
metamask: {
|
|
707
|
+
native: "metamask://",
|
|
708
|
+
scheme: "metamask://wc",
|
|
709
|
+
universal: "https://metamask.app.link/wc",
|
|
710
|
+
store: {
|
|
711
|
+
ios: "https://apps.apple.com/us/app/metamask/id1438144202",
|
|
712
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask"
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
trust: {
|
|
716
|
+
native: "trust://",
|
|
717
|
+
scheme: "trust://wc",
|
|
718
|
+
universal: "https://link.trustwallet.com/wc",
|
|
719
|
+
store: {
|
|
720
|
+
ios: "https://apps.apple.com/app/apple-store/id1288339409",
|
|
721
|
+
android: "https://play.google.com/store/apps/details?id=com.wallet.crypto.trustapp"
|
|
722
|
+
}
|
|
723
|
+
},
|
|
724
|
+
rainbow: {
|
|
725
|
+
native: "rainbow://",
|
|
726
|
+
scheme: "rainbow://wc",
|
|
727
|
+
universal: "https://rnbwapp.com/wc",
|
|
728
|
+
store: {
|
|
729
|
+
ios: "https://apps.apple.com/app/apple-store/id1457119021?pt=119997837&ct=wc&mt=8",
|
|
730
|
+
android: "https://play.google.com/store/apps/details?id=me.rainbow&referrer=utm_source%3Dwc%26utm_medium%3Dconnector%26utm_campaign%3Dwc"
|
|
731
|
+
}
|
|
732
|
+
},
|
|
733
|
+
coinbase: {
|
|
734
|
+
store: {
|
|
735
|
+
ios: "https://apps.apple.com/us/app/base-formerly-coinbase-wallet/id1278383455"
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
zerion: {
|
|
739
|
+
native: "zerion://",
|
|
740
|
+
scheme: "zerion://wc",
|
|
741
|
+
universal: "https://wallet.zerion.io/wc/wc",
|
|
742
|
+
store: {
|
|
743
|
+
ios: "https://apps.apple.com/app/id1456732565",
|
|
744
|
+
android: "https://play.google.com/store/apps/details?id=io.zerion.android&hl=en&gl=US"
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
tokenpocket: {
|
|
748
|
+
native: "tpoutside://",
|
|
749
|
+
scheme: "tpoutside://wc",
|
|
750
|
+
store: {
|
|
751
|
+
ios: "https://apps.apple.com/us/app/tp-wallet/id6444625622?l=en",
|
|
752
|
+
android: "https://play.google.com/store/apps/details?id=vip.mytokenpocket"
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
blockchaincom: {
|
|
756
|
+
native: "blockchain-wallet://",
|
|
757
|
+
scheme: "blockchain-wallet://wc",
|
|
758
|
+
universal: "https://login.blockchain.com/app/wc",
|
|
759
|
+
store: {
|
|
760
|
+
ios: "https://apps.apple.com/us/app/blockchain-bitcoin-wallet/id493253309",
|
|
761
|
+
android: "https://play.google.com/store/apps/details?id=piuk.blockchain.android"
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
exodus: {
|
|
765
|
+
native: "exodus://",
|
|
766
|
+
scheme: "exodus://wc",
|
|
767
|
+
universal: "https://exodus.com/m/wc",
|
|
768
|
+
store: {
|
|
769
|
+
ios: "https://apps.apple.com/us/app/exodus-crypto-bitcoin-wallet/id1414384820",
|
|
770
|
+
android: "https://play.google.com/store/apps/details?id=exodusmovement.exodus&hl=en&gl=US"
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
phantom: {
|
|
774
|
+
store: {
|
|
775
|
+
ios: "https://apps.apple.com/us/app/phantom-crypto-wallet/id1598432977",
|
|
776
|
+
android: "https://play.google.com/store/apps/details?id=app.phantom&hl=en"
|
|
777
|
+
}
|
|
778
|
+
},
|
|
779
|
+
okx: {
|
|
780
|
+
native: "okxwallet://main",
|
|
781
|
+
scheme: "okxwallet://main/wc",
|
|
782
|
+
store: {
|
|
783
|
+
ios: "https://apps.apple.com/us/app/okx-buy-bitcoin-eth-crypto/id1327268470",
|
|
784
|
+
android: "https://play.google.com/store/apps/details?id=com.okinc.okex.gp"
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
cryptocom: {
|
|
788
|
+
native: "cryptowallet://",
|
|
789
|
+
scheme: "cryptowallet://wc",
|
|
790
|
+
store: {
|
|
791
|
+
ios: "https://apps.apple.com/US/app/id1512048310?mt=8",
|
|
792
|
+
android: "https://play.google.com/store/apps/details?id=com.defi.wallet"
|
|
793
|
+
}
|
|
794
|
+
},
|
|
795
|
+
argent: {
|
|
796
|
+
native: "argent://app/",
|
|
797
|
+
scheme: "argent://app/wc",
|
|
798
|
+
universal: "https://www.argent.xyz/app/wc",
|
|
799
|
+
store: {
|
|
800
|
+
ios: "https://apps.apple.com/us/app/argent-defi-in-a-tap/id1358741926",
|
|
801
|
+
android: "https://play.google.com/store/apps/details?id=im.argent.contractwalletclient&hl=en&gl=US&pli=1"
|
|
802
|
+
}
|
|
803
|
+
},
|
|
804
|
+
safepal: {
|
|
805
|
+
native: "safepalwallet://",
|
|
806
|
+
scheme: "safepalwallet://wc",
|
|
807
|
+
universal: "https://link.safepal.io/wc",
|
|
808
|
+
store: {
|
|
809
|
+
ios: "https://apps.apple.com/app/safepal-wallet/id1548297139",
|
|
810
|
+
android: "https://play.google.com/store/apps/details?id=io.safepal.wallet"
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
imtoken: {
|
|
814
|
+
native: "imtokenv2://",
|
|
815
|
+
scheme: "imtokenv2://wc",
|
|
816
|
+
store: {
|
|
817
|
+
ios: "https://apps.apple.com/us/app/imtoken2/id1384798940",
|
|
818
|
+
android: "https://play.google.com/store/apps/details?id=im.token.app"
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
ronin: {
|
|
822
|
+
native: "roninwallet://",
|
|
823
|
+
scheme: "roninwallet://wc",
|
|
824
|
+
universal: "https://wallet.roninchain.com/wc",
|
|
825
|
+
store: {
|
|
826
|
+
ios: "https://apps.apple.com/us/app/ronin-wallet/id1592675001",
|
|
827
|
+
android: "https://play.google.com/store/apps/details?id=com.skymavis.genesis"
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
coin98: {
|
|
831
|
+
native: "coin98://",
|
|
832
|
+
scheme: "coin98://wc",
|
|
833
|
+
universal: "https://coin98.com/wc",
|
|
834
|
+
store: {
|
|
835
|
+
ios: "https://apps.apple.com/vn/app/coin98-wallet/id1561969966",
|
|
836
|
+
android: "https://play.google.com/store/apps/details?id=coin98.crypto.finance.media&hl=vi&gl=US"
|
|
837
|
+
}
|
|
838
|
+
},
|
|
839
|
+
bitkeep: {
|
|
840
|
+
native: "bitkeep://",
|
|
841
|
+
scheme: "bitkeep://wc",
|
|
842
|
+
universal: "https://bkapp.vip/wc",
|
|
843
|
+
store: {
|
|
844
|
+
ios: "https://web3.bitget.com/en/wallet-download?type=0",
|
|
845
|
+
android: "https://web3.bitget.com/en/wallet-download?type=0"
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
"1inch": {
|
|
849
|
+
native: "oneinch://open/nobodywilleveruseit",
|
|
850
|
+
scheme: "oneinch://open/nobodywilleveruseit/wc",
|
|
851
|
+
universal: "https://wallet.1inch.io/app/nobodywilleveruseit/wc",
|
|
852
|
+
store: {
|
|
853
|
+
ios: "https://apps.apple.com/us/app/1inch-defi-wallet/id1546049391",
|
|
854
|
+
android: "https://play.google.com/store/apps/details?id=io.oneinch.android"
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
ledgerlive: {
|
|
858
|
+
native: "ledgerlive://",
|
|
859
|
+
scheme: "ledgerlive://wc",
|
|
860
|
+
store: {
|
|
861
|
+
ios: "https://itunes.apple.com/app/id1361671700",
|
|
862
|
+
android: "https://play.google.com/store/apps/details?id=com.ledger.live"
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
atomic: {
|
|
866
|
+
native: "atomicwallet://",
|
|
867
|
+
scheme: "atomicwallet://wc",
|
|
868
|
+
store: {
|
|
869
|
+
ios: "https://apps.apple.com/us/app/atomic-wallet/id1478257827",
|
|
870
|
+
android: "https://play.google.com/store/apps/details?id=io.atomicwallet"
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
alpha: {
|
|
874
|
+
native: "awallet://",
|
|
875
|
+
scheme: "awallet://wc",
|
|
876
|
+
universal: "https://aw.app/wc",
|
|
877
|
+
store: {
|
|
878
|
+
ios: "https://apps.apple.com/us/app/alphawallet-eth-wallet/id1358230430",
|
|
879
|
+
android: "https://play.google.com/store/apps/details?id=io.stormbird.wallet"
|
|
880
|
+
}
|
|
881
|
+
},
|
|
882
|
+
math: {
|
|
883
|
+
native: "mathwallet://",
|
|
884
|
+
scheme: "mathwallet://wc",
|
|
885
|
+
universal: "https://www.mathwallet.org/wc",
|
|
886
|
+
store: {
|
|
887
|
+
ios: "https://apps.apple.com/us/app/mathwallet5/id1582612388",
|
|
888
|
+
android: "https://play.google.com/store/apps/details?id=com.mathwallet.android"
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
bitpay: {
|
|
892
|
+
native: "bitpay://",
|
|
893
|
+
scheme: "bitpay://wc",
|
|
894
|
+
universal: "https://link.bitpay.com/wc",
|
|
895
|
+
store: {
|
|
896
|
+
ios: "https://bitpay.onelink.me/Cenw/ejjaw7bs",
|
|
897
|
+
android: "https://bitpay.onelink.me/Cenw/ejjaw7bs"
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
rabby: {
|
|
901
|
+
native: "rabby://",
|
|
902
|
+
scheme: "rabby://wc",
|
|
903
|
+
store: {
|
|
904
|
+
ios: "https://apps.apple.com/us/app/rabby-wallet-crypto-evm/id6474381673",
|
|
905
|
+
android: "https://play.google.com/store/apps/details?id=com.debank.rabbymobile"
|
|
906
|
+
}
|
|
907
|
+
},
|
|
417
908
|
// Bybit's WC deep link nests the uri inside a targetUrl wrapper (bybitapp://open/route?targetUrl=by://web3/walletconnect/wc?uri=...), which the `${scheme}?uri=` builder can't express — QR/scan connect only.
|
|
418
|
-
bybit: {
|
|
419
|
-
|
|
420
|
-
|
|
909
|
+
bybit: {
|
|
910
|
+
store: {
|
|
911
|
+
ios: "https://apps.apple.com/us/app/bybit-buy-trade-crypto/id1488296980",
|
|
912
|
+
android: "https://play.google.com/store/apps/details?id=com.bybit.app"
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
binance: {
|
|
916
|
+
native: "bnc://app.binance.com/cedefi/",
|
|
917
|
+
scheme: "bnc://app.binance.com/cedefi/wc",
|
|
918
|
+
store: {
|
|
919
|
+
ios: "https://apps.apple.com/us/app/id1436799971",
|
|
920
|
+
android: "https://play.google.com/store/apps/details?id=com.binance.dev"
|
|
921
|
+
}
|
|
922
|
+
},
|
|
923
|
+
gate: {
|
|
924
|
+
native: "gtweb3wallet://",
|
|
925
|
+
scheme: "gtweb3wallet://wc",
|
|
926
|
+
store: {
|
|
927
|
+
ios: "https://apps.apple.com/us/app/gate-io-buy-bitcoin-crypto/id1294998195",
|
|
928
|
+
android: "https://play.google.com/store/apps/details?id=com.gateio.gateio"
|
|
929
|
+
}
|
|
930
|
+
},
|
|
421
931
|
// Core: `core://` scheme not corroborated to 2 sources — QR/scan connect only.
|
|
422
|
-
core: {
|
|
932
|
+
core: {
|
|
933
|
+
store: {
|
|
934
|
+
ios: "https://apps.apple.com/us/app/core-wallet/id6443685999",
|
|
935
|
+
android: "https://play.google.com/store/apps/details?id=com.avaxwallet"
|
|
936
|
+
}
|
|
937
|
+
},
|
|
423
938
|
// Backpack: `backpack://` scheme not corroborated to 2 sources — QR/scan connect only.
|
|
424
|
-
backpack: {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
939
|
+
backpack: {
|
|
940
|
+
store: {
|
|
941
|
+
ios: "https://apps.apple.com/us/app/backpack-wallet-exchange/id6445964121",
|
|
942
|
+
android: "https://play.google.com/store/apps/details?id=app.backpack.mobile"
|
|
943
|
+
}
|
|
944
|
+
},
|
|
945
|
+
frontier: {
|
|
946
|
+
native: "frontier://",
|
|
947
|
+
scheme: "frontier://wc",
|
|
948
|
+
store: {
|
|
949
|
+
ios: "https://apps.apple.com/us/app/frontier-crypto-defi-wallet/id1482380988",
|
|
950
|
+
android: "https://play.google.com/store/apps/details?id=com.frontierwallet"
|
|
951
|
+
}
|
|
952
|
+
},
|
|
953
|
+
onekey: {
|
|
954
|
+
native: "onekey-wallet://",
|
|
955
|
+
scheme: "onekey-wallet://wc",
|
|
956
|
+
store: {
|
|
957
|
+
ios: "https://apps.apple.com/us/app/onekey-open-source-wallet/id1609559473",
|
|
958
|
+
android: "https://play.google.com/store/apps/details?id=so.onekey.app.wallet"
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
kraken: {
|
|
962
|
+
native: "krakenwallet://",
|
|
963
|
+
scheme: "krakenwallet://wc",
|
|
964
|
+
store: {
|
|
965
|
+
ios: "https://apps.apple.com/us/app/kraken-wallet/id1626327149",
|
|
966
|
+
android: "https://play.google.com/store/apps/details?id=com.kraken.superwallet"
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
uniswap: {
|
|
970
|
+
native: "uniswap://",
|
|
971
|
+
scheme: "uniswap://wc",
|
|
972
|
+
store: {
|
|
973
|
+
ios: "https://apps.apple.com/us/app/uniswap-crypto-nft-wallet/id6443944476",
|
|
974
|
+
android: "https://play.google.com/store/apps/details?id=com.uniswap.mobile"
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
omni: {
|
|
978
|
+
native: "omni://",
|
|
979
|
+
scheme: "omni://wc",
|
|
980
|
+
store: {
|
|
981
|
+
ios: "https://apps.apple.com/us/app/omni-web3-wallet/id1569375204",
|
|
982
|
+
android: "https://play.google.com/store/apps/details?id=fi.steakwallet.app"
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
mew: {
|
|
986
|
+
universal: "https://mewwallet.com/wc",
|
|
987
|
+
store: {
|
|
988
|
+
ios: "https://apps.apple.com/app/id1464614025",
|
|
989
|
+
android: "https://play.google.com/store/apps/details?id=com.myetherwallet.mewwallet"
|
|
990
|
+
}
|
|
991
|
+
},
|
|
992
|
+
foxwallet: {
|
|
993
|
+
native: "foxwallet://",
|
|
994
|
+
scheme: "foxwallet://wc",
|
|
995
|
+
universal: "https://link.foxwallet.com/wc",
|
|
996
|
+
store: {
|
|
997
|
+
ios: "https://apps.apple.com/app/foxwallet-crypto-web3/id1590983231",
|
|
998
|
+
android: "https://play.google.com/store/apps/details?id=com.foxwallet.play"
|
|
999
|
+
}
|
|
1000
|
+
},
|
|
1001
|
+
nova: {
|
|
1002
|
+
native: "novawallet://",
|
|
1003
|
+
scheme: "novawallet://wc",
|
|
1004
|
+
store: {
|
|
1005
|
+
ios: "https://apps.apple.com/us/app/nova-polkadot-wallet/id1597119355",
|
|
1006
|
+
android: "https://play.google.com/store/apps/details?id=io.novafoundation.nova.market"
|
|
1007
|
+
}
|
|
1008
|
+
},
|
|
1009
|
+
subwallet: {
|
|
1010
|
+
native: "subwallet://",
|
|
1011
|
+
scheme: "subwallet://wc",
|
|
1012
|
+
store: {
|
|
1013
|
+
ios: "https://apps.apple.com/us/app/subwallet-polkadot-wallet/id1633050285",
|
|
1014
|
+
android: "https://play.google.com/store/apps/details?id=app.subwallet.mobile"
|
|
1015
|
+
}
|
|
1016
|
+
},
|
|
1017
|
+
safe: {
|
|
1018
|
+
native: "safe://",
|
|
1019
|
+
scheme: "safe://wc",
|
|
1020
|
+
store: {
|
|
1021
|
+
ios: "https://apps.apple.com/us/app/safe-mobile/id6748754793",
|
|
1022
|
+
android: "https://play.google.com/store/apps/details?id=global.safe.mobileapp"
|
|
1023
|
+
}
|
|
1024
|
+
},
|
|
1025
|
+
robinhood: {
|
|
1026
|
+
native: "robinhood-wallet://",
|
|
1027
|
+
scheme: "robinhood-wallet://wc",
|
|
1028
|
+
store: {
|
|
1029
|
+
ios: "https://apps.apple.com/us/app/robinhood-wallet-swap-crypto/id1634080733",
|
|
1030
|
+
android: "https://play.google.com/store/apps/details?id=com.robinhood.gateway"
|
|
1031
|
+
}
|
|
1032
|
+
},
|
|
1033
|
+
tangem: {
|
|
1034
|
+
native: "tangem://",
|
|
1035
|
+
scheme: "tangem://wc",
|
|
1036
|
+
store: {
|
|
1037
|
+
ios: "https://apps.apple.com/app/tangem/id1354868448",
|
|
1038
|
+
android: "https://play.google.com/store/apps/details?id=com.tangem.wallet"
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
437
1041
|
// Trezor Suite: WalletConnect pairing is QR/paste-into-Suite (no corroborated custom scheme) — QR connect only.
|
|
438
|
-
trezor: {
|
|
439
|
-
|
|
1042
|
+
trezor: {
|
|
1043
|
+
store: {
|
|
1044
|
+
ios: "https://apps.apple.com/us/app/trezor-suite/id1631884497",
|
|
1045
|
+
android: "https://play.google.com/store/apps/details?id=io.trezor.suite"
|
|
1046
|
+
}
|
|
1047
|
+
},
|
|
1048
|
+
kucoin: {
|
|
1049
|
+
native: "kucoin://",
|
|
1050
|
+
scheme: "kucoin:///wallet/walletConnect",
|
|
1051
|
+
store: {
|
|
1052
|
+
ios: "https://apps.apple.com/app/kucoin-buy-bitcoin-crypto/id1378956601",
|
|
1053
|
+
android: "https://play.google.com/store/apps/details?id=com.kubi.kucoin"
|
|
1054
|
+
}
|
|
1055
|
+
},
|
|
440
1056
|
// Jupiter (Solana): no corroborated WC deep-link scheme — QR connect only.
|
|
441
|
-
jupiter: {
|
|
442
|
-
|
|
1057
|
+
jupiter: {
|
|
1058
|
+
store: {
|
|
1059
|
+
ios: "https://apps.apple.com/us/app/jupiter-solana-swap-wallet/id6484069059",
|
|
1060
|
+
android: "https://play.google.com/store/apps/details?id=ag.jup.jupiter.android"
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
zengo: {
|
|
1064
|
+
native: "zengo://get.zengo.com/",
|
|
1065
|
+
scheme: "zengo://get.zengo.com/wc",
|
|
1066
|
+
store: {
|
|
1067
|
+
ios: "https://apps.apple.com/us/app/zengo-crypto-bitcoin-wallet/id1440147115",
|
|
1068
|
+
android: "https://play.google.com/store/apps/details?id=com.zengo.wallet"
|
|
1069
|
+
}
|
|
1070
|
+
},
|
|
443
1071
|
// Bitcoin.com Wallet: no corroborated WC deep-link scheme — QR connect only.
|
|
444
|
-
bitcoincom: {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
1072
|
+
bitcoincom: {
|
|
1073
|
+
store: {
|
|
1074
|
+
ios: "https://apps.apple.com/us/app/bitcoin-wallet-by-bitcoin-com/id1252903728",
|
|
1075
|
+
android: "https://play.google.com/store/apps/details?id=com.bitcoin.mwallet"
|
|
1076
|
+
}
|
|
1077
|
+
},
|
|
1078
|
+
keplr: {
|
|
1079
|
+
native: "keplrwallet://",
|
|
1080
|
+
scheme: "keplrwallet://wcV2",
|
|
1081
|
+
store: {
|
|
1082
|
+
ios: "https://apps.apple.com/us/app/keplr-wallet/id1567851089",
|
|
1083
|
+
android: "https://play.google.com/store/apps/details?id=com.chainapsis.keplr"
|
|
1084
|
+
}
|
|
1085
|
+
},
|
|
1086
|
+
cake: {
|
|
1087
|
+
native: "cakewallet://",
|
|
1088
|
+
scheme: "cakewallet://wc",
|
|
1089
|
+
store: {
|
|
1090
|
+
ios: "https://apps.apple.com/us/app/cake-wallet/id1334702542",
|
|
1091
|
+
android: "https://play.google.com/store/apps/details?id=com.cakewallet.cake_wallet"
|
|
1092
|
+
}
|
|
1093
|
+
},
|
|
1094
|
+
unstoppable: {
|
|
1095
|
+
native: "unstoppable.money://",
|
|
1096
|
+
scheme: "unstoppable.money://wc",
|
|
1097
|
+
store: {
|
|
1098
|
+
ios: "https://apps.apple.com/us/app/unstoppable-crypto-wallet/id1447619907",
|
|
1099
|
+
android: "https://play.google.com/store/apps/details?id=io.horizontalsystems.bankwallet"
|
|
1100
|
+
}
|
|
1101
|
+
},
|
|
1102
|
+
bifrost: {
|
|
1103
|
+
native: "bifrostwallet://",
|
|
1104
|
+
scheme: "bifrostwallet://wc",
|
|
1105
|
+
store: {
|
|
1106
|
+
ios: "https://apps.apple.com/us/app/bifrost-wallet/id1577198351",
|
|
1107
|
+
android: "https://play.google.com/store/apps/details?id=com.bifrostwallet.app"
|
|
1108
|
+
}
|
|
1109
|
+
},
|
|
1110
|
+
pintu: {
|
|
1111
|
+
native: "pintu://web3wallet",
|
|
1112
|
+
scheme: "pintu://web3wallet/wc",
|
|
1113
|
+
store: {
|
|
1114
|
+
ios: "https://apps.apple.com/id/app/pintu-buy-invest-crypto/id1494119678",
|
|
1115
|
+
android: "https://play.google.com/store/apps/details?id=com.valar.pintu"
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
hot: {
|
|
1119
|
+
native: "hotwallet://",
|
|
1120
|
+
scheme: "hotwallet://wc",
|
|
1121
|
+
store: {
|
|
1122
|
+
ios: "https://apps.apple.com/us/app/hot-wallet/id6740916148",
|
|
1123
|
+
android: "https://play.google.com/store/apps/details?id=app.herewallet.hot"
|
|
1124
|
+
}
|
|
1125
|
+
},
|
|
1126
|
+
arculus: {
|
|
1127
|
+
native: "arculuswc://",
|
|
1128
|
+
scheme: "arculuswc://wc",
|
|
1129
|
+
universal: "https://gw.arculus.co/app/wc",
|
|
1130
|
+
store: {
|
|
1131
|
+
ios: "https://apps.apple.com/us/app/arculus-wallet/id1575425801",
|
|
1132
|
+
android: "https://play.google.com/store/apps/details?id=co.arculus.wallet.android"
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
452
1135
|
};
|
|
453
1136
|
|
|
454
1137
|
// src/connectors/walletconnect/registry.ts
|
|
@@ -574,23 +1257,30 @@ var WalletConnectConnector = class extends BaseConnector {
|
|
|
574
1257
|
const link = this.links[req.walletId];
|
|
575
1258
|
if (link) {
|
|
576
1259
|
openWallet(link, uri);
|
|
577
|
-
void detectAppOpen(this.options.openTimeoutMs ?? 2e3).then(
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
1260
|
+
void detectAppOpen(this.options.openTimeoutMs ?? 2e3).then(
|
|
1261
|
+
(opened) => {
|
|
1262
|
+
if (!opened)
|
|
1263
|
+
this.emit({
|
|
1264
|
+
type: "wallet_open_failed",
|
|
1265
|
+
walletId: req.walletId,
|
|
1266
|
+
uri,
|
|
1267
|
+
store: link.store
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
);
|
|
586
1271
|
}
|
|
587
1272
|
}
|
|
588
1273
|
const pairingTopic = utils.parseUri(uri).topic;
|
|
589
|
-
const session = await
|
|
1274
|
+
const session = await withSignal2(approval(), req.signal, () => {
|
|
590
1275
|
void client.core.pairing.disconnect({ topic: pairingTopic }).catch(() => {
|
|
591
1276
|
});
|
|
592
1277
|
});
|
|
593
|
-
const connection = this.toConnection(
|
|
1278
|
+
const connection = this.toConnection(
|
|
1279
|
+
client,
|
|
1280
|
+
req.walletId,
|
|
1281
|
+
session,
|
|
1282
|
+
req.namespace
|
|
1283
|
+
);
|
|
594
1284
|
this.topics.set(req.walletId, session.topic);
|
|
595
1285
|
this.persist();
|
|
596
1286
|
return connection;
|
|
@@ -614,7 +1304,12 @@ var WalletConnectConnector = class extends BaseConnector {
|
|
|
614
1304
|
const client = this.client;
|
|
615
1305
|
if (client) {
|
|
616
1306
|
await Promise.allSettled(
|
|
617
|
-
client.session.getAll().map(
|
|
1307
|
+
client.session.getAll().map(
|
|
1308
|
+
(s) => client.disconnect({
|
|
1309
|
+
topic: s.topic,
|
|
1310
|
+
reason: utils.getSdkError("USER_DISCONNECTED")
|
|
1311
|
+
})
|
|
1312
|
+
)
|
|
618
1313
|
);
|
|
619
1314
|
}
|
|
620
1315
|
this.topics.clear();
|
|
@@ -682,7 +1377,8 @@ var WalletConnectConnector = class extends BaseConnector {
|
|
|
682
1377
|
load() {
|
|
683
1378
|
try {
|
|
684
1379
|
const raw = localStorage.getItem(STORAGE_KEY);
|
|
685
|
-
if (raw)
|
|
1380
|
+
if (raw)
|
|
1381
|
+
this.topics = new Map(JSON.parse(raw));
|
|
686
1382
|
} catch {
|
|
687
1383
|
}
|
|
688
1384
|
}
|
|
@@ -692,9 +1388,12 @@ function firstNamespace(session) {
|
|
|
692
1388
|
if (!name) return null;
|
|
693
1389
|
const v = session.namespaces[name];
|
|
694
1390
|
if (!v) return null;
|
|
695
|
-
return {
|
|
1391
|
+
return {
|
|
1392
|
+
name,
|
|
1393
|
+
value: { chains: v.chains, methods: v.methods, events: v.events }
|
|
1394
|
+
};
|
|
696
1395
|
}
|
|
697
|
-
function
|
|
1396
|
+
function withSignal2(promise, signal, onAbort) {
|
|
698
1397
|
if (!signal) return promise;
|
|
699
1398
|
if (signal.aborted) {
|
|
700
1399
|
onAbort();
|
|
@@ -720,16 +1419,28 @@ function withSignal(promise, signal, onAbort) {
|
|
|
720
1419
|
}
|
|
721
1420
|
|
|
722
1421
|
// src/core/lydian-connect.ts
|
|
1422
|
+
function injectedRdnsMap(sdkServed) {
|
|
1423
|
+
const map = {};
|
|
1424
|
+
for (const w of WALLET_CATALOG) {
|
|
1425
|
+
if (w.rdns && w.namespaces.includes("eip155") && !sdkServed.has(w.id))
|
|
1426
|
+
map[w.id] = w.rdns;
|
|
1427
|
+
}
|
|
1428
|
+
return map;
|
|
1429
|
+
}
|
|
723
1430
|
function createConnectors(config) {
|
|
724
1431
|
const app = {
|
|
725
1432
|
appName: config.appName,
|
|
726
1433
|
icon: config.icon,
|
|
727
1434
|
description: config.description
|
|
728
1435
|
};
|
|
1436
|
+
const sdk = [new MetaMaskConnector(app), new CoinbaseConnector(app)];
|
|
1437
|
+
const sdkServed = new Set(sdk.flatMap((c) => c.walletIds));
|
|
729
1438
|
return [
|
|
730
|
-
|
|
731
|
-
new
|
|
732
|
-
new WalletConnectConnector(app, {
|
|
1439
|
+
...sdk,
|
|
1440
|
+
new InjectedConnector(injectedRdnsMap(sdkServed)),
|
|
1441
|
+
new WalletConnectConnector(app, {
|
|
1442
|
+
projectId: config.walletConnectProjectId
|
|
1443
|
+
})
|
|
733
1444
|
];
|
|
734
1445
|
}
|
|
735
1446
|
var LydianConnect = class {
|
|
@@ -741,7 +1452,9 @@ var LydianConnect = class {
|
|
|
741
1452
|
}
|
|
742
1453
|
async connect(input) {
|
|
743
1454
|
if (input.chainId === void 0 || input.chainId === null) {
|
|
744
|
-
throw new Error(
|
|
1455
|
+
throw new Error(
|
|
1456
|
+
'connect() requires a chainId (a number like 137 or an "eip155:<id>" string)'
|
|
1457
|
+
);
|
|
745
1458
|
}
|
|
746
1459
|
return this.manager.connect({
|
|
747
1460
|
walletId: input.walletId,
|