@hot-labs/kit 1.0.39 → 1.0.41

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.
Files changed (233) hide show
  1. package/README.md +9 -1
  2. package/build/HotConnector.d.ts +25 -24
  3. package/build/HotConnector.js +25 -33
  4. package/build/HotConnector.js.map +1 -1
  5. package/build/OmniConnector.d.ts +3 -13
  6. package/build/OmniConnector.js +5 -7
  7. package/build/OmniConnector.js.map +1 -1
  8. package/build/OmniWallet.d.ts +4 -4
  9. package/build/OmniWallet.js +1 -1
  10. package/build/{omni → core}/Intents.js.map +1 -1
  11. package/build/{omni → core}/bridge.js +1 -0
  12. package/build/core/bridge.js.map +1 -0
  13. package/build/{omni → core}/config.js +5 -1
  14. package/build/{omni → core}/config.js.map +1 -1
  15. package/build/{omni → core}/defaultTokens.js.map +1 -1
  16. package/build/core/events.js.map +1 -0
  17. package/build/{omni → core}/index.d.ts +1 -0
  18. package/build/{omni → core}/index.js +1 -0
  19. package/build/{omni → core}/index.js.map +1 -1
  20. package/build/{omni → core}/nearRpc.js.map +1 -1
  21. package/build/{omni → core}/recipient.js.map +1 -1
  22. package/build/{omni → core}/token.js.map +1 -1
  23. package/build/{omni → core}/tokens.js.map +1 -1
  24. package/build/{omni → core}/types.js.map +1 -1
  25. package/build/{omni → core}/utils.js.map +1 -1
  26. package/build/cosmos/connector.d.ts +3 -3
  27. package/build/cosmos/connector.js +6 -4
  28. package/build/cosmos/connector.js.map +1 -1
  29. package/build/cosmos/index.d.ts +7 -0
  30. package/build/cosmos/index.js +5 -0
  31. package/build/cosmos/index.js.map +1 -0
  32. package/build/cosmos/wallet.d.ts +2 -2
  33. package/build/cosmos/wallet.js +1 -1
  34. package/build/defaults.d.ts +1 -0
  35. package/build/defaults.js +7 -0
  36. package/build/defaults.js.map +1 -0
  37. package/build/evm/connector.d.ts +3 -8
  38. package/build/evm/connector.js +13 -15
  39. package/build/evm/connector.js.map +1 -1
  40. package/build/evm/index.d.ts +6 -0
  41. package/build/evm/index.js +5 -0
  42. package/build/evm/index.js.map +1 -0
  43. package/build/{hot-wallet/evm.js → evm/injected.js} +2 -2
  44. package/build/evm/injected.js.map +1 -0
  45. package/build/evm/wallet.d.ts +3 -3
  46. package/build/evm/wallet.js +8 -4
  47. package/build/evm/wallet.js.map +1 -1
  48. package/build/exchange.d.ts +3 -3
  49. package/build/exchange.js +3 -3
  50. package/build/hot-wallet/google.d.ts +25 -0
  51. package/build/{GoogleConnector.js → hot-wallet/google.js} +51 -15
  52. package/build/hot-wallet/google.js.map +1 -0
  53. package/build/hot-wallet/{hot.js → iframe.js} +2 -9
  54. package/build/hot-wallet/{hot.js.map → iframe.js.map} +1 -1
  55. package/build/hot-wallet/index.d.ts +5 -4
  56. package/build/hot-wallet/index.js +3 -4
  57. package/build/hot-wallet/index.js.map +1 -1
  58. package/build/index.d.ts +1 -20
  59. package/build/index.js +1 -20
  60. package/build/index.js.map +1 -1
  61. package/build/near/connector.d.ts +2 -12
  62. package/build/near/connector.js +4 -4
  63. package/build/near/connector.js.map +1 -1
  64. package/build/near/index.d.ts +7 -0
  65. package/build/near/index.js +5 -0
  66. package/build/near/index.js.map +1 -0
  67. package/build/near/wallet.d.ts +3 -3
  68. package/build/near/wallet.js +3 -3
  69. package/build/solana/connector.d.ts +3 -4
  70. package/build/solana/connector.js +8 -8
  71. package/build/solana/connector.js.map +1 -1
  72. package/build/solana/index.d.ts +6 -0
  73. package/build/solana/index.js +5 -0
  74. package/build/solana/index.js.map +1 -0
  75. package/build/solana/injected/account.js.map +1 -0
  76. package/build/{hot-wallet/solana → solana/injected}/index.js +1 -1
  77. package/build/{hot-wallet/solana → solana/injected}/index.js.map +1 -1
  78. package/build/solana/injected/register.js.map +1 -0
  79. package/build/solana/injected/solana-wallet.js.map +1 -0
  80. package/build/solana/injected/utils.js.map +1 -0
  81. package/build/solana/wallet.d.ts +3 -3
  82. package/build/solana/wallet.js +3 -3
  83. package/build/stellar/connector.d.ts +1 -1
  84. package/build/stellar/connector.js +2 -2
  85. package/build/stellar/connector.js.map +1 -1
  86. package/build/stellar/index.d.ts +6 -0
  87. package/build/stellar/index.js +5 -0
  88. package/build/stellar/index.js.map +1 -0
  89. package/build/{hot-wallet/stellar.js → stellar/injected.js} +2 -2
  90. package/build/stellar/injected.js.map +1 -0
  91. package/build/stellar/wallet.d.ts +3 -3
  92. package/build/stellar/wallet.js +4 -4
  93. package/build/ton/connector.d.ts +1 -1
  94. package/build/ton/connector.js +2 -2
  95. package/build/ton/connector.js.map +1 -1
  96. package/build/ton/index.d.ts +7 -0
  97. package/build/ton/index.js +5 -0
  98. package/build/ton/index.js.map +1 -0
  99. package/build/{hot-wallet/ton.js → ton/injected.js} +2 -2
  100. package/build/ton/injected.js.map +1 -0
  101. package/build/ton/utils.js +1 -2
  102. package/build/ton/utils.js.map +1 -1
  103. package/build/ton/wallet.d.ts +3 -3
  104. package/build/ton/wallet.js +2 -2
  105. package/build/ui/connect/ConnectWallet.js +1 -1
  106. package/build/ui/payment/Bridge.d.ts +2 -2
  107. package/build/ui/payment/Bridge.js +7 -5
  108. package/build/ui/payment/Bridge.js.map +1 -1
  109. package/build/ui/payment/Payment.d.ts +2 -2
  110. package/build/ui/payment/Payment.js +2 -2
  111. package/build/ui/payment/Profile.js +2 -2
  112. package/build/ui/payment/SelectRecipient.d.ts +2 -2
  113. package/build/ui/payment/SelectRecipient.js +3 -3
  114. package/build/ui/payment/SelectSender.d.ts +1 -1
  115. package/build/ui/payment/SelectSender.js +2 -2
  116. package/build/ui/payment/SelectToken.d.ts +1 -1
  117. package/build/ui/payment/SelectToken.js +3 -3
  118. package/build/ui/payment/TokenCard.d.ts +1 -1
  119. package/build/ui/payment/TokenCard.js +2 -2
  120. package/build/ui/router.d.ts +3 -3
  121. package/build/ui/styles.js +4 -0
  122. package/build/ui/styles.js.map +1 -1
  123. package/package.json +10 -2
  124. package/src/HotConnector.ts +51 -45
  125. package/src/OmniConnector.ts +6 -11
  126. package/src/OmniWallet.ts +4 -4
  127. package/src/{omni → core}/bridge.ts +1 -0
  128. package/src/{omni → core}/config.ts +5 -1
  129. package/src/{omni → core}/index.ts +1 -0
  130. package/src/cosmos/connector.ts +18 -16
  131. package/src/cosmos/index.ts +9 -0
  132. package/src/cosmos/wallet.ts +2 -2
  133. package/src/defaults.ts +7 -0
  134. package/src/evm/connector.ts +18 -23
  135. package/src/evm/index.ts +7 -0
  136. package/src/{hot-wallet/evm.ts → evm/injected.ts} +1 -1
  137. package/src/evm/wallet.ts +10 -5
  138. package/src/exchange.ts +5 -5
  139. package/src/{GoogleConnector.ts → hot-wallet/google.ts} +60 -17
  140. package/src/hot-wallet/{hot.ts → iframe.ts} +1 -8
  141. package/src/hot-wallet/index.ts +6 -4
  142. package/src/index.ts +2 -25
  143. package/src/near/connector.ts +4 -15
  144. package/src/near/index.ts +9 -0
  145. package/src/near/wallet.ts +4 -4
  146. package/src/solana/connector.ts +13 -11
  147. package/src/solana/index.ts +7 -0
  148. package/src/{hot-wallet/solana → solana/injected}/index.ts +1 -1
  149. package/src/solana/wallet.ts +4 -4
  150. package/src/stellar/connector.ts +2 -2
  151. package/src/stellar/index.ts +7 -0
  152. package/src/{hot-wallet/stellar.ts → stellar/injected.ts} +1 -1
  153. package/src/stellar/wallet.ts +5 -5
  154. package/src/ton/connector.ts +2 -2
  155. package/src/ton/index.ts +9 -0
  156. package/src/{hot-wallet/ton.ts → ton/injected.ts} +1 -1
  157. package/src/ton/utils.ts +1 -3
  158. package/src/ton/wallet.ts +3 -3
  159. package/src/ui/connect/ConnectWallet.tsx +1 -1
  160. package/src/ui/payment/Bridge.tsx +7 -6
  161. package/src/ui/payment/Payment.tsx +3 -3
  162. package/src/ui/payment/Profile.tsx +3 -3
  163. package/src/ui/payment/SelectRecipient.tsx +3 -3
  164. package/src/ui/payment/SelectSender.tsx +2 -2
  165. package/src/ui/payment/SelectToken.tsx +4 -4
  166. package/src/ui/payment/TokenCard.tsx +3 -3
  167. package/src/ui/router.tsx +3 -3
  168. package/src/ui/styles.ts +4 -0
  169. package/build/GoogleConnector.d.ts +0 -20
  170. package/build/GoogleConnector.js.map +0 -1
  171. package/build/events.js.map +0 -1
  172. package/build/hot-wallet/evm.js.map +0 -1
  173. package/build/hot-wallet/solana/account.js.map +0 -1
  174. package/build/hot-wallet/solana/register.js.map +0 -1
  175. package/build/hot-wallet/solana/solana-wallet.js.map +0 -1
  176. package/build/hot-wallet/solana/utils.js.map +0 -1
  177. package/build/hot-wallet/stellar.js.map +0 -1
  178. package/build/hot-wallet/ton.js.map +0 -1
  179. package/build/hot-wallet/wallet.d.ts +0 -1
  180. package/build/hot-wallet/wallet.js +0 -40
  181. package/build/hot-wallet/wallet.js.map +0 -1
  182. package/build/omni/bridge.js.map +0 -1
  183. package/build/settings.d.ts +0 -5
  184. package/build/settings.js +0 -6
  185. package/build/settings.js.map +0 -1
  186. package/src/hot-wallet/wallet.ts +0 -44
  187. package/src/settings.ts +0 -5
  188. package/build/{omni → core}/Intents.d.ts +0 -0
  189. package/build/{omni → core}/Intents.js +0 -0
  190. package/build/{omni → core}/bridge.d.ts +0 -0
  191. package/build/{omni → core}/config.d.ts +0 -0
  192. package/build/{omni → core}/defaultTokens.d.ts +0 -0
  193. package/build/{omni → core}/defaultTokens.js +0 -0
  194. package/build/{events.d.ts → core/events.d.ts} +0 -0
  195. package/build/{events.js → core/events.js} +0 -0
  196. package/build/{omni → core}/nearRpc.d.ts +0 -0
  197. package/build/{omni → core}/nearRpc.js +0 -0
  198. package/build/{omni → core}/recipient.d.ts +0 -0
  199. package/build/{omni → core}/recipient.js +0 -0
  200. package/build/{omni → core}/token.d.ts +0 -0
  201. package/build/{omni → core}/token.js +0 -0
  202. package/build/{omni → core}/tokens.d.ts +0 -0
  203. package/build/{omni → core}/tokens.js +0 -0
  204. package/build/{omni → core}/types.d.ts +0 -0
  205. package/build/{omni → core}/types.js +0 -0
  206. package/build/{omni → core}/utils.d.ts +0 -0
  207. package/build/{omni → core}/utils.js +0 -0
  208. package/build/{hot-wallet/evm.d.ts → evm/injected.d.ts} +0 -0
  209. package/build/hot-wallet/{hot.d.ts → iframe.d.ts} +0 -0
  210. package/build/{hot-wallet/solana → solana/injected}/account.d.ts +0 -0
  211. package/build/{hot-wallet/solana → solana/injected}/account.js +0 -0
  212. package/build/{hot-wallet/solana → solana/injected}/index.d.ts +0 -0
  213. package/build/{hot-wallet/solana → solana/injected}/register.d.ts +0 -0
  214. package/build/{hot-wallet/solana → solana/injected}/register.js +0 -0
  215. package/build/{hot-wallet/solana → solana/injected}/solana-wallet.d.ts +0 -0
  216. package/build/{hot-wallet/solana → solana/injected}/solana-wallet.js +0 -0
  217. package/build/{hot-wallet/solana → solana/injected}/utils.d.ts +0 -0
  218. package/build/{hot-wallet/solana → solana/injected}/utils.js +0 -0
  219. package/build/{hot-wallet/stellar.d.ts → stellar/injected.d.ts} +0 -0
  220. package/build/{hot-wallet/ton.d.ts → ton/injected.d.ts} +0 -0
  221. package/src/{omni → core}/Intents.ts +0 -0
  222. package/src/{omni → core}/defaultTokens.ts +0 -0
  223. package/src/{events.ts → core/events.ts} +0 -0
  224. package/src/{omni → core}/nearRpc.ts +0 -0
  225. package/src/{omni → core}/recipient.ts +0 -0
  226. package/src/{omni → core}/token.ts +0 -0
  227. package/src/{omni → core}/tokens.ts +1 -1
  228. /package/src/{omni → core}/types.ts +0 -0
  229. /package/src/{omni → core}/utils.ts +0 -0
  230. /package/src/{hot-wallet/solana → solana/injected}/account.ts +0 -0
  231. /package/src/{hot-wallet/solana → solana/injected}/register.ts +0 -0
  232. /package/src/{hot-wallet/solana → solana/injected}/solana-wallet.ts +0 -0
  233. /package/src/{hot-wallet/solana → solana/injected}/utils.ts +0 -0
@@ -1,24 +1,15 @@
1
1
  import { computed, makeObservable, observable, runInAction } from "mobx";
2
2
 
3
3
  import { openBridge, openConnector, openPayment, openProfile, openWalletPicker } from "./ui/router";
4
- import { ConnectorType, OmniConnector, OmniConnectorOptions } from "./OmniConnector";
5
- import { chainsMap, Network, WalletType } from "./omni/config";
6
- import { OmniWallet, SignedAuth } from "./OmniWallet";
7
-
8
- import NearConnector, { NearConnectorOptions } from "./near/connector";
9
- import EvmConnector, { EvmConnectorOptions } from "./evm/connector";
10
- import CosmosConnector, { CosmosConnectorOptions } from "./cosmos/connector";
11
- import TonConnector, { TonConnectorOptions } from "./ton/connector";
12
- import SolanaConnector from "./solana/connector";
13
- import StellarConnector from "./stellar/connector";
14
- import GoogleConnector from "./GoogleConnector";
4
+ import { ConnectorType, OmniConnector } from "./OmniConnector";
5
+ import { chainsMap, Network, WalletType } from "./core/config";
6
+ import { OmniWallet } from "./OmniWallet";
15
7
 
16
8
  import { Exchange } from "./exchange";
17
- import { OmniToken } from "./omni/config";
18
- import { formatter } from "./omni/utils";
19
- import { Token } from "./omni/token";
20
- import { GlobalSettings } from "./settings";
21
- import { EventEmitter } from "./events";
9
+ import { OmniToken } from "./core/config";
10
+ import { formatter } from "./core/utils";
11
+ import { Token } from "./core/token";
12
+ import { EventEmitter } from "./core/events";
22
13
 
23
14
  import NearWallet from "./near/wallet";
24
15
  import EvmWallet from "./evm/wallet";
@@ -26,23 +17,20 @@ import SolanaWallet from "./solana/wallet";
26
17
  import StellarWallet from "./stellar/wallet";
27
18
  import TonWallet from "./ton/wallet";
28
19
  import CosmosWallet from "./cosmos/wallet";
29
- import { Intents } from "./omni/Intents";
30
- import { Recipient } from "./omni/recipient";
31
- import { openAuthPopup } from "./ui/connect/AuthPopup";
32
- import { tokens } from "./omni/tokens";
33
-
34
- export const near = (options?: NearConnectorOptions) => (wibe3: HotConnector) => new NearConnector(wibe3, options);
35
- export const evm = (options?: EvmConnectorOptions) => (wibe3: HotConnector) => new EvmConnector(wibe3, options);
36
- export const solana = (options?: OmniConnectorOptions) => (wibe3: HotConnector) => new SolanaConnector(wibe3, options);
37
- export const cosmos = (options?: CosmosConnectorOptions) => (wibe3: HotConnector) => new CosmosConnector(wibe3, options);
38
- export const ton = (options?: TonConnectorOptions) => (wibe3: HotConnector) => new TonConnector(wibe3, options);
39
- export const stellar = () => (wibe3: HotConnector) => new StellarConnector(wibe3);
40
- export const google = () => (wibe3: HotConnector) => new GoogleConnector(wibe3);
41
-
42
- interface HotConnectorOptions extends EvmConnectorOptions, OmniConnectorOptions, TonConnectorOptions, NearConnectorOptions, CosmosConnectorOptions {
43
- connectors?: OmniConnector[];
44
- webWallet?: string;
45
- tonApi?: string;
20
+ import { Intents } from "./core/Intents";
21
+ import { Recipient } from "./core/recipient";
22
+ import { tokens } from "./core/tokens";
23
+ import { rpc } from "./core/nearRpc";
24
+
25
+ interface HotConnectorOptions {
26
+ connectors?: ((wibe3: HotConnector) => Promise<OmniConnector>)[];
27
+ projectId?: string;
28
+ metadata?: {
29
+ name: string;
30
+ description: string;
31
+ url: string;
32
+ icons: string[];
33
+ };
46
34
  }
47
35
 
48
36
  export class HotConnector {
@@ -56,6 +44,19 @@ export class HotConnector {
56
44
  tokensUpdate: { tokens: Token[] };
57
45
  }>();
58
46
 
47
+ public settings: {
48
+ webWallet: string;
49
+ projectId?: string;
50
+ metadata?: {
51
+ name: string;
52
+ description: string;
53
+ url: string;
54
+ icons: string[];
55
+ };
56
+ } = {
57
+ webWallet: "https://app.hot-labs.org",
58
+ };
59
+
59
60
  constructor(options?: HotConnectorOptions) {
60
61
  makeObservable(this, {
61
62
  balances: observable,
@@ -71,12 +72,20 @@ export class HotConnector {
71
72
  cosmos: computed,
72
73
  });
73
74
 
74
- if (typeof window !== "undefined") {
75
- this.connectors = [near(), evm(options), solana(options), stellar(), ton(options), cosmos(options)].map((t) => t(this));
76
- }
75
+ const connectors: OmniConnector[] = [];
76
+ const tasks = options?.connectors?.map(async (initConnector, index) => {
77
+ const connector = await initConnector(this);
78
+ connector.onConnect((payload) => this.events.emit("connect", payload));
79
+ connector.onDisconnect((payload) => this.events.emit("disconnect", payload));
80
+ connectors[index] = connector;
81
+ });
82
+
83
+ Promise.all(tasks ?? []).then(() => {
84
+ this.connectors = connectors.filter((t) => t != null);
85
+ });
77
86
 
78
- GlobalSettings.webWallet = options?.webWallet ?? GlobalSettings.webWallet;
79
- GlobalSettings.tonApi = options?.tonApi ?? GlobalSettings.tonApi;
87
+ this.settings.projectId = options?.projectId ?? undefined;
88
+ this.settings.metadata = options?.metadata ?? undefined;
80
89
 
81
90
  this.connectors.forEach((t) => {
82
91
  t.onConnect((payload) => this.events.emit("connect", payload));
@@ -136,6 +145,10 @@ export class HotConnector {
136
145
  });
137
146
  }
138
147
 
148
+ get nearRpc() {
149
+ return rpc;
150
+ }
151
+
139
152
  get near(): NearWallet | null {
140
153
  return this.wallets.find((w) => w.type === WalletType.NEAR) as NearWallet | null;
141
154
  }
@@ -193,13 +206,6 @@ export class HotConnector {
193
206
  };
194
207
  }
195
208
 
196
- async auth<T = SignedAuth>(wallet: OmniWallet, domain: string, intents?: Record<string, any>[], then?: (signed: SignedAuth) => Promise<T>): Promise<T> {
197
- return openAuthPopup<T>(wallet, async () => {
198
- const signed = await wallet.signIntentsWithAuth(domain, intents);
199
- return (await then?.(signed)) ?? (signed as T);
200
- });
201
- }
202
-
203
209
  async fetchToken(token: Token, wallet: OmniWallet) {
204
210
  const key = `${wallet.type}:${wallet.address}`;
205
211
 
@@ -1,12 +1,12 @@
1
1
  import { makeObservable, observable, runInAction } from "mobx";
2
2
  import UniversalProvider, { NamespaceConfig } from "@walletconnect/universal-provider";
3
3
 
4
- import { EventEmitter } from "./events";
4
+ import { EventEmitter } from "./core/events";
5
5
  import { LocalStorage } from "./storage";
6
6
  import { HotConnector } from "./HotConnector";
7
7
 
8
8
  import { OmniWallet } from "./OmniWallet";
9
- import { WalletType } from "./omni/config";
9
+ import { WalletType } from "./core/config";
10
10
  import { openWCRequest } from "./ui/router";
11
11
 
12
12
  export enum ConnectorType {
@@ -22,11 +22,6 @@ export interface OmniConnectorOption {
22
22
  type: "extension" | "external";
23
23
  }
24
24
 
25
- export interface OmniConnectorOptions {
26
- projectId?: string;
27
- metadata?: { name: string; description: string; url: string; icons: string[] };
28
- }
29
-
30
25
  export const WC_ICON = "https://raw.githubusercontent.com/WalletConnect/walletconnect-assets/refs/heads/master/Icon/Blue%20(Default)/Icon.svg";
31
26
 
32
27
  export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
@@ -41,7 +36,7 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
41
36
 
42
37
  protected wc: Promise<UniversalProvider> | null = null;
43
38
 
44
- constructor(readonly wibe3: HotConnector, readonly settings?: OmniConnectorOptions) {
39
+ constructor(readonly wibe3: HotConnector) {
45
40
  makeObservable(this, {
46
41
  wallets: observable,
47
42
  options: observable,
@@ -49,12 +44,12 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
49
44
  }
50
45
 
51
46
  async initWalletConnect() {
52
- if (!this.settings?.projectId) throw new Error("Project ID is required");
47
+ if (!this.wibe3.settings?.projectId) throw new Error("Project ID is required");
53
48
  if (this.wc) return this.wc;
54
49
  this.wc = UniversalProvider.init({
55
50
  relayUrl: "wss://relay.walletconnect.org",
56
- projectId: this.settings?.projectId,
57
- metadata: this.settings?.metadata,
51
+ projectId: this.wibe3.settings?.projectId,
52
+ metadata: this.wibe3.settings?.metadata,
58
53
  customStoragePrefix: `wibe3:${this.id}`,
59
54
  name: this.name,
60
55
  });
package/src/OmniWallet.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { sha256 } from "@noble/hashes/sha2.js";
2
2
 
3
3
  import { openAuthPopup } from "./ui/connect/AuthPopup";
4
- import { OmniToken, WalletType } from "./omni/config";
4
+ import { OmniToken, WalletType } from "./core/config";
5
5
  import { OmniConnector } from "./OmniConnector";
6
- import { Intents } from "./omni/Intents";
7
- import { ReviewFee } from "./omni/bridge";
8
- import { Token } from "./omni/token";
6
+ import { Intents } from "./core/Intents";
7
+ import { ReviewFee } from "./core/bridge";
8
+ import { Token } from "./core/token";
9
9
 
10
10
  export interface AuthCommitment {
11
11
  tradingAddress: string;
@@ -6,6 +6,7 @@ export { ReviewFee };
6
6
  export const bridge = new HotBridge({
7
7
  api: ["https://dev.herewallet.app"],
8
8
  solanaRpc: ["https://api0.herewallet.app/api/v1/solana/rpc/1001"],
9
+ mpcApi: ["https://apt-hebdomadally-ariana.ngrok-free.dev"],
9
10
 
10
11
  publishIntents: async (signed: Record<string, any>[], hashes: string[] = []) => {
11
12
  const hash = await Intents.publishSignedIntents(signed, hashes);
@@ -97,7 +97,11 @@ export enum Network {
97
97
  }
98
98
 
99
99
  export const chainsMap: Record<number, { id: string; name: string; logo?: string }> = {
100
- [Network.Juno]: { id: "juno-1", name: "Juno", logo: "https://storage.herewallet.app/ft/4444118:ujuno.png" },
100
+ [Network.Juno]: {
101
+ id: "juno-1",
102
+ name: "Juno",
103
+ logo: "https://storage.herewallet.app/ft/4444118:ujuno.png",
104
+ },
101
105
  [Network.Gonka]: { id: "gonka-mainnet", name: "Gonka", logo: "https://storage.herewallet.app/ft/4444119:ngonka.png" },
102
106
  [Network.Monad]: { id: "monad", name: "Monad", logo: "https://storage.herewallet.app/upload/8f6bdf0d04494dc7157704cf3a7e623aeba7188120d93535d3b9330fa82fc200.JPG" },
103
107
  [Network.Near]: { id: "near", name: "NEAR", logo: "https://storage.herewallet.app/ft/1010:native.png" },
@@ -5,4 +5,5 @@ export { tokens } from "./tokens";
5
5
  export { bridge } from "./bridge";
6
6
  export { Recipient } from "./recipient";
7
7
  export { formatter } from "./utils";
8
+ export { rpc as nearRpc, TGAS } from "./nearRpc";
8
9
  export * from "./types";
@@ -3,15 +3,15 @@ import { TxRaw } from "@keplr-wallet/proto-types/cosmos/tx/v1beta1/tx";
3
3
  import { StargateClient } from "@cosmjs/stargate";
4
4
  import { hex } from "@scure/base";
5
5
 
6
- import { WalletType } from "../omni/config";
6
+ import { WalletType } from "../core/config";
7
7
  import { HotConnector } from "../HotConnector";
8
- import { ConnectorType, OmniConnector, OmniConnectorOptions, WC_ICON } from "../OmniConnector";
8
+ import { ConnectorType, OmniConnector, WC_ICON } from "../OmniConnector";
9
9
  import { OmniWallet } from "../OmniWallet";
10
10
 
11
11
  import { signAndSendTx } from "./helpers";
12
12
  import CosmosWallet from "./wallet";
13
13
 
14
- export interface CosmosConnectorOptions extends OmniConnectorOptions {
14
+ export interface CosmosConnectorOptions {
15
15
  cosmosChains?: Record<string, { chain: string; rpc: string; denom: string; prefix: string }>;
16
16
  }
17
17
 
@@ -52,7 +52,7 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
52
52
  id = "cosmos";
53
53
 
54
54
  constructor(wibe3: HotConnector, options?: CosmosConnectorOptions) {
55
- super(wibe3, options);
55
+ super(wibe3);
56
56
 
57
57
  this.options = [
58
58
  {
@@ -84,19 +84,21 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
84
84
  if (type === "leap" && window.leap) this.setKeplrWallet(window.leap, address, publicKey);
85
85
  });
86
86
 
87
- this.initWalletConnect().then(async (wc) => {
88
- this.options.unshift({
89
- download: "https://www.walletconnect.com/get",
90
- name: "WalletConnect",
91
- id: "walletconnect",
92
- type: "external",
93
- icon: WC_ICON,
94
- });
87
+ this.initWalletConnect()
88
+ .then(async (wc) => {
89
+ this.options.unshift({
90
+ download: "https://www.walletconnect.com/get",
91
+ name: "WalletConnect",
92
+ id: "walletconnect",
93
+ type: "external",
94
+ icon: WC_ICON,
95
+ });
95
96
 
96
- const selected = await this.getStorage();
97
- if (selected.type !== "walletconnect") return;
98
- this.setupWalletConnect(selected.id as "keplr" | "leap");
99
- });
97
+ const selected = await this.getStorage();
98
+ if (selected.type !== "walletconnect") return;
99
+ this.setupWalletConnect(selected.id as "keplr" | "leap");
100
+ })
101
+ .catch(() => {});
100
102
  }
101
103
 
102
104
  getConfig(chain: string) {
@@ -0,0 +1,9 @@
1
+ import type { CosmosConnectorOptions } from "./connector";
2
+ import CosmosConnector from "./connector";
3
+ import CosmosWallet from "./wallet";
4
+
5
+ import { HotConnector } from "../HotConnector";
6
+
7
+ export { CosmosConnector, CosmosConnectorOptions, CosmosWallet };
8
+
9
+ export default (options?: CosmosConnectorOptions) => async (wibe3: HotConnector) => new CosmosConnector(wibe3, options);
@@ -1,8 +1,8 @@
1
1
  import { StargateClient } from "@cosmjs/stargate";
2
2
 
3
3
  import { OmniWallet, SignedAuth } from "../OmniWallet";
4
- import { chainsMap, WalletType } from "../omni/config";
5
- import { ReviewFee } from "../omni/bridge";
4
+ import { chainsMap, WalletType } from "../core/config";
5
+ import { ReviewFee } from "../core/bridge";
6
6
  import CosmosConnector from "./connector";
7
7
 
8
8
  interface ProtocolWallet {
@@ -0,0 +1,7 @@
1
+ import near from "./near";
2
+ import stellar from "./stellar";
3
+ import ton from "./ton";
4
+ import solana from "./solana";
5
+ import evm from "./evm";
6
+
7
+ export const defaultConnectors = [near(), evm(), solana(), ton(), stellar()];
@@ -1,24 +1,17 @@
1
1
  import MetaMaskSDK from "@metamask/sdk";
2
2
  import { runInAction } from "mobx";
3
3
 
4
- import { ConnectorType, OmniConnector, OmniConnectorOptions, WC_ICON } from "../OmniConnector";
5
- import { WalletType } from "../omni/config";
6
- import { isInjected } from "../hot-wallet/hot";
4
+ import { ConnectorType, OmniConnector, WC_ICON } from "../OmniConnector";
5
+ import { Network, WalletType } from "../core/config";
6
+ import { isInjected } from "../hot-wallet/iframe";
7
7
  import { HotConnector } from "../HotConnector";
8
8
  import EvmWallet, { EvmProvider } from "./wallet";
9
9
 
10
- const chains = [1, 10, 56, 137, 8453, 42161, 421613, 80001];
11
-
12
- export interface EvmConnectorOptions extends OmniConnectorOptions {
13
- chains?: number[];
14
- }
15
-
16
10
  class EvmConnector extends OmniConnector<EvmWallet, { provider: EvmProvider }> {
17
11
  icon = "https://storage.herewallet.app/upload/06b43b164683c2cbfe9a9c0699f0953fd56f1f802035e7701ea10501d9e091c6.png";
18
12
  walletTypes = [WalletType.EVM, WalletType.OMNI];
19
13
  type = ConnectorType.WALLET;
20
14
  name = "EVM Wallet";
21
- chains = chains;
22
15
  id = "evm";
23
16
 
24
17
  MMSDK = new MetaMaskSDK({
@@ -29,10 +22,8 @@ class EvmConnector extends OmniConnector<EvmWallet, { provider: EvmProvider }> {
29
22
  },
30
23
  });
31
24
 
32
- constructor(wibe3: HotConnector, readonly settings: EvmConnectorOptions = {}) {
33
- super(wibe3, settings);
34
-
35
- if (settings.chains) this.chains.push(...settings.chains);
25
+ constructor(wibe3: HotConnector) {
26
+ super(wibe3);
36
27
 
37
28
  window.addEventListener<any>("eip6963:announceProvider", async (provider) => {
38
29
  if (this.options.find((t) => t.name === provider.detail.info.name || t.id === provider.detail.info.uuid)) return;
@@ -60,15 +51,19 @@ class EvmConnector extends OmniConnector<EvmWallet, { provider: EvmProvider }> {
60
51
 
61
52
  window.dispatchEvent(new Event("eip6963:requestProvider"));
62
53
 
63
- this.initWalletConnect().then((wc) => {
64
- this.options.unshift({ id: "walletconnect", name: "WalletConnect", icon: WC_ICON, provider: {} as any, type: "external" });
65
- });
54
+ this.initWalletConnect()
55
+ .then((wc) => {
56
+ this.options.unshift({ id: "walletconnect", name: "WalletConnect", icon: WC_ICON, provider: {} as any, type: "external" });
57
+ })
58
+ .catch(() => {});
66
59
 
67
- this.wc?.then(async (wc) => {
68
- const selected = await this.getConnectedWallet();
69
- if (selected.id !== "walletconnect") return;
70
- this.setupWalletConnect();
71
- });
60
+ this.wc
61
+ ?.then(async (wc) => {
62
+ const selected = await this.getConnectedWallet();
63
+ if (selected.id !== "walletconnect") return;
64
+ this.setupWalletConnect();
65
+ })
66
+ .catch(() => {});
72
67
  }
73
68
 
74
69
  async setupWalletConnect(): Promise<EvmWallet> {
@@ -120,7 +115,7 @@ class EvmConnector extends OmniConnector<EvmWallet, { provider: EvmProvider }> {
120
115
  namespaces: {
121
116
  eip155: {
122
117
  methods: ["eth_sendTransaction", "eth_signTransaction", "eth_sign", "personal_sign", "eth_signTypedData"],
123
- chains: chains.map((chain) => `eip155:${chain}`),
118
+ chains: Object.values(Network).map((chain) => `eip155:${chain}`),
124
119
  events: ["chainChanged", "accountsChanged"],
125
120
  rpcMap: {},
126
121
  },
@@ -0,0 +1,7 @@
1
+ import EvmConnector from "./connector";
2
+ import { HotConnector } from "../HotConnector";
3
+
4
+ export { default as EvmConnector } from "./connector";
5
+ export { default as EvmWallet } from "./wallet";
6
+
7
+ export default () => async (wibe3: HotConnector) => new EvmConnector(wibe3);
@@ -1,4 +1,4 @@
1
- import { isInjected, requestHot } from "./hot";
1
+ import { isInjected, requestHot } from "../hot-wallet/iframe";
2
2
 
3
3
  class HotEvmProvider {
4
4
  _events = new Map<string, Set<any>>();
package/src/evm/wallet.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { base64, base58, hex } from "@scure/base";
2
- import { BrowserProvider, ethers, JsonRpcProvider, JsonRpcSigner, TransactionRequest } from "ethers";
2
+ import { BrowserProvider, ethers, JsonRpcProvider, TransactionRequest } from "ethers";
3
+ import { JsonRpcSigner } from "ethers";
3
4
 
4
5
  import { OmniConnector } from "../OmniConnector";
5
6
  import { OmniWallet } from "../OmniWallet";
6
- import { WalletType } from "../omni/config";
7
- import { ReviewFee } from "../omni/bridge";
8
- import { Token } from "../omni/token";
7
+ import { WalletType } from "../core/config";
8
+ import { ReviewFee } from "../core/bridge";
9
+ import { Token } from "../core/token";
9
10
  import { erc20abi } from "./abi";
10
11
 
11
12
  export interface EvmProvider {
@@ -110,8 +111,12 @@ class EvmWallet extends OmniWallet {
110
111
 
111
112
  async sendTransaction(chain: number, request: TransactionRequest): Promise<string> {
112
113
  if (!this.provider.request) throw "not impl";
114
+ const provider = new BrowserProvider(this.provider as any);
115
+ const signer = new JsonRpcSigner(provider, this.address);
116
+
113
117
  await this.provider.request({ method: "wallet_switchEthereumChain", params: [{ chainId: `0x${chain.toString(16)}` }] });
114
- return await this.provider.request({ method: "eth_sendTransaction", params: [request] });
118
+ const tx = await signer.sendTransaction(request);
119
+ return tx.hash;
115
120
  }
116
121
 
117
122
  async transfer(args: { token: Token; receiver: string; amount: bigint; comment?: string; gasFee?: ReviewFee }): Promise<string> {
package/src/exchange.ts CHANGED
@@ -8,12 +8,12 @@ import NearWallet from "./near/wallet";
8
8
  import EvmWallet from "./evm/wallet";
9
9
 
10
10
  import { HotConnector } from "./HotConnector";
11
- import { Network, OmniToken, WalletType } from "./omni/config";
12
- import { bridge, ReviewFee } from "./omni/bridge";
13
- import { Recipient } from "./omni/recipient";
11
+ import { Network, OmniToken, WalletType } from "./core/config";
12
+ import { bridge, ReviewFee } from "./core/bridge";
13
+ import { Recipient } from "./core/recipient";
14
14
  import { OmniWallet } from "./OmniWallet";
15
- import { tokens } from "./omni/tokens";
16
- import { Token } from "./omni/token";
15
+ import { tokens } from "./core/tokens";
16
+ import { Token } from "./core/token";
17
17
 
18
18
  OpenAPI.BASE = "https://1click.chaindefuser.com";
19
19
  OpenAPI.TOKEN = "";
@@ -1,18 +1,22 @@
1
1
  import { WalletManifest, SignAndSendTransactionParams, SignAndSendTransactionsParams, SignMessageParams } from "@hot-labs/near-connect";
2
2
  import { Transaction } from "@stellar/stellar-base";
3
3
  import { action, makeObservable } from "mobx";
4
+ import uuid4 from "uuid4";
4
5
 
5
- import { requestWebWallet } from "./hot-wallet/wallet";
6
- import { ConnectorType, OmniConnector } from "./OmniConnector";
7
- import { OmniWallet } from "./OmniWallet";
8
- import { WalletType } from "./omni/config";
6
+ import { ConnectorType, OmniConnector } from "../OmniConnector";
7
+ import { OmniWallet } from "../OmniWallet";
8
+ import { WalletType } from "../core/config";
9
9
 
10
- import EvmWallet from "./evm/wallet";
11
- import NearWallet from "./near/wallet";
12
- import SolanaWallet from "./solana/wallet";
13
- import TonWallet from "./ton/wallet";
14
- import StellarWallet from "./stellar/wallet";
15
- import { HotConnector } from "./HotConnector";
10
+ import EvmWallet from "../evm/wallet";
11
+ import NearWallet from "../near/wallet";
12
+ import SolanaWallet from "../solana/wallet";
13
+ import TonWallet from "../ton/wallet";
14
+ import StellarWallet from "../stellar/wallet";
15
+ import { HotConnector } from "../HotConnector";
16
+
17
+ export interface GoogleConnectorOptions {
18
+ webWallet?: string;
19
+ }
16
20
 
17
21
  class GoogleConnector extends OmniConnector<OmniWallet> {
18
22
  walletTypes = [WalletType.EVM, WalletType.STELLAR, WalletType.TON, WalletType.NEAR, WalletType.SOLANA];
@@ -20,21 +24,20 @@ class GoogleConnector extends OmniConnector<OmniWallet> {
20
24
  type = ConnectorType.SOCIAL;
21
25
  name = "Google Wallet";
22
26
  id = "google";
27
+ webWallet: string;
23
28
 
24
- constructor(wibe3: HotConnector) {
29
+ constructor(wibe3: HotConnector, options?: GoogleConnectorOptions) {
25
30
  super(wibe3);
26
31
 
27
- makeObservable(this, {
28
- connectWallet: action,
29
- });
30
-
32
+ this.webWallet = options?.webWallet ?? "https://wallet.google.com";
33
+ makeObservable(this, { connectWallet: action });
31
34
  this.getStorage().then((accounts: any) => {
32
35
  accounts.forEach((account: any) => this.connectWallet(account));
33
36
  });
34
37
  }
35
38
 
36
39
  connectWallet(account: { type: number; address: string; publicKey: string }) {
37
- const request = requestWebWallet(account.type, account.address);
40
+ const request = this.requestWebWallet(account.type, account.address);
38
41
 
39
42
  if (account.type === WalletType.EVM) {
40
43
  this.setWallet(
@@ -87,7 +90,7 @@ class GoogleConnector extends OmniConnector<OmniWallet> {
87
90
  }
88
91
 
89
92
  async connect() {
90
- const accounts = await requestWebWallet()("connect:google", {});
93
+ const accounts = await this.requestWebWallet()("connect:google", {});
91
94
  accounts.forEach((account: { type: number; address: string; publicKey: string }) => this.connectWallet(account));
92
95
  this.setStorage(accounts);
93
96
  return this.wallets[0];
@@ -97,6 +100,46 @@ class GoogleConnector extends OmniConnector<OmniWallet> {
97
100
  this.removeAllWallets();
98
101
  this.removeStorage();
99
102
  }
103
+
104
+ requestWebWallet = (chain?: number, address?: string) => (method: string, request: any) => {
105
+ const width = 480;
106
+ const height = 640;
107
+ const x = (window.screen.width - width) / 2;
108
+ const y = (window.screen.height - height) / 2;
109
+ const popup = window.open(`${this.wibe3.settings.webWallet}`, "_blank", `popup=1,width=${width},height=${height},top=${y},left=${x}`);
110
+
111
+ return new Promise<any>(async (resolve, reject) => {
112
+ const interval = setInterval(() => {
113
+ if (!popup?.closed) return;
114
+ clearInterval(interval);
115
+ reject(new Error("User rejected"));
116
+ }, 100);
117
+
118
+ const id = uuid4();
119
+ const handler = (event: MessageEvent) => {
120
+ if (event.origin !== this.wibe3.settings.webWallet) return;
121
+
122
+ if (event.data === "hot:ready") {
123
+ popup?.postMessage({ chain, address, method, request, id }, "*");
124
+ return;
125
+ }
126
+
127
+ if (event.data.id !== id) return;
128
+ if (event.data.success === false) {
129
+ clearInterval(interval);
130
+ reject(new Error(event.data.payload));
131
+ window.removeEventListener("message", handler);
132
+ }
133
+
134
+ window.removeEventListener("message", handler);
135
+ resolve(event.data.payload);
136
+ clearInterval(interval);
137
+ popup?.close();
138
+ };
139
+
140
+ window.addEventListener("message", handler);
141
+ });
142
+ };
100
143
  }
101
144
 
102
145
  export default GoogleConnector;
@@ -1,11 +1,4 @@
1
- const ancestorOrigins = new Set([
2
- "http://localhost:1234",
3
- "https://my.herewallet.app",
4
- "https://tgapp-dev.herewallet.app",
5
- "https://tgapp.herewallet.app",
6
- "https://beta.herewallet.app",
7
- "https://app.hot-labs.org",
8
- ]);
1
+ const ancestorOrigins = new Set(["http://localhost:1234", "https://my.herewallet.app", "https://tgapp-dev.herewallet.app", "https://tgapp.herewallet.app", "https://beta.herewallet.app", "https://app.hot-labs.org"]);
9
2
 
10
3
  export const isInjected = () => {
11
4
  if (typeof window === "undefined") return false;
@@ -1,4 +1,6 @@
1
- import "./evm";
2
- import "./solana";
3
- import "./ton";
4
- import "./solana";
1
+ import GoogleConnector, { GoogleConnectorOptions } from "./google";
2
+ import { HotConnector } from "../HotConnector";
3
+
4
+ export { GoogleConnector, GoogleConnectorOptions };
5
+
6
+ export default (options?: GoogleConnectorOptions) => async (wibe3: HotConnector) => new GoogleConnector(wibe3, options);
package/src/index.ts CHANGED
@@ -1,30 +1,7 @@
1
- export { Network, OmniToken, WalletType } from "./omni/config";
2
- export { formatter } from "./omni/utils";
3
- export { EventEmitter } from "./events";
4
-
5
1
  export { OmniWallet } from "./OmniWallet";
6
2
  export { OmniConnector } from "./OmniConnector";
7
- export { Intents } from "./omni/Intents";
8
- export { Token } from "./omni/token";
9
- export { TGAS } from "./omni/nearRpc";
10
-
11
- export { default as EvmConnector } from "./evm/connector";
12
- export { default as SolanaConnector } from "./solana/connector";
13
- export { default as StellarConnector } from "./stellar/connector";
14
- export { default as TonConnector } from "./ton/connector";
15
- export { default as NearConnector } from "./near/connector";
16
- export { default as CosmosConnector } from "./cosmos/connector";
17
-
18
- export { default as EvmWallet } from "./evm/wallet";
19
- export { default as SolanaWallet } from "./solana/wallet";
20
- export { default as StellarWallet } from "./stellar/wallet";
21
- export { default as TonWallet } from "./ton/wallet";
22
- export { default as NearWallet } from "./near/wallet";
23
- export { default as CosmosWallet } from "./cosmos/wallet";
24
-
25
- export { near, evm, solana, stellar, ton, google } from "./HotConnector";
26
3
  export { HotConnector } from "./HotConnector";
27
4
 
28
- import "./hot-wallet";
29
-
30
5
  export { Bridge as BridgeWidget } from "./ui/payment/Bridge";
6
+
7
+ export * from "./core";