diff --git a/packages/apps-config/src/api/constants.ts b/packages/apps-config/src/api/constants.ts index d03f3f52ef15..0e8ef9a9e599 100644 --- a/packages/apps-config/src/api/constants.ts +++ b/packages/apps-config/src/api/constants.ts @@ -6,7 +6,7 @@ import type { HexString } from '@polkadot/util/types'; import { knownGenesis } from '@polkadot/networks/defaults'; import { assert, BN } from '@polkadot/util'; -function getGenesis (name: string): HexString { +export function getGenesis (name: string): HexString { const network = Object.entries(knownGenesis).find(([network]) => network === name); assert(network?.[1][0], `Unable to find genesisHash for ${name}`); diff --git a/packages/page-assets/src/Overview/Create/Info.tsx b/packages/page-assets/src/Overview/Create/Info.tsx index e9174c120439..07c851f5cab6 100644 --- a/packages/page-assets/src/Overview/Create/Info.tsx +++ b/packages/page-assets/src/Overview/Create/Info.tsx @@ -1,6 +1,7 @@ // Copyright 2017-2025 @polkadot/app-assets authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { BitLength } from '@polkadot/react-components/types'; import type { BN } from '@polkadot/util'; import type { InfoState } from './types.js'; @@ -20,6 +21,8 @@ interface Props { openId: BN; } +const ASSET_ID_BIT_LENGTH: BitLength = 128; + function Info ({ assetIds, className = '', defaultValue, onChange, openId }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); @@ -114,6 +117,7 @@ function Info ({ assetIds, className = '', defaultValue, onChange, openId }: Pro a.cmp(b))[ids.length - 1].add(BN_ONE); + } + const lastTaken = ids.find((id, index) => index === 0 ? !id.eq(BN_ONE) @@ -36,12 +45,13 @@ function findOpenId (ids?: BN[]): BN { ); return lastTaken - ? lastTaken.sub(BN_ONE) + ? lastTaken.add(BN_ONE) : ids[ids.length - 1].add(BN_ONE); } function AssetApp ({ basePath, className }: Props): React.ReactElement { const { t } = useTranslation(); + const { api } = useApi(); const { hasAccounts } = useAccounts(); const ids = useAssetIds(); const infos = useAssetInfos(ids); @@ -66,8 +76,8 @@ function AssetApp ({ basePath, className }: Props): React.ReactElement { ); const openId = useMemo( - () => findOpenId(ids), - [ids] + () => findOpenId(api.genesisHash.toHex(), ids), + [api.genesisHash, ids] ); return (