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

Feat/Base Chain support #1608

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6e9b38c
chore:add base support
corlard3y Jun 5, 2024
a1d3bd5
update base logo
corlard3y Jun 5, 2024
55fde8f
fix: update uiweb and restapi
corlard3y Jun 7, 2024
94a1918
fix: update fn
corlard3y Jun 7, 2024
8798ac1
update packages
corlard3y Jun 7, 2024
cdb75a8
comment code
corlard3y Jun 7, 2024
90737cd
fix: update version
corlard3y Jun 11, 2024
16a9695
fix: refactor undefined code
corlard3y Jun 11, 2024
1f39ef1
Merge branch 'main' into 1607-feature-base-chain-support
corlard3y Jul 10, 2024
80d1528
merge conflcts
corlard3y Jul 10, 2024
e1ca0aa
update versions
corlard3y Jul 15, 2024
6ad6949
Rewards QA Fixes (#1717)
corlard3y Jul 11, 2024
2d67eb5
DApp-1708 added support for new css variables and semantics in blocks…
rohitmalhotra1420 Jul 11, 2024
50a488d
chore: add activityTypeId query param to points vault user list (#1721)
kalashshah Jul 11, 2024
4004429
Support icon sizing according to 'size' prop in blocks button compone…
kalashshah Jul 11, 2024
e582e97
Rewards Unlock Profile flow (#1722)
corlard3y Jul 11, 2024
4b5ab81
refactored the TextInput code (#1732)
mishramonalisha76 Jul 16, 2024
8f2b840
update unlock profile steps (#1733)
corlard3y Jul 16, 2024
a7cf714
Rewards QA minor fixes (#1734)
corlard3y Jul 16, 2024
2e528df
Fixed the metamask pop up for staking in Yield Farming Page (#1731)
abhishek-01k Jul 16, 2024
65361c8
chore:add base support
corlard3y Jun 5, 2024
6fa8828
fix: update uiweb and restapi
corlard3y Jun 7, 2024
4fbeefd
fix: update fn
corlard3y Jun 7, 2024
b2f19d1
update packages
corlard3y Jun 7, 2024
ad8403b
fix: update version
corlard3y Jun 11, 2024
92eee17
update versions
corlard3y Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"@metamask/eth-sig-util": "^4.0.0",
"@mui/icons-material": "^5.8.4",
"@mui/material": "^5.5.0",
"@pushprotocol/restapi": "1.7.20",
"@pushprotocol/restapi": "1.7.23",
"@pushprotocol/socket": "0.5.3",
"@pushprotocol/uiweb": "1.6.0-alpha.4",
"@pushprotocol/uiweb": "1.3.8",
"@reduxjs/toolkit": "^1.7.1",
"@testing-library/dom": "^9.0.1",
"@testing-library/jest-dom": "^4.2.4",
Expand All @@ -46,9 +46,9 @@
"@unstoppabledomains/resolution": "8.5.0",
"@web3-name-sdk/core": "^0.1.18",
"@web3-onboard/coinbase": "^2.2.5",
"@web3-onboard/core": "2.21.6",
"@web3-onboard/injected-wallets": "2.10.16",
"@web3-onboard/react": "^2.8.9",
"@web3-onboard/core": "2.22.1",
"@web3-onboard/injected-wallets": "2.11.1",
"@web3-onboard/react": "^2.9.1",
"@web3-onboard/walletconnect": "2.5.5",
"@yisheng90/react-loading": "1.2.3",
"assert": "2.0.0",
Expand Down
6 changes: 6 additions & 0 deletions public/svg/Base.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/ChangeNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ChangeNetwork = () => {
color="#fff"
radius="15px"
padding="20px 20px"
onClick={() => switchChain(aliasChainId)}
onClick={() => switchChain(parseInt(aliasChainId))}
>
<Span
color="#fff"
Expand Down
7 changes: 7 additions & 0 deletions src/components/Faucets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ const Faucets = () => {
function: () => {},
link: 'https://cyber-testnet.testnets.rollbridge.app/',
},
{
id: '84532',
value: 'Base Sepolia',
title: 'Base Sepolia Faucet',
function: () => {},
link: 'https://www.alchemy.com/faucets/base-sepolia',
}
];

// render
Expand Down
2 changes: 1 addition & 1 deletion src/components/InitState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const InitState = () => {
!userPushSDKInstance
)
return;

(async function () {
if (onCoreNetwork) {
checkUserForChannelOwnership(account, userPushSDKInstance).then(async () => {
Expand Down
4 changes: 4 additions & 0 deletions src/components/VerifyAlias.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ const VerifyAlias = ({ aliasEthAccount, setAliasVerified }) => {
label: 'Cyber ETH',
url: 'https://cyber-testnet.testnets.rollbridge.app/',
},
84532: {
label: 'Base Sepolia',
url: 'https://www.alchemy.com/faucets/base-sepolia'
}
};

const checkAlias = async () => {
Expand Down
8 changes: 8 additions & 0 deletions src/config/config-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const config = {
421614, // arbitrum testnet
123, // fuse testnet
111557560, // Cyber testnet
84532, //base sepolia
],

/**
Expand Down Expand Up @@ -182,4 +183,11 @@ export const CHAIN_DETAILS = {
rpcUrl: 'https://cyber-testnet.alt.technology/',
commAddress: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F',
},
84532: {
label: 'Base Sepolia',
name: 'BASE_TESTNET',
chainid: 84532,
rpcUrl: 'https://sepolia.base.org/',
commAddress: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F',
},
};
8 changes: 8 additions & 0 deletions src/config/config-prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const config = {
1101, // polygon zkevm mainnet
122, // fuse mainnet
7560, // Cyber mainnet
8453, //base mainnet
],

/**
Expand Down Expand Up @@ -174,4 +175,11 @@ export const CHAIN_DETAILS = {
rpcUrl: 'https://cyber.alt.technology/',
commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
8453: {
label: 'Base Mainnet',
name: 'BASE_MAINNET',
chainid: 8453,
rpcUrl: 'https://mainnet.base.org/',
commAddress: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
};
8 changes: 8 additions & 0 deletions src/config/config-staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const config = {
421614, // arbitrum testnet
123, // fuse testnet
111557560, // Cyber testnet
84532, //base sepolia
],

/**
Expand Down Expand Up @@ -178,4 +179,11 @@ export const CHAIN_DETAILS = {
rpcUrl: 'https://cyber-testnet.alt.technology/',
commAddress: '0x6e489B7af21cEb969f49A90E481274966ce9D74d',
},
84532: {
label: 'Base Sepolia',
name: 'BASE_TESTNET',
chainid: 84532,
rpcUrl: 'https://sepolia.base.org/',
commAddress: '0x6e489B7af21cEb969f49A90E481274966ce9D74d',
},
};
12 changes: 12 additions & 0 deletions src/connectors/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ export const MAINNET_CHAINS: ChainConfig = {
nativeCurrency: ETH,
blockExplorerUrls: ['https://cyberscan.co/'],
},
8453: {
name: 'Base Mainnet',
urls: ['https://mainnet.base.org/'],
nativeCurrency: ETH,
blockExplorerUrls: ['https://basescan.org/'],
},
};

export const TESTNET_CHAINS: ChainConfig = {
Expand Down Expand Up @@ -192,6 +198,12 @@ export const TESTNET_CHAINS: ChainConfig = {
nativeCurrency: ETH,
blockExplorerUrls: ['https://testnet.cyberscan.co/'],
},
84532: {
name: 'Base Sepolia',
urls: ['https://sepolia.base.org/'],
nativeCurrency: ETH,
blockExplorerUrls: ['https://sepolia-explorer.base.org/'],
},
};

export const CHAINS: ChainConfig = {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/CaipHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { appConfig } from '../config/index.js';

export const Eip155EnabledIds: Array<Number> = [
1, 56, 137, 10, 1101, 42161, 11155111, 97, 80002, 11155420, 2442, 421614, 122, 123, 111557560, 7560,
1, 56, 137, 10, 1101, 42161, 11155111, 97, 80002, 11155420, 2442, 421614, 122, 123, 111557560, 7560, 84532, 8453,
];

// Types
Expand Down
69 changes: 52 additions & 17 deletions src/helpers/UtilityHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const UtilityHelper = {
chainId === 10 ||
chainId === 42161 ||
chainId === 122 ||
chainId === 7560
chainId === 7560 ||
chainId === 8453
) {
return true;
}
Expand Down Expand Up @@ -62,6 +63,8 @@ export const MaskedAliasChannels: {
123: {},
111557560: {},
7560: {},
8453: {},
84532: {},
};

export const findObject = (data: any, parentArray: any[], property: string): boolean => {
Expand Down Expand Up @@ -126,6 +129,8 @@ export const networkName = {
123: 'Fuse Testnet',
111557560: 'Cyber Testnet',
7560: 'Cyber Mainnet',
8453: 'Base Mainnet',
84532: 'Base Sepolia',
};

export const chainNameBackendStandard = {
Expand All @@ -151,6 +156,8 @@ export const aliasChainIdToChainName = {
123: 'FUSE',
111557560: 'CYBERCONNECT',
7560: 'CYBERCONNECT',
8453: 'BASE',
84532: 'BASE',
};

export const aliasChainIdsMapping = {
Expand Down Expand Up @@ -259,6 +266,20 @@ export const NETWORK_DETAILS = {
rpcUrls: ['https://cyber.alt.technology/'],
blockExplorerUrls: [' https://.cyberscan.co/'],
},
BASE_TESTNET: {
chainId: utils.hexValue(84532),
chainName: 'Base Testnet',
nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 },
rpcUrls: ['https://sepolia.base.org/'],
blockExplorerUrls: ['https://sepolia-explorer.base.org/'],
},
BASE_MAINNET: {
chainId: utils.hexValue(8453),
chainName: 'Base Mainnet',
nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 },
rpcUrls: ['https://mainnet.base.org/'],
blockExplorerUrls: ['https://basescan.org/'],
},
};

export const CORE_CHAIN_ID: number = appConfig.coreContractChain;
Expand All @@ -283,34 +304,48 @@ export const LOGO_FROM_CHAIN_ID: {
123: 'Fuse.svg',
111557560: 'Cyber.svg',
7560: 'Cyber.svg',
8453: 'Base.svg',
84532: 'Base.svg',
};

export type getAliasResponseType = {
address: string | null;
chainId: string | null;
};

// check code and verify with sc team or be before removing
// export const getAliasFromChannelDetails = (channelDetails: Object | null | string): getAliasResponseType => {
// if (!channelDetails || channelDetails === 'unfetched') return null;

// if (channelDetails['aliasDetails']) {
// const aliasDetails = channelDetails['aliasDetails'];
// const aliasDetail = { chainId: null, address: null };
// appConfig.allowedNetworks.forEach((chainID) => {
// const caipChainId = convertChainIdToChainCaip(chainID);
// if (aliasDetails[caipChainId!]) {
// aliasDetail.address = aliasDetails[caipChainId!];
// aliasDetail.chainId = chainID;
// }
// });
// if (aliasDetail.address) return aliasDetail;
// } else if (channelDetails['address'] != null && channelDetails['address'] != '') {
// if (appConfig.allowedNetworks.includes(+channelDetails['chain_id'])) {
// return { address: channelDetails['address'], chainId: channelDetails['chain_id'] };
// }
// }

// return { address: null, chainId: null };
// };

export const getAliasFromChannelDetails = (channelDetails: Object | null | string): getAliasResponseType => {
if (!channelDetails || channelDetails === 'unfetched') return null;

if (channelDetails['aliasDetails']) {
const aliasDetails = channelDetails['aliasDetails'];
const aliasDetail = { chainId: null, address: null };
appConfig.allowedNetworks.forEach((chainID) => {
const caipChainId = convertChainIdToChainCaip(chainID);
if (aliasDetails[caipChainId!]) {
aliasDetail.address = aliasDetails[caipChainId!];
aliasDetail.chainId = chainID;
}
});
if (aliasDetail.address) return aliasDetail;
} else if (channelDetails['address'] != null && channelDetails['address'] != '') {
if (appConfig.allowedNetworks.includes(+channelDetails['chain_id'])) {
return { address: channelDetails['address'], chainId: channelDetails['chain_id'] };
if (channelDetails['alias_address'] != null && channelDetails['alias_address'] != '') {
if (appConfig.allowedNetworks.includes(+channelDetails['alias_blockchain_id'])) {
return { address: channelDetails['alias_address'], chainId: channelDetails['alias_blockchain_id'] };
}
}

return { address: null, chainId: null };
return null;
};

export const CHANNEL_TYPE = {
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useInactiveListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export function useInactiveListener() {
if (appConfig.coreContractChain === 42)
return 'Unsupported Network, please connect to the Ethereum Kovan network or Polygon Amoy network';
else if (appConfig.coreContractChain === 11155111)
return 'Unsupported Network, please connect to the Ethereum Sepolia, Polygon Amoy, BNB testnet, Optimism Sepolia, Arbitrum Sepolia or Polygon zkEVM testnet';
return 'Unsupported Network, please connect to the Ethereum Sepolia, Polygon Amoy, BNB testnet, Optimism Sepolia, Arbitrum Sepolia, Base Sepolia or Polygon zkEVM testnet';
else
return 'Unsupported Network, please connect to the Ethereum, Polygon, BNB, Optimism, Arbitrum or Polygon zkEVM Mainnet';
return 'Unsupported Network, please connect to the Ethereum, Polygon, BNB, Optimism, Arbitrum, Base or Polygon zkEVM Mainnet';
};

useEffect(() => {
Expand Down
5 changes: 3 additions & 2 deletions src/modules/channelDashboard/ChannelOwnerDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ const ChannelOwnerDashboard = () => {
useEffect(() => {
if (!onCoreNetwork || !channelDetails || aliasAddrFromContract || channelDetails === 'unfetched') return;

const { address: aliasAddress, chainId: aliasChainId } = getAliasFromChannelDetails(channelDetails);
if (aliasAddress) {
const aliasDetails = getAliasFromChannelDetails(channelDetails);
if (aliasDetails) {
const { address: aliasAddress, chainId: aliasChainId } = aliasDetails;
dispatch(setAliasAddressFromContract(aliasAddress));
dispatch(setAliasChainId(aliasChainId));
// dispatch(setAliasAddress(aliasAddress));
Expand Down
18 changes: 9 additions & 9 deletions src/redux/slices/adminSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
*/

// External Packages
import { createSlice } from "@reduxjs/toolkit";
import { createSlice } from '@reduxjs/toolkit';

const initialState = {
channelDetails: "unfetched",
channelDetails: 'unfetched',
coreChannelAdmin: null,
canVerify: false,
aliasDetails: {
aliasAddr: null,
aliasAddrFromContract: null,
aliasEthAddr: null,
isAliasVerified: null,
aliasChainId: null
aliasChainId: null,
},
delegatees: null,
canVerify: false,
};

export const contractSlice = createSlice({
name: "admin",
name: 'admin',
initialState,
reducers: {
resetAdminSlice: () => initialState,
Expand All @@ -39,19 +39,19 @@ export const contractSlice = createSlice({
state.delegatees = action.payload;
},
setAliasAddress: (state, action) => {
state.aliasDetails["aliasAddr"] = action.payload;
state.aliasDetails['aliasAddr'] = action.payload;
},
setAliasAddressFromContract: (state, action) => {
state.aliasDetails['aliasAddrFromContract'] = action.payload;
},
setAliasEthAddress: (state, action) => {
state.aliasDetails["aliasEthAddr"] = action.payload;
state.aliasDetails['aliasEthAddr'] = action.payload;
},
setAliasChainId: (state, action) => {
state.aliasDetails["aliasChainId"] = action.payload;
state.aliasDetails['aliasChainId'] = action.payload;
},
setAliasVerified: (state, action) => {
state.aliasDetails["isAliasVerified"] = action.payload;
state.aliasDetails['isAliasVerified'] = action.payload;
},
},
});
Expand All @@ -66,7 +66,7 @@ export const {
setAliasAddress,
setAliasAddressFromContract,
setAliasEthAddress,
setAliasChainId
setAliasChainId,
} = contractSlice.actions;

export default contractSlice.reducer;
1 change: 1 addition & 0 deletions src/services/alias/getAliasDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Props = {
};

export const getAliasDetails = async ({ account, chainId }: Props) => {
console.log(account, aliasChainIdToChainName[chainId], appConfig.appEnv);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove this.

try {
const response = await PushAPI.alias.getAliasInfo({
alias: account,
Expand Down
4 changes: 2 additions & 2 deletions src/structure/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ function Header({ isDarkMode, darkModeToggle }) {
if (appConfig.coreContractChain === 42)
return 'Unsupported Network, please connect to the Ethereum Kovan network or Polygon Amoy network';
else if (appConfig.coreContractChain === 11155111)
return 'Unsupported Network, please connect to the Ethereum Sepolia, Polygon Amoy, BNB testnet, Optimism Sepolia, Arbitrum Sepolia or Polygon zkEVM testnet';
return 'Unsupported Network, please connect to the Ethereum Sepolia, Polygon Amoy, BNB testnet, Optimism Sepolia, Arbitrum Sepolia, Base Sepolia or Polygon zkEVM testnet';
else
return 'Unsupported Network, please connect to the Ethereum, Polygon, BNB, Optimism, Arbitrum or Polygon zkEVM Mainnet';
return 'Unsupported Network, please connect to the Ethereum, Polygon, BNB, Optimism, Arbitrum, Base or Polygon zkEVM Mainnet';
} else {
console.error(error);
return 'An unknown error occurred. Check the console for more details';
Expand Down
Loading
Loading