@tomo-inc/wallet-adaptor-base 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +53 -70
- package/dist/index.d.cts +8 -21
- package/dist/index.d.ts +8 -21
- package/dist/index.js +54 -68
- package/package.json +2 -1
- package/src/__tests__/wallet-standard.test.ts +4 -4
- package/src/index.ts +3 -3
- package/src/type.ts +6 -25
- package/src/utils/wallet-config.ts +1 -1
- package/src/wallets/detector.ts +28 -28
- package/src/wallets/index.ts +1 -1
- package/src/wallets/wallet-eip6963.ts +6 -4
- package/src/wallets/wallet-standard.ts +12 -8
- package/src/wallets/wallet-walletconnect.ts +16 -6
- /package/src/wallets/{Wallet.ts → types.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var walletUtils = require('@tomo-inc/wallet-utils');
|
|
3
4
|
var chains = require('viem/chains');
|
|
4
5
|
var core = require('@wallet-standard/core');
|
|
5
6
|
var walletConnectProtocol = require('@tomo-inc/wallet-connect-protocol');
|
|
@@ -116,24 +117,6 @@ var getAllWallets = async (baseUrl) => {
|
|
|
116
117
|
const walletList = allWallets = walletListData == null ? void 0 : walletListData.data;
|
|
117
118
|
return walletList;
|
|
118
119
|
};
|
|
119
|
-
|
|
120
|
-
// src/type.ts
|
|
121
|
-
var ProviderProtocol = /* @__PURE__ */ ((ProviderProtocol2) => {
|
|
122
|
-
ProviderProtocol2["EIP6963"] = "eip6963";
|
|
123
|
-
ProviderProtocol2["WALLET_STANDARD"] = "wallet-standard";
|
|
124
|
-
ProviderProtocol2["WALLET_CONNECT"] = "wallet-connect";
|
|
125
|
-
ProviderProtocol2["INJECT"] = "inject";
|
|
126
|
-
return ProviderProtocol2;
|
|
127
|
-
})(ProviderProtocol || {});
|
|
128
|
-
var ProviderChainType = /* @__PURE__ */ ((ProviderChainType2) => {
|
|
129
|
-
ProviderChainType2["inject"] = "inject";
|
|
130
|
-
ProviderChainType2["deeplink"] = "deeplink";
|
|
131
|
-
ProviderChainType2["walletConnect"] = "walletConnect";
|
|
132
|
-
return ProviderChainType2;
|
|
133
|
-
})(ProviderChainType || {});
|
|
134
|
-
var SupportedChainTypes = ["evm", "solana", "aptos", "dogecoin"];
|
|
135
|
-
|
|
136
|
-
// src/wallets/detector.ts
|
|
137
120
|
function getEvmExplicitInjectedProvider(flag) {
|
|
138
121
|
const _window = typeof window !== "undefined" ? window : void 0;
|
|
139
122
|
if (typeof _window === "undefined" || typeof _window.ethereum === "undefined") return;
|
|
@@ -258,42 +241,39 @@ function tomoConnectorDector(wallet) {
|
|
|
258
241
|
const isAptosExists = hasInjectedProvider(aptosNS);
|
|
259
242
|
const isDogecoinExists = hasInjectedProvider(dogecoinNS);
|
|
260
243
|
const isInstalled = isEvmExists || isSolanaExists || isAptosExists || isDogecoinExists;
|
|
244
|
+
const DEFAULT_PROVIDER = {
|
|
245
|
+
provider: void 0,
|
|
246
|
+
protocol: void 0,
|
|
247
|
+
standard: walletUtils.ProviderStandard.NORMAL
|
|
248
|
+
};
|
|
261
249
|
const providers = {};
|
|
262
250
|
if (evmNS.namespace || evmNS.flag) {
|
|
263
251
|
providers.evm = isEvmExists ? {
|
|
264
252
|
provider: getInjectedProvider(evmNS),
|
|
265
|
-
protocol:
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
protocol: void 0
|
|
269
|
-
};
|
|
253
|
+
protocol: walletUtils.ProviderProtocol.INJECT,
|
|
254
|
+
standard: walletUtils.ProviderStandard.EIP1193
|
|
255
|
+
} : DEFAULT_PROVIDER;
|
|
270
256
|
}
|
|
271
257
|
if (solanaNS.namespace) {
|
|
272
258
|
providers.solana = isSolanaExists ? {
|
|
273
259
|
provider: getInjectedProvider(solanaNS),
|
|
274
|
-
protocol:
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
protocol: void 0
|
|
278
|
-
};
|
|
260
|
+
protocol: walletUtils.ProviderProtocol.INJECT,
|
|
261
|
+
standard: walletUtils.ProviderStandard.NORMAL
|
|
262
|
+
} : DEFAULT_PROVIDER;
|
|
279
263
|
}
|
|
280
264
|
if (aptosNS.namespace) {
|
|
281
265
|
providers.aptos = isAptosExists ? {
|
|
282
266
|
provider: getInjectedProvider(aptosNS),
|
|
283
|
-
protocol:
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
protocol: void 0
|
|
287
|
-
};
|
|
267
|
+
protocol: walletUtils.ProviderProtocol.INJECT,
|
|
268
|
+
standard: walletUtils.ProviderStandard.NORMAL
|
|
269
|
+
} : DEFAULT_PROVIDER;
|
|
288
270
|
}
|
|
289
271
|
if (dogecoinNS.namespace) {
|
|
290
272
|
providers.dogecoin = isDogecoinExists ? {
|
|
291
273
|
provider: getInjectedProvider(dogecoinNS),
|
|
292
|
-
protocol:
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
protocol: void 0
|
|
296
|
-
};
|
|
274
|
+
protocol: walletUtils.ProviderProtocol.INJECT,
|
|
275
|
+
standard: walletUtils.ProviderStandard.NORMAL
|
|
276
|
+
} : DEFAULT_PROVIDER;
|
|
297
277
|
}
|
|
298
278
|
return {
|
|
299
279
|
info: {
|
|
@@ -312,23 +292,18 @@ function tomoConnectorDector(wallet) {
|
|
|
312
292
|
}
|
|
313
293
|
},
|
|
314
294
|
isInstalled,
|
|
315
|
-
providers
|
|
295
|
+
connectors: providers
|
|
316
296
|
};
|
|
317
297
|
}
|
|
318
298
|
function wagmiConnectorDector(wallet) {
|
|
319
299
|
var _a, _b, _c, _d;
|
|
320
300
|
const tempConfig = {};
|
|
321
301
|
const connector = wallet.createConnector(tempConfig);
|
|
322
|
-
const evmNS = {
|
|
323
|
-
namespace: (wallet == null ? void 0 : wallet.namespace) || "",
|
|
324
|
-
flag: (wallet == null ? void 0 : wallet.flag) || ""
|
|
325
|
-
};
|
|
326
|
-
const isEvm = hasInjectedProvider(evmNS);
|
|
327
|
-
isEvm || wallet.installed || false;
|
|
328
302
|
const providers = {
|
|
329
303
|
evm: {
|
|
330
304
|
provider: connector,
|
|
331
|
-
protocol:
|
|
305
|
+
protocol: walletUtils.ProviderProtocol.INJECT,
|
|
306
|
+
standard: walletUtils.ProviderStandard.EIP1193
|
|
332
307
|
}
|
|
333
308
|
};
|
|
334
309
|
return {
|
|
@@ -346,7 +321,7 @@ function wagmiConnectorDector(wallet) {
|
|
|
346
321
|
}
|
|
347
322
|
},
|
|
348
323
|
isInstalled: true,
|
|
349
|
-
providers
|
|
324
|
+
connectors: providers
|
|
350
325
|
};
|
|
351
326
|
}
|
|
352
327
|
function connectorDector(wallet, connectorType) {
|
|
@@ -364,8 +339,6 @@ var getDefaultConnectors = async (baseUrl) => {
|
|
|
364
339
|
}));
|
|
365
340
|
return defaultWallets == null ? void 0 : defaultWallets.map((wallet) => connectorDector(wallet, "tomo"));
|
|
366
341
|
};
|
|
367
|
-
|
|
368
|
-
// src/wallets/wallet-eip6963.ts
|
|
369
342
|
var announceEvent = "eip6963:announceProvider";
|
|
370
343
|
var requestEvent = "eip6963:requestProvider";
|
|
371
344
|
var walletType = "evm";
|
|
@@ -396,17 +369,18 @@ async function eip6963Wallets() {
|
|
|
396
369
|
}
|
|
397
370
|
},
|
|
398
371
|
isInstalled: true,
|
|
399
|
-
|
|
372
|
+
connectors: {
|
|
400
373
|
[walletType]: {
|
|
401
374
|
provider,
|
|
402
|
-
|
|
375
|
+
standard: walletUtils.ProviderStandard.EIP1193,
|
|
376
|
+
protocol: walletUtils.ProviderProtocol.INJECT
|
|
403
377
|
}
|
|
404
378
|
}
|
|
405
379
|
});
|
|
406
380
|
}
|
|
407
381
|
}
|
|
408
382
|
} catch (error) {
|
|
409
|
-
console.warn(`${
|
|
383
|
+
console.warn(`${walletUtils.ProviderProtocol.INJECT} detect error:`, error);
|
|
410
384
|
}
|
|
411
385
|
}
|
|
412
386
|
window.addEventListener(announceEvent, handleProviderAnnouncement);
|
|
@@ -465,10 +439,11 @@ async function walletStandardWallets() {
|
|
|
465
439
|
}
|
|
466
440
|
},
|
|
467
441
|
isInstalled: true,
|
|
468
|
-
|
|
442
|
+
connectors: {
|
|
469
443
|
solana: {
|
|
470
444
|
provider: wallet.features,
|
|
471
|
-
|
|
445
|
+
standard: walletUtils.ProviderStandard.WALLET_STANDARD,
|
|
446
|
+
protocol: walletUtils.ProviderProtocol.INJECT
|
|
472
447
|
}
|
|
473
448
|
}
|
|
474
449
|
});
|
|
@@ -491,10 +466,11 @@ async function walletStandardWallets() {
|
|
|
491
466
|
}
|
|
492
467
|
},
|
|
493
468
|
isInstalled: true,
|
|
494
|
-
|
|
469
|
+
connectors: {
|
|
495
470
|
aptos: {
|
|
496
471
|
provider: wallet.features,
|
|
497
|
-
|
|
472
|
+
standard: walletUtils.ProviderStandard.WALLET_STANDARD,
|
|
473
|
+
protocol: walletUtils.ProviderProtocol.INJECT
|
|
498
474
|
}
|
|
499
475
|
}
|
|
500
476
|
});
|
|
@@ -517,10 +493,11 @@ async function walletStandardWallets() {
|
|
|
517
493
|
}
|
|
518
494
|
},
|
|
519
495
|
isInstalled: true,
|
|
520
|
-
|
|
496
|
+
connectors: {
|
|
521
497
|
sui: {
|
|
522
498
|
provider: wallet.features,
|
|
523
|
-
|
|
499
|
+
standard: walletUtils.ProviderStandard.WALLET_STANDARD,
|
|
500
|
+
protocol: walletUtils.ProviderProtocol.INJECT
|
|
524
501
|
}
|
|
525
502
|
}
|
|
526
503
|
});
|
|
@@ -1160,15 +1137,24 @@ function convertWalletToConnector(wallet) {
|
|
|
1160
1137
|
},
|
|
1161
1138
|
isInstalled: true,
|
|
1162
1139
|
// Always available
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
protocol:
|
|
1140
|
+
connectors: {
|
|
1141
|
+
[walletUtils.ChainTypeEnum.EVM]: {
|
|
1142
|
+
standard: walletUtils.ProviderStandard.NORMAL,
|
|
1143
|
+
protocol: walletUtils.ProviderProtocol.WALLET_CONNECT,
|
|
1144
|
+
provider: createWalletConnectEVMProvider(walletConnectConfig == null ? void 0 : walletConnectConfig.evmNamespaces)
|
|
1167
1145
|
},
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
protocol:
|
|
1146
|
+
[walletUtils.ChainTypeEnum.SOLANA]: {
|
|
1147
|
+
standard: walletUtils.ProviderStandard.NORMAL,
|
|
1148
|
+
protocol: walletUtils.ProviderProtocol.WALLET_CONNECT,
|
|
1149
|
+
provider: createWalletConnectSolanaProvider(walletConnectConfig == null ? void 0 : walletConnectConfig.solanaNamespaces)
|
|
1171
1150
|
}
|
|
1151
|
+
// [ChainTypeEnum.BITCOIN]: null,
|
|
1152
|
+
// [ChainTypeEnum.DOGECOIN]: null,
|
|
1153
|
+
// [ChainTypeEnum.APTOS]: null,
|
|
1154
|
+
// [ChainTypeEnum.COSMOS]: null,
|
|
1155
|
+
// [ChainTypeEnum.TON]: null,
|
|
1156
|
+
// [ChainTypeEnum.TRON]: null,
|
|
1157
|
+
// [ChainTypeEnum.SUI]: null,
|
|
1172
1158
|
}
|
|
1173
1159
|
};
|
|
1174
1160
|
}
|
|
@@ -1868,12 +1854,12 @@ async function loadConnectors({
|
|
|
1868
1854
|
const _connector = connectorsFromConfig.find((c) => c.info.name === connector.info.name);
|
|
1869
1855
|
if (_connector) {
|
|
1870
1856
|
_connector.isInstalled = true;
|
|
1871
|
-
_connector.
|
|
1857
|
+
_connector.connectors = __spreadValues(__spreadValues({}, _connector.connectors), connector.connectors);
|
|
1872
1858
|
} else {
|
|
1873
1859
|
connectorsFromConfig.push(connector);
|
|
1874
1860
|
}
|
|
1875
1861
|
}
|
|
1876
|
-
const allConnectors = connectorsFromConfig.filter((wallet) => chainType !== "all" ? !!wallet.
|
|
1862
|
+
const allConnectors = connectorsFromConfig.filter((wallet) => chainType !== "all" ? !!wallet.connectors[chainType] : true).sort((a, b) => {
|
|
1877
1863
|
if (a.recommoned && !b.recommoned) return -1;
|
|
1878
1864
|
if (!a.recommoned && b.recommoned) return 1;
|
|
1879
1865
|
if (a.isInstalled && !b.isInstalled) return -1;
|
|
@@ -1886,9 +1872,6 @@ async function loadConnectors({
|
|
|
1886
1872
|
};
|
|
1887
1873
|
}
|
|
1888
1874
|
|
|
1889
|
-
exports.ProviderChainType = ProviderChainType;
|
|
1890
|
-
exports.ProviderProtocol = ProviderProtocol;
|
|
1891
|
-
exports.SupportedChainTypes = SupportedChainTypes;
|
|
1892
1875
|
exports.addChain = addChain;
|
|
1893
1876
|
exports.connect = connect;
|
|
1894
1877
|
exports.connectMobile = connectMobile;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
+
import { ChainTypeEnum, ProviderProtocol, ProviderStandard } from '@tomo-inc/wallet-utils';
|
|
2
|
+
|
|
1
3
|
type WalletProvider = any;
|
|
2
|
-
declare enum ProviderProtocol {
|
|
3
|
-
EIP6963 = "eip6963",
|
|
4
|
-
WALLET_STANDARD = "wallet-standard",
|
|
5
|
-
WALLET_CONNECT = "wallet-connect",
|
|
6
|
-
INJECT = "inject"
|
|
7
|
-
}
|
|
8
|
-
declare enum ProviderChainType {
|
|
9
|
-
inject = "inject",
|
|
10
|
-
deeplink = "deeplink",
|
|
11
|
-
walletConnect = "walletConnect"
|
|
12
|
-
}
|
|
13
4
|
type WalletConnectorType = "wagmi" | "tomo";
|
|
14
|
-
type AdaptorChainType =
|
|
15
|
-
declare const SupportedChainTypes: string[];
|
|
5
|
+
type AdaptorChainType = ChainTypeEnum | "all";
|
|
16
6
|
interface WalletInfo {
|
|
17
7
|
uuid: string;
|
|
18
8
|
name: string;
|
|
@@ -45,19 +35,16 @@ interface WalletInfo {
|
|
|
45
35
|
};
|
|
46
36
|
}
|
|
47
37
|
interface ConnectorProvider {
|
|
48
|
-
provider:
|
|
38
|
+
provider: WalletProvider;
|
|
49
39
|
protocol: ProviderProtocol;
|
|
40
|
+
standard: ProviderStandard;
|
|
50
41
|
}
|
|
42
|
+
type ConnectorProviders = Partial<Record<ChainTypeEnum, ConnectorProvider | null>>;
|
|
51
43
|
interface Connector {
|
|
52
44
|
info: WalletInfo;
|
|
53
45
|
isInstalled?: boolean;
|
|
54
46
|
recommoned?: boolean;
|
|
55
|
-
|
|
56
|
-
evm?: ConnectorProvider;
|
|
57
|
-
solana?: ConnectorProvider;
|
|
58
|
-
aptos?: ConnectorProvider;
|
|
59
|
-
dogecoin?: ConnectorProvider;
|
|
60
|
-
};
|
|
47
|
+
connectors: Partial<Record<ChainTypeEnum, ConnectorProvider | null>>;
|
|
61
48
|
}
|
|
62
49
|
interface ConnectParams {
|
|
63
50
|
dappLink: string;
|
|
@@ -249,4 +236,4 @@ declare function loadConnectors({ chainType, recommendedConnectors, connectorTyp
|
|
|
249
236
|
recommoned: Connector[];
|
|
250
237
|
}>;
|
|
251
238
|
|
|
252
|
-
export { type AdaptorChainType, type BalanceParams, type ChainInfo, type ConnectParams, type Connector, type ConnectorProvider, type
|
|
239
|
+
export { type AdaptorChainType, type BalanceParams, type ChainInfo, type ConnectParams, type Connector, type ConnectorProvider, type ConnectorProviders, type ITokenInfo, type SignInParams, type WalletConfig, type WalletConnectConfig, type WalletConnectorType, type WalletInfo, type WalletOptions, type WalletProvider, addChain, connect, connectMobile, disconnect, getAllWallets, getBalance, isMobile, isWagmiConnector, loadConnectors, setWalletConnectConfig, signInWithWallet, signMessage, switchChain, walletBaseUrl };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
+
import { ChainTypeEnum, ProviderProtocol, ProviderStandard } from '@tomo-inc/wallet-utils';
|
|
2
|
+
|
|
1
3
|
type WalletProvider = any;
|
|
2
|
-
declare enum ProviderProtocol {
|
|
3
|
-
EIP6963 = "eip6963",
|
|
4
|
-
WALLET_STANDARD = "wallet-standard",
|
|
5
|
-
WALLET_CONNECT = "wallet-connect",
|
|
6
|
-
INJECT = "inject"
|
|
7
|
-
}
|
|
8
|
-
declare enum ProviderChainType {
|
|
9
|
-
inject = "inject",
|
|
10
|
-
deeplink = "deeplink",
|
|
11
|
-
walletConnect = "walletConnect"
|
|
12
|
-
}
|
|
13
4
|
type WalletConnectorType = "wagmi" | "tomo";
|
|
14
|
-
type AdaptorChainType =
|
|
15
|
-
declare const SupportedChainTypes: string[];
|
|
5
|
+
type AdaptorChainType = ChainTypeEnum | "all";
|
|
16
6
|
interface WalletInfo {
|
|
17
7
|
uuid: string;
|
|
18
8
|
name: string;
|
|
@@ -45,19 +35,16 @@ interface WalletInfo {
|
|
|
45
35
|
};
|
|
46
36
|
}
|
|
47
37
|
interface ConnectorProvider {
|
|
48
|
-
provider:
|
|
38
|
+
provider: WalletProvider;
|
|
49
39
|
protocol: ProviderProtocol;
|
|
40
|
+
standard: ProviderStandard;
|
|
50
41
|
}
|
|
42
|
+
type ConnectorProviders = Partial<Record<ChainTypeEnum, ConnectorProvider | null>>;
|
|
51
43
|
interface Connector {
|
|
52
44
|
info: WalletInfo;
|
|
53
45
|
isInstalled?: boolean;
|
|
54
46
|
recommoned?: boolean;
|
|
55
|
-
|
|
56
|
-
evm?: ConnectorProvider;
|
|
57
|
-
solana?: ConnectorProvider;
|
|
58
|
-
aptos?: ConnectorProvider;
|
|
59
|
-
dogecoin?: ConnectorProvider;
|
|
60
|
-
};
|
|
47
|
+
connectors: Partial<Record<ChainTypeEnum, ConnectorProvider | null>>;
|
|
61
48
|
}
|
|
62
49
|
interface ConnectParams {
|
|
63
50
|
dappLink: string;
|
|
@@ -249,4 +236,4 @@ declare function loadConnectors({ chainType, recommendedConnectors, connectorTyp
|
|
|
249
236
|
recommoned: Connector[];
|
|
250
237
|
}>;
|
|
251
238
|
|
|
252
|
-
export { type AdaptorChainType, type BalanceParams, type ChainInfo, type ConnectParams, type Connector, type ConnectorProvider, type
|
|
239
|
+
export { type AdaptorChainType, type BalanceParams, type ChainInfo, type ConnectParams, type Connector, type ConnectorProvider, type ConnectorProviders, type ITokenInfo, type SignInParams, type WalletConfig, type WalletConnectConfig, type WalletConnectorType, type WalletInfo, type WalletOptions, type WalletProvider, addChain, connect, connectMobile, disconnect, getAllWallets, getBalance, isMobile, isWagmiConnector, loadConnectors, setWalletConnectConfig, signInWithWallet, signMessage, switchChain, walletBaseUrl };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProviderProtocol, ProviderStandard, ChainTypeEnum } from '@tomo-inc/wallet-utils';
|
|
1
2
|
import { mainnet } from 'viem/chains';
|
|
2
3
|
import { getWallets } from '@wallet-standard/core';
|
|
3
4
|
import { WalletConnectClient } from '@tomo-inc/wallet-connect-protocol';
|
|
@@ -114,24 +115,6 @@ var getAllWallets = async (baseUrl) => {
|
|
|
114
115
|
const walletList = allWallets = walletListData == null ? void 0 : walletListData.data;
|
|
115
116
|
return walletList;
|
|
116
117
|
};
|
|
117
|
-
|
|
118
|
-
// src/type.ts
|
|
119
|
-
var ProviderProtocol = /* @__PURE__ */ ((ProviderProtocol2) => {
|
|
120
|
-
ProviderProtocol2["EIP6963"] = "eip6963";
|
|
121
|
-
ProviderProtocol2["WALLET_STANDARD"] = "wallet-standard";
|
|
122
|
-
ProviderProtocol2["WALLET_CONNECT"] = "wallet-connect";
|
|
123
|
-
ProviderProtocol2["INJECT"] = "inject";
|
|
124
|
-
return ProviderProtocol2;
|
|
125
|
-
})(ProviderProtocol || {});
|
|
126
|
-
var ProviderChainType = /* @__PURE__ */ ((ProviderChainType2) => {
|
|
127
|
-
ProviderChainType2["inject"] = "inject";
|
|
128
|
-
ProviderChainType2["deeplink"] = "deeplink";
|
|
129
|
-
ProviderChainType2["walletConnect"] = "walletConnect";
|
|
130
|
-
return ProviderChainType2;
|
|
131
|
-
})(ProviderChainType || {});
|
|
132
|
-
var SupportedChainTypes = ["evm", "solana", "aptos", "dogecoin"];
|
|
133
|
-
|
|
134
|
-
// src/wallets/detector.ts
|
|
135
118
|
function getEvmExplicitInjectedProvider(flag) {
|
|
136
119
|
const _window = typeof window !== "undefined" ? window : void 0;
|
|
137
120
|
if (typeof _window === "undefined" || typeof _window.ethereum === "undefined") return;
|
|
@@ -256,42 +239,39 @@ function tomoConnectorDector(wallet) {
|
|
|
256
239
|
const isAptosExists = hasInjectedProvider(aptosNS);
|
|
257
240
|
const isDogecoinExists = hasInjectedProvider(dogecoinNS);
|
|
258
241
|
const isInstalled = isEvmExists || isSolanaExists || isAptosExists || isDogecoinExists;
|
|
242
|
+
const DEFAULT_PROVIDER = {
|
|
243
|
+
provider: void 0,
|
|
244
|
+
protocol: void 0,
|
|
245
|
+
standard: ProviderStandard.NORMAL
|
|
246
|
+
};
|
|
259
247
|
const providers = {};
|
|
260
248
|
if (evmNS.namespace || evmNS.flag) {
|
|
261
249
|
providers.evm = isEvmExists ? {
|
|
262
250
|
provider: getInjectedProvider(evmNS),
|
|
263
|
-
protocol:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
protocol: void 0
|
|
267
|
-
};
|
|
251
|
+
protocol: ProviderProtocol.INJECT,
|
|
252
|
+
standard: ProviderStandard.EIP1193
|
|
253
|
+
} : DEFAULT_PROVIDER;
|
|
268
254
|
}
|
|
269
255
|
if (solanaNS.namespace) {
|
|
270
256
|
providers.solana = isSolanaExists ? {
|
|
271
257
|
provider: getInjectedProvider(solanaNS),
|
|
272
|
-
protocol:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
protocol: void 0
|
|
276
|
-
};
|
|
258
|
+
protocol: ProviderProtocol.INJECT,
|
|
259
|
+
standard: ProviderStandard.NORMAL
|
|
260
|
+
} : DEFAULT_PROVIDER;
|
|
277
261
|
}
|
|
278
262
|
if (aptosNS.namespace) {
|
|
279
263
|
providers.aptos = isAptosExists ? {
|
|
280
264
|
provider: getInjectedProvider(aptosNS),
|
|
281
|
-
protocol:
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
protocol: void 0
|
|
285
|
-
};
|
|
265
|
+
protocol: ProviderProtocol.INJECT,
|
|
266
|
+
standard: ProviderStandard.NORMAL
|
|
267
|
+
} : DEFAULT_PROVIDER;
|
|
286
268
|
}
|
|
287
269
|
if (dogecoinNS.namespace) {
|
|
288
270
|
providers.dogecoin = isDogecoinExists ? {
|
|
289
271
|
provider: getInjectedProvider(dogecoinNS),
|
|
290
|
-
protocol:
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
protocol: void 0
|
|
294
|
-
};
|
|
272
|
+
protocol: ProviderProtocol.INJECT,
|
|
273
|
+
standard: ProviderStandard.NORMAL
|
|
274
|
+
} : DEFAULT_PROVIDER;
|
|
295
275
|
}
|
|
296
276
|
return {
|
|
297
277
|
info: {
|
|
@@ -310,23 +290,18 @@ function tomoConnectorDector(wallet) {
|
|
|
310
290
|
}
|
|
311
291
|
},
|
|
312
292
|
isInstalled,
|
|
313
|
-
providers
|
|
293
|
+
connectors: providers
|
|
314
294
|
};
|
|
315
295
|
}
|
|
316
296
|
function wagmiConnectorDector(wallet) {
|
|
317
297
|
var _a, _b, _c, _d;
|
|
318
298
|
const tempConfig = {};
|
|
319
299
|
const connector = wallet.createConnector(tempConfig);
|
|
320
|
-
const evmNS = {
|
|
321
|
-
namespace: (wallet == null ? void 0 : wallet.namespace) || "",
|
|
322
|
-
flag: (wallet == null ? void 0 : wallet.flag) || ""
|
|
323
|
-
};
|
|
324
|
-
const isEvm = hasInjectedProvider(evmNS);
|
|
325
|
-
isEvm || wallet.installed || false;
|
|
326
300
|
const providers = {
|
|
327
301
|
evm: {
|
|
328
302
|
provider: connector,
|
|
329
|
-
protocol:
|
|
303
|
+
protocol: ProviderProtocol.INJECT,
|
|
304
|
+
standard: ProviderStandard.EIP1193
|
|
330
305
|
}
|
|
331
306
|
};
|
|
332
307
|
return {
|
|
@@ -344,7 +319,7 @@ function wagmiConnectorDector(wallet) {
|
|
|
344
319
|
}
|
|
345
320
|
},
|
|
346
321
|
isInstalled: true,
|
|
347
|
-
providers
|
|
322
|
+
connectors: providers
|
|
348
323
|
};
|
|
349
324
|
}
|
|
350
325
|
function connectorDector(wallet, connectorType) {
|
|
@@ -362,8 +337,6 @@ var getDefaultConnectors = async (baseUrl) => {
|
|
|
362
337
|
}));
|
|
363
338
|
return defaultWallets == null ? void 0 : defaultWallets.map((wallet) => connectorDector(wallet, "tomo"));
|
|
364
339
|
};
|
|
365
|
-
|
|
366
|
-
// src/wallets/wallet-eip6963.ts
|
|
367
340
|
var announceEvent = "eip6963:announceProvider";
|
|
368
341
|
var requestEvent = "eip6963:requestProvider";
|
|
369
342
|
var walletType = "evm";
|
|
@@ -394,17 +367,18 @@ async function eip6963Wallets() {
|
|
|
394
367
|
}
|
|
395
368
|
},
|
|
396
369
|
isInstalled: true,
|
|
397
|
-
|
|
370
|
+
connectors: {
|
|
398
371
|
[walletType]: {
|
|
399
372
|
provider,
|
|
400
|
-
|
|
373
|
+
standard: ProviderStandard.EIP1193,
|
|
374
|
+
protocol: ProviderProtocol.INJECT
|
|
401
375
|
}
|
|
402
376
|
}
|
|
403
377
|
});
|
|
404
378
|
}
|
|
405
379
|
}
|
|
406
380
|
} catch (error) {
|
|
407
|
-
console.warn(`${
|
|
381
|
+
console.warn(`${ProviderProtocol.INJECT} detect error:`, error);
|
|
408
382
|
}
|
|
409
383
|
}
|
|
410
384
|
window.addEventListener(announceEvent, handleProviderAnnouncement);
|
|
@@ -463,10 +437,11 @@ async function walletStandardWallets() {
|
|
|
463
437
|
}
|
|
464
438
|
},
|
|
465
439
|
isInstalled: true,
|
|
466
|
-
|
|
440
|
+
connectors: {
|
|
467
441
|
solana: {
|
|
468
442
|
provider: wallet.features,
|
|
469
|
-
|
|
443
|
+
standard: ProviderStandard.WALLET_STANDARD,
|
|
444
|
+
protocol: ProviderProtocol.INJECT
|
|
470
445
|
}
|
|
471
446
|
}
|
|
472
447
|
});
|
|
@@ -489,10 +464,11 @@ async function walletStandardWallets() {
|
|
|
489
464
|
}
|
|
490
465
|
},
|
|
491
466
|
isInstalled: true,
|
|
492
|
-
|
|
467
|
+
connectors: {
|
|
493
468
|
aptos: {
|
|
494
469
|
provider: wallet.features,
|
|
495
|
-
|
|
470
|
+
standard: ProviderStandard.WALLET_STANDARD,
|
|
471
|
+
protocol: ProviderProtocol.INJECT
|
|
496
472
|
}
|
|
497
473
|
}
|
|
498
474
|
});
|
|
@@ -515,10 +491,11 @@ async function walletStandardWallets() {
|
|
|
515
491
|
}
|
|
516
492
|
},
|
|
517
493
|
isInstalled: true,
|
|
518
|
-
|
|
494
|
+
connectors: {
|
|
519
495
|
sui: {
|
|
520
496
|
provider: wallet.features,
|
|
521
|
-
|
|
497
|
+
standard: ProviderStandard.WALLET_STANDARD,
|
|
498
|
+
protocol: ProviderProtocol.INJECT
|
|
522
499
|
}
|
|
523
500
|
}
|
|
524
501
|
});
|
|
@@ -1158,15 +1135,24 @@ function convertWalletToConnector(wallet) {
|
|
|
1158
1135
|
},
|
|
1159
1136
|
isInstalled: true,
|
|
1160
1137
|
// Always available
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
protocol:
|
|
1138
|
+
connectors: {
|
|
1139
|
+
[ChainTypeEnum.EVM]: {
|
|
1140
|
+
standard: ProviderStandard.NORMAL,
|
|
1141
|
+
protocol: ProviderProtocol.WALLET_CONNECT,
|
|
1142
|
+
provider: createWalletConnectEVMProvider(walletConnectConfig == null ? void 0 : walletConnectConfig.evmNamespaces)
|
|
1165
1143
|
},
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
protocol:
|
|
1144
|
+
[ChainTypeEnum.SOLANA]: {
|
|
1145
|
+
standard: ProviderStandard.NORMAL,
|
|
1146
|
+
protocol: ProviderProtocol.WALLET_CONNECT,
|
|
1147
|
+
provider: createWalletConnectSolanaProvider(walletConnectConfig == null ? void 0 : walletConnectConfig.solanaNamespaces)
|
|
1169
1148
|
}
|
|
1149
|
+
// [ChainTypeEnum.BITCOIN]: null,
|
|
1150
|
+
// [ChainTypeEnum.DOGECOIN]: null,
|
|
1151
|
+
// [ChainTypeEnum.APTOS]: null,
|
|
1152
|
+
// [ChainTypeEnum.COSMOS]: null,
|
|
1153
|
+
// [ChainTypeEnum.TON]: null,
|
|
1154
|
+
// [ChainTypeEnum.TRON]: null,
|
|
1155
|
+
// [ChainTypeEnum.SUI]: null,
|
|
1170
1156
|
}
|
|
1171
1157
|
};
|
|
1172
1158
|
}
|
|
@@ -1866,12 +1852,12 @@ async function loadConnectors({
|
|
|
1866
1852
|
const _connector = connectorsFromConfig.find((c) => c.info.name === connector.info.name);
|
|
1867
1853
|
if (_connector) {
|
|
1868
1854
|
_connector.isInstalled = true;
|
|
1869
|
-
_connector.
|
|
1855
|
+
_connector.connectors = __spreadValues(__spreadValues({}, _connector.connectors), connector.connectors);
|
|
1870
1856
|
} else {
|
|
1871
1857
|
connectorsFromConfig.push(connector);
|
|
1872
1858
|
}
|
|
1873
1859
|
}
|
|
1874
|
-
const allConnectors = connectorsFromConfig.filter((wallet) => chainType !== "all" ? !!wallet.
|
|
1860
|
+
const allConnectors = connectorsFromConfig.filter((wallet) => chainType !== "all" ? !!wallet.connectors[chainType] : true).sort((a, b) => {
|
|
1875
1861
|
if (a.recommoned && !b.recommoned) return -1;
|
|
1876
1862
|
if (!a.recommoned && b.recommoned) return 1;
|
|
1877
1863
|
if (a.isInstalled && !b.isInstalled) return -1;
|
|
@@ -1884,4 +1870,4 @@ async function loadConnectors({
|
|
|
1884
1870
|
};
|
|
1885
1871
|
}
|
|
1886
1872
|
|
|
1887
|
-
export {
|
|
1873
|
+
export { addChain, connect, connectMobile, disconnect, getAllWallets, getBalance, isMobile, isWagmiConnector, loadConnectors, setWalletConnectConfig, signInWithWallet, signMessage, switchChain, walletBaseUrl };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomo-inc/wallet-adaptor-base",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"author": "tomo.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@solana/web3.js": "^1.98.0",
|
|
23
23
|
"@wallet-standard/core": "^1.1.0",
|
|
24
24
|
"viem": "2.21.54",
|
|
25
|
+
"@tomo-inc/wallet-utils": "0.0.17",
|
|
25
26
|
"@tomo-inc/wallet-connect-protocol": "0.0.17"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderStandard } from "@tomo-inc/wallet-utils";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
3
|
import { walletStandardWallets } from "../wallets/wallet-standard";
|
|
3
|
-
import { ProviderProtocol } from "../type";
|
|
4
4
|
|
|
5
5
|
// Mock @wallet-standard/core - use vi.hoisted to avoid initialization issues
|
|
6
6
|
const { mockWallets, mockWalletsAPI } = vi.hoisted(() => {
|
|
@@ -63,7 +63,7 @@ describe("wallet-standard", () => {
|
|
|
63
63
|
|
|
64
64
|
expect(result.solanaWallets).toHaveLength(1);
|
|
65
65
|
expect(result.solanaWallets[0].info.name).toBe("Solana Wallet");
|
|
66
|
-
expect(result.solanaWallets[0].
|
|
66
|
+
expect(result.solanaWallets[0].connectors.solana?.protocol).toBe(ProviderStandard.WALLET_STANDARD);
|
|
67
67
|
expect(result.solanaWallets[0].isInstalled).toBe(true);
|
|
68
68
|
});
|
|
69
69
|
|
|
@@ -86,7 +86,7 @@ describe("wallet-standard", () => {
|
|
|
86
86
|
|
|
87
87
|
expect(result.aptosWallets).toHaveLength(1);
|
|
88
88
|
expect(result.aptosWallets[0].info.name).toBe("Aptos Wallet");
|
|
89
|
-
expect(result.aptosWallets[0].
|
|
89
|
+
expect(result.aptosWallets[0].connectors.aptos?.protocol).toBe(ProviderStandard.WALLET_STANDARD);
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it("should detect Sui wallets", async () => {
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { isWagmiConnector } from "./utils/wallet-config";
|
|
|
5
5
|
import { getAllWallets, walletBaseUrl } from "./wallets";
|
|
6
6
|
import { getDefaultConnectors } from "./wallets/defaultConnectors";
|
|
7
7
|
import { connectorDector, supportedWalletConfigTypes, walletConfigAdapter } from "./wallets/detector";
|
|
8
|
-
import { WagmiWalletConfig, WalletConfig } from "./wallets/
|
|
8
|
+
import { WagmiWalletConfig, WalletConfig } from "./wallets/types";
|
|
9
9
|
import { eip6963Wallets } from "./wallets/wallet-eip6963";
|
|
10
10
|
import { walletStandardWallets } from "./wallets/wallet-standard";
|
|
11
11
|
import { setWalletConnectConfig, walletConnectWallets } from "./wallets/wallet-walletconnect";
|
|
@@ -77,14 +77,14 @@ export async function loadConnectors({
|
|
|
77
77
|
const _connector = connectorsFromConfig.find((c) => c.info.name === connector.info.name);
|
|
78
78
|
if (_connector) {
|
|
79
79
|
_connector.isInstalled = true;
|
|
80
|
-
_connector.
|
|
80
|
+
_connector.connectors = { ..._connector.connectors, ...connector.connectors };
|
|
81
81
|
} else {
|
|
82
82
|
connectorsFromConfig.push(connector);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
const allConnectors = connectorsFromConfig
|
|
87
|
-
.filter((wallet) => (chainType !== "all" ? !!wallet.
|
|
87
|
+
.filter((wallet) => (chainType !== "all" ? !!wallet.connectors[chainType] : true))
|
|
88
88
|
.sort((a, b) => {
|
|
89
89
|
// First priority: recommoned wallets
|
|
90
90
|
if (a.recommoned && !b.recommoned) return -1;
|
package/src/type.ts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
+
import { ChainTypeEnum, ProviderProtocol, ProviderStandard } from "@tomo-inc/wallet-utils";
|
|
1
2
|
export type WalletProvider = any;
|
|
2
3
|
|
|
3
|
-
export enum ProviderProtocol {
|
|
4
|
-
EIP6963 = "eip6963",
|
|
5
|
-
WALLET_STANDARD = "wallet-standard",
|
|
6
|
-
WALLET_CONNECT = "wallet-connect",
|
|
7
|
-
INJECT = "inject",
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export enum ProviderChainType {
|
|
11
|
-
inject = "inject",
|
|
12
|
-
deeplink = "deeplink",
|
|
13
|
-
walletConnect = "walletConnect",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
4
|
export type WalletConnectorType = "wagmi" | "tomo";
|
|
17
5
|
|
|
18
|
-
export type AdaptorChainType =
|
|
19
|
-
|
|
20
|
-
export const SupportedChainTypes = ["evm", "solana", "aptos", "dogecoin"];
|
|
21
|
-
|
|
6
|
+
export type AdaptorChainType = ChainTypeEnum | "all";
|
|
22
7
|
export interface WalletInfo {
|
|
23
8
|
uuid: string;
|
|
24
9
|
name: string;
|
|
@@ -53,21 +38,17 @@ export interface WalletInfo {
|
|
|
53
38
|
}
|
|
54
39
|
|
|
55
40
|
export interface ConnectorProvider {
|
|
56
|
-
provider:
|
|
41
|
+
provider: WalletProvider;
|
|
57
42
|
protocol: ProviderProtocol;
|
|
43
|
+
standard: ProviderStandard;
|
|
58
44
|
}
|
|
59
45
|
|
|
46
|
+
export type ConnectorProviders = Partial<Record<ChainTypeEnum, ConnectorProvider | null>>;
|
|
60
47
|
export interface Connector {
|
|
61
48
|
info: WalletInfo;
|
|
62
49
|
isInstalled?: boolean;
|
|
63
50
|
recommoned?: boolean;
|
|
64
|
-
|
|
65
|
-
providers: {
|
|
66
|
-
evm?: ConnectorProvider;
|
|
67
|
-
solana?: ConnectorProvider;
|
|
68
|
-
aptos?: ConnectorProvider;
|
|
69
|
-
dogecoin?: ConnectorProvider;
|
|
70
|
-
};
|
|
51
|
+
connectors: Partial<Record<ChainTypeEnum, ConnectorProvider | null>>;
|
|
71
52
|
}
|
|
72
53
|
|
|
73
54
|
export interface ConnectParams {
|
package/src/wallets/detector.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ProviderProtocol, ProviderStandard } from "@tomo-inc/wallet-utils";
|
|
1
2
|
import { mainnet } from "viem/chains";
|
|
2
|
-
import { Connector,
|
|
3
|
-
import { WagmiWalletConfig, WalletConfig } from "./
|
|
3
|
+
import { Connector, WalletConnectorType } from "../type";
|
|
4
|
+
import { WagmiWalletConfig, WalletConfig } from "./types";
|
|
4
5
|
|
|
5
6
|
type WalletProviderFlags = string;
|
|
6
7
|
type WindowProvider = any;
|
|
@@ -194,50 +195,48 @@ function tomoConnectorDector(wallet: WalletConfig): Connector {
|
|
|
194
195
|
const isDogecoinExists = hasInjectedProvider(dogecoinNS);
|
|
195
196
|
const isInstalled = isEvmExists || isSolanaExists || isAptosExists || isDogecoinExists;
|
|
196
197
|
|
|
198
|
+
const DEFAULT_PROVIDER = {
|
|
199
|
+
provider: undefined,
|
|
200
|
+
protocol: undefined,
|
|
201
|
+
standard: ProviderStandard.NORMAL,
|
|
202
|
+
};
|
|
203
|
+
|
|
197
204
|
const providers: any = {};
|
|
198
205
|
if (evmNS.namespace || evmNS.flag) {
|
|
199
206
|
providers.evm = isEvmExists
|
|
200
207
|
? {
|
|
201
208
|
provider: getInjectedProvider(evmNS),
|
|
202
|
-
protocol: ProviderProtocol.
|
|
209
|
+
protocol: ProviderProtocol.INJECT,
|
|
210
|
+
standard: ProviderStandard.EIP1193,
|
|
203
211
|
}
|
|
204
|
-
:
|
|
205
|
-
provider: undefined,
|
|
206
|
-
protocol: undefined,
|
|
207
|
-
};
|
|
212
|
+
: DEFAULT_PROVIDER;
|
|
208
213
|
}
|
|
209
214
|
if (solanaNS.namespace) {
|
|
210
215
|
providers.solana = isSolanaExists
|
|
211
216
|
? {
|
|
212
217
|
provider: getInjectedProvider(solanaNS),
|
|
213
218
|
protocol: ProviderProtocol.INJECT,
|
|
219
|
+
standard: ProviderStandard.NORMAL,
|
|
214
220
|
}
|
|
215
|
-
:
|
|
216
|
-
provider: undefined,
|
|
217
|
-
protocol: undefined,
|
|
218
|
-
};
|
|
221
|
+
: DEFAULT_PROVIDER;
|
|
219
222
|
}
|
|
220
223
|
if (aptosNS.namespace) {
|
|
221
224
|
providers.aptos = isAptosExists
|
|
222
225
|
? {
|
|
223
226
|
provider: getInjectedProvider(aptosNS),
|
|
224
227
|
protocol: ProviderProtocol.INJECT,
|
|
228
|
+
standard: ProviderStandard.NORMAL,
|
|
225
229
|
}
|
|
226
|
-
:
|
|
227
|
-
provider: undefined,
|
|
228
|
-
protocol: undefined,
|
|
229
|
-
};
|
|
230
|
+
: DEFAULT_PROVIDER;
|
|
230
231
|
}
|
|
231
232
|
if (dogecoinNS.namespace) {
|
|
232
233
|
providers.dogecoin = isDogecoinExists
|
|
233
234
|
? {
|
|
234
235
|
provider: getInjectedProvider(dogecoinNS),
|
|
235
236
|
protocol: ProviderProtocol.INJECT,
|
|
237
|
+
standard: ProviderStandard.NORMAL,
|
|
236
238
|
}
|
|
237
|
-
:
|
|
238
|
-
provider: undefined,
|
|
239
|
-
protocol: undefined,
|
|
240
|
-
};
|
|
239
|
+
: DEFAULT_PROVIDER;
|
|
241
240
|
}
|
|
242
241
|
return {
|
|
243
242
|
info: {
|
|
@@ -256,24 +255,25 @@ function tomoConnectorDector(wallet: WalletConfig): Connector {
|
|
|
256
255
|
},
|
|
257
256
|
},
|
|
258
257
|
isInstalled,
|
|
259
|
-
providers,
|
|
258
|
+
connectors: providers,
|
|
260
259
|
};
|
|
261
260
|
}
|
|
262
261
|
|
|
263
262
|
function wagmiConnectorDector(wallet: WagmiWalletConfig): Connector {
|
|
264
263
|
const tempConfig = {} as Record<string, any>;
|
|
265
264
|
const connector = wallet.createConnector(tempConfig);
|
|
266
|
-
const evmNS = {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
};
|
|
265
|
+
// const evmNS = {
|
|
266
|
+
// namespace: wallet?.namespace || "",
|
|
267
|
+
// flag: wallet?.flag || "",
|
|
268
|
+
// };
|
|
270
269
|
|
|
271
|
-
const isEvm = hasInjectedProvider(evmNS);
|
|
272
|
-
const isInstalled = isEvm || wallet.installed || false;
|
|
270
|
+
// const isEvm = hasInjectedProvider(evmNS);
|
|
271
|
+
// const isInstalled = isEvm || wallet.installed || false;
|
|
273
272
|
const providers = {
|
|
274
273
|
evm: {
|
|
275
274
|
provider: connector,
|
|
276
|
-
protocol: ProviderProtocol.
|
|
275
|
+
protocol: ProviderProtocol.INJECT,
|
|
276
|
+
standard: ProviderStandard.EIP1193,
|
|
277
277
|
},
|
|
278
278
|
};
|
|
279
279
|
return {
|
|
@@ -291,7 +291,7 @@ function wagmiConnectorDector(wallet: WagmiWalletConfig): Connector {
|
|
|
291
291
|
},
|
|
292
292
|
},
|
|
293
293
|
isInstalled: true,
|
|
294
|
-
providers,
|
|
294
|
+
connectors: providers,
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
|
package/src/wallets/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderProtocol, ProviderStandard } from "@tomo-inc/wallet-utils";
|
|
2
|
+
import { Connector, WalletInfo } from "../type";
|
|
2
3
|
import { uniqueConnectors } from "../utils/utils";
|
|
3
4
|
|
|
4
5
|
const announceEvent = "eip6963:announceProvider";
|
|
@@ -41,17 +42,18 @@ export async function eip6963Wallets(): Promise<Connector[]> {
|
|
|
41
42
|
},
|
|
42
43
|
},
|
|
43
44
|
isInstalled: true,
|
|
44
|
-
|
|
45
|
+
connectors: {
|
|
45
46
|
[walletType]: {
|
|
46
47
|
provider,
|
|
47
|
-
|
|
48
|
+
standard: ProviderStandard.EIP1193,
|
|
49
|
+
protocol: ProviderProtocol.INJECT,
|
|
48
50
|
},
|
|
49
51
|
},
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
} catch (error) {
|
|
54
|
-
console.warn(`${ProviderProtocol.
|
|
56
|
+
console.warn(`${ProviderProtocol.INJECT} detect error:`, error);
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Connector, ProviderProtocol } from "../type";
|
|
1
|
+
import { ProviderProtocol, ProviderStandard } from "@tomo-inc/wallet-utils";
|
|
3
2
|
import { getWallets } from "@wallet-standard/core";
|
|
3
|
+
import { Connector } from "../type";
|
|
4
|
+
import { uniqueConnectors } from "../utils/utils";
|
|
4
5
|
|
|
5
6
|
const disabledWallets = {
|
|
6
7
|
"Bitget Wallet": true,
|
|
@@ -71,10 +72,11 @@ export async function walletStandardWallets(): Promise<{
|
|
|
71
72
|
},
|
|
72
73
|
},
|
|
73
74
|
isInstalled: true,
|
|
74
|
-
|
|
75
|
+
connectors: {
|
|
75
76
|
solana: {
|
|
76
77
|
provider: wallet.features,
|
|
77
|
-
|
|
78
|
+
standard: ProviderStandard.WALLET_STANDARD,
|
|
79
|
+
protocol: ProviderProtocol.INJECT,
|
|
78
80
|
},
|
|
79
81
|
},
|
|
80
82
|
});
|
|
@@ -101,10 +103,11 @@ export async function walletStandardWallets(): Promise<{
|
|
|
101
103
|
},
|
|
102
104
|
},
|
|
103
105
|
isInstalled: true,
|
|
104
|
-
|
|
106
|
+
connectors: {
|
|
105
107
|
aptos: {
|
|
106
108
|
provider: wallet.features,
|
|
107
|
-
|
|
109
|
+
standard: ProviderStandard.WALLET_STANDARD,
|
|
110
|
+
protocol: ProviderProtocol.INJECT,
|
|
108
111
|
},
|
|
109
112
|
},
|
|
110
113
|
});
|
|
@@ -131,10 +134,11 @@ export async function walletStandardWallets(): Promise<{
|
|
|
131
134
|
},
|
|
132
135
|
},
|
|
133
136
|
isInstalled: true,
|
|
134
|
-
|
|
137
|
+
connectors: {
|
|
135
138
|
sui: {
|
|
136
139
|
provider: wallet.features,
|
|
137
|
-
|
|
140
|
+
standard: ProviderStandard.WALLET_STANDARD,
|
|
141
|
+
protocol: ProviderProtocol.INJECT,
|
|
138
142
|
},
|
|
139
143
|
} as any,
|
|
140
144
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NamespaceConfig } from "@tomo-inc/wallet-connect-protocol";
|
|
2
|
-
import {
|
|
2
|
+
import { ChainTypeEnum, ProviderProtocol, ProviderStandard } from "@tomo-inc/wallet-utils";
|
|
3
|
+
import { Connector } from "../type";
|
|
3
4
|
import { walletBaseUrl } from "./index";
|
|
4
5
|
import { WalletConnectProvider } from "./providers/WalletConnectProvider";
|
|
5
6
|
import { WalletConnectSolanaProvider } from "./providers/WalletConnectSolanaProvider";
|
|
@@ -76,15 +77,24 @@ function convertWalletToConnector(wallet: Record<string, any>): Connector {
|
|
|
76
77
|
},
|
|
77
78
|
},
|
|
78
79
|
isInstalled: true, // Always available
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
connectors: {
|
|
81
|
+
[ChainTypeEnum.EVM]: {
|
|
82
|
+
standard: ProviderStandard.NORMAL,
|
|
82
83
|
protocol: ProviderProtocol.WALLET_CONNECT,
|
|
84
|
+
provider: createWalletConnectEVMProvider(walletConnectConfig?.evmNamespaces),
|
|
83
85
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
[ChainTypeEnum.SOLANA]: {
|
|
87
|
+
standard: ProviderStandard.NORMAL,
|
|
86
88
|
protocol: ProviderProtocol.WALLET_CONNECT,
|
|
89
|
+
provider: createWalletConnectSolanaProvider(walletConnectConfig?.solanaNamespaces),
|
|
87
90
|
},
|
|
91
|
+
// [ChainTypeEnum.BITCOIN]: null,
|
|
92
|
+
// [ChainTypeEnum.DOGECOIN]: null,
|
|
93
|
+
// [ChainTypeEnum.APTOS]: null,
|
|
94
|
+
// [ChainTypeEnum.COSMOS]: null,
|
|
95
|
+
// [ChainTypeEnum.TON]: null,
|
|
96
|
+
// [ChainTypeEnum.TRON]: null,
|
|
97
|
+
// [ChainTypeEnum.SUI]: null,
|
|
88
98
|
},
|
|
89
99
|
};
|
|
90
100
|
}
|
|
File without changes
|