mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-05-08 19:47:56 +00:00
c71ddb6e0d
- Clone Polkadot.js Apps repository - Update package.json with Pezkuwi branding - Add Pezkuwi endpoint to production chains (wss://pezkuwichain.app:9944) - Create comprehensive README for SDK UI - Set up project structure with all packages Next steps: - Apply Kurdistan colors (Kesk, Sor, Zer, Spi + Black) to UI theme - Replace logos with Pezkuwi branding - Test build and deployment
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
// Copyright 2017-2025 @polkadot/react-hooks authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ApiPromise } from '@polkadot/api';
|
|
import type { Option } from '@polkadot/types';
|
|
import type { PalletBrokerConfigRecord } from '@polkadot/types/lookup';
|
|
import type { PalletBrokerConfigRecord as SimplifiedPalletBrokerConfigRecord } from './types.js';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { createNamedHook, useCall } from '@polkadot/react-hooks';
|
|
|
|
function extractInfo (config: Option<PalletBrokerConfigRecord>): SimplifiedPalletBrokerConfigRecord {
|
|
const c = config.unwrap();
|
|
|
|
return {
|
|
advanceNotice: c.advanceNotice?.toNumber(),
|
|
contributionTimeout: c.contributionTimeout?.toNumber(),
|
|
idealBulkProportion: c.idealBulkProportion,
|
|
interludeLength: c.interludeLength?.toNumber(),
|
|
leadinLength: c.leadinLength?.toNumber(),
|
|
limitCoresOffered: c.limitCoresOffered?.isSome ? c.limitCoresOffered?.unwrap().toNumber() : 0,
|
|
regionLength: c.regionLength?.toNumber(),
|
|
renewalBump: c.renewalBump
|
|
};
|
|
}
|
|
|
|
function useBrokerConfigImpl (api: ApiPromise, ready: boolean) {
|
|
const config = useCall<Option<PalletBrokerConfigRecord>>(ready && api?.query.broker.configuration);
|
|
|
|
const [state, setState] = useState<SimplifiedPalletBrokerConfigRecord | undefined>();
|
|
|
|
useEffect((): void => {
|
|
!!config && !!config.isSome && !!config.toJSON() &&
|
|
setState(
|
|
extractInfo(config)
|
|
);
|
|
}, [config]);
|
|
|
|
return state;
|
|
}
|
|
|
|
export const useBrokerConfig = createNamedHook('useBrokerConfig', useBrokerConfigImpl);
|