From ec6c16082e36480ee6526d4c497d2b72765459b9 Mon Sep 17 00:00:00 2001 From: KlausMikhaelson Date: Fri, 15 Mar 2024 14:05:37 -0600 Subject: [PATCH 1/7] feat: integrating spaceid in uiweb --- .husky/pre-commit | 2 +- .../src/app/ChatUITest/ChatViewComponent.tsx | 5 +- packages/uiweb/package.json | 3 +- .../chat/ChatProfile/ChatProfile.tsx | 3 + .../components/chat/reusables/AddWallets.tsx | 1 + packages/uiweb/src/lib/helpers/address.ts | 55 ++++++++----- packages/uiweb/src/lib/helpers/chat/search.ts | 21 +++-- packages/uiweb/src/lib/helpers/udResolver.ts | 2 + packages/uiweb/yarn.lock | 82 ++++++++++++++++++- 9 files changed, 142 insertions(+), 32 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index a481e02de..3c0fbeb62 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -4,4 +4,4 @@ echo "\nRunning GIT hooks..." yarn cleanbuild yarn nx affected --target=lint -yarn nx affected --target=test +# yarn nx affected --target=test 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 72f09c750..cd83af0b5 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx @@ -19,8 +19,9 @@ const ChatViewComponentTest = () => { {/* {console.log('in close')}} modalBackground={MODAL_BACKGROUND_TYPE.OVERLAY} modalPositionType={MODAL_POSITION_TYPE.RELATIVE}/> */} console.log("Verification Failed")} - - chatId='0x56A734ba4C7c7b117774C9aAcCEf521eBE66d65b' +// 786f61c51d436d5a4a02ddb8553ebb4496d909a054eed87967e780531db7960f +// 0xb4aB21716847F6181C4F72c1ad5c05Aa6B8702e1 + chatId='0xfD8D06740291E7F2675Bc584fC6021d488B37c4f' chatProfileLeftHelperComponent={console.debug('clicked')}/>} chatProfileRightHelperComponent={
right component
} diff --git a/packages/uiweb/package.json b/packages/uiweb/package.json index e2b634781..87f9d5e32 100644 --- a/packages/uiweb/package.json +++ b/packages/uiweb/package.json @@ -10,6 +10,7 @@ "@livepeer/react": "^2.6.0", "@pushprotocol/socket": "^0.5.0", "@unstoppabledomains/resolution": "^8.5.0", + "@web3-name-sdk/core": "^0.1.15", "@web3-onboard/coinbase": "^2.2.5", "@web3-onboard/core": "^2.21.1", "@web3-onboard/injected-wallets": "^2.10.5", @@ -23,8 +24,8 @@ "html-react-parser": "^1.4.13", "livekit-client": "^1.13.3", "moment": "^2.29.4", - "react-icons": "^4.10.1", "react-easy-crop": "^4.1.4", + "react-icons": "^4.10.1", "react-image-file-resizer": "^0.4.7", "react-toastify": "^9.1.3", "react-twitter-embed": "^4.0.4", diff --git a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx index 240945fd1..c4f24fb2a 100644 --- a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx @@ -67,9 +67,12 @@ export const ChatProfile: React.FC = ({ }; const fetchProfileData = async () => { + console.log("in fetchchat profile data") if (isValidETHAddress(chatId)) { + console.log('chatId', chatId); const ChatProfile = await fetchUserProfile({ profileId: chatId, env,user }); const result = await resolveNewEns(chatId, provider, env); + console.log('resultttt', result); setWeb3Name(result); setChatInfo(ChatProfile); setGroupInfo(null); diff --git a/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx b/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx index 092155fa8..8ab23d162 100644 --- a/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx +++ b/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx @@ -72,6 +72,7 @@ export const AddWallets = ({ searchedText: string; }): Promise => { //fix ens search + console.log('searchedText', searchedText); const newChatUser = await getNewChatUser({ searchText: searchedText, fetchChatProfile:fetchUserProfile, diff --git a/packages/uiweb/src/lib/helpers/address.ts b/packages/uiweb/src/lib/helpers/address.ts index 83c6d4d53..caa69c3b9 100644 --- a/packages/uiweb/src/lib/helpers/address.ts +++ b/packages/uiweb/src/lib/helpers/address.ts @@ -2,6 +2,7 @@ import { ethers } from 'ethers'; import type { Web3Provider, InfuraProvider } from '@ethersproject/providers'; import { Env, SignerType } from '@pushprotocol/restapi'; import { getUdResolver } from './udResolver'; +import { createWeb3Name } from '@web3-name-sdk/core'; /** * @@ -58,22 +59,28 @@ export const resolveEns = (address: string, provider: Web3Provider) => { // ); // } + console.log('enssss', address); + provider.lookupAddress(checksumWallet).then((ens) => { + console.log('ens', ens); if (ens) { + console.log('ens', ens); return ens; } else { return null; } }); }; - +// isko change karna hai spaceId se export const resolveNewEns = async ( address: string, provider: InfuraProvider, - env:Env + env: Env ) => { const walletLowercase = pCAIP10ToWallet(address).toLowerCase(); const checksumWallet = ethers.utils.getAddress(walletLowercase); + const web3Name = createWeb3Name(); + // const check // let provider = ethers.getDefaultProvider('mainnet'); // if ( @@ -93,25 +100,33 @@ export const resolveNewEns = async ( let result: string | null = null; try { - const ens = await provider.lookupAddress(checksumWallet) - if (ens) { - result = ens; - // return ens; - } else { - try { - const udResolver = getUdResolver(env); - - // attempt reverse resolution on provided address - const udName = await udResolver.reverse(checksumWallet); - if (udName) { - result = udName - } else { - result = null; - } - } catch (err) { - console.debug(err); - } + const ens = await provider.lookupAddress(checksumWallet) + if (ens) { + result = ens; + // return ens; + } else { + try { + const udResolver = getUdResolver(env); + + // attempt reverse resolution on provided address + // const udName = await udResolver.reverse(checksumWallet); + console.log(checksumWallet, "udName") + result = await web3Name.getDomainName({ + address: checksumWallet, + rpcUrl: "https://mainnet.infura.io/v3/4bc7ff5f8f7f4e57b5011844d399bc47", + // queryTldList: ['bnb'], + queryChainIdList: [1, 137, 80001, 11155111, 97, 420, 56, 250, 128, 1287], + }) + console.log(result, "newwww") + // if (udName) { + // result = udName + // } else { + // result = null; + // } + } catch (err) { + console.debug(err); } + } } catch (err) { console.debug(err); diff --git a/packages/uiweb/src/lib/helpers/chat/search.ts b/packages/uiweb/src/lib/helpers/chat/search.ts index 2c228c3b9..6bb8a560d 100644 --- a/packages/uiweb/src/lib/helpers/chat/search.ts +++ b/packages/uiweb/src/lib/helpers/chat/search.ts @@ -17,6 +17,7 @@ import type { import { pCAIP10ToWallet, walletToPCAIP10 } from '../address'; import { getUdResolver } from '../udResolver'; import { displayDefaultUser } from './user'; +import { createWeb3Name } from "@web3-name-sdk/core"; export const getObjectsWithMatchingKeys = ( obj: ChatFeedsType, @@ -68,41 +69,47 @@ export const getNewChatUser = async ({ let chatProfile: IUser | undefined; let address: string | null = null; address = await getAddress(searchText, env); + console.log('searchedTextttt', address); // const provider = new ethers.providers.InfuraProvider(); // address = await provider.resolveName(searchText); // if (!address) { // address = await getAddress(searchText, env); // } if (address) { - chatProfile = await fetchChatProfile({ profileId: address, env,user }); + chatProfile = await fetchChatProfile({ profileId: address, env, user }); if (!chatProfile) chatProfile = displayDefaultUser({ caip10: walletToPCAIP10(address) }); return chatProfile; } return; }; - +/// export const getAddress = async (searchText: string, env: Env) => { + const web3Name = createWeb3Name(); + console.log('searchText', searchText); const udResolver = getUdResolver(env); const provider = new ethers.providers.InfuraProvider( CoreContractChainId[env], InfuraAPIKey ); let address: string | null = null; + let addresss: string | null = null; if (searchText.includes('.')) { try { + addresss = await web3Name.getAddress(searchText); + console.log('addresss', addresss); address = await udResolver.owner(searchText); - } catch (err) { + } catch (err) { try { address = await provider.resolveName(searchText); } catch (err) { console.debug(err); } - - console.debug(err); - } - return address || null; + console.debug(err); + } + + return addresss || null; } else if (await ethers.utils.isAddress(pCAIP10ToWallet(searchText))) { return searchText; } else { diff --git a/packages/uiweb/src/lib/helpers/udResolver.ts b/packages/uiweb/src/lib/helpers/udResolver.ts index 3391a09d4..5bc8b3445 100644 --- a/packages/uiweb/src/lib/helpers/udResolver.ts +++ b/packages/uiweb/src/lib/helpers/udResolver.ts @@ -2,8 +2,10 @@ import Resolution from '@unstoppabledomains/resolution'; import { ethers } from 'ethers'; import { allowedNetworks, InfuraAPIKey, NETWORK_DETAILS } from '../config'; import type { Env } from '@pushprotocol/restapi'; +import {createWeb3Name} from "@web3-name-sdk/core"; export const getUdResolver = (env:Env): Resolution => { + const web3Name = createWeb3Name(); const l1ChainId = allowedNetworks[env].includes(1) ? 1 : 5; const l2ChainId = allowedNetworks[env].includes(137) ? 137 : 80001; // ToDo: Enable for sepolia chainId once UD supports it diff --git a/packages/uiweb/yarn.lock b/packages/uiweb/yarn.lock index 4d3ac82a3..a1c278be0 100644 --- a/packages/uiweb/yarn.lock +++ b/packages/uiweb/yarn.lock @@ -2,6 +2,16 @@ # yarn lockfile v1 +"@adraffy/ens-normalize@1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7" + integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q== + +"@adraffy/ens-normalize@^1.10.0": + version "1.10.1" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069" + integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw== + "@babel/runtime@^7.13.10", "@babel/runtime@^7.21.0": version "7.21.5" resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.5.tgz" @@ -44,6 +54,11 @@ stream-browserify "^3.0.0" util "^0.12.4" +"@ensdomains/ens-validation@^0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@ensdomains/ens-validation/-/ens-validation-0.1.0.tgz#9ebfe66016fbf069a6ebca70c043714f6f02fbe6" + integrity sha512-rbDh2K6GfqXvBcJUISaTTYEt3f079WA4ohTE5Lh4/8EaaPAk/9vk3EisMUQV2UVxeFIZQEEyRCIOmRTpqN0W7A== + "@esbuild/android-arm64@0.19.2": version "0.19.2" resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.19.2.tgz#bc35990f412a749e948b792825eef7df0ce0e073" @@ -1144,7 +1159,7 @@ "@motionone/dom" "^10.16.2" tslib "^2.3.1" -"@noble/curves@^1.0.0": +"@noble/curves@1.2.0", "@noble/curves@^1.0.0", "@noble/curves@~1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw== @@ -1156,6 +1171,11 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== +"@noble/hashes@~1.3.0", "@noble/hashes@~1.3.2": + version "1.3.3" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" + integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== + "@pushprotocol/socket@^0.5.0": version "0.5.0" resolved "https://registry.npmjs.org/@pushprotocol/socket/-/socket-0.5.0.tgz" @@ -1449,6 +1469,28 @@ resolved "https://registry.yarnpkg.com/@react-hook/latest/-/latest-1.0.3.tgz#c2d1d0b0af8b69ec6e2b3a2412ba0768ac82db80" integrity sha512-dy6duzl+JnAZcDbNTfmaP3xHiKtbXYOaz3G51MGVljh548Y8MWzTr+PHLOfvpypEVW9zwvl+VyKjbWKEVbV1Rg== +"@scure/base@~1.1.0", "@scure/base@~1.1.2": + version "1.1.5" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.5.tgz#1d85d17269fe97694b9c592552dd9e5e33552157" + integrity sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ== + +"@scure/bip32@1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.3.2.tgz#90e78c027d5e30f0b22c1f8d50ff12f3fb7559f8" + integrity sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA== + dependencies: + "@noble/curves" "~1.2.0" + "@noble/hashes" "~1.3.2" + "@scure/base" "~1.1.2" + +"@scure/bip39@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.2.1.tgz#5cee8978656b272a917b7871c981e0541ad6ac2a" + integrity sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg== + dependencies: + "@noble/hashes" "~1.3.0" + "@scure/base" "~1.1.0" + "@sideway/address@^4.1.3": version "4.1.4" resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0" @@ -2120,6 +2162,15 @@ "@walletconnect/window-getters" "^1.0.1" tslib "1.14.1" +"@web3-name-sdk/core@^0.1.15": + version "0.1.15" + resolved "https://registry.yarnpkg.com/@web3-name-sdk/core/-/core-0.1.15.tgz#d6ab12ee515177e821cec64285fc3a667872ef48" + integrity sha512-CIYB+mLBooYuM82eM5VwJfGaQEGUpb2g2DXe756DQppAVk6K9SdYxJuPhDzc5LMbJ4K+u5+rAPNXe0+Z4Ym1sQ== + dependencies: + "@adraffy/ens-normalize" "^1.10.0" + "@ensdomains/ens-validation" "^0.1.0" + viem "^1.20" + "@web3-onboard/coinbase@^2.2.5": version "2.2.5" resolved "https://registry.yarnpkg.com/@web3-onboard/coinbase/-/coinbase-2.2.5.tgz#fb7a57e5456323c0ee107ce48ea0cc80acbb6e07" @@ -2217,6 +2268,11 @@ JSONStream@^1.3.5: jsonparse "^1.2.0" through ">=2.2.7 <3" +abitype@0.9.8: + version "0.9.8" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.9.8.tgz#1f120b6b717459deafd213dfbf3a3dd1bf10ae8c" + integrity sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ== + aes-js@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" @@ -3271,6 +3327,11 @@ isomorphic-ws@^4.0.1: resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== +isows@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.3.tgz#93c1cf0575daf56e7120bab5c8c448b0809d0d74" + integrity sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg== + jayson@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/jayson/-/jayson-4.1.0.tgz#60dc946a85197317f2b1439d672a8b0a99cea2f9" @@ -4370,6 +4431,20 @@ valtio@1.11.0: proxy-compare "2.5.1" use-sync-external-store "1.2.0" +viem@^1.20: + version "1.21.4" + resolved "https://registry.yarnpkg.com/viem/-/viem-1.21.4.tgz#883760e9222540a5a7e0339809202b45fe6a842d" + integrity sha512-BNVYdSaUjeS2zKQgPs+49e5JKocfo60Ib2yiXOWBT6LuVxY1I/6fFX3waEtpXvL1Xn4qu+BVitVtMh9lyThyhQ== + dependencies: + "@adraffy/ens-normalize" "1.10.0" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@scure/bip32" "1.3.2" + "@scure/bip39" "1.2.1" + abitype "0.9.8" + isows "1.0.3" + ws "8.13.0" + webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz" @@ -4439,6 +4514,11 @@ ws@7.5.3: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.3.tgz#160835b63c7d97bfab418fc1b8a9fced2ac01a74" integrity sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg== +ws@8.13.0: + version "8.13.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" + integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== + ws@^7.4.5, ws@^7.5.1: version "7.5.9" resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591" From f222a55afed84daa94b3ffec4829f0bf25895420 Mon Sep 17 00:00:00 2001 From: KlausMikhaelson Date: Wed, 20 Mar 2024 04:05:58 -0600 Subject: [PATCH 2/7] fix: fixed project id setting error --- .husky/pre-commit | 2 +- .../src/app/ChatUITest/ChatViewComponent.tsx | 2 +- packages/uiweb/src/lib/config/constants.ts | 7 +++++ packages/uiweb/src/lib/helpers/address.ts | 18 ++---------- packages/uiweb/src/lib/helpers/chat/search.ts | 28 ++++--------------- 5 files changed, 17 insertions(+), 40 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 3c0fbeb62..a481e02de 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -4,4 +4,4 @@ echo "\nRunning GIT hooks..." yarn cleanbuild yarn nx affected --target=lint -# yarn nx affected --target=test +yarn nx affected --target=test 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 cd83af0b5..be9fda35b 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx @@ -21,7 +21,7 @@ const ChatViewComponentTest = () => { onVerificationFail={() => console.log("Verification Failed")} // 786f61c51d436d5a4a02ddb8553ebb4496d909a054eed87967e780531db7960f // 0xb4aB21716847F6181C4F72c1ad5c05Aa6B8702e1 - chatId='0xfD8D06740291E7F2675Bc584fC6021d488B37c4f' + chatId='786f61c51d436d5a4a02ddb8553ebb4496d909a054eed87967e780531db7960f' chatProfileLeftHelperComponent={console.debug('clicked')}/>} chatProfileRightHelperComponent={
right component
} diff --git a/packages/uiweb/src/lib/config/constants.ts b/packages/uiweb/src/lib/config/constants.ts index a01eadc60..aa9cbaaf7 100644 --- a/packages/uiweb/src/lib/config/constants.ts +++ b/packages/uiweb/src/lib/config/constants.ts @@ -50,6 +50,13 @@ export const CoreRPC = { local: 'https://sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', }; +export const BSC_RPC = { + dev: 'https://convincing-old-violet.bsc-testnet.quiknode.pro/473ebceb2d8570ac74ba8d2f82e9531d25a54db9', + prod: 'https://sly-practical-market.bsc.quiknode.pro/dbe75022456376761bf648cc0868b765e2f11cad', + staging: 'https://convincing-old-violet.bsc-testnet.quiknode.pro/473ebceb2d8570ac74ba8d2f82e9531d25a54db9', + local: 'https://convincing-old-violet.bsc-testnet.quiknode.pro/473ebceb2d8570ac74ba8d2f82e9531d25a54db9' +} + const TESTNET_NETWORK = { ETHEREUM: 'eip155:11155111', diff --git a/packages/uiweb/src/lib/helpers/address.ts b/packages/uiweb/src/lib/helpers/address.ts index caa69c3b9..ea087ab2b 100644 --- a/packages/uiweb/src/lib/helpers/address.ts +++ b/packages/uiweb/src/lib/helpers/address.ts @@ -3,6 +3,7 @@ import type { Web3Provider, InfuraProvider } from '@ethersproject/providers'; import { Env, SignerType } from '@pushprotocol/restapi'; import { getUdResolver } from './udResolver'; import { createWeb3Name } from '@web3-name-sdk/core'; +import { BSC_RPC } from '../config'; /** * @@ -103,26 +104,13 @@ export const resolveNewEns = async ( const ens = await provider.lookupAddress(checksumWallet) if (ens) { result = ens; - // return ens; } else { try { - const udResolver = getUdResolver(env); - - // attempt reverse resolution on provided address - // const udName = await udResolver.reverse(checksumWallet); - console.log(checksumWallet, "udName") result = await web3Name.getDomainName({ address: checksumWallet, - rpcUrl: "https://mainnet.infura.io/v3/4bc7ff5f8f7f4e57b5011844d399bc47", - // queryTldList: ['bnb'], - queryChainIdList: [1, 137, 80001, 11155111, 97, 420, 56, 250, 128, 1287], + rpcUrl: BSC_RPC[env], + queryChainIdList: [137, 80001, 11155111, 97, 420, 56, 250, 128, 1287], }) - console.log(result, "newwww") - // if (udName) { - // result = udName - // } else { - // result = null; - // } } catch (err) { console.debug(err); } diff --git a/packages/uiweb/src/lib/helpers/chat/search.ts b/packages/uiweb/src/lib/helpers/chat/search.ts index 6bb8a560d..ee7962c74 100644 --- a/packages/uiweb/src/lib/helpers/chat/search.ts +++ b/packages/uiweb/src/lib/helpers/chat/search.ts @@ -18,6 +18,7 @@ import { pCAIP10ToWallet, walletToPCAIP10 } from '../address'; import { getUdResolver } from '../udResolver'; import { displayDefaultUser } from './user'; import { createWeb3Name } from "@web3-name-sdk/core"; +import { BSC_RPC } from '../../config'; export const getObjectsWithMatchingKeys = ( obj: ChatFeedsType, @@ -69,12 +70,6 @@ export const getNewChatUser = async ({ let chatProfile: IUser | undefined; let address: string | null = null; address = await getAddress(searchText, env); - console.log('searchedTextttt', address); - // const provider = new ethers.providers.InfuraProvider(); - // address = await provider.resolveName(searchText); - // if (!address) { - // address = await getAddress(searchText, env); - // } if (address) { chatProfile = await fetchChatProfile({ profileId: address, env, user }); if (!chatProfile) @@ -86,30 +81,17 @@ export const getNewChatUser = async ({ /// export const getAddress = async (searchText: string, env: Env) => { const web3Name = createWeb3Name(); - console.log('searchText', searchText); - const udResolver = getUdResolver(env); - const provider = new ethers.providers.InfuraProvider( - CoreContractChainId[env], - InfuraAPIKey - ); let address: string | null = null; - let addresss: string | null = null; if (searchText.includes('.')) { try { - addresss = await web3Name.getAddress(searchText); - console.log('addresss', addresss); - address = await udResolver.owner(searchText); + address = await web3Name.getAddress(searchText, { + rpcUrl: BSC_RPC[env], + }); } catch (err) { - try { - address = await provider.resolveName(searchText); - } catch (err) { - console.debug(err); - } - console.debug(err); } - return addresss || null; + return address || null; } else if (await ethers.utils.isAddress(pCAIP10ToWallet(searchText))) { return searchText; } else { From 3e7d62a8b5360773089f4e2c3ac01ccc0f4a9f31 Mon Sep 17 00:00:00 2001 From: KlausMikhaelson Date: Wed, 27 Mar 2024 12:11:09 -0600 Subject: [PATCH 3/7] fix: removed unnecessary code --- .../uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx index c4f24fb2a..240945fd1 100644 --- a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx @@ -67,12 +67,9 @@ export const ChatProfile: React.FC = ({ }; const fetchProfileData = async () => { - console.log("in fetchchat profile data") if (isValidETHAddress(chatId)) { - console.log('chatId', chatId); const ChatProfile = await fetchUserProfile({ profileId: chatId, env,user }); const result = await resolveNewEns(chatId, provider, env); - console.log('resultttt', result); setWeb3Name(result); setChatInfo(ChatProfile); setGroupInfo(null); From 39f971045c95ef2023672f018d7b9498002ff5e6 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 27 May 2024 16:40:46 +0530 Subject: [PATCH 4/7] fix: added space id --- packages/uiweb/src/lib/helpers/address.ts | 4 ++-- packages/uiweb/src/lib/helpers/chat/search.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/uiweb/src/lib/helpers/address.ts b/packages/uiweb/src/lib/helpers/address.ts index 85393154c..6f8d39782 100644 --- a/packages/uiweb/src/lib/helpers/address.ts +++ b/packages/uiweb/src/lib/helpers/address.ts @@ -49,12 +49,12 @@ export const pCAIP10ToWallet = (wallet: string): string => { export const resolveWeb3Name = async (address: string, user: PushAPI | undefined) => { const walletLowercase = pCAIP10ToWallet(address).toLowerCase(); const checksumWallet = ethers.utils.getAddress(walletLowercase); - const web3Name = createWeb3Name(); + const web3NameClient = createWeb3Name(); let result: string | null = null; try { - result = await web3Name.getDomainName({ + result = await web3NameClient.getDomainName({ address: checksumWallet, queryChainIdList: allowedNetworks[user?.env || CONSTANTS.ENV.PROD], }); diff --git a/packages/uiweb/src/lib/helpers/chat/search.ts b/packages/uiweb/src/lib/helpers/chat/search.ts index 145773a29..db0f9ff22 100644 --- a/packages/uiweb/src/lib/helpers/chat/search.ts +++ b/packages/uiweb/src/lib/helpers/chat/search.ts @@ -59,11 +59,11 @@ export const getNewChatUser = async ({ export const getAddress = async (searchText: string, env: Env) => { const udResolver = getUdResolver(env); - const web3name = createWeb3Name(); + const web3NameClient = createWeb3Name(); let address: string | null = null; if (searchText.includes('.')) { try { - address = await web3name.getAddress(searchText); + address = await web3NameClient.getAddress(searchText); if (!address) { if (!udResolver) throw new Error('No udResolver available for the network'); address = await udResolver?.owner(searchText); From b31707cfbae7a16d611d6252e13d23c5d902afc7 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra <42746736+mishramonalisha76@users.noreply.github.com> Date: Mon, 27 May 2024 17:00:12 +0530 Subject: [PATCH 5/7] Update AddWallets.tsx --- packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx b/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx index c63f54ed4..01d23fc7c 100644 --- a/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx +++ b/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx @@ -62,8 +62,6 @@ export const AddWallets = ({ }; const handleSearch = async ({ searchedText }: { searchedText: string }): Promise => { - //fix ens search - console.log('searchedText', searchedText); const newChatUser = await getNewChatUser({ searchText: searchedText, fetchChatProfile: fetchUserProfile, From 993e05d3d3b40544f0d4333a146b282d844c1f1a Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 27 May 2024 17:11:14 +0530 Subject: [PATCH 6/7] fix: made some optimisations --- .../chat/ChatPreview/ChatPreview.tsx | 2 +- .../chat/ChatProfile/ChatProfile.tsx | 4 +- .../chat/UserProfile/UserProfile.tsx | 6 +-- .../components/supportChat/AddressInfo.tsx | 39 ++++++++----------- packages/uiweb/src/lib/helpers/address.ts | 8 ++-- packages/uiweb/src/lib/helpers/chat/user.ts | 37 ------------------ .../uiweb/src/lib/hooks/useResolveWeb3Name.ts | 10 ++--- 7 files changed, 30 insertions(+), 76 deletions(-) diff --git a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx index 7bb3b94e8..5ede67242 100644 --- a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx @@ -41,7 +41,7 @@ export const ChatPreview: React.FC = (options: IChatPreviewPr setFormattedAddress(address); if (!options.chatPreviewPayload?.chatGroup) { try { - const result = await resolveWeb3Name(address, user); + const result = await resolveWeb3Name(address, user?.env || CONSTANTS.ENV.PROD); if (result) setWeb3Name(result); } catch (e) { // console.debug(e); diff --git a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx index 277e2e20d..887a5ce43 100644 --- a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx @@ -93,7 +93,7 @@ export const ChatProfile: React.FC = ({ // To setup web3 name, asynchrounously const setupWeb3Name = async (address: string) => { console.debug('UIWeb::ChatProfile::setupWeb3Name sending address for resolution', address); - const result = await resolveWeb3Name(address, user); + const result = await resolveWeb3Name(address, user?.env || CONSTANTS.ENV.PROD); console.debug('UIWeb::ChatProfile::setupWeb3Name got result as ', address, result); setInitialized((prevState) => ({ @@ -372,7 +372,7 @@ const AddonComponentSection = styled(Section)` @media ${device.mobileL} { gap: 5px; - } ; + } `; const ImageItem = styled.div` diff --git a/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx b/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx index 4e6c6e445..e29e07afc 100644 --- a/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx +++ b/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx @@ -1,7 +1,7 @@ import React, { useContext, useEffect, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; -import { IUser } from '@pushprotocol/restapi'; +import { IUser, CONSTANTS } from '@pushprotocol/restapi'; import { ethers } from 'ethers'; import styled from 'styled-components'; @@ -15,7 +15,7 @@ import { ProfileContainer } from '../reusables'; import { ThemeContext } from '../theme/ThemeProvider'; import { UpdateUserProfileModal } from './UpdateUserProfileModal'; -import { CoreContractChainId, InfuraAPIKey, ProfilePicture, device } from '../../../config'; +import { Constants, CoreContractChainId, InfuraAPIKey, ProfilePicture, device } from '../../../config'; import VerticalEllipsisIcon from '../../../icons/VerticalEllipsis.svg'; import UserProfileIcon from '../../../icons/userCircleGear.svg'; import { MODAL_BACKGROUND_TYPE, MODAL_POSITION_TYPE } from '../../../types'; @@ -50,7 +50,7 @@ export const UserProfile: React.FC = ({ (async () => { const fetchedUser = await fetchChatProfile({ user }); if (fetchedUser) { - const result = await resolveWeb3Name(fetchedUser?.wallets, user); + const result = await resolveWeb3Name(fetchedUser?.wallets, user?.env || CONSTANTS.ENV.PROD); setWeb3Name(result); setUserProfile(fetchedUser); } diff --git a/packages/uiweb/src/lib/components/supportChat/AddressInfo.tsx b/packages/uiweb/src/lib/components/supportChat/AddressInfo.tsx index 8fcac839b..90a18a609 100644 --- a/packages/uiweb/src/lib/components/supportChat/AddressInfo.tsx +++ b/packages/uiweb/src/lib/components/supportChat/AddressInfo.tsx @@ -1,32 +1,34 @@ -import { ethers } from 'ethers'; import React, { useContext, useEffect, useState } from 'react'; + import styled from 'styled-components'; -import { Constants, ENV, InfuraAPIKey, allowedNetworks } from '../../config'; +import { ethers } from 'ethers'; + +import { ChatProps } from './Chat'; + import { SupportChatPropsContext } from '../../context'; -import { copyToClipboard, pCAIP10ToWallet, resolveWeb3Name, } from '../../helpers'; +import { Constants, ENV, InfuraAPIKey, allowedNetworks } from '../../config'; + +import { copyToClipboard, pCAIP10ToWallet, resolveWeb3Name } from '../../helpers'; import { CopySvg } from '../../icons/CopySvg'; -import { ChatProps } from './Chat'; export const AddressInfo: React.FC = () => { - const { supportAddress, env, theme, user } = useContext(SupportChatPropsContext); const [ensName, setEnsName] = useState(''); const [pushUser, setPushUser] = useState({}); const [isCopied, setIsCopied] = useState(false); const walletAddress = pCAIP10ToWallet(supportAddress!); - const l1ChainId = (allowedNetworks[env!]?.includes(1)) ? 1 : 5; + const l1ChainId = allowedNetworks[env!]?.includes(1) ? 1 : 5; const provider = new ethers.providers.InfuraProvider(l1ChainId, InfuraAPIKey); useEffect(() => { const getUser = async () => { -if(user){ - const fetchedUser = await user.info(); - const ensNameResult = await resolveWeb3Name(supportAddress!, user) - setEnsName(ensNameResult!) -setPushUser(fetchedUser); -} - + if (user) { + const fetchedUser = await user.info(); + const ensNameResult = await resolveWeb3Name(supportAddress!, user?.env || Constants.ENV.PROD); + setEnsName(ensNameResult!); + setPushUser(fetchedUser); + } }; getUser(); }, [supportAddress, user]); @@ -36,20 +38,13 @@ setPushUser(fetchedUser);
address profile {ensName && `${ensName}`} - {!ensName && - `${walletAddress.substring(0, 8)}...${walletAddress.substring( - walletAddress.length - 8 - )}`} + {!ensName && `${walletAddress.substring(0, 8)}...${walletAddress.substring(walletAddress.length - 8)}`}
{!isCopied && ( diff --git a/packages/uiweb/src/lib/helpers/address.ts b/packages/uiweb/src/lib/helpers/address.ts index d34db654e..a70df287a 100644 --- a/packages/uiweb/src/lib/helpers/address.ts +++ b/packages/uiweb/src/lib/helpers/address.ts @@ -1,6 +1,6 @@ import { CONSTANTS, PushAPI, SignerType } from '@pushprotocol/restapi'; import { ethers } from 'ethers'; -import { allowedNetworks } from '../config'; +import { ENV, allowedNetworks } from '../config'; import { getUdResolver } from './udResolver'; import { createWeb3Name } from '@web3-name-sdk/core'; @@ -46,7 +46,7 @@ export const pCAIP10ToWallet = (wallet: string): string => { return wallet; }; -export const resolveWeb3Name = async (address: string, user: PushAPI | undefined) => { +export const resolveWeb3Name = async (address: string, env: ENV) => { const walletLowercase = pCAIP10ToWallet(address).toLowerCase(); const checksumWallet = ethers.utils.getAddress(walletLowercase); const web3NameClient = createWeb3Name(); @@ -56,10 +56,10 @@ export const resolveWeb3Name = async (address: string, user: PushAPI | undefined try { result = await web3NameClient.getDomainName({ address: checksumWallet, - queryChainIdList: allowedNetworks[(user?.env || CONSTANTS.ENV.PROD) as keyof typeof allowedNetworks], + queryChainIdList: allowedNetworks[env], }); if (!result) { - const udResolver = getUdResolver(user ? user.env : CONSTANTS.ENV.PROD); + const udResolver = getUdResolver(env); if (!udResolver) { throw new Error('UIWeb::helpers::address::resolveWeb3Name::Error in UD resolver'); } diff --git a/packages/uiweb/src/lib/helpers/chat/user.ts b/packages/uiweb/src/lib/helpers/chat/user.ts index 4414fd60f..2fa5a6cc7 100644 --- a/packages/uiweb/src/lib/helpers/chat/user.ts +++ b/packages/uiweb/src/lib/helpers/chat/user.ts @@ -33,40 +33,3 @@ export const displayDefaultUser = ({ caip10 }: { caip10: string }): IUser => { }; return userCreated; }; -export const getEnsName = async ( - provider: ethers.providers.BaseProvider | any, - checksumWallet: string, - setWeb3Name: (id: string, web3Name: string) => void -) => { - let ensName: string | null = null; - provider.lookupAddress(checksumWallet).then(async (ens: string) => { - if (ens) { - ensName = ens; - setWeb3Name(checksumWallet.toLowerCase(), ensName); - } else { - ensName = null; - } - }); - return ensName; -}; - -export const getUnstoppableName = async ( - checksumWallet: string, - setWeb3Name: (id: string, web3Name: string) => void, - env: Env -) => { - // Unstoppable Domains resolution library - const udResolver = getUdResolver(env); - if (!udResolver) { - return null; - } - - // attempt reverse resolution on provided address - let udName = await udResolver.reverse(checksumWallet); - if (udName) { - setWeb3Name(checksumWallet.toLowerCase(), udName); - } else { - udName = null; - } - return udName; -}; diff --git a/packages/uiweb/src/lib/hooks/useResolveWeb3Name.ts b/packages/uiweb/src/lib/hooks/useResolveWeb3Name.ts index e9d63fdc7..12c2301f9 100644 --- a/packages/uiweb/src/lib/hooks/useResolveWeb3Name.ts +++ b/packages/uiweb/src/lib/hooks/useResolveWeb3Name.ts @@ -2,22 +2,19 @@ import type { Env } from '@pushprotocol/restapi'; import { ethers } from 'ethers'; import { useContext, useEffect, useState } from 'react'; -import { CoreContractChainId, ENV, InfuraAPIKey } from '../config'; import { ChatMainStateContext } from '../context'; import type { ChatMainStateContextType } from '../context/chatAndNotification/chat/chatMainStateContext'; // Internal Components // Internal Configs -import { getEnsName, getUdResolver, getUnstoppableName, pCAIP10ToWallet } from '../helpers'; -import { Web3NameListType } from '../types'; +import { pCAIP10ToWallet, resolveWeb3Name } from '../helpers'; export function useResolveWeb3Name(address: string, env: Env) { const { web3NameList, setWeb3Name, selectedChatId } = useContext(ChatMainStateContext); useEffect(() => { (async () => { - const provider = new ethers.providers.InfuraProvider(CoreContractChainId[env], InfuraAPIKey); if (address) { const walletLowercase = pCAIP10ToWallet(address)?.toLowerCase(); const checksumWallet = ethers.utils.getAddress(walletLowercase); @@ -30,9 +27,8 @@ export function useResolveWeb3Name(address: string, env: Env) { return; } }); - - (await getUnstoppableName(checksumWallet, setWeb3Name, env)) || - (await getEnsName(provider, checksumWallet, setWeb3Name)); + const result = await resolveWeb3Name(checksumWallet, env); + if (result) setWeb3Name(checksumWallet.toLowerCase(), result); } catch (e) { console.error(e); } From b37d3bc9736e29bcba6c9f29b0627e58bfc6bbd1 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Tue, 28 May 2024 16:42:25 +0530 Subject: [PATCH 7/7] fix: fixed lint issues --- .../sdk-frontend-react/src/app/constants.ts | 3 +-- .../components/chat/ChatPreview/ChatPreview.tsx | 2 +- .../components/chat/ChatProfile/ChatProfile.tsx | 2 +- .../components/chat/ChatViewList/ChatViewList.tsx | 4 +++- .../components/chat/UserProfile/UserProfile.tsx | 2 +- .../lib/components/supportChat/AddressInfo.tsx | 2 +- packages/uiweb/src/lib/config/constants.ts | 7 ------- packages/uiweb/src/lib/helpers/address.ts | 15 ++++++++------- packages/uiweb/src/lib/helpers/chat/search.ts | 8 ++++---- packages/uiweb/src/lib/helpers/chat/user.ts | 4 +--- packages/uiweb/src/lib/helpers/udResolver.ts | 4 ++-- 11 files changed, 23 insertions(+), 30 deletions(-) diff --git a/packages/examples/sdk-frontend-react/src/app/constants.ts b/packages/examples/sdk-frontend-react/src/app/constants.ts index f7acc7974..14b32ec58 100644 --- a/packages/examples/sdk-frontend-react/src/app/constants.ts +++ b/packages/examples/sdk-frontend-react/src/app/constants.ts @@ -1,3 +1,2 @@ // the unique id for a chat or the receivers's wallet ddress or domain name -export const CHAT_ID = - '34c44214589cecc176a136ee1daf0f0231ecc6d6574b920b5ae39eb971fa3cb4'; +export const CHAT_ID = 'allen.bnb'; diff --git a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx index 5ede67242..59b46aa52 100644 --- a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx @@ -41,7 +41,7 @@ export const ChatPreview: React.FC = (options: IChatPreviewPr setFormattedAddress(address); if (!options.chatPreviewPayload?.chatGroup) { try { - const result = await resolveWeb3Name(address, user?.env || CONSTANTS.ENV.PROD); + const result = await resolveWeb3Name(address, user?.env); if (result) setWeb3Name(result); } catch (e) { // console.debug(e); diff --git a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx index 887a5ce43..25375b0ce 100644 --- a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx @@ -93,7 +93,7 @@ export const ChatProfile: React.FC = ({ // To setup web3 name, asynchrounously const setupWeb3Name = async (address: string) => { console.debug('UIWeb::ChatProfile::setupWeb3Name sending address for resolution', address); - const result = await resolveWeb3Name(address, user?.env || CONSTANTS.ENV.PROD); + const result = await resolveWeb3Name(address, user?.env); console.debug('UIWeb::ChatProfile::setupWeb3Name got result as ', address, result); setInitialized((prevState) => ({ diff --git a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx index f51098d0b..6cdfa3177 100644 --- a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx @@ -293,7 +293,9 @@ export const ChatViewList: React.FC = (options: IChatViewLis return () => clearTimeout(timer); } - return () => {}; + return () => { + //empty return + }; }, [chatAcceptStream, participantJoinStream]); // Change listtype to 'UINITIALIZED' and hidden to true when participantRemoveStream or participantLeaveStream is received diff --git a/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx b/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx index e29e07afc..b377cd042 100644 --- a/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx +++ b/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx @@ -50,7 +50,7 @@ export const UserProfile: React.FC = ({ (async () => { const fetchedUser = await fetchChatProfile({ user }); if (fetchedUser) { - const result = await resolveWeb3Name(fetchedUser?.wallets, user?.env || CONSTANTS.ENV.PROD); + const result = await resolveWeb3Name(fetchedUser?.wallets, user?.env); setWeb3Name(result); setUserProfile(fetchedUser); } diff --git a/packages/uiweb/src/lib/components/supportChat/AddressInfo.tsx b/packages/uiweb/src/lib/components/supportChat/AddressInfo.tsx index 90a18a609..628d5bb8d 100644 --- a/packages/uiweb/src/lib/components/supportChat/AddressInfo.tsx +++ b/packages/uiweb/src/lib/components/supportChat/AddressInfo.tsx @@ -25,7 +25,7 @@ export const AddressInfo: React.FC = () => { const getUser = async () => { if (user) { const fetchedUser = await user.info(); - const ensNameResult = await resolveWeb3Name(supportAddress!, user?.env || Constants.ENV.PROD); + const ensNameResult = await resolveWeb3Name(supportAddress!, user?.env); setEnsName(ensNameResult!); setPushUser(fetchedUser); } diff --git a/packages/uiweb/src/lib/config/constants.ts b/packages/uiweb/src/lib/config/constants.ts index 49072b130..d542e8254 100644 --- a/packages/uiweb/src/lib/config/constants.ts +++ b/packages/uiweb/src/lib/config/constants.ts @@ -51,13 +51,6 @@ export const CoreRPC = { local: 'https://sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', }; -export const BSC_RPC = { - dev: 'https://convincing-old-violet.bsc-testnet.quiknode.pro/473ebceb2d8570ac74ba8d2f82e9531d25a54db9', - prod: 'https://sly-practical-market.bsc.quiknode.pro/dbe75022456376761bf648cc0868b765e2f11cad', - staging: 'https://convincing-old-violet.bsc-testnet.quiknode.pro/473ebceb2d8570ac74ba8d2f82e9531d25a54db9', - local: 'https://convincing-old-violet.bsc-testnet.quiknode.pro/473ebceb2d8570ac74ba8d2f82e9531d25a54db9', -}; - const TESTNET_NETWORK = { ETHEREUM: 'eip155:11155111', POLYGON: 'eip155:80002', diff --git a/packages/uiweb/src/lib/helpers/address.ts b/packages/uiweb/src/lib/helpers/address.ts index a70df287a..c5f06521f 100644 --- a/packages/uiweb/src/lib/helpers/address.ts +++ b/packages/uiweb/src/lib/helpers/address.ts @@ -1,8 +1,8 @@ -import { CONSTANTS, PushAPI, SignerType } from '@pushprotocol/restapi'; +import { SignerType, CONSTANTS } from '@pushprotocol/restapi'; import { ethers } from 'ethers'; import { ENV, allowedNetworks } from '../config'; -import { getUdResolver } from './udResolver'; import { createWeb3Name } from '@web3-name-sdk/core'; +import { getUdResolverClient } from './udResolver'; /** * @@ -47,6 +47,7 @@ export const pCAIP10ToWallet = (wallet: string): string => { }; export const resolveWeb3Name = async (address: string, env: ENV) => { + env = env || CONSTANTS.ENV.PROD; const walletLowercase = pCAIP10ToWallet(address).toLowerCase(); const checksumWallet = ethers.utils.getAddress(walletLowercase); const web3NameClient = createWeb3Name(); @@ -59,15 +60,15 @@ export const resolveWeb3Name = async (address: string, env: ENV) => { queryChainIdList: allowedNetworks[env], }); if (!result) { - const udResolver = getUdResolver(env); - if (!udResolver) { + const udResolverClient = getUdResolverClient(env); + if (!udResolverClient) { throw new Error('UIWeb::helpers::address::resolveWeb3Name::Error in UD resolver'); } // attempt reverse resolution on provided address - const udName = await udResolver.reverse(checksumWallet); + const udDomainName = await udResolverClient.reverse(checksumWallet); - if (udName) { - result = udName; + if (udDomainName) { + result = udDomainName; } } } catch (err) { diff --git a/packages/uiweb/src/lib/helpers/chat/search.ts b/packages/uiweb/src/lib/helpers/chat/search.ts index db0f9ff22..36b73ac7c 100644 --- a/packages/uiweb/src/lib/helpers/chat/search.ts +++ b/packages/uiweb/src/lib/helpers/chat/search.ts @@ -2,7 +2,7 @@ import type { Env, IFeeds, IUser, PushAPI } from '@pushprotocol/restapi'; import { ethers } from 'ethers'; import type { ChatFeedsType, NotificationFeedsType, ParsedNotificationType, Web3NameListType } from '../../types'; import { pCAIP10ToWallet, walletToPCAIP10 } from '../address'; -import { getUdResolver } from '../udResolver'; +import { getUdResolverClient } from '../udResolver'; import { displayDefaultUser } from './user'; import { createWeb3Name } from '@web3-name-sdk/core'; @@ -58,15 +58,15 @@ export const getNewChatUser = async ({ }; export const getAddress = async (searchText: string, env: Env) => { - const udResolver = getUdResolver(env); + const udResolverClient = getUdResolverClient(env); const web3NameClient = createWeb3Name(); let address: string | null = null; if (searchText.includes('.')) { try { address = await web3NameClient.getAddress(searchText); if (!address) { - if (!udResolver) throw new Error('No udResolver available for the network'); - address = await udResolver?.owner(searchText); + if (!udResolverClient) throw new Error('No udResolverClient available for the network'); + address = await udResolverClient?.owner(searchText); } } catch (err) { console.debug(err); diff --git a/packages/uiweb/src/lib/helpers/chat/user.ts b/packages/uiweb/src/lib/helpers/chat/user.ts index 2fa5a6cc7..f0cdb9ef7 100644 --- a/packages/uiweb/src/lib/helpers/chat/user.ts +++ b/packages/uiweb/src/lib/helpers/chat/user.ts @@ -1,7 +1,5 @@ -import type { Env, IUser } from '@pushprotocol/restapi'; +import type { IUser } from '@pushprotocol/restapi'; import { ProfilePicture } from '../../config'; -import { ethers } from 'ethers'; -import { getUdResolver } from '../udResolver'; export const displayDefaultUser = ({ caip10 }: { caip10: string }): IUser => { const userCreated: IUser = { diff --git a/packages/uiweb/src/lib/helpers/udResolver.ts b/packages/uiweb/src/lib/helpers/udResolver.ts index 9670443fd..cc54d1d57 100644 --- a/packages/uiweb/src/lib/helpers/udResolver.ts +++ b/packages/uiweb/src/lib/helpers/udResolver.ts @@ -3,7 +3,7 @@ import Resolution from '@unstoppabledomains/resolution'; import { ethers } from 'ethers'; import { allowedNetworks, InfuraAPIKey, NETWORK_DETAILS } from '../config'; -export const getUdResolver = (env: Env): Resolution | undefined => { +export const getUdResolverClient = (env: Env): Resolution | undefined => { try { const l1ChainId = allowedNetworks[env].includes(1) ? 1 : 5; const l2ChainId = allowedNetworks[env].includes(137) ? 137 : 80002; @@ -24,7 +24,7 @@ export const getUdResolver = (env: Env): Resolution | undefined => { }, }); } catch (e) { - console.debug(`Errored:UIWeb::helpers::getUdResolver::UD doesnot provide support for the network`); + console.debug(`Errored:UIWeb::helpers::getUdResolverClient::UD doesnot provide support for the network`); return undefined; } };