@hot-labs/kit 1.0.48 → 1.0.51

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 (60) hide show
  1. package/build/HotConnector.d.ts +0 -2
  2. package/build/HotConnector.js +4 -5
  3. package/build/HotConnector.js.map +1 -1
  4. package/build/OmniWallet.d.ts +3 -18
  5. package/build/OmniWallet.js +8 -3
  6. package/build/OmniWallet.js.map +1 -1
  7. package/build/core/Intents.d.ts +1 -6
  8. package/build/core/api.d.ts +5 -6
  9. package/build/core/api.js +15 -11
  10. package/build/core/api.js.map +1 -1
  11. package/build/core/token.js +6 -2
  12. package/build/core/token.js.map +1 -1
  13. package/build/core/types.d.ts +4 -3
  14. package/build/cosmos/connector.d.ts +1 -1
  15. package/build/cosmos/connector.js +3 -2
  16. package/build/cosmos/connector.js.map +1 -1
  17. package/build/cosmos/wallet.d.ts +3 -3
  18. package/build/cosmos/wallet.js +0 -3
  19. package/build/cosmos/wallet.js.map +1 -1
  20. package/build/evm/wallet.d.ts +2 -8
  21. package/build/evm/wallet.js +3 -14
  22. package/build/evm/wallet.js.map +1 -1
  23. package/build/exchange.js +4 -3
  24. package/build/exchange.js.map +1 -1
  25. package/build/near/connector.js +1 -1
  26. package/build/near/connector.js.map +1 -1
  27. package/build/near/wallet.d.ts +2 -9
  28. package/build/near/wallet.js +3 -20
  29. package/build/near/wallet.js.map +1 -1
  30. package/build/solana/wallet.d.ts +3 -9
  31. package/build/solana/wallet.js +23 -28
  32. package/build/solana/wallet.js.map +1 -1
  33. package/build/stellar/wallet.d.ts +2 -8
  34. package/build/stellar/wallet.js +0 -12
  35. package/build/stellar/wallet.js.map +1 -1
  36. package/build/ton/connector.js +6 -14
  37. package/build/ton/connector.js.map +1 -1
  38. package/build/ton/wallet.d.ts +0 -15
  39. package/build/ton/wallet.js +0 -15
  40. package/build/ton/wallet.js.map +1 -1
  41. package/build/ui/payment/Bridge.js +7 -1
  42. package/build/ui/payment/Bridge.js.map +1 -1
  43. package/package.json +1 -1
  44. package/skill.md +2 -7
  45. package/src/HotConnector.ts +4 -5
  46. package/src/OmniWallet.ts +10 -23
  47. package/src/core/api.ts +19 -13
  48. package/src/core/token.ts +7 -2
  49. package/src/core/types.ts +4 -3
  50. package/src/cosmos/connector.ts +4 -3
  51. package/src/cosmos/wallet.ts +3 -6
  52. package/src/evm/wallet.ts +5 -17
  53. package/src/exchange.ts +6 -6
  54. package/src/near/connector.ts +1 -1
  55. package/src/near/wallet.ts +4 -22
  56. package/src/solana/wallet.ts +28 -31
  57. package/src/stellar/wallet.ts +2 -15
  58. package/src/ton/connector.ts +6 -14
  59. package/src/ton/wallet.ts +0 -17
  60. package/src/ui/payment/Bridge.tsx +6 -1
@@ -1,5 +1,5 @@
1
1
  import { NearWalletBase, SignMessageParams, SignedMessage, SignAndSendTransactionParams } from "@hot-labs/near-connect";
2
- import { base64, base58, hex } from "@scure/base";
2
+ import { base64, base58 } from "@scure/base";
3
3
  import { Action } from "@near-js/transactions";
4
4
 
5
5
  import { OmniConnector } from "../OmniConnector";
@@ -8,6 +8,7 @@ import { WalletType } from "../core/chains";
8
8
  import { ReviewFee } from "../core/bridge";
9
9
  import { rpc, TGAS } from "../core/nearRpc";
10
10
  import { Token } from "../core/token";
11
+ import { Commitment } from "../core";
11
12
 
12
13
  export default class NearWallet extends OmniWallet {
13
14
  readonly type = WalletType.NEAR;
@@ -102,6 +103,7 @@ export default class NearWallet extends OmniWallet {
102
103
  }
103
104
 
104
105
  async needRegisterToken(token: string, address: string): Promise<boolean> {
106
+ if (token === "native") return false;
105
107
  const storage = await rpc.viewMethod({ contractId: token, methodName: "storage_balance_of", args: { account_id: address } }).catch(() => null);
106
108
  return storage == null;
107
109
  }
@@ -188,27 +190,7 @@ export default class NearWallet extends OmniWallet {
188
190
  return await this.sendTransaction({ receiverId: args.token.address, actions });
189
191
  }
190
192
 
191
- async signIntentsWithAuth(domain: string, intents?: Record<string, any>[]) {
192
- if (!this.wallet) throw "not impl";
193
- const accounts = await this.wallet.getAccounts();
194
- if (accounts.length === 0) throw new Error("No account found");
195
- const { accountId, publicKey } = accounts[0];
196
-
197
- const seed = hex.encode(window.crypto.getRandomValues(new Uint8Array(32)));
198
- const msgBuffer = new TextEncoder().encode(`${domain}_${seed}`);
199
- const nonce = await window.crypto.subtle.digest("SHA-256", new Uint8Array(msgBuffer));
200
-
201
- return {
202
- signed: await this.signIntents(intents || [], { nonce: new Uint8Array(nonce) }),
203
- chainId: WalletType.NEAR,
204
- publicKey: publicKey,
205
- address: accountId,
206
- domain,
207
- seed,
208
- };
209
- }
210
-
211
- async signIntents(intents: Record<string, any>[], options?: { nonce?: Uint8Array; deadline?: number }): Promise<Record<string, any>> {
193
+ async signIntents(intents: Record<string, any>[], options?: { nonce?: Uint8Array; deadline?: number }): Promise<Commitment> {
212
194
  if (!this.wallet) throw "not impl";
213
195
 
214
196
  const nonce = new Uint8Array(options?.nonce || window.crypto.getRandomValues(new Uint8Array(32)));
@@ -20,17 +20,21 @@ import { OmniWallet } from "../OmniWallet";
20
20
  import { Token } from "../core/token";
21
21
  import { formatter } from "../core/utils";
22
22
  import { ReviewFee } from "../core/bridge";
23
+ import { Commitment } from "../core";
24
+ import { api } from "../core/api";
23
25
 
24
26
  import { ISolanaProtocolWallet } from "./protocol";
25
27
 
26
28
  class SolanaWallet extends OmniWallet {
27
29
  readonly type = WalletType.SOLANA;
28
- readonly connection: Connection;
29
30
 
30
31
  constructor(readonly connector: OmniConnector, readonly wallet: ISolanaProtocolWallet) {
31
32
  super(connector);
32
- this.connection = new Connection("https://api0.herewallet.app/api/v1/evm/rpc/1001", {
33
- httpHeaders: { "Api-Key": connector.wibe3.api.apiKey },
33
+ }
34
+
35
+ getConnection() {
36
+ return new Connection(api.getRpcUrl(Network.Solana), {
37
+ httpHeaders: { "Api-Key": api.apiKey },
34
38
  });
35
39
  }
36
40
 
@@ -47,13 +51,15 @@ class SolanaWallet extends OmniWallet {
47
51
  }
48
52
 
49
53
  async fetchBalance(_: number, address: string) {
54
+ const connection = this.getConnection();
55
+
50
56
  if (address === "native") {
51
- const balance = await this.connection.getBalance(new PublicKey(this.address));
57
+ const balance = await connection.getBalance(new PublicKey(this.address));
52
58
  return BigInt(balance);
53
59
  }
54
60
 
55
61
  const ATA = getAssociatedTokenAddressSync(new PublicKey(address), new PublicKey(this.address));
56
- const meta = await this.connection.getTokenAccountBalance(ATA);
62
+ const meta = await connection.getTokenAccountBalance(ATA);
57
63
  return BigInt(meta.value.amount);
58
64
  }
59
65
 
@@ -62,25 +68,12 @@ class SolanaWallet extends OmniWallet {
62
68
  super.disconnect();
63
69
  }
64
70
 
65
- async signIntentsWithAuth(domain: string, intents?: Record<string, any>[]) {
66
- const seed = hex.encode(window.crypto.getRandomValues(new Uint8Array(32)));
67
- const msgBuffer = new TextEncoder().encode(`${domain}_${seed}`);
68
- const nonce = await window.crypto.subtle.digest("SHA-256", new Uint8Array(msgBuffer));
69
-
70
- return {
71
- signed: await this.signIntents(intents || [], { nonce: new Uint8Array(nonce) }),
72
- publicKey: `ed25519:${this.address}`,
73
- chainId: WalletType.SOLANA,
74
- address: this.address,
75
- seed,
76
- };
77
- }
78
-
79
71
  async buildTranferInstructions(token: Token, amount: bigint, receiver: string, fee: ReviewFee) {
80
72
  const destination = new PublicKey(receiver);
81
73
  const owner = new PublicKey(this.address);
74
+ const connection = this.getConnection();
82
75
 
83
- const reserve = await this.connection.getMinimumBalanceForRentExemption(0);
76
+ const reserve = await connection.getMinimumBalanceForRentExemption(0);
84
77
  let additionalFee = 0n;
85
78
 
86
79
  if (token.address === "native") {
@@ -96,7 +89,7 @@ class SolanaWallet extends OmniWallet {
96
89
  }
97
90
 
98
91
  const mint = new PublicKey(token.address);
99
- const mintAccount = await this.connection.getAccountInfo(mint);
92
+ const mintAccount = await connection.getAccountInfo(mint);
100
93
  const tokenProgramId = mintAccount?.owner.equals(TOKEN_2022_PROGRAM_ID) ? TOKEN_2022_PROGRAM_ID : TOKEN_PROGRAM_ID;
101
94
 
102
95
  const tokenFrom = getAssociatedTokenAddressSync(mint, owner, false, tokenProgramId);
@@ -104,11 +97,11 @@ class SolanaWallet extends OmniWallet {
104
97
 
105
98
  const instructions: TransactionInstruction[] = [ComputeBudgetProgram.setComputeUnitPrice({ microLamports: Number(fee.baseFee) }), ComputeBudgetProgram.setComputeUnitLimit({ units: Number(fee.gasLimit) })];
106
99
 
107
- const isRegistered = await getAccount(this.connection, tokenTo, "confirmed", tokenProgramId).catch(() => null);
100
+ const isRegistered = await getAccount(connection, tokenTo, "confirmed", tokenProgramId).catch(() => null);
108
101
  if (isRegistered == null) {
109
102
  const inst = createAssociatedTokenAccountInstruction(new PublicKey(this.address), tokenTo, destination, mint, tokenProgramId, ASSOCIATED_TOKEN_PROGRAM_ID);
110
103
  instructions.push(inst);
111
- additionalFee += BigInt(await getMinimumBalanceForRentExemptAccount(this.connection));
104
+ additionalFee += BigInt(await getMinimumBalanceForRentExemptAccount(connection));
112
105
  }
113
106
 
114
107
  if (tokenProgramId === TOKEN_2022_PROGRAM_ID) {
@@ -121,7 +114,8 @@ class SolanaWallet extends OmniWallet {
121
114
  }
122
115
 
123
116
  async transferFee(token: Token, receiver: string): Promise<ReviewFee> {
124
- const { blockhash } = await this.connection.getLatestBlockhash();
117
+ const connection = this.getConnection();
118
+ const { blockhash } = await connection.getLatestBlockhash();
125
119
  const fee = new ReviewFee({ chain: Network.Solana, gasLimit: 1_400_000n, baseFee: 100n });
126
120
  const { instructions, additionalFee, reserve } = await this.buildTranferInstructions(token, 1n, receiver, fee);
127
121
 
@@ -134,10 +128,10 @@ class SolanaWallet extends OmniWallet {
134
128
  });
135
129
 
136
130
  if (priorityFeeData?.priorityFeeLevels == null) throw "Failed to fetch gas";
137
- const simulate = await this.connection.simulateTransaction(tx).catch(() => null);
131
+ const simulate = await connection.simulateTransaction(tx).catch(() => null);
138
132
  const unitsConsumed = formatter.bigIntMax(BigInt(simulate?.value.unitsConsumed || 10_000n), 10_000n);
139
133
 
140
- const msgFee = await this.connection.getFeeForMessage(msgForEstimate);
134
+ const msgFee = await connection.getFeeForMessage(msgForEstimate);
141
135
  const medium = BigInt(priorityFeeData.priorityFeeLevels.medium);
142
136
  const high = BigInt(priorityFeeData.priorityFeeLevels.high);
143
137
  const veryHigh = BigInt(priorityFeeData.priorityFeeLevels.veryHigh);
@@ -158,7 +152,7 @@ class SolanaWallet extends OmniWallet {
158
152
  }
159
153
 
160
154
  async getPriorityFeeEstimate(params: any): Promise<any> {
161
- const response = await fetch("https://api0.herewallet.app/api/v1/evm/helius/staked", {
155
+ const response = await fetch(api.baseUrl + "/api/v1/wibe3/helius/staked", {
162
156
  body: JSON.stringify({ jsonrpc: "2.0", id: "helius-sdk", method: "getPriorityFeeEstimate", params: [params] }),
163
157
  headers: { "Content-Type": "application/json" },
164
158
  method: "POST",
@@ -178,20 +172,23 @@ class SolanaWallet extends OmniWallet {
178
172
 
179
173
  async sendTransaction(instructions: TransactionInstruction[]): Promise<string> {
180
174
  if (!this.wallet.sendTransaction) throw "not impl";
181
- const { blockhash } = await this.connection.getLatestBlockhash();
175
+ const connection = this.getConnection();
176
+ const { blockhash } = await connection.getLatestBlockhash();
182
177
  const message = new TransactionMessage({ payerKey: new PublicKey(this.address), recentBlockhash: blockhash, instructions });
183
178
  const transaction = new VersionedTransaction(message.compileToV0Message());
184
- return await this.wallet.sendTransaction(transaction, this.connection, { preflightCommitment: "confirmed" });
179
+ return await this.wallet.sendTransaction(transaction, connection, { preflightCommitment: "confirmed" });
185
180
  }
186
181
 
187
182
  async fetchBalances(chain: number, whitelist: string[]): Promise<Record<string, bigint>> {
188
183
  const native = await this.fetchBalance(chain, "native");
184
+ const connection = this.getConnection();
185
+
189
186
  try {
190
187
  const res = await fetch(`https://api0.herewallet.app/api/v1/user/balances/${chain}/${this.address}`, { body: JSON.stringify({ whitelist }), method: "POST" });
191
188
  const { balances } = await res.json();
192
189
  return { ...balances, native };
193
190
  } catch {
194
- const tokenAccounts = await this.connection.getParsedTokenAccountsByOwner(new PublicKey(this.address), { programId: TOKEN_PROGRAM_ID });
191
+ const tokenAccounts = await connection.getParsedTokenAccountsByOwner(new PublicKey(this.address), { programId: TOKEN_PROGRAM_ID });
195
192
  const balances = Object.fromEntries(
196
193
  tokenAccounts.value.map((account) => {
197
194
  const { mint, tokenAmount } = account.account.data.parsed.info;
@@ -208,7 +205,7 @@ class SolanaWallet extends OmniWallet {
208
205
  return this.wallet.signMessage(message);
209
206
  }
210
207
 
211
- async signIntents(intents: Record<string, any>[], options?: { deadline?: number; nonce?: Uint8Array }): Promise<Record<string, any>> {
208
+ async signIntents(intents: Record<string, any>[], options?: { deadline?: number; nonce?: Uint8Array }): Promise<Commitment> {
212
209
  const nonce = new Uint8Array(options?.nonce || window.crypto.getRandomValues(new Uint8Array(32)));
213
210
 
214
211
  const message = JSON.stringify({
@@ -9,6 +9,7 @@ import { ReviewFee } from "../core/bridge";
9
9
  import { formatter } from "../core/utils";
10
10
  import { Network } from "../core/chains";
11
11
  import { Token } from "../core/token";
12
+ import { Commitment } from "../core";
12
13
 
13
14
  interface ProtocolWallet {
14
15
  signTransaction?: (transaction: Transaction) => Promise<{ signedTxXdr: string }>;
@@ -149,20 +150,6 @@ class StellarWallet extends OmniWallet {
149
150
  return this.sendTransaction(tx);
150
151
  }
151
152
 
152
- async signIntentsWithAuth(domain: string, intents?: Record<string, any>[]) {
153
- const seed = hex.encode(window.crypto.getRandomValues(new Uint8Array(32)));
154
- const msgBuffer = new TextEncoder().encode(`${domain}_${seed}`);
155
- const nonce = await window.crypto.subtle.digest("SHA-256", new Uint8Array(msgBuffer));
156
-
157
- return {
158
- signed: await this.signIntents(intents || [], { nonce: new Uint8Array(nonce) }),
159
- publicKey: `ed25519:${this.publicKey}`,
160
- chainId: WalletType.STELLAR,
161
- address: this.address,
162
- seed,
163
- };
164
- }
165
-
166
153
  async sendTransaction(transaction: Transaction) {
167
154
  if (!this.wallet.signTransaction) throw "not impl";
168
155
  const result = await this.wallet.signTransaction(transaction);
@@ -176,7 +163,7 @@ class StellarWallet extends OmniWallet {
176
163
  return await this.wallet.signMessage(message);
177
164
  }
178
165
 
179
- async signIntents(intents: Record<string, any>[], options?: { deadline?: number; nonce?: Uint8Array }): Promise<Record<string, any>> {
166
+ async signIntents(intents: Record<string, any>[], options?: { deadline?: number; nonce?: Uint8Array }): Promise<Commitment> {
180
167
  const nonce = new Uint8Array(options?.nonce || window.crypto.getRandomValues(new Uint8Array(32)));
181
168
 
182
169
  const message = JSON.stringify({
@@ -14,28 +14,19 @@ export interface TonConnectorOptions {
14
14
  }
15
15
 
16
16
  const hotWallet = {
17
- app_name: "hot",
18
17
  name: "HOT",
18
+ app_name: "hot",
19
19
  image: "https://raw.githubusercontent.com/hot-dao/media/main/logo.png",
20
20
  about_url: "https://hot-labs.org/",
21
21
  universal_url: "https://t.me/herewalletbot?attach=wallet",
22
22
  bridge: [
23
- {
24
- type: "sse",
25
- url: "https://sse-bridge.hot-labs.org",
26
- },
27
- {
28
- type: "js",
29
- key: "hotWallet",
30
- },
23
+ { type: "sse", url: "https://sse-bridge.hot-labs.org" },
24
+ { type: "js", key: "hotWallet" },
31
25
  ],
32
26
  platforms: ["ios", "android", "chrome", "firefox", "macos", "windows", "linux"],
33
27
  features: [
34
- {
35
- name: "SendTransaction",
36
- maxMessages: 4,
37
- extraCurrencySupported: false,
38
- },
28
+ { name: "SendTransaction", maxMessages: 4, extraCurrencySupported: false },
29
+ { name: "SignData", types: ["text", "binary", "cell"] },
39
30
  ],
40
31
  };
41
32
 
@@ -69,6 +60,7 @@ class TonConnector extends OmniConnector<TonWallet> {
69
60
  connector: new TonConnect({
70
61
  walletsListSource: url,
71
62
  manifestUrl: this.args?.tonManifestUrl,
63
+ walletsRequiredFeatures: { signData: { types: ["text"] } },
72
64
  }),
73
65
  });
74
66
 
package/src/ton/wallet.ts CHANGED
@@ -136,23 +136,6 @@ class TonWallet extends OmniWallet {
136
136
  return tx;
137
137
  }
138
138
 
139
- async signIntentsWithAuth(domain: string, intents?: Record<string, unknown>[]) {
140
- const address = this.wallet.account?.address;
141
- if (!address) throw new Error("Wallet not connected");
142
-
143
- const seed = hex.encode(window.crypto.getRandomValues(new Uint8Array(32)));
144
- const msgBuffer = new TextEncoder().encode(`${domain}_${seed}`);
145
- const nonce = await window.crypto.subtle.digest("SHA-256", new Uint8Array(msgBuffer));
146
-
147
- return {
148
- signed: await this.signIntents(intents || [], { nonce: new Uint8Array(nonce) }),
149
- publicKey: `ed25519:${this.publicKey}`,
150
- chainId: WalletType.TON,
151
- address: address,
152
- seed,
153
- };
154
- }
155
-
156
139
  async signIntents(intents: Record<string, unknown>[], options?: { deadline?: number; nonce?: Uint8Array }) {
157
140
  if (!this.wallet.signData) throw "Not impl";
158
141
  const nonce = new Uint8Array(options?.nonce || window.crypto.getRandomValues(new Uint8Array(32)));
@@ -74,6 +74,11 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
74
74
  return hot.wallets.find((w) => w.type === from.type);
75
75
  });
76
76
 
77
+ useEffect(() => {
78
+ if (from.type === WalletType.OMNI) setSender(hot.priorityWallet);
79
+ if (to.type === WalletType.OMNI) setRecipient(Recipient.fromWallet(hot.priorityWallet!));
80
+ }, [hot.priorityWallet]);
81
+
77
82
  const [recipient, setRecipient] = useState<Recipient | undefined>(() => {
78
83
  if (setup?.recipient) return setup.recipient;
79
84
  if (to.type === WalletType.OMNI) return Recipient.fromWallet(hot.priorityWallet!);
@@ -267,7 +272,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
267
272
  <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
268
273
  <p style={{ fontWeight: "bold" }}>{from.chain === -4 ? "Withdraw HEX from:" : "Send from:"}</p>
269
274
  <BadgeButton onClick={() => openSelectSender({ hot, type: from.type, onSelect: (wallet) => setSender(wallet) })}>
270
- <p>{formatter.truncateAddress(sender === "qr" ? "QR code" : sender?.address ?? "Connect wallet")}</p>
275
+ <p>{formatter.truncateAddress(sender === "qr" ? "QR code" : sender?.address ?? "Select sender")}</p>
271
276
  </BadgeButton>
272
277
  </div>
273
278
  </div>