@hot-labs/kit 1.0.56 → 1.1.0-beta.1

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 (214) hide show
  1. package/README.md +2 -9
  2. package/build/HotConnector.d.ts +6 -6
  3. package/build/HotConnector.js +18 -23
  4. package/build/HotConnector.js.map +1 -1
  5. package/build/OmniConnector.d.ts +4 -0
  6. package/build/OmniConnector.js +5 -5
  7. package/build/OmniConnector.js.map +1 -1
  8. package/build/OmniWallet.d.ts +10 -17
  9. package/build/OmniWallet.js +14 -19
  10. package/build/OmniWallet.js.map +1 -1
  11. package/build/core/Intents.d.ts +23 -39
  12. package/build/core/Intents.js +104 -115
  13. package/build/core/Intents.js.map +1 -1
  14. package/build/core/api.d.ts +1 -0
  15. package/build/core/api.js +10 -2
  16. package/build/core/api.js.map +1 -1
  17. package/build/core/bridge.js +1 -1
  18. package/build/core/bridge.js.map +1 -1
  19. package/build/core/chains.js +1 -1
  20. package/build/core/chains.js.map +1 -1
  21. package/build/core/index.d.ts +1 -1
  22. package/build/core/index.js +1 -1
  23. package/build/core/index.js.map +1 -1
  24. package/build/core/types.d.ts +17 -0
  25. package/build/core/utils.d.ts +1 -0
  26. package/build/core/utils.js +10 -0
  27. package/build/core/utils.js.map +1 -1
  28. package/build/cosmos/connector.js +2 -2
  29. package/build/cosmos/connector.js.map +1 -1
  30. package/build/cosmos/wallet.d.ts +2 -4
  31. package/build/cosmos/wallet.js +3 -8
  32. package/build/cosmos/wallet.js.map +1 -1
  33. package/build/evm/connector.d.ts +2 -3
  34. package/build/evm/connector.js +7 -11
  35. package/build/evm/connector.js.map +1 -1
  36. package/build/evm/injected.js +3 -3
  37. package/build/evm/injected.js.map +1 -1
  38. package/build/evm/wallet.d.ts +2 -1
  39. package/build/evm/wallet.js +7 -5
  40. package/build/evm/wallet.js.map +1 -1
  41. package/build/exchange.d.ts +4 -1
  42. package/build/exchange.js +21 -20
  43. package/build/exchange.js.map +1 -1
  44. package/build/hot-wallet/google.js +10 -5
  45. package/build/hot-wallet/google.js.map +1 -1
  46. package/build/hot-wallet/iframe.d.ts +36 -3
  47. package/build/hot-wallet/iframe.js +134 -27
  48. package/build/hot-wallet/iframe.js.map +1 -1
  49. package/build/hot-wallet/proxy.d.ts +8 -0
  50. package/build/hot-wallet/proxy.js +45 -0
  51. package/build/hot-wallet/proxy.js.map +1 -0
  52. package/build/index.d.ts +1 -0
  53. package/build/index.js +1 -0
  54. package/build/index.js.map +1 -1
  55. package/build/near/connector.js +2 -2
  56. package/build/near/connector.js.map +1 -1
  57. package/build/{core/nearRpc.d.ts → near/rpc.d.ts} +0 -1
  58. package/build/{core/nearRpc.js → near/rpc.js} +5 -11
  59. package/build/near/rpc.js.map +1 -0
  60. package/build/near/wallet.d.ts +2 -4
  61. package/build/near/wallet.js +4 -9
  62. package/build/near/wallet.js.map +1 -1
  63. package/build/solana/{protocol.d.ts → WalletStandard.d.ts} +1 -1
  64. package/build/solana/{protocol.js → WalletStandard.js} +1 -1
  65. package/build/solana/WalletStandard.js.map +1 -0
  66. package/build/solana/connector.d.ts +1 -1
  67. package/build/solana/connector.js +11 -10
  68. package/build/solana/connector.js.map +1 -1
  69. package/build/solana/injected/account.js +1 -2
  70. package/build/solana/injected/account.js.map +1 -1
  71. package/build/solana/injected/index.js +16 -19
  72. package/build/solana/injected/index.js.map +1 -1
  73. package/build/solana/injected/solana-wallet.js.map +1 -1
  74. package/build/solana/wallet.d.ts +3 -5
  75. package/build/solana/wallet.js +3 -8
  76. package/build/solana/wallet.js.map +1 -1
  77. package/build/solana/{wallets.js → walletStandartList.js} +1 -1
  78. package/build/solana/walletStandartList.js.map +1 -0
  79. package/build/stellar/connector.d.ts +10 -6
  80. package/build/stellar/connector.js +38 -30
  81. package/build/stellar/connector.js.map +1 -1
  82. package/build/stellar/freigher.d.ts +46 -0
  83. package/build/stellar/freigher.js +110 -0
  84. package/build/stellar/freigher.js.map +1 -0
  85. package/build/stellar/{injected.d.ts → hotWallet.d.ts} +1 -6
  86. package/build/stellar/hotWallet.js +28 -0
  87. package/build/stellar/hotWallet.js.map +1 -0
  88. package/build/stellar/wallet.d.ts +10 -8
  89. package/build/stellar/wallet.js +12 -16
  90. package/build/stellar/wallet.js.map +1 -1
  91. package/build/ton/connector.d.ts +0 -1
  92. package/build/ton/connector.js +7 -7
  93. package/build/ton/connector.js.map +1 -1
  94. package/build/ton/injected.js +6 -6
  95. package/build/ton/injected.js.map +1 -1
  96. package/build/ton/wallet.d.ts +2 -3
  97. package/build/ton/wallet.js +3 -4
  98. package/build/ton/wallet.js.map +1 -1
  99. package/build/tron/connector.d.ts +51 -0
  100. package/build/tron/connector.js +65 -0
  101. package/build/tron/connector.js.map +1 -0
  102. package/build/tron/index.d.ts +6 -0
  103. package/build/tron/index.js +5 -0
  104. package/build/tron/index.js.map +1 -0
  105. package/build/tron/wallet.d.ts +52 -0
  106. package/build/tron/wallet.js +122 -0
  107. package/build/tron/wallet.js.map +1 -0
  108. package/build/ui/Popup.js +1 -1
  109. package/build/ui/Popup.js.map +1 -1
  110. package/build/ui/connect/AuthPopup.js +1 -1
  111. package/build/ui/connect/AuthPopup.js.map +1 -1
  112. package/build/ui/connect/ConnectWallet.d.ts +2 -1
  113. package/build/ui/connect/ConnectWallet.js +2 -2
  114. package/build/ui/connect/ConnectWallet.js.map +1 -1
  115. package/build/ui/icons/arrow-right.js +1 -1
  116. package/build/ui/icons/arrow-right.js.map +1 -1
  117. package/build/ui/icons/close.js +1 -1
  118. package/build/ui/icons/close.js.map +1 -1
  119. package/build/ui/icons/exchange.js +1 -1
  120. package/build/ui/icons/exchange.js.map +1 -1
  121. package/build/ui/icons/logout.js +1 -1
  122. package/build/ui/icons/logout.js.map +1 -1
  123. package/build/ui/icons/pending.js +1 -1
  124. package/build/ui/icons/pending.js.map +1 -1
  125. package/build/ui/icons/qr.js +1 -1
  126. package/build/ui/icons/qr.js.map +1 -1
  127. package/build/ui/icons/search.js +1 -1
  128. package/build/ui/icons/search.js.map +1 -1
  129. package/build/ui/icons/switch.js +1 -1
  130. package/build/ui/icons/switch.js.map +1 -1
  131. package/build/ui/icons/wallet.js +1 -1
  132. package/build/ui/icons/wallet.js.map +1 -1
  133. package/build/ui/payment/Bridge.js +7 -2
  134. package/build/ui/payment/Bridge.js.map +1 -1
  135. package/build/ui/payment/Payment.d.ts +16 -8
  136. package/build/ui/payment/Payment.js +116 -21
  137. package/build/ui/payment/Payment.js.map +1 -1
  138. package/build/ui/payment/Profile.js +1 -1
  139. package/build/ui/payment/Profile.js.map +1 -1
  140. package/build/ui/payment/SelectToken.js +1 -1
  141. package/build/ui/payment/SelectToken.js.map +1 -1
  142. package/build/ui/payment/TokenCard.js +1 -1
  143. package/build/ui/payment/TokenCard.js.map +1 -1
  144. package/build/ui/router.d.ts +2 -1
  145. package/build/ui/router.js +2 -2
  146. package/build/ui/router.js.map +1 -1
  147. package/build/ui/styles.js +4 -3
  148. package/build/ui/styles.js.map +1 -1
  149. package/package.json +10 -5
  150. package/src/HotConnector.ts +21 -29
  151. package/src/OmniConnector.ts +9 -9
  152. package/src/OmniWallet.ts +24 -25
  153. package/src/core/Intents.ts +123 -139
  154. package/src/core/api.ts +13 -2
  155. package/src/core/bridge.ts +3 -2
  156. package/src/core/chains.ts +1 -1
  157. package/src/core/index.ts +1 -1
  158. package/src/core/types.ts +21 -0
  159. package/src/core/utils.ts +11 -0
  160. package/src/cosmos/connector.ts +2 -2
  161. package/src/cosmos/wallet.ts +3 -7
  162. package/src/evm/connector.ts +9 -12
  163. package/src/evm/injected.ts +3 -3
  164. package/src/evm/wallet.ts +9 -6
  165. package/src/exchange.ts +20 -20
  166. package/src/hot-wallet/google.ts +12 -5
  167. package/src/hot-wallet/iframe.ts +151 -24
  168. package/src/hot-wallet/proxy.ts +54 -0
  169. package/src/index.ts +2 -0
  170. package/src/near/connector.ts +2 -2
  171. package/src/{core/nearRpc.ts → near/rpc.ts} +4 -11
  172. package/src/near/wallet.ts +4 -9
  173. package/src/solana/{protocol.ts → WalletStandard.ts} +2 -4
  174. package/src/solana/connector.ts +11 -10
  175. package/src/solana/injected/account.ts +1 -2
  176. package/src/solana/injected/index.ts +15 -18
  177. package/src/solana/injected/solana-wallet.ts +6 -6
  178. package/src/solana/wallet.ts +4 -8
  179. package/src/stellar/connector.ts +40 -32
  180. package/src/stellar/freigher.ts +119 -0
  181. package/src/stellar/{injected.ts → hotWallet.ts} +8 -12
  182. package/src/stellar/wallet.ts +17 -17
  183. package/src/ton/connector.ts +15 -15
  184. package/src/ton/injected.ts +6 -6
  185. package/src/ton/wallet.ts +3 -3
  186. package/src/tron/connector.ts +89 -0
  187. package/src/tron/index.ts +7 -0
  188. package/src/tron/wallet.ts +146 -0
  189. package/src/ui/Popup.tsx +7 -3
  190. package/src/ui/connect/AuthPopup.tsx +2 -1
  191. package/src/ui/connect/ConnectWallet.tsx +3 -2
  192. package/src/ui/icons/arrow-right.tsx +2 -2
  193. package/src/ui/icons/close.tsx +1 -1
  194. package/src/ui/icons/exchange.tsx +4 -4
  195. package/src/ui/icons/logout.tsx +6 -6
  196. package/src/ui/icons/pending.tsx +2 -4
  197. package/src/ui/icons/qr.tsx +1 -2
  198. package/src/ui/icons/search.tsx +4 -4
  199. package/src/ui/icons/switch.tsx +4 -4
  200. package/src/ui/icons/wallet.tsx +2 -4
  201. package/src/ui/payment/Bridge.tsx +9 -2
  202. package/src/ui/payment/Payment.tsx +259 -31
  203. package/src/ui/payment/Profile.tsx +10 -8
  204. package/src/ui/payment/SelectToken.tsx +1 -1
  205. package/src/ui/payment/TokenCard.tsx +1 -1
  206. package/src/ui/router.tsx +5 -6
  207. package/src/ui/styles.ts +4 -3
  208. package/build/core/nearRpc.js.map +0 -1
  209. package/build/solana/protocol.js.map +0 -1
  210. package/build/solana/wallets.js.map +0 -1
  211. package/build/stellar/injected.js +0 -32
  212. package/build/stellar/injected.js.map +0 -1
  213. /package/build/solana/{wallets.d.ts → walletStandartList.d.ts} +0 -0
  214. /package/src/solana/{wallets.ts → walletStandartList.ts} +0 -0
@@ -1,7 +1,5 @@
1
1
  import type { Connection, Transaction, VersionedTransaction } from "@solana/web3.js";
2
- import { SolanaSignAndSendTransactionMethod, SolanaSignMessageMethod, SolanaSignTransactionMethod } from "@solana/wallet-standard-features";
3
2
  import type { Wallet } from "@wallet-standard/base";
4
- import { base58 } from "@scure/base";
5
3
 
6
4
  export interface ISolanaProtocolWallet {
7
5
  address: string;
@@ -41,7 +39,7 @@ class SolanaProtocolWallet implements ISolanaProtocolWallet {
41
39
  async sendTransaction(transaction: Transaction | VersionedTransaction, connection: Connection, options?: any): Promise<string> {
42
40
  const account = await this.getAccount();
43
41
  const features = this.wallet.features as any;
44
- const signTx = features["solana:signTransaction"]?.signTransaction as SolanaSignTransactionMethod;
42
+ const signTx = features["solana:signTransaction"]?.signTransaction;
45
43
  const [signed] = await signTx({ account, chain: account.chains[0], transaction: transaction.serialize() });
46
44
  const signedTx = signed.signedTransaction as Transaction | VersionedTransaction | Uint8Array;
47
45
  const raw = signedTx instanceof Uint8Array ? signedTx : (signedTx as any).serialize();
@@ -52,7 +50,7 @@ class SolanaProtocolWallet implements ISolanaProtocolWallet {
52
50
  async signMessage(message: string) {
53
51
  const account = await this.getAccount();
54
52
  const features = this.wallet.features as any;
55
- const signMessageFeature = features["solana:signMessage"]?.signMessage as SolanaSignMessageMethod;
53
+ const signMessageFeature = features["solana:signMessage"]?.signMessage;
56
54
 
57
55
  if (!signMessageFeature) throw new Error("Wallet does not support solana:signMessage");
58
56
  const [result] = await signMessageFeature({ account, message: new TextEncoder().encode(message) });
@@ -6,11 +6,11 @@ import { runInAction } from "mobx";
6
6
  import { ConnectorType, OmniConnector, WC_ICON } from "../OmniConnector";
7
7
  import { HotConnector } from "../HotConnector";
8
8
  import { OmniWallet } from "../OmniWallet";
9
- import { isInjected } from "../hot-wallet/iframe";
10
9
  import { WalletType } from "../core/chains";
10
+ import HOT from "../hot-wallet/iframe";
11
11
 
12
- import SolanaProtocolWallet from "./protocol";
13
- import { getWallets } from "./wallets";
12
+ import SolanaProtocolWallet from "./WalletStandard";
13
+ import { getWallets } from "./walletStandartList";
14
14
  import SolanaWallet from "./wallet";
15
15
 
16
16
  const wallets = getWallets();
@@ -36,7 +36,7 @@ class SolanaConnector extends OmniConnector<SolanaWallet, { wallet: Wallet }> {
36
36
  const wallet = this.options.find((w) => w.id === id);
37
37
  if (!wallet) return;
38
38
  const protocolWallet = await SolanaProtocolWallet.connect(wallet.wallet, { silent: true });
39
- this.setWallet(new SolanaWallet(this, protocolWallet));
39
+ this.setWallet(new SolanaWallet(protocolWallet));
40
40
  } catch {
41
41
  this.removeStorage();
42
42
  }
@@ -59,7 +59,7 @@ class SolanaConnector extends OmniConnector<SolanaWallet, { wallet: Wallet }> {
59
59
  const connected = await this.getConnectedWallet();
60
60
  if (connected !== wallet.name) return;
61
61
  const protocolWallet = await SolanaProtocolWallet.connect(wallet, { silent: true });
62
- this.setWallet(new SolanaWallet(this, protocolWallet));
62
+ this.setWallet(new SolanaWallet(protocolWallet));
63
63
  } catch {
64
64
  this.removeStorage();
65
65
  }
@@ -88,7 +88,7 @@ class SolanaConnector extends OmniConnector<SolanaWallet, { wallet: Wallet }> {
88
88
 
89
89
  this.setStorage({ type: "walletconnect" });
90
90
  return this.setWallet(
91
- new SolanaWallet(this, {
91
+ new SolanaWallet({
92
92
  address: account,
93
93
  sendTransaction: async (tx: Transaction | VersionedTransaction, connection: Connection, options?: any) => {
94
94
  const transaction = Buffer.from(tx.serialize()).toString("base64");
@@ -112,12 +112,13 @@ class SolanaConnector extends OmniConnector<SolanaWallet, { wallet: Wallet }> {
112
112
  );
113
113
  }
114
114
 
115
- async createWallet(address: string): Promise<OmniWallet> {
116
- return new SolanaWallet(this, { address });
115
+ async disconnect() {
116
+ this.wallets.forEach((w) => w.wallet.disconnect?.());
117
+ super.disconnect();
117
118
  }
118
119
 
119
120
  async getConnectedWallet() {
120
- if (isInjected()) return { type: "wallet", id: "HOT Wallet" };
121
+ if (HOT.isInjected) return { type: "wallet", id: "HOT Wallet" };
121
122
  return this.getStorage();
122
123
  }
123
124
 
@@ -142,7 +143,7 @@ class SolanaConnector extends OmniConnector<SolanaWallet, { wallet: Wallet }> {
142
143
  try {
143
144
  this.setStorage({ type: "wallet", id });
144
145
  const protocolWallet = await SolanaProtocolWallet.connect(wallet.wallet, { silent: false });
145
- return this.setWallet(new SolanaWallet(this, protocolWallet));
146
+ return this.setWallet(new SolanaWallet(protocolWallet));
146
147
  } catch (e) {
147
148
  this.removeStorage();
148
149
  throw e;
@@ -1,9 +1,8 @@
1
- import { SolanaSignAndSendTransaction, SolanaSignMessage, SolanaSignTransaction } from "@solana/wallet-standard-features";
2
1
  import type { WalletAccount } from "@wallet-standard/base";
3
2
  import { SOLANA_CHAINS } from "./utils";
4
3
 
5
4
  const chains = SOLANA_CHAINS;
6
- const features = [SolanaSignAndSendTransaction, SolanaSignTransaction, SolanaSignMessage] as const;
5
+ const features = ["solana:signAndSendTransaction", "solana:signMessage", "solana:signMessage"] as const;
7
6
 
8
7
  export class GhostWalletAccount implements WalletAccount {
9
8
  readonly #address: WalletAccount["address"];
@@ -1,6 +1,6 @@
1
1
  import { Transaction, VersionedTransaction, PublicKey } from "@solana/web3.js";
2
2
 
3
- import { isInjected, requestHot } from "../../hot-wallet/iframe";
3
+ import HOT from "../../hot-wallet/iframe";
4
4
  import { registerWallet } from "./register";
5
5
  import { GhostWallet } from "./solana-wallet";
6
6
 
@@ -25,17 +25,17 @@ const hotSolana = {
25
25
  publicKey: null as PublicKey | null,
26
26
 
27
27
  async connect(options: any) {
28
- const { publicKey } = await requestHot("solana:connect", options);
28
+ const { publicKey } = await HOT.request("solana:connect", options);
29
29
  hotSolana.publicKey = new PublicKey(publicKey);
30
30
  return { publicKey: hotSolana.publicKey };
31
31
  },
32
32
 
33
33
  async disconnect() {
34
- return await requestHot("solana:disconnect", {});
34
+ return await HOT.request("solana:disconnect", {});
35
35
  },
36
36
 
37
37
  async signAllTransactions(transactions: any[]) {
38
- const result = await requestHot("solana:signAllTransactions", {
38
+ const result = await HOT.request("solana:signAllTransactions", {
39
39
  transactions: transactions.map((t) => t.serialize().toString("base64")),
40
40
  });
41
41
 
@@ -43,7 +43,7 @@ const hotSolana = {
43
43
  },
44
44
 
45
45
  async signTransaction(transaction: any) {
46
- const result = await requestHot("solana:signAllTransactions", {
46
+ const result = await HOT.request("solana:signAllTransactions", {
47
47
  transactions: [transaction.serialize().toString("base64")],
48
48
  });
49
49
 
@@ -51,7 +51,7 @@ const hotSolana = {
51
51
  },
52
52
 
53
53
  async signAndSendTransaction(transaction: any, options: any) {
54
- const result = await requestHot("solana:signAndSendTransaction", {
54
+ const result = await HOT.request("solana:signAndSendTransaction", {
55
55
  transaction: transaction.serialize().toString("base64"),
56
56
  options,
57
57
  });
@@ -61,11 +61,10 @@ const hotSolana = {
61
61
 
62
62
  async signIn(input: any) {
63
63
  throw "Not supported";
64
- return await requestHot("solana:signIn", input);
65
64
  },
66
65
 
67
66
  async signMessage(message: string) {
68
- const result = await requestHot("solana:signMessage", { message: Buffer.from(message).toString("base64") });
67
+ const result = await HOT.request("solana:signMessage", { message: Buffer.from(message).toString("base64") });
69
68
  return { signature: Buffer.from(result.signature, "base64") };
70
69
  },
71
70
 
@@ -84,15 +83,13 @@ HOT.subscribe("solana:accountChanged", (publicKey: string | null) => {
84
83
  });
85
84
  */
86
85
 
87
- if (isInjected()) {
88
- registerWallet(new GhostWallet(hotSolana));
86
+ registerWallet(new GhostWallet(hotSolana));
89
87
 
90
- // New wallets no longer need to register wallet globals - and can
91
- // ignore the code below. However if you have legacy apps relying on globals,
92
- // this is the safest way to attach the reference to the window, guarding against errors.
93
- try {
94
- Object.defineProperty(window, "hotSolana", { value: hotSolana });
95
- } catch (error) {
96
- //
97
- }
88
+ // New wallets no longer need to register wallet globals - and can
89
+ // ignore the code below. However if you have legacy apps relying on globals,
90
+ // this is the safest way to attach the reference to the window, guarding against errors.
91
+ try {
92
+ Object.defineProperty(window, "hotSolana", { value: hotSolana });
93
+ } catch (error) {
94
+ //
98
95
  }
@@ -110,7 +110,7 @@ export class GhostWallet implements Wallet {
110
110
  this._connected();
111
111
  }
112
112
 
113
- _on: StandardEventsOnMethod = (event, listener) => {
113
+ _on: StandardEventsOnMethod = (event: StandardEventsNames, listener: StandardEventsListeners[StandardEventsNames]) => {
114
114
  this._listeners[event]?.push(listener) || (this._listeners[event] = [listener]);
115
115
  return (): void => this._off(event, listener);
116
116
  };
@@ -152,7 +152,7 @@ export class GhostWallet implements Wallet {
152
152
  }
153
153
  };
154
154
 
155
- _connect: StandardConnectMethod = async ({ silent } = {}) => {
155
+ _connect: StandardConnectMethod = async ({ silent }: { silent?: boolean } = {}) => {
156
156
  if (!this._account) await this._ghost.connect(silent ? { onlyIfTrusted: true } : undefined);
157
157
  this._connected();
158
158
  return { accounts: this.accounts };
@@ -162,7 +162,7 @@ export class GhostWallet implements Wallet {
162
162
  await this._ghost.disconnect();
163
163
  };
164
164
 
165
- _signAndSendTransaction: SolanaSignAndSendTransactionMethod = async (...inputs) => {
165
+ _signAndSendTransaction: SolanaSignAndSendTransactionMethod = async (...inputs: any[]) => {
166
166
  if (!this._account) throw new Error("not connected");
167
167
 
168
168
  const outputs: SolanaSignAndSendTransactionOutput[] = [];
@@ -189,7 +189,7 @@ export class GhostWallet implements Wallet {
189
189
  return outputs;
190
190
  };
191
191
 
192
- _signTransaction: SolanaSignTransactionMethod = async (...inputs) => {
192
+ _signTransaction: SolanaSignTransactionMethod = async (...inputs: any[]) => {
193
193
  if (!this._account) throw new Error("not connected");
194
194
 
195
195
  const outputs: SolanaSignTransactionOutput[] = [];
@@ -243,7 +243,7 @@ export class GhostWallet implements Wallet {
243
243
  return outputs;
244
244
  };
245
245
 
246
- _signMessage: SolanaSignMessageMethod = async (...inputs) => {
246
+ _signMessage: SolanaSignMessageMethod = async (...inputs: any[]) => {
247
247
  if (!this._account) throw new Error("not connected");
248
248
 
249
249
  const outputs: SolanaSignMessageOutput[] = [];
@@ -264,7 +264,7 @@ export class GhostWallet implements Wallet {
264
264
  return outputs;
265
265
  };
266
266
 
267
- _signIn: SolanaSignInMethod = async (...inputs) => {
267
+ _signIn: SolanaSignInMethod = async (...inputs: any[]) => {
268
268
  const outputs: SolanaSignInOutput[] = [];
269
269
 
270
270
  if (inputs.length > 1) {
@@ -23,13 +23,14 @@ import { ReviewFee } from "../core/bridge";
23
23
  import { Commitment } from "../core";
24
24
  import { api } from "../core/api";
25
25
 
26
- import { ISolanaProtocolWallet } from "./protocol";
26
+ import { ISolanaProtocolWallet } from "./WalletStandard";
27
27
 
28
28
  class SolanaWallet extends OmniWallet {
29
+ readonly icon = "https://storage.herewallet.app/upload/8700f33153ad813e133e5bf9b791b5ecbeea66edca6b8d17aeccb8048eb29ef7.png";
29
30
  readonly type = WalletType.SOLANA;
30
31
 
31
- constructor(readonly connector: OmniConnector, readonly wallet: ISolanaProtocolWallet) {
32
- super(connector);
32
+ constructor(readonly wallet: ISolanaProtocolWallet) {
33
+ super();
33
34
  }
34
35
 
35
36
  getConnection() {
@@ -63,11 +64,6 @@ class SolanaWallet extends OmniWallet {
63
64
  return BigInt(meta.value.amount);
64
65
  }
65
66
 
66
- async disconnect() {
67
- await this.wallet.disconnect?.();
68
- super.disconnect();
69
- }
70
-
71
67
  async buildTranferInstructions(token: Token, amount: bigint, receiver: string, fee: ReviewFee) {
72
68
  const destination = new PublicKey(receiver);
73
69
  const owner = new PublicKey(this.address);
@@ -1,68 +1,76 @@
1
- import { sep43Modules, HotWalletModule, StellarWalletsKit, WalletNetwork, ISupportedWallet } from "@creit.tech/stellar-wallets-kit";
2
1
  import { Transaction } from "@stellar/stellar-base";
3
2
 
3
+ import HOT from "../hot-wallet/iframe";
4
4
  import { WalletType } from "../core/chains";
5
5
  import { HotConnector } from "../HotConnector";
6
6
  import { ConnectorType, OmniConnector } from "../OmniConnector";
7
- import { isInjected } from "../hot-wallet/iframe";
8
- import { OmniWallet } from "../OmniWallet";
9
- import StellarWallet from "./wallet";
10
7
 
11
- class StellarConnector extends OmniConnector<StellarWallet, ISupportedWallet> {
12
- stellarKit: StellarWalletsKit;
8
+ import { FreighterModule } from "./freigher";
9
+ import { HotWalletModule } from "./hotWallet";
10
+ import StellarWallet from "./wallet";
13
11
 
12
+ class StellarConnector extends OmniConnector<StellarWallet> {
14
13
  icon = "https://storage.herewallet.app/upload/1469894e53ca248ac6adceb2194e6950a13a52d972beb378a20bce7815ba01a4.png";
15
14
  walletTypes = [WalletType.STELLAR, WalletType.OMNI];
16
15
  type = ConnectorType.WALLET;
17
16
  name = "Stellar Wallet";
18
17
  id = "stellar";
19
18
 
20
- constructor(wibe3: HotConnector, stellarKit?: StellarWalletsKit) {
21
- super(wibe3);
19
+ modules = {
20
+ hotWallet: new HotWalletModule(),
21
+ freighter: new FreighterModule(),
22
+ };
22
23
 
23
- this.stellarKit = stellarKit || new StellarWalletsKit({ network: WalletNetwork.PUBLIC, modules: isInjected() ? [new HotWalletModule()] : sep43Modules() });
24
- this.stellarKit.getSupportedWallets().then((wallets) => {
25
- const hot = wallets.find((w) => w.id === "hot-wallet");
26
- this.options = wallets.filter((w) => w.id !== "hot-wallet").map((w) => ({ ...w, name: w.name, icon: w.icon, download: w.url, type: "external" as const, id: w.id }));
27
- if (hot) this.options.unshift({ ...hot, name: hot.name, icon: hot.icon, download: hot.url, type: "external" as const, id: hot.id });
28
- });
24
+ constructor(wibe3: HotConnector) {
25
+ super(wibe3);
29
26
 
30
- this.getConnectedWallet().then((data) => {
31
- if (!data || !this.stellarKit) throw "No wallet";
27
+ this.options = Object.values(this.modules).map((module) => ({
28
+ type: "external" as const,
29
+ name: module.productName,
30
+ icon: module.productIcon,
31
+ download: module.productUrl,
32
+ id: module.productId,
33
+ }));
32
34
 
33
- this.stellarKit.setWallet(data.id!);
34
- const signMessage = async (message: string) => this.stellarKit.signMessage(message);
35
- const signTransaction = async (transaction: Transaction) => this.stellarKit.signTransaction(transaction.toXDR());
36
- this.setWallet(new StellarWallet(this, { address: data.address!, signMessage, signTransaction }));
35
+ this.getConnectedWallet().then(async ({ id, address }) => {
36
+ if (!id || !address) return;
37
+ const wallet = this.getWallet(id);
38
+ const isAvailable = await wallet?.isAvailable();
39
+ if (isAvailable && wallet) this.selectWallet(address, wallet);
37
40
  });
38
41
  }
39
42
 
40
- async createWallet(address: string): Promise<OmniWallet> {
41
- return new StellarWallet(this, { address });
43
+ getWallet(id: string): FreighterModule | HotWalletModule | null {
44
+ return Object.values(this.modules).find((module) => module.productId === id) || null;
42
45
  }
43
46
 
44
47
  async getConnectedWallet() {
45
- if (isInjected()) {
46
- this.stellarKit.setWallet("hot-wallet");
47
- const { address } = await this.stellarKit.getAddress();
48
- return { type: "wallet", id: "hot-wallet", address };
48
+ if (HOT.isInjected) {
49
+ const { address } = await this.modules.hotWallet.getAddress();
50
+ return { type: "wallet", id: this.modules.hotWallet.productId, address };
49
51
  }
50
52
 
51
53
  return await this.getStorage();
52
54
  }
53
55
 
56
+ async selectWallet(address: string, wallet: HotWalletModule | FreighterModule) {
57
+ const signMessage = async (message: string) => wallet.signMessage(message);
58
+ const signTransaction = async (transaction: Transaction) => wallet.signTransaction(transaction.toXDR());
59
+ return this.setWallet(new StellarWallet({ address, rpc: this.wibe3.hotBridge.stellar, signMessage, signTransaction }));
60
+ }
61
+
54
62
  async connect(id: string) {
55
- this.stellarKit.setWallet(id);
56
- const { address } = await this.stellarKit.getAddress();
57
- const signMessage = async (message: string) => this.stellarKit.signMessage(message);
58
- const signTransaction = async (transaction: Transaction) => this.stellarKit.signTransaction(transaction.toXDR());
63
+ const wallet = this.getWallet(id);
64
+ if (!wallet) throw new Error("Wallet not found");
65
+
66
+ const { address } = await wallet.getAddress();
59
67
  this.setStorage({ type: "wallet", id, address });
60
- return this.setWallet(new StellarWallet(this, { address, signMessage, signTransaction }));
68
+ return this.selectWallet(address, wallet);
61
69
  }
62
70
 
63
71
  async disconnect() {
64
72
  super.disconnect();
65
- this.stellarKit.disconnect();
73
+ this.removeStorage();
66
74
  }
67
75
  }
68
76
 
@@ -0,0 +1,119 @@
1
+ import { isConnected, requestAccess, getAddress, signTransaction, signAuthEntry, signMessage, getNetwork } from "@stellar/freighter-api";
2
+
3
+ declare global {
4
+ interface Window {
5
+ stellar?: {
6
+ provider: string;
7
+ platform: string;
8
+ };
9
+ }
10
+ }
11
+
12
+ function parseError(e: any) {
13
+ return {
14
+ code: e?.error?.code || e?.code || -1,
15
+ message: e?.error?.message || e?.message || (typeof e === "string" && e) || "Unhandled error from the wallet",
16
+ ext: e?.error?.ext || e?.ext,
17
+ };
18
+ }
19
+
20
+ const FREIGHTER_ID = "freighter";
21
+ export class FreighterModule {
22
+ productId = FREIGHTER_ID;
23
+ productName = "Freighter";
24
+ productUrl = "https://freighter.app";
25
+ productIcon = "https://stellar.creit.tech/wallet-icons/freighter.png";
26
+
27
+ async runChecks() {
28
+ if (!(await this.isAvailable())) {
29
+ throw new Error("Freighter is not connected");
30
+ }
31
+ }
32
+
33
+ async isAvailable() {
34
+ if (window.stellar?.provider === "freighter" && window.stellar?.platform === "mobile") return false;
35
+ return isConnected()
36
+ .then(({ isConnected: isConnected2, error }) => !error && isConnected2)
37
+ .catch(() => false);
38
+ }
39
+
40
+ async getAddress(params?: { skipRequestAccess?: boolean }): Promise<{ address: string }> {
41
+ return this.runChecks()
42
+ .then(async () => {
43
+ if (params?.skipRequestAccess) return true;
44
+ return requestAccess();
45
+ })
46
+ .then(() => getAddress())
47
+ .then(({ address, error }) => {
48
+ if (error) throw error;
49
+ if (!address)
50
+ throw {
51
+ code: -3,
52
+ message: "Getting the address is not allowed, please request access first.",
53
+ };
54
+ return { address };
55
+ })
56
+ .catch((e) => {
57
+ throw parseError(e);
58
+ });
59
+ }
60
+ async signTransaction(xdr: string, opts?: { address?: string; networkPassphrase?: string }): Promise<{ signedTxXdr: string; signerAddress?: string }> {
61
+ return this.runChecks()
62
+ .then(async () => {
63
+ const { signedTxXdr, signerAddress, error } = await signTransaction(xdr, {
64
+ address: opts?.address,
65
+ networkPassphrase: opts?.networkPassphrase,
66
+ });
67
+ if (error) throw error;
68
+ return { signedTxXdr, signerAddress };
69
+ })
70
+ .catch((e) => {
71
+ throw parseError(e);
72
+ });
73
+ }
74
+
75
+ async signAuthEntry(authEntry: string, opts?: { address?: string; networkPassphrase?: string }): Promise<{ signedAuthEntry: string; signerAddress?: string }> {
76
+ return this.runChecks()
77
+ .then(async () => {
78
+ const { signedAuthEntry, signerAddress, error } = await signAuthEntry(authEntry, {
79
+ address: opts?.address,
80
+ networkPassphrase: opts?.networkPassphrase,
81
+ });
82
+ if (error || !signedAuthEntry) throw error;
83
+ return { signedAuthEntry: Buffer.from(signedAuthEntry).toString("base64"), signerAddress };
84
+ })
85
+ .catch((e) => {
86
+ throw parseError(e);
87
+ });
88
+ }
89
+
90
+ async signMessage(message: string, opts?: { address?: string; networkPassphrase?: string }): Promise<{ signedMessage: string; signerAddress?: string }> {
91
+ return this.runChecks()
92
+ .then(async () => {
93
+ const { signedMessage, signerAddress, error } = await signMessage(message, {
94
+ address: opts?.address,
95
+ networkPassphrase: opts?.networkPassphrase,
96
+ });
97
+ if (error || !signedMessage) throw error;
98
+ return {
99
+ signedMessage: typeof signedMessage === "string" ? signedMessage : Buffer.from(signedMessage).toString("base64"),
100
+ signerAddress,
101
+ };
102
+ })
103
+ .catch((e) => {
104
+ throw parseError(e);
105
+ });
106
+ }
107
+
108
+ async getNetwork(): Promise<{ network: string; networkPassphrase: string }> {
109
+ return this.runChecks()
110
+ .then(async () => {
111
+ const { network, networkPassphrase, error } = await getNetwork();
112
+ if (error) throw error;
113
+ return { network, networkPassphrase };
114
+ })
115
+ .catch((e) => {
116
+ throw parseError(e);
117
+ });
118
+ }
119
+ }
@@ -1,13 +1,9 @@
1
- import { type ModuleInterface, ModuleType, WalletNetwork } from "@creit.tech/stellar-wallets-kit";
2
- import { requestHot } from "../hot-wallet/iframe";
1
+ import { Networks } from "@stellar/stellar-sdk";
2
+ import HOT from "../hot-wallet/iframe";
3
3
 
4
4
  export const HOTWALLET_ID: string = "hot-wallet";
5
5
 
6
- /**
7
- * **IMPORTANT**: This module requires that you have a "global" and a "Buffer" polyfill in your app, if not provided then this module will break your app.
8
- */
9
- export class HotWalletModule implements ModuleInterface {
10
- moduleType: ModuleType = ModuleType.HOT_WALLET;
6
+ export class HotWalletModule {
11
7
  productId: string = HOTWALLET_ID;
12
8
  productName: string = "HOT Wallet";
13
9
  productUrl: string = "https://hot-labs.org/wallet";
@@ -18,22 +14,22 @@ export class HotWalletModule implements ModuleInterface {
18
14
  }
19
15
 
20
16
  async getAddress(): Promise<{ address: string }> {
21
- return await requestHot("stellar:getAddress", {});
17
+ return await HOT.request("stellar:getAddress", {});
22
18
  }
23
19
 
24
20
  async signTransaction(xdr: string, opts?: { address?: string }): Promise<{ signedTxXdr: string; signerAddress?: string }> {
25
- return await requestHot("stellar:signTransaction", { xdr, accountToSign: opts?.address });
21
+ return await HOT.request("stellar:signTransaction", { xdr, accountToSign: opts?.address });
26
22
  }
27
23
 
28
24
  async signAuthEntry(authEntry: string, opts?: { address?: string }): Promise<{ signedAuthEntry: string; signerAddress?: string }> {
29
- return await requestHot("stellar:signAuthEntry", { authEntry, accountToSign: opts?.address });
25
+ return await HOT.request("stellar:signAuthEntry", { authEntry, accountToSign: opts?.address });
30
26
  }
31
27
 
32
28
  async signMessage(message: string, opts?: { address?: string }): Promise<{ signedMessage: string; signerAddress?: string }> {
33
- return await requestHot("stellar:signMessage", { message, accountToSign: opts?.address });
29
+ return await HOT.request("stellar:signMessage", { message, accountToSign: opts?.address });
34
30
  }
35
31
 
36
32
  async getNetwork(): Promise<{ network: string; networkPassphrase: string }> {
37
- return { network: "mainnet", networkPassphrase: WalletNetwork.PUBLIC };
33
+ return { network: "mainnet", networkPassphrase: Networks.PUBLIC };
38
34
  }
39
35
  }
@@ -4,7 +4,6 @@ import { rpc } from "@stellar/stellar-sdk";
4
4
 
5
5
  import { WalletType } from "../core/chains";
6
6
  import { OmniWallet } from "../OmniWallet";
7
- import { OmniConnector } from "../OmniConnector";
8
7
  import { ReviewFee } from "../core/bridge";
9
8
  import { formatter } from "../core/utils";
10
9
  import { Network } from "../core/chains";
@@ -12,9 +11,13 @@ import { Token } from "../core/token";
12
11
  import { Commitment } from "../core";
13
12
 
14
13
  interface ProtocolWallet {
14
+ address: string;
15
15
  signTransaction?: (transaction: Transaction) => Promise<{ signedTxXdr: string }>;
16
16
  signMessage?: (message: string) => Promise<{ signedMessage: string }>;
17
- address: string;
17
+ rpc: {
18
+ callSoroban: (callback: (s: any) => Promise<any>) => Promise<any>;
19
+ callHorizon: (callback: (h: any) => Promise<any>) => Promise<any>;
20
+ };
18
21
  }
19
22
 
20
23
  export const ACCOUNT_FOR_SIMULATE = "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7";
@@ -28,14 +31,11 @@ export enum ASSET_CONTRACT_METHOD {
28
31
  }
29
32
 
30
33
  class StellarWallet extends OmniWallet {
34
+ readonly icon = "https://storage.herewallet.app/upload/1469894e53ca248ac6adceb2194e6950a13a52d972beb378a20bce7815ba01a4.png";
31
35
  readonly type = WalletType.STELLAR;
32
36
 
33
- constructor(readonly connector: OmniConnector, readonly wallet: ProtocolWallet) {
34
- super(connector);
35
- }
36
-
37
- get rpc() {
38
- return this.connector.wibe3.hotBridge.stellar;
37
+ constructor(readonly wallet: ProtocolWallet) {
38
+ super();
39
39
  }
40
40
 
41
41
  get address() {
@@ -86,8 +86,8 @@ class StellarWallet extends OmniWallet {
86
86
  const asset = await this.getAssetFromContractId(token);
87
87
  const sendAmount = formatter.formatAmount(amount, 7);
88
88
 
89
- const account = await this.connector.wibe3.hotBridge.stellar.callSoroban((s) => s.getAccount(this.address));
90
- const baseFee = await this.connector.wibe3.hotBridge.stellar.callHorizon((h) => h.fetchBaseFee()).catch(() => +BASE_FEE);
89
+ const account = await this.wallet.rpc.callSoroban((s) => s.getAccount(this.address));
90
+ const baseFee = await this.wallet.rpc.callHorizon((h) => h.fetchBaseFee()).catch(() => +BASE_FEE);
91
91
  const builder = new TransactionBuilder(account, {
92
92
  memo: memo ? Memo.text(memo) : undefined,
93
93
  networkPassphrase: Networks.PUBLIC,
@@ -106,13 +106,13 @@ class StellarWallet extends OmniWallet {
106
106
  )
107
107
  );
108
108
 
109
- const tx = await this.rpc.callSoroban((s) => s.prepareTransaction(builder.build() as any));
109
+ const tx = await this.wallet.rpc.callSoroban((s) => s.prepareTransaction(builder.build() as any));
110
110
  const fee = BigInt(Math.floor(baseFee * tx.operations.length));
111
111
  return { fee: new ReviewFee({ baseFee: fee, priorityFee: 0n, gasLimit: 1n, chain: Network.Stellar }), tx: tx as unknown as Transaction };
112
112
  }
113
113
 
114
114
  let needXlm = 0;
115
- const receiverAccount = await this.rpc.callHorizon((h) => h.loadAccount(receiver)).catch(() => null);
115
+ const receiverAccount = await this.wallet.rpc.callHorizon((h) => h.loadAccount(receiver)).catch(() => null);
116
116
  const claimableBalance = Operation.createClaimableBalance({ amount: amount.toString(), claimants: [new Claimant(receiver)], asset });
117
117
 
118
118
  if (receiverAccount == null) {
@@ -154,7 +154,7 @@ class StellarWallet extends OmniWallet {
154
154
  if (!this.wallet.signTransaction) throw "not impl";
155
155
  const result = await this.wallet.signTransaction(transaction);
156
156
  const txObject = new Transaction(result.signedTxXdr, Networks.PUBLIC);
157
- const { hash } = await this.rpc.callHorizon((t) => t.submitTransaction(txObject as any));
157
+ const { hash } = await this.wallet.rpc.callHorizon((t) => t.submitTransaction(txObject as any));
158
158
  return hash;
159
159
  }
160
160
 
@@ -197,7 +197,7 @@ class StellarWallet extends OmniWallet {
197
197
  async changeTrustline(address: string) {
198
198
  if (address === "native") return;
199
199
  const asset = await this.getAssetFromContractId(address);
200
- const account = await this.rpc.callHorizon((h) => h.loadAccount(this.address));
200
+ const account = await this.wallet.rpc.callHorizon((h) => h.loadAccount(this.address));
201
201
  const trustlineOp = Operation.changeTrust({ asset: asset, source: this.address });
202
202
  const trustlineTx = new TransactionBuilder(account, { fee: BASE_FEE, networkPassphrase: Networks.PUBLIC }) //
203
203
  .addOperation(trustlineOp)
@@ -215,7 +215,7 @@ class StellarWallet extends OmniWallet {
215
215
  }
216
216
 
217
217
  const tx = await this.buildSmartContactTx(ACCOUNT_FOR_SIMULATE, id, ASSET_CONTRACT_METHOD.NAME);
218
- const result = (await this.rpc.callSoroban((s) => s.simulateTransaction(tx as any))) as unknown as rpc.Api.SimulateTransactionSuccessResponse;
218
+ const result = (await this.wallet.rpc.callSoroban((s) => s.simulateTransaction(tx as any))) as unknown as rpc.Api.SimulateTransactionSuccessResponse;
219
219
 
220
220
  const value = result?.result?.retval?.value();
221
221
  if (!value) throw "Asset not found";
@@ -227,7 +227,7 @@ class StellarWallet extends OmniWallet {
227
227
  }
228
228
 
229
229
  async buildSmartContactTx(publicKey: string, contactId: string, method: string, ...args: any[]) {
230
- const account = await this.rpc.callSoroban((s) => s.getAccount(publicKey));
230
+ const account = await this.wallet.rpc.callSoroban((s) => s.getAccount(publicKey));
231
231
  const contract = new Contract(contactId);
232
232
  const builtTx = new TransactionBuilder(account, { fee: BASE_FEE, networkPassphrase: Networks.PUBLIC });
233
233
 
@@ -244,7 +244,7 @@ class StellarWallet extends OmniWallet {
244
244
  Address.fromString(contract).toScVal()
245
245
  );
246
246
 
247
- const result = (await this.rpc.callSoroban((s) => s.simulateTransaction(tx as any))) as unknown as rpc.Api.SimulateTransactionSuccessResponse;
247
+ const result = (await this.wallet.rpc.callSoroban((s) => s.simulateTransaction(tx as any))) as unknown as rpc.Api.SimulateTransactionSuccessResponse;
248
248
  if (result) return BigInt(this.i128ToInt(result.result?.retval.value() as xdr.Int128Parts));
249
249
  return 0n;
250
250
  }