diff --git a/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx b/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx index 636b42fe6..be2a51045 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx @@ -35,7 +35,7 @@ export const ChatSupportTest = () => { { const { supportAddress, env, theme, pushUser } = useContext(SupportChatPropsContext); @@ -11,11 +12,15 @@ export const AddressInfo: React.FC = () => { const [user, setUser] = useState({}); const [isCopied, setIsCopied] = useState(false); const walletAddress = pCAIP10ToWallet(supportAddress); + const l1ChainId = allowedNetworks[env].includes(1) ? 1 : 5; + const provider = new ethers.providers.InfuraProvider(l1ChainId, InfuraAPIKey); useEffect(() => { const getUser = async () => { if(pushUser){ const user = await pushUser.info(); + const ensNameResult = await resolveNewEns(supportAddress, provider) + setEnsName(ensNameResult!) setUser(user); } diff --git a/packages/uiweb/src/lib/components/supportChat/Chat.tsx b/packages/uiweb/src/lib/components/supportChat/Chat.tsx index c1caa964c..9fad073d2 100644 --- a/packages/uiweb/src/lib/components/supportChat/Chat.tsx +++ b/packages/uiweb/src/lib/components/supportChat/Chat.tsx @@ -3,7 +3,7 @@ import { PushAPI } from '@pushprotocol/restapi'; import { ChatIcon } from '../../icons/ChatIcon'; import { Modal } from './Modal'; import styled from 'styled-components'; -import { handleOnChatIconClick } from '../../helpers'; +import { getAddress, handleOnChatIconClick } from '../../helpers'; import { SupportChatMainStateContext, SupportChatPropsContext, @@ -16,6 +16,7 @@ import { useSDKSocket } from '../../hooks/useSDKSocket'; import { Div } from '../reusables/sharedStyling'; import { getAddressFromSigner } from '../../helpers'; import { sign } from 'crypto'; + export type ChatProps = { account?: string; signer: SignerType; @@ -50,6 +51,7 @@ export type ButtonStyleProps = { const [chats, setChats] = useState([]); const [accountadd, setAccountadd] = useState(account) const [pushUser, setPushUser] = useState(null); + const [resolvedSupportAddress, setResolvedSupportAddress] = useState(''); const setChatsSorted = (chats: IMessageIPFS[]) => { const chatsWithNumericTimestamps = chats.map(item => ({ @@ -72,7 +74,7 @@ export type ButtonStyleProps = { env, apiKey, pushUser: pushUser!, - supportAddress, + supportAddress: resolvedSupportAddress, signer }); @@ -81,7 +83,7 @@ export type ButtonStyleProps = { account : accountadd, signer, pushUser, - supportAddress, + supportAddress : resolvedSupportAddress, greetingMsg, modalTitle, theme: { ...lightTheme, ...theme }, @@ -89,6 +91,18 @@ export type ButtonStyleProps = { env, }; + useEffect(() => { + + const getNewSupportAddress = async() => { + if(supportAddress.includes(".")){ + const newAddress = await getAddress(supportAddress, env) +setResolvedSupportAddress(newAddress!); + }else{ +setResolvedSupportAddress(supportAddress); + } + } + getNewSupportAddress(); + },[supportAddress, pushUser, env]) useEffect(() => {