Relaycode

Bounty Selector

Searchable combobox for selecting a treasury bounty by index

Connecting to Polkadot...
import { BountySelector } from "@/components/params/selectors/bounty-selector";

<BountySelector
  name="bountyId"
  label="Bounty"
  client={client}
  palletContext={governanceContext}
  isContextLoading={false}
  onChange={(value) => console.log("Selected:", value)}
/>

Bounty Selector

The Bounty Selector is a contextual selector that replaces the default numeric input when the extrinsic builder detects a bounty_id parameter in bounty-related calls. It displays a searchable combobox populated with live bounty data including titles, reward values, curator information, and status.

When It Appears

The Bounty Selector activates for these pallet/method/parameter combinations defined in PALLET_OVERRIDES:

PalletMethodParameter
Bountiesapprove_bountybounty_id
Bountiespropose_curatorbounty_id
Bountiesclose_bountybounty_id
Bountiesaward_bountybounty_id
Bountiesclaim_bountybounty_id

Props

The component accepts the standard ParamInputProps interface with context extensions:

PropTypeRequiredDescription
labelstringNoDisplay label shown above the selector
valueanyNoCurrently selected bounty index
onChange(value: unknown) => voidNoCallback fired with the selected bounty index
isContextLoadingbooleanNoWhen true, displays a skeleton loading placeholder
palletContextPalletContextDataNoGovernance context containing the bounties list

Features

  • Searchable: Filters bounties by index, title, description, or curator address.
  • Reward display: Shows the bounty reward value converted from planck to the chain's native token denomination (e.g. "100 DOT").
  • Curator info: Displays the curator's on-chain identity name when available, otherwise shows a truncated address.
  • Status badge: A badge showing the bounty's current status (e.g. Active, CuratorProposed, PendingPayout).
  • Bounty index: Each row displays the bounty index in monospace (e.g. "#7") for quick identification.
  • Title with fallback: Shows the bounty title, falling back to the first 60 characters of the description, or "Untitled" if neither is available.
  • Graceful fallback: Falls back to a plain numeric input via SelectorFallback when context data is unavailable.

Data Source

Bounty data comes from the GovernanceContext fetched by lib/pallet-context/governance.ts. The primary source is the Polkassembly API (lib/api/polkassembly.ts -- fetchBounties), which provides bounty IDs, titles, descriptions, curators, reward amounts, and statuses. Falls back to on-chain RPC (bounties.bounties.entries()) when the API is unavailable, though the RPC fallback provides less metadata (no titles or descriptions).

Usage

The Bounty Selector is resolved automatically by findComponentWithContext when pallet overrides match:

import { findComponentWithContext } from "@/lib/input-map";

// When palletName="Bounties", methodName="approve_bounty", fieldName="bounty_id"
const result = findComponentWithContext(
  "Bounties", "approve_bounty", "bounty_id", typeName, typeId, client, palletContext
);
// result.component === BountySelector
// result.isOverride === true

Value Format

The onChange callback receives a number -- the bounty index of the selected bounty.