* feat: create hook for quering foreign assets locations * feat: add foreign assets tab * fix: useMapKeys used instead of useMapEntries * chore: rename hook * feat: add ForeignAssets component and Summary for displaying foreign asset counts * chore: rename folder * feat: implement useForeignAssetInfos hook for managing foreign asset information * feat: add Asset and Assets components for displaying foreign asset information * feat: enhance Asset component with CopyButton for location and adjust Assets table layout * chore: add translations * fix: CI error * fix: CI build errors * feat: added expander component for multilocation * chore: align position change
25 lines
825 B
TypeScript
25 lines
825 B
TypeScript
// Copyright 2017-2025 @polkadot/app-assets authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { StorageKey } from '@polkadot/types';
|
|
import type { StagingXcmV3MultiLocation } from '@polkadot/types/lookup';
|
|
|
|
import { createNamedHook, useApi, useMapKeys } from '@polkadot/react-hooks';
|
|
|
|
const EMPTY_PARAMS: unknown[] = [];
|
|
|
|
const OPT_KEY = {
|
|
transform: (keys: StorageKey<[StagingXcmV3MultiLocation]>[]): StagingXcmV3MultiLocation[] =>
|
|
keys.flatMap(({ args }) => args)
|
|
};
|
|
|
|
function useForeignAssetLocationsImpl () {
|
|
const { api, isApiReady } = useApi();
|
|
|
|
const values = useMapKeys(isApiReady && api.query.foreignAssets?.asset, EMPTY_PARAMS, OPT_KEY) || [];
|
|
|
|
return values;
|
|
}
|
|
|
|
export const useForeignAssetLocations = createNamedHook('useForeignAssetLocations', useForeignAssetLocationsImpl);
|