@tomo-inc/wallet-adaptor-base 0.0.16 → 0.0.18
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 +169 -34
- package/dist/index.d.cts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +168 -35
- package/package.json +2 -2
- package/src/__tests__/defaultConnectors.test.ts +110 -0
- package/src/__tests__/wallet-standard.test.ts +302 -0
- package/src/index.ts +21 -12
- package/src/utils/wallet-config.ts +85 -0
- package/src/wallet-api/connect.ts +10 -3
- package/src/wallets/defaultConnectors.ts +5 -10
- package/src/wallets/detector.ts +139 -4
- package/src/wallets/index.ts +11 -2
- package/src/wallets/wallet-walletconnect.ts +2 -3
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chains = require('viem/chains');
|
|
3
4
|
var core = require('@wallet-standard/core');
|
|
4
5
|
var walletConnectProtocol = require('@tomo-inc/wallet-connect-protocol');
|
|
5
6
|
var viem = require('viem');
|
|
@@ -72,6 +73,50 @@ function uint8arrayToHex(uint8array) {
|
|
|
72
73
|
return Array.from(uint8array, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
// src/utils/wallet-config.ts
|
|
77
|
+
function hasWalletConfigProperties(config) {
|
|
78
|
+
if (!config || typeof config !== "object") {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return typeof config.id === "string" && typeof config.name === "string" && typeof config.icon === "string" && typeof config.iconBackground === "string";
|
|
82
|
+
}
|
|
83
|
+
function hasWagmiConnectorProperties(config) {
|
|
84
|
+
if (!config || typeof config !== "object") {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (typeof config.createConnector === "function") {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
const hasConnectorMethods = typeof config.connect === "function" || typeof config.disconnect === "function" || typeof config.getAccounts === "function" || typeof config.getChainId === "function";
|
|
91
|
+
const hasConnectorId = typeof config.id === "string" || typeof config.name === "string";
|
|
92
|
+
return hasConnectorMethods && hasConnectorId;
|
|
93
|
+
}
|
|
94
|
+
function isWagmiConnector(config) {
|
|
95
|
+
if (typeof config === "function") {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
if (config && typeof config === "object") {
|
|
99
|
+
const hasWalletConfigProps = hasWalletConfigProperties(config);
|
|
100
|
+
if (!hasWalletConfigProps) {
|
|
101
|
+
return hasWagmiConnectorProperties(config);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/wallets/index.ts
|
|
108
|
+
var walletBaseUrl = "https://web3-assets.tomo.inc";
|
|
109
|
+
var allWallets = [];
|
|
110
|
+
var getAllWallets = async (baseUrl) => {
|
|
111
|
+
if (allWallets.length > 0) {
|
|
112
|
+
return allWallets;
|
|
113
|
+
}
|
|
114
|
+
const walletListResponse = await fetch((baseUrl || walletBaseUrl) + "/api/wallets");
|
|
115
|
+
const walletListData = await walletListResponse.json();
|
|
116
|
+
const walletList = allWallets = walletListData == null ? void 0 : walletListData.data;
|
|
117
|
+
return walletList;
|
|
118
|
+
};
|
|
119
|
+
|
|
75
120
|
// src/type.ts
|
|
76
121
|
var ProviderProtocol = /* @__PURE__ */ ((ProviderProtocol2) => {
|
|
77
122
|
ProviderProtocol2["EIP6963"] = "eip6963";
|
|
@@ -133,17 +178,67 @@ var supportedWalletConfigTypes = {
|
|
|
133
178
|
tomo: true,
|
|
134
179
|
wagmi: true
|
|
135
180
|
};
|
|
136
|
-
function
|
|
181
|
+
function findWalletInDefaultConnectors(id, name, defaultWallets) {
|
|
182
|
+
let found = defaultWallets.find(
|
|
183
|
+
(wallet) => {
|
|
184
|
+
var _a, _b;
|
|
185
|
+
return ((_a = wallet.id) == null ? void 0 : _a.toLowerCase()) === id.toLowerCase() || ((_b = wallet.id) == null ? void 0 : _b.toLowerCase()) === id.toLowerCase().replace(/\s+/g, "-");
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
if (!found) {
|
|
189
|
+
const normalizedName = name.toLowerCase();
|
|
190
|
+
found = defaultWallets.find((wallet) => {
|
|
191
|
+
const walletName = wallet.name.toLowerCase();
|
|
192
|
+
return walletName === normalizedName || walletName.includes(normalizedName) || normalizedName.includes(walletName) || // support common wallet name variations matching
|
|
193
|
+
normalizedName.includes("metamask") && walletName.includes("metamask") || normalizedName.includes("coinbase") && walletName.includes("coinbase") || normalizedName.includes("safe") && walletName.includes("safe") || normalizedName.includes("walletconnect") && walletName.includes("walletconnect") || normalizedName.includes("injected") && walletName.includes("injected");
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return found || null;
|
|
197
|
+
}
|
|
198
|
+
function adaptWagmiConnectorToWalletConfig(wagmiConnector, allWallets2, baseUrl) {
|
|
199
|
+
var _a, _b, _c, _d;
|
|
200
|
+
const tempConfig = { chains: [chains.mainnet] };
|
|
201
|
+
const connector = wagmiConnector(tempConfig);
|
|
202
|
+
const id = connector.id || "unknown";
|
|
203
|
+
const name = connector.name || "Unknown Wallet";
|
|
204
|
+
const defaultWallet = findWalletInDefaultConnectors(id, name, allWallets2);
|
|
205
|
+
const walletConfig = {
|
|
206
|
+
id,
|
|
207
|
+
name,
|
|
208
|
+
namespace: (defaultWallet == null ? void 0 : defaultWallet.namespace) || "eip155",
|
|
209
|
+
// default EVM namespace
|
|
210
|
+
icon: baseUrl + (defaultWallet == null ? void 0 : defaultWallet.icon) || "",
|
|
211
|
+
iconBackground: (defaultWallet == null ? void 0 : defaultWallet.iconBackground) || "#666666",
|
|
212
|
+
rdns: defaultWallet == null ? void 0 : defaultWallet.rdns,
|
|
213
|
+
downloadUrls: (defaultWallet == null ? void 0 : defaultWallet.downloadUrls) || {},
|
|
214
|
+
installed: (defaultWallet == null ? void 0 : defaultWallet.installed) || false,
|
|
215
|
+
flag: (defaultWallet == null ? void 0 : defaultWallet.flag) || "",
|
|
216
|
+
solana: {
|
|
217
|
+
namespace: ((_a = defaultWallet == null ? void 0 : defaultWallet.solana) == null ? void 0 : _a.namespace) || "",
|
|
218
|
+
flag: ((_b = defaultWallet == null ? void 0 : defaultWallet.solana) == null ? void 0 : _b.flag) || ""
|
|
219
|
+
},
|
|
220
|
+
aptos: {
|
|
221
|
+
namespace: ((_c = defaultWallet == null ? void 0 : defaultWallet.aptos) == null ? void 0 : _c.namespace) || "",
|
|
222
|
+
flag: ((_d = defaultWallet == null ? void 0 : defaultWallet.aptos) == null ? void 0 : _d.flag) || ""
|
|
223
|
+
},
|
|
224
|
+
createConnector: wagmiConnector
|
|
225
|
+
};
|
|
226
|
+
return walletConfig;
|
|
227
|
+
}
|
|
228
|
+
function walletConfigAdapter(walletConfig, connectorType, allWallets2, baseUrl) {
|
|
137
229
|
switch (connectorType) {
|
|
138
230
|
case "tomo":
|
|
139
231
|
return walletConfig;
|
|
140
232
|
case "wagmi":
|
|
141
|
-
|
|
233
|
+
if (typeof walletConfig === "function") {
|
|
234
|
+
return adaptWagmiConnectorToWalletConfig(walletConfig, allWallets2, baseUrl);
|
|
235
|
+
}
|
|
236
|
+
return walletConfig;
|
|
142
237
|
default:
|
|
143
238
|
return walletConfig;
|
|
144
239
|
}
|
|
145
240
|
}
|
|
146
|
-
function
|
|
241
|
+
function tomoConnectorDector(wallet) {
|
|
147
242
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
148
243
|
const evmNS = {
|
|
149
244
|
namespace: (wallet == null ? void 0 : wallet.namespace) || "",
|
|
@@ -220,19 +315,54 @@ function connectorDector(wallet) {
|
|
|
220
315
|
providers
|
|
221
316
|
};
|
|
222
317
|
}
|
|
318
|
+
function wagmiConnectorDector(wallet) {
|
|
319
|
+
var _a, _b, _c, _d;
|
|
320
|
+
const tempConfig = {};
|
|
321
|
+
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
|
+
const providers = {
|
|
329
|
+
evm: {
|
|
330
|
+
provider: connector,
|
|
331
|
+
protocol: "eip6963" /* EIP6963 */
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
return {
|
|
335
|
+
info: {
|
|
336
|
+
uuid: wallet == null ? void 0 : wallet.id,
|
|
337
|
+
name: wallet == null ? void 0 : wallet.name,
|
|
338
|
+
icon: wallet == null ? void 0 : wallet.icon,
|
|
339
|
+
iconBackground: wallet == null ? void 0 : wallet.iconBackground,
|
|
340
|
+
rdns: wallet == null ? void 0 : wallet.rdns,
|
|
341
|
+
links: {
|
|
342
|
+
homepage: ((_a = wallet == null ? void 0 : wallet.downloadUrls) == null ? void 0 : _a.qrCode) || "",
|
|
343
|
+
ios_install: ((_b = wallet == null ? void 0 : wallet.downloadUrls) == null ? void 0 : _b.ios) || "",
|
|
344
|
+
android_install: ((_c = wallet == null ? void 0 : wallet.downloadUrls) == null ? void 0 : _c.android) || "",
|
|
345
|
+
chrome_install: ((_d = wallet == null ? void 0 : wallet.downloadUrls) == null ? void 0 : _d.chrome) || ""
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
isInstalled: true,
|
|
349
|
+
providers
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function connectorDector(wallet, connectorType) {
|
|
353
|
+
if (connectorType === "wagmi") {
|
|
354
|
+
return wagmiConnectorDector(wallet);
|
|
355
|
+
}
|
|
356
|
+
return tomoConnectorDector(wallet);
|
|
357
|
+
}
|
|
223
358
|
|
|
224
359
|
// src/wallets/defaultConnectors.ts
|
|
225
|
-
var defaultWallets = [];
|
|
226
360
|
var getDefaultConnectors = async (baseUrl) => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const walletListResponse = await fetch((baseUrl || "https://web3-assets.tomo.inc") + "/api/wallets");
|
|
231
|
-
const walletList = await walletListResponse.json();
|
|
232
|
-
defaultWallets = walletList == null ? void 0 : walletList.data.map((wallet) => __spreadProps(__spreadValues({}, wallet), {
|
|
233
|
-
icon: (baseUrl || "https://web3-assets.tomo.inc") + wallet.icon
|
|
361
|
+
const walletList = await getAllWallets(baseUrl);
|
|
362
|
+
const defaultWallets = walletList == null ? void 0 : walletList.map((wallet) => __spreadProps(__spreadValues({}, wallet), {
|
|
363
|
+
icon: (baseUrl || walletBaseUrl) + wallet.icon
|
|
234
364
|
}));
|
|
235
|
-
return defaultWallets == null ? void 0 : defaultWallets.map((wallet) => connectorDector(wallet));
|
|
365
|
+
return defaultWallets == null ? void 0 : defaultWallets.map((wallet) => connectorDector(wallet, "tomo"));
|
|
236
366
|
};
|
|
237
367
|
|
|
238
368
|
// src/wallets/wallet-eip6963.ts
|
|
@@ -1006,9 +1136,7 @@ async function walletConnectWallets(baseUrl) {
|
|
|
1006
1136
|
if (wcWallets.length > 0) {
|
|
1007
1137
|
return wcWallets.map((wallet) => convertWalletToConnector(wallet));
|
|
1008
1138
|
}
|
|
1009
|
-
const walletListResponse = await fetch(
|
|
1010
|
-
(baseUrl || "https://web3-assets.tomo.inc") + "/api/wallets?walletId=walletConnect"
|
|
1011
|
-
);
|
|
1139
|
+
const walletListResponse = await fetch((baseUrl || walletBaseUrl) + "/api/wallets?walletId=walletConnect");
|
|
1012
1140
|
const walletList = await walletListResponse.json();
|
|
1013
1141
|
if (((_a = walletList == null ? void 0 : walletList.data) == null ? void 0 : _a.length) === 0) {
|
|
1014
1142
|
return [];
|
|
@@ -1182,9 +1310,16 @@ var connect = async (connectParams, walletOptions) => {
|
|
|
1182
1310
|
let address = "";
|
|
1183
1311
|
let network = "";
|
|
1184
1312
|
if (chainType === "evm") {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1313
|
+
if (provider == null ? void 0 : provider.request) {
|
|
1314
|
+
const res = await provider.request({ method: "eth_requestAccounts" });
|
|
1315
|
+
address = (res == null ? void 0 : res[0]) || "";
|
|
1316
|
+
chainId = await provider.request({ method: "eth_chainId" });
|
|
1317
|
+
} else {
|
|
1318
|
+
const wagmiProvider = await provider.getProvider();
|
|
1319
|
+
const res = await wagmiProvider.request({ method: "eth_requestAccounts" });
|
|
1320
|
+
address = (res == null ? void 0 : res[0]) || "";
|
|
1321
|
+
chainId = await provider.request({ method: "eth_chainId" });
|
|
1322
|
+
}
|
|
1188
1323
|
}
|
|
1189
1324
|
if (chainType === "solana") {
|
|
1190
1325
|
let res = null;
|
|
@@ -1694,42 +1829,40 @@ var getBalance = async (token, walletOptions) => {
|
|
|
1694
1829
|
throw new Error(`getBalance not supported in ${chainType}`);
|
|
1695
1830
|
};
|
|
1696
1831
|
|
|
1697
|
-
// src/wallets/index.ts
|
|
1698
|
-
var getAllWallets = async (baseUrl) => {
|
|
1699
|
-
const walletListResponse = await fetch((baseUrl || "https://web3-assets.tomo.inc") + "/api/wallets");
|
|
1700
|
-
const walletList = await walletListResponse.json();
|
|
1701
|
-
return walletList;
|
|
1702
|
-
};
|
|
1703
|
-
|
|
1704
1832
|
// src/index.ts
|
|
1705
|
-
var walletBaseUrl = "https://embedded-wallet.tomo.inc";
|
|
1706
1833
|
async function loadConnectors({
|
|
1707
1834
|
chainType = "all",
|
|
1708
|
-
|
|
1835
|
+
recommendedConnectors,
|
|
1709
1836
|
connectorTypes = [],
|
|
1710
1837
|
options = {
|
|
1711
1838
|
baseUrl: walletBaseUrl
|
|
1712
1839
|
}
|
|
1713
1840
|
}) {
|
|
1714
|
-
const recommonedWalletConfigs =
|
|
1841
|
+
const recommonedWalletConfigs = recommendedConnectors || [];
|
|
1715
1842
|
const evmWallets = await eip6963Wallets();
|
|
1716
1843
|
const { solanaWallets, aptosWallets } = await walletStandardWallets();
|
|
1717
1844
|
const wcWallets2 = await walletConnectWallets(options.baseUrl);
|
|
1718
|
-
|
|
1845
|
+
const allWallets2 = await getAllWallets(options.baseUrl);
|
|
1846
|
+
let recommendedConnectorsDetected = [];
|
|
1719
1847
|
if (recommonedWalletConfigs.length > 0) {
|
|
1720
|
-
|
|
1848
|
+
recommendedConnectorsDetected = recommonedWalletConfigs.map((walletConfig, index) => {
|
|
1721
1849
|
const connectorType = connectorTypes[index];
|
|
1722
1850
|
if (!supportedWalletConfigTypes[connectorType]) {
|
|
1723
1851
|
throw new Error(`Unsupported wallet config type: ${connectorType}`);
|
|
1724
1852
|
}
|
|
1725
|
-
const _walletConfig = walletConfigAdapter(
|
|
1726
|
-
|
|
1853
|
+
const _walletConfig = walletConfigAdapter(
|
|
1854
|
+
walletConfig,
|
|
1855
|
+
connectorType,
|
|
1856
|
+
allWallets2,
|
|
1857
|
+
options.baseUrl || walletBaseUrl
|
|
1858
|
+
);
|
|
1859
|
+
return __spreadProps(__spreadValues({}, connectorDector(_walletConfig, connectorType)), {
|
|
1727
1860
|
recommoned: true
|
|
1728
1861
|
});
|
|
1729
1862
|
});
|
|
1730
1863
|
}
|
|
1731
1864
|
const defaultConnectors = await getDefaultConnectors(options.baseUrl);
|
|
1732
|
-
const connectorsFromConfig = uniqueConnectors([...
|
|
1865
|
+
const connectorsFromConfig = uniqueConnectors([...recommendedConnectorsDetected, ...defaultConnectors]);
|
|
1733
1866
|
const connectorsDetecteds = [...evmWallets, ...solanaWallets, ...aptosWallets, ...wcWallets2];
|
|
1734
1867
|
for (const connector of connectorsDetecteds) {
|
|
1735
1868
|
const _connector = connectorsFromConfig.find((c) => c.info.name === connector.info.name);
|
|
@@ -1749,7 +1882,7 @@ async function loadConnectors({
|
|
|
1749
1882
|
});
|
|
1750
1883
|
return {
|
|
1751
1884
|
all: allConnectors,
|
|
1752
|
-
recommoned:
|
|
1885
|
+
recommoned: recommendedConnectorsDetected
|
|
1753
1886
|
};
|
|
1754
1887
|
}
|
|
1755
1888
|
|
|
@@ -1763,8 +1896,10 @@ exports.disconnect = disconnect;
|
|
|
1763
1896
|
exports.getAllWallets = getAllWallets;
|
|
1764
1897
|
exports.getBalance = getBalance;
|
|
1765
1898
|
exports.isMobile = isMobile;
|
|
1899
|
+
exports.isWagmiConnector = isWagmiConnector;
|
|
1766
1900
|
exports.loadConnectors = loadConnectors;
|
|
1767
1901
|
exports.setWalletConnectConfig = setWalletConnectConfig;
|
|
1768
1902
|
exports.signInWithWallet = signInWithWallet;
|
|
1769
1903
|
exports.signMessage = signMessage;
|
|
1770
1904
|
exports.switchChain = switchChain;
|
|
1905
|
+
exports.walletBaseUrl = walletBaseUrl;
|
package/dist/index.d.cts
CHANGED
|
@@ -156,6 +156,25 @@ type WalletConfig = {
|
|
|
156
156
|
};
|
|
157
157
|
type WagmiWalletConfig = any;
|
|
158
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Detect if the given config is a wagmi connector
|
|
161
|
+
* Wagmi connector is usually a function (CreateConnectorFn) with specific properties
|
|
162
|
+
*
|
|
163
|
+
* @param config - The wallet config to check (WalletConfig | WagmiWalletConfig)
|
|
164
|
+
* @returns true if the config is a wagmi connector, false otherwise
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* import { isWagmiConnector } from '@tomo-inc/wallet-adaptor-base';
|
|
169
|
+
*
|
|
170
|
+
* const connector = injected({ target: 'metamask' });
|
|
171
|
+
* if (isWagmiConnector(connector)) {
|
|
172
|
+
* // Handle wagmi connector
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
declare function isWagmiConnector(config: WalletConfig | WagmiWalletConfig): boolean;
|
|
177
|
+
|
|
159
178
|
/**
|
|
160
179
|
* Set WalletConnect configuration
|
|
161
180
|
* Must be called before using WalletConnect wallet
|
|
@@ -215,11 +234,12 @@ declare const signMessage: (data: {
|
|
|
215
234
|
isInstalled?: boolean;
|
|
216
235
|
}) => Promise<string>;
|
|
217
236
|
|
|
237
|
+
declare const walletBaseUrl = "https://web3-assets.tomo.inc";
|
|
218
238
|
declare const getAllWallets: (baseUrl?: string) => Promise<any>;
|
|
219
239
|
|
|
220
|
-
declare function loadConnectors({ chainType,
|
|
240
|
+
declare function loadConnectors({ chainType, recommendedConnectors, connectorTypes, options, }: {
|
|
221
241
|
chainType?: AdaptorChainType;
|
|
222
|
-
|
|
242
|
+
recommendedConnectors?: (WalletConfig | WagmiWalletConfig)[];
|
|
223
243
|
connectorTypes?: WalletConnectorType[];
|
|
224
244
|
options?: {
|
|
225
245
|
baseUrl?: string;
|
|
@@ -229,4 +249,4 @@ declare function loadConnectors({ chainType, recommonedConnectors, connectorType
|
|
|
229
249
|
recommoned: Connector[];
|
|
230
250
|
}>;
|
|
231
251
|
|
|
232
|
-
export { type AdaptorChainType, type BalanceParams, type ChainInfo, type ConnectParams, type Connector, type ConnectorProvider, type ITokenInfo, ProviderChainType, ProviderProtocol, type SignInParams, SupportedChainTypes, type WalletConfig, type WalletConnectConfig, type WalletConnectorType, type WalletInfo, type WalletOptions, type WalletProvider, addChain, connect, connectMobile, disconnect, getAllWallets, getBalance, isMobile, loadConnectors, setWalletConnectConfig, signInWithWallet, signMessage, switchChain };
|
|
252
|
+
export { type AdaptorChainType, type BalanceParams, type ChainInfo, type ConnectParams, type Connector, type ConnectorProvider, type ITokenInfo, ProviderChainType, ProviderProtocol, type SignInParams, SupportedChainTypes, 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
|
@@ -156,6 +156,25 @@ type WalletConfig = {
|
|
|
156
156
|
};
|
|
157
157
|
type WagmiWalletConfig = any;
|
|
158
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Detect if the given config is a wagmi connector
|
|
161
|
+
* Wagmi connector is usually a function (CreateConnectorFn) with specific properties
|
|
162
|
+
*
|
|
163
|
+
* @param config - The wallet config to check (WalletConfig | WagmiWalletConfig)
|
|
164
|
+
* @returns true if the config is a wagmi connector, false otherwise
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* import { isWagmiConnector } from '@tomo-inc/wallet-adaptor-base';
|
|
169
|
+
*
|
|
170
|
+
* const connector = injected({ target: 'metamask' });
|
|
171
|
+
* if (isWagmiConnector(connector)) {
|
|
172
|
+
* // Handle wagmi connector
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
declare function isWagmiConnector(config: WalletConfig | WagmiWalletConfig): boolean;
|
|
177
|
+
|
|
159
178
|
/**
|
|
160
179
|
* Set WalletConnect configuration
|
|
161
180
|
* Must be called before using WalletConnect wallet
|
|
@@ -215,11 +234,12 @@ declare const signMessage: (data: {
|
|
|
215
234
|
isInstalled?: boolean;
|
|
216
235
|
}) => Promise<string>;
|
|
217
236
|
|
|
237
|
+
declare const walletBaseUrl = "https://web3-assets.tomo.inc";
|
|
218
238
|
declare const getAllWallets: (baseUrl?: string) => Promise<any>;
|
|
219
239
|
|
|
220
|
-
declare function loadConnectors({ chainType,
|
|
240
|
+
declare function loadConnectors({ chainType, recommendedConnectors, connectorTypes, options, }: {
|
|
221
241
|
chainType?: AdaptorChainType;
|
|
222
|
-
|
|
242
|
+
recommendedConnectors?: (WalletConfig | WagmiWalletConfig)[];
|
|
223
243
|
connectorTypes?: WalletConnectorType[];
|
|
224
244
|
options?: {
|
|
225
245
|
baseUrl?: string;
|
|
@@ -229,4 +249,4 @@ declare function loadConnectors({ chainType, recommonedConnectors, connectorType
|
|
|
229
249
|
recommoned: Connector[];
|
|
230
250
|
}>;
|
|
231
251
|
|
|
232
|
-
export { type AdaptorChainType, type BalanceParams, type ChainInfo, type ConnectParams, type Connector, type ConnectorProvider, type ITokenInfo, ProviderChainType, ProviderProtocol, type SignInParams, SupportedChainTypes, type WalletConfig, type WalletConnectConfig, type WalletConnectorType, type WalletInfo, type WalletOptions, type WalletProvider, addChain, connect, connectMobile, disconnect, getAllWallets, getBalance, isMobile, loadConnectors, setWalletConnectConfig, signInWithWallet, signMessage, switchChain };
|
|
252
|
+
export { type AdaptorChainType, type BalanceParams, type ChainInfo, type ConnectParams, type Connector, type ConnectorProvider, type ITokenInfo, ProviderChainType, ProviderProtocol, type SignInParams, SupportedChainTypes, 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 };
|