mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-04-23 10:37:59 +00:00
feat: initial Pezkuwi Apps rebrand from polkadot-apps
Rebranded terminology: - Polkadot → Pezkuwi - Kusama → Dicle - Westend → Zagros - Rococo → PezkuwiChain - Substrate → Bizinikiwi - parachain → teyrchain Custom logos with Kurdistan brand colors (#e6007a → #86e62a): - bizinikiwi-hexagon.svg - sora-bizinikiwi.svg - hezscanner.svg - heztreasury.svg - pezkuwiscan.svg - pezkuwistats.svg - pezkuwiassembly.svg - pezkuwiholic.svg
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// Copyright 2017-2025 @pezkuwi/react-hooks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { StorageKey, u32 } from '@pezkuwi/types';
|
||||
import type { EventRecord } from '@pezkuwi/types/interfaces';
|
||||
import type { Changes } from './useEventChanges.js';
|
||||
|
||||
import { createNamedHook, useApi, useEventChanges, useMapKeys } from './index.js';
|
||||
|
||||
const EMPTY_PARAMS: unknown[] = [];
|
||||
|
||||
const OPT_KEY = {
|
||||
transform: (keys: StorageKey<[u32]>[]): u32[] =>
|
||||
keys.map(({ args: [id] }) => id).filter((id) => id !== undefined)
|
||||
};
|
||||
|
||||
function filter (records: EventRecord[]): Changes<u32> {
|
||||
const added: u32[] = [];
|
||||
const removed: u32[] = [];
|
||||
|
||||
records.forEach(({ event: { data: [id], method } }): void => {
|
||||
if (method === 'Created' || method === 'ForceCreated') {
|
||||
added.push(id as u32);
|
||||
} else {
|
||||
removed.push(id as u32);
|
||||
}
|
||||
});
|
||||
|
||||
return { added, removed };
|
||||
}
|
||||
|
||||
function useAssetIdsImpl (): u32[] | undefined {
|
||||
const { api } = useApi();
|
||||
const startValue = useMapKeys(api.query.assets?.asset, EMPTY_PARAMS, OPT_KEY) || [];
|
||||
|
||||
return useEventChanges([
|
||||
api.events.assets?.Created,
|
||||
api.events.assets?.Destroyed,
|
||||
api.events.assets?.ForceCreated
|
||||
], filter, startValue);
|
||||
}
|
||||
|
||||
export const useAssetIds = createNamedHook('useAssetIds', useAssetIdsImpl);
|
||||
Reference in New Issue
Block a user