herald-exchange-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.
@@ -207,7 +207,13 @@ const SellAdminCryptoAccount = ({
207
207
  intervalRef.current = setInterval(() => {
208
208
  // console.log(token, networkType)
209
209
  if (["USDT", "USDC"].includes(currency) && networkType) {
210
- fetchTokenTransactions(networkType, walletAddress, startTimestamp, expected_amount);
210
+ fetchTokenTransactions({
211
+ currency,
212
+ token: networkType,
213
+ walletAddress,
214
+ startTimestamp,
215
+ expected_amount,
216
+ });
211
217
  } else {
212
218
  fetchTransactions(token, walletAddress, startTimestamp, expected_amount);
213
219
  }
@@ -303,12 +309,19 @@ const SellAdminCryptoAccount = ({
303
309
  });
304
310
  };
305
311
 
306
- const fetchTokenTransactions = async (
307
- token: string,
308
- walletAddress: string,
309
- startTimestamp: any,
310
- expectedAmount: any
311
- ) => {
312
+ const fetchTokenTransactions = async ({
313
+ currency,
314
+ token,
315
+ walletAddress,
316
+ startTimestamp,
317
+ expected_amount,
318
+ }: {
319
+ currency: string;
320
+ token: string;
321
+ walletAddress: string;
322
+ startTimestamp: any;
323
+ expected_amount: string;
324
+ }) => {
312
325
  let apiUrl = "";
313
326
  console.log({ token });
314
327
 
@@ -323,13 +336,13 @@ const SellAdminCryptoAccount = ({
323
336
 
324
337
  const contract_address = getContactAddress({
325
338
  mode,
326
- token,
339
+ token: currency,
327
340
  networkType,
328
341
  });
329
342
 
330
343
  console.log({ contract_address, rpcUrl });
331
344
 
332
- console.log("Checking for Token @ ", networkType, contract_address, token);
345
+ console.log("Checking for Token @ ", currency, networkType, contract_address, token);
333
346
 
334
347
  if (["ETH", "BNB", "MATIC"].includes(networkType)) {
335
348
  const key = networkType == "ETH" ? ETH_KEY : networkType == "BNB" ? BNB_KEY : MATIC_KEY;
@@ -352,7 +365,7 @@ const SellAdminCryptoAccount = ({
352
365
  token,
353
366
  startTimestamp,
354
367
  contract_address,
355
- expectedAmount
368
+ expected_amount
356
369
  );
357
370
  } catch (error) {
358
371
  console.error("Error fetching token transactions:", error);
@@ -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 connection to fetch exchange rate
48
48
 
49
49
  const [step, setStep] = useState(1); // used to render components
50
50
 
@@ -486,14 +486,26 @@ const SellField = ({ apiKey, parameters, clientReferenceID, mode }: SellFieldPro
486
486
  handleCryptoCurrencyValueChange(newValue);
487
487
  }}
488
488
  />
489
+ {invalidAmount?.min && (
490
+ <p className={styles.errorMsg}>
491
+ Invalid, Min : {parseFloat(tokenSellData?.minAmount)?.toFixed(8)}
492
+ </p>
493
+ )}
494
+ {invalidAmount?.max && (
495
+ <p className={styles.errorMsg}>
496
+ Invalid, Max : {parseFloat(tokenSellData?.maxAmount)?.toString()}
497
+ </p>
498
+ )}
489
499
  </div>
490
500
  </div>
491
501
  <div className={styles.offRampFieldSelectCard}>
492
502
  <div className={`${styles.offRampFieldSelect}`}>
493
503
  {cryptoCurrencyOptions?.length > 0 ? (
494
504
  <CustomSelect
495
- backgroundColor="#f3e2c3"
505
+ backgroundColor="var(--primary-set-color)"
506
+ colorvalue="var(--off-white)"
496
507
  placeholder="Select"
508
+ svgFill ="var(--off-white)"
497
509
  image={true}
498
510
  singleicons={true}
499
511
  value={selectedCrypto}
@@ -515,7 +527,8 @@ const SellField = ({ apiKey, parameters, clientReferenceID, mode }: SellFieldPro
515
527
  ["USDT", "USDC"].includes(tokenSellData.selectedCrypto) && (
516
528
  <div className={styles.selected__two}>
517
529
  <CustomSelect
518
- backgroundColor="#fff"
530
+ backgroundColor="var(--no-set-color)"
531
+ colorvalue="var(--primary-set-color)"
519
532
  placeholder="Select"
520
533
  options={networkOptions}
521
534
  image={true}
@@ -536,16 +549,7 @@ const SellField = ({ apiKey, parameters, clientReferenceID, mode }: SellFieldPro
536
549
  )}
537
550
  </div>
538
551
  </div>
539
- {invalidAmount?.min && (
540
- <p className={styles.errorMsg}>
541
- Invalid, Min : {parseFloat(tokenSellData?.minAmount)?.toFixed(8)}
542
- </p>
543
- )}
544
- {invalidAmount?.max && (
545
- <p className={styles.errorMsg}>
546
- Invalid, Max : {parseFloat(tokenSellData?.maxAmount)?.toString()}
547
- </p>
548
- )}
552
+
549
553
  <div className={styles.offRampInfoBox}>
550
554
  <div className={`${styles.offRampLabelCard} ${styles.offRampSpace}`}>
551
555
  <div className={styles.offRampLabelIcons}>
@@ -555,6 +559,7 @@ const SellField = ({ apiKey, parameters, clientReferenceID, mode }: SellFieldPro
555
559
  width="12"
556
560
  height="12"
557
561
  viewBox="0 0 300 300"
562
+ fill="#fff"
558
563
  >
559
564
  <path
560
565
  d="M240.3 171.5H59.7c-11.9 0-21.5-9.6-21.5-21.5s9.6-21.5 21.5-21.5h180.6c11.9 0 21.5 9.6 21.5 21.5s-9.6 21.5-21.5 21.5"
@@ -581,28 +586,22 @@ const SellField = ({ apiKey, parameters, clientReferenceID, mode }: SellFieldPro
581
586
  <div className={styles.offRampDetails}>
582
587
  <div className={styles.offRampHead}>Withdrawal Method</div>
583
588
  <div className={styles.offPaymentBox}>
584
- <div className={`${styles.offPaymentCheckCard} ${styles.selected}`}>
585
- <input
586
- type="radio"
587
- name="radioDefault"
588
- id="radioDefault1"
589
- value="0.10234"
590
- className={styles.inputControl}
591
- />
589
+ <div className={styles.offPaymentCheckCard}>
592
590
  <div>Bank Transfer</div>
593
591
  <svg
594
592
  xmlns="http://www.w3.org/2000/svg"
595
- width="20"
596
- height="20"
593
+ width="18"
594
+ height="18"
597
595
  viewBox="0 0 408.576 408.576"
598
596
  >
599
597
  <g>
600
598
  <path
601
599
  d="M204.288 0C91.648 0 0 91.648 0 204.288s91.648 204.288 204.288 204.288 204.288-91.648 204.288-204.288S316.928 0 204.288 0zm114.176 150.528-130.56 129.536c-7.68 7.68-19.968 8.192-28.16.512L90.624 217.6c-8.192-7.68-8.704-20.48-1.536-28.672 7.68-8.192 20.48-8.704 28.672-1.024l54.784 50.176L289.28 121.344c8.192-8.192 20.992-8.192 29.184 0s8.192 20.992 0 29.184z"
602
- fill="#F9C201"
600
+ fill="#22BB33"
603
601
  ></path>
604
602
  </g>
605
603
  </svg>
604
+
606
605
  </div>
607
606
  </div>
608
607
  </div>
@@ -634,9 +633,11 @@ const SellField = ({ apiKey, parameters, clientReferenceID, mode }: SellFieldPro
634
633
  <div className={styles.offRampFieldSelect}>
635
634
  {fiatCurrencyOptions?.length > 0 ? (
636
635
  <CustomSelect
637
- backgroundColor="#f3e2c3"
636
+ backgroundColor="var(--primary-set-color)"
637
+ colorvalue="var(--off-white)"
638
638
  placeholder="Select"
639
639
  borderColor="var(--no-color)"
640
+ svgFill ="var(--off-white)"
640
641
  image={true}
641
642
  singleicons={true}
642
643
  options={fiatCurrencyOptions}
@@ -400,6 +400,8 @@ const WidgetBankDetails = ({
400
400
  placeholder={isFetchingBeneficiary ? "Loading..." : "Select Beneficiary"}
401
401
  value={selectedBeneficiary}
402
402
  isDisabled={beneficiaryOptions?.length <= 0}
403
+ backgroundColor="var(--off-white-border)"
404
+ colorvalue="var(--primary-set-color)"
403
405
  />
404
406
  </div>
405
407
  </div>
@@ -440,7 +442,7 @@ const WidgetBankDetails = ({
440
442
  <g>
441
443
  <path
442
444
  d="M204.288 0C91.648 0 0 91.648 0 204.288s91.648 204.288 204.288 204.288 204.288-91.648 204.288-204.288S316.928 0 204.288 0zm114.176 150.528-130.56 129.536c-7.68 7.68-19.968 8.192-28.16.512L90.624 217.6c-8.192-7.68-8.704-20.48-1.536-28.672 7.68-8.192 20.48-8.704 28.672-1.024l54.784 50.176L289.28 121.344c8.192-8.192 20.992-8.192 29.184 0s8.192 20.992 0 29.184z"
443
- fill={formState?.type === item.label ? "#F9C201" : "#efefef"}
445
+ fill={formState?.type === item.label ? "#22BB33" : "#efefef"}
444
446
  ></path>
445
447
  </g>
446
448
  </svg>
@@ -461,6 +463,8 @@ const WidgetBankDetails = ({
461
463
  <div className={styles.offRampNewBankFields}>
462
464
  <CustomSelect
463
465
  options={bankOptions}
466
+ backgroundColor="var(--off-white-border)"
467
+ colorvalue="var(--primary-set-color)"
464
468
  isClearable={true}
465
469
  placeholder="Select Bank"
466
470
  value={
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React from "react";
2
2
  import styles from "../assets/css/style.module.css";
3
3
  import WidgetContent from "./WidgetContent";
4
4
  import { ToastProvider } from "../hooks/toastProvider";
@@ -19,9 +19,6 @@ const WidgetComponent = ({
19
19
  }: WidgetComponentProps) => {
20
20
  return (
21
21
  <div style={{ position: "relative" }} className={styles.widgetComponent} id="widget-container">
22
- <div className={`${styles.exchangeWidgetWrapped} ${styles.show}`}>
23
- <div className={styles.exchangeWidgetModal}>
24
- <div className={styles.exchangeWidgetContent}>
25
22
  <ToastProvider>
26
23
  <WidgetContent
27
24
  sellParameters={sellParameters}
@@ -31,9 +28,6 @@ const WidgetComponent = ({
31
28
  />
32
29
  </ToastProvider>
33
30
  </div>
34
- </div>
35
- </div>
36
- </div>
37
31
  );
38
32
  };
39
33
 
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import SellField from "./SellField";
3
3
  import type { SellParamsType } from "./types";
4
- import styles from "../assets/css/style.module.css";
5
4
 
6
5
  type WidgetContentProps = {
7
6
  apiKey: string;
@@ -13,16 +12,12 @@ type WidgetContentProps = {
13
12
  const WidgetContent = ({ apiKey, sellParameters, clientReferenceID, mode }: WidgetContentProps) => {
14
13
  // const [activeTab, setActiveTab] = useState("sell");
15
14
  return (
16
- <div className={styles.widegtTabsWrapped}>
17
- <div className={styles.widegtTabsContent}>
18
15
  <SellField
19
16
  apiKey={apiKey}
20
17
  parameters={sellParameters}
21
18
  clientReferenceID={clientReferenceID}
22
19
  mode={mode}
23
20
  />
24
- </div>
25
- </div>
26
21
  );
27
22
  };
28
23
 
@@ -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"],