@tomo-inc/embedded-wallet-providers 0.0.16 → 0.0.17

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 CHANGED
@@ -4,7 +4,25 @@ var injectProviders = require('@tomo-inc/inject-providers');
4
4
  var walletUtils = require('@tomo-inc/wallet-utils');
5
5
  var oidcAuth = require('@tomo-inc/oidc-auth');
6
6
 
7
- // src/embedded-wallet.ts
7
+ var __defProp = Object.defineProperty;
8
+ var __defProps = Object.defineProperties;
9
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
10
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
13
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
+ var __spreadValues = (a, b) => {
15
+ for (var prop in b || (b = {}))
16
+ if (__hasOwnProp.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ if (__getOwnPropSymbols)
19
+ for (var prop of __getOwnPropSymbols(b)) {
20
+ if (__propIsEnum.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ }
23
+ return a;
24
+ };
25
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8
26
  var evmDappPopups = {
9
27
  connect: "/dapp/connect",
10
28
  eth_requestAccounts: "/dapp/connect",
@@ -80,11 +98,11 @@ var shopDappPopups = {
80
98
  rewardClaimedDialog: "/dapp-shop/dialog"
81
99
  };
82
100
  var dappPopups = {
83
- [walletUtils.ChainTypes.EVM]: evmDappPopups,
84
- [walletUtils.ChainTypes.DOGE]: dogeDappPopups,
85
- [walletUtils.ChainTypes.SOL]: solanaDappPopups,
86
- [walletUtils.ChainTypes.TRON]: tronDappPopups,
87
- [walletUtils.ChainTypes.BTC]: btcDappPopups,
101
+ [walletUtils.ChainTypeEnum.EVM]: evmDappPopups,
102
+ [walletUtils.ChainTypeEnum.DOGECOIN]: dogeDappPopups,
103
+ [walletUtils.ChainTypeEnum.SOLANA]: solanaDappPopups,
104
+ [walletUtils.ChainTypeEnum.TRON]: tronDappPopups,
105
+ [walletUtils.ChainTypeEnum.BITCOIN]: btcDappPopups,
88
106
  shop: shopDappPopups
89
107
  };
90
108
 
@@ -145,18 +163,24 @@ var onResponse = async (requestParams) => {
145
163
  };
146
164
  var EmbeddedWallet = class _EmbeddedWallet {
147
165
  constructor() {
148
- this.isAvailable = false;
149
- this.config = null;
150
- this.info = null;
151
- this.btcProvider = null;
152
- this.dogecoinProvider = null;
153
- this.evmProvider = null;
154
- this.solanaProvider = null;
155
- this.tronProvider = null;
166
+ this.themeConfig = null;
156
167
  this.walletIframe = null;
157
168
  this.walletOrigin = "";
158
169
  this.maskZIndex = 999;
159
- this.persistedTheme = null;
170
+ this.isAvailable = false;
171
+ this.config = null;
172
+ this.info = null;
173
+ this.connectors = {
174
+ [walletUtils.ChainTypeEnum.BITCOIN]: null,
175
+ [walletUtils.ChainTypeEnum.DOGECOIN]: null,
176
+ [walletUtils.ChainTypeEnum.EVM]: null,
177
+ [walletUtils.ChainTypeEnum.SOLANA]: null,
178
+ [walletUtils.ChainTypeEnum.TRON]: null,
179
+ [walletUtils.ChainTypeEnum.SUI]: null,
180
+ [walletUtils.ChainTypeEnum.TON]: null,
181
+ [walletUtils.ChainTypeEnum.COSMOS]: null,
182
+ [walletUtils.ChainTypeEnum.APTOS]: null
183
+ };
160
184
  this.loginByGoogle = null;
161
185
  this.loginByX = null;
162
186
  this.loginStatusCallback = null;
@@ -181,10 +205,9 @@ var EmbeddedWallet = class _EmbeddedWallet {
181
205
  return _EmbeddedWallet.instance;
182
206
  }
183
207
  async init(config) {
184
- var _a;
185
- this.config = config;
186
- if (!config.tomoClientId) {
187
- throw new Error("tomoClientId is required.");
208
+ this.config = __spreadValues({}, config);
209
+ if (!config.clientId) {
210
+ throw new Error("clientId is required.");
188
211
  }
189
212
  if (!config.walletBaseUrl) {
190
213
  throw new Error("walletBaseUrl is required.");
@@ -197,33 +220,58 @@ var EmbeddedWallet = class _EmbeddedWallet {
197
220
  }
198
221
  hostArr.reverse();
199
222
  const rdns = hostArr.join(".");
200
- this.info = {
201
- uuid: hostArr.join("-"),
202
- name: config.name,
203
- icon: config.logo,
204
- rdns,
205
- links: {
206
- homepage: config.walletBaseUrl
207
- }
208
- };
209
223
  const productInfo = {
210
224
  name: config.name,
211
225
  rdns,
212
226
  icon: config.logo
213
227
  };
214
- this.btcProvider = new injectProviders.BtcProvider(productInfo, { sendRequest, onResponse });
215
- this.dogecoinProvider = new injectProviders.DogecoinProvider(productInfo, { sendRequest, onResponse });
216
- this.evmProvider = new injectProviders.EvmProvider(productInfo, { sendRequest, onResponse });
217
- this.solanaProvider = new injectProviders.SolanaProvider(productInfo, { sendRequest, onResponse });
218
- this.tronProvider = new injectProviders.TronProvider(productInfo, { sendRequest, onResponse });
219
- const { loginByGoogle, loginByX } = oidcAuth.OidcAuth(config);
228
+ this.info = __spreadProps(__spreadValues({}, productInfo), {
229
+ uuid: hostArr.join("-"),
230
+ links: {
231
+ homepage: config.walletBaseUrl
232
+ }
233
+ });
234
+ this.connectors = __spreadProps(__spreadValues({}, this.connectors), {
235
+ [walletUtils.ChainTypeEnum.EVM]: {
236
+ provider: new injectProviders.EvmProvider(productInfo, { sendRequest, onResponse }),
237
+ standard: walletUtils.ProviderStandard.EIP1193,
238
+ protocol: walletUtils.ProviderProtocol.INJECT
239
+ },
240
+ [walletUtils.ChainTypeEnum.BITCOIN]: {
241
+ provider: new injectProviders.BitcoinProvider(productInfo, { sendRequest, onResponse }),
242
+ standard: walletUtils.ProviderStandard.NORMAL,
243
+ protocol: walletUtils.ProviderProtocol.INJECT
244
+ },
245
+ [walletUtils.ChainTypeEnum.DOGECOIN]: {
246
+ provider: new injectProviders.DogecoinProvider(productInfo, { sendRequest, onResponse }),
247
+ standard: walletUtils.ProviderStandard.NORMAL,
248
+ protocol: walletUtils.ProviderProtocol.INJECT
249
+ },
250
+ [walletUtils.ChainTypeEnum.SOLANA]: {
251
+ provider: new injectProviders.SolanaProvider(productInfo, { sendRequest, onResponse }),
252
+ standard: walletUtils.ProviderStandard.NORMAL,
253
+ protocol: walletUtils.ProviderProtocol.INJECT
254
+ },
255
+ [walletUtils.ChainTypeEnum.TRON]: {
256
+ provider: new injectProviders.TronProvider(productInfo, { sendRequest, onResponse }),
257
+ standard: walletUtils.ProviderStandard.NORMAL,
258
+ protocol: walletUtils.ProviderProtocol.INJECT
259
+ }
260
+ });
261
+ const { loginByGoogle, loginByX } = oidcAuth.OidcAuth({
262
+ tomoStage: config.stage,
263
+ xClientId: config.xClientId,
264
+ googleClientId: config.googleClientId
265
+ });
220
266
  this.loginByGoogle = loginByGoogle;
221
267
  this.loginByX = loginByX;
222
268
  const { isAvailable, message, connectedInfo } = await this.login();
223
269
  this.isAvailable = isAvailable;
270
+ console.log("embedded-wallet-providers connectedInfo::", connectedInfo);
224
271
  const { connected, address = [] } = (connectedInfo == null ? void 0 : connectedInfo.evmProvider) || {};
225
272
  if (connected && address.length > 0) {
226
- (_a = this.evmProvider) == null ? void 0 : _a.setConnectedStatus({ connected, address });
273
+ const evmConnector = this.connectors[walletUtils.ChainTypeEnum.EVM];
274
+ (evmConnector == null ? void 0 : evmConnector.provider) && evmConnector.provider.setConnectedStatus({ connected, address });
227
275
  }
228
276
  return { isAvailable, message, connectedInfo };
229
277
  }
@@ -240,11 +288,11 @@ var EmbeddedWallet = class _EmbeddedWallet {
240
288
  }
241
289
  return new Promise((resolve, reject) => {
242
290
  try {
243
- const { walletBaseUrl, tomoClientId, tomoStage, logo, name } = config || {};
244
- if (!walletBaseUrl || !tomoClientId) {
245
- throw new Error("walletBaseUrl + tomoClientId is required");
291
+ const { walletBaseUrl, clientId, stage, logo, name } = config || {};
292
+ if (!walletBaseUrl || !clientId) {
293
+ throw new Error("walletBaseUrl + clientId is required");
246
294
  }
247
- const EMBEDDED_WALLET_ID = tomoClientId;
295
+ const EMBEDDED_WALLET_ID = clientId;
248
296
  let walletIframe = document.getElementById(EMBEDDED_WALLET_ID);
249
297
  if (!walletIframe) {
250
298
  walletIframe = document.createElement("iframe");
@@ -252,8 +300,15 @@ var EmbeddedWallet = class _EmbeddedWallet {
252
300
  walletIframe.id = EMBEDDED_WALLET_ID;
253
301
  document.body.appendChild(walletIframe);
254
302
  }
255
- const dappOrigin = window.location.origin;
256
- walletIframe.src = `${walletBaseUrl}#dappOrigin=${dappOrigin}&tomoStage=${tomoStage}&tomoClientId=${tomoClientId}&oidcToken=${oidcToken || ""}&logo=${logo || ""}&name=${name || ""}`;
303
+ const searchParams = new URLSearchParams({
304
+ dappOrigin: window.location.origin,
305
+ tomoStage: stage,
306
+ tomoClientId: clientId,
307
+ oidcToken: oidcToken || "",
308
+ logo: logo || "",
309
+ name: name || ""
310
+ });
311
+ walletIframe.src = `${walletBaseUrl}#${searchParams.toString()}`;
257
312
  walletIframe.allow = "publickey-credentials-get; publickey-credentials-create";
258
313
  this.walletIframe = walletIframe;
259
314
  } catch (error) {
@@ -263,10 +318,11 @@ var EmbeddedWallet = class _EmbeddedWallet {
263
318
  const receiveResponse = ({ origin, data }) => {
264
319
  var _a;
265
320
  if ((data == null ? void 0 : data.type) === "wallet-ready" && origin === this.walletOrigin) {
321
+ console.log("------receiveResponse", data, origin);
266
322
  this.isAvailable = ((_a = data == null ? void 0 : data.data) == null ? void 0 : _a.isAvailable) || false;
267
- if (this.persistedTheme) {
323
+ if (this.themeConfig) {
268
324
  setTimeout(() => {
269
- this.request("theme-change", this.persistedTheme);
325
+ this.request("theme-change", this.themeConfig);
270
326
  }, 0);
271
327
  }
272
328
  resolve(data == null ? void 0 : data.data);
@@ -284,7 +340,7 @@ var EmbeddedWallet = class _EmbeddedWallet {
284
340
  });
285
341
  }
286
342
  async themeChange(theme) {
287
- this.persistedTheme = theme;
343
+ this.themeConfig = theme;
288
344
  this.request("theme-change", theme);
289
345
  }
290
346
  popup() {
package/dist/index.d.cts CHANGED
@@ -1,17 +1,8 @@
1
+ import { BitcoinProvider, DogecoinProvider, EvmProvider, SolanaProvider, TronProvider } from '@tomo-inc/inject-providers';
2
+ import { ChainTypeEnum, ProviderStandard, ProviderProtocol } from '@tomo-inc/wallet-utils';
1
3
  export { EmailLoginResult } from '@tomo-inc/oidc-auth';
2
- import { BtcProvider, DogecoinProvider, EvmProvider, SolanaProvider, TronProvider } from '@tomo-inc/inject-providers';
3
4
 
4
- interface InitConfig {
5
- xClientId: string;
6
- googleClientId: string;
7
- name: string;
8
- logo: string;
9
- tomoStage: "dev" | "prod";
10
- tomoClientId: string;
11
- walletBaseUrl: string;
12
- relayBaseUrl?: string;
13
- theme: any;
14
- }
5
+ type TomoStage = "dev" | "pre" | "prod";
15
6
  interface WalletInfo {
16
7
  uuid: string;
17
8
  name: string;
@@ -25,30 +16,46 @@ interface WalletInfo {
25
16
  type WalletRequestMethod = "logout" | "token" | "market" | "assets" | "transactions" | "wallet" | "emailLogin" | "theme-change";
26
17
  type WalletOpenMethod = "wallet" | "swap" | "onRamp" | "funding" | "mfaVerify" | "mnemonic" | "setting";
27
18
  type EmbeddedWalletConfig = {
28
- tomoStage: "dev" | "pre" | "prod";
19
+ xClientId: string;
20
+ googleClientId: string;
21
+ clientId: string;
29
22
  name: string;
30
23
  logo: string;
31
- clientId: string;
32
- googleClientId: string;
33
- xClientId: string;
24
+ stage: TomoStage;
34
25
  walletBaseUrl: string;
26
+ relayBaseUrl?: string;
27
+ theme?: any;
35
28
  [key: string]: unknown;
36
29
  };
30
+ type UnsupportedType = null;
31
+ type ProviderConfig<TProvider> = {
32
+ provider: TProvider;
33
+ standard: ProviderStandard;
34
+ protocol: ProviderProtocol;
35
+ };
36
+ /** Maps each chain type to its provider so that providers[ChainTypeEnum.EVM] is inferred as EvmProvider | null, etc. */
37
+ type EmbeddedWalletConnectors = {
38
+ [ChainTypeEnum.BITCOIN]: ProviderConfig<BitcoinProvider> | UnsupportedType;
39
+ [ChainTypeEnum.DOGECOIN]: ProviderConfig<DogecoinProvider> | UnsupportedType;
40
+ [ChainTypeEnum.EVM]: ProviderConfig<EvmProvider> | UnsupportedType;
41
+ [ChainTypeEnum.SOLANA]: ProviderConfig<SolanaProvider> | UnsupportedType;
42
+ [ChainTypeEnum.TRON]: ProviderConfig<TronProvider> | UnsupportedType;
43
+ [ChainTypeEnum.SUI]: UnsupportedType;
44
+ [ChainTypeEnum.TON]: UnsupportedType;
45
+ [ChainTypeEnum.COSMOS]: UnsupportedType;
46
+ [ChainTypeEnum.APTOS]: UnsupportedType;
47
+ };
37
48
 
38
49
  declare class EmbeddedWallet {
39
- isAvailable: boolean;
40
- config: InitConfig | null;
41
- info: WalletInfo | null;
42
- btcProvider: BtcProvider | null;
43
- dogecoinProvider: DogecoinProvider | null;
44
- evmProvider: EvmProvider | null;
45
- solanaProvider: SolanaProvider | null;
46
- tronProvider: TronProvider | null;
50
+ private static instance;
51
+ private themeConfig;
47
52
  walletIframe: HTMLIFrameElement | null;
48
53
  walletOrigin: string;
49
54
  maskZIndex: number;
50
- private static instance;
51
- private persistedTheme;
55
+ isAvailable: boolean;
56
+ config: EmbeddedWalletConfig | null;
57
+ info: WalletInfo | null;
58
+ connectors: EmbeddedWalletConnectors;
52
59
  loginByGoogle: (() => Promise<string>) | null;
53
60
  loginByX: (() => Promise<string>) | null;
54
61
  loginStatusCallback: (({ type }: {
@@ -56,7 +63,7 @@ declare class EmbeddedWallet {
56
63
  }) => void) | null;
57
64
  constructor();
58
65
  static getInstance(): EmbeddedWallet;
59
- init(config: InitConfig): Promise<{
66
+ init(config: EmbeddedWalletConfig): Promise<{
60
67
  isAvailable: boolean;
61
68
  message: string | undefined;
62
69
  connectedInfo: any;
@@ -99,4 +106,4 @@ declare class EmbeddedWallet {
99
106
  open(method: WalletOpenMethod, params?: any): Promise<any>;
100
107
  }
101
108
 
102
- export { EmbeddedWallet, type EmbeddedWalletConfig, type InitConfig };
109
+ export { EmbeddedWallet, type EmbeddedWalletConfig };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,8 @@
1
+ import { BitcoinProvider, DogecoinProvider, EvmProvider, SolanaProvider, TronProvider } from '@tomo-inc/inject-providers';
2
+ import { ChainTypeEnum, ProviderStandard, ProviderProtocol } from '@tomo-inc/wallet-utils';
1
3
  export { EmailLoginResult } from '@tomo-inc/oidc-auth';
2
- import { BtcProvider, DogecoinProvider, EvmProvider, SolanaProvider, TronProvider } from '@tomo-inc/inject-providers';
3
4
 
4
- interface InitConfig {
5
- xClientId: string;
6
- googleClientId: string;
7
- name: string;
8
- logo: string;
9
- tomoStage: "dev" | "prod";
10
- tomoClientId: string;
11
- walletBaseUrl: string;
12
- relayBaseUrl?: string;
13
- theme: any;
14
- }
5
+ type TomoStage = "dev" | "pre" | "prod";
15
6
  interface WalletInfo {
16
7
  uuid: string;
17
8
  name: string;
@@ -25,30 +16,46 @@ interface WalletInfo {
25
16
  type WalletRequestMethod = "logout" | "token" | "market" | "assets" | "transactions" | "wallet" | "emailLogin" | "theme-change";
26
17
  type WalletOpenMethod = "wallet" | "swap" | "onRamp" | "funding" | "mfaVerify" | "mnemonic" | "setting";
27
18
  type EmbeddedWalletConfig = {
28
- tomoStage: "dev" | "pre" | "prod";
19
+ xClientId: string;
20
+ googleClientId: string;
21
+ clientId: string;
29
22
  name: string;
30
23
  logo: string;
31
- clientId: string;
32
- googleClientId: string;
33
- xClientId: string;
24
+ stage: TomoStage;
34
25
  walletBaseUrl: string;
26
+ relayBaseUrl?: string;
27
+ theme?: any;
35
28
  [key: string]: unknown;
36
29
  };
30
+ type UnsupportedType = null;
31
+ type ProviderConfig<TProvider> = {
32
+ provider: TProvider;
33
+ standard: ProviderStandard;
34
+ protocol: ProviderProtocol;
35
+ };
36
+ /** Maps each chain type to its provider so that providers[ChainTypeEnum.EVM] is inferred as EvmProvider | null, etc. */
37
+ type EmbeddedWalletConnectors = {
38
+ [ChainTypeEnum.BITCOIN]: ProviderConfig<BitcoinProvider> | UnsupportedType;
39
+ [ChainTypeEnum.DOGECOIN]: ProviderConfig<DogecoinProvider> | UnsupportedType;
40
+ [ChainTypeEnum.EVM]: ProviderConfig<EvmProvider> | UnsupportedType;
41
+ [ChainTypeEnum.SOLANA]: ProviderConfig<SolanaProvider> | UnsupportedType;
42
+ [ChainTypeEnum.TRON]: ProviderConfig<TronProvider> | UnsupportedType;
43
+ [ChainTypeEnum.SUI]: UnsupportedType;
44
+ [ChainTypeEnum.TON]: UnsupportedType;
45
+ [ChainTypeEnum.COSMOS]: UnsupportedType;
46
+ [ChainTypeEnum.APTOS]: UnsupportedType;
47
+ };
37
48
 
38
49
  declare class EmbeddedWallet {
39
- isAvailable: boolean;
40
- config: InitConfig | null;
41
- info: WalletInfo | null;
42
- btcProvider: BtcProvider | null;
43
- dogecoinProvider: DogecoinProvider | null;
44
- evmProvider: EvmProvider | null;
45
- solanaProvider: SolanaProvider | null;
46
- tronProvider: TronProvider | null;
50
+ private static instance;
51
+ private themeConfig;
47
52
  walletIframe: HTMLIFrameElement | null;
48
53
  walletOrigin: string;
49
54
  maskZIndex: number;
50
- private static instance;
51
- private persistedTheme;
55
+ isAvailable: boolean;
56
+ config: EmbeddedWalletConfig | null;
57
+ info: WalletInfo | null;
58
+ connectors: EmbeddedWalletConnectors;
52
59
  loginByGoogle: (() => Promise<string>) | null;
53
60
  loginByX: (() => Promise<string>) | null;
54
61
  loginStatusCallback: (({ type }: {
@@ -56,7 +63,7 @@ declare class EmbeddedWallet {
56
63
  }) => void) | null;
57
64
  constructor();
58
65
  static getInstance(): EmbeddedWallet;
59
- init(config: InitConfig): Promise<{
66
+ init(config: EmbeddedWalletConfig): Promise<{
60
67
  isAvailable: boolean;
61
68
  message: string | undefined;
62
69
  connectedInfo: any;
@@ -99,4 +106,4 @@ declare class EmbeddedWallet {
99
106
  open(method: WalletOpenMethod, params?: any): Promise<any>;
100
107
  }
101
108
 
102
- export { EmbeddedWallet, type EmbeddedWalletConfig, type InitConfig };
109
+ export { EmbeddedWallet, type EmbeddedWalletConfig };
package/dist/index.js CHANGED
@@ -1,8 +1,26 @@
1
- import { BtcProvider, DogecoinProvider, EvmProvider, SolanaProvider, TronProvider } from '@tomo-inc/inject-providers';
2
- import { ChainTypes } from '@tomo-inc/wallet-utils';
1
+ import { TronProvider, SolanaProvider, DogecoinProvider, BitcoinProvider, EvmProvider } from '@tomo-inc/inject-providers';
2
+ import { ChainTypeEnum, ProviderProtocol, ProviderStandard } from '@tomo-inc/wallet-utils';
3
3
  import { OidcAuth } from '@tomo-inc/oidc-auth';
4
4
 
5
- // src/embedded-wallet.ts
5
+ var __defProp = Object.defineProperty;
6
+ var __defProps = Object.defineProperties;
7
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
6
24
  var evmDappPopups = {
7
25
  connect: "/dapp/connect",
8
26
  eth_requestAccounts: "/dapp/connect",
@@ -78,11 +96,11 @@ var shopDappPopups = {
78
96
  rewardClaimedDialog: "/dapp-shop/dialog"
79
97
  };
80
98
  var dappPopups = {
81
- [ChainTypes.EVM]: evmDappPopups,
82
- [ChainTypes.DOGE]: dogeDappPopups,
83
- [ChainTypes.SOL]: solanaDappPopups,
84
- [ChainTypes.TRON]: tronDappPopups,
85
- [ChainTypes.BTC]: btcDappPopups,
99
+ [ChainTypeEnum.EVM]: evmDappPopups,
100
+ [ChainTypeEnum.DOGECOIN]: dogeDappPopups,
101
+ [ChainTypeEnum.SOLANA]: solanaDappPopups,
102
+ [ChainTypeEnum.TRON]: tronDappPopups,
103
+ [ChainTypeEnum.BITCOIN]: btcDappPopups,
86
104
  shop: shopDappPopups
87
105
  };
88
106
 
@@ -143,18 +161,24 @@ var onResponse = async (requestParams) => {
143
161
  };
144
162
  var EmbeddedWallet = class _EmbeddedWallet {
145
163
  constructor() {
146
- this.isAvailable = false;
147
- this.config = null;
148
- this.info = null;
149
- this.btcProvider = null;
150
- this.dogecoinProvider = null;
151
- this.evmProvider = null;
152
- this.solanaProvider = null;
153
- this.tronProvider = null;
164
+ this.themeConfig = null;
154
165
  this.walletIframe = null;
155
166
  this.walletOrigin = "";
156
167
  this.maskZIndex = 999;
157
- this.persistedTheme = null;
168
+ this.isAvailable = false;
169
+ this.config = null;
170
+ this.info = null;
171
+ this.connectors = {
172
+ [ChainTypeEnum.BITCOIN]: null,
173
+ [ChainTypeEnum.DOGECOIN]: null,
174
+ [ChainTypeEnum.EVM]: null,
175
+ [ChainTypeEnum.SOLANA]: null,
176
+ [ChainTypeEnum.TRON]: null,
177
+ [ChainTypeEnum.SUI]: null,
178
+ [ChainTypeEnum.TON]: null,
179
+ [ChainTypeEnum.COSMOS]: null,
180
+ [ChainTypeEnum.APTOS]: null
181
+ };
158
182
  this.loginByGoogle = null;
159
183
  this.loginByX = null;
160
184
  this.loginStatusCallback = null;
@@ -179,10 +203,9 @@ var EmbeddedWallet = class _EmbeddedWallet {
179
203
  return _EmbeddedWallet.instance;
180
204
  }
181
205
  async init(config) {
182
- var _a;
183
- this.config = config;
184
- if (!config.tomoClientId) {
185
- throw new Error("tomoClientId is required.");
206
+ this.config = __spreadValues({}, config);
207
+ if (!config.clientId) {
208
+ throw new Error("clientId is required.");
186
209
  }
187
210
  if (!config.walletBaseUrl) {
188
211
  throw new Error("walletBaseUrl is required.");
@@ -195,33 +218,58 @@ var EmbeddedWallet = class _EmbeddedWallet {
195
218
  }
196
219
  hostArr.reverse();
197
220
  const rdns = hostArr.join(".");
198
- this.info = {
199
- uuid: hostArr.join("-"),
200
- name: config.name,
201
- icon: config.logo,
202
- rdns,
203
- links: {
204
- homepage: config.walletBaseUrl
205
- }
206
- };
207
221
  const productInfo = {
208
222
  name: config.name,
209
223
  rdns,
210
224
  icon: config.logo
211
225
  };
212
- this.btcProvider = new BtcProvider(productInfo, { sendRequest, onResponse });
213
- this.dogecoinProvider = new DogecoinProvider(productInfo, { sendRequest, onResponse });
214
- this.evmProvider = new EvmProvider(productInfo, { sendRequest, onResponse });
215
- this.solanaProvider = new SolanaProvider(productInfo, { sendRequest, onResponse });
216
- this.tronProvider = new TronProvider(productInfo, { sendRequest, onResponse });
217
- const { loginByGoogle, loginByX } = OidcAuth(config);
226
+ this.info = __spreadProps(__spreadValues({}, productInfo), {
227
+ uuid: hostArr.join("-"),
228
+ links: {
229
+ homepage: config.walletBaseUrl
230
+ }
231
+ });
232
+ this.connectors = __spreadProps(__spreadValues({}, this.connectors), {
233
+ [ChainTypeEnum.EVM]: {
234
+ provider: new EvmProvider(productInfo, { sendRequest, onResponse }),
235
+ standard: ProviderStandard.EIP1193,
236
+ protocol: ProviderProtocol.INJECT
237
+ },
238
+ [ChainTypeEnum.BITCOIN]: {
239
+ provider: new BitcoinProvider(productInfo, { sendRequest, onResponse }),
240
+ standard: ProviderStandard.NORMAL,
241
+ protocol: ProviderProtocol.INJECT
242
+ },
243
+ [ChainTypeEnum.DOGECOIN]: {
244
+ provider: new DogecoinProvider(productInfo, { sendRequest, onResponse }),
245
+ standard: ProviderStandard.NORMAL,
246
+ protocol: ProviderProtocol.INJECT
247
+ },
248
+ [ChainTypeEnum.SOLANA]: {
249
+ provider: new SolanaProvider(productInfo, { sendRequest, onResponse }),
250
+ standard: ProviderStandard.NORMAL,
251
+ protocol: ProviderProtocol.INJECT
252
+ },
253
+ [ChainTypeEnum.TRON]: {
254
+ provider: new TronProvider(productInfo, { sendRequest, onResponse }),
255
+ standard: ProviderStandard.NORMAL,
256
+ protocol: ProviderProtocol.INJECT
257
+ }
258
+ });
259
+ const { loginByGoogle, loginByX } = OidcAuth({
260
+ tomoStage: config.stage,
261
+ xClientId: config.xClientId,
262
+ googleClientId: config.googleClientId
263
+ });
218
264
  this.loginByGoogle = loginByGoogle;
219
265
  this.loginByX = loginByX;
220
266
  const { isAvailable, message, connectedInfo } = await this.login();
221
267
  this.isAvailable = isAvailable;
268
+ console.log("embedded-wallet-providers connectedInfo::", connectedInfo);
222
269
  const { connected, address = [] } = (connectedInfo == null ? void 0 : connectedInfo.evmProvider) || {};
223
270
  if (connected && address.length > 0) {
224
- (_a = this.evmProvider) == null ? void 0 : _a.setConnectedStatus({ connected, address });
271
+ const evmConnector = this.connectors[ChainTypeEnum.EVM];
272
+ (evmConnector == null ? void 0 : evmConnector.provider) && evmConnector.provider.setConnectedStatus({ connected, address });
225
273
  }
226
274
  return { isAvailable, message, connectedInfo };
227
275
  }
@@ -238,11 +286,11 @@ var EmbeddedWallet = class _EmbeddedWallet {
238
286
  }
239
287
  return new Promise((resolve, reject) => {
240
288
  try {
241
- const { walletBaseUrl, tomoClientId, tomoStage, logo, name } = config || {};
242
- if (!walletBaseUrl || !tomoClientId) {
243
- throw new Error("walletBaseUrl + tomoClientId is required");
289
+ const { walletBaseUrl, clientId, stage, logo, name } = config || {};
290
+ if (!walletBaseUrl || !clientId) {
291
+ throw new Error("walletBaseUrl + clientId is required");
244
292
  }
245
- const EMBEDDED_WALLET_ID = tomoClientId;
293
+ const EMBEDDED_WALLET_ID = clientId;
246
294
  let walletIframe = document.getElementById(EMBEDDED_WALLET_ID);
247
295
  if (!walletIframe) {
248
296
  walletIframe = document.createElement("iframe");
@@ -250,8 +298,15 @@ var EmbeddedWallet = class _EmbeddedWallet {
250
298
  walletIframe.id = EMBEDDED_WALLET_ID;
251
299
  document.body.appendChild(walletIframe);
252
300
  }
253
- const dappOrigin = window.location.origin;
254
- walletIframe.src = `${walletBaseUrl}#dappOrigin=${dappOrigin}&tomoStage=${tomoStage}&tomoClientId=${tomoClientId}&oidcToken=${oidcToken || ""}&logo=${logo || ""}&name=${name || ""}`;
301
+ const searchParams = new URLSearchParams({
302
+ dappOrigin: window.location.origin,
303
+ tomoStage: stage,
304
+ tomoClientId: clientId,
305
+ oidcToken: oidcToken || "",
306
+ logo: logo || "",
307
+ name: name || ""
308
+ });
309
+ walletIframe.src = `${walletBaseUrl}#${searchParams.toString()}`;
255
310
  walletIframe.allow = "publickey-credentials-get; publickey-credentials-create";
256
311
  this.walletIframe = walletIframe;
257
312
  } catch (error) {
@@ -261,10 +316,11 @@ var EmbeddedWallet = class _EmbeddedWallet {
261
316
  const receiveResponse = ({ origin, data }) => {
262
317
  var _a;
263
318
  if ((data == null ? void 0 : data.type) === "wallet-ready" && origin === this.walletOrigin) {
319
+ console.log("------receiveResponse", data, origin);
264
320
  this.isAvailable = ((_a = data == null ? void 0 : data.data) == null ? void 0 : _a.isAvailable) || false;
265
- if (this.persistedTheme) {
321
+ if (this.themeConfig) {
266
322
  setTimeout(() => {
267
- this.request("theme-change", this.persistedTheme);
323
+ this.request("theme-change", this.themeConfig);
268
324
  }, 0);
269
325
  }
270
326
  resolve(data == null ? void 0 : data.data);
@@ -282,7 +338,7 @@ var EmbeddedWallet = class _EmbeddedWallet {
282
338
  });
283
339
  }
284
340
  async themeChange(theme) {
285
- this.persistedTheme = theme;
341
+ this.themeConfig = theme;
286
342
  this.request("theme-change", theme);
287
343
  }
288
344
  popup() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomo-inc/embedded-wallet-providers",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "author": "tomo.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@tomo-inc/oidc-auth": "0.0.16",
20
- "@tomo-inc/wallet-utils": "0.0.16",
21
- "@tomo-inc/inject-providers": "0.0.14"
20
+ "@tomo-inc/wallet-utils": "0.0.17",
21
+ "@tomo-inc/inject-providers": "0.0.15"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^20.0.0",
@@ -1,24 +1,45 @@
1
- import { BtcProvider, DogecoinProvider, EvmProvider, SolanaProvider, TronProvider } from "@tomo-inc/inject-providers";
1
+ import {
2
+ BitcoinProvider,
3
+ DogecoinProvider,
4
+ EvmProvider,
5
+ SolanaProvider,
6
+ TronProvider,
7
+ } from "@tomo-inc/inject-providers";
2
8
  import { onResponse, sendRequest } from "./hub";
3
9
 
4
10
  import { OidcAuth } from "@tomo-inc/oidc-auth";
5
- import { InitConfig, WalletInfo, WalletOpenMethod, WalletRequestMethod } from "./types";
6
-
11
+ import { ChainTypeEnum, ProviderProtocol, ProviderStandard } from "@tomo-inc/wallet-utils";
12
+ import {
13
+ EmbeddedWalletConfig,
14
+ EmbeddedWalletConnectors,
15
+ WalletInfo,
16
+ WalletOpenMethod,
17
+ WalletRequestMethod,
18
+ } from "./types";
19
+
20
+ // ------------------------------------------------------------
7
21
  export class EmbeddedWallet {
8
- public isAvailable: boolean = false;
9
- public config: InitConfig | null = null;
10
- public info: WalletInfo | null = null;
11
- public btcProvider: BtcProvider | null = null;
12
- public dogecoinProvider: DogecoinProvider | null = null;
13
- public evmProvider: EvmProvider | null = null;
14
- public solanaProvider: SolanaProvider | null = null;
15
- public tronProvider: TronProvider | null = null;
22
+ private static instance: EmbeddedWallet;
23
+ private themeConfig: any | null = null;
16
24
 
17
25
  public walletIframe: HTMLIFrameElement | null = null;
18
26
  public walletOrigin: string = "";
19
27
  public maskZIndex: number = 999;
20
- private static instance: EmbeddedWallet;
21
- private persistedTheme: any | null = null;
28
+ public isAvailable: boolean = false;
29
+ public config: EmbeddedWalletConfig | null = null;
30
+ public info: WalletInfo | null = null;
31
+ public connectors: EmbeddedWalletConnectors = {
32
+ [ChainTypeEnum.BITCOIN]: null,
33
+ [ChainTypeEnum.DOGECOIN]: null,
34
+ [ChainTypeEnum.EVM]: null,
35
+ [ChainTypeEnum.SOLANA]: null,
36
+ [ChainTypeEnum.TRON]: null,
37
+ [ChainTypeEnum.SUI]: null,
38
+ [ChainTypeEnum.TON]: null,
39
+ [ChainTypeEnum.COSMOS]: null,
40
+ [ChainTypeEnum.APTOS]: null,
41
+ };
42
+
22
43
  public loginByGoogle: (() => Promise<string>) | null = null;
23
44
  public loginByX: (() => Promise<string>) | null = null;
24
45
  public loginStatusCallback: (({ type }: { type: string }) => void) | null = null;
@@ -31,12 +52,13 @@ export class EmbeddedWallet {
31
52
  return EmbeddedWallet.instance;
32
53
  }
33
54
 
34
- public async init(config: InitConfig) {
35
- this.config = config;
55
+ public async init(config: EmbeddedWalletConfig) {
56
+ this.config = { ...config };
36
57
 
37
- if (!config.tomoClientId) {
38
- throw new Error("tomoClientId is required.");
58
+ if (!config.clientId) {
59
+ throw new Error("clientId is required.");
39
60
  }
61
+
40
62
  if (!config.walletBaseUrl) {
41
63
  throw new Error("walletBaseUrl is required.");
42
64
  }
@@ -50,29 +72,54 @@ export class EmbeddedWallet {
50
72
  hostArr.reverse();
51
73
  const rdns = hostArr.join(".");
52
74
 
53
- this.info = {
54
- uuid: hostArr.join("-"),
75
+ const productInfo = {
55
76
  name: config.name,
56
- icon: config.logo,
57
77
  rdns,
78
+ icon: config.logo,
79
+ };
80
+
81
+ this.info = {
82
+ ...productInfo,
83
+ uuid: hostArr.join("-"),
58
84
  links: {
59
85
  homepage: config.walletBaseUrl,
60
86
  },
61
87
  };
62
88
 
63
- const productInfo = {
64
- name: config.name,
65
- rdns,
66
- icon: config.logo,
89
+ this.connectors = {
90
+ ...this.connectors,
91
+ [ChainTypeEnum.EVM]: {
92
+ provider: new EvmProvider(productInfo, { sendRequest, onResponse }),
93
+ standard: ProviderStandard.EIP1193,
94
+ protocol: ProviderProtocol.INJECT,
95
+ },
96
+ [ChainTypeEnum.BITCOIN]: {
97
+ provider: new BitcoinProvider(productInfo, { sendRequest, onResponse }),
98
+ standard: ProviderStandard.NORMAL,
99
+ protocol: ProviderProtocol.INJECT,
100
+ },
101
+ [ChainTypeEnum.DOGECOIN]: {
102
+ provider: new DogecoinProvider(productInfo, { sendRequest, onResponse }),
103
+ standard: ProviderStandard.NORMAL,
104
+ protocol: ProviderProtocol.INJECT,
105
+ },
106
+ [ChainTypeEnum.SOLANA]: {
107
+ provider: new SolanaProvider(productInfo, { sendRequest, onResponse }),
108
+ standard: ProviderStandard.NORMAL,
109
+ protocol: ProviderProtocol.INJECT,
110
+ },
111
+ [ChainTypeEnum.TRON]: {
112
+ provider: new TronProvider(productInfo, { sendRequest, onResponse }),
113
+ standard: ProviderStandard.NORMAL,
114
+ protocol: ProviderProtocol.INJECT,
115
+ },
67
116
  };
68
117
 
69
- this.btcProvider = new BtcProvider(productInfo, { sendRequest, onResponse });
70
- this.dogecoinProvider = new DogecoinProvider(productInfo, { sendRequest, onResponse });
71
- this.evmProvider = new EvmProvider(productInfo, { sendRequest, onResponse });
72
- this.solanaProvider = new SolanaProvider(productInfo, { sendRequest, onResponse });
73
- this.tronProvider = new TronProvider(productInfo, { sendRequest, onResponse });
74
-
75
- const { loginByGoogle, loginByX } = OidcAuth(config);
118
+ const { loginByGoogle, loginByX } = OidcAuth({
119
+ tomoStage: config.stage,
120
+ xClientId: config.xClientId,
121
+ googleClientId: config.googleClientId,
122
+ });
76
123
 
77
124
  this.loginByGoogle = loginByGoogle;
78
125
  this.loginByX = loginByX;
@@ -80,9 +127,12 @@ export class EmbeddedWallet {
80
127
  const { isAvailable, message, connectedInfo } = await this.login();
81
128
  this.isAvailable = isAvailable;
82
129
 
130
+ console.log("embedded-wallet-providers connectedInfo::", connectedInfo);
131
+
83
132
  const { connected, address = [] } = connectedInfo?.evmProvider || {};
84
133
  if (connected && address.length > 0) {
85
- this.evmProvider?.setConnectedStatus({ connected, address });
134
+ const evmConnector = this.connectors[ChainTypeEnum.EVM];
135
+ evmConnector?.provider && evmConnector.provider.setConnectedStatus({ connected, address });
86
136
  }
87
137
  return { isAvailable, message, connectedInfo };
88
138
  }
@@ -102,12 +152,12 @@ export class EmbeddedWallet {
102
152
 
103
153
  return new Promise((resolve, reject) => {
104
154
  try {
105
- const { walletBaseUrl, tomoClientId, tomoStage, logo, name } = config || {};
106
- if (!walletBaseUrl || !tomoClientId) {
107
- throw new Error("walletBaseUrl + tomoClientId is required");
155
+ const { walletBaseUrl, clientId, stage, logo, name } = config || {};
156
+ if (!walletBaseUrl || !clientId) {
157
+ throw new Error("walletBaseUrl + clientId is required");
108
158
  }
109
159
 
110
- const EMBEDDED_WALLET_ID = tomoClientId;
160
+ const EMBEDDED_WALLET_ID = clientId;
111
161
 
112
162
  let walletIframe = document.getElementById(EMBEDDED_WALLET_ID) as HTMLIFrameElement | null;
113
163
  if (!walletIframe) {
@@ -116,9 +166,15 @@ export class EmbeddedWallet {
116
166
  walletIframe.id = EMBEDDED_WALLET_ID;
117
167
  document.body.appendChild(walletIframe);
118
168
  }
119
-
120
- const dappOrigin = window.location.origin;
121
- walletIframe.src = `${walletBaseUrl}#dappOrigin=${dappOrigin}&tomoStage=${tomoStage}&tomoClientId=${tomoClientId}&oidcToken=${oidcToken || ""}&logo=${logo || ""}&name=${name || ""}`;
169
+ const searchParams = new URLSearchParams({
170
+ dappOrigin: window.location.origin,
171
+ tomoStage: stage,
172
+ tomoClientId: clientId,
173
+ oidcToken: oidcToken || "",
174
+ logo: logo || "",
175
+ name: name || "",
176
+ });
177
+ walletIframe.src = `${walletBaseUrl}#${searchParams.toString()}`;
122
178
  walletIframe.allow = "publickey-credentials-get; publickey-credentials-create";
123
179
  this.walletIframe = walletIframe;
124
180
  } catch (error) {
@@ -128,12 +184,13 @@ export class EmbeddedWallet {
128
184
 
129
185
  const receiveResponse = ({ origin, data }: { origin: string; data: any }) => {
130
186
  if (data?.type === "wallet-ready" && origin === this.walletOrigin) {
187
+ console.log("------receiveResponse", data, origin);
131
188
  this.isAvailable = data?.data?.isAvailable || false;
132
189
  // Apply persisted theme after wallet is ready
133
- if (this.persistedTheme) {
190
+ if (this.themeConfig) {
134
191
  // Apply persisted theme asynchronously
135
192
  setTimeout(() => {
136
- this.request("theme-change", this.persistedTheme);
193
+ this.request("theme-change", this.themeConfig);
137
194
  }, 0);
138
195
  }
139
196
  resolve(data?.data);
@@ -154,7 +211,7 @@ export class EmbeddedWallet {
154
211
 
155
212
  public async themeChange(theme: any) {
156
213
  // Persist theme to memory
157
- this.persistedTheme = theme;
214
+ this.themeConfig = theme;
158
215
  this.request("theme-change", theme);
159
216
  }
160
217
 
@@ -185,13 +242,6 @@ export class EmbeddedWallet {
185
242
  * call relay for cubist logout, retrieve sessionInfo
186
243
  */
187
244
  public async logout(): Promise<boolean> {
188
- // const { tomoClientId = "" } = this.config || {};
189
- // if (tomoClientId) {
190
- // const walletIframe = document.getElementById(tomoClientId) as HTMLIFrameElement | null;
191
- // if (walletIframe) {
192
- // walletIframe.parentElement?.removeChild(walletIframe);
193
- // }
194
- // }
195
245
  if (this.walletIframe) {
196
246
  this.walletIframe.src = `${this.walletOrigin}#logout=true`;
197
247
  }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { EmbeddedWalletConfig, InitConfig } from "./types";
1
+ export type { EmbeddedWalletConfig } from "./types";
2
2
 
3
3
  export type { EmailLoginResult } from "@tomo-inc/oidc-auth";
4
4
 
@@ -1,4 +1,4 @@
1
- import { ChainTypes } from "@tomo-inc/wallet-utils";
1
+ import { ChainTypeEnum } from "@tomo-inc/wallet-utils";
2
2
 
3
3
  /*
4
4
  popups = {
@@ -94,11 +94,11 @@ const shopDappPopups = {
94
94
  };
95
95
 
96
96
  const dappPopups = {
97
- [ChainTypes.EVM]: evmDappPopups,
98
- [ChainTypes.DOGE]: dogeDappPopups,
99
- [ChainTypes.SOL]: solanaDappPopups,
100
- [ChainTypes.TRON]: tronDappPopups,
101
- [ChainTypes.BTC]: btcDappPopups,
97
+ [ChainTypeEnum.EVM]: evmDappPopups,
98
+ [ChainTypeEnum.DOGECOIN]: dogeDappPopups,
99
+ [ChainTypeEnum.SOLANA]: solanaDappPopups,
100
+ [ChainTypeEnum.TRON]: tronDappPopups,
101
+ [ChainTypeEnum.BITCOIN]: btcDappPopups,
102
102
  shop: shopDappPopups,
103
103
  };
104
104
 
package/src/types.ts CHANGED
@@ -1,15 +1,14 @@
1
- export interface InitConfig {
2
- xClientId: string;
3
- googleClientId: string;
4
- name: string;
5
- logo: string;
6
- tomoStage: "dev" | "prod";
7
- tomoClientId: string;
8
- walletBaseUrl: string;
9
- relayBaseUrl?: string;
10
- theme: any;
11
- }
1
+ import {
2
+ BitcoinProvider,
3
+ DogecoinProvider,
4
+ EvmProvider,
5
+ SolanaProvider,
6
+ TronProvider,
7
+ } from "@tomo-inc/inject-providers";
8
+
9
+ import { ChainTypeEnum, ProviderProtocol, ProviderStandard } from "@tomo-inc/wallet-utils";
12
10
 
11
+ export type TomoStage = "dev" | "pre" | "prod";
13
12
  export interface WalletInfo {
14
13
  uuid: string;
15
14
  name: string;
@@ -34,12 +33,49 @@ export type WalletRequestMethod =
34
33
  export type WalletOpenMethod = "wallet" | "swap" | "onRamp" | "funding" | "mfaVerify" | "mnemonic" | "setting";
35
34
 
36
35
  export type EmbeddedWalletConfig = {
37
- tomoStage: "dev" | "pre" | "prod";
36
+ // social services client ids
37
+ xClientId: string;
38
+ googleClientId: string;
39
+ clientId: string;
40
+
41
+ // wallet info
38
42
  name: string;
39
43
  logo: string;
40
- clientId: string;
41
- googleClientId: string;
42
- xClientId: string;
44
+
45
+ // tomo services configuration
46
+ stage: TomoStage;
43
47
  walletBaseUrl: string;
48
+ relayBaseUrl?: string;
49
+ // See: @tomo-inc/tomo-ui/types.ts
50
+ theme?: any;
51
+
44
52
  [key: string]: unknown;
45
53
  };
54
+
55
+ export type UnsupportedType = null;
56
+ export type ProviderType =
57
+ | BitcoinProvider
58
+ | DogecoinProvider
59
+ | EvmProvider
60
+ | SolanaProvider
61
+ | TronProvider
62
+ | UnsupportedType;
63
+
64
+ export type ProviderConfig<TProvider> = {
65
+ provider: TProvider;
66
+ standard: ProviderStandard;
67
+ protocol: ProviderProtocol;
68
+ };
69
+
70
+ /** Maps each chain type to its provider so that providers[ChainTypeEnum.EVM] is inferred as EvmProvider | null, etc. */
71
+ export type EmbeddedWalletConnectors = {
72
+ [ChainTypeEnum.BITCOIN]: ProviderConfig<BitcoinProvider> | UnsupportedType;
73
+ [ChainTypeEnum.DOGECOIN]: ProviderConfig<DogecoinProvider> | UnsupportedType;
74
+ [ChainTypeEnum.EVM]: ProviderConfig<EvmProvider> | UnsupportedType;
75
+ [ChainTypeEnum.SOLANA]: ProviderConfig<SolanaProvider> | UnsupportedType;
76
+ [ChainTypeEnum.TRON]: ProviderConfig<TronProvider> | UnsupportedType;
77
+ [ChainTypeEnum.SUI]: UnsupportedType;
78
+ [ChainTypeEnum.TON]: UnsupportedType;
79
+ [ChainTypeEnum.COSMOS]: UnsupportedType;
80
+ [ChainTypeEnum.APTOS]: UnsupportedType;
81
+ };