@hot-labs/kit 1.0.41 → 1.0.44

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 (111) hide show
  1. package/README.md +14 -9
  2. package/build/HotConnector.d.ts +26 -15
  3. package/build/HotConnector.js +36 -14
  4. package/build/HotConnector.js.map +1 -1
  5. package/build/OmniConnector.d.ts +1 -1
  6. package/build/OmniWallet.d.ts +1 -1
  7. package/build/core/Intents.d.ts +3 -1
  8. package/build/core/Intents.js +4 -1
  9. package/build/core/Intents.js.map +1 -1
  10. package/build/core/bridge.d.ts +2 -2
  11. package/build/core/bridge.js +32 -31
  12. package/build/core/bridge.js.map +1 -1
  13. package/build/core/{config.d.ts → chains.d.ts} +21 -5
  14. package/build/core/chains.js +381 -0
  15. package/build/core/chains.js.map +1 -0
  16. package/build/core/index.d.ts +7 -6
  17. package/build/core/index.js +7 -6
  18. package/build/core/index.js.map +1 -1
  19. package/build/core/recipient.d.ts +1 -1
  20. package/build/core/recipient.js +1 -1
  21. package/build/core/token.d.ts +2 -2
  22. package/build/core/token.js +10 -47
  23. package/build/core/token.js.map +1 -1
  24. package/build/core/tokens.d.ts +1 -1
  25. package/build/core/tokens.js +8 -6
  26. package/build/core/tokens.js.map +1 -1
  27. package/build/core/types.d.ts +1 -0
  28. package/build/cosmos/connector.d.ts +4 -23
  29. package/build/cosmos/connector.js +33 -22
  30. package/build/cosmos/connector.js.map +1 -1
  31. package/build/cosmos/index.d.ts +2 -3
  32. package/build/cosmos/index.js +1 -1
  33. package/build/cosmos/index.js.map +1 -1
  34. package/build/cosmos/wallet.d.ts +1 -1
  35. package/build/cosmos/wallet.js +2 -2
  36. package/build/cosmos/wallet.js.map +1 -1
  37. package/build/evm/connector.d.ts +1 -1
  38. package/build/evm/connector.js +1 -1
  39. package/build/evm/wallet.d.ts +1 -1
  40. package/build/evm/wallet.js +1 -1
  41. package/build/exchange.d.ts +2 -2
  42. package/build/exchange.js +18 -21
  43. package/build/exchange.js.map +1 -1
  44. package/build/hot-wallet/google.d.ts +1 -1
  45. package/build/hot-wallet/google.js +1 -1
  46. package/build/near/connector.d.ts +1 -1
  47. package/build/near/connector.js +1 -1
  48. package/build/near/wallet.d.ts +1 -1
  49. package/build/near/wallet.js +1 -1
  50. package/build/solana/connector.d.ts +1 -1
  51. package/build/solana/connector.js +1 -1
  52. package/build/solana/wallet.d.ts +1 -1
  53. package/build/solana/wallet.js +1 -1
  54. package/build/stellar/connector.d.ts +1 -1
  55. package/build/stellar/connector.js +1 -1
  56. package/build/stellar/wallet.d.ts +3 -2
  57. package/build/stellar/wallet.js +16 -13
  58. package/build/stellar/wallet.js.map +1 -1
  59. package/build/ton/connector.d.ts +1 -1
  60. package/build/ton/connector.js +1 -1
  61. package/build/ton/wallet.d.ts +1 -1
  62. package/build/ton/wallet.js +1 -1
  63. package/build/ui/payment/Bridge.js +1 -1
  64. package/build/ui/payment/Payment.js +1 -1
  65. package/build/ui/payment/SelectRecipient.d.ts +1 -1
  66. package/build/ui/payment/SelectRecipient.js +1 -1
  67. package/build/ui/payment/SelectSender.d.ts +1 -1
  68. package/build/ui/payment/SelectSender.js +1 -1
  69. package/build/ui/payment/SelectToken.js +1 -1
  70. package/build/ui/payment/TokenCard.js +16 -3
  71. package/build/ui/payment/TokenCard.js.map +1 -1
  72. package/build/ui/router.d.ts +1 -1
  73. package/package.json +1 -1
  74. package/skill.md +174 -72
  75. package/src/HotConnector.ts +68 -38
  76. package/src/OmniConnector.ts +1 -1
  77. package/src/OmniWallet.ts +1 -1
  78. package/src/core/Intents.ts +6 -3
  79. package/src/core/bridge.ts +33 -33
  80. package/src/core/chains.ts +400 -0
  81. package/src/core/index.ts +7 -6
  82. package/src/core/recipient.ts +1 -1
  83. package/src/core/token.ts +11 -28
  84. package/src/core/tokens.ts +8 -6
  85. package/src/core/types.ts +1 -0
  86. package/src/cosmos/connector.ts +33 -27
  87. package/src/cosmos/index.ts +2 -3
  88. package/src/cosmos/wallet.ts +2 -2
  89. package/src/evm/connector.ts +1 -1
  90. package/src/evm/wallet.ts +1 -1
  91. package/src/exchange.ts +22 -25
  92. package/src/hot-wallet/google.ts +1 -1
  93. package/src/near/connector.ts +1 -1
  94. package/src/near/wallet.ts +1 -1
  95. package/src/solana/connector.ts +1 -1
  96. package/src/solana/wallet.ts +1 -1
  97. package/src/stellar/connector.ts +1 -1
  98. package/src/stellar/wallet.ts +17 -13
  99. package/src/ton/connector.ts +1 -1
  100. package/src/ton/wallet.ts +1 -1
  101. package/src/ui/payment/Bridge.tsx +1 -1
  102. package/src/ui/payment/Payment.tsx +1 -1
  103. package/src/ui/payment/Profile.tsx +1 -1
  104. package/src/ui/payment/SelectRecipient.tsx +1 -1
  105. package/src/ui/payment/SelectSender.tsx +1 -1
  106. package/src/ui/payment/SelectToken.tsx +1 -1
  107. package/src/ui/payment/TokenCard.tsx +21 -6
  108. package/src/ui/router.tsx +1 -1
  109. package/build/core/config.js +0 -130
  110. package/build/core/config.js.map +0 -1
  111. package/src/core/config.ts +0 -134
@@ -1,9 +1,10 @@
1
- import type { Keplr } from "@keplr-wallet/provider-extension";
1
+ import { Keplr } from "@keplr-wallet/provider-extension";
2
2
  import { TxRaw } from "@keplr-wallet/proto-types/cosmos/tx/v1beta1/tx";
3
3
  import { StargateClient } from "@cosmjs/stargate";
4
+ import { runInAction } from "mobx";
4
5
  import { hex } from "@scure/base";
5
6
 
6
- import { WalletType } from "../core/config";
7
+ import { chains, WalletType } from "../core/chains";
7
8
  import { HotConnector } from "../HotConnector";
8
9
  import { ConnectorType, OmniConnector, WC_ICON } from "../OmniConnector";
9
10
  import { OmniWallet } from "../OmniWallet";
@@ -11,10 +12,6 @@ import { OmniWallet } from "../OmniWallet";
11
12
  import { signAndSendTx } from "./helpers";
12
13
  import CosmosWallet from "./wallet";
13
14
 
14
- export interface CosmosConnectorOptions {
15
- cosmosChains?: Record<string, { chain: string; rpc: string; denom: string; prefix: string }>;
16
- }
17
-
18
15
  declare global {
19
16
  interface Window {
20
17
  keplr?: Keplr;
@@ -42,8 +39,6 @@ const wallets = {
42
39
  };
43
40
 
44
41
  export default class CosmosConnector extends OmniConnector<CosmosWallet> {
45
- cosmosChains: Record<string, { chain: string; rpc: string; denom: string; prefix: string }>;
46
-
47
42
  type = ConnectorType.WALLET;
48
43
  walletTypes = [WalletType.COSMOS];
49
44
  icon = "https://legacy.cosmos.network/presskit/cosmos-brandmark-dynamic-dark.svg";
@@ -51,12 +46,12 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
51
46
  isSupported = true;
52
47
  id = "cosmos";
53
48
 
54
- constructor(wibe3: HotConnector, options?: CosmosConnectorOptions) {
49
+ constructor(wibe3: HotConnector) {
55
50
  super(wibe3);
56
51
 
57
52
  this.options = [
58
53
  {
59
- name: "keplr" in window ? "Keplr" : "Keplr Mobile",
54
+ name: "Keplr",
60
55
  download: "https://www.keplr.app/get",
61
56
  icon: "https://cdn.prod.website-files.com/667dc891bc7b863b5397495b/68a4ca95f93a9ab64dc67ab4_keplr-symbol.svg",
62
57
  type: "keplr" in window ? "extension" : "external",
@@ -71,16 +66,23 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
71
66
  },
72
67
  ];
73
68
 
74
- this.cosmosChains = {
75
- "juno-1": { chain: "juno-1", rpc: "https://juno-rpc.publicnode.com", denom: "ujuno", prefix: "juno" },
76
- "gonka-mainnet": { chain: "gonka-mainnet", rpc: "https://dev.herewallet.app/api/v1/evm/rpc/4444119", denom: "ngonka", prefix: "gonka" },
77
- "cosmoshub-4": { chain: "cosmoshub-4", rpc: "https://rpc.cosmoshub.certus.one", denom: "uatom", prefix: "cosmos" },
78
- ...options?.cosmosChains,
79
- };
69
+ Keplr.getKeplr().then((keplr) => {
70
+ const option = this.options.find((option) => option.id === "keplr")!;
71
+ runInAction(() => {
72
+ option.type = keplr ? "extension" : "external";
73
+ option.name = keplr ? "Keplr" : "Keplr Mobile";
74
+ });
75
+ });
80
76
 
81
- this.getStorage().then(({ type, address, publicKey }) => {
77
+ this.getStorage().then(async ({ type, address, publicKey }) => {
82
78
  if (!address || !publicKey) return;
83
- if (type === "keplr" && window.keplr) this.setKeplrWallet(window.keplr, address, publicKey);
79
+
80
+ if (type === "keplr") {
81
+ const keplr = await Keplr.getKeplr();
82
+ if (keplr) this.setKeplrWallet(keplr, address, publicKey);
83
+ else this.disconnect();
84
+ }
85
+
84
86
  if (type === "leap" && window.leap) this.setKeplrWallet(window.leap, address, publicKey);
85
87
  });
86
88
 
@@ -101,8 +103,8 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
101
103
  .catch(() => {});
102
104
  }
103
105
 
104
- getConfig(chain: string) {
105
- return this.cosmosChains[chain];
106
+ get chains() {
107
+ return chains.getByType(WalletType.COSMOS).map((t) => t.key);
106
108
  }
107
109
 
108
110
  async setupWalletConnect(id?: "keplr" | "leap"): Promise<CosmosWallet> {
@@ -141,7 +143,10 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
141
143
  },
142
144
  });
143
145
 
144
- const client = await StargateClient.connect(this.getConfig(signDoc.chainId)?.rpc || "");
146
+ const chain = chains.getByKey(signDoc.chainId);
147
+ if (!chain) throw new Error("Chain not found");
148
+
149
+ const client = await StargateClient.connect(chain.rpc);
145
150
  const protobufTx = TxRaw.encode({
146
151
  bodyBytes: signed.bodyBytes,
147
152
  authInfoBytes: signed.authInfoBytes,
@@ -164,8 +169,8 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
164
169
  publicKeyHex: publicKey,
165
170
  disconnect: () => keplr.disable(),
166
171
  sendTransaction: async (signDoc: any) => {
167
- await keplr.enable(Object.keys(this.cosmosChains));
168
- const rpcEndpoint = this.getConfig(signDoc.chainId)?.rpc || "";
172
+ await keplr.enable(this.chains);
173
+ const rpcEndpoint = chains.get(signDoc.chainId)?.rpc || "";
169
174
  return await signAndSendTx(keplr, rpcEndpoint, signDoc);
170
175
  },
171
176
  })
@@ -181,7 +186,7 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
181
186
  cosmos: {
182
187
  methods: ["cosmos_getAccounts", "cosmos_signDirect"],
183
188
  events: ["chainChanged", "accountsChanged"],
184
- chains: Object.keys(this.cosmosChains).map((chain) => `cosmos:${chain}`),
189
+ chains: this.chains.map((chain) => `cosmos:${chain}`),
185
190
  rpcMap: {},
186
191
  },
187
192
  },
@@ -200,7 +205,7 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
200
205
  chainName: "Gonka",
201
206
  });
202
207
 
203
- await extension.enable(Object.keys(this.cosmosChains));
208
+ await extension.enable(this.chains);
204
209
  const account = await extension.getKey("gonka-mainnet");
205
210
  await this.setStorage({ type, address: account.bech32Address, publicKey: hex.encode(account.pubKey) });
206
211
  return await this.setKeplrWallet(extension, account.bech32Address, hex.encode(account.pubKey));
@@ -214,7 +219,7 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
214
219
  cosmos: {
215
220
  methods: ["cosmos_getAccounts", "cosmos_signDirect"],
216
221
  events: ["chainChanged", "accountsChanged"],
217
- chains: Object.keys(this.cosmosChains).map((chain) => `cosmos:${chain}`),
222
+ chains: this.chains.map((chain) => `cosmos:${chain}`),
218
223
  rpcMap: {},
219
224
  },
220
225
  },
@@ -222,7 +227,8 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
222
227
  }
223
228
 
224
229
  if (id === "keplr") {
225
- return await this.connectKeplr("keplr", window.keplr);
230
+ const keplr = await Keplr.getKeplr();
231
+ return await this.connectKeplr("keplr", keplr);
226
232
  }
227
233
 
228
234
  if (id === "leap") {
@@ -1,9 +1,8 @@
1
- import type { CosmosConnectorOptions } from "./connector";
2
1
  import CosmosConnector from "./connector";
3
2
  import CosmosWallet from "./wallet";
4
3
 
5
4
  import { HotConnector } from "../HotConnector";
6
5
 
7
- export { CosmosConnector, CosmosConnectorOptions, CosmosWallet };
6
+ export { CosmosConnector, CosmosWallet };
8
7
 
9
- export default (options?: CosmosConnectorOptions) => async (wibe3: HotConnector) => new CosmosConnector(wibe3, options);
8
+ export default () => async (wibe3: HotConnector) => new CosmosConnector(wibe3);
@@ -1,7 +1,7 @@
1
1
  import { StargateClient } from "@cosmjs/stargate";
2
2
 
3
3
  import { OmniWallet, SignedAuth } from "../OmniWallet";
4
- import { chainsMap, WalletType } from "../core/config";
4
+ import { chains, WalletType } from "../core/chains";
5
5
  import { ReviewFee } from "../core/bridge";
6
6
  import CosmosConnector from "./connector";
7
7
 
@@ -68,7 +68,7 @@ export default class CosmosWallet extends OmniWallet {
68
68
  }
69
69
 
70
70
  async fetchBalance(chain: number, token: string): Promise<bigint> {
71
- const config = this.connector.getConfig(chainsMap[chain].id);
71
+ const config = chains.get(chain);
72
72
  if (!config) throw new Error("Config not found");
73
73
  const client = await StargateClient.connect(config.rpc);
74
74
  const balance = await client.getBalance(this.address, token);
@@ -2,7 +2,7 @@ import MetaMaskSDK from "@metamask/sdk";
2
2
  import { runInAction } from "mobx";
3
3
 
4
4
  import { ConnectorType, OmniConnector, WC_ICON } from "../OmniConnector";
5
- import { Network, WalletType } from "../core/config";
5
+ import { Network, WalletType } from "../core/chains";
6
6
  import { isInjected } from "../hot-wallet/iframe";
7
7
  import { HotConnector } from "../HotConnector";
8
8
  import EvmWallet, { EvmProvider } from "./wallet";
package/src/evm/wallet.ts CHANGED
@@ -4,7 +4,7 @@ import { JsonRpcSigner } from "ethers";
4
4
 
5
5
  import { OmniConnector } from "../OmniConnector";
6
6
  import { OmniWallet } from "../OmniWallet";
7
- import { WalletType } from "../core/config";
7
+ import { WalletType } from "../core/chains";
8
8
  import { ReviewFee } from "../core/bridge";
9
9
  import { Token } from "../core/token";
10
10
  import { erc20abi } from "./abi";
package/src/exchange.ts CHANGED
@@ -2,19 +2,16 @@ import { GetExecutionStatusResponse, OneClickService, ApiError, OpenAPI, QuoteRe
2
2
  import { utils } from "@hot-labs/omni-sdk";
3
3
  import { hex } from "@scure/base";
4
4
 
5
- import CosmosWallet from "./cosmos/wallet";
6
- import StellarWallet from "./stellar/wallet";
7
- import NearWallet from "./near/wallet";
8
- import EvmWallet from "./evm/wallet";
9
-
10
- import { HotConnector } from "./HotConnector";
11
- import { Network, OmniToken, WalletType } from "./core/config";
12
- import { bridge, ReviewFee } from "./core/bridge";
5
+ import { Network, OmniToken, WalletType } from "./core/chains";
6
+ import { ReviewFee } from "./core/bridge";
13
7
  import { Recipient } from "./core/recipient";
14
- import { OmniWallet } from "./OmniWallet";
15
8
  import { tokens } from "./core/tokens";
16
9
  import { Token } from "./core/token";
17
10
 
11
+ import StellarWallet from "./stellar/wallet";
12
+ import { HotConnector } from "./HotConnector";
13
+ import { OmniWallet } from "./OmniWallet";
14
+
18
15
  OpenAPI.BASE = "https://1click.chaindefuser.com";
19
16
  OpenAPI.TOKEN = "";
20
17
 
@@ -78,11 +75,11 @@ export class Exchange {
78
75
  const { sender, token, amount, recipient, onMessage } = args;
79
76
  onMessage("Sending deposit transaction");
80
77
 
81
- if (token.type === WalletType.COSMOS && sender instanceof CosmosWallet) {
82
- const cosmosBridge = await bridge.cosmos();
78
+ if (token.type === WalletType.COSMOS && this.wibe3.isCosmosWallet(sender)) {
79
+ const cosmosBridge = await this.wibe3.hotBridge.cosmos();
83
80
  const hash = await cosmosBridge.deposit({
84
81
  sendTransaction: async (tx) => sender.sendTransaction(tx),
85
- senderPublicKey: hex.decode(sender.publicKey),
82
+ senderPublicKey: hex.decode(sender.publicKey!),
86
83
  intentAccount: recipient.omniAddress,
87
84
  sender: sender.address,
88
85
  token: token.address,
@@ -91,15 +88,15 @@ export class Exchange {
91
88
  });
92
89
 
93
90
  onMessage("Waiting for deposit");
94
- const deposit = await bridge.waitPendingDeposit(token.chain, hash, recipient.omniAddress);
91
+ const deposit = await this.wibe3.hotBridge.waitPendingDeposit(token.chain, hash, recipient.omniAddress);
95
92
  onMessage("Finishing deposit");
96
- await bridge.finishDeposit(deposit);
93
+ await this.wibe3.hotBridge.finishDeposit(deposit);
97
94
  onMessage("Deposit finished");
98
95
  return;
99
96
  }
100
97
 
101
- if (token.type === WalletType.EVM && sender instanceof EvmWallet) {
102
- const hash = await bridge.evm.deposit({
98
+ if (token.type === WalletType.EVM && this.wibe3.isEvmWallet(sender)) {
99
+ const hash = await this.wibe3.hotBridge.evm.deposit({
103
100
  sendTransaction: async (tx) => sender.sendTransaction(token.chain, tx),
104
101
  intentAccount: recipient.omniAddress,
105
102
  sender: sender.address,
@@ -110,15 +107,15 @@ export class Exchange {
110
107
 
111
108
  if (!hash) throw new Error("Failed to deposit");
112
109
  onMessage("Waiting for deposit");
113
- const deposit = await bridge.waitPendingDeposit(token.chain, hash, recipient.omniAddress);
110
+ const deposit = await this.wibe3.hotBridge.waitPendingDeposit(token.chain, hash, recipient.omniAddress);
114
111
  onMessage("Finishing deposit");
115
- await bridge.finishDeposit(deposit);
112
+ await this.wibe3.hotBridge.finishDeposit(deposit);
116
113
  onMessage("Deposit finished");
117
114
  return;
118
115
  }
119
116
 
120
- if (token.type === WalletType.NEAR && sender instanceof NearWallet) {
121
- return await bridge.near.deposit({
117
+ if (token.type === WalletType.NEAR && this.wibe3.isNearWallet(sender)) {
118
+ return await this.wibe3.hotBridge.near.deposit({
122
119
  sendTransaction: async (tx: any) => sender.sendTransaction(tx),
123
120
  intentAccount: recipient.omniAddress,
124
121
  sender: sender.address,
@@ -134,11 +131,11 @@ export class Exchange {
134
131
  const { sender, token, amount, recipient } = args;
135
132
 
136
133
  const receipientWallet = this.wibe3.wallets.find((w) => w.address === recipient.address);
137
- if (receipientWallet instanceof NearWallet && token.type === WalletType.NEAR) {
134
+ if (this.wibe3.isNearWallet(receipientWallet) && token.type === WalletType.NEAR) {
138
135
  await receipientWallet.registerToken(token.originalAddress);
139
136
  }
140
137
 
141
- await bridge.withdrawToken({
138
+ await this.wibe3.hotBridge.withdrawToken({
142
139
  signIntents: async (intents) => sender.signIntents(intents),
143
140
  intentAccount: sender.omniAddress,
144
141
  receiver: recipient.address,
@@ -152,7 +149,7 @@ export class Exchange {
152
149
  async withdrawFee(request: BridgeRequest) {
153
150
  if (request.sender === "qr") throw new Error("Sender is QR");
154
151
  if (request.to.chain === Network.Near || request.to.chain === Network.Hot) return 0n;
155
- const gaslessFee = await bridge.getGaslessWithdrawFee({
152
+ const gaslessFee = await this.wibe3.hotBridge.getGaslessWithdrawFee({
156
153
  receiver: request.recipient.address,
157
154
  token: request.to.address,
158
155
  chain: request.to.chain,
@@ -162,7 +159,7 @@ export class Exchange {
162
159
  if (request.to.address === "native") return 0n;
163
160
 
164
161
  // if withdraw token is not native, we need to swap a bit of it to native to cover the withdraw fee
165
- const swap = await bridge.buildSwapExectOutIntent({
162
+ const swap = await this.wibe3.hotBridge.buildSwapExectOutIntent({
166
163
  intentFrom: utils.toOmniIntent(request.to.chain, request.to.address),
167
164
  intentTo: utils.toOmniIntent(request.to.chain, "native"),
168
165
  amountOut: gaslessFee.gasPrice,
@@ -186,7 +183,7 @@ export class Exchange {
186
183
  const noFee = from.symbol === to.symbol;
187
184
 
188
185
  if (sender !== "qr" && directChains.includes(from.chain) && to.chain === Network.Hot && from.omniAddress === to.omniAddress) {
189
- const fee = await bridge.getDepositFee({
186
+ const fee = await this.wibe3.hotBridge.getDepositFee({
190
187
  intentAccount: sender.omniAddress,
191
188
  sender: sender.address,
192
189
  token: from.address,
@@ -5,7 +5,7 @@ import uuid4 from "uuid4";
5
5
 
6
6
  import { ConnectorType, OmniConnector } from "../OmniConnector";
7
7
  import { OmniWallet } from "../OmniWallet";
8
- import { WalletType } from "../core/config";
8
+ import { WalletType } from "../core/chains";
9
9
 
10
10
  import EvmWallet from "../evm/wallet";
11
11
  import NearWallet from "../near/wallet";
@@ -1,7 +1,7 @@
1
1
  import { NearConnector } from "@hot-labs/near-connect";
2
2
  import { runInAction } from "mobx";
3
3
 
4
- import { WalletType } from "../core/config";
4
+ import { WalletType } from "../core/chains";
5
5
  import { ConnectorType, OmniConnector } from "../OmniConnector";
6
6
  import { HotConnector } from "../HotConnector";
7
7
  import NearWallet from "./wallet";
@@ -4,7 +4,7 @@ import { Action } from "@near-js/transactions";
4
4
 
5
5
  import { OmniConnector } from "../OmniConnector";
6
6
  import { OmniWallet } from "../OmniWallet";
7
- import { WalletType } from "../core/config";
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";
@@ -7,7 +7,7 @@ import { ConnectorType, OmniConnector, WC_ICON } from "../OmniConnector";
7
7
  import { HotConnector } from "../HotConnector";
8
8
  import { OmniWallet } from "../OmniWallet";
9
9
  import { isInjected } from "../hot-wallet/iframe";
10
- import { WalletType } from "../core/config";
10
+ import { WalletType } from "../core/chains";
11
11
 
12
12
  import SolanaProtocolWallet from "./protocol";
13
13
  import { getWallets } from "./wallets";
@@ -13,7 +13,7 @@ import {
13
13
  createTransferCheckedInstruction,
14
14
  } from "@solana/spl-token";
15
15
 
16
- import { Network, WalletType } from "../core/config";
16
+ import { Network, WalletType } from "../core/chains";
17
17
  import { OmniConnector } from "../OmniConnector";
18
18
  import { OmniWallet } from "../OmniWallet";
19
19
 
@@ -1,7 +1,7 @@
1
1
  import { sep43Modules, HotWalletModule, StellarWalletsKit, WalletNetwork, ISupportedWallet } from "@creit.tech/stellar-wallets-kit";
2
2
  import { Transaction } from "@stellar/stellar-base";
3
3
 
4
- import { WalletType } from "../core/config";
4
+ import { WalletType } from "../core/chains";
5
5
  import { HotConnector } from "../HotConnector";
6
6
  import { ConnectorType, OmniConnector } from "../OmniConnector";
7
7
  import { isInjected } from "../hot-wallet/iframe";
@@ -2,12 +2,12 @@ import { base64, base58, hex, base32 } from "@scure/base";
2
2
  import { Address, Asset, BASE_FEE, Claimant, Contract, Memo, nativeToScVal, Networks, Operation, TimeoutInfinite, Transaction, TransactionBuilder, xdr } from "@stellar/stellar-base";
3
3
  import { rpc } from "@stellar/stellar-sdk";
4
4
 
5
- import { WalletType } from "../core/config";
5
+ import { WalletType } from "../core/chains";
6
6
  import { OmniWallet } from "../OmniWallet";
7
7
  import { OmniConnector } from "../OmniConnector";
8
- import { bridge, ReviewFee } from "../core/bridge";
8
+ import { ReviewFee } from "../core/bridge";
9
9
  import { formatter } from "../core/utils";
10
- import { Network } from "../core/config";
10
+ import { Network } from "../core/chains";
11
11
  import { Token } from "../core/token";
12
12
 
13
13
  interface ProtocolWallet {
@@ -33,6 +33,10 @@ class StellarWallet extends OmniWallet {
33
33
  super(connector);
34
34
  }
35
35
 
36
+ get rpc() {
37
+ return this.connector.wibe3.hotBridge.stellar;
38
+ }
39
+
36
40
  get address() {
37
41
  return this.wallet.address;
38
42
  }
@@ -81,8 +85,8 @@ class StellarWallet extends OmniWallet {
81
85
  const asset = await this.getAssetFromContractId(token);
82
86
  const sendAmount = formatter.formatAmount(amount, 7);
83
87
 
84
- const account = await bridge.stellar.callSoroban((s) => s.getAccount(this.address));
85
- const baseFee = await bridge.stellar.callHorizon((h) => h.fetchBaseFee()).catch(() => +BASE_FEE);
88
+ const account = await this.connector.wibe3.hotBridge.stellar.callSoroban((s) => s.getAccount(this.address));
89
+ const baseFee = await this.connector.wibe3.hotBridge.stellar.callHorizon((h) => h.fetchBaseFee()).catch(() => +BASE_FEE);
86
90
  const builder = new TransactionBuilder(account, {
87
91
  memo: memo ? Memo.text(memo) : undefined,
88
92
  networkPassphrase: Networks.PUBLIC,
@@ -101,13 +105,13 @@ class StellarWallet extends OmniWallet {
101
105
  )
102
106
  );
103
107
 
104
- const tx = await bridge.stellar.callSoroban((s) => s.prepareTransaction(builder.build() as any));
108
+ const tx = await this.rpc.callSoroban((s) => s.prepareTransaction(builder.build() as any));
105
109
  const fee = BigInt(Math.floor(baseFee * tx.operations.length));
106
110
  return { fee: new ReviewFee({ baseFee: fee, priorityFee: 0n, gasLimit: 1n, chain: Network.Stellar }), tx: tx as unknown as Transaction };
107
111
  }
108
112
 
109
113
  let needXlm = 0;
110
- const receiverAccount = await bridge.stellar.callHorizon((h) => h.loadAccount(receiver)).catch(() => null);
114
+ const receiverAccount = await this.rpc.callHorizon((h) => h.loadAccount(receiver)).catch(() => null);
111
115
  const claimableBalance = Operation.createClaimableBalance({ amount: amount.toString(), claimants: [new Claimant(receiver)], asset });
112
116
 
113
117
  if (receiverAccount == null) {
@@ -163,7 +167,7 @@ class StellarWallet extends OmniWallet {
163
167
  if (!this.wallet.signTransaction) throw "not impl";
164
168
  const result = await this.wallet.signTransaction(transaction);
165
169
  const txObject = new Transaction(result.signedTxXdr, Networks.PUBLIC);
166
- const { hash } = await bridge.stellar.callHorizon((t) => t.submitTransaction(txObject as any));
170
+ const { hash } = await this.rpc.callHorizon((t) => t.submitTransaction(txObject as any));
167
171
  return hash;
168
172
  }
169
173
 
@@ -195,7 +199,7 @@ class StellarWallet extends OmniWallet {
195
199
 
196
200
  static async isTokenActivated(address: string, token: string) {
197
201
  if (address === "native") return true;
198
- const data = await bridge.stellar.callHorizon((h) => h.loadAccount(address));
202
+ const data = await fetch(`https://horizon.stellar.org/accounts/${address}`).then((res) => res.json());
199
203
  return data.balances.some((ft: any) => {
200
204
  if (!ft.asset_issuer) return false;
201
205
  const asset = new Asset(ft.asset_code, ft.asset_issuer).contractId(Networks.PUBLIC);
@@ -206,7 +210,7 @@ class StellarWallet extends OmniWallet {
206
210
  async changeTrustline(address: string) {
207
211
  if (address === "native") return;
208
212
  const asset = await this.getAssetFromContractId(address);
209
- const account = await bridge.stellar.callHorizon((h) => h.loadAccount(this.address));
213
+ const account = await this.rpc.callHorizon((h) => h.loadAccount(this.address));
210
214
  const trustlineOp = Operation.changeTrust({ asset: asset, source: this.address });
211
215
  const trustlineTx = new TransactionBuilder(account, { fee: BASE_FEE, networkPassphrase: Networks.PUBLIC }) //
212
216
  .addOperation(trustlineOp)
@@ -224,7 +228,7 @@ class StellarWallet extends OmniWallet {
224
228
  }
225
229
 
226
230
  const tx = await this.buildSmartContactTx(ACCOUNT_FOR_SIMULATE, id, ASSET_CONTRACT_METHOD.NAME);
227
- const result = (await bridge.stellar.callSoroban((s) => s.simulateTransaction(tx as any))) as unknown as rpc.Api.SimulateTransactionSuccessResponse;
231
+ const result = (await this.rpc.callSoroban((s) => s.simulateTransaction(tx as any))) as unknown as rpc.Api.SimulateTransactionSuccessResponse;
228
232
 
229
233
  const value = result?.result?.retval?.value();
230
234
  if (!value) throw "Asset not found";
@@ -236,7 +240,7 @@ class StellarWallet extends OmniWallet {
236
240
  }
237
241
 
238
242
  async buildSmartContactTx(publicKey: string, contactId: string, method: string, ...args: any[]) {
239
- const account = await bridge.stellar.callSoroban((s) => s.getAccount(publicKey));
243
+ const account = await this.rpc.callSoroban((s) => s.getAccount(publicKey));
240
244
  const contract = new Contract(contactId);
241
245
  const builtTx = new TransactionBuilder(account, { fee: BASE_FEE, networkPassphrase: Networks.PUBLIC });
242
246
 
@@ -253,7 +257,7 @@ class StellarWallet extends OmniWallet {
253
257
  Address.fromString(contract).toScVal()
254
258
  );
255
259
 
256
- const result = (await bridge.stellar.callSoroban((s) => s.simulateTransaction(tx as any))) as unknown as rpc.Api.SimulateTransactionSuccessResponse;
260
+ const result = (await this.rpc.callSoroban((s) => s.simulateTransaction(tx as any))) as unknown as rpc.Api.SimulateTransactionSuccessResponse;
257
261
  if (result) return BigInt(this.i128ToInt(result.result?.retval.value() as xdr.Int128Parts));
258
262
  return 0n;
259
263
  }
@@ -1,7 +1,7 @@
1
1
  import { TonConnectUI, TonConnect } from "@tonconnect/ui";
2
2
  import { runInAction } from "mobx";
3
3
 
4
- import { WalletType } from "../core/config";
4
+ import { WalletType } from "../core/chains";
5
5
  import { HotConnector } from "../HotConnector";
6
6
  import { ConnectorType, OmniConnector } from "../OmniConnector";
7
7
  import { isInjected } from "../hot-wallet/iframe";
package/src/ton/wallet.ts CHANGED
@@ -5,7 +5,7 @@ import { toUserFriendlyAddress } from "@tonconnect/ui";
5
5
  import { base58, base64, hex } from "@scure/base";
6
6
 
7
7
  import { OmniWallet } from "../OmniWallet";
8
- import { WalletType } from "../core/config";
8
+ import { WalletType } from "../core/chains";
9
9
  import { OmniConnector } from "../OmniConnector";
10
10
  import { ReviewFee } from "../core/bridge";
11
11
  import { Token } from "../core/token";
@@ -12,7 +12,7 @@ import { Recipient } from "../../core/recipient";
12
12
  import { OmniWallet } from "../../OmniWallet";
13
13
  import { BridgeReview } from "../../exchange";
14
14
  import { HotConnector } from "../../HotConnector";
15
- import { WalletType } from "../../core/config";
15
+ import { WalletType } from "../../core/chains";
16
16
  import { Token } from "../../core/token";
17
17
 
18
18
  import Popup from "../Popup";
@@ -6,7 +6,7 @@ import { openBridge, openConnector } from "../router";
6
6
  import { Recipient } from "../../core/recipient";
7
7
  import { BridgeReview } from "../../exchange";
8
8
  import { OmniWallet } from "../../OmniWallet";
9
- import { Network } from "../../core/config";
9
+ import { Network } from "../../core/chains";
10
10
  import { Token } from "../../core/token";
11
11
  import Popup from "../Popup";
12
12
 
@@ -6,7 +6,7 @@ import { LogoutIcon } from "../icons/logout";
6
6
  import { openBridge, openConnector } from "../router";
7
7
  import { HotConnector } from "../../HotConnector";
8
8
  import { formatter } from "../../core/utils";
9
- import { OmniToken } from "../../core/config";
9
+ import { OmniToken } from "../../core/chains";
10
10
  import { tokens } from "../../core/tokens";
11
11
  import Popup from "../Popup";
12
12
 
@@ -7,7 +7,7 @@ import { PopupOption, PopupOptionInfo } from "../styles";
7
7
  import { ConnectorType, OmniConnector } from "../../OmniConnector";
8
8
  import { HotConnector } from "../../HotConnector";
9
9
  import { Recipient } from "../../core/recipient";
10
- import { WalletType } from "../../core/config";
10
+ import { WalletType } from "../../core/chains";
11
11
  import { openWalletPicker } from "../router";
12
12
  import { formatter } from "../../core/utils";
13
13
  import Popup from "../Popup";
@@ -6,7 +6,7 @@ import { PopupOption, PopupOptionInfo } from "../styles";
6
6
 
7
7
  import { ConnectorType, OmniConnector } from "../../OmniConnector";
8
8
  import { OmniWallet } from "../../OmniWallet";
9
- import { WalletType } from "../../core/config";
9
+ import { WalletType } from "../../core/chains";
10
10
  import { HotConnector } from "../../HotConnector";
11
11
  import { openWalletPicker } from "../router";
12
12
  import { formatter } from "../../core/utils";
@@ -6,7 +6,7 @@ import { formatter } from "../../core/utils";
6
6
  import { Token } from "../../core/token";
7
7
  import { HotConnector } from "../../HotConnector";
8
8
  import { OmniWallet } from "../../OmniWallet";
9
- import { Network, OmniToken } from "../../core/config";
9
+ import { Network, OmniToken } from "../../core/chains";
10
10
  import { PopupOption } from "../styles";
11
11
  import Popup from "../Popup";
12
12
 
@@ -1,12 +1,14 @@
1
1
  import { observer } from "mobx-react-lite";
2
2
  import { useEffect, useState } from "react";
3
+ import styled from "styled-components";
3
4
 
5
+ import { chains } from "../../core/chains";
4
6
  import { formatter } from "../../core/utils";
5
7
  import { Token } from "../../core/token";
8
+
6
9
  import { HotConnector } from "../../HotConnector";
7
10
  import { OmniWallet } from "../../OmniWallet";
8
11
  import { PopupOption } from "../styles";
9
- import { chainsMap } from "../../core/config";
10
12
 
11
13
  const images = {
12
14
  cached: new Map<string, Promise<void>>(),
@@ -56,7 +58,7 @@ export const TokenIcon = observer(({ token, wallet }: { token: Token; wallet?: O
56
58
  <div style={{ position: "relative", width: 40, height: 40 }}>
57
59
  <ImageView src={token.icon} alt={token.symbol} size={40} />
58
60
  <ImageView src={token.chainIcon} alt={token.symbol} size={14} style={{ position: "absolute", bottom: 0, right: 0 }} />
59
- {token.chain === -4 && wallet?.type && <ImageView src={wallet.icon} alt={chainsMap[wallet.type]?.name || ""} size={14} style={{ position: "absolute", bottom: 0, left: 0 }} />}
61
+ {token.chain === -4 && wallet?.type && <ImageView src={wallet.icon} alt={chains.get(wallet.type)?.name || ""} size={14} style={{ position: "absolute", bottom: 0, left: 0 }} />}
60
62
  </div>
61
63
  );
62
64
  });
@@ -69,15 +71,28 @@ export const TokenCard = observer(({ token, onSelect, hot, wallet }: { token: To
69
71
  <PopupOption key={token.id} onClick={() => onSelect(token, wallet)}>
70
72
  <TokenIcon token={token} wallet={wallet} />
71
73
 
72
- <div style={{ marginTop: -2, display: "flex", flexDirection: "column", gap: 4, textAlign: "left" }}>
74
+ <TokenWrap style={{ marginTop: -2, textAlign: "left" }}>
73
75
  <p style={{ textAlign: "left", fontSize: 20, fontWeight: "bold" }}>{symbol}</p>
74
76
  <p style={{ textAlign: "left", fontSize: 14, color: "#c6c6c6" }}>${formatter.amount(token.usd)}</p>
75
- </div>
77
+ </TokenWrap>
76
78
 
77
- <div style={{ display: "flex", flexDirection: "column", gap: 4, paddingRight: 4, marginLeft: "auto", alignItems: "flex-end" }}>
79
+ <TokenWrap style={{ paddingRight: 4, marginLeft: "auto", alignItems: "flex-end" }}>
78
80
  <p style={{ textAlign: "right", fontSize: 20 }}>{token.readable(balance)}</p>
79
81
  <p style={{ textAlign: "right", fontSize: 14, color: "#c6c6c6" }}>${token.readable(balance, token.usd)}</p>
80
- </div>
82
+ </TokenWrap>
81
83
  </PopupOption>
82
84
  );
83
85
  });
86
+
87
+ const TokenWrap = styled.div`
88
+ display: flex;
89
+ flex-direction: column;
90
+ gap: 4px;
91
+
92
+ &,
93
+ p {
94
+ white-space: nowrap;
95
+ overflow: hidden;
96
+ text-overflow: ellipsis;
97
+ }
98
+ `;
package/src/ui/router.tsx CHANGED
@@ -3,7 +3,7 @@ import { OmniConnector } from "../OmniConnector";
3
3
  import { BridgeReview } from "../exchange";
4
4
  import { Token } from "../core/token";
5
5
  import { OmniWallet } from "../OmniWallet";
6
- import { WalletType } from "../core/config";
6
+ import { WalletType } from "../core/chains";
7
7
  import { Recipient } from "../core/recipient";
8
8
 
9
9
  import { present } from "./Popup";