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.Contract.Event

Contract event watching via port subscriptions.

-- Subscribe to Transfer events
subscriptions model =
    Event.watchEvent
        { contract = tokenAddress
        , event = "Transfer"
        , filter = []
        }
        |> Event.decoder transferDecoder
        |> onContractEvent TransferReceived
type alias EventFilter =
{ contract : Address
, event : String
, topics : List (Maybe String)
}

An event subscription filter.

type alias EventLog a =
{ data : a
, contract : Address
, topics : List String
, blockNumber : Int
, txHash : TxHash
, logIndex : Int
}

A decoded event log.

type alias GetLogsQuery =
{ contract : Address
, fromBlock : BlockNumber
, toBlock : BlockNumber
, topics : List (Maybe String)
}

A query for getLogs with fromBlock/toBlock range.

watchEvent : EventFilter -> Value

Create an event watch command.

encode : EventFilter -> Value

Encode an event filter for the JS port.

decoder : Decoder a -> Decoder (EventLog a)

Decode a watchEvent log from the JS port.

Requires the message to have tag: "eventLog" — use logsDecoder for the batch getLogs response which wraps logs in an array.

getLogs : GetLogsQuery -> Value

Encode a getLogs query for the JS port.

logsDecoder : Decoder a -> Decoder (List (EventLog a))

Decode a list of event logs with a custom data decoder.

Decodes the { tag: "logs", logs: [...] } response from getLogs.