mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-07-21 13:25:40 +00:00
Add Pezkuwi SDK UI - Polkadot.js Apps clone
- 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
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// Copyright 2017-2025 @polkadot/app-staking authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiPromise } from '@polkadot/api';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { PoolAccounts } from './types.js';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { createNamedHook, useApi } from '@polkadot/react-hooks';
|
||||
import { bnToU8a, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
|
||||
const EMPTY_H256 = new Uint8Array(32);
|
||||
const MOD_PREFIX = stringToU8a('modl');
|
||||
const U32_OPTS = { bitLength: 32, isLe: true };
|
||||
|
||||
function createAccount (api: ApiPromise, palletId: Uint8Array, poolId: BN, index: number): string {
|
||||
return api.registry.createType('AccountId32', u8aConcat(
|
||||
MOD_PREFIX,
|
||||
palletId,
|
||||
new Uint8Array([index]),
|
||||
bnToU8a(poolId, U32_OPTS),
|
||||
EMPTY_H256
|
||||
)).toString();
|
||||
}
|
||||
|
||||
export function createAccounts (api: ApiPromise, poolId: BN): PoolAccounts {
|
||||
const palletId = api.consts.nominationPools.palletId.toU8a();
|
||||
|
||||
return {
|
||||
rewardId: createAccount(api, palletId, poolId, 1),
|
||||
stashId: createAccount(api, palletId, poolId, 0)
|
||||
};
|
||||
}
|
||||
|
||||
function usePoolAccountsImpl (poolId: BN): PoolAccounts {
|
||||
const { api } = useApi();
|
||||
|
||||
return useMemo(
|
||||
() => createAccounts(api, poolId),
|
||||
[api, poolId]
|
||||
);
|
||||
}
|
||||
|
||||
export default createNamedHook('usePoolAccounts', usePoolAccountsImpl);
|
||||
Reference in New Issue
Block a user