Skip to content

Commit

Permalink
fix: fixed infura key
Browse files Browse the repository at this point in the history
  • Loading branch information
mishramonalisha76 committed Oct 11, 2024
1 parent 52ecf45 commit 44fae1a
Show file tree
Hide file tree
Showing 8 changed files with 23,327 additions and 33,367 deletions.
4,792 changes: 1,694 additions & 3,098 deletions packages/restapi/yarn.lock

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions packages/uiweb/src/lib/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@ export const CoreContractChainId = {
local: 11155111,
};

export const CoreRPC = {
prod: 'https://mainnet.infura.io/v3/4ff53a5254144d988a8318210b56f47a',
dev: 'https://sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7',
staging: 'https://sepolia.infura.io/v3/49f638cc25a94ddb86b7aefd612f11ab',
local: 'https://sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7',
export const infuraAPIKey = '100cce93cd9d4626b9cedf707d4dbabc';

export const CoreRPC = (env: ENV) => {
const baseinfuraURL = {
prod: 'https://mainnet.infura.io/v3/',
dev: 'https://sepolia.infura.io/v3/',
staging: 'https://sepolia.infura.io/v3/',
local: 'https://sepolia.infura.io/v3/',
};
return `${baseinfuraURL[env]}${infuraAPIKey}`;
};

const TESTNET_NETWORK = {
Expand Down
1 change: 1 addition & 0 deletions packages/uiweb/src/lib/context/chatContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface IChatDataContextValues {
isPushChatStreamConnected: boolean;
setIsPushChatStreamConnected: React.Dispatch<React.SetStateAction<boolean>>;
toast: any;
infuraProjectId: string;
uiConfig: {
suppressToast?: boolean;
};
Expand Down
5 changes: 4 additions & 1 deletion packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import usePushUser from '../hooks/usePushUser';
// Internal Configs
import { lightChatTheme } from '../components/chat/theme';
import { ThemeContext } from '../components/chat/theme/ThemeProvider';
import { Constants, ENV, GUEST_MODE_ACCOUNT } from '../config';
import { Constants, ENV, GUEST_MODE_ACCOUNT, infuraAPIKey } from '../config';

// Assets

Expand Down Expand Up @@ -48,6 +48,7 @@ export interface IChatUIProviderProps {
uiConfig?: {
suppressToast?: boolean;
};
infuraProjectId?: string;
}

// Exported Functions
Expand All @@ -61,6 +62,7 @@ export const ChatUIProvider = ({
theme,
debug = false,
uiConfig = {},
infuraProjectId = infuraAPIKey,
}: IChatUIProviderProps) => {
// Now destructure with a default value for suppressToast
const { suppressToast = false } = uiConfig;
Expand Down Expand Up @@ -452,6 +454,7 @@ export const ChatUIProvider = ({
setIsPushChatStreamConnected,
user: pushUser,
setUser: setPushUser,
infuraProjectId: infuraProjectId,
toast: toastify,
uiConfig: uiConfig,
chatStream,
Expand Down
2 changes: 1 addition & 1 deletion packages/uiweb/src/lib/helpers/address.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SignerType, CONSTANTS } from '@pushprotocol/restapi';
import { ethers } from 'ethers';
import { ENV, allowedNetworks } from '../config';
import { ENV, allowedNetworks, infuraAPIKey } from '../config';
import { createWeb3Name } from '@web3-name-sdk/core';
import { getUdResolverClient } from './udResolver';

Expand Down
15 changes: 9 additions & 6 deletions packages/uiweb/src/lib/hooks/useAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { Env } from '@pushprotocol/restapi';
import { useConnectWallet, useSetChain } from '@web3-onboard/react';
import { ethers } from 'ethers';
import { useMemo } from 'react';
import { CoreContractChainId, CoreRPC, GUEST_MODE_ACCOUNT } from '../config';
import { CoreContractChainId, CoreRPC, ENV, GUEST_MODE_ACCOUNT } from '../config';

interface useAccountParams {
env:Env;
env: Env;
}
export const useAccount = ({env}:useAccountParams) => {
export const useAccount = ({ env }: useAccountParams) => {
const [{ wallet, connecting }, connect, disconnect, updateBalances, setWalletModules, setPrimaryWallet] =
useConnectWallet();

Expand All @@ -21,7 +21,9 @@ export const useAccount = ({env}:useAccountParams) => {
setChain({ chainId: ethers.utils.hexValue(desiredChain) });
};
const provider = useMemo(() => {
return wallet ? new ethers.providers.Web3Provider(wallet.provider, 'any') : new ethers.providers.JsonRpcProvider(CoreRPC[env]);
return wallet
? new ethers.providers.Web3Provider(wallet.provider, 'any')
: new ethers.providers.JsonRpcProvider(CoreRPC(env));
}, [wallet]);

return {
Expand All @@ -33,12 +35,13 @@ export const useAccount = ({env}:useAccountParams) => {
setWalletModules,
setPrimaryWallet,
provider,
account: wallet && wallet.accounts.length > 0 ? ethers.utils.getAddress(wallet.accounts[0].address) : GUEST_MODE_ACCOUNT,
account:
wallet && wallet.accounts.length > 0 ? ethers.utils.getAddress(wallet.accounts[0].address) : GUEST_MODE_ACCOUNT,
chainId: connectedChain ? Number(connectedChain.id) : CoreContractChainId[env],
isActive,
setChain,
switchChain,
settingChain,
chains,
};
};
};
Loading

0 comments on commit 44fae1a

Please sign in to comment.