* Staking pools * Fly-by comment fix * Some infrastructure * multi * Create value * Retrieve singular params instance * defaultValue for multi query * Retrieve list of pool ids * Drive-by param formatting * Pool list retrieval * Retrieve pool info * Adjust trigger placement * Dump info * Join modal * Fix build * Allow creation & joining * caveman typing * Adjust disabled state * Adjust * cowboy types * Some basic stats * Created/Destoyed events * Adjust for latest * Set metadata on creation * Basic pools
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
// Copyright 2017-2022 @polkadot/app-staking authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { BN } from '@polkadot/util';
|
|
import type { Params } from './types';
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import { FormatBalance } from '@polkadot/react-query';
|
|
import { formatNumber, stringify } from '@polkadot/util';
|
|
|
|
import Join from './Join';
|
|
import usePoolInfo from './usePoolInfo';
|
|
|
|
interface Props {
|
|
className?: string;
|
|
id: BN;
|
|
params: Params;
|
|
}
|
|
|
|
function Pool ({ className, id, params }: Props): React.ReactElement<Props> | null {
|
|
const info = usePoolInfo(id);
|
|
const metadata = useMemo(
|
|
() => info && info.metadata && info.metadata.length
|
|
? info.metadata.isUtf8
|
|
? info.metadata.toUtf8()
|
|
: info.metadata.toString()
|
|
: null,
|
|
[info]
|
|
);
|
|
|
|
if (!info) {
|
|
return null;
|
|
}
|
|
|
|
console.log(stringify(info, 2));
|
|
|
|
return (
|
|
<tr className={className}>
|
|
<td className='number'><h1>{formatNumber(id)}</h1></td>
|
|
<td className='start'>{metadata}</td>
|
|
<td className='number'><FormatBalance value={info.bonded?.points} /></td>
|
|
<td className='number'>{formatNumber(info.bonded?.delegatorCounter)}</td>
|
|
<td className='button'>
|
|
<Join
|
|
id={id}
|
|
isDisabled={!info.bonded?.state.isOpen}
|
|
params={params}
|
|
/>
|
|
</td>
|
|
</tr>
|
|
);
|
|
}
|
|
|
|
export default React.memo(Pool);
|