-
Notifications
You must be signed in to change notification settings - Fork 5
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: support Aleph Zero #1576
base: main
Are you sure you want to change the base?
feat: support Aleph Zero #1576
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import type { Chain } from '@polkadot/extension-chains/types'; | |
import { createWsEndpoints } from '@polkagate/apps-config'; | ||
import { useMemo } from 'react'; | ||
|
||
import { useUserAddedEndpoint } from '../fullscreen/addNewChain/utils'; | ||
import getChainGenesisHash from '../util/getChainGenesisHash'; | ||
import { sanitizeChainName } from '../util/utils'; | ||
import useApi from './useApi'; | ||
|
@@ -15,14 +16,23 @@ const allEndpoints = createWsEndpoints(); | |
|
||
export default function useApiWithChain2 (chain: Chain | null | undefined): ApiPromise | undefined { | ||
const genesisHash = useMemo(() => chain?.genesisHash || getChainGenesisHash(chain?.name), [chain]); | ||
const userAddedEndpoint = useUserAddedEndpoint(genesisHash); | ||
|
||
const maybeEndpoint = useMemo(() => { | ||
const chainName = sanitizeChainName(chain?.name); | ||
|
||
const endpoints = allEndpoints?.filter((e) => String(e.text)?.toLowerCase() === chainName?.toLowerCase() || String(e.info)?.toLowerCase() === chainName?.toLowerCase()); | ||
const endpoints = allEndpoints?.filter((e) => | ||
String(e.text)?.toLowerCase() === chainName?.toLowerCase() || | ||
String(e.info)?.toLowerCase() === chainName?.toLowerCase() || | ||
String(e.text)?.replace(/\s/g, '')?.toLowerCase() === chainName?.toLowerCase() | ||
); | ||
Comment on lines
+24
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential issue with converting undefined to string Using Consider updating the filter logic to handle const endpoints = allEndpoints?.filter((e) =>
e.text?.toLowerCase() === chainName?.toLowerCase() ||
e.info?.toLowerCase() === chainName?.toLowerCase() ||
e.text?.replace(/\s/g, '').toLowerCase() === chainName?.toLowerCase()
); |
||
|
||
if (!endpoints?.length && userAddedEndpoint) { | ||
return userAddedEndpoint[0].value as string; | ||
} | ||
Comment on lines
+30
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure 'userAddedEndpoint' is not empty before accessing When if (!endpoints?.length && userAddedEndpoint?.length > 0) {
return userAddedEndpoint[0].value as string;
} |
||
|
||
return endpoints?.length ? endpoints[0].value : undefined; | ||
}, [chain?.name]); | ||
}, [chain?.name, userAddedEndpoint]); | ||
|
||
const _api = useApi(undefined, undefined, maybeEndpoint, genesisHash); | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -28,7 +28,7 @@ export default function useIdentity (genesisHash: string | undefined, formatted: | |||||
} | ||||||
|
||||||
const i = await api.query['identity']['identityOf'](accountId) as any; | ||||||
const id = i.isSome ? i.unwrap()[0] as PalletIdentityRegistration : null; | ||||||
const id = i.isSome ? i.unwrap()[0] || i.unwrap() as PalletIdentityRegistration : null; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix potential type casting issue by adding parentheses The type assertion may not apply as intended due to operator precedence. To ensure that the type casting applies to the entire expression Apply this diff to fix the issue: - const id = i.isSome ? i.unwrap()[0] || i.unwrap() as PalletIdentityRegistration : null;
+ const id = i.isSome ? (i.unwrap()[0] || i.unwrap()) as PalletIdentityRegistration : null; 📝 Committable suggestion
Suggested change
|
||||||
|
||||||
return id?.info | ||||||
? { | ||||||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid casting 'stashId' using 'as unknown as string'; use '.toString()' method instead
Casting
parsedStakingAccount.stashId
withas unknown as string
may conceal underlying type issues and reduce type safety. It's clearer and more type-safe to convertstashId
to a string using the.toString()
method.Apply this diff to fix the issue:
📝 Committable suggestion