Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
koybasimuhittin committed Nov 19, 2023
2 parents 8cf3c06 + 7578f29 commit 3c3f776
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/hardhat/contracts/HarbergerNft.sol
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ contract HarbergerNft is ERC721, Owned {
prices[id] = newPrice;

forcedTransferFrom(oldOwner, msg.sender, id);
oldOwner.call{value: buyPrice}("");
emit Buy(id, newPrice, newExpirationDate);
(bool success, ) = oldOwner.call{value: buyPrice}("");
require(success, "Payment to old owner failed");
}

/// @notice sets custom resolver address for a token
Expand Down
4 changes: 4 additions & 0 deletions packages/nextjs/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
}

.input-box {
box-shadow: 0px 0px 10px 5px rgba(61, 185, 207, 0.50) inset, 0px 4px 15px 0px rgba(0, 0, 0, 0.50);
}
}

@layer base {
Expand Down
52 changes: 52 additions & 0 deletions packages/nextjs/hooks/usePush.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//yarn add @pushprotocol/restapi @pushprotocol/socket
import { PushAPI, ethersV5SignerType, CONSTANTS } from "@pushprotocol/restapi";
import { ENV } from "@pushprotocol/restapi/src/lib/constants";
const env = ENV.STAGING;

export const useChatStream = async (signer: ethersV5SignerType) => {
const user = await PushAPI.initialize(signer, { env });
const stream = user.initStream([CONSTANTS.STREAM.CHAT], {
filter: {
channels: ['*'], // pass in specific channels to only listen to those
chats: ['*'], // pass in specific chat ids to only listen to those
},
connection: {
retries: 3, // number of retries in case of error
},
raw: false // enable true to show all data
})
; (await stream).on(CONSTANTS.STREAM.CHAT, (data: any) => {
console.log('chat data', data)
return [data.from, data.content]
}
)
; (await stream).connect()
}

export const useChatSend = async (message: string, signer: ethersV5SignerType, to: string) => {
try {
const user = await PushAPI.initialize(signer, { env });
await user.chat.send(to, { content: `${message}`, type: "Text" })
}
catch (e) {
console.log(e)
throw e
}
}

export const useChatList = async (signer: ethersV5SignerType) => {
try {
const user = await PushAPI.initialize(signer, { env });
const chats = await user.chat.list("CHATS")
const mapped = chats.map((chat: any) => {
return {
address: chat.fromDID.split(":")[1],
content: chat.messageContent
}
}
)
} catch (e) {
console.log(e)
throw e
}
}
25 changes: 23 additions & 2 deletions packages/nextjs/pages/chat/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
import { useState } from "react";

export default function Home() {
return <></>
}
const [message, setMessage] = useState("");

return (
<>
<div className="w-full flex flex-col h-[760px] justify-end gap-3">
<div className="px-48">
Deneme
</div>
<div className="w-full flex focus:outline-none gap-6 justify-center items-center">
<input
className="flex gap-5 rounded-xl w-3/4 h-16 bg-white input-box px-4 text-[20px]"
onChange={(e) => setMessage(e.currentTarget.value)}
></input>
<button className="w-[150px] h-[70px] bg-[#3DB9CF] rounded-xl">
Send
</button>
</div>
</div>
</>
);
}

0 comments on commit 3c3f776

Please sign in to comment.