mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-20 00:01:06 +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 @@
|
||||
# @pezkuwi/app-whitelist
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"bugs": "https://github.com/pezkuwichain/pezkuwi-apps/issues",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/pezkuwichain/pezkuwi-apps/tree/master/packages/page-whitelist#readme",
|
||||
"license": "Apache-2.0",
|
||||
"name": "@pezkuwi/app-whitelist",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"directory": "packages/page-whitelist",
|
||||
"type": "git",
|
||||
"url": "https://github.com/pezkuwichain/pezkuwi-apps.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "0.168.2-4-x",
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"react-dom": "*",
|
||||
"react-is": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-whitelist authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import Call from '@pezkuwi/app-preimages/Preimages/Call';
|
||||
import Hash from '@pezkuwi/app-preimages/Preimages/Hash';
|
||||
import { usePreimage } from '@pezkuwi/react-hooks';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
value: HexString;
|
||||
}
|
||||
|
||||
function Details ({ className, value }: Props): React.ReactElement<Props> {
|
||||
const info = usePreimage(value);
|
||||
|
||||
return (
|
||||
<tr className={ className }>
|
||||
<Hash value={value} />
|
||||
<Call value={info} />
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Details);
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-whitelist authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { CardSummary, SummaryBox } from '@pezkuwi/react-components';
|
||||
import { formatNumber } from '@pezkuwi/util';
|
||||
|
||||
import { useTranslation } from '../translate.js';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
hashes?: string[];
|
||||
}
|
||||
|
||||
function Summary ({ className, hashes }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<SummaryBox className={className}>
|
||||
<CardSummary label={t('hashes')}>
|
||||
{hashes === undefined
|
||||
? <span className='--tmp'>99</span>
|
||||
: formatNumber(hashes.length)
|
||||
}
|
||||
</CardSummary>
|
||||
</SummaryBox>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Summary);
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-whitelist authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { SubmittableExtrinsicFunction } from '@pezkuwi/api/types';
|
||||
|
||||
import React, { useRef } from 'react';
|
||||
|
||||
import { Table } from '@pezkuwi/react-components';
|
||||
|
||||
import { useTranslation } from '../translate.js';
|
||||
import useHashes from '../useHashes.js';
|
||||
import Details from './Details.js';
|
||||
import Summary from './Summary.js';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
defaultPropose?: SubmittableExtrinsicFunction<'promise'>;
|
||||
filter?: (section: string, method?: string) => boolean;
|
||||
}
|
||||
|
||||
function Hashes ({ className }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const hashes = useHashes();
|
||||
|
||||
const headerRef = useRef<([React.ReactNode?, string?, number?] | false)[]>([
|
||||
[t('calls'), 'start'],
|
||||
[undefined, 'all'],
|
||||
[undefined, 'media--1300']
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<Summary hashes={hashes} />
|
||||
<Table
|
||||
className={className}
|
||||
empty={hashes && t('No call hashes found')}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{hashes?.map((h) => (
|
||||
<Details
|
||||
key={h}
|
||||
value={h}
|
||||
/>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Hashes);
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-whitelist authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React, { useRef } from 'react';
|
||||
|
||||
import { Tabs } from '@pezkuwi/react-components';
|
||||
|
||||
import Hashes from './Hashes/index.js';
|
||||
import { useTranslation } from './translate.js';
|
||||
|
||||
interface Props {
|
||||
basePath: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function App ({ basePath, className }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const tabsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'overview',
|
||||
text: t('Overview')
|
||||
}
|
||||
]);
|
||||
|
||||
return (
|
||||
<main className={className}>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
items={tabsRef.current}
|
||||
/>
|
||||
<Hashes />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(App);
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-whitelist authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { useTranslation as useTranslationBase } from 'react-i18next';
|
||||
|
||||
export function useTranslation (): { t: (key: string, options?: { replace: Record<string, unknown> }) => string } {
|
||||
return useTranslationBase('app-whitelist');
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-preimages authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Changes } from '@pezkuwi/react-hooks/useEventChanges';
|
||||
import type { StorageKey } from '@pezkuwi/types';
|
||||
import type { EventRecord, Hash } from '@pezkuwi/types/interfaces';
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { createNamedHook, useApi, useEventChanges, useMapKeys } from '@pezkuwi/react-hooks';
|
||||
|
||||
const OPT_HASH = {
|
||||
transform: (keys: StorageKey<[Hash]>[]): Hash[] =>
|
||||
keys.map(({ args: [hash] }) => hash)
|
||||
};
|
||||
|
||||
function filter (records: EventRecord[]): Changes<Hash> {
|
||||
const added: Hash[] = [];
|
||||
const removed: Hash[] = [];
|
||||
|
||||
records.forEach(({ event: { data: [hash], method } }): void => {
|
||||
if (method === 'CallWhitelisted') {
|
||||
added.push(hash as Hash);
|
||||
} else {
|
||||
removed.push(hash as Hash);
|
||||
}
|
||||
});
|
||||
|
||||
return { added, removed };
|
||||
}
|
||||
|
||||
function useHashesImpl (): HexString[] | undefined {
|
||||
const { api } = useApi();
|
||||
const startValue = useMapKeys(api.query.whitelist.whitelistedCall, [], OPT_HASH);
|
||||
const hashes = useEventChanges([
|
||||
api.events.whitelist.CallWhitelisted,
|
||||
api.events.whitelist.WhitelistedCallRemoved
|
||||
], filter, startValue);
|
||||
|
||||
return useMemo(
|
||||
() => hashes?.map((h) => h.toHex()),
|
||||
[hashes]
|
||||
);
|
||||
}
|
||||
|
||||
export default createNamedHook('useHashes', useHashesImpl);
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "..",
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"references": [
|
||||
{ "path": "../page-preimages/tsconfig.build.json" },
|
||||
{ "path": "../react-components/tsconfig.build.json" },
|
||||
{ "path": "../react-hooks/tsconfig.build.json" }
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user