diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index fcb90d70b8..cd310fb3e9 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -41,6 +41,7 @@ jobs: touch apps/bridge-dapp/.env echo NX_BRIDGE_APP_DOMAIN=${{ secrets.NX_BRIDGE_APP_DOMAIN }} >> apps/bridge-dapp/.env + echo WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }} >> apps/bridge-dapp/.env echo HOSTED_ORBIT_MULTLICALL3_ADDRESS=${{ secrets.HOSTED_ORBIT_MULTLICALL3_ADDRESS }} >> apps/bridge-dapp/.env echo ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env echo HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env diff --git a/.github/workflows/deploy-bridge-dapp-dev.yml b/.github/workflows/deploy-bridge-dapp-dev.yml index 4a9a97bebf..7c19ec3045 100644 --- a/.github/workflows/deploy-bridge-dapp-dev.yml +++ b/.github/workflows/deploy-bridge-dapp-dev.yml @@ -37,6 +37,7 @@ jobs: run: | touch apps/bridge-dapp/.env echo NX_BRIDGE_APP_DOMAIN=${{ secrets.NX_BRIDGE_APP_DOMAIN }} >> apps/bridge-dapp/.env + echo WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }} >> apps/bridge-dapp/.env echo HOSTED_ORBIT_MULTLICALL3_ADDRESS=${{ secrets.HOSTED_ORBIT_MULTLICALL3_ADDRESS }} >> apps/bridge-dapp/.env echo ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env echo HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env diff --git a/.github/workflows/deploy-webbsite-dev.yml b/.github/workflows/deploy-webbsite-dev.yml index fbd0b50a6f..3b0f0cd509 100644 --- a/.github/workflows/deploy-webbsite-dev.yml +++ b/.github/workflows/deploy-webbsite-dev.yml @@ -57,6 +57,10 @@ jobs: run: yarn add -D -W netlify-cli - name: Build project + # Fix: JavaScript heap out of memory + # https://github.com/actions/runner-images/issues/70#issuecomment-1191708172 + env: + NODE_OPTIONS: '--max_old_space_size=4096' run: yarn build:webbsite - name: Deploy site diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b18d347993..65ac1c7782 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,6 +82,7 @@ jobs: touch apps/bridge-dapp/.env echo NX_BRIDGE_APP_DOMAIN=${{ secrets.NX_BRIDGE_APP_DOMAIN }} >> apps/bridge-dapp/.env + echo WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }} >> apps/bridge-dapp/.env echo HOSTED_ORBIT_MULTLICALL3_ADDRESS=${{ secrets.HOSTED_ORBIT_MULTLICALL3_ADDRESS }} >> apps/bridge-dapp/.env echo ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env echo HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env diff --git a/apps/bridge-dapp/.env.example b/apps/bridge-dapp/.env.example index b8fc28e50c..f74420f0d5 100644 --- a/apps/bridge-dapp/.env.example +++ b/apps/bridge-dapp/.env.example @@ -5,6 +5,8 @@ NX_BRIDGE_APP_DOMAIN=http:localhost:3000 POLKADOT_TEST_ACCOUNT_ADDRESS="" +WALLET_CONNECT_PROJECT_ID="" + # If you want to enable the local orbit integration, # you need to set the local anchor addresses of the local orbit instance LOCAL_ORBIT_ANCHOR_ADDRESS="" diff --git a/apps/bridge-dapp/src/components/ChainListCardWrapper/ChainListCardWrapper.tsx b/apps/bridge-dapp/src/components/ChainListCardWrapper/ChainListCardWrapper.tsx index 64944b5781..91cb3b6280 100644 --- a/apps/bridge-dapp/src/components/ChainListCardWrapper/ChainListCardWrapper.tsx +++ b/apps/bridge-dapp/src/components/ChainListCardWrapper/ChainListCardWrapper.tsx @@ -55,7 +55,7 @@ export const ChainListCardWrapper: FC = ({ return getActiveSourceChains(apiConfig.chains).map((val) => { const currency = getNativeCurrencyFromConfig( apiConfig.currencies, - calculateTypedChainId(val.chainType, val.chainId) + calculateTypedChainId(val.chainType, val.id) ); return { @@ -84,7 +84,7 @@ export const ChainListCardWrapper: FC = ({ const isSupported = activeWallet && activeWallet.supportedChainIds.includes( - calculateTypedChainId(chain.chainType, chain.chainId) + calculateTypedChainId(chain.chainType, chain.id) ); let bridge: Bridge | undefined; diff --git a/apps/bridge-dapp/src/components/Header/WalletButton.tsx b/apps/bridge-dapp/src/components/Header/WalletButton.tsx index d98908d033..3a8b87ba27 100644 --- a/apps/bridge-dapp/src/components/Header/WalletButton.tsx +++ b/apps/bridge-dapp/src/components/Header/WalletButton.tsx @@ -27,6 +27,8 @@ import { import { FC, useCallback, useMemo, useState } from 'react'; import { ClearDataModal } from './ClearDataModal'; import { HeaderButton } from './HeaderButton'; +import { WebbWeb3Provider, isViemError } from '@webb-tools/web3-api-provider'; +import { WebbError, WebbErrorCodes } from '@webb-tools/dapp-types'; export const WalletButton: FC<{ account: Account; wallet: WalletConfig }> = ({ account, @@ -35,14 +37,20 @@ export const WalletButton: FC<{ account: Account; wallet: WalletConfig }> = ({ // Clear data modal const [isOpen, setIsOpen] = useState(false); - const { activeChain, noteManager, purgeNoteAccount, inactivateApi } = - useWebContext(); + const { + activeApi, + activeChain, + noteManager, + purgeNoteAccount, + inactivateApi, + } = useWebContext(); // Get all note, syncNotes and isSyncingNote function const { allNotes, isSyncingNote, syncNotes: handleSyncNotes, + syncNotesProgress, } = useNoteAccount(); const { setMainComponent, notificationApi, logger } = useWebbUI(); @@ -78,13 +86,11 @@ export const WalletButton: FC<{ account: Account; wallet: WalletConfig }> = ({ // Calculate the account explorer url const accountExplorerUrl = useMemo(() => { - if (!activeChain?.blockExplorerStub) return '#'; + if (!activeChain?.blockExplorers) return '#'; - const uri = activeChain.blockExplorerStub.endsWith('/') - ? `address/${account.address}` - : `/address/${account.address}`; + const url = activeChain.blockExplorers.default.url; - return `${activeChain.blockExplorerStub}${uri}`; + return new URL(`/address/${account.address}`, url).toString(); }, [activeChain, account]); // Clear data function @@ -148,32 +154,25 @@ export const WalletButton: FC<{ account: Account; wallet: WalletConfig }> = ({ // Funciton to switch account within the connected wallet const handleSwitchAccount = useCallback(async () => { - if (!activeChain) { - notificationApi({ - variant: 'error', - message: 'No active chain', - }); + // Switch account only support on web3 provider + if (!activeApi || !(activeApi instanceof WebbWeb3Provider)) { return; } - if ( - typeof window !== 'undefined' && - typeof window.ethereum !== 'undefined' - ) { - try { - await window.ethereum.request({ - method: 'wallet_requestPermissions', - params: [ - { - eth_accounts: {}, - }, - ], - }); - } catch (error) { - console.log(error); + try { + const walletClient = activeApi.walletClient; + + await walletClient.requestPermissions({ eth_accounts: {} }); + } catch (error) { + let message = WebbError.from(WebbErrorCodes.SwitchAccountFailed).message; + + if (isViemError(error)) { + message = error.shortMessage; } + + notificationApi({ variant: 'error', message }); } - }, [activeChain, notificationApi]); + }, [activeApi, notificationApi]); // Disconnect function // TODO: The disconnect function does not work properly @@ -276,6 +275,11 @@ export const WalletButton: FC<{ account: Account; wallet: WalletConfig }> = ({