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

Migrated app.config.chain.getById() calls to newer trpc.community.getCommunity() + cleanup/state-refactor of related components #8779

Merged
merged 84 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
5ff429b
Refactored `AdminOnboardingSlider.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 6, 2024
b8b1f97
Refactored `CWSearchBar.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 6, 2024
66fd74a
Refactored `DirectoryMenuItem.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 6, 2024
eeb8778
Refactored `ProfileActivityRow.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 6, 2024
bdce093
Refactored `feed.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 6, 2024
809d835
Refactored `AllowList.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 6, 2024
f935055
Refactored `Tag.showcase.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 6, 2024
a102079
Removed `app.chain.getById` from `Webhooks.tsx`
mzparacha Aug 6, 2024
f3ae371
Refactored `AuthorAndPublishInfo.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 6, 2024
448c6aa
Refactored `pages/notification/*` components to use `useGetCommunityB…
mzparacha Aug 6, 2024
835adb4
Refactored helper components for old notifications page to use `useGe…
mzparacha Aug 6, 2024
f6fde81
Refactored `view_multiple_snapshots/index.tsx` to use `useGetCommunit…
mzparacha Aug 6, 2024
b968fb1
Refactored `CommunityMembersPage.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 6, 2024
b9156ca
Refactored `DirectoryPage.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 6, 2024
e6140f0
Refactored to use + update community with RQ
mzparacha Aug 6, 2024
f1b7563
Added `useRunOnceOnCondition()` which runs once/comp-lifecycle on spe…
mzparacha Aug 6, 2024
5038f96
"Refactored `CustomTOS.tsx` to use `useGetCommunityByIdQuery` + updat…
mzparacha Aug 6, 2024
89f2bce
"Refactored `Directory.tsx` to use `useGetCommunityByIdQuery` + updat…
mzparacha Aug 6, 2024
0aa6999
"Refactored `Snapshots.tsx` to use `useGetCommunityByIdQuery` + updat…
mzparacha Aug 6, 2024
7f6ce20
Moved link categorization logic from ChainInfo.ts to helpers/link.ts
mzparacha Aug 6, 2024
4871053
"Refactored `external_links_module.tsx` to use `useGetCommunityByIdQu…
mzparacha Aug 6, 2024
b167102
Refactored valid-link check logic
mzparacha Aug 7, 2024
4b1c004
Fix valid-link check bug with `getLinkType()` helper
mzparacha Aug 7, 2024
e8a53cf
Removed `app.config.chain.getById` form `notifications/helpers.tsx`
mzparacha Aug 7, 2024
2d4677d
Refactored `CommunityProfileForm.tsx` to use `useGetCommunityByIdQuer…
mzparacha Aug 7, 2024
12ada74
Refactored `CWRelatedCommunityCard.tsx` and stake components to use `…
mzparacha Aug 7, 2024
e33706b
Removed `app.config.chain.getById` from `AllowList.tsx`
mzparacha Aug 7, 2024
08e7f17
Removed `app.config.chain.getById` from `CommunityMembersPage.tsx`
mzparacha Aug 7, 2024
615d5e6
Refactored `Analytics.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 7, 2024
9afb1ca
Refactored `DeleteChainTask.tsx` to use `CommunityFinder.tsx` for fet…
mzparacha Aug 7, 2024
1f1e198
Refactored `DownloadMembersListTask.tsx` to use `CommunityFinder.tsx`…
mzparacha Aug 7, 2024
c422cdf
Refactored `RPCEndpointTask.tsx` to use `useGetCommunityByIdQuery` + …
mzparacha Aug 7, 2024
cce8440
Refactored `UpdateCommunityIdTask.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 7, 2024
6b1d85b
Refactored `UpdateCustomDomainTask.tsx` to use `useGetCommunityByIdQu…
mzparacha Aug 7, 2024
4147f80
Refactored render maps in `NotificationsSettingsOld/index.tsx` to use…
mzparacha Aug 7, 2024
5dcc7e6
Removed `app.config.chain.getById` from `MyCommunityStakes.tsx` and r…
mzparacha Aug 7, 2024
352ecc0
Updated get community by id response
mzparacha Aug 7, 2024
2069be6
Added query invalidation helper for `/communities/:id` caches
mzparacha Aug 7, 2024
06258e6
Removed `app.config.chain.getById` from `editCommunityTags.tsx`
mzparacha Aug 7, 2024
ac35a59
Removed `app.config.chain.getById` from `updateActiveCommunity.tsx`
mzparacha Aug 7, 2024
58beba7
Removed `app.config.chain.getById` from `useCommunityJoin.tsx`
mzparacha Aug 7, 2024
435cfcd
Updated docs referring `app.config.chain.getById` to now refer to `us…
mzparacha Aug 8, 2024
f1fd705
Refactored non-react controllers/helpers to use `EXCEPTION_CASE_VANIL…
mzparacha Aug 8, 2024
055d8e3
Merge branch 'master' into malik.8762.community-by-id
mzparacha Aug 8, 2024
91eaae8
Fixed CI/CD code quality tests
mzparacha Aug 8, 2024
0d3f211
Fix Lint
mzparacha Aug 8, 2024
f9371ef
Removed `updateChainData` from `ChainInfo.ts`
mzparacha Aug 8, 2024
f6aa235
Removed todo for community suggesstion algo refactor
mzparacha Aug 8, 2024
b1b4b0d
Refactored `app.config.chains.getById` from `useAuthentication()`
mzparacha Aug 8, 2024
06cea85
Refactored `fullUser.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 8, 2024
309c938
Refactored `user.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 8, 2024
a0b6adf
Removed calls to `/bulkOffchain`
mzparacha Aug 8, 2024
c9036f1
Fixed and reduced instances unnecessarily using full `ChainInfo` object
mzparacha Aug 8, 2024
5c3cf18
Refactored `Layout.tsx` to use `useGetCommunityByIdQuery`
mzparacha Aug 9, 2024
c7aea10
Added conditional checks to `app.chain.meta.*` properties
mzparacha Aug 9, 2024
5e541b7
Added cleanup comment
mzparacha Aug 9, 2024
d68a26c
Added cleanup comment for `EXCEPTION_CASE_threadCountersStore`
mzparacha Aug 9, 2024
7fb7bc3
Removed unnecessary todo
mzparacha Aug 9, 2024
223a2a6
Refactored `Permissions.ts` and related components to use `useGetComm…
mzparacha Aug 12, 2024
14c464c
Updated `EXCEPTION_CASE_VANILLA_getCommunityById` to use cache
mzparacha Aug 12, 2024
df3898c
Removed `app.config.chains.getById` reference from `AddressInfo.ts`
mzparacha Aug 12, 2024
fa8b139
Fix query call
mzparacha Aug 12, 2024
0870ea7
Merge branch 'master' into malik.8762.community-by-id
mzparacha Aug 12, 2024
98f859c
Fix types
mzparacha Aug 12, 2024
059363e
Fix console errors
mzparacha Aug 12, 2024
57b00c1
Fix CI
mzparacha Aug 12, 2024
57dc168
Removed extra ChainInfo methods
mzparacha Aug 12, 2024
215939c
Fix CI
mzparacha Aug 12, 2024
88e0cb5
Removed unnecessary todos
mzparacha Aug 12, 2024
9957063
Updated community profile form to update banner text
mzparacha Aug 12, 2024
38a0382
Fix lint issues
mzparacha Aug 12, 2024
fa83e74
Fix lint
mzparacha Aug 12, 2024
e1390a7
Merge branch 'master' into malik.8762.community-by-id
mzparacha Aug 13, 2024
84a68b9
Removed `clients/scipts` path from file imports
mzparacha Aug 13, 2024
534417a
Update todo comment about 1inch dark mode
mzparacha Aug 13, 2024
428c382
Display slack links in community sidebar as normal links
mzparacha Aug 13, 2024
6b3889a
Fix permission check for community admins
mzparacha Aug 13, 2024
4521354
Fix staked community crashing
mzparacha Aug 13, 2024
7a050be
Fix stake filter in communities list page
mzparacha Aug 13, 2024
b0cacd3
Update dir structure for CommunityDirectoryCard
mzparacha Aug 14, 2024
d9ddd2b
Convert ChainNetwork type to string.
jnaviask Aug 14, 2024
9048ed9
Fix typeerror.
jnaviask Aug 14, 2024
5f9aa16
Merge pull request #8843 from hicommonwealth/jake.8762.eliminate-netw…
mzparacha Aug 14, 2024
37647c6
Merge branch 'master' into malik.8762.community-by-id
jnaviask Aug 14, 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
8 changes: 4 additions & 4 deletions common_knowledge/App-Initialization-Flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ The goal of this document is to describe the current state of the app initializa
2. This `Layout` component includes a nested `Suspense` component (via the `react` library) and `ErrorBoundary` component (via the `react-error-boundary` library).
3. The `LayoutComponent` operates as follows:
1. If, _at render time_, `app.loadingError` is set, display an application error.
2. If, _at render time_, `app.config.chains.getById(scope)` does not return successfully, render a `PageNotFound` view.
3. If, _at render time_, there is no `selectedScope`, and no custom domain, then whatever chain is currently being loaded is deinitialized by `deinitChainOrCommunity`, and the `ScopeToLoad` state variable set to `null`. A loading spinner is shown, triggered by `shouldShowLoadingState`.
4. If, _at render time_, the `selectedScope` differs from `app.activeChainId()`, the `isLoading` and `scopeToLoad` global state variables are updated (to `true` and `selectedScope`, respectively). `selectChain()` is fired, receiving new scope's chain as argument; on completion, the `isLoading` state variable is set to `false`.
2. If, _at render time_, `useGetCommunityByIdQuery(scope)` does not return successfully, render a `PageNotFound` view.
3. If, _at render time_, there is no `providedCommunityScope`, and no custom domain, then whatever chain is currently being loaded is deinitialized by `deinitChainOrCommunity`, and the `communityToLoad` state variable set to `null`. A loading spinner is shown, triggered by `shouldShowLoadingState`.
4. If, _at render time_, the `providedCommunityScope` differs from `app.activeChainId()`, the `isLoading` and `communityToLoad` global state variables are updated (to `true` and `providedCommunityScope`, respectively). `selectChain()` is fired, receiving new scope's chain as argument; on completion, the `isLoading` state variable is set to `false`.
5. If none of these conditions apply, the routed-to page is rendered.
9. If `selectChain()` (`/helpers/chain.ts`) is fired, per step #8:
1. If no `chain` argument is passed, the function defaults to a `chain` value set my `app.user.selectedChain`, or else 'edgeware'.
Expand Down Expand Up @@ -66,4 +66,4 @@ The goal of this document is to describe the current state of the app initializa

## Change Log

- 230810: Authored by Graham Johnson (#4763).
- 230810: Authored by Graham Johnson (#4763).
1 change: 1 addition & 0 deletions libs/model/src/community/GetCommunity.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function GetCommunity(): Query<typeof schemas.GetCommunity> {
],
},
];

if (payload.include_node_info) {
include.push({
model: models.ChainNode,
Expand Down
4 changes: 3 additions & 1 deletion libs/model/src/community/GetStakeTransaction.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ export function GetStakeTransaction(): Query<
'default_symbol', c.default_symbol,
'icon_url', c.icon_url,
'name', c.name,
'chain_node_id', c.chain_node_id
'chain_node_id', c.chain_node_id,
'chain_node_name', cn.name
) AS community
FROM "StakeTransactions" AS t
LEFT JOIN "Communities" AS c ON c.id = t.community_id
LEFT JOIN "ChainNodes" AS cn ON cn.id = c.chain_node_id
LEFT JOIN "CommunityStakes" AS cs ON cs.community_id = t.community_id
${addressFilter}
`,
Expand Down
14 changes: 13 additions & 1 deletion libs/schemas/src/entities/community.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Community = z.object({
name: z.string(),
chain_node_id: PG_INT,
default_symbol: z.string().default(''),
network: z.nativeEnum(ChainNetwork).default(ChainNetwork.Ethereum),
network: z.string().default(ChainNetwork.Ethereum),
base: z.nativeEnum(ChainBase),
icon_url: z.string().nullish(),
active: z.boolean(),
Expand Down Expand Up @@ -68,5 +68,17 @@ export const Community = z.object({
contest_managers: z.array(ContestManager).optional(),
});

export const ExtendedCommunity = Community.extend({
numVotingThreads: PG_INT,
numTotalThreads: PG_INT,
adminsAndMods: z.array(
z.object({
address: z.string(),
role: z.enum(['admin', 'moderator']),
}),
),
communityBanner: z.string().nullish(),
});

// aliases
export const Chain = Community;
20 changes: 8 additions & 12 deletions libs/schemas/src/queries/community.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import {
MIN_SCHEMA_INT,
} from '@hicommonwealth/shared';
import { z } from 'zod';
import { Community, CommunityMember, CommunityStake } from '../entities';
import {
Community,
CommunityMember,
CommunityStake,
ExtendedCommunity,
} from '../entities';
import { PG_INT } from '../utils';
import { PaginatedResultSchema, PaginationParamsSchema } from './pagination';

Expand Down Expand Up @@ -36,17 +41,7 @@ export const GetCommunity = {
id: z.string(),
include_node_info: z.boolean().optional(),
}),
output: Community.extend({
numVotingThreads: PG_INT,
numTotalThreads: PG_INT,
adminsAndMods: z.array(
z.object({
address: z.string(),
role: z.enum(['admin', 'moderator']),
}),
),
communityBanner: z.string().optional(),
}).optional(),
output: ExtendedCommunity,
};

export const GetCommunityStake = {
Expand Down Expand Up @@ -106,6 +101,7 @@ export const GetStakeTransaction = {
icon_url: z.string().nullish(),
name: z.string(),
chain_node_id: PG_INT.nullish(),
chain_node_name: z.string().nullish(),
}),
})
.array(),
Expand Down
45 changes: 10 additions & 35 deletions libs/shared/src/types/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,51 +127,26 @@ export enum CommunityCategoryType {
DAO = 'DAO',
}

// TODO: remove many of these chain networks, esp substrate (make them all "Substrate"),
// and just use id to identify specific chains for conditionals
// This enum represents known values for the "network" field on Community, which can be used for
// switched functionality against specific groups of communities (so we could e.g. group together all
// communities on a specific testnet, or all ERC20s). In practice this field is deprecated, and should be
// removed, but these following values remain as either defaults or for custom integration support.
export enum ChainNetwork {
Ethereum = 'ethereum',
ERC20 = 'erc20',
ERC721 = 'erc721',
ERC1155 = 'erc1155',
Edgeware = 'edgeware',
EdgewareTestnet = 'edgeware-testnet',
Kusama = 'kusama',
Kulupu = 'kulupu',
Polkadot = 'polkadot',
Plasm = 'plasm',
Stafi = 'stafi',
Darwinia = 'darwinia',
Phala = 'phala',
Centrifuge = 'centrifuge',
Straightedge = 'straightedge',
Osmosis = 'osmosis',
Injective = 'injective',
InjectiveTestnet = 'injective-testnet',
Solana = 'solana',
Terra = 'terra',
Ethereum = 'ethereum',
NEAR = 'near',
NEARTestnet = 'near-testnet',
Stargaze = 'stargaze',
Compound = 'compound',
Aave = 'aave',
AaveLocal = 'aave-local',
dYdX = 'dydx',
Metacartel = 'metacartel',
ALEX = 'alex',
ERC20 = 'erc20',
ERC721 = 'erc721',
ERC1155 = 'erc1155',
CW20 = 'cw20',
CW721 = 'cw721',
Clover = 'clover',
HydraDX = 'hydradx',
Crust = 'crust',
Sputnik = 'sputnik',
SolanaDevnet = 'solana-devnet',
SolanaTestnet = 'solana-testnet',
Solana = 'solana',
SPL = 'spl', // solana token
Evmos = 'evmos',
Kava = 'kava',
Kyve = 'kyve',
Stargaze = 'stargaze',
Cosmos = 'cosmos',
}

/**
Expand Down
56 changes: 41 additions & 15 deletions packages/commonwealth/client/scripts/controllers/app/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import { CosmosExtension } from '@magic-ext/cosmos';
import { OAuthExtension } from '@magic-ext/oauth';
import { Magic } from 'magic-sdk';

import { ExtendedCommunity } from '@hicommonwealth/schemas';
import axios from 'axios';
import app from 'state';
import { EXCEPTION_CASE_VANILLA_getCommunityById } from 'state/api/communities/getCommuityById';
import { SERVER_URL } from 'state/api/config';
import { fetchProfilesByAddress } from 'state/api/profiles/fetchProfilesByAddress';
import {
Expand All @@ -33,10 +35,11 @@ import {
import { authModal } from 'state/ui/modals/authModal';
import { welcomeOnboardModal } from 'state/ui/modals/welcomeOnboardModal';
import { userStore } from 'state/ui/user';
import { z } from 'zod';
import Account from '../../models/Account';
import AddressInfo from '../../models/AddressInfo';
import type BlockInfo from '../../models/BlockInfo';
import type ChainInfo from '../../models/ChainInfo';
import ChainInfo from '../../models/ChainInfo';

function storeActiveAccount(account: Account) {
const user = userStore.getState();
Expand Down Expand Up @@ -112,14 +115,13 @@ export async function completeClientLogin(account: Account) {
}
}

export async function updateActiveAddresses({ chain }: { chain?: ChainInfo }) {
export async function updateActiveAddresses(chainId: string) {
// update addresses for a chain (if provided) or for communities (if null)
// for communities, addresses on all chains are available by default
userStore.getState().setData({
accounts: userStore
.getState()
.addresses // @ts-expect-error StrictNullChecks
.filter((a) => a.community.id === chain.id)
.addresses.filter((a) => a.community.id === chainId)
.map((addr) => {
const tempAddr = app.chain?.accounts.get(addr.address, false);
tempAddr.profile = addr.profile;
Expand All @@ -131,8 +133,7 @@ export async function updateActiveAddresses({ chain }: { chain?: ChainInfo }) {

// select the address that the new chain should be initialized with
const memberAddresses = userStore.getState().accounts.filter((account) => {
// @ts-expect-error StrictNullChecks
return account.community.id === chain.id;
return account.community.id === chainId;
});

if (memberAddresses.length === 1) {
Expand All @@ -145,7 +146,7 @@ export async function updateActiveAddresses({ chain }: { chain?: ChainInfo }) {
const communityAddressesSortedByLastUsed = [
...(userStore
.getState()
.addresses.filter((a) => a.community.id === chain?.id) || []),
.addresses.filter((a) => a.community.id === chainId) || []),
].sort((a, b) => {
if (b.lastActive && a.lastActive) return b.lastActive.diff(a.lastActive);
if (!b.lastActive && !a.lastActive) return 0; // no change
Expand Down Expand Up @@ -285,7 +286,15 @@ export async function createUserWithAddress(
});

const id = response.data.result.id;
const chainInfo = app.config.chains.getById(chain);

const communityInfo = await EXCEPTION_CASE_VANILLA_getCommunityById(
chain || '',
true,
);
const chainInfo = ChainInfo.fromTRPCResponse(
communityInfo as z.infer<typeof ExtendedCommunity>,
);

const account = new Account({
addressId: id,
address,
Expand Down Expand Up @@ -359,7 +368,7 @@ export async function startLoginWithMagicLink({
redirectTo ? encodeURIComponent(redirectTo) : ''
}&chain=${chain || ''}&sso=${provider}`;
await magic.oauth.loginWithRedirect({
provider: provider as any,
provider,
redirectURI: new URL(
'/finishsociallogin' + params,
window.location.origin,
Expand Down Expand Up @@ -418,8 +427,16 @@ export async function handleSocialLoginCallback({
}): Promise<{ address: string; isAddressNew: boolean }> {
// desiredChain may be empty if social login was initialized from
// a page without a chain, in which case we default to an eth login
// @ts-expect-error StrictNullChecks
const desiredChain = app.chain?.meta || app.config.chains.getById(chain);
let desiredChain = app.chain?.meta;
if (!desiredChain && chain) {
const communityInfo = await EXCEPTION_CASE_VANILLA_getCommunityById(
chain || '',
true,
);
desiredChain = ChainInfo.fromTRPCResponse(
communityInfo as z.infer<typeof ExtendedCommunity>,
);
}
const isCosmos = desiredChain?.base === ChainBase.CosmosSDK;
const magic = await constructMagic(isCosmos, desiredChain?.id);
const isEmail = walletSsoSource === WalletSsoSource.Email;
Expand Down Expand Up @@ -554,10 +571,19 @@ export async function handleSocialLoginCallback({
// This is code from before desiredChain was implemented, and
// may not be necessary anymore:
if (app.chain) {
const c =
userStore.getState().activeCommunity ||
app.config.chains.getById(app.activeChainId());
await updateActiveAddresses({ chain: c });
let chainInfo = userStore.getState().activeCommunity;

if (!chainInfo && chain) {
const communityInfo = await EXCEPTION_CASE_VANILLA_getCommunityById(
chain || '',
true,
);
chainInfo = ChainInfo.fromTRPCResponse(
communityInfo as z.infer<typeof ExtendedCommunity>,
);
}

chainInfo && (await updateActiveAddresses(chainInfo.id));
}

const { Profiles: profiles, email: ssoEmail } = response.data.result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ class CoinbaseWebWalletController implements IWebWallet<string> {
} catch (switchError) {
// This error code indicates that the chain has not been added to coinbase.
if (switchError.code === 4902) {
const wsRpcUrl = new URL(app.chain.meta.node.url);
const wsRpcUrl = new URL(app.chain?.meta?.node?.url);
const rpcUrl =
app.chain.meta.node.altWalletUrl || `https://${wsRpcUrl.host}`;
app.chain?.meta?.node?.altWalletUrl || `https://${wsRpcUrl.host}`;

const chains = await axios.get('https://chainid.network/chains.json');
const baseChain = chains.data.find((c) => c.chainId === chainId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import app from 'state';
import type Web3 from 'web3';

import { SIWESigner } from '@canvas-js/chain-ethereum';
import { ExtendedCommunity } from '@hicommonwealth/schemas';
import { EXCEPTION_CASE_VANILLA_getCommunityById } from 'state/api/communities/getCommuityById';
import { userStore } from 'state/ui/user';
import { hexToNumber } from 'web3-utils';
import { z } from 'zod';
import BlockInfo from '../../../models/BlockInfo';
import ChainInfo from '../../../models/ChainInfo';
import IWebWallet from '../../../models/IWebWallet';
Expand Down Expand Up @@ -97,10 +100,21 @@ class WalletConnectWebWalletController implements IWebWallet<string> {
public async enable() {
console.log('Attempting to enable WalletConnect');
this._enabling = true;
// try {
// Create WalletConnect Provider
this._chainInfo =
app.chain?.meta || app.config.chains.getById(this.defaultNetwork);
this._chainInfo = app?.chain?.meta;

if (!this._chainInfo && app.activeChainId()) {
const communityInfo = await EXCEPTION_CASE_VANILLA_getCommunityById(
app.activeChainId() || '',
true,
);

const chainInfo = ChainInfo.fromTRPCResponse(
communityInfo as z.infer<typeof ExtendedCommunity>,
);

this._chainInfo = chainInfo;
}

const chainId = this._chainInfo.node?.ethChainId || 1;
const EthereumProvider = (await import('@walletconnect/ethereum-provider'))
.default;
Expand Down
Loading
Loading