From 7df4c10916026156b71031357586441fc8115b28 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Thu, 10 Oct 2024 18:18:17 +0530 Subject: [PATCH 01/14] added keys --- src/App.tsx | 2 +- src/config/config-alpha.js | 9 +++-- src/config/config-dev.js | 9 +++-- src/config/config-general.js | 61 +++++++++++++++++--------------- src/config/config-localhost.js | 7 ++-- src/config/config-prod.js | 9 +++-- src/config/config-staging.js | 7 ++-- src/connectors/walletConnect.tsx | 7 ++++ src/connectors/web3Onboard.tsx | 4 +-- src/hooks/useResolveWeb3Name.ts | 4 +++ 10 files changed, 74 insertions(+), 45 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index a05df39c7b..6cc85ffdf4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -356,7 +356,7 @@ export default function App() { { let domainName: string | null = ''; const web3NameClient = createWeb3Name(); + console.debug('in get domain name'); web3NameClient .getDomainName({ address: checksumWallet, queryChainIdList: appConfig.allowedNetworks, + rpcUrl: appConfig.coreRPC, }) .then(async (domain) => { if (domain) { @@ -30,6 +32,8 @@ const getDomainName = async (checksumWallet: string, setWeb3NameList: any) => { domainName = null; } }); + console.debug('in get domain name', domainName); + return domainName; }; From 6191e6a13be64581b0bb220239c059b34364b105 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Thu, 10 Oct 2024 18:28:51 +0530 Subject: [PATCH 02/14] added keys --- src/connectors/walletConnect.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/connectors/walletConnect.tsx b/src/connectors/walletConnect.tsx index 0fb1b3b953..c633eab3a9 100644 --- a/src/connectors/walletConnect.tsx +++ b/src/connectors/walletConnect.tsx @@ -15,12 +15,6 @@ const wcV2InitOptions: WalletConnectOptions = { * Chains required to be supported by all wallets connecting to your DApp */ requiredChains: [appConfig.coreContractChain], - /** - * Defaults to `appMetadata.explore` that is supplied to the web3-onboard init - * Strongly recommended to provide atleast one URL as it is required by some wallets (i.e. MetaMask) - * To connect with walletconnect - */ - dappUrl: 'https://localhost:3000/', /** * Optional chains From c4eb4b27ba6ad92694ad8ca97c9d0439286f25c4 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Fri, 11 Oct 2024 12:16:42 +0530 Subject: [PATCH 03/14] added local infura key --- src/config/config-alpha.js | 18 ++++++++++-------- src/config/config-dev.js | 30 +++++++++++++++--------------- src/config/config-general.js | 12 ------------ src/config/config-localhost.js | 12 ++++++------ src/config/config-prod.js | 18 ++++++++++-------- src/config/config-staging.js | 27 ++++++++++++++------------- src/hooks/useResolveWeb3Name.ts | 2 -- 7 files changed, 55 insertions(+), 64 deletions(-) diff --git a/src/config/config-alpha.js b/src/config/config-alpha.js index 3261cf5b83..54b5e29530 100644 --- a/src/config/config-alpha.js +++ b/src/config/config-alpha.js @@ -1,4 +1,8 @@ // environmental configurations for the dapp for different environments +const infuraProjectId = + window.location.hostname == 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'dd262cc008764b29bd6a15249db4772e'; export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -37,15 +41,13 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: EnvHelper.isLocalHost - ? import.meta.env.VITE_APP_IPFS_INFURA_API_KEY - : 'dd262cc008764b29bd6a15249db4772e', + infuraAPIKey: infuraProjectId, coreContractChain: 1, //the chain id of the network which the core contract relies on - coreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, + coreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, mainnetCoreContractChain: 1, aliasRPC: { - 137: 'https://polygon-mainnet.infura.io/v3/150f25623ae64d08ab7ec7dd0c6b6ee9', + 137: `https://polygon-mainnet.infura.io/v3/${infuraProjectId}`, 56: 'https://bsc-dataseed.binance.org/', 10: 'https://opt-mainnet.g.alchemy.com/v2/JYW0UaSC5Zd0hrI6vE2K9VN1wJupoY5B', 42161: 'https://arb1.arbitrum.io/rpc', @@ -123,7 +125,7 @@ export const CHAIN_DETAILS = { label: 'Ethereum Mainnet', name: 'ETH_MAINNET', chainId: 1, - rpcUrl: 'https://mainnet.infura.io/v3/dd262cc008764b29bd6a15249db4772e', + rpcUrl: `https://mainnet.infura.io/v3/${infuraProjectId}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'mainnet', }, @@ -131,7 +133,7 @@ export const CHAIN_DETAILS = { label: 'Polygon Mainnet', name: 'POLYGON_MAINNET', chainId: 137, - rpcUrl: 'https://polygon-mainnet.infura.io/v3/150f25623ae64d08ab7ec7dd0c6b6ee9', + rpcUrl: `https://polygon-mainnet.infura.io/v3/${infuraProjectId}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'polygon-mainnet', }, diff --git a/src/config/config-dev.js b/src/config/config-dev.js index 9c7821ce87..f047295bdf 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -1,6 +1,8 @@ -import { EnvHelper } from 'helpers/UtilityHelper'; - // environmental configurations for the dapp for different environments +const infuraProjectId = + window.location.hostname == 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'be75cf427a5c41f9badb591994019d22'; export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -41,19 +43,17 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: EnvHelper.isLocalHost - ? import.meta.env.VITE_APP_IPFS_INFURA_API_KEY - : 'be75cf427a5c41f9badb591994019d22', + infuraAPIKey: infuraProjectId, coreContractChain: 11155111, //the chain id of the network which the core contract relies on - coreRPC: `https://sepolia.infura.io/v3/${infuraAPIKey}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, + coreRPC: `https://sepolia.infura.io/v3/${infuraProjectId}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, mainnetCoreContractChain: 1, aliasRPC: { - 80002: 'https://polygon-amoy.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', - 97: 'https://data-seed-prebsc-1-s1.binance.org:8545', - 11155420: 'https://optimism-sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + 80002: `https://polygon-amoy.infura.io/v3/${infuraProjectId}`, + 97: `https://data-seed-prebsc-1-s1.binance.org:8545`, + 11155420: `https://optimism-sepolia.infura.io/v3/${infuraProjectId}`, 2442: 'https://rpc.cardona.zkevm-rpc.com', - 421614: 'https://arbitrum-sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + 421614: `https://arbitrum-sepolia.infura.io/v3/${infuraProjectId}`, }, infuraApiUrl: 'https:/infura-ipfs.io/ipfs/', @@ -135,7 +135,7 @@ export const CHAIN_DETAILS = { label: 'Ethereum Sepolia', name: 'ETH_TEST_SEPOLIA', chainId: 11155111, - rpcUrl: 'https://sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + rpcUrl: `https://sepolia.infura.io/v3/${config.infuraAPIKey}`, commAddress: '0x28709649Dfda9baDEbb61dBF7a8D199cfC8EcF2e', network: 'sepolia', }, @@ -143,7 +143,7 @@ export const CHAIN_DETAILS = { label: 'Polygon Amoy', name: 'POLYGON_TEST_AMOY', chainId: 80002, - rpcUrl: 'https://polygon-amoy.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + rpcUrl: `https://polygon-amoy.infura.io/v3/${config.infuraAPIKey}`, commAddress: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', network: 'polygon-amoy', }, @@ -158,7 +158,7 @@ export const CHAIN_DETAILS = { label: 'Optimism Sepolia', name: 'OPTIMISM_TESTNET', chainId: 11155420, - rpcUrl: 'https://optimism-sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + rpcUrl: `https://optimism-sepolia.infura.io/v3/${config.infuraAPIKey}`, commAddress: '0x754787358fac861ef904c92d54f7adb659779317', }, 2442: { @@ -172,7 +172,7 @@ export const CHAIN_DETAILS = { label: 'Arbitrum Testnet', name: 'ARBITRUM_TESTNET', chainId: 421614, - rpcUrl: 'https://arbitrum-sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + rpcUrl: `https://arbitrum-sepolia.infura.io/v3/${config.infuraAPIKey}`, commAddress: '0x754787358fac861ef904c92d54f7adb659779317', }, 123: { diff --git a/src/config/config-general.js b/src/config/config-general.js index 95788d22d8..82c1a11523 100644 --- a/src/config/config-general.js +++ b/src/config/config-general.js @@ -1,15 +1,3 @@ -// environmental configurations for the dapp for different environments -// export const config = { -// /** -// * API Calls Related -// */ -// // infuraAPIKey: 'e214e9781e104829bc93941508a45b58' -// infuraAPIKey: 'dd262cc008764b29bd6a15249db4772e', -// // infuraAPIKey: EnvHelper.isLocalHost -// // ? import.meta.env.VITE_APP_IPFS_INFURA_API_KEY -// // : 'dd262cc008764b29bd6a15249db4772e', -// }; - // Internal Components import daiAbi from './abis/dai'; import epnsTokenAbi from './abis/EPNS.json'; diff --git a/src/config/config-localhost.js b/src/config/config-localhost.js index 8925c42dde..b6e7bd51b6 100644 --- a/src/config/config-localhost.js +++ b/src/config/config-localhost.js @@ -31,10 +31,10 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: import.meta.env.VITE_APP_IPFS_INFURA_API_KEY, + infuraAPIKey: import.meta.env.VITE_APP_INFURA_PROJECT_ID, coreContractChain: 5, //the chain id of the network which the core contract relies on - coreRPC: `https://goerli.infura.io/v3/${infuraAPIKey}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, + coreRPC: `https://goerli.infura.io/v3/${import.meta.env.VITE_APP_INFURA_PROJECT_ID}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${import.meta.env.VITE_APP_INFURA_PROJECT_ID}`, mainnetCoreContractChain: 1, aliasRPC: { 80002: 'https://polygon-amoy.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', @@ -100,7 +100,7 @@ export const CHAIN_DETAILS = { label: 'Ethereum Goerli', name: 'ETH_TEST_GOERLI', chainId: 5, - rpcUrl: `https://goerli.infura.io/v3/${import.meta.env.VITE_APP_IPFS_INFURA_API_KEY}`, + rpcUrl: `https://goerli.infura.io/v3/${import.meta.env.VITE_APP_INFURA_PROJECT_ID}`, commAddress: '0xc064F30bac07e84500c97A04D21a9d1bfFC72Ec0', network: 'goerli', }, @@ -108,7 +108,7 @@ export const CHAIN_DETAILS = { label: 'Polygon Amoy', name: 'POLYGON_TEST_AMOY', chainId: 80002, - rpcUrl: 'https://polygon-amoy.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + rpcUrl: `https://polygon-amoy.infura.io/v3/${import.meta.env.VITE_APP_INFURA_PROJECT_ID}`, commAddress: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', network: 'polygon-amoy', }, @@ -123,7 +123,7 @@ export const CHAIN_DETAILS = { label: 'Optimism Sepolia', name: 'OPTIMISM_TESTNET', chainId: 11155420, - rpcUrl: 'https://optimism-sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + rpcUrl: `https://optimism-sepolia.infura.io/v3/${import.meta.env.VITE_APP_INFURA_PROJECT_ID}`, commAddress: '0x9Dc25996ba72A2FD7E64e7a674232a683f406F1A', }, }; diff --git a/src/config/config-prod.js b/src/config/config-prod.js index 2d0cb20a4a..12a0526cac 100644 --- a/src/config/config-prod.js +++ b/src/config/config-prod.js @@ -1,4 +1,8 @@ // environmental configurations for the dapp for different environments +const infuraProjectId = + window.location.hostname == 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'dd262cc008764b29bd6a15249db4772e'; export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -38,15 +42,13 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: EnvHelper.isLocalHost - ? import.meta.env.VITE_APP_IPFS_INFURA_API_KEY - : 'dd262cc008764b29bd6a15249db4772e', + infuraAPIKey: infuraProjectId, coreContractChain: 1, //the chain id of the network which the core contract relies on - coreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, + coreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, mainnetCoreContractChain: 1, aliasRPC: { - 137: 'https://polygon-mainnet.infura.io/v3/150f25623ae64d08ab7ec7dd0c6b6ee9', + 137: `https://polygon-mainnet.infura.io/v3/${infuraProjectId}`, 56: 'https://bsc-dataseed.binance.org/', 10: 'https://opt-mainnet.g.alchemy.com/v2/JYW0UaSC5Zd0hrI6vE2K9VN1wJupoY5B', 42161: 'https://arb1.arbitrum.io/rpc', @@ -126,7 +128,7 @@ export const CHAIN_DETAILS = { label: 'Ethereum Mainnet', name: 'ETH_MAINNET', chainId: 1, - rpcUrl: 'https://mainnet.infura.io/v3/dd262cc008764b29bd6a15249db4772e', + rpcUrl: `https://mainnet.infura.io/v3/${config.infuraAPIKey}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'mainnet', }, @@ -134,7 +136,7 @@ export const CHAIN_DETAILS = { label: 'Polygon Mainnet', name: 'POLYGON_MAINNET', chainId: 137, - rpcUrl: 'https://polygon-mainnet.infura.io/v3/150f25623ae64d08ab7ec7dd0c6b6ee9', + rpcUrl: `https://polygon-mainnet.infura.io/v3/${config.infuraAPIKey}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'polygon-mainnet', }, diff --git a/src/config/config-staging.js b/src/config/config-staging.js index 2d0a2afba0..8f2860c759 100644 --- a/src/config/config-staging.js +++ b/src/config/config-staging.js @@ -1,4 +1,8 @@ // environmental configurations for the dapp for different environments +const infuraProjectId = + window.location.hostname == 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'be75cf427a5c41f9badb591994019d22'; export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -40,19 +44,16 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: EnvHelper.isLocalHost - ? import.meta.env.VITE_APP_IPFS_INFURA_API_KEY - : 'be75cf427a5c41f9badb591994019d22', - coreContractChain: 11155111, //the chain id of the network which the core contract relies on - coreRPC: `https://sepolia.infura.io/v3/${infuraAPIKey}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, + infuraAPIKey: infuraProjectId, + coreRPC: `https://sepolia.infura.io/v3/${infuraProjectId}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, mainnetCoreContractChain: 1, aliasRPC: { - 80002: 'https://polygon-amoy.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + 80002: `https://polygon-amoy.infura.io/v3/${infuraProjectId}`, 97: 'https://data-seed-prebsc-1-s1.binance.org:8545', - 11155420: 'https://optimism-sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + 11155420: `https://optimism-sepolia.infura.io/v3/${infuraProjectId}`, 2442: 'https://rpc.cardona.zkevm-rpc.com', - 421614: 'https://arbitrum-sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + 421614: `https://arbitrum-sepolia.infura.io/v3/${infuraProjectId}`, }, infuraApiUrl: 'https:/infura-ipfs.io/ipfs/', @@ -130,7 +131,7 @@ export const CHAIN_DETAILS = { label: 'Ethereum Sepolia', name: 'ETH_TEST_SEPOLIA', chainId: 11155111, - rpcUrl: 'https://sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + rpcUrl: `https://sepolia.infura.io/v3/${config.infuraAPIKey}`, commAddress: '0x0c34d54a09cfe75bccd878a469206ae77e0fe6e7', network: 'sepolia', }, @@ -138,7 +139,7 @@ export const CHAIN_DETAILS = { label: 'Polygon Amoy', name: 'POLYGON_TEST_AMOY', chainId: 80002, - rpcUrl: 'https://polygon-amoy.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + rpcUrl: `https://polygon-amoy.infura.io/v3/${config.infuraAPIKey}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'polygon-amoy', }, @@ -153,7 +154,7 @@ export const CHAIN_DETAILS = { label: 'Optimism Sepolia', name: 'OPTIMISM_TESTNET', chainId: 11155420, - rpcUrl: 'https://optimism-sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + rpcUrl: `https://optimism-sepolia.infura.io/v3/${config.infuraAPIKey}`, commAddress: '0x9Dc25996ba72A2FD7E64e7a674232a683f406F1A', }, 2442: { @@ -167,7 +168,7 @@ export const CHAIN_DETAILS = { label: 'Arbitrum Testnet', name: 'ARBITRUM_TESTNET', chainId: 421614, - rpcUrl: 'https://arbitrum-sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + rpcUrl: `https://arbitrum-sepolia.infura.io/v3/${config.infuraAPIKey}`, commAddress: '0x9Dc25996ba72A2FD7E64e7a674232a683f406F1A', }, 123: { diff --git a/src/hooks/useResolveWeb3Name.ts b/src/hooks/useResolveWeb3Name.ts index 94f27a81d8..f9570ec498 100644 --- a/src/hooks/useResolveWeb3Name.ts +++ b/src/hooks/useResolveWeb3Name.ts @@ -17,12 +17,10 @@ import { appConfig } from '../config/index.js'; const getDomainName = async (checksumWallet: string, setWeb3NameList: any) => { let domainName: string | null = ''; const web3NameClient = createWeb3Name(); - console.debug('in get domain name'); web3NameClient .getDomainName({ address: checksumWallet, queryChainIdList: appConfig.allowedNetworks, - rpcUrl: appConfig.coreRPC, }) .then(async (domain) => { if (domain) { From 10778c0ebcb2b54935bb7653a1b17f60b5f59d2d Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Fri, 11 Oct 2024 17:04:24 +0530 Subject: [PATCH 04/14] fixed re render --- src/components/Profile.tsx | 2 +- src/components/chat/chatsnap/ChatSnap.tsx | 13 +++---- .../chat/w2wChat/chatBox/ChatBox.tsx | 2 +- src/components/chat/w2wChat/chats/Chats.tsx | 2 +- .../chat/w2wChat/profile/Profile.tsx | 2 +- src/hooks/useResolveWeb3Name.ts | 39 ++++++------------- src/modules/gov/GovModule.tsx | 2 +- .../components/LeaderBoardListItem.tsx | 2 +- src/primaries/Profile.tsx | 4 +- 9 files changed, 26 insertions(+), 42 deletions(-) diff --git a/src/components/Profile.tsx b/src/components/Profile.tsx index 1efe6b3c4b..d4d6de4aa9 100644 --- a/src/components/Profile.tsx +++ b/src/components/Profile.tsx @@ -19,7 +19,7 @@ function Profile() { const { account } = useAccount(); const { authError } = useContext(ErrorContext); - useResolveWeb3Name(account); + // useResolveWeb3Name(account); // get ens name from context const ensName = web3NameList[account]; diff --git a/src/components/chat/chatsnap/ChatSnap.tsx b/src/components/chat/chatsnap/ChatSnap.tsx index e2d26f3247..cee4172b0b 100644 --- a/src/components/chat/chatsnap/ChatSnap.tsx +++ b/src/components/chat/chatsnap/ChatSnap.tsx @@ -1,5 +1,5 @@ // React + Web3 Essentials -import React,{useContext} from 'react'; +import React, { useContext } from 'react'; import { ethers } from 'ethers'; // External Packages @@ -35,17 +35,17 @@ interface ChatSnapPropsI { // Other Information section const ChatSnap = ({ pfp, username, chatSnapMsg, timestamp, selected, onClick, isGroup }: ChatSnapPropsI) => { - const { web3NameList }:AppContextType=useContext(AppContext); + const { web3NameList }: AppContextType = useContext(AppContext); let ensName = ''; // get theme const theme = useTheme(); // resolve web3 names - useResolveWeb3Name(!isGroup ? username : null); + // useResolveWeb3Name(!isGroup ? username : null); // get ens name from context - if(!isGroup){ + if (!isGroup) { if (username?.includes(':nft')) { // to match "eip155:" followed by any chainId and replace it with "eip155:" and split the string at ':nft' and keep the part before it username = username.replace(/eip155:\d+:/, 'eip155:').split(':nft')[0]; @@ -108,11 +108,10 @@ const ChatSnap = ({ pfp, username, chatSnapMsg, timestamp, selected, onClick, is let date = null; if (timestamp) { - - if (typeof timestamp === "string" && timestamp?.includes('Z')) { + if (typeof timestamp === 'string' && timestamp?.includes('Z')) { timestamp = timestamp.replace('Z', ''); } - + date = convertTimestampToDateDayTime(new Date(timestamp)); } diff --git a/src/components/chat/w2wChat/chatBox/ChatBox.tsx b/src/components/chat/w2wChat/chatBox/ChatBox.tsx index 59a833c4af..0277a3722d 100644 --- a/src/components/chat/w2wChat/chatBox/ChatBox.tsx +++ b/src/components/chat/w2wChat/chatBox/ChatBox.tsx @@ -75,7 +75,7 @@ const ChatBox = ({ triggerChatParticipant }): JSX.Element => { useClickAway(groupInfoRef, () => setShowGroupInfo(false)); //resolve web3 names - useResolveWeb3Name(!isGroup ? currentChat?.wallets?.split(',')[0].toString() : null); + // useResolveWeb3Name(!isGroup ? currentChat?.wallets?.split(',')[0].toString() : null); // get web3 name let ensName = ''; diff --git a/src/components/chat/w2wChat/chats/Chats.tsx b/src/components/chat/w2wChat/chats/Chats.tsx index 10ef6a6dbf..a071cb0b39 100644 --- a/src/components/chat/w2wChat/chats/Chats.tsx +++ b/src/components/chat/w2wChat/chats/Chats.tsx @@ -51,7 +51,7 @@ export default function Chats({ msg, caip10, messageBeingSent, ApproveIntent, is msg.messageType = 'TwitterFeedLink'; } const walletAddress = shortenText(caip10ToWallet(msg?.fromCAIP10)?.toLowerCase(), 6); - useResolveWeb3Name(msg?.fromCAIP10); + // useResolveWeb3Name(msg?.fromCAIP10); const walletLowercase = caip10ToWallet(msg?.fromCAIP10)?.toLowerCase(); const checksumWallet = walletLowercase ? ethers.utils.getAddress(walletLowercase) : null; diff --git a/src/components/chat/w2wChat/profile/Profile.tsx b/src/components/chat/w2wChat/profile/Profile.tsx index 442a78f872..73069fa770 100644 --- a/src/components/chat/w2wChat/profile/Profile.tsx +++ b/src/components/chat/w2wChat/profile/Profile.tsx @@ -23,7 +23,7 @@ const Profile = ({ setActiveTab, showQR, setShowQR }: any): JSX.Element => { const theme = useTheme(); // resolve web3 name - useResolveWeb3Name(account); + // useResolveWeb3Name(account); const ensName = web3NameList[account]; diff --git a/src/hooks/useResolveWeb3Name.ts b/src/hooks/useResolveWeb3Name.ts index f9570ec498..b5e7b88276 100644 --- a/src/hooks/useResolveWeb3Name.ts +++ b/src/hooks/useResolveWeb3Name.ts @@ -1,13 +1,11 @@ // React + Web3 Essentials import { ethers } from 'ethers'; -import { useContext, useEffect, useState } from 'react'; +import { useContext, useEffect } from 'react'; import { createWeb3Name } from '@web3-name-sdk/core'; // Internal Components import { AppContext } from 'contexts/AppContext'; import { caip10ToWallet } from 'helpers/w2w'; -import { Context } from 'modules/chat/ChatModule'; -import { AppContext as ContextType, MessageIPFS } from 'types/chat'; import { AppContextType } from 'types/context'; // Internal Configs @@ -25,12 +23,11 @@ const getDomainName = async (checksumWallet: string, setWeb3NameList: any) => { .then(async (domain) => { if (domain) { domainName = domain; - setWeb3NameList((prev) => ({ ...prev, [checksumWallet]: domain })); } else { domainName = null; } + setWeb3NameList((prev) => ({ ...prev, [checksumWallet]: domainName })); }); - console.debug('in get domain name', domainName); return domainName; }; @@ -42,24 +39,19 @@ const getUnstoppableName = async (checksumWallet: string, setWeb3NameList: any) // attempt reverse resolution on provided address let udName = await udResolver.reverse(checksumWallet); - if (udName) { - setWeb3NameList((prev) => ({ ...prev, [checksumWallet]: udName })); - } else { + if (!udName) { udName = null; } + setWeb3NameList((prev) => ({ ...prev, [checksumWallet]: udName })); + return udName; }; export function useResolveWeb3Name(address?: string) { - const [web3Name, setWeb3Name] = useState(null); - - const ctx: ContextType = useContext(Context); - const { web3NameList, setWeb3NameList }: AppContextType = useContext(AppContext); useEffect(() => { (async () => { - setWeb3Name(null); if (address) { const walletLowercase = address.includes(':nft') ? caip10ToWallet( @@ -73,20 +65,12 @@ export function useResolveWeb3Name(address?: string) { const checksumWallet = ethers.utils.getAddress(walletLowercase); if (ethers.utils.isAddress(checksumWallet)) { try { - Object.keys(web3NameList).forEach((element) => { - if (web3NameList[checksumWallet]) { - setWeb3Name(web3NameList[checksumWallet]); - return; - } - }); - - let web3Response = - (await getDomainName(checksumWallet, setWeb3NameList)) || - (await getUnstoppableName(checksumWallet, setWeb3NameList)); - // store result - if (web3Response) { - setWeb3Name(web3Response); + if (web3NameList.hasOwnProperty(checksumWallet)) { return; + } else { + console.debug('in web3 name'); + (await getDomainName(checksumWallet, setWeb3NameList)) || + (await getUnstoppableName(checksumWallet, setWeb3NameList)); } } catch (e) { console.debug('Error fetching web3 name from indexDB', e); @@ -95,7 +79,6 @@ export function useResolveWeb3Name(address?: string) { } // no web3 name found - setWeb3Name(''); })(); - }, [ctx?.currentChat, address]); + }, [address]); } diff --git a/src/modules/gov/GovModule.tsx b/src/modules/gov/GovModule.tsx index dcf9249f91..3baa83e8e8 100644 --- a/src/modules/gov/GovModule.tsx +++ b/src/modules/gov/GovModule.tsx @@ -71,7 +71,7 @@ const GovModule = () => { const [transactionMode, setTransactionMode] = useState('gasless'); // Resolving web3 names - useResolveWeb3Name(account); + // useResolveWeb3Name(account); const web3Name = web3NameList[account]; const toggleShowAnswer = (id) => { diff --git a/src/modules/rewards/components/LeaderBoardListItem.tsx b/src/modules/rewards/components/LeaderBoardListItem.tsx index 8109a85f59..5b4ae6dbd7 100644 --- a/src/modules/rewards/components/LeaderBoardListItem.tsx +++ b/src/modules/rewards/components/LeaderBoardListItem.tsx @@ -29,7 +29,7 @@ export type LeaderboardListItemProps = { const LeaderboardListItem: FC = ({ rank, address, points, isLoading }) => { const { web3NameList }: AppContextType = useContext(AppContext)!; - useResolveWeb3Name(address); + // useResolveWeb3Name(address); const web3Name = web3NameList[address]; const displayName = web3Name ? web3Name : shortenText(address, 10, 10); diff --git a/src/primaries/Profile.tsx b/src/primaries/Profile.tsx index d28ea2b45b..3fb1b10823 100644 --- a/src/primaries/Profile.tsx +++ b/src/primaries/Profile.tsx @@ -39,6 +39,7 @@ const Profile = ({ isDarkMode }: { isDarkMode: boolean }) => { }); // resolve web3 name + console.debug('calling hook multiple times'); useResolveWeb3Name(account); const web3Name = web3NameList[account]; @@ -99,6 +100,7 @@ const Profile = ({ isDarkMode }: { isDarkMode: boolean }) => { const handleConnectWallet = () => { connect(); }; + console.debug(web3Name, 'web3name'); const isWalletConnected = !!wallet?.accounts?.length; @@ -128,7 +130,7 @@ const Profile = ({ isDarkMode }: { isDarkMode: boolean }) => { onClick={() => setShowDropdown(!showDropdown)} ref={toggleArrowRef} > - {web3Name === null ? ( + {web3Name === undefined ? ( Date: Fri, 11 Oct 2024 17:43:50 +0530 Subject: [PATCH 05/14] added review changes --- src/App.tsx | 2 +- src/modules/gov/GovModule.tsx | 2 +- src/modules/rewards/components/LeaderBoardListItem.tsx | 2 +- src/primaries/Profile.tsx | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 6cc85ffdf4..a05df39c7b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -356,7 +356,7 @@ export default function App() { { const [transactionMode, setTransactionMode] = useState('gasless'); // Resolving web3 names - // useResolveWeb3Name(account); + useResolveWeb3Name(account); const web3Name = web3NameList[account]; const toggleShowAnswer = (id) => { diff --git a/src/modules/rewards/components/LeaderBoardListItem.tsx b/src/modules/rewards/components/LeaderBoardListItem.tsx index 5b4ae6dbd7..8109a85f59 100644 --- a/src/modules/rewards/components/LeaderBoardListItem.tsx +++ b/src/modules/rewards/components/LeaderBoardListItem.tsx @@ -29,7 +29,7 @@ export type LeaderboardListItemProps = { const LeaderboardListItem: FC = ({ rank, address, points, isLoading }) => { const { web3NameList }: AppContextType = useContext(AppContext)!; - // useResolveWeb3Name(address); + useResolveWeb3Name(address); const web3Name = web3NameList[address]; const displayName = web3Name ? web3Name : shortenText(address, 10, 10); diff --git a/src/primaries/Profile.tsx b/src/primaries/Profile.tsx index 3fb1b10823..c53cdcc179 100644 --- a/src/primaries/Profile.tsx +++ b/src/primaries/Profile.tsx @@ -39,7 +39,6 @@ const Profile = ({ isDarkMode }: { isDarkMode: boolean }) => { }); // resolve web3 name - console.debug('calling hook multiple times'); useResolveWeb3Name(account); const web3Name = web3NameList[account]; @@ -100,7 +99,6 @@ const Profile = ({ isDarkMode }: { isDarkMode: boolean }) => { const handleConnectWallet = () => { connect(); }; - console.debug(web3Name, 'web3name'); const isWalletConnected = !!wallet?.accounts?.length; From 9b5c1787018238c0418f1502ddc18552c7c0e51d Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Fri, 11 Oct 2024 18:04:13 +0530 Subject: [PATCH 06/14] added exp sdk verion --- package.json | 2 +- yarn.lock | 31 +++++++------------------------ 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index d97c238a00..038c993c2b 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@mui/material": "^5.5.0", "@pushprotocol/restapi": "1.7.25", "@pushprotocol/socket": "0.5.3", - "@pushprotocol/uiweb": "1.5.0", + "@pushprotocol/uiweb": "2.0.0-exp.7", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-switch": "^1.1.0", diff --git a/yarn.lock b/yarn.lock index e5fe044936..66b86d0fd9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3990,16 +3990,16 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/uiweb@npm:1.5.0": - version: 1.5.0 - resolution: "@pushprotocol/uiweb@npm:1.5.0" +"@pushprotocol/uiweb@npm:2.0.0-exp.7": + version: 2.0.0-exp.7 + resolution: "@pushprotocol/uiweb@npm:2.0.0-exp.7" dependencies: "@livekit/components-react": "npm:^1.2.2" "@livekit/components-styles": "npm:^1.0.6" "@livepeer/react": "npm:^2.6.0" "@pushprotocol/socket": "npm:^0.5.0" "@unstoppabledomains/resolution": "npm:^8.5.0" - "@web3-name-sdk/core": "npm:^0.1.15" + "@web3-name-sdk/core": "npm:^0.2.0" "@web3-onboard/coinbase": "npm:^2.2.5" "@web3-onboard/core": "npm:^2.21.1" "@web3-onboard/injected-wallets": "npm:^2.10.5" @@ -4034,7 +4034,7 @@ __metadata: react-dom: 17.0.2 styled-components: ^6.0.8 viem: ^1.3.0 - checksum: 10/43eba2cab26c15c06dbaaade167e65f843dda4381b2daf9206c6931b4582c0282ac79f6ca9baafa687f3c86bd5ae2324bc5f01d853a9b7eb56aafa74f68e2e33 + checksum: 10/1e13a109b4468a32a1fcb90c311e8ccee227005e4162aac05721660ebcc6c856bb95e6327f9f528966d523d0642ab57623bebb15d0abf20f67ee8df6bd2e28ec languageName: node linkType: hard @@ -7948,23 +7948,6 @@ __metadata: languageName: node linkType: hard -"@web3-name-sdk/core@npm:^0.1.15": - version: 0.1.18 - resolution: "@web3-name-sdk/core@npm:0.1.18" - dependencies: - "@adraffy/ens-normalize": "npm:^1.10.0" - "@ensdomains/ens-validation": "npm:^0.1.0" - viem: "npm:^1.20" - peerDependencies: - "@bonfida/spl-name-service": ^1.4.0 - "@sei-js/core": ^3.1.0 - "@siddomains/injective-sidjs": 0.0.2-beta - "@siddomains/sei-sidjs": ^0.0.4 - "@solana/web3.js": ^1.75.0 - checksum: 10/eebbc7f28ae67cf92c558dc61fae28e5242386416a5d225082f8091eab8ad958257e9a534defc42218d00aa5ca9d04700226e16fa992da28e2e8e77af932337c - languageName: node - linkType: hard - "@web3-name-sdk/core@npm:^0.2.0": version: 0.2.0 resolution: "@web3-name-sdk/core@npm:0.2.0" @@ -18290,7 +18273,7 @@ __metadata: "@mui/material": "npm:^5.5.0" "@pushprotocol/restapi": "npm:1.7.25" "@pushprotocol/socket": "npm:0.5.3" - "@pushprotocol/uiweb": "npm:1.5.0" + "@pushprotocol/uiweb": "npm:2.0.0-exp.7" "@radix-ui/react-dialog": "npm:^1.1.1" "@radix-ui/react-dropdown-menu": "npm:^2.1.1" "@radix-ui/react-switch": "npm:^1.1.0" @@ -22106,7 +22089,7 @@ __metadata: languageName: node linkType: hard -"viem@npm:^1.20, viem@npm:^1.20.3": +"viem@npm:^1.20.3": version: 1.21.4 resolution: "viem@npm:1.21.4" dependencies: From e7160c30d93f19b9d4f2f6e7803cfbf2d185667a Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Fri, 11 Oct 2024 18:07:23 +0530 Subject: [PATCH 07/14] added exp sdk verion --- basePath.js | 4 ++++ src/config/config-alpha.js | 7 +++---- src/config/config-dev.js | 7 +++---- src/config/config-prod.js | 7 +++---- src/config/config-staging.js | 7 +++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/basePath.js b/basePath.js index 0348210880..e38df2b761 100644 --- a/basePath.js +++ b/basePath.js @@ -8,3 +8,7 @@ export function getPreviewBasePath() { } return ''; } + +export function getInfuraAPIKey(key) { + return window.location.hostname === 'localhost' ? import.meta.env.VITE_APP_INFURA_PROJECT_ID : key; +} diff --git a/src/config/config-alpha.js b/src/config/config-alpha.js index 54b5e29530..b253b396ec 100644 --- a/src/config/config-alpha.js +++ b/src/config/config-alpha.js @@ -1,8 +1,7 @@ +import { getInfuraAPIKey } from '../../basePath'; + // environmental configurations for the dapp for different environments -const infuraProjectId = - window.location.hostname == 'localhost' - ? import.meta.env.VITE_APP_INFURA_PROJECT_ID - : 'dd262cc008764b29bd6a15249db4772e'; +const infuraProjectId = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection diff --git a/src/config/config-dev.js b/src/config/config-dev.js index f047295bdf..ed5b18d473 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -1,8 +1,7 @@ +import { getInfuraAPIKey } from '../../basePath'; + // environmental configurations for the dapp for different environments -const infuraProjectId = - window.location.hostname == 'localhost' - ? import.meta.env.VITE_APP_INFURA_PROJECT_ID - : 'be75cf427a5c41f9badb591994019d22'; +const infuraProjectId = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection diff --git a/src/config/config-prod.js b/src/config/config-prod.js index 12a0526cac..588d4dc529 100644 --- a/src/config/config-prod.js +++ b/src/config/config-prod.js @@ -1,8 +1,7 @@ +import { getInfuraAPIKey } from '../../basePath'; + // environmental configurations for the dapp for different environments -const infuraProjectId = - window.location.hostname == 'localhost' - ? import.meta.env.VITE_APP_INFURA_PROJECT_ID - : 'dd262cc008764b29bd6a15249db4772e'; +const infuraProjectId = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection diff --git a/src/config/config-staging.js b/src/config/config-staging.js index 8f2860c759..d2daeebe18 100644 --- a/src/config/config-staging.js +++ b/src/config/config-staging.js @@ -1,8 +1,7 @@ +import { getInfuraAPIKey } from '../../basePath'; + // environmental configurations for the dapp for different environments -const infuraProjectId = - window.location.hostname == 'localhost' - ? import.meta.env.VITE_APP_INFURA_PROJECT_ID - : 'be75cf427a5c41f9badb591994019d22'; +const infuraProjectId = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection From 1cd778c4b1a4dda26527bc6040c45fccf9981256 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 14 Oct 2024 13:37:15 +0530 Subject: [PATCH 08/14] fixed review comments --- basePath.js | 7 ++++++- package.json | 2 +- src/config/config-alpha.js | 14 +++++++------- src/config/config-dev.js | 14 +++++++------- src/config/config-general.js | 1 - src/config/config-localhost.js | 13 +++++++------ src/config/config-prod.js | 10 +++++----- src/config/config-staging.js | 14 +++++++------- src/hooks/useResolveWeb3Name.ts | 1 - yarn.lock | 10 +++++----- 10 files changed, 45 insertions(+), 41 deletions(-) diff --git a/basePath.js b/basePath.js index e38df2b761..0e8adde394 100644 --- a/basePath.js +++ b/basePath.js @@ -9,6 +9,11 @@ export function getPreviewBasePath() { return ''; } +/* +This checks if the current domain is localhost and uses the localhost Infura key accordingly. +*/ export function getInfuraAPIKey(key) { - return window.location.hostname === 'localhost' ? import.meta.env.VITE_APP_INFURA_PROJECT_ID : key; + return window.location.hostname === 'localhost' && typeof import.meta !== 'undefined' && import.meta.env + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : key; } diff --git a/package.json b/package.json index 038c993c2b..0a40357821 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@mui/material": "^5.5.0", "@pushprotocol/restapi": "1.7.25", "@pushprotocol/socket": "0.5.3", - "@pushprotocol/uiweb": "2.0.0-exp.7", + "@pushprotocol/uiweb": "2.0.0-exp.8", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-switch": "^1.1.0", diff --git a/src/config/config-alpha.js b/src/config/config-alpha.js index b253b396ec..9087b34d17 100644 --- a/src/config/config-alpha.js +++ b/src/config/config-alpha.js @@ -1,7 +1,7 @@ import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraProjectId = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); +const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -40,13 +40,13 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: infuraProjectId, + infuraAPIKey: infuraAPIKey, coreContractChain: 1, //the chain id of the network which the core contract relies on - coreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, + coreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, mainnetCoreContractChain: 1, aliasRPC: { - 137: `https://polygon-mainnet.infura.io/v3/${infuraProjectId}`, + 137: `https://polygon-mainnet.infura.io/v3/${infuraAPIKey}`, 56: 'https://bsc-dataseed.binance.org/', 10: 'https://opt-mainnet.g.alchemy.com/v2/JYW0UaSC5Zd0hrI6vE2K9VN1wJupoY5B', 42161: 'https://arb1.arbitrum.io/rpc', @@ -124,7 +124,7 @@ export const CHAIN_DETAILS = { label: 'Ethereum Mainnet', name: 'ETH_MAINNET', chainId: 1, - rpcUrl: `https://mainnet.infura.io/v3/${infuraProjectId}`, + rpcUrl: `https://mainnet.infura.io/v3/${infuraAPIKey}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'mainnet', }, @@ -132,7 +132,7 @@ export const CHAIN_DETAILS = { label: 'Polygon Mainnet', name: 'POLYGON_MAINNET', chainId: 137, - rpcUrl: `https://polygon-mainnet.infura.io/v3/${infuraProjectId}`, + rpcUrl: `https://polygon-mainnet.infura.io/v3/${infuraAPIKey}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'polygon-mainnet', }, diff --git a/src/config/config-dev.js b/src/config/config-dev.js index ed5b18d473..ebfead3215 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -1,7 +1,7 @@ import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraProjectId = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); +const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -42,17 +42,17 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: infuraProjectId, + infuraAPIKey: infuraAPIKey, coreContractChain: 11155111, //the chain id of the network which the core contract relies on - coreRPC: `https://sepolia.infura.io/v3/${infuraProjectId}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, + coreRPC: `https://sepolia.infura.io/v3/${infuraAPIKey}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, mainnetCoreContractChain: 1, aliasRPC: { - 80002: `https://polygon-amoy.infura.io/v3/${infuraProjectId}`, + 80002: `https://polygon-amoy.infura.io/v3/${infuraAPIKey}`, 97: `https://data-seed-prebsc-1-s1.binance.org:8545`, - 11155420: `https://optimism-sepolia.infura.io/v3/${infuraProjectId}`, + 11155420: `https://optimism-sepolia.infura.io/v3/${infuraAPIKey}`, 2442: 'https://rpc.cardona.zkevm-rpc.com', - 421614: `https://arbitrum-sepolia.infura.io/v3/${infuraProjectId}`, + 421614: `https://arbitrum-sepolia.infura.io/v3/${infuraAPIKey}`, }, infuraApiUrl: 'https:/infura-ipfs.io/ipfs/', diff --git a/src/config/config-general.js b/src/config/config-general.js index 82c1a11523..9bfcf45a98 100644 --- a/src/config/config-general.js +++ b/src/config/config-general.js @@ -19,7 +19,6 @@ import stakingV2Abi from './abis/StakingV2.json'; // for new staking V2 Contract import uniV2LpTokenAbi from './abis/UniV2LPToken.json'; // for new staking V2 Contract on staging import PushCoreV2 from './abis/PushCoreV2.json'; import PushRevealAbi from './abis/PushReveal.json'; -import { InfuraAPIKey } from '@pushprotocol/uiweb'; export const abis = { erc20: erc20Abi, diff --git a/src/config/config-localhost.js b/src/config/config-localhost.js index b6e7bd51b6..686b871736 100644 --- a/src/config/config-localhost.js +++ b/src/config/config-localhost.js @@ -1,4 +1,5 @@ // environmental configurations for the dapp for different environments +const infuraAPIKey = import.meta.env.VITE_APP_INFURA_PROJECT_ID || ''; export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -31,10 +32,10 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: import.meta.env.VITE_APP_INFURA_PROJECT_ID, + infuraAPIKey: infuraAPIKey, coreContractChain: 5, //the chain id of the network which the core contract relies on - coreRPC: `https://goerli.infura.io/v3/${import.meta.env.VITE_APP_INFURA_PROJECT_ID}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${import.meta.env.VITE_APP_INFURA_PROJECT_ID}`, + coreRPC: `https://goerli.infura.io/v3/${infuraAPIKey}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, mainnetCoreContractChain: 1, aliasRPC: { 80002: 'https://polygon-amoy.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', @@ -100,7 +101,7 @@ export const CHAIN_DETAILS = { label: 'Ethereum Goerli', name: 'ETH_TEST_GOERLI', chainId: 5, - rpcUrl: `https://goerli.infura.io/v3/${import.meta.env.VITE_APP_INFURA_PROJECT_ID}`, + rpcUrl: `https://goerli.infura.io/v3/${infuraAPIKey}`, commAddress: '0xc064F30bac07e84500c97A04D21a9d1bfFC72Ec0', network: 'goerli', }, @@ -108,7 +109,7 @@ export const CHAIN_DETAILS = { label: 'Polygon Amoy', name: 'POLYGON_TEST_AMOY', chainId: 80002, - rpcUrl: `https://polygon-amoy.infura.io/v3/${import.meta.env.VITE_APP_INFURA_PROJECT_ID}`, + rpcUrl: `https://polygon-amoy.infura.io/v3/${infuraAPIKey}`, commAddress: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', network: 'polygon-amoy', }, @@ -123,7 +124,7 @@ export const CHAIN_DETAILS = { label: 'Optimism Sepolia', name: 'OPTIMISM_TESTNET', chainId: 11155420, - rpcUrl: `https://optimism-sepolia.infura.io/v3/${import.meta.env.VITE_APP_INFURA_PROJECT_ID}`, + rpcUrl: `https://optimism-sepolia.infura.io/v3/${infuraAPIKey}`, commAddress: '0x9Dc25996ba72A2FD7E64e7a674232a683f406F1A', }, }; diff --git a/src/config/config-prod.js b/src/config/config-prod.js index 588d4dc529..1c75e7477e 100644 --- a/src/config/config-prod.js +++ b/src/config/config-prod.js @@ -1,7 +1,7 @@ import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraProjectId = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); +const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -41,13 +41,13 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: infuraProjectId, + infuraAPIKey: infuraAPIKey, coreContractChain: 1, //the chain id of the network which the core contract relies on - coreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, + coreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, mainnetCoreContractChain: 1, aliasRPC: { - 137: `https://polygon-mainnet.infura.io/v3/${infuraProjectId}`, + 137: `https://polygon-mainnet.infura.io/v3/${infuraAPIKey}`, 56: 'https://bsc-dataseed.binance.org/', 10: 'https://opt-mainnet.g.alchemy.com/v2/JYW0UaSC5Zd0hrI6vE2K9VN1wJupoY5B', 42161: 'https://arb1.arbitrum.io/rpc', diff --git a/src/config/config-staging.js b/src/config/config-staging.js index d2daeebe18..d7e9d1bbc3 100644 --- a/src/config/config-staging.js +++ b/src/config/config-staging.js @@ -1,7 +1,7 @@ import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraProjectId = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); +const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -43,16 +43,16 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: infuraProjectId, - coreRPC: `https://sepolia.infura.io/v3/${infuraProjectId}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, + infuraAPIKey: infuraAPIKey, + coreRPC: `https://sepolia.infura.io/v3/${infuraAPIKey}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, mainnetCoreContractChain: 1, aliasRPC: { - 80002: `https://polygon-amoy.infura.io/v3/${infuraProjectId}`, + 80002: `https://polygon-amoy.infura.io/v3/${infuraAPIKey}`, 97: 'https://data-seed-prebsc-1-s1.binance.org:8545', - 11155420: `https://optimism-sepolia.infura.io/v3/${infuraProjectId}`, + 11155420: `https://optimism-sepolia.infura.io/v3/${infuraAPIKey}`, 2442: 'https://rpc.cardona.zkevm-rpc.com', - 421614: `https://arbitrum-sepolia.infura.io/v3/${infuraProjectId}`, + 421614: `https://arbitrum-sepolia.infura.io/v3/${infuraAPIKey}`, }, infuraApiUrl: 'https:/infura-ipfs.io/ipfs/', diff --git a/src/hooks/useResolveWeb3Name.ts b/src/hooks/useResolveWeb3Name.ts index b5e7b88276..c07f9ecd7a 100644 --- a/src/hooks/useResolveWeb3Name.ts +++ b/src/hooks/useResolveWeb3Name.ts @@ -68,7 +68,6 @@ export function useResolveWeb3Name(address?: string) { if (web3NameList.hasOwnProperty(checksumWallet)) { return; } else { - console.debug('in web3 name'); (await getDomainName(checksumWallet, setWeb3NameList)) || (await getUnstoppableName(checksumWallet, setWeb3NameList)); } diff --git a/yarn.lock b/yarn.lock index 66b86d0fd9..b39b0d87e4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3990,9 +3990,9 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/uiweb@npm:2.0.0-exp.7": - version: 2.0.0-exp.7 - resolution: "@pushprotocol/uiweb@npm:2.0.0-exp.7" +"@pushprotocol/uiweb@npm:2.0.0-exp.8": + version: 2.0.0-exp.8 + resolution: "@pushprotocol/uiweb@npm:2.0.0-exp.8" dependencies: "@livekit/components-react": "npm:^1.2.2" "@livekit/components-styles": "npm:^1.0.6" @@ -4034,7 +4034,7 @@ __metadata: react-dom: 17.0.2 styled-components: ^6.0.8 viem: ^1.3.0 - checksum: 10/1e13a109b4468a32a1fcb90c311e8ccee227005e4162aac05721660ebcc6c856bb95e6327f9f528966d523d0642ab57623bebb15d0abf20f67ee8df6bd2e28ec + checksum: 10/f4b15fefddce852c63f032445b0015aa2e5d55b6a9f1fdc9f61e586a2352ca673055d59e494724b09dc101388e62736518b52f31af07331bb2b6daac8cb84811 languageName: node linkType: hard @@ -18273,7 +18273,7 @@ __metadata: "@mui/material": "npm:^5.5.0" "@pushprotocol/restapi": "npm:1.7.25" "@pushprotocol/socket": "npm:0.5.3" - "@pushprotocol/uiweb": "npm:2.0.0-exp.7" + "@pushprotocol/uiweb": "npm:2.0.0-exp.8" "@radix-ui/react-dialog": "npm:^1.1.1" "@radix-ui/react-dropdown-menu": "npm:^2.1.1" "@radix-ui/react-switch": "npm:^1.1.0" From b9b760f0488c1bab05d1e1fa82de27339a2ef96f Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 14 Oct 2024 13:46:30 +0530 Subject: [PATCH 09/14] checking deploy preview --- basePath.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/basePath.js b/basePath.js index 0e8adde394..9169fcf358 100644 --- a/basePath.js +++ b/basePath.js @@ -13,7 +13,5 @@ export function getPreviewBasePath() { This checks if the current domain is localhost and uses the localhost Infura key accordingly. */ export function getInfuraAPIKey(key) { - return window.location.hostname === 'localhost' && typeof import.meta !== 'undefined' && import.meta.env - ? import.meta.env.VITE_APP_INFURA_PROJECT_ID - : key; + return window.location.hostname === 'localhost' ? key : key; } From 22f4b24e1ac5f3a1d9bcbc8a1f2d740fc3b3146f Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 14 Oct 2024 13:53:02 +0530 Subject: [PATCH 10/14] checking deploy preview --- basePath.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basePath.js b/basePath.js index 9169fcf358..d98754a6fb 100644 --- a/basePath.js +++ b/basePath.js @@ -13,5 +13,5 @@ export function getPreviewBasePath() { This checks if the current domain is localhost and uses the localhost Infura key accordingly. */ export function getInfuraAPIKey(key) { - return window.location.hostname === 'localhost' ? key : key; + return key; } From 41f988b1e515d7ba1b761128e67a3adbacc7999f Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 14 Oct 2024 14:00:51 +0530 Subject: [PATCH 11/14] checking deploy preview --- basePath.js | 6 +++--- src/config/config-alpha.js | 6 +++++- src/config/config-dev.js | 5 ++++- src/config/config-prod.js | 6 +++++- src/config/config-staging.js | 6 +++++- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/basePath.js b/basePath.js index d98754a6fb..0c4b1fb6f8 100644 --- a/basePath.js +++ b/basePath.js @@ -12,6 +12,6 @@ export function getPreviewBasePath() { /* This checks if the current domain is localhost and uses the localhost Infura key accordingly. */ -export function getInfuraAPIKey(key) { - return key; -} +// export function getInfuraAPIKey(key) { +// return window.location.hostname === 'localhost' ? import.meta.env.VITE_APP_INFURA_PROJECT_ID : key; +// } diff --git a/src/config/config-alpha.js b/src/config/config-alpha.js index 9087b34d17..e232138c5e 100644 --- a/src/config/config-alpha.js +++ b/src/config/config-alpha.js @@ -1,7 +1,11 @@ import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); +const infuraAPIKey = + window.location.hostname === 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'dd262cc008764b29bd6a15249db4772e'; +// const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection diff --git a/src/config/config-dev.js b/src/config/config-dev.js index ebfead3215..8451c4de23 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -1,7 +1,10 @@ import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); +const infuraAPIKey = + window.location.hostname === 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'be75cf427a5c41f9badb591994019d22'; export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection diff --git a/src/config/config-prod.js b/src/config/config-prod.js index 1c75e7477e..e0e6803d8c 100644 --- a/src/config/config-prod.js +++ b/src/config/config-prod.js @@ -1,7 +1,11 @@ import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); +const infuraAPIKey = + window.location.hostname === 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'dd262cc008764b29bd6a15249db4772e'; +// const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection diff --git a/src/config/config-staging.js b/src/config/config-staging.js index d7e9d1bbc3..4f9a610633 100644 --- a/src/config/config-staging.js +++ b/src/config/config-staging.js @@ -1,7 +1,11 @@ import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); +const infuraAPIKey = + window.location.hostname === 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'be75cf427a5c41f9badb591994019d22'; +// const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection From 557b764a5b7bb2fc407305d166bb397166d75619 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 14 Oct 2024 14:01:47 +0530 Subject: [PATCH 12/14] checking deploy preview --- src/config/config-alpha.js | 2 +- src/config/config-dev.js | 2 +- src/config/config-prod.js | 2 +- src/config/config-staging.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config/config-alpha.js b/src/config/config-alpha.js index e232138c5e..16ae5d5999 100644 --- a/src/config/config-alpha.js +++ b/src/config/config-alpha.js @@ -1,4 +1,4 @@ -import { getInfuraAPIKey } from '../../basePath'; +// import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments const infuraAPIKey = diff --git a/src/config/config-dev.js b/src/config/config-dev.js index 8451c4de23..40829b0f79 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -1,4 +1,4 @@ -import { getInfuraAPIKey } from '../../basePath'; +// import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments const infuraAPIKey = diff --git a/src/config/config-prod.js b/src/config/config-prod.js index e0e6803d8c..3cbd449e03 100644 --- a/src/config/config-prod.js +++ b/src/config/config-prod.js @@ -1,4 +1,4 @@ -import { getInfuraAPIKey } from '../../basePath'; +// import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments const infuraAPIKey = diff --git a/src/config/config-staging.js b/src/config/config-staging.js index 4f9a610633..056a06e2f7 100644 --- a/src/config/config-staging.js +++ b/src/config/config-staging.js @@ -1,4 +1,4 @@ -import { getInfuraAPIKey } from '../../basePath'; +// import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments const infuraAPIKey = From 5a15ee5a2e21839db6263f1f024b3ee59f696bea Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 14 Oct 2024 14:48:31 +0530 Subject: [PATCH 13/14] checking deploy preview --- basePath.js | 8 +++++--- src/config/config-alpha.js | 20 ++++++++------------ src/config/config-dev.js | 7 ++----- src/config/config-prod.js | 8 ++------ src/config/config-staging.js | 8 ++------ 5 files changed, 19 insertions(+), 32 deletions(-) diff --git a/basePath.js b/basePath.js index 0c4b1fb6f8..0e8adde394 100644 --- a/basePath.js +++ b/basePath.js @@ -12,6 +12,8 @@ export function getPreviewBasePath() { /* This checks if the current domain is localhost and uses the localhost Infura key accordingly. */ -// export function getInfuraAPIKey(key) { -// return window.location.hostname === 'localhost' ? import.meta.env.VITE_APP_INFURA_PROJECT_ID : key; -// } +export function getInfuraAPIKey(key) { + return window.location.hostname === 'localhost' && typeof import.meta !== 'undefined' && import.meta.env + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : key; +} diff --git a/src/config/config-alpha.js b/src/config/config-alpha.js index 16ae5d5999..b253b396ec 100644 --- a/src/config/config-alpha.js +++ b/src/config/config-alpha.js @@ -1,11 +1,7 @@ -// import { getInfuraAPIKey } from '../../basePath'; +import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = - window.location.hostname === 'localhost' - ? import.meta.env.VITE_APP_INFURA_PROJECT_ID - : 'dd262cc008764b29bd6a15249db4772e'; -// const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); +const infuraProjectId = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -44,13 +40,13 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: infuraAPIKey, + infuraAPIKey: infuraProjectId, coreContractChain: 1, //the chain id of the network which the core contract relies on - coreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, + coreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, mainnetCoreContractChain: 1, aliasRPC: { - 137: `https://polygon-mainnet.infura.io/v3/${infuraAPIKey}`, + 137: `https://polygon-mainnet.infura.io/v3/${infuraProjectId}`, 56: 'https://bsc-dataseed.binance.org/', 10: 'https://opt-mainnet.g.alchemy.com/v2/JYW0UaSC5Zd0hrI6vE2K9VN1wJupoY5B', 42161: 'https://arb1.arbitrum.io/rpc', @@ -128,7 +124,7 @@ export const CHAIN_DETAILS = { label: 'Ethereum Mainnet', name: 'ETH_MAINNET', chainId: 1, - rpcUrl: `https://mainnet.infura.io/v3/${infuraAPIKey}`, + rpcUrl: `https://mainnet.infura.io/v3/${infuraProjectId}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'mainnet', }, @@ -136,7 +132,7 @@ export const CHAIN_DETAILS = { label: 'Polygon Mainnet', name: 'POLYGON_MAINNET', chainId: 137, - rpcUrl: `https://polygon-mainnet.infura.io/v3/${infuraAPIKey}`, + rpcUrl: `https://polygon-mainnet.infura.io/v3/${infuraProjectId}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'polygon-mainnet', }, diff --git a/src/config/config-dev.js b/src/config/config-dev.js index 40829b0f79..ebfead3215 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -1,10 +1,7 @@ -// import { getInfuraAPIKey } from '../../basePath'; +import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = - window.location.hostname === 'localhost' - ? import.meta.env.VITE_APP_INFURA_PROJECT_ID - : 'be75cf427a5c41f9badb591994019d22'; +const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection diff --git a/src/config/config-prod.js b/src/config/config-prod.js index 3cbd449e03..1c75e7477e 100644 --- a/src/config/config-prod.js +++ b/src/config/config-prod.js @@ -1,11 +1,7 @@ -// import { getInfuraAPIKey } from '../../basePath'; +import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = - window.location.hostname === 'localhost' - ? import.meta.env.VITE_APP_INFURA_PROJECT_ID - : 'dd262cc008764b29bd6a15249db4772e'; -// const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); +const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection diff --git a/src/config/config-staging.js b/src/config/config-staging.js index 056a06e2f7..d7e9d1bbc3 100644 --- a/src/config/config-staging.js +++ b/src/config/config-staging.js @@ -1,11 +1,7 @@ -// import { getInfuraAPIKey } from '../../basePath'; +import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = - window.location.hostname === 'localhost' - ? import.meta.env.VITE_APP_INFURA_PROJECT_ID - : 'be75cf427a5c41f9badb591994019d22'; -// const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); +const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection From 32edaa1cb71b383936d16eeb8e0cc55b28a1e3c5 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 14 Oct 2024 15:05:58 +0530 Subject: [PATCH 14/14] checking deploy preview --- basePath.js | 16 ++++++++-------- src/config/config-alpha.js | 20 ++++++++++++-------- src/config/config-dev.js | 7 +++++-- src/config/config-prod.js | 8 ++++++-- src/config/config-staging.js | 8 ++++++-- 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/basePath.js b/basePath.js index 0e8adde394..98b0ed4f49 100644 --- a/basePath.js +++ b/basePath.js @@ -9,11 +9,11 @@ export function getPreviewBasePath() { return ''; } -/* -This checks if the current domain is localhost and uses the localhost Infura key accordingly. -*/ -export function getInfuraAPIKey(key) { - return window.location.hostname === 'localhost' && typeof import.meta !== 'undefined' && import.meta.env - ? import.meta.env.VITE_APP_INFURA_PROJECT_ID - : key; -} +// /* +// This checks if the current domain is localhost and uses the localhost Infura key accordingly. +// */ +// export function getInfuraAPIKey(key) { +// return window.location.hostname === 'localhost' && typeof import.meta !== 'undefined' && import.meta.env +// ? import.meta.env.VITE_APP_INFURA_PROJECT_ID +// : key; +// } diff --git a/src/config/config-alpha.js b/src/config/config-alpha.js index b253b396ec..16ae5d5999 100644 --- a/src/config/config-alpha.js +++ b/src/config/config-alpha.js @@ -1,7 +1,11 @@ -import { getInfuraAPIKey } from '../../basePath'; +// import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraProjectId = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); +const infuraAPIKey = + window.location.hostname === 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'dd262cc008764b29bd6a15249db4772e'; +// const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection @@ -40,13 +44,13 @@ export const config = { /** * Core Network Related Data */ - infuraAPIKey: infuraProjectId, + infuraAPIKey: infuraAPIKey, coreContractChain: 1, //the chain id of the network which the core contract relies on - coreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, - mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraProjectId}`, + coreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, + mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`, mainnetCoreContractChain: 1, aliasRPC: { - 137: `https://polygon-mainnet.infura.io/v3/${infuraProjectId}`, + 137: `https://polygon-mainnet.infura.io/v3/${infuraAPIKey}`, 56: 'https://bsc-dataseed.binance.org/', 10: 'https://opt-mainnet.g.alchemy.com/v2/JYW0UaSC5Zd0hrI6vE2K9VN1wJupoY5B', 42161: 'https://arb1.arbitrum.io/rpc', @@ -124,7 +128,7 @@ export const CHAIN_DETAILS = { label: 'Ethereum Mainnet', name: 'ETH_MAINNET', chainId: 1, - rpcUrl: `https://mainnet.infura.io/v3/${infuraProjectId}`, + rpcUrl: `https://mainnet.infura.io/v3/${infuraAPIKey}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'mainnet', }, @@ -132,7 +136,7 @@ export const CHAIN_DETAILS = { label: 'Polygon Mainnet', name: 'POLYGON_MAINNET', chainId: 137, - rpcUrl: `https://polygon-mainnet.infura.io/v3/${infuraProjectId}`, + rpcUrl: `https://polygon-mainnet.infura.io/v3/${infuraAPIKey}`, commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', network: 'polygon-mainnet', }, diff --git a/src/config/config-dev.js b/src/config/config-dev.js index ebfead3215..40829b0f79 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -1,7 +1,10 @@ -import { getInfuraAPIKey } from '../../basePath'; +// import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); +const infuraAPIKey = + window.location.hostname === 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'be75cf427a5c41f9badb591994019d22'; export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection diff --git a/src/config/config-prod.js b/src/config/config-prod.js index 1c75e7477e..3cbd449e03 100644 --- a/src/config/config-prod.js +++ b/src/config/config-prod.js @@ -1,7 +1,11 @@ -import { getInfuraAPIKey } from '../../basePath'; +// import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); +const infuraAPIKey = + window.location.hostname === 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'dd262cc008764b29bd6a15249db4772e'; +// const infuraAPIKey = getInfuraAPIKey('dd262cc008764b29bd6a15249db4772e'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection diff --git a/src/config/config-staging.js b/src/config/config-staging.js index d7e9d1bbc3..056a06e2f7 100644 --- a/src/config/config-staging.js +++ b/src/config/config-staging.js @@ -1,7 +1,11 @@ -import { getInfuraAPIKey } from '../../basePath'; +// import { getInfuraAPIKey } from '../../basePath'; // environmental configurations for the dapp for different environments -const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); +const infuraAPIKey = + window.location.hostname === 'localhost' + ? import.meta.env.VITE_APP_INFURA_PROJECT_ID + : 'be75cf427a5c41f9badb591994019d22'; +// const infuraAPIKey = getInfuraAPIKey('be75cf427a5c41f9badb591994019d22'); export const config = { /** * Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection