quietgarden/elm-web3/2.0.1

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/quietgarden/elm-web3 is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 2.0.1 found (5 same-name repos checked); no cached copy. Use another version.

Details

Web3.Balance

Typed balance query with correlation IDs.

This module provides a dedicated, typed interface for querying native ETH/PLS balances. Multiple queries can be in flight simultaneously — each carries a correlation id that is echoed back so responses can be matched.

-- Send via your port:
web3Cmd (Web3.Balance.encode (Web3.Balance.getBalance address "my-id"))


-- Receive via your port:
case D.decodeValue Web3.Balance.decoder incoming of
    Ok (Web3.Balance.GotBalance id wei) ->
        -- id matches the one you sent; wei is the amount
    Err _ ->
        -- not a balance response
type Cmd

A pending balance request. Carry the address and a correlation id.

type Msg
= GotBalance String Wei

A resolved balance response. Contains the correlation id and the amount in wei.

getBalance : Address -> String -> Cmd

Build a balance query for address, tagged with id.

encode : Cmd -> Value

Encode a Cmd for the JS port.

Produces {tag:'getBalance', address, id}.

decoder : Decoder Msg

Decode a {tag:'balance', id, wei} response from the JS port.