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