cmditch/elm-ethereum/3.0.0

NOTE: the latest version is 5.0.0

Eth.Sentry.Tx

Core

type TxSentry msg
type Msg
update : Msg -> TxSentry msg -> ( TxSentry msg, Cmd msg )
init : ( OutPort, InPort ) -> (Msg -> msg) -> HttpProvider -> TxSentry msg
type alias OutPort =
Value -> Cmd Msg

The txOut port. Where information from your elm app is sent OUT to javascript land. Used for sending Send Tx parameters to Metamask, or other wallets.

port txOut : Value -> Cmd msg
type alias InPort =
(Value -> Msg) -> Sub Msg

The txIn subscription. Where information from the outside comes IN to your elm app. Used for getting the TxHash response from Metamask, or other wallets.

 port txIn : (Value -> msg) -> Sub msg
listen : TxSentry msg -> Sub msg

Send Txs

(Result String Tx -> msg)
-> TxSentry msg
-> Send
-> ( TxSentry msg, Cmd msg )
(Result String Tx -> msg)
-> (Result String TxReceipt -> msg)
-> TxSentry msg
-> Send
-> ( TxSentry msg, Cmd msg )

Custom Send

type alias CustomSend msg =
{ onSign : Maybe (Result String TxHash -> msg)
, onBroadcast : Maybe (Result String Tx -> msg)
, onMined :
Maybe
( Result String TxReceipt -> msg
, Maybe
{ confirmations : Int
, toMsg : TxTracker -> msg
}
)
}
onSign : Message after metamask/wallet has signed tx and returned tx hash
onBroadcast : Message after tx is confirmed sitting in tx queue on the node
onMined : ( message after tx is mined,
            (number of blocks deep to watch tx, message on each mined block after tx is sent - stops sending messages when first tuple value is reached)
          )
type alias TxTracker =
{ currentDepth : Int
, minedInBlock : Int
, stopWatchingAtBlock : Int
, lastCheckedBlock : Int
, txHash : TxHash
, doneWatching : Bool
, reOrg : Bool
}

For checking whether a tx has reached a certain block depth (# of confirmations) in a customSend

customSend : TxSentry msg -> CustomSend msg -> Send -> ( TxSentry msg, Cmd msg )

Utils

changeNode : HttpProvider -> TxSentry msg -> TxSentry msg

Look into the errors this might cause, some kind of cleanup process should probably occur on changing a node.