Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infura key #1919

Closed
wants to merge 15 commits into from
9 changes: 9 additions & 0 deletions basePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ 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;
// }
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@mui/material": "^5.5.0",
"@pushprotocol/restapi": "1.7.25",
"@pushprotocol/socket": "0.5.3",
"@pushprotocol/uiweb": "1.6.0-alpha.8",
"@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",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
13 changes: 6 additions & 7 deletions src/components/chat/chatsnap/ChatSnap.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// React + Web3 Essentials
import React,{useContext} from 'react';
import React, { useContext } from 'react';
import { ethers } from 'ethers';

// External Packages
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/chat/w2wChat/chatBox/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
2 changes: 1 addition & 1 deletion src/components/chat/w2wChat/chats/Chats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/components/chat/w2wChat/profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
18 changes: 13 additions & 5 deletions src/config/config-alpha.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// 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');
export const config = {
/**
* Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection
Expand Down Expand Up @@ -37,12 +44,13 @@ export const config = {
/**
* Core Network Related Data
*/
infuraAPIKey: infuraAPIKey,
coreContractChain: 1, //the chain id of the network which the core contract relies on
coreRPC: 'https://mainnet.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
mainnetCoreRPC: 'https://mainnet.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
coreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`,
mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`,
mainnetCoreContractChain: 1,
aliasRPC: {
137: 'https://polygon-mainnet.infura.io/v3/150f25623ae64d08ab7ec7dd0c6b6ee9',
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',
Expand Down Expand Up @@ -120,15 +128,15 @@ export const CHAIN_DETAILS = {
label: 'Ethereum Mainnet',
name: 'ETH_MAINNET',
chainId: 1,
rpcUrl: 'https://mainnet.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
rpcUrl: `https://mainnet.infura.io/v3/${infuraAPIKey}`,
commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
network: 'mainnet',
},
137: {
label: 'Polygon Mainnet',
name: 'POLYGON_MAINNET',
chainId: 137,
rpcUrl: 'https://polygon-mainnet.infura.io/v3/150f25623ae64d08ab7ec7dd0c6b6ee9',
rpcUrl: `https://polygon-mainnet.infura.io/v3/${infuraAPIKey}`,
commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
network: 'polygon-mainnet',
},
Expand Down
27 changes: 17 additions & 10 deletions src/config/config-dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// 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';
export const config = {
/**
* Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection
Expand Down Expand Up @@ -39,16 +45,17 @@ export const config = {
/**
* Core Network Related Data
*/
infuraAPIKey: infuraAPIKey,
coreContractChain: 11155111, //the chain id of the network which the core contract relies on
coreRPC: 'https://ethereum-sepolia-rpc.publicnode.com',
mainnetCoreRPC: 'https://mainnet.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
coreRPC: `https://sepolia.infura.io/v3/${infuraAPIKey}`,
mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`,
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/${infuraAPIKey}`,
97: `https://data-seed-prebsc-1-s1.binance.org:8545`,
11155420: `https://optimism-sepolia.infura.io/v3/${infuraAPIKey}`,
2442: 'https://rpc.cardona.zkevm-rpc.com',
421614: 'https://arbitrum-sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7',
421614: `https://arbitrum-sepolia.infura.io/v3/${infuraAPIKey}`,
},
infuraApiUrl: 'https:/infura-ipfs.io/ipfs/',

Expand Down Expand Up @@ -130,15 +137,15 @@ 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',
},
80002: {
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',
},
Expand All @@ -153,7 +160,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: {
Expand All @@ -167,7 +174,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: {
Expand Down
52 changes: 21 additions & 31 deletions src/config/config-general.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
// environmental configurations for the dapp for different environments
export const config = {
/**
* API Calls Related
*/
// infuraAPIKey: 'e214e9781e104829bc93941508a45b58'
infuraAPIKey: '1afc24a3e4c443a0990d6e5efc2ecde5',

}

// Internal Components
import daiAbi from "./abis/dai";
import epnsTokenAbi from "./abis/EPNS.json";
import epnsCommAbi from "./abis/epnsCommunicator.json";
import epnscoreAbi from "./abis/epnscore";
import erc20Abi from "./abis/erc20";
import ec721Abi from "./abis/ERC721.json";
import MerkleDistributorAbi from "./abis/MerkleDistributor.json";
import NFTRewards from "./abis/NFTRewards.json";
import NFTRewardsV2 from "./abis/NFTRewardsV2.json";
import ownableAbi from "./abis/ownable";
import rockstarAbi from "./abis/Rockstar.json";
import rockstarV2Abi from "./abis/RockstarV2.json";
import stakingAbi from "./abis/Staking.json";
import UniswapV2Router02Abi from "./abis/UniswapV2Router02.json";
import yieldFarmingAbi from "./abis/YieldFarm.json";
import pushTokenAbi from "./abis/pushToken.json";
import stakingV2Abi from "./abis/StakingV2.json"; // for new staking V2 Contract on staging
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 daiAbi from './abis/dai';
import epnsTokenAbi from './abis/EPNS.json';
import epnsCommAbi from './abis/epnsCommunicator.json';
import epnscoreAbi from './abis/epnscore';
import erc20Abi from './abis/erc20';
import ec721Abi from './abis/ERC721.json';
import MerkleDistributorAbi from './abis/MerkleDistributor.json';
import NFTRewards from './abis/NFTRewards.json';
import NFTRewardsV2 from './abis/NFTRewardsV2.json';
import ownableAbi from './abis/ownable';
import rockstarAbi from './abis/Rockstar.json';
import rockstarV2Abi from './abis/RockstarV2.json';
import stakingAbi from './abis/Staking.json';
import UniswapV2Router02Abi from './abis/UniswapV2Router02.json';
import yieldFarmingAbi from './abis/YieldFarm.json';
import pushTokenAbi from './abis/pushToken.json';
import stakingV2Abi from './abis/StakingV2.json'; // for new staking V2 Contract on staging
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';

export const abis = {
erc20: erc20Abi,
Expand All @@ -51,5 +41,5 @@ export const abis = {
stakingV2: stakingV2Abi,
uniV2LpToken: uniV2LpTokenAbi,
pushCoreV2: PushCoreV2,
pushReveal: PushRevealAbi
pushReveal: PushRevealAbi,
};
12 changes: 7 additions & 5 deletions src/config/config-localhost.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -31,9 +32,10 @@ export const config = {
/**
* Core Network Related Data
*/
infuraAPIKey: infuraAPIKey,
coreContractChain: 5, //the chain id of the network which the core contract relies on
coreRPC: 'https://goerli.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
mainnetCoreRPC: 'https://mainnet.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
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',
Expand Down Expand Up @@ -99,15 +101,15 @@ export const CHAIN_DETAILS = {
label: 'Ethereum Goerli',
name: 'ETH_TEST_GOERLI',
chainId: 5,
rpcUrl: 'https://goerli.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
rpcUrl: `https://goerli.infura.io/v3/${infuraAPIKey}`,
commAddress: '0xc064F30bac07e84500c97A04D21a9d1bfFC72Ec0',
network: 'goerli',
},
80002: {
label: 'Polygon Amoy',
name: 'POLYGON_TEST_AMOY',
chainId: 80002,
rpcUrl: 'https://polygon-amoy.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7',
rpcUrl: `https://polygon-amoy.infura.io/v3/${infuraAPIKey}`,
commAddress: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f',
network: 'polygon-amoy',
},
Expand All @@ -122,7 +124,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/${infuraAPIKey}`,
commAddress: '0x9Dc25996ba72A2FD7E64e7a674232a683f406F1A',
},
};
18 changes: 13 additions & 5 deletions src/config/config-prod.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// 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');
export const config = {
/**
* Push Nodes Environment - can be dev, staging or prod - important to keep one on one connection
Expand Down Expand Up @@ -38,12 +45,13 @@ export const config = {
/**
* Core Network Related Data
*/
infuraAPIKey: infuraAPIKey,
coreContractChain: 1, //the chain id of the network which the core contract relies on
coreRPC: 'https://mainnet.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
mainnetCoreRPC: 'https://mainnet.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
coreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`,
mainnetCoreRPC: `https://mainnet.infura.io/v3/${infuraAPIKey}`,
mainnetCoreContractChain: 1,
aliasRPC: {
137: 'https://polygon-mainnet.infura.io/v3/150f25623ae64d08ab7ec7dd0c6b6ee9',
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',
Expand Down Expand Up @@ -123,15 +131,15 @@ export const CHAIN_DETAILS = {
label: 'Ethereum Mainnet',
name: 'ETH_MAINNET',
chainId: 1,
rpcUrl: 'https://mainnet.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
rpcUrl: `https://mainnet.infura.io/v3/${config.infuraAPIKey}`,
commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
network: 'mainnet',
},
137: {
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',
},
Expand Down
Loading
Loading