ltc section

This commit is contained in:
Phillip Lang Martinez 2024-07-17 20:53:38 -04:00
parent 0399c9d147
commit a743be7c0b
6 changed files with 257 additions and 156 deletions

26
package-lock.json generated
View File

@ -10,6 +10,7 @@
"dependencies": { "dependencies": {
"@emotion/react": "^11.11.4", "@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0", "@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.16.4",
"@mui/material": "^5.15.14", "@mui/material": "^5.15.14",
"@testing-library/jest-dom": "^6.4.6", "@testing-library/jest-dom": "^6.4.6",
"@testing-library/user-event": "^14.5.2", "@testing-library/user-event": "^14.5.2",
@ -1221,6 +1222,31 @@
"url": "https://opencollective.com/mui-org" "url": "https://opencollective.com/mui-org"
} }
}, },
"node_modules/@mui/icons-material": {
"version": "5.16.4",
"resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.16.4.tgz",
"integrity": "sha512-j9/CWctv6TH6Dou2uR2EH7UOgu79CW/YcozxCYVLJ7l03pCsiOlJ5sBArnWJxJ+nGkFwyL/1d1k8JEPMDR125A==",
"dependencies": {
"@babel/runtime": "^7.23.9"
},
"engines": {
"node": ">=12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/mui-org"
},
"peerDependencies": {
"@mui/material": "^5.0.0",
"@types/react": "^17.0.0 || ^18.0.0",
"react": "^17.0.0 || ^18.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/@mui/material": { "node_modules/@mui/material": {
"version": "5.15.14", "version": "5.15.14",
"resolved": "https://registry.npmjs.org/@mui/material/-/material-5.15.14.tgz", "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.15.14.tgz",

View File

@ -14,6 +14,7 @@
"dependencies": { "dependencies": {
"@emotion/react": "^11.11.4", "@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0", "@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.16.4",
"@mui/material": "^5.15.14", "@mui/material": "^5.15.14",
"@testing-library/jest-dom": "^6.4.6", "@testing-library/jest-dom": "^6.4.6",
"@testing-library/user-event": "^14.5.2", "@testing-library/user-event": "^14.5.2",

View File

@ -3,14 +3,16 @@ import reactLogo from "./assets/react.svg";
import viteLogo from "/vite.svg"; import viteLogo from "/vite.svg";
import "./App.css"; import "./App.css";
import { useDropzone } from "react-dropzone"; import { useDropzone } from "react-dropzone";
import { Box, Input, InputLabel, Tooltip, Typography } from "@mui/material"; import { Box, CircularProgress, Input, InputLabel, Tooltip, Typography } from "@mui/material";
import { decryptStoredWallet } from "./utils/decryptWallet"; import { decryptStoredWallet } from "./utils/decryptWallet";
import { CountdownCircleTimer } from "react-countdown-circle-timer"; import { CountdownCircleTimer } from "react-countdown-circle-timer";
import Logo1 from "./assets/svgs/Logo1.svg"; import Logo1 from "./assets/svgs/Logo1.svg";
import Logo1Dark from "./assets/svgs/Logo1Dark.svg"; import Logo1Dark from "./assets/svgs/Logo1Dark.svg";
import RefreshIcon from '@mui/icons-material/Refresh';
import Logo2 from "./assets/svgs/Logo2.svg"; import Logo2 from "./assets/svgs/Logo2.svg";
import Copy from "./assets/svgs/Copy.svg"; import Copy from "./assets/svgs/Copy.svg";
import ltcLogo from './assets/ltc.png';
import qortLogo from './assets/qort.png'
import { CopyToClipboard } from "react-copy-to-clipboard"; import { CopyToClipboard } from "react-copy-to-clipboard";
import Download from "./assets/svgs/Download.svg"; import Download from "./assets/svgs/Download.svg";
import Logout from "./assets/svgs/Logout.svg"; import Logout from "./assets/svgs/Logout.svg";
@ -63,13 +65,16 @@ function App() {
const [extState, setExtstate] = useState<extStates>("not-authenticated"); const [extState, setExtstate] = useState<extStates>("not-authenticated");
const [backupjson, setBackupjson] = useState<any>(null); const [backupjson, setBackupjson] = useState<any>(null);
const [rawWallet, setRawWallet] = useState<any>(null); const [rawWallet, setRawWallet] = useState<any>(null);
const [ltcBalanceLoading, setLtcBalanceLoading] = useState<boolean>(false);
const [qortBalanceLoading, setQortBalanceLoading] = useState<boolean>(false)
const [decryptedWallet, setdecryptedWallet] = useState<any>(null); const [decryptedWallet, setdecryptedWallet] = useState<any>(null);
const [requestConnection, setRequestConnection] = useState<any>(null); const [requestConnection, setRequestConnection] = useState<any>(null);
const [requestBuyOrder, setRequestBuyOrder] = useState<any>(null); const [requestBuyOrder, setRequestBuyOrder] = useState<any>(null);
const [authenticatedMode, setAuthenticatedMode] = useState('qort')
const [requestAuthentication, setRequestAuthentication] = useState<any>(null); const [requestAuthentication, setRequestAuthentication] = useState<any>(null);
const [userInfo, setUserInfo] = useState<any>(null); const [userInfo, setUserInfo] = useState<any>(null);
const [balance, setBalance] = useState<any>(null); const [balance, setBalance] = useState<any>(null);
const [ltcBalance, setLtcBalance] = useState<any>(null)
const [paymentTo, setPaymentTo] = useState<string>(""); const [paymentTo, setPaymentTo] = useState<string>("");
const [paymentAmount, setPaymentAmount] = useState<number>(0); const [paymentAmount, setPaymentAmount] = useState<number>(0);
const [paymentPassword, setPaymentPassword] = useState<string>(""); const [paymentPassword, setPaymentPassword] = useState<string>("");
@ -79,7 +84,7 @@ function App() {
const [walletToBeDownloaded, setWalletToBeDownloaded] = useState<any>(null); const [walletToBeDownloaded, setWalletToBeDownloaded] = useState<any>(null);
const [walletToBeDownloadedPassword, setWalletToBeDownloadedPassword] = const [walletToBeDownloadedPassword, setWalletToBeDownloadedPassword] =
useState<string>(""); useState<string>("");
const [authenticatePassword, setAuthenticatePassword] = const [authenticatePassword, setAuthenticatePassword] =
useState<string>(""); useState<string>("");
const [sendqortState, setSendqortState] = useState<any>(null); const [sendqortState, setSendqortState] = useState<any>(null);
const [isLoading, setIsLoading] = useState<boolean>(false) const [isLoading, setIsLoading] = useState<boolean>(false)
@ -89,11 +94,11 @@ function App() {
] = useState<string>(""); ] = useState<string>("");
const [walletToBeDownloadedError, setWalletToBeDownloadedError] = const [walletToBeDownloadedError, setWalletToBeDownloadedError] =
useState<string>(""); useState<string>("");
const [walletToBeDecryptedError, setWalletToBeDecryptedError] = const [walletToBeDecryptedError, setWalletToBeDecryptedError] =
useState<string>(""); useState<string>("");
const holdRefExtState = useRef<extStates>("not-authenticated") const holdRefExtState = useRef<extStates>("not-authenticated")
useEffect(()=> { useEffect(() => {
if(extState){ if (extState) {
holdRefExtState.current = extState holdRefExtState.current = extState
} }
}, [extState]) }, [extState])
@ -129,7 +134,7 @@ function App() {
try { try {
if (typeof fileContents !== "string") return; if (typeof fileContents !== "string") return;
pf = JSON.parse(fileContents); pf = JSON.parse(fileContents);
} catch (e) {} } catch (e) { }
try { try {
const requiredFields = [ const requiredFields = [
@ -167,7 +172,7 @@ function App() {
wallet = await wallet2.generateSaveWalletData( wallet = await wallet2.generateSaveWalletData(
password, password,
crypto.kdfThreads, crypto.kdfThreads,
() => {} () => { }
); );
setWalletToBeDownloaded({ setWalletToBeDownloaded({
@ -205,10 +210,21 @@ function App() {
const getBalanceFunc = () => { const getBalanceFunc = () => {
setQortBalanceLoading(true)
chrome.runtime.sendMessage({ action: "balance" }, (response) => { chrome.runtime.sendMessage({ action: "balance" }, (response) => {
if (response && !response?.error) { if (response && !response?.error) {
setBalance(response); setBalance(response);
} }
setQortBalanceLoading(false)
});
};
const getLtcBalanceFunc = () => {
setLtcBalanceLoading(true)
chrome.runtime.sendMessage({ action: "ltcBalance" }, (response) => {
if (response && !response?.error) {
setLtcBalance(response);
}
setLtcBalanceLoading(false)
}); });
}; };
const sendCoinFunc = () => { const sendCoinFunc = () => {
@ -349,7 +365,7 @@ function App() {
}, },
}, },
(response) => { (response) => {
window.close(); window.close();
} }
); );
return; return;
@ -361,8 +377,8 @@ function App() {
action: "buyOrderConfirmation", action: "buyOrderConfirmation",
payload: { payload: {
crosschainAtInfo: requestBuyOrder?.crosschainAtInfo, crosschainAtInfo: requestBuyOrder?.crosschainAtInfo,
interactionId: requestBuyOrder?.interactionId, interactionId: requestBuyOrder?.interactionId,
isDecline: false, isDecline: false,
}, },
}, },
(response) => { (response) => {
@ -409,11 +425,11 @@ function App() {
chrome.runtime.sendMessage({ action: "getWalletInfo" }, (response) => { chrome.runtime.sendMessage({ action: "getWalletInfo" }, (response) => {
if (response && response?.walletInfo) { if (response && response?.walletInfo) {
setRawWallet(response?.walletInfo); setRawWallet(response?.walletInfo);
if(holdRefExtState.current === 'web-app-request-payment' || holdRefExtState.current === 'web-app-request-connection' || holdRefExtState.current === 'web-app-request-buy-order') return if (holdRefExtState.current === 'web-app-request-payment' || holdRefExtState.current === 'web-app-request-connection' || holdRefExtState.current === 'web-app-request-buy-order') return
setExtstate("authenticated"); setExtstate("authenticated");
} }
}); });
} catch (error) {} finally { } catch (error) { } finally {
setIsLoading(false) setIsLoading(false)
} }
}, []); }, []);
@ -427,7 +443,8 @@ function App() {
} }
}); });
getBalanceFunc(); getBalanceFunc();
} catch (error) {} getLtcBalanceFunc()
} catch (error) { }
}, [address]); }, [address]);
useEffect(() => { useEffect(() => {
@ -444,8 +461,8 @@ function App() {
return; return;
} }
setIsLoading(true) setIsLoading(true)
await new Promise<void>((res)=> { await new Promise<void>((res) => {
setTimeout(()=> { setTimeout(() => {
res() res()
}, 250) }, 250)
}) })
@ -487,8 +504,8 @@ function App() {
return; return;
} }
setIsLoading(true) setIsLoading(true)
await new Promise<void>((res)=> { await new Promise<void>((res) => {
setTimeout(()=> { setTimeout(() => {
res() res()
}, 250) }, 250)
}) })
@ -496,12 +513,14 @@ function App() {
const wallet = await res.generateSaveWalletData( const wallet = await res.generateSaveWalletData(
walletToBeDownloadedPassword, walletToBeDownloadedPassword,
crypto.kdfThreads, crypto.kdfThreads,
() => {} () => { }
); );
chrome.runtime.sendMessage({ action: "decryptWallet", payload: { chrome.runtime.sendMessage({
password: walletToBeDownloadedPassword, action: "decryptWallet", payload: {
wallet password: walletToBeDownloadedPassword,
} }, (response) => { wallet
}
}, (response) => {
if (response && !response?.error) { if (response && !response?.error) {
setRawWallet(wallet); setRawWallet(wallet);
setWalletToBeDownloaded({ setWalletToBeDownloaded({
@ -515,7 +534,7 @@ function App() {
} }
}); });
getBalanceFunc(); getBalanceFunc();
} else if(response?.error){ } else if (response?.error) {
setIsLoading(false) setIsLoading(false)
setWalletToBeDecryptedError(response.error) setWalletToBeDecryptedError(response.error)
} }
@ -536,7 +555,7 @@ function App() {
resetAllStates(); resetAllStates();
} }
}); });
} catch (error) {} } catch (error) { }
}; };
const returnToMain = () => { const returnToMain = () => {
@ -561,6 +580,7 @@ function App() {
setRequestAuthentication(null); setRequestAuthentication(null);
setUserInfo(null); setUserInfo(null);
setBalance(null); setBalance(null);
setLtcBalance(null)
setPaymentTo(""); setPaymentTo("");
setPaymentAmount(0); setPaymentAmount(0);
setPaymentPassword(""); setPaymentPassword("");
@ -574,19 +594,21 @@ function App() {
setSendqortState(null); setSendqortState(null);
}; };
const authenticateWallet = async()=> { const authenticateWallet = async () => {
try { try {
setIsLoading(true) setIsLoading(true)
setWalletToBeDecryptedError('') setWalletToBeDecryptedError('')
await new Promise<void>((res)=> { await new Promise<void>((res) => {
setTimeout(()=> { setTimeout(() => {
res() res()
}, 250) }, 250)
}) })
chrome.runtime.sendMessage({ action: "decryptWallet", payload: { chrome.runtime.sendMessage({
password: authenticatePassword, action: "decryptWallet", payload: {
wallet: rawWallet password: authenticatePassword,
} }, (response) => { wallet: rawWallet
}
}, (response) => {
if (response && !response?.error) { if (response && !response?.error) {
setAuthenticatePassword(""); setAuthenticatePassword("");
setExtstate("authenticated"); setExtstate("authenticated");
@ -598,7 +620,7 @@ function App() {
} }
}); });
getBalanceFunc(); getBalanceFunc();
} else if(response?.error){ } else if (response?.error) {
setIsLoading(false) setIsLoading(false)
setWalletToBeDecryptedError(response.error) setWalletToBeDecryptedError(response.error)
} }
@ -684,55 +706,91 @@ function App() {
<AuthenticatedContainer> <AuthenticatedContainer>
<AuthenticatedContainerInnerLeft> <AuthenticatedContainerInnerLeft>
<Spacer height="48px" /> <Spacer height="48px" />
<img src={Logo2} />
<Spacer height="32px" /> {authenticatedMode === 'ltc' ? (
<TextP <>
sx={{ <img src={ltcLogo} />
textAlign: "center", <Spacer height="32px" />
lineHeight: "24px", <CopyToClipboard text={rawWallet?.ltcAddress}>
fontSize: "20px", <AddressBox>
}} {rawWallet?.ltcAddress?.slice(0, 6)}...
> {rawWallet?.ltcAddress?.slice(-4)} <img src={Copy} />
{userInfo?.name} </AddressBox>
</TextP> </CopyToClipboard>
<Spacer height="10px" /> <Spacer height="10px" />
<CopyToClipboard text={rawWallet?.address0}> {ltcBalanceLoading && <CircularProgress color="success" size={16} />}
<AddressBox> {ltcBalance && !ltcBalanceLoading && (
{rawWallet?.address0?.slice(0, 6)}... <Box sx={{
{rawWallet?.address0?.slice(-4)} <img src={Copy} /> gap: '10px',
</AddressBox> display: 'flex',
</CopyToClipboard> alignItems: 'center'
<Spacer height="10px" /> }}>
{balance && ( <TextP
<TextP sx={{
sx={{ textAlign: "center",
textAlign: "center", lineHeight: "24px",
lineHeight: "24px", fontSize: "20px",
fontSize: "20px", fontWeight: 700,
fontWeight: 700, }}
}} >
> {ltcBalance?.toFixed(5)} LTC
{balance?.toFixed(2)} QORT </TextP>
</TextP> <RefreshIcon onClick={getLtcBalanceFunc} sx={{
fontSize: '16px',
color: 'white',
cursor: 'pointer'
}} />
</Box>
)}
</>
) : (
<>
<img src={Logo2} />
<Spacer height="32px" />
<TextP
sx={{
textAlign: "center",
lineHeight: "24px",
fontSize: "20px",
}}
>
{userInfo?.name}
</TextP>
<Spacer height="10px" />
<CopyToClipboard text={rawWallet?.address0}>
<AddressBox>
{rawWallet?.address0?.slice(0, 6)}...
{rawWallet?.address0?.slice(-4)} <img src={Copy} />
</AddressBox>
</CopyToClipboard>
<Spacer height="10px" />
{qortBalanceLoading && <CircularProgress color="success" size={16} />}
{balance && (
<TextP
sx={{
textAlign: "center",
lineHeight: "24px",
fontSize: "20px",
fontWeight: 700,
}}
>
{balance?.toFixed(2)} QORT
</TextP>
)}
<Spacer height="55px" />
<CustomButton
onClick={() => {
setExtstate("send-qort");
}}
>
Transfer QORT
</CustomButton>
</>
)} )}
{/* <p>balance: {balance}</p> */}
<Spacer height="55px" />
{/* <CustomButton
onClick={() => {
setExtstate("download-wallet");
}}
>
Download Wallet
</CustomButton> */}
<CustomButton
onClick={() => {
setExtstate("send-qort");
}}
>
Transfer QORT
</CustomButton>
</AuthenticatedContainerInnerLeft> </AuthenticatedContainerInnerLeft>
<AuthenticatedContainerInnerRight> <AuthenticatedContainerInnerRight>
<Spacer height="20px" /> <Spacer height="20px" />
@ -753,6 +811,25 @@ function App() {
cursor: "pointer", cursor: "pointer",
}} }}
/> />
<Spacer height="20px" />
{authenticatedMode === 'qort' && (
<img onClick={() => {
setAuthenticatedMode('ltc')
}} src={ltcLogo} style={{
cursor: "pointer",
width: '20px',
height: 'auto'
}} />
)}
{authenticatedMode === 'ltc' && (
<img onClick={() => {
setAuthenticatedMode('qort')
}} src={qortLogo} style={{
cursor: "pointer",
width: '20px',
height: 'auto'
}} />
)}
</AuthenticatedContainerInnerRight> </AuthenticatedContainerInnerRight>
</AuthenticatedContainer> </AuthenticatedContainer>
)} )}
@ -865,7 +942,7 @@ function App() {
</CustomButton> </CustomButton>
</> </>
)} )}
{extState === "web-app-request-buy-order" && ( {extState === "web-app-request-buy-order" && (
<> <>
<Spacer height="100px" /> <Spacer height="100px" />
@ -1143,7 +1220,7 @@ function App() {
style={{ style={{
cursor: "pointer", cursor: "pointer",
}} }}
onClick={()=> { onClick={() => {
setRawWallet(null); setRawWallet(null);
setExtstate("not-authenticated"); setExtstate("not-authenticated");
}} }}
@ -1179,31 +1256,31 @@ function App() {
</Box> </Box>
<Spacer height="35px" /> <Spacer height="35px" />
<> <>
<CustomLabel htmlFor="standard-adornment-password"> <CustomLabel htmlFor="standard-adornment-password">
Wallet Password Wallet Password
</CustomLabel> </CustomLabel>
<Spacer height="5px" /> <Spacer height="5px" />
<PasswordField <PasswordField
id="standard-adornment-password" id="standard-adornment-password"
value={authenticatePassword} value={authenticatePassword}
onChange={(e) => onChange={(e) =>
setAuthenticatePassword(e.target.value) setAuthenticatePassword(e.target.value)
}
onKeyDown={(e) => {
if (e.key === "Enter") {
authenticateWallet();
} }
onKeyDown={(e) => { }}
if (e.key === "Enter") { />
authenticateWallet(); <Spacer height="20px" />
} <CustomButton onClick={authenticateWallet} >
}} Authenticate
/> </CustomButton>
<Spacer height="20px" /> <ErrorText>
<CustomButton onClick={authenticateWallet} > {walletToBeDecryptedError}
Authenticate </ErrorText>
</CustomButton> </>
<ErrorText>
{walletToBeDecryptedError}
</ErrorText>
</>
</> </>
)} )}
{extState === "download-wallet" && ( {extState === "download-wallet" && (
@ -1290,34 +1367,34 @@ function App() {
<> <>
{!walletToBeDownloaded && ( {!walletToBeDownloaded && (
<> <>
<Spacer height="22px" /> <Spacer height="22px" />
<Box <Box
sx={{ sx={{
display: "flex", display: "flex",
width: "100%", width: "100%",
justifyContent: "flex-start", justifyContent: "flex-start",
paddingLeft: "22px", paddingLeft: "22px",
boxSizing: "border-box", boxSizing: "border-box",
}} }}
> >
<img <img
style={{ style={{
cursor: "pointer", cursor: "pointer",
}} }}
onClick={()=> { onClick={() => {
setExtstate("not-authenticated") setExtstate("not-authenticated")
}} }}
src={Return} src={Return}
/> />
</Box> </Box>
<Spacer height="15px" /> <Spacer height="15px" />
<div className="image-container" style={{ <div className="image-container" style={{
width: '136px', width: '136px',
height: '154px' height: '154px'
}}> }}>
<img src={Logo1} className="base-image" /> <img src={Logo1} className="base-image" />
<img src={Logo1Dark} className="hover-image" /> <img src={Logo1Dark} className="hover-image" />
</div> </div>
<Spacer height="38px" /> <Spacer height="38px" />
<TextP <TextP
sx={{ sx={{

BIN
src/assets/ltc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
src/assets/qort.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -113,7 +113,6 @@ async function connection(hostname) {
async function getTradeInfo(qortalAtAddress) { async function getTradeInfo(qortalAtAddress) {
const response = await fetch(buyTradeNodeBaseUrl + "/crosschain/trade/" + qortalAtAddress); const response = await fetch(buyTradeNodeBaseUrl + "/crosschain/trade/" + qortalAtAddress);
console.log({})
if (!response?.ok) throw new Error("Cannot crosschain trade information"); if (!response?.ok) throw new Error("Cannot crosschain trade information");
const data = await response.json(); const data = await response.json();
return data; return data;
@ -283,7 +282,7 @@ async function decryptWallet({ password, wallet, walletVersion }) {
const keyPair = wallet2._addresses[0].keyPair; const keyPair = wallet2._addresses[0].keyPair;
const ltcPrivateKey = wallet2._addresses[0].ltcWallet.derivedMasterPrivateKey const ltcPrivateKey = wallet2._addresses[0].ltcWallet.derivedMasterPrivateKey
const ltcPublicKey = wallet2._addresses[0].ltcWallet.derivedMasterPublicKey const ltcPublicKey = wallet2._addresses[0].ltcWallet.derivedMasterPublicKey
const ltcAddress = wallet2._addresses[0].ltcWallet.address
const toSave = { const toSave = {
privateKey: Base58.encode(keyPair.privateKey), privateKey: Base58.encode(keyPair.privateKey),
publicKey: Base58.encode(keyPair.publicKey), publicKey: Base58.encode(keyPair.publicKey),
@ -302,7 +301,8 @@ async function decryptWallet({ password, wallet, walletVersion }) {
}); });
const newWallet = { const newWallet = {
...wallet, ...wallet,
publicKey: Base58.encode(keyPair.publicKey) publicKey: Base58.encode(keyPair.publicKey),
ltcAddress: ltcAddress
} }
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
chrome.storage.local.set({ walletInfo: newWallet }, () => { chrome.storage.local.set({ walletInfo: newWallet }, () => {
@ -322,7 +322,6 @@ async function decryptWallet({ password, wallet, walletVersion }) {
} }
async function signChatFunc(chatBytesArray, chatNonce, validApi, keyPair) { async function signChatFunc(chatBytesArray, chatNonce, validApi, keyPair) {
console.log({ chatBytesArray, chatNonce, validApi, keyPair })
let response let response
try { try {
const signedChatBytes = signChat( const signedChatBytes = signChat(
@ -569,7 +568,6 @@ async function fetchMessagesForBuyOrders(apiCall, signature, senderPublicKey) {
const response = await fetch(apiCall); const response = await fetch(apiCall);
let data = await response.json(); let data = await response.json();
data = data.filter((item) => !triedChatMessage.includes(item.signature)) data = data.filter((item) => !triedChatMessage.includes(item.signature))
console.log({data})
if (data && data.length > 0) { if (data && data.length > 0) {
const encodedMessageObj = data[0] const encodedMessageObj = data[0]
const resKeyPair = await getKeyPair() const resKeyPair = await getKeyPair()
@ -583,7 +581,6 @@ async function fetchMessagesForBuyOrders(apiCall, signature, senderPublicKey) {
const decodedMessage = decryptChatMessage(encodedMessageObj.data, keyPair.privateKey, senderPublicKey, encodedMessageObj.reference) const decodedMessage = decryptChatMessage(encodedMessageObj.data, keyPair.privateKey, senderPublicKey, encodedMessageObj.reference)
const parsedMessage = JSON.parse(decodedMessage) const parsedMessage = JSON.parse(decodedMessage)
console.log({parsedMessage})
if (parsedMessage?.extra?.chatRequestSignature === signature) { if (parsedMessage?.extra?.chatRequestSignature === signature) {
resolve(parsedMessage); resolve(parsedMessage);
} else { } else {