@polkadot/types/interfaces#TreasuryProposal TypeScript Examples

The following examples show how to use @polkadot/types/interfaces#TreasuryProposal. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TreasuryCell.tsx    From crust-apps with Apache License 2.0 6 votes vote down vote up
function TreasuryCell ({ className = '', value }: Props): React.ReactElement<Props> | null {
  const { api } = useApi();
  const [proposalId] = useState(value.unwrap());
  const proposal = useCall<TreasuryProposal | null>(api.query.treasury.proposals, [proposalId], transformProposal);
  const [{ params, values }, setExtracted] = useState<ParamState>({ params: [], values: [] });

  useEffect((): void => {
    proposal && setExtracted({
      params: [{
        name: 'proposal',
        type: getTypeDef('TreasuryProposal')
      }],
      values: [{
        isValid: true,
        value: proposal
      }]
    });
  }, [proposal]);

  if (!proposal) {
    return null;
  }

  return (
    <div className={className}>
      <Params
        isDisabled
        params={params}
        values={values}
      />
    </div>
  );
}
Example #2
Source File: TreasuryCell.tsx    From crust-apps with Apache License 2.0 5 votes vote down vote up
transformProposal = {
  transform: (optProp: Option<TreasuryProposal>) => optProp.unwrapOr(null)
}