@lydianpay/lydianconnect 1.0.0 → 1.1.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/README.md +23 -56
- package/dist/index.cjs +345 -245
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -163
- package/dist/index.d.ts +38 -163
- package/dist/index.js +346 -241
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,20 +2,26 @@ import SignClient from '@walletconnect/sign-client';
|
|
|
2
2
|
import { getSdkError } from '@walletconnect/utils';
|
|
3
3
|
|
|
4
4
|
// src/core/manager.ts
|
|
5
|
-
var
|
|
6
|
-
constructor(
|
|
5
|
+
var ConnectManager = class {
|
|
6
|
+
constructor(connectors) {
|
|
7
7
|
this.byWallet = /* @__PURE__ */ new Map();
|
|
8
8
|
this.connections = /* @__PURE__ */ new Map();
|
|
9
9
|
this.handlers = /* @__PURE__ */ new Set();
|
|
10
10
|
this.unsubs = [];
|
|
11
11
|
this.started = false;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const fallbacks = connectors.filter((c) => c.walletIds.length === 0);
|
|
13
|
+
if (fallbacks.length !== 1) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`LydianConnect requires exactly one fallback connector (empty walletIds); found ${fallbacks.length}`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
this.fallback = fallbacks[0];
|
|
19
|
+
this.all = connectors;
|
|
20
|
+
for (const connector of connectors) {
|
|
15
21
|
for (const id of connector.walletIds) this.byWallet.set(id, connector);
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
|
-
/** Wire connector event forwarding, once.
|
|
24
|
+
/** Wire connector event forwarding, once. */
|
|
19
25
|
async init() {
|
|
20
26
|
if (this.started) return;
|
|
21
27
|
this.started = true;
|
|
@@ -23,18 +29,17 @@ var LydianConnect = class {
|
|
|
23
29
|
this.unsubs.push(connector.on((event) => this.handle(event)));
|
|
24
30
|
}
|
|
25
31
|
}
|
|
26
|
-
/** SDK connector if one claims this walletId, else the
|
|
32
|
+
/** SDK connector if one claims this walletId, else the fallback. The host app is oblivious. */
|
|
27
33
|
resolve(walletId) {
|
|
28
34
|
return this.byWallet.get(walletId) ?? this.fallback;
|
|
29
35
|
}
|
|
30
|
-
async connect(
|
|
36
|
+
async connect(req) {
|
|
31
37
|
if (!this.started) await this.init();
|
|
32
|
-
const connection = await this.resolve(
|
|
33
|
-
this.connections.set(
|
|
34
|
-
this.emit({ type: "connect", walletId:
|
|
38
|
+
const connection = await this.resolve(req.walletId).connect(req);
|
|
39
|
+
this.connections.set(req.walletId, connection);
|
|
40
|
+
this.emit({ type: "connect", walletId: req.walletId, connection });
|
|
35
41
|
return connection;
|
|
36
42
|
}
|
|
37
|
-
/** Resume any live sessions across all connectors (e.g. after a page reload). */
|
|
38
43
|
async restore() {
|
|
39
44
|
if (!this.started) await this.init();
|
|
40
45
|
const restored = [];
|
|
@@ -60,7 +65,6 @@ var LydianConnect = class {
|
|
|
60
65
|
await Promise.allSettled([...this.connections.values()].map((c) => c.disconnect()));
|
|
61
66
|
this.connections.clear();
|
|
62
67
|
}
|
|
63
|
-
/** Disconnect everything and clear all connector-held state. */
|
|
64
68
|
async reset() {
|
|
65
69
|
await this.disconnect();
|
|
66
70
|
await Promise.allSettled(this.all.map((c) => c.reset()));
|
|
@@ -78,6 +82,28 @@ var LydianConnect = class {
|
|
|
78
82
|
}
|
|
79
83
|
};
|
|
80
84
|
|
|
85
|
+
// src/core/namespace.ts
|
|
86
|
+
var DEFAULT_EVM_METHODS = [
|
|
87
|
+
"eth_sendTransaction",
|
|
88
|
+
"personal_sign",
|
|
89
|
+
"eth_signTypedData_v4",
|
|
90
|
+
"wallet_switchEthereumChain"
|
|
91
|
+
];
|
|
92
|
+
var DEFAULT_EVM_EVENTS = ["chainChanged", "accountsChanged"];
|
|
93
|
+
function buildNamespace(chainId) {
|
|
94
|
+
const caip = typeof chainId === "number" ? `eip155:${chainId}` : chainId;
|
|
95
|
+
const [name, reference] = caip.split(":");
|
|
96
|
+
if (name !== "eip155" || !reference || !/^\d+$/.test(reference) || Number(reference) <= 0) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`Unsupported chain "${caip}". lydianconnect is EVM-only for now \u2014 pass a positive number or an "eip155:<id>" string.`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
name,
|
|
103
|
+
value: { chains: [caip], methods: DEFAULT_EVM_METHODS, events: DEFAULT_EVM_EVENTS }
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
81
107
|
// src/core/connector.ts
|
|
82
108
|
var BaseConnector = class {
|
|
83
109
|
constructor() {
|
|
@@ -98,41 +124,262 @@ var BaseConnector = class {
|
|
|
98
124
|
}
|
|
99
125
|
};
|
|
100
126
|
|
|
127
|
+
// src/core/app.ts
|
|
128
|
+
function deriveUrl() {
|
|
129
|
+
return typeof window !== "undefined" ? window.location.origin : "";
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/connectors/metamask/connector.ts
|
|
133
|
+
var WALLET_ID = "metamask";
|
|
134
|
+
var MetaMaskConnector = class extends BaseConnector {
|
|
135
|
+
constructor(app) {
|
|
136
|
+
super();
|
|
137
|
+
this.app = app;
|
|
138
|
+
this.type = "sdk";
|
|
139
|
+
this.walletIds = [WALLET_ID];
|
|
140
|
+
this.sdk = null;
|
|
141
|
+
this.provider = null;
|
|
142
|
+
this.listenersBound = false;
|
|
143
|
+
}
|
|
144
|
+
isAvailable() {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
async getProvider() {
|
|
148
|
+
if (this.provider) return this.provider;
|
|
149
|
+
const { MetaMaskSDK } = await import('@metamask/sdk');
|
|
150
|
+
const dappMetadata = {
|
|
151
|
+
name: this.app.appName,
|
|
152
|
+
url: deriveUrl(),
|
|
153
|
+
...this.app.icon ? { iconUrl: this.app.icon } : {}
|
|
154
|
+
};
|
|
155
|
+
const sdk = new MetaMaskSDK({ dappMetadata });
|
|
156
|
+
await sdk.init();
|
|
157
|
+
const provider = sdk.getProvider();
|
|
158
|
+
if (!provider) throw new Error("MetaMask provider unavailable");
|
|
159
|
+
this.sdk = sdk;
|
|
160
|
+
this.provider = provider;
|
|
161
|
+
this.bindEvents(provider);
|
|
162
|
+
return provider;
|
|
163
|
+
}
|
|
164
|
+
bindEvents(provider) {
|
|
165
|
+
if (this.listenersBound) return;
|
|
166
|
+
this.listenersBound = true;
|
|
167
|
+
provider.on("chainChanged", (hex) => {
|
|
168
|
+
this.emit({ type: "chainChanged", walletId: WALLET_ID, chainId: toCaip(String(hex)) });
|
|
169
|
+
});
|
|
170
|
+
provider.on("accountsChanged", (accounts) => {
|
|
171
|
+
const account = Array.isArray(accounts) ? accounts[0] : void 0;
|
|
172
|
+
if (account) this.emit({ type: "accountsChanged", walletId: WALLET_ID, account });
|
|
173
|
+
else this.emit({ type: "disconnect", walletId: WALLET_ID });
|
|
174
|
+
});
|
|
175
|
+
provider.on("disconnect", () => this.emit({ type: "disconnect", walletId: WALLET_ID }));
|
|
176
|
+
}
|
|
177
|
+
async connect(req) {
|
|
178
|
+
const provider = await this.getProvider();
|
|
179
|
+
const accounts = await provider.request({ method: "eth_requestAccounts" });
|
|
180
|
+
const account = accounts?.[0];
|
|
181
|
+
if (!account) throw new Error("MetaMask returned no account");
|
|
182
|
+
await this.ensureChain(provider, req);
|
|
183
|
+
const chainId = toCaip(await provider.request({ method: "eth_chainId" }));
|
|
184
|
+
return this.toConnection(provider, account, chainId);
|
|
185
|
+
}
|
|
186
|
+
async restore() {
|
|
187
|
+
const provider = await this.getProvider().catch(() => null);
|
|
188
|
+
if (!provider) return [];
|
|
189
|
+
const accounts = await provider.request({ method: "eth_accounts" }).catch(() => []);
|
|
190
|
+
const account = accounts?.[0];
|
|
191
|
+
if (!account) return [];
|
|
192
|
+
const chainId = toCaip(
|
|
193
|
+
await provider.request({ method: "eth_chainId" }).catch(() => "0x1")
|
|
194
|
+
);
|
|
195
|
+
return [this.toConnection(provider, account, chainId)];
|
|
196
|
+
}
|
|
197
|
+
async reset() {
|
|
198
|
+
await this.sdk?.terminate();
|
|
199
|
+
this.provider = null;
|
|
200
|
+
this.listenersBound = false;
|
|
201
|
+
}
|
|
202
|
+
/** Best-effort switch to the requested chain; leaves the wallet as-is if it's unknown to it. */
|
|
203
|
+
async ensureChain(provider, req) {
|
|
204
|
+
const wanted = req.namespace.value.chains?.[0];
|
|
205
|
+
const wantedNum = wanted ? Number(wanted.split(":")[1]) : NaN;
|
|
206
|
+
if (!Number.isFinite(wantedNum) || wantedNum <= 0) return;
|
|
207
|
+
const current = parseInt(
|
|
208
|
+
await provider.request({ method: "eth_chainId" }).catch(() => "0x0") ?? "0x0",
|
|
209
|
+
16
|
|
210
|
+
);
|
|
211
|
+
if (current === wantedNum) return;
|
|
212
|
+
await provider.request({
|
|
213
|
+
method: "wallet_switchEthereumChain",
|
|
214
|
+
params: [{ chainId: `0x${wantedNum.toString(16)}` }]
|
|
215
|
+
}).catch(() => {
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
toConnection(provider, account, chainId) {
|
|
219
|
+
return {
|
|
220
|
+
walletId: WALLET_ID,
|
|
221
|
+
account,
|
|
222
|
+
chainId,
|
|
223
|
+
request: async (args) => await provider.request({ method: args.method, params: args.params }),
|
|
224
|
+
openWallet: () => {
|
|
225
|
+
},
|
|
226
|
+
// MetaMask SDK foregrounds the wallet on request
|
|
227
|
+
disconnect: async () => {
|
|
228
|
+
await this.sdk?.terminate();
|
|
229
|
+
this.provider = null;
|
|
230
|
+
this.listenersBound = false;
|
|
231
|
+
this.emit({ type: "disconnect", walletId: WALLET_ID });
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
function toCaip(hexChainId) {
|
|
237
|
+
if (!hexChainId) return "eip155:1";
|
|
238
|
+
const num = hexChainId.startsWith("0x") ? parseInt(hexChainId, 16) : Number(hexChainId);
|
|
239
|
+
return `eip155:${Number.isFinite(num) ? num : 1}`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// src/connectors/coinbase/connector.ts
|
|
243
|
+
function rpc(provider, method, params) {
|
|
244
|
+
return provider.request({ method, params });
|
|
245
|
+
}
|
|
246
|
+
var WALLET_ID2 = "coinbase";
|
|
247
|
+
var CoinbaseConnector = class extends BaseConnector {
|
|
248
|
+
constructor(app) {
|
|
249
|
+
super();
|
|
250
|
+
this.app = app;
|
|
251
|
+
this.type = "sdk";
|
|
252
|
+
this.walletIds = [WALLET_ID2];
|
|
253
|
+
this.provider = null;
|
|
254
|
+
this.listenersBound = false;
|
|
255
|
+
}
|
|
256
|
+
isAvailable() {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
async getProvider(appChainIds) {
|
|
260
|
+
if (this.provider) return this.provider;
|
|
261
|
+
const { CoinbaseWalletSDK } = await import('@coinbase/wallet-sdk');
|
|
262
|
+
const sdk = new CoinbaseWalletSDK({
|
|
263
|
+
appName: this.app.appName,
|
|
264
|
+
appLogoUrl: this.app.icon,
|
|
265
|
+
appChainIds
|
|
266
|
+
// one-time SDK-init hint; ensureChain enforces the actual chain per connect
|
|
267
|
+
});
|
|
268
|
+
const provider = sdk.makeWeb3Provider();
|
|
269
|
+
this.provider = provider;
|
|
270
|
+
this.bindEvents(provider);
|
|
271
|
+
return provider;
|
|
272
|
+
}
|
|
273
|
+
bindEvents(provider) {
|
|
274
|
+
if (this.listenersBound) return;
|
|
275
|
+
this.listenersBound = true;
|
|
276
|
+
provider.on("chainChanged", (hex) => {
|
|
277
|
+
this.emit({ type: "chainChanged", walletId: WALLET_ID2, chainId: toCaip2(String(hex)) });
|
|
278
|
+
});
|
|
279
|
+
provider.on("accountsChanged", (accounts) => {
|
|
280
|
+
const account = Array.isArray(accounts) ? accounts[0] : void 0;
|
|
281
|
+
if (account) this.emit({ type: "accountsChanged", walletId: WALLET_ID2, account });
|
|
282
|
+
else this.emit({ type: "disconnect", walletId: WALLET_ID2 });
|
|
283
|
+
});
|
|
284
|
+
provider.on("disconnect", () => this.emit({ type: "disconnect", walletId: WALLET_ID2 }));
|
|
285
|
+
}
|
|
286
|
+
async connect(req) {
|
|
287
|
+
const provider = await this.getProvider(evmChainIds(req));
|
|
288
|
+
const accounts = await rpc(provider, "eth_requestAccounts");
|
|
289
|
+
const account = accounts?.[0];
|
|
290
|
+
if (!account) throw new Error("Coinbase Wallet returned no account");
|
|
291
|
+
await this.ensureChain(provider, req);
|
|
292
|
+
const chainId = toCaip2(await rpc(provider, "eth_chainId"));
|
|
293
|
+
return this.toConnection(provider, account, chainId);
|
|
294
|
+
}
|
|
295
|
+
async restore() {
|
|
296
|
+
const provider = await this.getProvider().catch(() => null);
|
|
297
|
+
if (!provider) return [];
|
|
298
|
+
const accounts = await rpc(provider, "eth_accounts").catch(() => []);
|
|
299
|
+
const account = accounts?.[0];
|
|
300
|
+
if (!account) return [];
|
|
301
|
+
const chainId = toCaip2(await rpc(provider, "eth_chainId").catch(() => "0x1"));
|
|
302
|
+
return [this.toConnection(provider, account, chainId)];
|
|
303
|
+
}
|
|
304
|
+
async reset() {
|
|
305
|
+
await this.provider?.disconnect().catch(() => {
|
|
306
|
+
});
|
|
307
|
+
this.provider = null;
|
|
308
|
+
this.listenersBound = false;
|
|
309
|
+
}
|
|
310
|
+
async ensureChain(provider, req) {
|
|
311
|
+
const wanted = req.namespace.value.chains?.[0];
|
|
312
|
+
const wantedNum = wanted ? Number(wanted.split(":")[1]) : NaN;
|
|
313
|
+
if (!Number.isFinite(wantedNum) || wantedNum <= 0) return;
|
|
314
|
+
const current = parseInt(
|
|
315
|
+
await rpc(provider, "eth_chainId").catch(() => "0x0") ?? "0x0",
|
|
316
|
+
16
|
|
317
|
+
);
|
|
318
|
+
if (current === wantedNum) return;
|
|
319
|
+
await rpc(provider, "wallet_switchEthereumChain", [{ chainId: `0x${wantedNum.toString(16)}` }]).catch(
|
|
320
|
+
() => {
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
toConnection(provider, account, chainId) {
|
|
325
|
+
return {
|
|
326
|
+
walletId: WALLET_ID2,
|
|
327
|
+
account,
|
|
328
|
+
chainId,
|
|
329
|
+
request: (args) => rpc(provider, args.method, args.params),
|
|
330
|
+
openWallet: () => {
|
|
331
|
+
},
|
|
332
|
+
// Coinbase SDK foregrounds the wallet on request
|
|
333
|
+
disconnect: async () => {
|
|
334
|
+
await provider.disconnect().catch(() => {
|
|
335
|
+
});
|
|
336
|
+
this.provider = null;
|
|
337
|
+
this.listenersBound = false;
|
|
338
|
+
this.emit({ type: "disconnect", walletId: WALLET_ID2 });
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
function toCaip2(hexChainId) {
|
|
344
|
+
if (!hexChainId) return "eip155:1";
|
|
345
|
+
const num = hexChainId.startsWith("0x") ? parseInt(hexChainId, 16) : Number(hexChainId);
|
|
346
|
+
return `eip155:${Number.isFinite(num) ? num : 1}`;
|
|
347
|
+
}
|
|
348
|
+
function evmChainIds(req) {
|
|
349
|
+
const wanted = req.namespace.value.chains?.[0];
|
|
350
|
+
const n = wanted ? Number(wanted.split(":")[1]) : NaN;
|
|
351
|
+
return Number.isFinite(n) && n > 0 ? [n] : void 0;
|
|
352
|
+
}
|
|
353
|
+
|
|
101
354
|
// src/connectors/walletconnect/wallet-links.generated.ts
|
|
102
355
|
var GENERATED_WALLET_LINKS = {
|
|
103
|
-
metamask: { "scheme": "metamask://wc", "universal": "https://metamask.app.link/wc", "store": { "ios": "https://apps.apple.com/us/app/metamask/id1438144202", "android": "https://play.google.com/store/apps/details?id=io.metamask" } },
|
|
104
|
-
trust: { "scheme": "trust://wc", "universal": "https://link.trustwallet.com/wc", "store": { "ios": "https://apps.apple.com/app/apple-store/id1288339409", "android": "https://play.google.com/store/apps/details?id=com.wallet.crypto.trustapp" } },
|
|
105
|
-
rainbow: { "scheme": "rainbow://wc", "universal": "https://rnbwapp.com/wc", "store": { "ios": "https://apps.apple.com/app/apple-store/id1457119021?pt=119997837&ct=wc&mt=8", "android": "https://play.google.com/store/apps/details?id=me.rainbow&referrer=utm_source%3Dwc%26utm_medium%3Dconnector%26utm_campaign%3Dwc" } },
|
|
356
|
+
metamask: { "native": "metamask://", "scheme": "metamask://wc", "universal": "https://metamask.app.link/wc", "store": { "ios": "https://apps.apple.com/us/app/metamask/id1438144202", "android": "https://play.google.com/store/apps/details?id=io.metamask" } },
|
|
357
|
+
trust: { "native": "trust://", "scheme": "trust://wc", "universal": "https://link.trustwallet.com/wc", "store": { "ios": "https://apps.apple.com/app/apple-store/id1288339409", "android": "https://play.google.com/store/apps/details?id=com.wallet.crypto.trustapp" } },
|
|
358
|
+
rainbow: { "native": "rainbow://", "scheme": "rainbow://wc", "universal": "https://rnbwapp.com/wc", "store": { "ios": "https://apps.apple.com/app/apple-store/id1457119021?pt=119997837&ct=wc&mt=8", "android": "https://play.google.com/store/apps/details?id=me.rainbow&referrer=utm_source%3Dwc%26utm_medium%3Dconnector%26utm_campaign%3Dwc" } },
|
|
106
359
|
coinbase: { "store": { "ios": "https://apps.apple.com/us/app/base-formerly-coinbase-wallet/id1278383455" } },
|
|
107
|
-
zerion: { "scheme": "zerion://wc", "universal": "https://wallet.zerion.io/wc/wc", "store": { "ios": "https://apps.apple.com/app/id1456732565", "android": "https://play.google.com/store/apps/details?id=io.zerion.android&hl=en&gl=US" } },
|
|
108
|
-
tokenpocket: { "scheme": "tpoutside://wc", "store": { "ios": "https://apps.apple.com/us/app/tp-wallet/id6444625622?l=en", "android": "https://play.google.com/store/apps/details?id=vip.mytokenpocket" } },
|
|
109
|
-
blockchaincom: { "scheme": "blockchain-wallet://wc", "universal": "https://login.blockchain.com/app/wc", "store": { "ios": "https://apps.apple.com/us/app/blockchain-bitcoin-wallet/id493253309", "android": "https://play.google.com/store/apps/details?id=piuk.blockchain.android" } },
|
|
110
|
-
exodus: { "scheme": "exodus://wc", "universal": "https://exodus.com/m/wc", "store": { "ios": "https://apps.apple.com/us/app/exodus-crypto-bitcoin-wallet/id1414384820", "android": "https://play.google.com/store/apps/details?id=exodusmovement.exodus&hl=en&gl=US" } },
|
|
360
|
+
zerion: { "native": "zerion://", "scheme": "zerion://wc", "universal": "https://wallet.zerion.io/wc/wc", "store": { "ios": "https://apps.apple.com/app/id1456732565", "android": "https://play.google.com/store/apps/details?id=io.zerion.android&hl=en&gl=US" } },
|
|
361
|
+
tokenpocket: { "native": "tpoutside://", "scheme": "tpoutside://wc", "store": { "ios": "https://apps.apple.com/us/app/tp-wallet/id6444625622?l=en", "android": "https://play.google.com/store/apps/details?id=vip.mytokenpocket" } },
|
|
362
|
+
blockchaincom: { "native": "blockchain-wallet://", "scheme": "blockchain-wallet://wc", "universal": "https://login.blockchain.com/app/wc", "store": { "ios": "https://apps.apple.com/us/app/blockchain-bitcoin-wallet/id493253309", "android": "https://play.google.com/store/apps/details?id=piuk.blockchain.android" } },
|
|
363
|
+
exodus: { "native": "exodus://", "scheme": "exodus://wc", "universal": "https://exodus.com/m/wc", "store": { "ios": "https://apps.apple.com/us/app/exodus-crypto-bitcoin-wallet/id1414384820", "android": "https://play.google.com/store/apps/details?id=exodusmovement.exodus&hl=en&gl=US" } },
|
|
111
364
|
phantom: { "store": { "ios": "https://apps.apple.com/us/app/phantom-crypto-wallet/id1598432977", "android": "https://play.google.com/store/apps/details?id=app.phantom&hl=en" } },
|
|
112
|
-
okx: { "scheme": "okex://main/wc", "universal": "https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/walletConnect/wc", "store": { "ios": "https://apps.apple.com/us/app/okx-buy-bitcoin-eth-crypto/id1327268470", "android": "https://play.google.com/store/apps/details?id=com.okinc.okex.gp" } },
|
|
113
|
-
cryptocom: { "scheme": "dfw://wc", "universal": "https://wallet.crypto.com/deeplink/wc", "store": { "ios": "https://apps.apple.com/US/app/id1512048310?mt=8", "android": "https://play.google.com/store/apps/details?id=com.defi.wallet" } },
|
|
114
|
-
argent: { "scheme": "argent://app/wc", "universal": "https://www.argent.xyz/app/wc", "store": { "ios": "https://apps.apple.com/us/app/argent-defi-in-a-tap/id1358741926", "android": "https://play.google.com/store/apps/details?id=im.argent.contractwalletclient&hl=en&gl=US&pli=1" } },
|
|
115
|
-
safepal: { "scheme": "safepalwallet://wc", "universal": "https://link.safepal.io/wc", "store": { "ios": "https://apps.apple.com/app/safepal-wallet/id1548297139", "android": "https://play.google.com/store/apps/details?id=io.safepal.wallet" } },
|
|
116
|
-
imtoken: { "scheme": "imtokenv2://wc", "store": { "ios": "https://apps.apple.com/us/app/imtoken2/id1384798940", "android": "https://play.google.com/store/apps/details?id=im.token.app" } },
|
|
117
|
-
ronin: { "scheme": "roninwallet://wc", "universal": "https://wallet.roninchain.com/wc", "store": { "ios": "https://apps.apple.com/us/app/ronin-wallet/id1592675001", "android": "https://play.google.com/store/apps/details?id=com.skymavis.genesis" } },
|
|
118
|
-
coin98: { "scheme": "coin98://wc", "universal": "https://coin98.com/wc", "store": { "ios": "https://apps.apple.com/vn/app/coin98-wallet/id1561969966", "android": "https://play.google.com/store/apps/details?id=coin98.crypto.finance.media&hl=vi&gl=US" } },
|
|
119
|
-
bitkeep: { "scheme": "bitkeep://wc", "universal": "https://bkapp.vip/wc", "store": { "ios": "https://web3.bitget.com/en/wallet-download?type=0", "android": "https://web3.bitget.com/en/wallet-download?type=0" } },
|
|
120
|
-
"1inch": { "scheme": "oneinch://open/nobodywilleveruseit/wc", "universal": "https://wallet.1inch.io/app/nobodywilleveruseit/wc", "store": { "ios": "https://apps.apple.com/us/app/1inch-defi-wallet/id1546049391", "android": "https://play.google.com/store/apps/details?id=io.oneinch.android" } },
|
|
121
|
-
ledgerlive: { "scheme": "ledgerlive://wc", "store": { "ios": "https://itunes.apple.com/app/id1361671700", "android": "https://play.google.com/store/apps/details?id=com.ledger.live" } },
|
|
122
|
-
atomic: { "scheme": "atomicwallet://wc", "store": { "ios": "https://apps.apple.com/us/app/atomic-wallet/id1478257827", "android": "https://play.google.com/store/apps/details?id=io.atomicwallet" } },
|
|
123
|
-
alpha: { "scheme": "awallet://wc", "universal": "https://aw.app/wc", "store": { "ios": "https://apps.apple.com/us/app/alphawallet-eth-wallet/id1358230430", "android": "https://play.google.com/store/apps/details?id=io.stormbird.wallet" } },
|
|
124
|
-
math: { "scheme": "mathwallet://wc", "universal": "https://www.mathwallet.org/wc", "store": { "ios": "https://apps.apple.com/us/app/mathwallet5/id1582612388", "android": "https://play.google.com/store/apps/details?id=com.mathwallet.android" } },
|
|
125
|
-
bitpay: { "scheme": "bitpay://wc", "universal": "https://link.bitpay.com/wc", "store": { "ios": "https://bitpay.onelink.me/Cenw/ejjaw7bs", "android": "https://bitpay.onelink.me/Cenw/ejjaw7bs" } }
|
|
365
|
+
okx: { "native": "okex://main", "scheme": "okex://main/wc", "universal": "https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/walletConnect/wc", "store": { "ios": "https://apps.apple.com/us/app/okx-buy-bitcoin-eth-crypto/id1327268470", "android": "https://play.google.com/store/apps/details?id=com.okinc.okex.gp" } },
|
|
366
|
+
cryptocom: { "native": "dfw://", "scheme": "dfw://wc", "universal": "https://wallet.crypto.com/deeplink/wc", "store": { "ios": "https://apps.apple.com/US/app/id1512048310?mt=8", "android": "https://play.google.com/store/apps/details?id=com.defi.wallet" } },
|
|
367
|
+
argent: { "native": "argent://app/", "scheme": "argent://app/wc", "universal": "https://www.argent.xyz/app/wc", "store": { "ios": "https://apps.apple.com/us/app/argent-defi-in-a-tap/id1358741926", "android": "https://play.google.com/store/apps/details?id=im.argent.contractwalletclient&hl=en&gl=US&pli=1" } },
|
|
368
|
+
safepal: { "native": "safepalwallet://", "scheme": "safepalwallet://wc", "universal": "https://link.safepal.io/wc", "store": { "ios": "https://apps.apple.com/app/safepal-wallet/id1548297139", "android": "https://play.google.com/store/apps/details?id=io.safepal.wallet" } },
|
|
369
|
+
imtoken: { "native": "imtokenv2://", "scheme": "imtokenv2://wc", "store": { "ios": "https://apps.apple.com/us/app/imtoken2/id1384798940", "android": "https://play.google.com/store/apps/details?id=im.token.app" } },
|
|
370
|
+
ronin: { "native": "roninwallet://", "scheme": "roninwallet://wc", "universal": "https://wallet.roninchain.com/wc", "store": { "ios": "https://apps.apple.com/us/app/ronin-wallet/id1592675001", "android": "https://play.google.com/store/apps/details?id=com.skymavis.genesis" } },
|
|
371
|
+
coin98: { "native": "coin98://", "scheme": "coin98://wc", "universal": "https://coin98.com/wc", "store": { "ios": "https://apps.apple.com/vn/app/coin98-wallet/id1561969966", "android": "https://play.google.com/store/apps/details?id=coin98.crypto.finance.media&hl=vi&gl=US" } },
|
|
372
|
+
bitkeep: { "native": "bitkeep://", "scheme": "bitkeep://wc", "universal": "https://bkapp.vip/wc", "store": { "ios": "https://web3.bitget.com/en/wallet-download?type=0", "android": "https://web3.bitget.com/en/wallet-download?type=0" } },
|
|
373
|
+
"1inch": { "native": "oneinch://open/nobodywilleveruseit", "scheme": "oneinch://open/nobodywilleveruseit/wc", "universal": "https://wallet.1inch.io/app/nobodywilleveruseit/wc", "store": { "ios": "https://apps.apple.com/us/app/1inch-defi-wallet/id1546049391", "android": "https://play.google.com/store/apps/details?id=io.oneinch.android" } },
|
|
374
|
+
ledgerlive: { "native": "ledgerlive://", "scheme": "ledgerlive://wc", "store": { "ios": "https://itunes.apple.com/app/id1361671700", "android": "https://play.google.com/store/apps/details?id=com.ledger.live" } },
|
|
375
|
+
atomic: { "native": "atomicwallet://", "scheme": "atomicwallet://wc", "store": { "ios": "https://apps.apple.com/us/app/atomic-wallet/id1478257827", "android": "https://play.google.com/store/apps/details?id=io.atomicwallet" } },
|
|
376
|
+
alpha: { "native": "awallet://", "scheme": "awallet://wc", "universal": "https://aw.app/wc", "store": { "ios": "https://apps.apple.com/us/app/alphawallet-eth-wallet/id1358230430", "android": "https://play.google.com/store/apps/details?id=io.stormbird.wallet" } },
|
|
377
|
+
math: { "native": "mathwallet://", "scheme": "mathwallet://wc", "universal": "https://www.mathwallet.org/wc", "store": { "ios": "https://apps.apple.com/us/app/mathwallet5/id1582612388", "android": "https://play.google.com/store/apps/details?id=com.mathwallet.android" } },
|
|
378
|
+
bitpay: { "native": "bitpay://", "scheme": "bitpay://wc", "universal": "https://link.bitpay.com/wc", "store": { "ios": "https://bitpay.onelink.me/Cenw/ejjaw7bs", "android": "https://bitpay.onelink.me/Cenw/ejjaw7bs" } }
|
|
126
379
|
};
|
|
127
380
|
|
|
128
381
|
// src/connectors/walletconnect/registry.ts
|
|
129
|
-
var
|
|
130
|
-
infinity: { scheme: "infinity://wc" }
|
|
131
|
-
};
|
|
132
|
-
var DEFAULT_WALLET_LINKS = {
|
|
133
|
-
...MANUAL_WALLET_LINKS,
|
|
134
|
-
...GENERATED_WALLET_LINKS
|
|
135
|
-
};
|
|
382
|
+
var DEFAULT_WALLET_LINKS = GENERATED_WALLET_LINKS;
|
|
136
383
|
|
|
137
384
|
// src/connectors/walletconnect/deeplink.ts
|
|
138
385
|
function isMobile() {
|
|
@@ -153,6 +400,11 @@ function openWallet(link, uri) {
|
|
|
153
400
|
openHref(buildLink(link.scheme, uri), false);
|
|
154
401
|
}
|
|
155
402
|
}
|
|
403
|
+
function openWalletApp(link) {
|
|
404
|
+
if (typeof document === "undefined") return;
|
|
405
|
+
if (!link.native) return;
|
|
406
|
+
openHref(link.native, false);
|
|
407
|
+
}
|
|
156
408
|
function openHref(href, newContext) {
|
|
157
409
|
const a = document.createElement("a");
|
|
158
410
|
a.href = href;
|
|
@@ -190,9 +442,10 @@ function detectAppOpen(timeoutMs) {
|
|
|
190
442
|
// src/connectors/walletconnect/connector.ts
|
|
191
443
|
var STORAGE_KEY = "lydianconnect.wc.topics";
|
|
192
444
|
var WalletConnectConnector = class extends BaseConnector {
|
|
193
|
-
constructor(
|
|
445
|
+
constructor(app, options) {
|
|
194
446
|
super();
|
|
195
|
-
this.
|
|
447
|
+
this.app = app;
|
|
448
|
+
this.options = options;
|
|
196
449
|
this.type = "walletconnect";
|
|
197
450
|
this.walletIds = [];
|
|
198
451
|
// claims any wallet not served by an SDK connector
|
|
@@ -200,7 +453,7 @@ var WalletConnectConnector = class extends BaseConnector {
|
|
|
200
453
|
this.topics = /* @__PURE__ */ new Map();
|
|
201
454
|
this.warm = null;
|
|
202
455
|
this.warming = null;
|
|
203
|
-
this.links = { ...DEFAULT_WALLET_LINKS, ...
|
|
456
|
+
this.links = { ...DEFAULT_WALLET_LINKS, ...options.walletLinks ?? {} };
|
|
204
457
|
}
|
|
205
458
|
isAvailable() {
|
|
206
459
|
return true;
|
|
@@ -208,9 +461,14 @@ var WalletConnectConnector = class extends BaseConnector {
|
|
|
208
461
|
async getClient() {
|
|
209
462
|
if (this.client) return this.client;
|
|
210
463
|
const client = await SignClient.init({
|
|
211
|
-
projectId: this.
|
|
212
|
-
metadata:
|
|
213
|
-
|
|
464
|
+
projectId: this.options.projectId,
|
|
465
|
+
metadata: {
|
|
466
|
+
name: this.app.appName,
|
|
467
|
+
description: this.app.description ?? this.app.appName,
|
|
468
|
+
url: deriveUrl(),
|
|
469
|
+
icons: this.app.icon ? [this.app.icon] : []
|
|
470
|
+
},
|
|
471
|
+
relayUrl: this.options.relayUrl
|
|
214
472
|
});
|
|
215
473
|
client.on("session_delete", ({ topic }) => {
|
|
216
474
|
const walletId = this.walletForTopic(topic);
|
|
@@ -260,7 +518,7 @@ var WalletConnectConnector = class extends BaseConnector {
|
|
|
260
518
|
const link = this.links[req.walletId];
|
|
261
519
|
if (link) {
|
|
262
520
|
openWallet(link, warm.uri);
|
|
263
|
-
void detectAppOpen(this.
|
|
521
|
+
void detectAppOpen(this.options.openTimeoutMs ?? 2e3).then((opened) => {
|
|
264
522
|
if (!opened) this.emit({ type: "wallet_open_failed", walletId: req.walletId, uri: warm.uri });
|
|
265
523
|
});
|
|
266
524
|
}
|
|
@@ -333,6 +591,11 @@ var WalletConnectConnector = class extends BaseConnector {
|
|
|
333
591
|
chainId,
|
|
334
592
|
request: { method: args.method, params: args.params }
|
|
335
593
|
}),
|
|
594
|
+
openWallet: () => {
|
|
595
|
+
if (!isMobile()) return;
|
|
596
|
+
const link = this.links[walletId];
|
|
597
|
+
if (link) openWalletApp(link);
|
|
598
|
+
},
|
|
336
599
|
disconnect: async () => {
|
|
337
600
|
await client.disconnect({ topic, reason: getSdkError("USER_DISCONNECTED") }).catch(() => {
|
|
338
601
|
});
|
|
@@ -399,211 +662,53 @@ function withSignal(promise, signal, onAbort) {
|
|
|
399
662
|
});
|
|
400
663
|
}
|
|
401
664
|
|
|
402
|
-
// src/
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
isAvailable() {
|
|
415
|
-
return true;
|
|
416
|
-
}
|
|
417
|
-
async getProvider() {
|
|
418
|
-
if (this.provider) return this.provider;
|
|
419
|
-
const { MetaMaskSDK } = await import('@metamask/sdk');
|
|
420
|
-
const sdk = new MetaMaskSDK({
|
|
421
|
-
dappMetadata: this.config.dappMetadata,
|
|
422
|
-
...this.config.sdkOptions
|
|
423
|
-
});
|
|
424
|
-
await sdk.init();
|
|
425
|
-
const provider = sdk.getProvider();
|
|
426
|
-
if (!provider) throw new Error("MetaMask provider unavailable");
|
|
427
|
-
this.sdk = sdk;
|
|
428
|
-
this.provider = provider;
|
|
429
|
-
this.bindEvents(provider);
|
|
430
|
-
return provider;
|
|
431
|
-
}
|
|
432
|
-
bindEvents(provider) {
|
|
433
|
-
if (this.listenersBound) return;
|
|
434
|
-
this.listenersBound = true;
|
|
435
|
-
provider.on("chainChanged", (hex) => {
|
|
436
|
-
this.emit({ type: "chainChanged", walletId: WALLET_ID, chainId: toCaip(String(hex)) });
|
|
437
|
-
});
|
|
438
|
-
provider.on("accountsChanged", (accounts) => {
|
|
439
|
-
const account = Array.isArray(accounts) ? accounts[0] : void 0;
|
|
440
|
-
if (account) this.emit({ type: "accountsChanged", walletId: WALLET_ID, account });
|
|
441
|
-
else this.emit({ type: "disconnect", walletId: WALLET_ID });
|
|
442
|
-
});
|
|
443
|
-
provider.on("disconnect", () => this.emit({ type: "disconnect", walletId: WALLET_ID }));
|
|
444
|
-
}
|
|
445
|
-
async connect(req) {
|
|
446
|
-
const provider = await this.getProvider();
|
|
447
|
-
const accounts = await provider.request({ method: "eth_requestAccounts" });
|
|
448
|
-
const account = accounts?.[0];
|
|
449
|
-
if (!account) throw new Error("MetaMask returned no account");
|
|
450
|
-
await this.ensureChain(provider, req);
|
|
451
|
-
const chainId = toCaip(await provider.request({ method: "eth_chainId" }));
|
|
452
|
-
return this.toConnection(provider, account, chainId);
|
|
453
|
-
}
|
|
454
|
-
async restore() {
|
|
455
|
-
const provider = await this.getProvider().catch(() => null);
|
|
456
|
-
if (!provider) return [];
|
|
457
|
-
const accounts = await provider.request({ method: "eth_accounts" }).catch(() => []);
|
|
458
|
-
const account = accounts?.[0];
|
|
459
|
-
if (!account) return [];
|
|
460
|
-
const chainId = toCaip(
|
|
461
|
-
await provider.request({ method: "eth_chainId" }).catch(() => "0x1")
|
|
462
|
-
);
|
|
463
|
-
return [this.toConnection(provider, account, chainId)];
|
|
464
|
-
}
|
|
465
|
-
async reset() {
|
|
466
|
-
await this.sdk?.terminate();
|
|
467
|
-
this.provider = null;
|
|
468
|
-
this.listenersBound = false;
|
|
469
|
-
}
|
|
470
|
-
/** Best-effort switch to the requested chain; leaves the wallet as-is if it's unknown to it. */
|
|
471
|
-
async ensureChain(provider, req) {
|
|
472
|
-
const wanted = req.namespace.value.chains?.[0];
|
|
473
|
-
const wantedNum = wanted ? Number(wanted.split(":")[1]) : NaN;
|
|
474
|
-
if (!Number.isFinite(wantedNum) || wantedNum <= 0) return;
|
|
475
|
-
const current = parseInt(
|
|
476
|
-
await provider.request({ method: "eth_chainId" }).catch(() => "0x0") ?? "0x0",
|
|
477
|
-
16
|
|
478
|
-
);
|
|
479
|
-
if (current === wantedNum) return;
|
|
480
|
-
await provider.request({
|
|
481
|
-
method: "wallet_switchEthereumChain",
|
|
482
|
-
params: [{ chainId: `0x${wantedNum.toString(16)}` }]
|
|
483
|
-
}).catch(() => {
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
toConnection(provider, account, chainId) {
|
|
487
|
-
return {
|
|
488
|
-
walletId: WALLET_ID,
|
|
489
|
-
account,
|
|
490
|
-
chainId,
|
|
491
|
-
request: async (args) => await provider.request({ method: args.method, params: args.params }),
|
|
492
|
-
disconnect: async () => {
|
|
493
|
-
await this.sdk?.terminate();
|
|
494
|
-
this.provider = null;
|
|
495
|
-
this.listenersBound = false;
|
|
496
|
-
this.emit({ type: "disconnect", walletId: WALLET_ID });
|
|
497
|
-
}
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
function toCaip(hexChainId) {
|
|
502
|
-
if (!hexChainId) return "eip155:1";
|
|
503
|
-
const num = hexChainId.startsWith("0x") ? parseInt(hexChainId, 16) : Number(hexChainId);
|
|
504
|
-
return `eip155:${Number.isFinite(num) ? num : 1}`;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// src/connectors/coinbase/connector.ts
|
|
508
|
-
function rpc(provider, method, params) {
|
|
509
|
-
return provider.request({ method, params });
|
|
665
|
+
// src/core/lydian-connect.ts
|
|
666
|
+
function createConnectors(config) {
|
|
667
|
+
const app = {
|
|
668
|
+
appName: config.appName,
|
|
669
|
+
icon: config.icon,
|
|
670
|
+
description: config.description
|
|
671
|
+
};
|
|
672
|
+
return [
|
|
673
|
+
new MetaMaskConnector(app),
|
|
674
|
+
new CoinbaseConnector(app),
|
|
675
|
+
new WalletConnectConnector(app, { projectId: config.walletConnectProjectId })
|
|
676
|
+
];
|
|
510
677
|
}
|
|
511
|
-
var
|
|
512
|
-
var CoinbaseConnector = class extends BaseConnector {
|
|
678
|
+
var LydianConnect = class {
|
|
513
679
|
constructor(config) {
|
|
514
|
-
|
|
515
|
-
this.config = config;
|
|
516
|
-
this.type = "sdk";
|
|
517
|
-
this.walletIds = [WALLET_ID2];
|
|
518
|
-
this.provider = null;
|
|
519
|
-
this.listenersBound = false;
|
|
680
|
+
this.manager = new ConnectManager(createConnectors(config));
|
|
520
681
|
}
|
|
521
|
-
|
|
522
|
-
return
|
|
682
|
+
init() {
|
|
683
|
+
return this.manager.init();
|
|
523
684
|
}
|
|
524
|
-
async
|
|
525
|
-
if (
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
685
|
+
async connect(input) {
|
|
686
|
+
if (input.chainId === void 0 || input.chainId === null) {
|
|
687
|
+
throw new Error('connect() requires a chainId (a number like 137 or an "eip155:<id>" string)');
|
|
688
|
+
}
|
|
689
|
+
return this.manager.connect({
|
|
690
|
+
walletId: input.walletId,
|
|
691
|
+
namespace: buildNamespace(input.chainId),
|
|
692
|
+
signal: input.signal
|
|
531
693
|
});
|
|
532
|
-
const provider = sdk.makeWeb3Provider();
|
|
533
|
-
this.provider = provider;
|
|
534
|
-
this.bindEvents(provider);
|
|
535
|
-
return provider;
|
|
536
694
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
this.listenersBound = true;
|
|
540
|
-
provider.on("chainChanged", (hex) => {
|
|
541
|
-
this.emit({ type: "chainChanged", walletId: WALLET_ID2, chainId: toCaip2(String(hex)) });
|
|
542
|
-
});
|
|
543
|
-
provider.on("accountsChanged", (accounts) => {
|
|
544
|
-
const account = Array.isArray(accounts) ? accounts[0] : void 0;
|
|
545
|
-
if (account) this.emit({ type: "accountsChanged", walletId: WALLET_ID2, account });
|
|
546
|
-
else this.emit({ type: "disconnect", walletId: WALLET_ID2 });
|
|
547
|
-
});
|
|
548
|
-
provider.on("disconnect", () => this.emit({ type: "disconnect", walletId: WALLET_ID2 }));
|
|
695
|
+
restore() {
|
|
696
|
+
return this.manager.restore();
|
|
549
697
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
const accounts = await rpc(provider, "eth_requestAccounts");
|
|
553
|
-
const account = accounts?.[0];
|
|
554
|
-
if (!account) throw new Error("Coinbase Wallet returned no account");
|
|
555
|
-
await this.ensureChain(provider, req);
|
|
556
|
-
const chainId = toCaip2(await rpc(provider, "eth_chainId"));
|
|
557
|
-
return this.toConnection(provider, account, chainId);
|
|
698
|
+
disconnect(walletId) {
|
|
699
|
+
return this.manager.disconnect(walletId);
|
|
558
700
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
if (!provider) return [];
|
|
562
|
-
const accounts = await rpc(provider, "eth_accounts").catch(() => []);
|
|
563
|
-
const account = accounts?.[0];
|
|
564
|
-
if (!account) return [];
|
|
565
|
-
const chainId = toCaip2(await rpc(provider, "eth_chainId").catch(() => "0x1"));
|
|
566
|
-
return [this.toConnection(provider, account, chainId)];
|
|
567
|
-
}
|
|
568
|
-
async reset() {
|
|
569
|
-
await this.provider?.disconnect().catch(() => {
|
|
570
|
-
});
|
|
571
|
-
this.provider = null;
|
|
572
|
-
this.listenersBound = false;
|
|
701
|
+
reset() {
|
|
702
|
+
return this.manager.reset();
|
|
573
703
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
const wantedNum = wanted ? Number(wanted.split(":")[1]) : NaN;
|
|
577
|
-
if (!Number.isFinite(wantedNum) || wantedNum <= 0) return;
|
|
578
|
-
const current = parseInt(await rpc(provider, "eth_chainId").catch(() => "0x0"), 16);
|
|
579
|
-
if (current === wantedNum) return;
|
|
580
|
-
await rpc(provider, "wallet_switchEthereumChain", [{ chainId: `0x${wantedNum.toString(16)}` }]).catch(
|
|
581
|
-
() => {
|
|
582
|
-
}
|
|
583
|
-
);
|
|
704
|
+
get(walletId) {
|
|
705
|
+
return this.manager.get(walletId);
|
|
584
706
|
}
|
|
585
|
-
|
|
586
|
-
return
|
|
587
|
-
walletId: WALLET_ID2,
|
|
588
|
-
account,
|
|
589
|
-
chainId,
|
|
590
|
-
request: (args) => rpc(provider, args.method, args.params),
|
|
591
|
-
disconnect: async () => {
|
|
592
|
-
await provider.disconnect().catch(() => {
|
|
593
|
-
});
|
|
594
|
-
this.provider = null;
|
|
595
|
-
this.listenersBound = false;
|
|
596
|
-
this.emit({ type: "disconnect", walletId: WALLET_ID2 });
|
|
597
|
-
}
|
|
598
|
-
};
|
|
707
|
+
on(handler) {
|
|
708
|
+
return this.manager.on(handler);
|
|
599
709
|
}
|
|
600
710
|
};
|
|
601
|
-
function toCaip2(hexChainId) {
|
|
602
|
-
if (!hexChainId) return "eip155:1";
|
|
603
|
-
const num = hexChainId.startsWith("0x") ? parseInt(hexChainId, 16) : Number(hexChainId);
|
|
604
|
-
return `eip155:${Number.isFinite(num) ? num : 1}`;
|
|
605
|
-
}
|
|
606
711
|
|
|
607
|
-
export {
|
|
712
|
+
export { LydianConnect };
|
|
608
713
|
//# sourceMappingURL=index.js.map
|
|
609
714
|
//# sourceMappingURL=index.js.map
|