@tomo-inc/embedded-wallet-providers 0.0.15 → 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,17 +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;
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
+ };
159
184
  this.loginByGoogle = null;
160
185
  this.loginByX = null;
161
186
  this.loginStatusCallback = null;
@@ -180,10 +205,9 @@ var EmbeddedWallet = class _EmbeddedWallet {
180
205
  return _EmbeddedWallet.instance;
181
206
  }
182
207
  async init(config) {
183
- var _a;
184
- this.config = config;
185
- if (!config.tomoClientId) {
186
- throw new Error("tomoClientId is required.");
208
+ this.config = __spreadValues({}, config);
209
+ if (!config.clientId) {
210
+ throw new Error("clientId is required.");
187
211
  }
188
212
  if (!config.walletBaseUrl) {
189
213
  throw new Error("walletBaseUrl is required.");
@@ -196,33 +220,58 @@ var EmbeddedWallet = class _EmbeddedWallet {
196
220
  }
197
221
  hostArr.reverse();
198
222
  const rdns = hostArr.join(".");
199
- this.info = {
200
- uuid: hostArr.join("-"),
201
- name: config.name,
202
- icon: config.logo,
203
- rdns,
204
- links: {
205
- homepage: config.walletBaseUrl
206
- }
207
- };
208
223
  const productInfo = {
209
224
  name: config.name,
210
225
  rdns,
211
226
  icon: config.logo
212
227
  };
213
- this.btcProvider = new injectProviders.BtcProvider(productInfo, { sendRequest, onResponse });
214
- this.dogecoinProvider = new injectProviders.DogecoinProvider(productInfo, { sendRequest, onResponse });
215
- this.evmProvider = new injectProviders.EvmProvider(productInfo, { sendRequest, onResponse });
216
- this.solanaProvider = new injectProviders.SolanaProvider(productInfo, { sendRequest, onResponse });
217
- this.tronProvider = new injectProviders.TronProvider(productInfo, { sendRequest, onResponse });
218
- 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
+ });
219
266
  this.loginByGoogle = loginByGoogle;
220
267
  this.loginByX = loginByX;
221
268
  const { isAvailable, message, connectedInfo } = await this.login();
222
269
  this.isAvailable = isAvailable;
270
+ console.log("embedded-wallet-providers connectedInfo::", connectedInfo);
223
271
  const { connected, address = [] } = (connectedInfo == null ? void 0 : connectedInfo.evmProvider) || {};
224
272
  if (connected && address.length > 0) {
225
- (_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 });
226
275
  }
227
276
  return { isAvailable, message, connectedInfo };
228
277
  }
@@ -239,11 +288,11 @@ var EmbeddedWallet = class _EmbeddedWallet {
239
288
  }
240
289
  return new Promise((resolve, reject) => {
241
290
  try {
242
- const { walletBaseUrl, tomoClientId, tomoStage, logo, name } = config || {};
243
- if (!walletBaseUrl || !tomoClientId) {
244
- 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");
245
294
  }
246
- const EMBEDDED_WALLET_ID = tomoClientId;
295
+ const EMBEDDED_WALLET_ID = clientId;
247
296
  let walletIframe = document.getElementById(EMBEDDED_WALLET_ID);
248
297
  if (!walletIframe) {
249
298
  walletIframe = document.createElement("iframe");
@@ -251,8 +300,15 @@ var EmbeddedWallet = class _EmbeddedWallet {
251
300
  walletIframe.id = EMBEDDED_WALLET_ID;
252
301
  document.body.appendChild(walletIframe);
253
302
  }
254
- const dappOrigin = window.location.origin;
255
- 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()}`;
256
312
  walletIframe.allow = "publickey-credentials-get; publickey-credentials-create";
257
313
  this.walletIframe = walletIframe;
258
314
  } catch (error) {
@@ -262,7 +318,13 @@ var EmbeddedWallet = class _EmbeddedWallet {
262
318
  const receiveResponse = ({ origin, data }) => {
263
319
  var _a;
264
320
  if ((data == null ? void 0 : data.type) === "wallet-ready" && origin === this.walletOrigin) {
321
+ console.log("------receiveResponse", data, origin);
265
322
  this.isAvailable = ((_a = data == null ? void 0 : data.data) == null ? void 0 : _a.isAvailable) || false;
323
+ if (this.themeConfig) {
324
+ setTimeout(() => {
325
+ this.request("theme-change", this.themeConfig);
326
+ }, 0);
327
+ }
266
328
  resolve(data == null ? void 0 : data.data);
267
329
  if (this.loginStatusCallback) {
268
330
  this == null ? void 0 : this.loginStatusCallback({ type: "login" });
@@ -277,6 +339,10 @@ var EmbeddedWallet = class _EmbeddedWallet {
277
339
  window.addEventListener("message", this.walletCloseHandler);
278
340
  });
279
341
  }
342
+ async themeChange(theme) {
343
+ this.themeConfig = theme;
344
+ this.request("theme-change", theme);
345
+ }
280
346
  popup() {
281
347
  if (!this.walletIframe) {
282
348
  return;
package/dist/index.d.cts CHANGED
@@ -1,16 +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
- }
5
+ type TomoStage = "dev" | "pre" | "prod";
14
6
  interface WalletInfo {
15
7
  uuid: string;
16
8
  name: string;
@@ -21,22 +13,49 @@ interface WalletInfo {
21
13
  homepage: string;
22
14
  };
23
15
  }
24
- type WalletRequestMethod = "logout" | "token" | "market" | "assets" | "transactions" | "wallet" | "emailLogin";
16
+ type WalletRequestMethod = "logout" | "token" | "market" | "assets" | "transactions" | "wallet" | "emailLogin" | "theme-change";
25
17
  type WalletOpenMethod = "wallet" | "swap" | "onRamp" | "funding" | "mfaVerify" | "mnemonic" | "setting";
18
+ type EmbeddedWalletConfig = {
19
+ xClientId: string;
20
+ googleClientId: string;
21
+ clientId: string;
22
+ name: string;
23
+ logo: string;
24
+ stage: TomoStage;
25
+ walletBaseUrl: string;
26
+ relayBaseUrl?: string;
27
+ theme?: any;
28
+ [key: string]: unknown;
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
+ };
26
48
 
27
49
  declare class EmbeddedWallet {
28
- isAvailable: boolean;
29
- config: InitConfig | null;
30
- info: WalletInfo | null;
31
- btcProvider: BtcProvider | null;
32
- dogecoinProvider: DogecoinProvider | null;
33
- evmProvider: EvmProvider | null;
34
- solanaProvider: SolanaProvider | null;
35
- tronProvider: TronProvider | null;
50
+ private static instance;
51
+ private themeConfig;
36
52
  walletIframe: HTMLIFrameElement | null;
37
53
  walletOrigin: string;
38
54
  maskZIndex: number;
39
- private static instance;
55
+ isAvailable: boolean;
56
+ config: EmbeddedWalletConfig | null;
57
+ info: WalletInfo | null;
58
+ connectors: EmbeddedWalletConnectors;
40
59
  loginByGoogle: (() => Promise<string>) | null;
41
60
  loginByX: (() => Promise<string>) | null;
42
61
  loginStatusCallback: (({ type }: {
@@ -44,7 +63,7 @@ declare class EmbeddedWallet {
44
63
  }) => void) | null;
45
64
  constructor();
46
65
  static getInstance(): EmbeddedWallet;
47
- init(config: InitConfig): Promise<{
66
+ init(config: EmbeddedWalletConfig): Promise<{
48
67
  isAvailable: boolean;
49
68
  message: string | undefined;
50
69
  connectedInfo: any;
@@ -58,6 +77,7 @@ declare class EmbeddedWallet {
58
77
  message?: string;
59
78
  isAvailable: boolean;
60
79
  }>;
80
+ themeChange(theme: any): Promise<void>;
61
81
  private walletCloseHandler;
62
82
  popup(): void;
63
83
  close(): void;
@@ -86,4 +106,4 @@ declare class EmbeddedWallet {
86
106
  open(method: WalletOpenMethod, params?: any): Promise<any>;
87
107
  }
88
108
 
89
- export { EmbeddedWallet, type InitConfig };
109
+ export { EmbeddedWallet, type EmbeddedWalletConfig };
package/dist/index.d.ts CHANGED
@@ -1,16 +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
- }
5
+ type TomoStage = "dev" | "pre" | "prod";
14
6
  interface WalletInfo {
15
7
  uuid: string;
16
8
  name: string;
@@ -21,22 +13,49 @@ interface WalletInfo {
21
13
  homepage: string;
22
14
  };
23
15
  }
24
- type WalletRequestMethod = "logout" | "token" | "market" | "assets" | "transactions" | "wallet" | "emailLogin";
16
+ type WalletRequestMethod = "logout" | "token" | "market" | "assets" | "transactions" | "wallet" | "emailLogin" | "theme-change";
25
17
  type WalletOpenMethod = "wallet" | "swap" | "onRamp" | "funding" | "mfaVerify" | "mnemonic" | "setting";
18
+ type EmbeddedWalletConfig = {
19
+ xClientId: string;
20
+ googleClientId: string;
21
+ clientId: string;
22
+ name: string;
23
+ logo: string;
24
+ stage: TomoStage;
25
+ walletBaseUrl: string;
26
+ relayBaseUrl?: string;
27
+ theme?: any;
28
+ [key: string]: unknown;
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
+ };
26
48
 
27
49
  declare class EmbeddedWallet {
28
- isAvailable: boolean;
29
- config: InitConfig | null;
30
- info: WalletInfo | null;
31
- btcProvider: BtcProvider | null;
32
- dogecoinProvider: DogecoinProvider | null;
33
- evmProvider: EvmProvider | null;
34
- solanaProvider: SolanaProvider | null;
35
- tronProvider: TronProvider | null;
50
+ private static instance;
51
+ private themeConfig;
36
52
  walletIframe: HTMLIFrameElement | null;
37
53
  walletOrigin: string;
38
54
  maskZIndex: number;
39
- private static instance;
55
+ isAvailable: boolean;
56
+ config: EmbeddedWalletConfig | null;
57
+ info: WalletInfo | null;
58
+ connectors: EmbeddedWalletConnectors;
40
59
  loginByGoogle: (() => Promise<string>) | null;
41
60
  loginByX: (() => Promise<string>) | null;
42
61
  loginStatusCallback: (({ type }: {
@@ -44,7 +63,7 @@ declare class EmbeddedWallet {
44
63
  }) => void) | null;
45
64
  constructor();
46
65
  static getInstance(): EmbeddedWallet;
47
- init(config: InitConfig): Promise<{
66
+ init(config: EmbeddedWalletConfig): Promise<{
48
67
  isAvailable: boolean;
49
68
  message: string | undefined;
50
69
  connectedInfo: any;
@@ -58,6 +77,7 @@ declare class EmbeddedWallet {
58
77
  message?: string;
59
78
  isAvailable: boolean;
60
79
  }>;
80
+ themeChange(theme: any): Promise<void>;
61
81
  private walletCloseHandler;
62
82
  popup(): void;
63
83
  close(): void;
@@ -86,4 +106,4 @@ declare class EmbeddedWallet {
86
106
  open(method: WalletOpenMethod, params?: any): Promise<any>;
87
107
  }
88
108
 
89
- export { EmbeddedWallet, 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,17 +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;
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
+ };
157
182
  this.loginByGoogle = null;
158
183
  this.loginByX = null;
159
184
  this.loginStatusCallback = null;
@@ -178,10 +203,9 @@ var EmbeddedWallet = class _EmbeddedWallet {
178
203
  return _EmbeddedWallet.instance;
179
204
  }
180
205
  async init(config) {
181
- var _a;
182
- this.config = config;
183
- if (!config.tomoClientId) {
184
- throw new Error("tomoClientId is required.");
206
+ this.config = __spreadValues({}, config);
207
+ if (!config.clientId) {
208
+ throw new Error("clientId is required.");
185
209
  }
186
210
  if (!config.walletBaseUrl) {
187
211
  throw new Error("walletBaseUrl is required.");
@@ -194,33 +218,58 @@ var EmbeddedWallet = class _EmbeddedWallet {
194
218
  }
195
219
  hostArr.reverse();
196
220
  const rdns = hostArr.join(".");
197
- this.info = {
198
- uuid: hostArr.join("-"),
199
- name: config.name,
200
- icon: config.logo,
201
- rdns,
202
- links: {
203
- homepage: config.walletBaseUrl
204
- }
205
- };
206
221
  const productInfo = {
207
222
  name: config.name,
208
223
  rdns,
209
224
  icon: config.logo
210
225
  };
211
- this.btcProvider = new BtcProvider(productInfo, { sendRequest, onResponse });
212
- this.dogecoinProvider = new DogecoinProvider(productInfo, { sendRequest, onResponse });
213
- this.evmProvider = new EvmProvider(productInfo, { sendRequest, onResponse });
214
- this.solanaProvider = new SolanaProvider(productInfo, { sendRequest, onResponse });
215
- this.tronProvider = new TronProvider(productInfo, { sendRequest, onResponse });
216
- 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
+ });
217
264
  this.loginByGoogle = loginByGoogle;
218
265
  this.loginByX = loginByX;
219
266
  const { isAvailable, message, connectedInfo } = await this.login();
220
267
  this.isAvailable = isAvailable;
268
+ console.log("embedded-wallet-providers connectedInfo::", connectedInfo);
221
269
  const { connected, address = [] } = (connectedInfo == null ? void 0 : connectedInfo.evmProvider) || {};
222
270
  if (connected && address.length > 0) {
223
- (_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 });
224
273
  }
225
274
  return { isAvailable, message, connectedInfo };
226
275
  }
@@ -237,11 +286,11 @@ var EmbeddedWallet = class _EmbeddedWallet {
237
286
  }
238
287
  return new Promise((resolve, reject) => {
239
288
  try {
240
- const { walletBaseUrl, tomoClientId, tomoStage, logo, name } = config || {};
241
- if (!walletBaseUrl || !tomoClientId) {
242
- 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");
243
292
  }
244
- const EMBEDDED_WALLET_ID = tomoClientId;
293
+ const EMBEDDED_WALLET_ID = clientId;
245
294
  let walletIframe = document.getElementById(EMBEDDED_WALLET_ID);
246
295
  if (!walletIframe) {
247
296
  walletIframe = document.createElement("iframe");
@@ -249,8 +298,15 @@ var EmbeddedWallet = class _EmbeddedWallet {
249
298
  walletIframe.id = EMBEDDED_WALLET_ID;
250
299
  document.body.appendChild(walletIframe);
251
300
  }
252
- const dappOrigin = window.location.origin;
253
- 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()}`;
254
310
  walletIframe.allow = "publickey-credentials-get; publickey-credentials-create";
255
311
  this.walletIframe = walletIframe;
256
312
  } catch (error) {
@@ -260,7 +316,13 @@ var EmbeddedWallet = class _EmbeddedWallet {
260
316
  const receiveResponse = ({ origin, data }) => {
261
317
  var _a;
262
318
  if ((data == null ? void 0 : data.type) === "wallet-ready" && origin === this.walletOrigin) {
319
+ console.log("------receiveResponse", data, origin);
263
320
  this.isAvailable = ((_a = data == null ? void 0 : data.data) == null ? void 0 : _a.isAvailable) || false;
321
+ if (this.themeConfig) {
322
+ setTimeout(() => {
323
+ this.request("theme-change", this.themeConfig);
324
+ }, 0);
325
+ }
264
326
  resolve(data == null ? void 0 : data.data);
265
327
  if (this.loginStatusCallback) {
266
328
  this == null ? void 0 : this.loginStatusCallback({ type: "login" });
@@ -275,6 +337,10 @@ var EmbeddedWallet = class _EmbeddedWallet {
275
337
  window.addEventListener("message", this.walletCloseHandler);
276
338
  });
277
339
  }
340
+ async themeChange(theme) {
341
+ this.themeConfig = theme;
342
+ this.request("theme-change", theme);
343
+ }
278
344
  popup() {
279
345
  if (!this.walletIframe) {
280
346
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomo-inc/embedded-wallet-providers",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "author": "tomo.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -16,9 +16,9 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "@tomo-inc/wallet-utils": "0.0.15",
20
- "@tomo-inc/oidc-auth": "0.0.15",
21
- "@tomo-inc/inject-providers": "0.0.13"
19
+ "@tomo-inc/oidc-auth": "0.0.16",
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,23 +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;
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
+
21
43
  public loginByGoogle: (() => Promise<string>) | null = null;
22
44
  public loginByX: (() => Promise<string>) | null = null;
23
45
  public loginStatusCallback: (({ type }: { type: string }) => void) | null = null;
@@ -30,12 +52,13 @@ export class EmbeddedWallet {
30
52
  return EmbeddedWallet.instance;
31
53
  }
32
54
 
33
- public async init(config: InitConfig) {
34
- this.config = config;
55
+ public async init(config: EmbeddedWalletConfig) {
56
+ this.config = { ...config };
35
57
 
36
- if (!config.tomoClientId) {
37
- throw new Error("tomoClientId is required.");
58
+ if (!config.clientId) {
59
+ throw new Error("clientId is required.");
38
60
  }
61
+
39
62
  if (!config.walletBaseUrl) {
40
63
  throw new Error("walletBaseUrl is required.");
41
64
  }
@@ -49,29 +72,54 @@ export class EmbeddedWallet {
49
72
  hostArr.reverse();
50
73
  const rdns = hostArr.join(".");
51
74
 
52
- this.info = {
53
- uuid: hostArr.join("-"),
75
+ const productInfo = {
54
76
  name: config.name,
55
- icon: config.logo,
56
77
  rdns,
78
+ icon: config.logo,
79
+ };
80
+
81
+ this.info = {
82
+ ...productInfo,
83
+ uuid: hostArr.join("-"),
57
84
  links: {
58
85
  homepage: config.walletBaseUrl,
59
86
  },
60
87
  };
61
88
 
62
- const productInfo = {
63
- name: config.name,
64
- rdns,
65
- 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
+ },
66
116
  };
67
117
 
68
- this.btcProvider = new BtcProvider(productInfo, { sendRequest, onResponse });
69
- this.dogecoinProvider = new DogecoinProvider(productInfo, { sendRequest, onResponse });
70
- this.evmProvider = new EvmProvider(productInfo, { sendRequest, onResponse });
71
- this.solanaProvider = new SolanaProvider(productInfo, { sendRequest, onResponse });
72
- this.tronProvider = new TronProvider(productInfo, { sendRequest, onResponse });
73
-
74
- const { loginByGoogle, loginByX } = OidcAuth(config);
118
+ const { loginByGoogle, loginByX } = OidcAuth({
119
+ tomoStage: config.stage,
120
+ xClientId: config.xClientId,
121
+ googleClientId: config.googleClientId,
122
+ });
75
123
 
76
124
  this.loginByGoogle = loginByGoogle;
77
125
  this.loginByX = loginByX;
@@ -79,9 +127,12 @@ export class EmbeddedWallet {
79
127
  const { isAvailable, message, connectedInfo } = await this.login();
80
128
  this.isAvailable = isAvailable;
81
129
 
130
+ console.log("embedded-wallet-providers connectedInfo::", connectedInfo);
131
+
82
132
  const { connected, address = [] } = connectedInfo?.evmProvider || {};
83
133
  if (connected && address.length > 0) {
84
- this.evmProvider?.setConnectedStatus({ connected, address });
134
+ const evmConnector = this.connectors[ChainTypeEnum.EVM];
135
+ evmConnector?.provider && evmConnector.provider.setConnectedStatus({ connected, address });
85
136
  }
86
137
  return { isAvailable, message, connectedInfo };
87
138
  }
@@ -101,12 +152,12 @@ export class EmbeddedWallet {
101
152
 
102
153
  return new Promise((resolve, reject) => {
103
154
  try {
104
- const { walletBaseUrl, tomoClientId, tomoStage, logo, name } = config || {};
105
- if (!walletBaseUrl || !tomoClientId) {
106
- 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");
107
158
  }
108
159
 
109
- const EMBEDDED_WALLET_ID = tomoClientId;
160
+ const EMBEDDED_WALLET_ID = clientId;
110
161
 
111
162
  let walletIframe = document.getElementById(EMBEDDED_WALLET_ID) as HTMLIFrameElement | null;
112
163
  if (!walletIframe) {
@@ -115,9 +166,15 @@ export class EmbeddedWallet {
115
166
  walletIframe.id = EMBEDDED_WALLET_ID;
116
167
  document.body.appendChild(walletIframe);
117
168
  }
118
-
119
- const dappOrigin = window.location.origin;
120
- 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()}`;
121
178
  walletIframe.allow = "publickey-credentials-get; publickey-credentials-create";
122
179
  this.walletIframe = walletIframe;
123
180
  } catch (error) {
@@ -127,7 +184,15 @@ export class EmbeddedWallet {
127
184
 
128
185
  const receiveResponse = ({ origin, data }: { origin: string; data: any }) => {
129
186
  if (data?.type === "wallet-ready" && origin === this.walletOrigin) {
187
+ console.log("------receiveResponse", data, origin);
130
188
  this.isAvailable = data?.data?.isAvailable || false;
189
+ // Apply persisted theme after wallet is ready
190
+ if (this.themeConfig) {
191
+ // Apply persisted theme asynchronously
192
+ setTimeout(() => {
193
+ this.request("theme-change", this.themeConfig);
194
+ }, 0);
195
+ }
131
196
  resolve(data?.data);
132
197
  if (this.loginStatusCallback) {
133
198
  this?.loginStatusCallback({ type: "login" });
@@ -144,6 +209,12 @@ export class EmbeddedWallet {
144
209
  });
145
210
  }
146
211
 
212
+ public async themeChange(theme: any) {
213
+ // Persist theme to memory
214
+ this.themeConfig = theme;
215
+ this.request("theme-change", theme);
216
+ }
217
+
147
218
  private walletCloseHandler = ({ origin, data }: { origin: string; data: any }) => {
148
219
  if (data?.type === "wallet-close" && origin === this.walletOrigin) {
149
220
  this.close();
@@ -171,13 +242,6 @@ export class EmbeddedWallet {
171
242
  * call relay for cubist logout, retrieve sessionInfo
172
243
  */
173
244
  public async logout(): Promise<boolean> {
174
- // const { tomoClientId = "" } = this.config || {};
175
- // if (tomoClientId) {
176
- // const walletIframe = document.getElementById(tomoClientId) as HTMLIFrameElement | null;
177
- // if (walletIframe) {
178
- // walletIframe.parentElement?.removeChild(walletIframe);
179
- // }
180
- // }
181
245
  if (this.walletIframe) {
182
246
  this.walletIframe.src = `${this.walletOrigin}#logout=true`;
183
247
  }
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
- import type { InitConfig } from "./types";
1
+ export type { EmbeddedWalletConfig } from "./types";
2
2
 
3
- export type { InitConfig };
4
- export { type EmailLoginResult } from "@tomo-inc/oidc-auth";
3
+ export type { EmailLoginResult } from "@tomo-inc/oidc-auth";
5
4
 
6
5
  export { EmbeddedWallet } from "./embedded-wallet";
@@ -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,14 +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
- }
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";
11
10
 
11
+ export type TomoStage = "dev" | "pre" | "prod";
12
12
  export interface WalletInfo {
13
13
  uuid: string;
14
14
  name: string;
@@ -20,6 +20,62 @@ export interface WalletInfo {
20
20
  };
21
21
  }
22
22
 
23
- export type WalletRequestMethod = "logout" | "token" | "market" | "assets" | "transactions" | "wallet" | "emailLogin";
23
+ export type WalletRequestMethod =
24
+ | "logout"
25
+ | "token"
26
+ | "market"
27
+ | "assets"
28
+ | "transactions"
29
+ | "wallet"
30
+ | "emailLogin"
31
+ | "theme-change";
24
32
 
25
33
  export type WalletOpenMethod = "wallet" | "swap" | "onRamp" | "funding" | "mfaVerify" | "mnemonic" | "setting";
34
+
35
+ export type EmbeddedWalletConfig = {
36
+ // social services client ids
37
+ xClientId: string;
38
+ googleClientId: string;
39
+ clientId: string;
40
+
41
+ // wallet info
42
+ name: string;
43
+ logo: string;
44
+
45
+ // tomo services configuration
46
+ stage: TomoStage;
47
+ walletBaseUrl: string;
48
+ relayBaseUrl?: string;
49
+ // See: @tomo-inc/tomo-ui/types.ts
50
+ theme?: any;
51
+
52
+ [key: string]: unknown;
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
+ };