herald-exchange-offramp-widget 1.0.0
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/.babelrc +3 -0
- package/Readme.md +118 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +24 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +58 -0
- package/rollup.config.js +90 -0
- package/src/assets/css/style.module.css +1473 -0
- package/src/assets/icons-one.png +0 -0
- package/src/assets/react.svg +1 -0
- package/src/components/ButtonStepper.tsx +144 -0
- package/src/components/CommonCenterLoader.tsx +31 -0
- package/src/components/CustomeSelect.tsx +178 -0
- package/src/components/DotLoader.tsx +7 -0
- package/src/components/SellAdminCryptoAccount.tsx +603 -0
- package/src/components/SellField.tsx +712 -0
- package/src/components/WidgetBankDetails.tsx +612 -0
- package/src/components/WidgetComponent.tsx +40 -0
- package/src/components/WidgetContent.tsx +29 -0
- package/src/components/WidgetSuccesDetails.tsx +113 -0
- package/src/components/api.ts +59 -0
- package/src/components/chains.ts +319 -0
- package/src/components/images.d.ts +5 -0
- package/src/components/loader.tsx +12 -0
- package/src/components/style.module.css.d.ts +4 -0
- package/src/components/toast.tsx +43 -0
- package/src/components/types.ts +237 -0
- package/src/components/utils.ts +17 -0
- package/src/hooks/toastProvider.tsx +63 -0
- package/src/hooks/useSocketExchange.tsx +48 -0
- package/src/index.ts +3 -0
- package/tsconfig.json +118 -0
@@ -0,0 +1,603 @@
|
|
1
|
+
import React, { useEffect, useState, useRef } from "react";
|
2
|
+
import CommonCenterLoader, { ButtonLoader } from "./CommonCenterLoader";
|
3
|
+
// import CopyToClipboard from "react-copy-to-clipboard";
|
4
|
+
import ButtonStepper from "./ButtonStepper";
|
5
|
+
import { QRCodeCanvas } from "qrcode.react";
|
6
|
+
import { handleApiCall } from "./api";
|
7
|
+
import { useToast } from "../hooks/toastProvider";
|
8
|
+
import type { tokenSellDataType } from "./SellField";
|
9
|
+
import type { OfframpTransactionAPIResponse, WalletAddressAPIRespone } from "./types";
|
10
|
+
import styles from "../assets/css/style.module.css";
|
11
|
+
import { getContactAddress, getSupportedTokens } from "./chains";
|
12
|
+
import { getBaseUrl } from "./utils";
|
13
|
+
|
14
|
+
type WalletAddressKeys = "evm" | "trx" | "sol";
|
15
|
+
|
16
|
+
type SellAdminCryptoAccountProps = {
|
17
|
+
tokenSellData: tokenSellDataType;
|
18
|
+
setTokenSellData: (data: any) => void;
|
19
|
+
apiKey: string;
|
20
|
+
setStep: (step: number) => void;
|
21
|
+
clientReferenceID: string;
|
22
|
+
mode: string;
|
23
|
+
};
|
24
|
+
|
25
|
+
const SellAdminCryptoAccount = ({
|
26
|
+
tokenSellData,
|
27
|
+
setTokenSellData,
|
28
|
+
apiKey,
|
29
|
+
setStep,
|
30
|
+
clientReferenceID,
|
31
|
+
mode,
|
32
|
+
}: SellAdminCryptoAccountProps) => {
|
33
|
+
const { addToast } = useToast(); // to show toast
|
34
|
+
|
35
|
+
// const updateTokenSellData = (data) => setTokenSellData(data);
|
36
|
+
|
37
|
+
// const [errorMessage, setErrorMessage] = useState(false);
|
38
|
+
const [transactionSuccess, setTransactionSuccess] = useState(false);
|
39
|
+
const [skipRender, setSkipRender] = useState(true);
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
41
|
+
const [sellStaticCaseWallet, setSellStaticCaseWallet] = useState(false);
|
42
|
+
// const [files, setFiles] = useState([]);
|
43
|
+
const [generatedQr, setGeneratedQr] = useState<string>("");
|
44
|
+
const [monitoring, setMonitoring] = useState(true);
|
45
|
+
// const [tronMonitoring, setTronMonitoring] = useState(false);
|
46
|
+
// const [solanaMonitoring, setSolanaMonitoring] = useState(false);
|
47
|
+
const [automaticHash, setAutomaticHash] = useState(true);
|
48
|
+
const [walletLoading, setWalletLoading] = useState(false);
|
49
|
+
const [adminWallet, setAdminWallet] = useState<string | null>(null);
|
50
|
+
const [transactionHash, setTransactionHash] = useState<string>("");
|
51
|
+
const [selltokensLoading, setSellTokensLoading] = useState(false);
|
52
|
+
const [tokenSell, setTokenSell] = useState<any>(null);
|
53
|
+
|
54
|
+
const intervalRef = useRef<any>(null);
|
55
|
+
const inputRef = useRef<any>(null);
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
57
|
+
const [networkType, setNetworkType] = useState(tokenSellData.network_type || "");
|
58
|
+
|
59
|
+
// const validationSchema = Yup.object().shape({
|
60
|
+
// transaction_hash: Yup.string()
|
61
|
+
// .required(t("transaction.required"))
|
62
|
+
// .min(3, t("transaction.invalid"))
|
63
|
+
// });
|
64
|
+
|
65
|
+
useEffect(() => {
|
66
|
+
window.scrollTo(0, 0);
|
67
|
+
fetchAdminWallet();
|
68
|
+
}, []);
|
69
|
+
|
70
|
+
const onSubmit = () => {
|
71
|
+
sellTokenStart({
|
72
|
+
...tokenSellData,
|
73
|
+
transaction_hash: transactionHash,
|
74
|
+
});
|
75
|
+
};
|
76
|
+
|
77
|
+
useEffect(() => {
|
78
|
+
if (!skipRender && adminWallet) {
|
79
|
+
const wallet_address = adminWallet;
|
80
|
+
|
81
|
+
const token = ["USDT", "USDC"].includes(tokenSellData.selectedCrypto)
|
82
|
+
? tokenSellData.network_type
|
83
|
+
: tokenSellData.selectedCrypto;
|
84
|
+
console.log({ wallet_address });
|
85
|
+
generateQRDetails(wallet_address, token, tokenSellData.selectedCrypto);
|
86
|
+
}
|
87
|
+
setSkipRender(false);
|
88
|
+
}, [adminWallet, tokenSellData]);
|
89
|
+
|
90
|
+
const generateQRDetails = async (wallet_address: string, token: string, currency: string) => {
|
91
|
+
const network = token === "TRX" ? "tron" : token === "SOL" ? "solana" : "ethereum";
|
92
|
+
const depositAmountInWei = ["TRX", "SOL"].includes(token)
|
93
|
+
? tokenSellData.from_amount.toString()
|
94
|
+
: ["USDC", "USDT"].includes(currency)
|
95
|
+
? tokenSellData.from_amount.toString()
|
96
|
+
: tokenSellData.from_amount.toString();
|
97
|
+
const depositLabel = "HeraldExchangeSell";
|
98
|
+
const uri = `${network}:${wallet_address}?amount=${depositAmountInWei}&label=${encodeURIComponent(
|
99
|
+
depositLabel
|
100
|
+
)}`;
|
101
|
+
setGeneratedQr(uri);
|
102
|
+
};
|
103
|
+
|
104
|
+
const fetchAdminWallet = async () => {
|
105
|
+
const baseUrl = getBaseUrl(mode);
|
106
|
+
setWalletLoading(true);
|
107
|
+
|
108
|
+
handleApiCall({
|
109
|
+
url: `${baseUrl}/api/offramp/wallet_address`,
|
110
|
+
headers: {
|
111
|
+
"Content-Type": "application/json",
|
112
|
+
"X-API-KEY": apiKey,
|
113
|
+
"User-Id": clientReferenceID,
|
114
|
+
},
|
115
|
+
onSuccess: (result: WalletAddressAPIRespone) => {
|
116
|
+
if (result?.data?.wallet_address) {
|
117
|
+
const networkType: string = (
|
118
|
+
["USDT", "USDC"].includes(tokenSellData.selectedCrypto)
|
119
|
+
? tokenSellData.network_type
|
120
|
+
: tokenSellData.selectedCrypto
|
121
|
+
).toLowerCase();
|
122
|
+
|
123
|
+
const walletKeys: WalletAddressKeys[] = ["evm", "trx", "sol"];
|
124
|
+
|
125
|
+
const wallet_address: string = ["eth", "bnb", "matic"].includes(networkType)
|
126
|
+
? result?.data?.wallet_address["evm"]
|
127
|
+
: walletKeys.includes(networkType as WalletAddressKeys)
|
128
|
+
? result?.data?.wallet_address[networkType as WalletAddressKeys]
|
129
|
+
: "";
|
130
|
+
|
131
|
+
setAdminWallet(wallet_address);
|
132
|
+
setWalletLoading(false);
|
133
|
+
}
|
134
|
+
},
|
135
|
+
onError: () => {
|
136
|
+
addToast("Error fetching exchange rate", "error");
|
137
|
+
setWalletLoading(false);
|
138
|
+
},
|
139
|
+
});
|
140
|
+
};
|
141
|
+
|
142
|
+
const sellTokenStart = async (data: any) => {
|
143
|
+
setSellTokensLoading(true);
|
144
|
+
const baseUrl = getBaseUrl(mode);
|
145
|
+
|
146
|
+
const formdata = new FormData();
|
147
|
+
|
148
|
+
formdata.append("from", tokenSellData.selectedCrypto);
|
149
|
+
formdata.append("to", tokenSellData.selectedFiat);
|
150
|
+
if (["USDT", "USDC"].includes(tokenSellData.selectedCrypto)) {
|
151
|
+
formdata.append("network_type", tokenSellData.network_type);
|
152
|
+
}
|
153
|
+
formdata.append("value", tokenSellData.from_amount);
|
154
|
+
formdata.append("initial_exchange_rate", tokenSellData.exchange_rate?.toString());
|
155
|
+
formdata.append("transaction_hash", data.transaction_hash);
|
156
|
+
formdata.append("bank_account", tokenSellData.selectedBeneficiary);
|
157
|
+
|
158
|
+
handleApiCall({
|
159
|
+
url: `${baseUrl}/api/offramp/transactions`,
|
160
|
+
headers: {
|
161
|
+
"X-API-KEY": apiKey,
|
162
|
+
"User-Id": clientReferenceID,
|
163
|
+
},
|
164
|
+
method: "POST",
|
165
|
+
body: formdata,
|
166
|
+
onSuccess: (result: OfframpTransactionAPIResponse) => {
|
167
|
+
if (result?.success) {
|
168
|
+
setTokenSell({
|
169
|
+
data: result?.data,
|
170
|
+
});
|
171
|
+
setTransactionSuccess(true);
|
172
|
+
setTokenSellData({
|
173
|
+
...tokenSellData,
|
174
|
+
response: result?.data,
|
175
|
+
});
|
176
|
+
setSellTokensLoading(false);
|
177
|
+
addToast(`${result?.message}`, "success");
|
178
|
+
setStep(4);
|
179
|
+
} else {
|
180
|
+
addToast(`${result?.message}`, "error");
|
181
|
+
setTransactionSuccess(false);
|
182
|
+
setSellTokensLoading(false);
|
183
|
+
}
|
184
|
+
},
|
185
|
+
onError: (error: any) => {
|
186
|
+
addToast(` ${error}`, "error");
|
187
|
+
setTransactionSuccess(false);
|
188
|
+
setSellTokensLoading(false);
|
189
|
+
},
|
190
|
+
});
|
191
|
+
};
|
192
|
+
|
193
|
+
useEffect(() => {
|
194
|
+
if (!skipRender && adminWallet && monitoring) {
|
195
|
+
const walletAddress = adminWallet;
|
196
|
+
|
197
|
+
const token = ["USDT", "USDC"].includes(tokenSellData.selectedCrypto)
|
198
|
+
? tokenSellData.network_type
|
199
|
+
: tokenSellData.selectedCrypto;
|
200
|
+
const currency = tokenSellData.selectedCrypto;
|
201
|
+
const expected_amount = tokenSellData.from_amount;
|
202
|
+
|
203
|
+
if (walletAddress) {
|
204
|
+
const startTimestamp = Date.now();
|
205
|
+
// let rpcUrl = SUPPORTED_RPC_NODES[SupportedTokens[token]];
|
206
|
+
|
207
|
+
intervalRef.current = setInterval(() => {
|
208
|
+
// console.log(token, networkType)
|
209
|
+
if (["USDT", "USDC"].includes(currency) && networkType) {
|
210
|
+
fetchTokenTransactions(networkType, walletAddress, startTimestamp, expected_amount);
|
211
|
+
} else {
|
212
|
+
fetchTransactions(token, walletAddress, startTimestamp, expected_amount);
|
213
|
+
}
|
214
|
+
}, 10000);
|
215
|
+
}
|
216
|
+
// generateQRDetails(walletAddress, token, tokenSellData.from_currency);
|
217
|
+
}
|
218
|
+
setSkipRender(false);
|
219
|
+
return () => {
|
220
|
+
if (intervalRef.current) {
|
221
|
+
clearInterval(intervalRef.current);
|
222
|
+
}
|
223
|
+
};
|
224
|
+
}, [adminWallet, tokenSellData, monitoring]);
|
225
|
+
|
226
|
+
const fetchTransactions = async (
|
227
|
+
token: string,
|
228
|
+
walletAddress: string,
|
229
|
+
startTimestamp: any,
|
230
|
+
expectedAmount: string
|
231
|
+
) => {
|
232
|
+
let apiUrl = "";
|
233
|
+
|
234
|
+
// const rpcUrl = SUPPORTED_RPC_NODES[SupportedTokens[token]];
|
235
|
+
const rpcUrl = getSupportedTokens({
|
236
|
+
mode,
|
237
|
+
token,
|
238
|
+
});
|
239
|
+
|
240
|
+
const ETH_KEY = "B34RQKNPZUV8IM6866DQ58WCS2Q6SWAP8V";
|
241
|
+
const BNB_KEY = "876A7KYGBE2TVBBNY33I4GZPXE1Q4QH3QA";
|
242
|
+
const MATIC_KEY = "KYV61TJQU5RDMTGY1D95J8R61HWCR9T7KT";
|
243
|
+
|
244
|
+
if (token === "ETH") {
|
245
|
+
apiUrl = `${rpcUrl}/api?module=account&action=txlist&address=${walletAddress}&startblock=0&endblock=99999999&sort=desc&apikey=${ETH_KEY}`;
|
246
|
+
} else if (token === "BNB") {
|
247
|
+
apiUrl = `${rpcUrl}/api?module=account&action=txlist&address=${walletAddress}&startblock=0&endblock=99999999&sort=desc&apikey=${BNB_KEY}`;
|
248
|
+
} else if (token === "MATIC" || token === "POLYGON" || token === "POLYGON_AMOY") {
|
249
|
+
apiUrl = `${rpcUrl}/api?module=account&action=txlist&address=${walletAddress}&startblock=0&endblock=99999999&sort=desc&apikey=${MATIC_KEY}`;
|
250
|
+
} else if (token === "TRX") {
|
251
|
+
apiUrl = `${rpcUrl}/v1/accounts/${walletAddress}/transactions?limit=10`;
|
252
|
+
} else if (token === "SOL") {
|
253
|
+
return fetchSolanaTransactions();
|
254
|
+
// apiUrl = `https://api.mainnet-beta.solana.com/`;
|
255
|
+
} else {
|
256
|
+
console.error("Unsupported network");
|
257
|
+
return;
|
258
|
+
}
|
259
|
+
|
260
|
+
if (automaticHash) {
|
261
|
+
try {
|
262
|
+
const response = await fetch(apiUrl);
|
263
|
+
const data = await response.json();
|
264
|
+
processTransactions(data, walletAddress, token, startTimestamp, expectedAmount);
|
265
|
+
} catch (error) {
|
266
|
+
console.error("Error fetching transactions:", error);
|
267
|
+
}
|
268
|
+
}
|
269
|
+
};
|
270
|
+
|
271
|
+
const processTransactions = (
|
272
|
+
data: any,
|
273
|
+
walletAddress: string,
|
274
|
+
token: string,
|
275
|
+
startTimestamp: any,
|
276
|
+
expectedAmount: any
|
277
|
+
) => {
|
278
|
+
let transactions = [];
|
279
|
+
|
280
|
+
if (token === "ETH" || token === "BNB" || token === "MATIC") {
|
281
|
+
transactions = data.result;
|
282
|
+
} else if (token === "TRX") {
|
283
|
+
transactions = data.data;
|
284
|
+
} else if (token === "SOL") {
|
285
|
+
transactions = data.result;
|
286
|
+
}
|
287
|
+
|
288
|
+
transactions.forEach((tx: any) => {
|
289
|
+
const timestamp = token == "TRX" ? tx.block_timestamp : tx.timeStamp * 1000;
|
290
|
+
// console.log(timestamp, startTimestamp, timestamp > startTimestamp)
|
291
|
+
if (timestamp > startTimestamp) {
|
292
|
+
const hash = tx.hash || tx.transactionHash || tx.txID;
|
293
|
+
const amount =
|
294
|
+
token == "TRX" ? tx.raw_data.contract[0].parameter.value.amount / 1e6 : tx.value / 1e18;
|
295
|
+
if (expectedAmount == amount) {
|
296
|
+
console.log("New Transaction Detected:", { hash, amount });
|
297
|
+
// formRef?.current?.setFieldValue("transaction_hash", hash);
|
298
|
+
inputRef.current.value = hash;
|
299
|
+
setTransactionHash(hash);
|
300
|
+
setMonitoring(false);
|
301
|
+
}
|
302
|
+
}
|
303
|
+
});
|
304
|
+
};
|
305
|
+
|
306
|
+
const fetchTokenTransactions = async (
|
307
|
+
token: string,
|
308
|
+
walletAddress: string,
|
309
|
+
startTimestamp: any,
|
310
|
+
expectedAmount: any
|
311
|
+
) => {
|
312
|
+
let apiUrl = "";
|
313
|
+
console.log({ token });
|
314
|
+
|
315
|
+
const rpcUrl = getSupportedTokens({
|
316
|
+
mode,
|
317
|
+
token,
|
318
|
+
});
|
319
|
+
|
320
|
+
const ETH_KEY = "B34RQKNPZUV8IM6866DQ58WCS2Q6SWAP8V";
|
321
|
+
const BNB_KEY = "876A7KYGBE2TVBBNY33I4GZPXE1Q4QH3QA";
|
322
|
+
const MATIC_KEY = "KYV61TJQU5RDMTGY1D95J8R61HWCR9T7KT";
|
323
|
+
|
324
|
+
const contract_address = getContactAddress({
|
325
|
+
mode,
|
326
|
+
token,
|
327
|
+
networkType,
|
328
|
+
});
|
329
|
+
|
330
|
+
console.log({ contract_address, rpcUrl });
|
331
|
+
|
332
|
+
console.log("Checking for Token @ ", networkType, contract_address, token);
|
333
|
+
|
334
|
+
if (["ETH", "BNB", "MATIC"].includes(networkType)) {
|
335
|
+
const key = networkType == "ETH" ? ETH_KEY : networkType == "BNB" ? BNB_KEY : MATIC_KEY;
|
336
|
+
apiUrl = `${rpcUrl}/api?module=account&action=tokentx&address=${walletAddress}&startblock=0&endblock=99999999&sort=desc&apikey=${key}`;
|
337
|
+
} else if (networkType === "TRX") {
|
338
|
+
apiUrl = `${rpcUrl}/v1/accounts/${walletAddress}/transactions/trc20`;
|
339
|
+
} else if (networkType === "SOL") {
|
340
|
+
return fetchSolanaTransactions();
|
341
|
+
} else {
|
342
|
+
console.error("Unsupported token network");
|
343
|
+
return;
|
344
|
+
}
|
345
|
+
|
346
|
+
try {
|
347
|
+
const response = await fetch(apiUrl);
|
348
|
+
const data = await response.json();
|
349
|
+
processTokenTransactions(
|
350
|
+
data,
|
351
|
+
walletAddress,
|
352
|
+
token,
|
353
|
+
startTimestamp,
|
354
|
+
contract_address,
|
355
|
+
expectedAmount
|
356
|
+
);
|
357
|
+
} catch (error) {
|
358
|
+
console.error("Error fetching token transactions:", error);
|
359
|
+
}
|
360
|
+
};
|
361
|
+
|
362
|
+
const processTokenTransactions = (
|
363
|
+
data: any,
|
364
|
+
walletAddress: string,
|
365
|
+
token: string,
|
366
|
+
startTimestamp: any,
|
367
|
+
contract_address: any,
|
368
|
+
expectedAmount: any
|
369
|
+
) => {
|
370
|
+
const transactions = data.result || data.data || [];
|
371
|
+
|
372
|
+
transactions.forEach((tx: any) => {
|
373
|
+
const timestamp = networkType == "TRX" ? tx.block_timestamp : tx.timeStamp * 1000;
|
374
|
+
if (timestamp > startTimestamp) {
|
375
|
+
if (networkType == "TRX") {
|
376
|
+
// Check if the token is same and then proceed
|
377
|
+
// if(contract_address.toLowerCase() == tx.token_info.address.toLowerCase()){
|
378
|
+
const hash = tx.hash || tx.transaction_id || tx.txID;
|
379
|
+
const amount = parseFloat(tx.value) / 10 ** parseInt(tx.token_info.decimals);
|
380
|
+
|
381
|
+
console.log("New TRC20 Transaction Detected:", { hash, amount });
|
382
|
+
|
383
|
+
if (amount == expectedAmount) {
|
384
|
+
// formRef?.current?.setFieldValue("transaction_hash", hash);
|
385
|
+
inputRef.current.value = hash;
|
386
|
+
setTransactionHash(hash);
|
387
|
+
setMonitoring(false);
|
388
|
+
}
|
389
|
+
// }
|
390
|
+
} else {
|
391
|
+
if (contract_address.toLowerCase() == tx.contractAddress.toLowerCase()) {
|
392
|
+
const hash = tx.hash || tx.transactionHash || tx.txID;
|
393
|
+
const amount = parseFloat(tx.value) / 10 ** parseInt(tx.tokenDecimal);
|
394
|
+
console.log("New ERC20 Transaction Detected:", { hash, amount });
|
395
|
+
if (amount == expectedAmount) {
|
396
|
+
// formRef?.current?.setFieldValue("transaction_hash", hash);
|
397
|
+
inputRef.current.value = hash;
|
398
|
+
setTransactionHash(hash);
|
399
|
+
setMonitoring(false);
|
400
|
+
}
|
401
|
+
}
|
402
|
+
}
|
403
|
+
}
|
404
|
+
});
|
405
|
+
};
|
406
|
+
|
407
|
+
const fetchSolanaTransactions = async () => {
|
408
|
+
setAutomaticHash(false);
|
409
|
+
setMonitoring(false);
|
410
|
+
};
|
411
|
+
|
412
|
+
// const handleManualHash = () => {
|
413
|
+
// setMonitoring(false);
|
414
|
+
// setAutomaticHash(false);
|
415
|
+
// };
|
416
|
+
|
417
|
+
return (
|
418
|
+
<>
|
419
|
+
<div className={styles.sellPaymentDetailsWrap}>
|
420
|
+
<div className={styles.offRampBankHead}>
|
421
|
+
<div style={{ cursor: "pointer" }} onClick={() => setStep(2)}>
|
422
|
+
<svg
|
423
|
+
xmlns="http://www.w3.org/2000/svg"
|
424
|
+
xmlSpace="preserve"
|
425
|
+
width="18"
|
426
|
+
height="18"
|
427
|
+
viewBox="0 0 240.823 240.823"
|
428
|
+
>
|
429
|
+
<path
|
430
|
+
d="M57.633 129.007 165.93 237.268c4.752 4.74 12.451 4.74 17.215 0 4.752-4.74 4.752-12.439 0-17.179l-99.707-99.671 99.695-99.671c4.752-4.74 4.752-12.439 0-17.191-4.752-4.74-12.463-4.74-17.215 0L57.621 111.816c-4.679 4.691-4.679 12.511.012 17.191"
|
431
|
+
data-original="#000000"
|
432
|
+
></path>
|
433
|
+
</svg>
|
434
|
+
</div>
|
435
|
+
<div className={styles.bankTitles}>Sell Crypto</div>
|
436
|
+
</div>
|
437
|
+
</div>
|
438
|
+
|
439
|
+
{walletLoading ? (
|
440
|
+
<CommonCenterLoader />
|
441
|
+
) : adminWallet && Object.keys(adminWallet)?.length > 0 ? (
|
442
|
+
<>
|
443
|
+
<div className={styles.sellPaymentDetailsWrap}>
|
444
|
+
<div className={styles.sellQRPayementWrap}>
|
445
|
+
<div className={styles.sellAmtDetails}>
|
446
|
+
<div className={styles.sellAmtDetailsWrap}>
|
447
|
+
<div className={styles.sellAmtPay}>
|
448
|
+
<span className={styles.sellPayLabel}>You Pay </span>
|
449
|
+
<span className={styles.sellPayAmt}>
|
450
|
+
{tokenSellData.from_amount} {tokenSellData.selectedCrypto}{" "}
|
451
|
+
{["USDT", "USDC"].includes(tokenSellData.selectedCrypto) &&
|
452
|
+
tokenSellData.network_type
|
453
|
+
? `(${tokenSellData.network_type})`
|
454
|
+
: ""}
|
455
|
+
</span>
|
456
|
+
</div>
|
457
|
+
<div className={styles.sellAmtGet}>
|
458
|
+
<span className={styles.sellPayLabel}>You Get </span>
|
459
|
+
<span className={styles.sellPayAmt}>
|
460
|
+
{tokenSellData.to_currency_conversion_value?.toFixed(4)}{" "}
|
461
|
+
{tokenSellData.selectedFiat}
|
462
|
+
</span>
|
463
|
+
</div>
|
464
|
+
</div>
|
465
|
+
<div className={styles.sellEstimatedInfo}>
|
466
|
+
<p>
|
467
|
+
{" "}
|
468
|
+
<span>Estimated Rate </span>{" "}
|
469
|
+
<span>
|
470
|
+
1 {tokenSellData.selectedCrypto} ={" "}
|
471
|
+
{!isNaN(tokenSellData.exchange_rate)
|
472
|
+
? tokenSellData.exchange_rate.toFixed(4)
|
473
|
+
: 0.0}{" "}
|
474
|
+
{tokenSellData.selectedFiat}
|
475
|
+
</span>
|
476
|
+
</p>
|
477
|
+
</div>
|
478
|
+
</div>
|
479
|
+
<div className={styles.sellPaymentQRBox}>
|
480
|
+
<div className={styles.sellPaymentQRFrame}>
|
481
|
+
{generatedQr ? (
|
482
|
+
<QRCodeCanvas
|
483
|
+
value={generatedQr}
|
484
|
+
size={128}
|
485
|
+
bgColor={"#ffffff"}
|
486
|
+
fgColor={"#000000"}
|
487
|
+
level={"H"}
|
488
|
+
/>
|
489
|
+
) : (
|
490
|
+
<CommonCenterLoader />
|
491
|
+
)}
|
492
|
+
</div>
|
493
|
+
</div>
|
494
|
+
</div>
|
495
|
+
</div>
|
496
|
+
<form onSubmit={onSubmit}>
|
497
|
+
<div className={styles.selllWalletAddressCard}>
|
498
|
+
{sellStaticCaseWallet ||
|
499
|
+
(adminWallet && (
|
500
|
+
<div className={styles.sellWalletDataCard}>
|
501
|
+
<h6>Wallet Address</h6>
|
502
|
+
<div className={styles.sellWalletCodeCard}>
|
503
|
+
<div className={styles.sellWalletCode}>
|
504
|
+
<span> {adminWallet}</span>{" "}
|
505
|
+
</div>
|
506
|
+
<button
|
507
|
+
className={`${styles.actionBtn} ${styles.overlay}`}
|
508
|
+
type="button"
|
509
|
+
onClick={async () => {
|
510
|
+
await navigator.clipboard.writeText(adminWallet);
|
511
|
+
addToast("Copied", "success");
|
512
|
+
}}
|
513
|
+
>
|
514
|
+
<svg
|
515
|
+
xmlns="http://www.w3.org/2000/svg"
|
516
|
+
width="20"
|
517
|
+
height="20"
|
518
|
+
viewBox="0 0 24 24"
|
519
|
+
fill="none"
|
520
|
+
stroke="#298BFF"
|
521
|
+
stroke-width="2"
|
522
|
+
stroke-linecap="round"
|
523
|
+
stroke-linejoin="round"
|
524
|
+
className="icon icon-tabler icons-tabler-outline icon-tabler-copy"
|
525
|
+
>
|
526
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
527
|
+
<path d="M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" />
|
528
|
+
<path d="M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" />
|
529
|
+
</svg>
|
530
|
+
</button>
|
531
|
+
</div>
|
532
|
+
</div>
|
533
|
+
))}
|
534
|
+
<div className={styles.sellHashBox}>
|
535
|
+
<div
|
536
|
+
style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}
|
537
|
+
>
|
538
|
+
<div className={styles.sellHashLabel}>
|
539
|
+
Transaction Hash <span>*</span>
|
540
|
+
</div>
|
541
|
+
{/* {automaticHash ? (
|
542
|
+
<button
|
543
|
+
className={styles.manualHashBtn}
|
544
|
+
style={{ fontSize: "0.8em" }}
|
545
|
+
onClick={() => handleManualHash()}
|
546
|
+
>
|
547
|
+
Enter Manually
|
548
|
+
</button>
|
549
|
+
) : null} */}
|
550
|
+
</div>
|
551
|
+
<input
|
552
|
+
className={styles.sellHashFields}
|
553
|
+
type="text"
|
554
|
+
placeholder={"Enter Transaction Hash"}
|
555
|
+
name="transaction_hash"
|
556
|
+
onChange={(e) => setTransactionHash(e.target.value)}
|
557
|
+
ref={inputRef}
|
558
|
+
disabled={automaticHash}
|
559
|
+
// disabled={tokenSell.buttonDisable}
|
560
|
+
/>
|
561
|
+
{/* {!transactionHash && <p className="errorMsg">Required</p>} */}
|
562
|
+
</div>
|
563
|
+
</div>
|
564
|
+
<div className={styles.efiSwapAction}>
|
565
|
+
{monitoring || selltokensLoading || transactionSuccess ? (
|
566
|
+
<div className="mt-3">
|
567
|
+
<ButtonStepper props={tokenSell} monitoring={monitoring} />
|
568
|
+
</div>
|
569
|
+
) : (
|
570
|
+
<button
|
571
|
+
className={`${styles.actionBtn} ${styles.primary}`}
|
572
|
+
onClick={(e) => {
|
573
|
+
e.preventDefault();
|
574
|
+
onSubmit();
|
575
|
+
}}
|
576
|
+
disabled={!transactionHash || selltokensLoading}
|
577
|
+
>
|
578
|
+
{selltokensLoading ? <ButtonLoader /> : "Submit"}
|
579
|
+
</button>
|
580
|
+
)}
|
581
|
+
</div>
|
582
|
+
</form>
|
583
|
+
</>
|
584
|
+
) : (
|
585
|
+
<>
|
586
|
+
<div className={styles.no_wallet_details}>
|
587
|
+
<p>No Wallet Details Found</p>
|
588
|
+
<div>
|
589
|
+
<button
|
590
|
+
className={`${styles.actionBtn} ${styles.primary}`}
|
591
|
+
onClick={() => fetchAdminWallet()}
|
592
|
+
>
|
593
|
+
Retry
|
594
|
+
</button>
|
595
|
+
</div>
|
596
|
+
</div>
|
597
|
+
</>
|
598
|
+
)}
|
599
|
+
</>
|
600
|
+
);
|
601
|
+
};
|
602
|
+
|
603
|
+
export default SellAdminCryptoAccount;
|