intrepidshape/elm-web3-ui/3.0.0

NOTE: the latest version is 4.0.0

Web3.Ui.FundingPool

Render a crowd-funded pool panel -- generic shape for any "escrowed funding with a target, deadline, and refund fallback" mechanism.

Use cases:

  • Community-funded audits (pledgers crowdfund a security review -> auditor delivers report -> escrow releases).
  • Bug-bounty / vulnerability-fix pools.
  • Open-source-feature crowdfunding (pledgers fund a feature -> maintainer ships -> escrow releases).
  • Refundable kickstarter-style commitments where the deliverable is on-chain verifiable.

The structural pattern is universal:

  1. Someone commits to deliver against a target.
  2. Anyone pledges native value while the deadline is in the future.
  3. Once the target is met, the proposer releases by publishing a deliverable URI.
  4. If the deadline passes without release, every pledger pulls back their own deposit.

Three lifecycle states swap the primary CTA:

  • Open -- collecting pledges, deadline ahead.
  • Funded -- target reached, awaiting release.
  • Closed -- released (with deliverable URL) or expired (refunds).

The panel title, status pill copy, CTA verbs, and disclaimer are all configurable via Labels so the panel can speak in the voice of whichever mechanism the caller is exposing.

Web3.Ui.FundingPool.view []
    { pool =
        Web3.Ui.FundingPool.pool
            { target = "25.0"
            , balance = "14.75"
            , unit = "PLS"
            , deadline = "6 days"
            , pledgerCount = 47
            , topPledgers = [ { label = "alice.eth", amount = "2.5" } ]
            , status = Open
            , reportUrl = Nothing
            }
    , labels = Web3.Ui.FundingPool.defaultLabels
    , onPledge = Just PledgeStandard
    , onPledgeCustom = Just PledgeCustom
    , onRefund = Nothing
    , onViewReport = Nothing
    }

Stateless -- caller owns the Pool and emits the appropriate msg.

CSS classes follow BEM: web3-funding-pool, web3-funding-pool__head, web3-funding-pool__title, web3-funding-pool__subtitle, web3-funding-pool__stats, web3-funding-pool__stat, web3-funding-pool__stat-label, web3-funding-pool__stat-value, web3-funding-pool__progress, web3-funding-pool__progress-fill, web3-funding-pool__pledgers, web3-funding-pool__pledger, web3-funding-pool__actions, web3-funding-pool__cta, web3-funding-pool__cta--primary / --secondary, web3-funding-pool__report, web3-funding-pool__disclaimer.

view : List (Attribute msg) -> Config msg -> Html msg

Render the panel.

type alias Config msg =
{ pool : Pool
, labels : Labels
, onPledge : Maybe msg
, onPledgeCustom : Maybe msg
, onRefund : Maybe msg
, onViewReport : Maybe msg
}

Configuration for view. Each onXxx is optional -- pass Nothing to disable that affordance.

type Pool

The pool's current observable state. Values are pre-formatted strings because amount/unit/precision is the caller's concern -- this primitive is rendering, not arithmetic.

type alias Pledger =
{ label : String
, amount : String
}

One pledger row in the "top pledgers" list.

type Status
= Open
| Funded
| Closed

A pool's lifecycle state.

type alias Labels =
{ title : String
, pledgeCta : String
, pledgeCustomCta : String
, refundCta : String
, viewReportCta : String
, fundedMessage : String
, disclaimer : String
, targetLabel : String
, poolLabel : String
, deadlineLabel : String
, pledgerCountLabel : String
, topPledgersTitle : String
, statusLabels :
{ open : String
, funded : String
, closed : String
}
}

Configurable strings rendered inside the panel. Override per pool mechanism: an audit pool reads "Community-funded audit" / "Pledge" / "View audit report"; a feature-funding pool reads "Community-funded feature" / "Back" / "View deliverable".

statusLabels maps each Status to its status-pill text.

defaultLabels : Labels

Generic defaults. Caller overrides any field with mechanism-specific copy (e.g. forge.intrepiddev uses audit-pool framing on top of this).

{ target : String
, balance : String
, unit : String
, deadline : String
, pledgerCount : Int
, topPledgers : List Pledger
, status : Status
, reportUrl : Maybe String
}
-> Pool

Construct a Pool. Progress is derived from target+balance by parsing both decimal strings into scaled integers and dividing in BigInt space, so a pool denominated in wei-sized numbers is placed as accurately as one denominated in whole units. Unparseable input reads as 0. The result clamps to [0, 100].