herald-exchange-onramp_offramp-widget 1.0.0 → 1.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herald-exchange-onramp_offramp-widget",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -56,4 +56,4 @@
56
56
  "stream": false,
57
57
  "crypto": false
58
58
  }
59
- }
59
+ }
@@ -208,7 +208,13 @@ const SellAdminCryptoAccount = ({
208
208
  intervalRef.current = setInterval(() => {
209
209
  // console.log(token, networkType)
210
210
  if (["USDT", "USDC"].includes(currency) && networkType) {
211
- fetchTokenTransactions(networkType, walletAddress, startTimestamp, expected_amount);
211
+ fetchTokenTransactions({
212
+ currency,
213
+ token: networkType,
214
+ walletAddress,
215
+ startTimestamp,
216
+ expected_amount,
217
+ });
212
218
  } else {
213
219
  fetchTransactions(token, walletAddress, startTimestamp, expected_amount);
214
220
  }
@@ -304,12 +310,19 @@ const SellAdminCryptoAccount = ({
304
310
  });
305
311
  };
306
312
 
307
- const fetchTokenTransactions = async (
308
- token: string,
309
- walletAddress: string,
310
- startTimestamp: any,
311
- expectedAmount: any
312
- ) => {
313
+ const fetchTokenTransactions = async ({
314
+ currency,
315
+ token,
316
+ walletAddress,
317
+ startTimestamp,
318
+ expected_amount,
319
+ }: {
320
+ currency: string;
321
+ token: string;
322
+ walletAddress: string;
323
+ startTimestamp: any;
324
+ expected_amount: string;
325
+ }) => {
313
326
  let apiUrl = "";
314
327
  console.log({ token });
315
328
 
@@ -324,13 +337,13 @@ const SellAdminCryptoAccount = ({
324
337
 
325
338
  const contract_address = getContactAddress({
326
339
  mode,
327
- token,
340
+ token: currency,
328
341
  networkType,
329
342
  });
330
343
 
331
344
  console.log({ contract_address, rpcUrl });
332
345
 
333
- console.log("Checking for Token @ ", networkType, contract_address, token);
346
+ console.log("Checking for Token @ ", currency, networkType, contract_address, token);
334
347
 
335
348
  if (["ETH", "BNB", "MATIC"].includes(networkType)) {
336
349
  const key = networkType == "ETH" ? ETH_KEY : networkType == "BNB" ? BNB_KEY : MATIC_KEY;
@@ -353,7 +366,7 @@ const SellAdminCryptoAccount = ({
353
366
  token,
354
367
  startTimestamp,
355
368
  contract_address,
356
- expectedAmount
369
+ expected_amount
357
370
  );
358
371
  } catch (error) {
359
372
  console.error("Error fetching token transactions:", error);
@@ -414,7 +427,6 @@ const SellAdminCryptoAccount = ({
414
427
  // setMonitoring(false);
415
428
  // setAutomaticHash(false);
416
429
  // };
417
-
418
430
  return (
419
431
  <>
420
432
  <div className={styles.bank_head}>
@@ -44,7 +44,7 @@ export type tokenSellDataType = {
44
44
  // Sell Crypto and receive Fiat
45
45
  const SellField = ({ apiKey, parameters, clientReferenceID, mode }: SellFieldProps) => {
46
46
  const { addToast } = useToast(); // to show toast
47
- const exchangeSocket: any = useExchangeSocket({}); // socket connevction to fetch exchange rate
47
+ const exchangeSocket: any = useExchangeSocket({ mode }); // socket connevction to fetch exchange rate
48
48
 
49
49
  const [step, setStep] = useState(1); // used to render components
50
50
 
@@ -397,6 +397,8 @@ const SellField = ({ apiKey, parameters, clientReferenceID, mode }: SellFieldPro
397
397
  });
398
398
  }, [exchangeRateForThisUser, tokenSellData]);
399
399
 
400
+ console.log({ tokenSellData, exchangeRate });
401
+
400
402
  useEffect(() => {
401
403
  if (tokenSellData) {
402
404
  console.log("calculating");
@@ -2,21 +2,32 @@
2
2
  import { useEffect, useRef } from "react";
3
3
  import { io } from "socket.io-client";
4
4
 
5
- const socketUrl = "https://woowga-node.herald.exchange:9001/";
5
+ const getSocketUrl = (mode: string) => {
6
+ if (mode === "production") {
7
+ return "https://woowga-node.herald.exchange:9001/";
8
+ } else {
9
+ return "https://efi-exchange.blockstall.com:9001/";
10
+ }
11
+ };
12
+
6
13
  let socket: any = null;
7
14
  let refCount = 0;
8
15
 
9
16
  export const useExchangeSocket = ({
10
17
  onConnectCallback,
11
18
  onDisconnectCallback,
19
+ mode,
12
20
  }: {
13
21
  onConnectCallback?: () => void;
14
22
  onDisconnectCallback?: () => void;
23
+ mode: string;
15
24
  }) => {
16
25
  const socketRef = useRef(null);
17
26
 
18
27
  useEffect(() => {
19
28
  refCount += 1;
29
+ const socketUrl = getSocketUrl(mode);
30
+
20
31
  if (!socket) {
21
32
  socket = io(socketUrl, {
22
33
  transports: ["websocket"],