diff --git a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx index 20b26b84d..e5c68d7cf 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx @@ -29,7 +29,7 @@ const ChatViewComponentTest = () => { {/* {console.log('in close')}} modalBackground={MODAL_BACKGROUND_TYPE.OVERLAY} modalPositionType={MODAL_POSITION_TYPE.RELATIVE}/> */} console.log('Verification Failed')} - chatId="4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68" + chatId="34c44214589cecc176a136ee1daf0f0231ecc6d6574b920b5ae39eb971fa3cb4" chatProfileLeftHelperComponent={ console.debug('clicked')} /> } diff --git a/packages/restapi/src/lib/channels/subscribe.ts b/packages/restapi/src/lib/channels/subscribe.ts index a99723472..00b6216f9 100644 --- a/packages/restapi/src/lib/channels/subscribe.ts +++ b/packages/restapi/src/lib/channels/subscribe.ts @@ -4,14 +4,15 @@ import { getDomainInformation, getSubscriptionMessage, } from './signature.helpers'; -import Constants, {ENV} from '../constants'; -import { SignerType } from "../types"; -import { axiosPost } from "../utils/axiosUtil"; +import Constants, { ENV } from '../constants'; +import { SignerType } from '../types'; +import { axiosPost } from '../utils/axiosUtil'; export type SubscribeOptionsType = { signer: SignerType; channelAddress: string; userAddress: string; verifyingContractAddress?: string; + origin?: string; env?: ENV; onSuccess?: () => void; onError?: (err: Error) => void; @@ -23,6 +24,7 @@ export const subscribe = async (options: SubscribeOptionsType) => { channelAddress, userAddress, verifyingContractAddress, + origin, env = Constants.ENV.PROD, onSuccess, onError, @@ -86,6 +88,7 @@ export const subscribe = async (options: SubscribeOptionsType) => { channel: _channelAddress, subscriber: _userAddress, }, + origin: origin }; await axiosPost(requestUrl, body); diff --git a/packages/restapi/src/lib/channels/subscribeV2.ts b/packages/restapi/src/lib/channels/subscribeV2.ts index e37188c10..c38fdc456 100644 --- a/packages/restapi/src/lib/channels/subscribeV2.ts +++ b/packages/restapi/src/lib/channels/subscribeV2.ts @@ -15,6 +15,7 @@ export type SubscribeOptionsV2Type = { settings?: string | null; verifyingContractAddress?: string; env?: ENV; + origin?: string; onSuccess?: () => void; onError?: (err: Error) => void; }; @@ -27,6 +28,7 @@ export const subscribeV2 = async (options: SubscribeOptionsV2Type) => { settings = undefined, verifyingContractAddress, env = Constants.ENV.PROD, + origin, onSuccess, onError, } = options || {}; @@ -85,6 +87,7 @@ export const subscribeV2 = async (options: SubscribeOptionsV2Type) => { const body = { verificationProof: `eip712v2:${verificationProof}`, message: messageInformation.data, + origin: origin }; const res = await axiosPost(requestUrl, body); diff --git a/packages/restapi/src/lib/pushapi/PushAPI.ts b/packages/restapi/src/lib/pushapi/PushAPI.ts index e0bd220c7..a071234f1 100644 --- a/packages/restapi/src/lib/pushapi/PushAPI.ts +++ b/packages/restapi/src/lib/pushapi/PushAPI.ts @@ -28,6 +28,7 @@ export class PushAPI { private readMode: boolean; private alpha: { feature: string[] }; public account: string; + public chainWiseAccount: string; public decryptedPgpPvtKey?: string; public pgpPublicKey?: string; public env: ENV; @@ -65,6 +66,7 @@ export class PushAPI { this.alpha = alpha; this.env = env; this.account = account; + this.chainWiseAccount = walletToPCAIP10(account); this.decryptedPgpPvtKey = decryptedPgpPvtKey; this.pgpPublicKey = pgpPublicKey; this.progressHook = progressHook; @@ -274,7 +276,6 @@ export class PushAPI { readMode = true; } } - derivedAccount = walletToPCAIP10(derivedAccount); // Initialize PushAPI instance const api = new PushAPI( settings.env as ENV, diff --git a/packages/restapi/tests/lib/channel/subscribeV2.test.ts b/packages/restapi/tests/lib/channel/subscribeV2.test.ts index ba5453c85..ef2c9cb03 100644 --- a/packages/restapi/tests/lib/channel/subscribeV2.test.ts +++ b/packages/restapi/tests/lib/channel/subscribeV2.test.ts @@ -30,6 +30,7 @@ describe('PUSH_CHANNEL.subscribeV2 functionality', () => { channelAddress: 'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681', userAddress: `eip155:11155111:${account1}`, env: _env, + origin: 'test' }); expect(res.status).to.be.equal(204); }); diff --git a/packages/uiweb/package-lock.json b/packages/uiweb/package-lock.json index 898a92ce8..29a653a4a 100644 --- a/packages/uiweb/package-lock.json +++ b/packages/uiweb/package-lock.json @@ -1,12 +1,12 @@ { "name": "@pushprotocol/uiweb", - "version": "0.0.1-alpha.0", + "version": "1.4.0-alpha.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@pushprotocol/uiweb", - "version": "0.0.1-alpha.0", + "version": "1.4.0-alpha.4", "dependencies": { "@livepeer/react": "^2.6.0", "@pushprotocol/socket": "^0.5.0", diff --git a/packages/uiweb/package.json b/packages/uiweb/package.json index e14ab273f..07799c86d 100644 --- a/packages/uiweb/package.json +++ b/packages/uiweb/package.json @@ -1,6 +1,6 @@ { "name": "@pushprotocol/uiweb", - "version": "0.0.1-alpha.46", + "version": "1.4.0-alpha.4", "publishConfig": { "registry": "https://registry.npmjs.org/" }, @@ -37,7 +37,7 @@ "uuid": "^9.0.1" }, "peerDependencies": { - "@pushprotocol/restapi": "0.0.1-alpha.80", + "@pushprotocol/restapi": "1.7.13", "@pushprotocol/socket": "^0.5.0", "react": ">=16.8.0", "styled-components": "^6.0.8" diff --git a/packages/uiweb/src/lib/components/chat/ChatViewBubble/ChatViewBubble.tsx b/packages/uiweb/src/lib/components/chat/ChatViewBubble/ChatViewBubble.tsx index cd04730cf..ab9cbb9f2 100644 --- a/packages/uiweb/src/lib/components/chat/ChatViewBubble/ChatViewBubble.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatViewBubble/ChatViewBubble.tsx @@ -33,7 +33,7 @@ import { TwitterCard } from './cards/twitter/TwitterCard'; const SenderMessageAddress = ({ chat }: { chat: IMessagePayload }) => { const { user } = useContext(ChatDataContext); const theme = useContext(ThemeContext); - return chat.fromCAIP10?.split(':')[1] !== user?.account ? ( + return chat.fromCAIP10 !== user?.account ? ( { + const { user } = useChatData(); const theme = useContext(ThemeContext); return ( - {isGroup && } + {isGroup && chat?.fromCAIP10 !== user?.account && }
- {isGroup && } + {isGroup && chat?.fromCAIP10 !== user?.account && } {children}
@@ -174,12 +175,12 @@ export const ChatViewBubble = ({ }) => { const { user } = useChatData(); const position = - pCAIP10ToWallet(decryptedMessagePayload.fromDID).toLowerCase() !== user?.account?.toLowerCase() ? 0 : 1; - + pCAIP10ToWallet(decryptedMessagePayload.fromDID).toLowerCase() !== pCAIP10ToWallet(user?.account!)?.toLowerCase() + ? 0 + : 1; const { tweetId, messageType }: TwitterFeedReturnType = checkTwitterUrl({ message: decryptedMessagePayload?.messageContent, }); - if (messageType === 'TwitterFeedLink') { decryptedMessagePayload.messageType = 'TwitterFeedLink'; } diff --git a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx index ee171f859..a97c0d512 100644 --- a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx @@ -70,13 +70,9 @@ export const ChatViewList: React.FC = (options: IChatViewLis invalidChat: false, }); - const [loading, setLoading] = useState(true); - const { chatId, limit = chatLimit, chatFilterList = [] } = options || {}; const { user, toast } = useChatData(); - const [chatInfo, setChatInfo] = useState(null); const [groupInfo, setGroupInfo] = useState(null); - const [userInfo, setUserInfo] = useState(null); // const [chatStatusText, setChatStatusText] = useState(''); const [messages, setMessages] = useState([]); @@ -172,9 +168,9 @@ export const ChatViewList: React.FC = (options: IChatViewLis //moniters stream changes useEffect(() => { if (Object.keys(chatAcceptStream || {}).length > 0 && chatAcceptStream.constructor === Object) { - const updatedChatInfo = { ...(chatInfo as ChatInfoResponse) }; + const updatedChatInfo = { ...(initialized.chatInfo as ChatInfoResponse) }; if (updatedChatInfo) updatedChatInfo.list = 'CHATS'; - setChatInfo(updatedChatInfo); + setInitialized({ ...initialized, chatInfo: updatedChatInfo }); } }, [chatAcceptStream]); @@ -394,7 +390,9 @@ export const ChatViewList: React.FC = (options: IChatViewLis const dateNum = moment(chat.timestamp).format('L'); // TODO: This is a hack as chat.fromDID is converted with eip to match with user.account creating a bug for omnichain const position = - pCAIP10ToWallet(chat.fromDID)?.toLowerCase() !== user?.account?.toLowerCase() ? 0 : 1; + pCAIP10ToWallet(chat.fromDID)?.toLowerCase() !== pCAIP10ToWallet(user?.account!)?.toLowerCase() + ? 0 + : 1; return ( <> {dates.has(dateNum) ? null : renderDate({ chat, dateNum })} diff --git a/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx b/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx index 6f564ec87..87a3d811a 100644 --- a/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx +++ b/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx @@ -241,7 +241,7 @@ const AddCriteria = ({ handlePrevious, onClose, criteriaStateManager }: ModalHea function: () => setSelectedChainValue(6), } as DropdownValueType); } - + console.debug(dropdownChainsValues); const onQuantityChange = (e: any) => { setQuantity({ ...quantity, value: e.target.value }); }; @@ -263,6 +263,7 @@ const AddCriteria = ({ handlePrevious, onClose, criteriaStateManager }: ModalHea } } + console.debug(selectedChainValue); const rule: Rule = { type: _type, category: category, diff --git a/packages/uiweb/src/lib/components/chat/MessageInput/MessageInput.tsx b/packages/uiweb/src/lib/components/chat/MessageInput/MessageInput.tsx index 658c63127..adec52c20 100644 --- a/packages/uiweb/src/lib/components/chat/MessageInput/MessageInput.tsx +++ b/packages/uiweb/src/lib/components/chat/MessageInput/MessageInput.tsx @@ -291,7 +291,7 @@ export const MessageInput: React.FC = ({ } } else { const sendTextMessage = await sendMessage({ - message: `Hello, please let me join this group, my wallet address is ${user?.account}`, + message: `Hello, please let me join this group, my wallet address is ${pCAIP10ToWallet(user?.account || '')}`, chatId: groupInfo?.groupCreator || '', messageType: 'Text', }); diff --git a/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx b/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx index b15cb0d83..4e6c6e445 100644 --- a/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx +++ b/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx @@ -5,7 +5,7 @@ import { IUser } from '@pushprotocol/restapi'; import { ethers } from 'ethers'; import styled from 'styled-components'; -import { resolveWeb3Name, shortenText } from '../../../helpers'; +import { pCAIP10ToWallet, resolveWeb3Name, shortenText } from '../../../helpers'; import { useClickAway } from '../../../hooks'; import { useChatData } from '../../../hooks/chat/useChatData'; import useChatProfile from '../../../hooks/chat/useChatProfile'; @@ -81,76 +81,76 @@ export const UserProfile: React.FC = ({ return ( + - + {userProfile && ( +
+ setOptions(true)} + /> +
+ )} + {options && ( + - {userProfile && ( -
+ ref={DropdownRef} + onClick={() => setShowUpdateUserProfileModal(true)} + > + setOptions(true)} /> -
- )} - {options && ( - setShowUpdateUserProfileModal(true)} - > - - - Edit Profile - - + Edit Profile + +
+ )} + {showUpdateUserProfileModal && + createPortal( + , + document.body )} - {showUpdateUserProfileModal && - createPortal( - , - document.body - )} -
+ ); }; diff --git a/packages/uiweb/src/lib/components/notification/index.tsx b/packages/uiweb/src/lib/components/notification/index.tsx index 565347d2f..1f0e6767b 100644 --- a/packages/uiweb/src/lib/components/notification/index.tsx +++ b/packages/uiweb/src/lib/components/notification/index.tsx @@ -2,11 +2,7 @@ import * as PropTypes from 'prop-types'; import * as React from 'react'; import styled, { css } from 'styled-components'; -import { - MediaHelper, - convertTimeStamp, - extractTimeStamp, -} from '../../utilities'; +import { MediaHelper, convertTimeStamp, extractTimeStamp } from '../../utilities'; import IPFSIcon from '../ipfsicon'; import Loader from '../loader/loader'; import ImageOverlayComponent from '../overlay'; @@ -15,12 +11,17 @@ import chainDetails from './chainDetails'; import { DecryptButton, useDecrypt } from './decrypt'; import ActionButton from './styled/ActionButton'; -import { useDivOffsetWidth } from "../../hooks"; -import { LinkIcon } from "../../icons/Link"; +import { useDivOffsetWidth } from '../../hooks'; +import { LinkIcon } from '../../icons/Link'; import type { INotificationItemTheme } from './theme'; import { getCustomTheme } from './theme'; -export { baseTheme as notificationBaseTheme, darkTheme as notificationDarkTheme, lightTheme as notificationLightTheme, type INotificationItemTheme } from './theme'; +export { + baseTheme as notificationBaseTheme, + darkTheme as notificationDarkTheme, + lightTheme as notificationLightTheme, + type INotificationItemTheme, +} from './theme'; // ================= Define types export type chainNameType = @@ -67,7 +68,7 @@ export type NotificationItemProps = { type ContainerDataType = { timestamp?: string; -}& OffsetWidthType; +} & OffsetWidthType; type OffsetWidthType = { offsetWidth: number; }; @@ -103,20 +104,13 @@ export const NotificationItem: React.FC = ({ isSecret, decryptFn, }) => { - const { notificationBody: parsedBody, timeStamp } = extractTimeStamp( - notificationBody || '' - ); - const themeObject = getCustomTheme(theme,customTheme!); - + const { notificationBody: parsedBody, timeStamp } = extractTimeStamp(notificationBody || ''); + const themeObject = getCustomTheme(theme, customTheme!); - const { - notifTitle, - notifBody, - notifCta, - notifImage, - setDecryptedValues, - isSecretRevealed, - } = useDecrypt({ notificationTitle, parsedBody, cta, image }, isSecret); + const { notifTitle, notifBody, notifCta, notifImage, setDecryptedValues, isSecretRevealed } = useDecrypt( + { notificationTitle, parsedBody, cta, image }, + isSecret + ); const isCtaURLValid = MediaHelper.validURL(notifCta); const isChannelURLValid = MediaHelper.validURL(url); @@ -126,7 +120,7 @@ export const NotificationItem: React.FC = ({ const [subscribeLoading, setSubscribeLoading] = React.useState(false); const [isSubscribed, setIsSubscribed] = React.useState(true); //use this to confirm if this is s const [divRef, offsetWidth] = useDivOffsetWidth(); - + const showMetaInfo = isSecret || timeStamp; // console.log({ // chainName, @@ -190,7 +184,6 @@ export const NotificationItem: React.FC = ({ return ( = ({ {/* header that only pops up on small devices */} - - + + {app} {chainName && chainDetails[chainName] ? ( - {chainDetails[chainName].icon} + {chainDetails[chainName].icon} ) : null} {/* header that only pops up on small devices */} {/* content of the component */} - + {/* section for media content */} {notifImage && // if its an image then render this (!MediaHelper.isMediaSupportedVideo(notifImage) ? ( setImageOverlay(notifImage || '')} > - + ) : // if its a youtube url, RENDER THIS MediaHelper.isMediaYoutube(notifImage) ? ( - +