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

Switch WalletConnect to v2 #223

Merged
merged 7 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jobs:
REACT_APP_CLUSTER: ${{ vars.REACT_APP_CLUSTER }}
REACT_APP_SOLANA_API_URL: ${{ vars.REACT_APP_SOLANA_API_URL }}
REACT_APP_COVALENT_API_KEY: ${{ secrets.REACT_APP_COVALENT_API_KEY }}
REACT_APP_WALLET_CONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}
run: |
pushd public
npm run set-version
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ jobs:
REACT_APP_SOLANA_API_URL: ${{ vars.REACT_APP_SOLANA_API_URL }}
REACT_APP_COVALENT_API_KEY: ${{ secrets.REACT_APP_COVALENT_API_KEY }}
REACT_APP_TRM_API_KEY: ${{ secrets.REACT_APP_TRM_API_KEY }}
REACT_APP_WALLET_CONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}
run: |
echo 'REACT_APP_VERSION=$npm_package_version' > .env
npm run build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
REACT_APP_CLUSTER: testnet
REACT_APP_SOLANA_API_URL: ${{ vars.REACT_APP_SOLANA_API_URL }}
REACT_APP_COVALENT_API_KEY: ${{ secrets.REACT_APP_COVALENT_API_KEY }}
REACT_APP_WALLET_CONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}
run: |
pushd public
npm run set-version
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xlabs/portal-bridge-ui",
"version": "0.1.48",
"version": "0.1.49",
"private": true,
"dependencies": {
"@certusone/wormhole-sdk": "^0.9.20",
Expand Down
15 changes: 15 additions & 0 deletions src/contexts/AlgorandWalletContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ import { AlgorandWallet } from "@xlabs-libs/wallet-aggregator-algorand";
import { CHAIN_ID_ALGORAND } from "@xlabs-libs/wallet-aggregator-core";
import { useWallet } from "@xlabs-libs/wallet-aggregator-react";
import { useMemo } from "react";
import {
AlgorandLedgerWallet,
DeflyWallet,
MyAlgoWallet,
PeraWallet,
} from "@xlabs-libs/wallet-aggregator-algorand";

export const getAlgorandWallets = (): AlgorandWallet[] => {
return [
new MyAlgoWallet(),
new PeraWallet(),
new DeflyWallet({}),
new AlgorandLedgerWallet(),
];
};

export const useAlgorandWallet = () => {
const wallet = useWallet(CHAIN_ID_ALGORAND);
Expand Down
29 changes: 28 additions & 1 deletion src/contexts/EthereumProviderContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { isEVMChain } from "@certusone/wormhole-sdk";
import { ChainId } from "@xlabs-libs/wallet-aggregator-core";
import { EVMWallet } from "@xlabs-libs/wallet-aggregator-evm";
import {
EVMWallet,
InjectedWallet,
WalletConnectWallet,
} from "@xlabs-libs/wallet-aggregator-evm";
import { useWallet } from "@xlabs-libs/wallet-aggregator-react";
import { ethers } from "ethers";
import { useEffect, useMemo, useState } from "react";
Expand All @@ -16,6 +20,29 @@ interface IEthereumContext {
wallet: EVMWallet | undefined;
}

export const getEvmWallets = (): EVMWallet[] => {
return [
new InjectedWallet(),
new WalletConnectWallet({
connectorOptions: {
projectId: process.env.REACT_APP_WALLET_CONNECT_PROJECT_ID || "",
showQrModal: true,
qrModalOptions: {
explorerAllowList: [],
explorerDenyList: [],
themeMode: 'light'
},
metadata: {
url: "https://portalbridge.com",
name: "Wormhole Portal Bridge",
description: "Wormhole Portal Bridge",
icons: ["https://portalbridge.com/favicon.ico"],
},
},
}),
];
};

export const useEthereumProvider = (chainId: ChainId): IEthereumContext => {
const wallet = useWallet<EVMWallet>(chainId);

Expand Down
21 changes: 4 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { CssBaseline } from "@material-ui/core";
import { ThemeProvider } from "@material-ui/core/styles";
import {
AlgorandLedgerWallet,
DeflyWallet,
MyAlgoWallet,
PeraWallet,
} from "@xlabs-libs/wallet-aggregator-algorand";
import {
CHAIN_ID_ALGORAND,
CHAIN_ID_APTOS,
Expand All @@ -17,10 +11,6 @@ import {
CHAIN_ID_TERRA2,
CHAIN_ID_XPLA,
} from "@xlabs-libs/wallet-aggregator-core";
import {
InjectedWallet,
WalletConnectLegacyWallet,
} from "@xlabs-libs/wallet-aggregator-evm";
import { WalletContextProvider } from "@xlabs-libs/wallet-aggregator-react";
import { SnackbarProvider } from "notistack";
import ReactDOM from "react-dom";
Expand All @@ -29,8 +19,10 @@ import { HashRouter } from "react-router-dom";
import App from "./App";
import ErrorBoundary from "./ErrorBoundary";
import BackgroundImage from "./components/BackgroundImage";
import { getAlgorandWallets } from "./contexts/AlgorandWalletContext";
import { getWrappedWallets as getWrappedAptosWallets } from "./contexts/AptosWalletContext";
import { BetaContextProvider } from "./contexts/BetaContext";
import { getEvmWallets } from "./contexts/EthereumProviderContext";
import { getInjectiveWallets } from "./contexts/InjectiveWalletContext";
import { getNearWallets } from "./contexts/NearWalletContext";
import { getWrappedWallets as getWrappedSolanaWallets } from "./contexts/SolanaWalletContext";
Expand All @@ -42,13 +34,8 @@ import { store } from "./store";

const AGGREGATOR_WALLETS_BUILDER = async () => {
return {
[CHAIN_ID_ALGORAND]: [
new MyAlgoWallet(),
new PeraWallet(),
new DeflyWallet(),
new AlgorandLedgerWallet(),
],
[CHAIN_ID_ETH]: [new InjectedWallet(), new WalletConnectLegacyWallet()],
[CHAIN_ID_ALGORAND]: getAlgorandWallets(),
[CHAIN_ID_ETH]: getEvmWallets(),
[CHAIN_ID_SOLANA]: getWrappedSolanaWallets(),
[CHAIN_ID_APTOS]: getWrappedAptosWallets(),
[CHAIN_ID_INJECTIVE]: getInjectiveWallets(),
Expand Down
3 changes: 3 additions & 0 deletions src/muiTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export const theme = responsiveFontSizes(
letterSpacing: -1.02,
},
},
zIndex: {
modal: 50,
},
overrides: {
MuiCssBaseline: {
"@global": {
Expand Down