Skip to content

Commit

Permalink
evm error resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
Ans155 committed Jun 22, 2023
1 parent f7424f5 commit cd5f53e
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 22 deletions.
1 change: 1 addition & 0 deletions components/Friend/Card/Card.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
padding: 1rem;
border-bottom: 1px solid #f1820342;
cursor: pointer;
width:20%;

}

Expand Down
18 changes: 8 additions & 10 deletions components/Friend/Chat/Chat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import images from "../../../assets";
import { convertTime } from '../../../utils/apiFeature';
import { Loader } from '../../index';
import { useRouter } from 'next/router';
const Chat = ({functionName, readMessage, friendMsg, account, userName, Loading, currentUserName, currentUserAddress}) => {
const Chat = ({sendMessage, readMessage, friendMsg, account, userName, Loading, currentUserName, currentUserAddress}) => {

const [message, setMessage] = useState('');
const [chatData, setChatData] = useState({name:"", address:""});
Expand Down Expand Up @@ -72,16 +72,14 @@ const Chat = ({functionName, readMessage, friendMsg, account, userName, Loading,
{currentUserName && currentUserAddress ?(
<div className={Style.Chat_box_send}>
<div className={Style.Chat_box_send_img}>
<Image src={images.smile} alt='smile' width={50} height={50}/>
<Image src={images.smile} alt='smile' width={30} height={30}/>
<input type='text' placeholder='send your message' onChange={(e)=> setMessage(e.target.value)} />
<Image src={images.file} alt="file" width={50} height={50} />
{
Loading==true ? (
<Loader />
) : (
<Image src={images.send} alt="file" width={50} height={50} onClick={() => functionName({msg:message, address:chatData})}/>
)
}
<Image src={images.file} alt="file" width={30} height={30} />
<>
<small>{message} {chatData.address}</small>
<Image src={images.send} alt="send" width={30} height={30} onClick={() => sendMessage({ msg: message, address: chatData.address})}/>
</>

</div>
</div>

Expand Down
9 changes: 6 additions & 3 deletions components/Friend/Chat/Chat.module.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
.Chat{
position:absolute;
top:14rem;
left:40rem;
padding: 2rem;
background-color: rgba(0, 0, 0, 0.25);
border-radius: .5rem;
overflow-y: scroll;
width:50%

}

Expand Down Expand Up @@ -43,9 +46,9 @@
background-color: #f182035b;
outline: none;
border: none;
padding: 1rem;
padding: 0.5rem;
color: #f18203;
border-radius: .5rem;
border-radius: 1rem;
}

.Chat_user_info{
Expand Down
2 changes: 1 addition & 1 deletion components/Friend/friend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Friend = () => {
</div>
<div className={Style.Friend_box_right}>
<Chat
functionName={sendMessage}
sendMessage={sendMessage}
readMessage={readMessage}
friendMsg={friendMsg}
account={account}
Expand Down
2 changes: 1 addition & 1 deletion components/Friend/friend.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
padding: 1rem;
border-radius: .5rem;
color:#FFFFFF;
width:40%;
width:30%;
}

@media only screen and (max-width: 35rem) {
Expand Down
8 changes: 5 additions & 3 deletions context/AppContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,20 @@ export const AppProvider = ({ children }) => {

const sendMessage = async ({msg, address}) => {
try {
if(msg ||address) return setError("name and account must be there");
console.log(msg);
console.log(address);
const contract = await connectingWithContract();

const addMessage =await contract.sendMessage({address, msg});
const addMessage =await contract.sendMessage(address, msg);
setLoading(true);
await addMessage.wait();
setLoading(false);
//router.push("/");
window.location.reload();

} catch (error) {
setError("error while creating account, please reload");
setError("bhosda");
console.log(error);
}
};

Expand Down
4 changes: 2 additions & 2 deletions context/ChatApp.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/chatApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ contract ChatApp{
else return keccak256(abi.encodePacked(pubkey2,pubkey1));
}

function sendMessage(address friend_key, string calldata _msg) external{
function sendMessage(address friend_key,string calldata _msg) external{
require(checkUserExists(msg.sender), "Create an account first");
require(checkUserExists(friend_key), "User is not registered");
require(checkAlreadyFriends(msg.sender, friend_key), "You are not friends");
Expand Down
3 changes: 2 additions & 1 deletion styles/globals.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
body {
font-family: Arial, sans-serif;
background-color: #292f3f
background-color: #292f3f;
color: #FFFFFF;
}

0 comments on commit cd5f53e

Please sign in to comment.