Top-level module that composes wallet and transaction state.
This module bundles Web3.Wallet.State and a list of named Web3.Transaction.Status
values into a single Model. Wire it into your app's model/update/subscriptions
to get wallet connection, chain validation, and transaction tracking with a single
port pair.
port web3Cmd : Json.Encode.Value -> Cmd msg
port web3Sub : (Json.Decode.Value -> msg) -> Sub msg
type alias Model =
{ web3 : Web3.Model
, ...
}
type Msg
= Web3Msg Web3.Msg
| ...
init : ( Model, Cmd Msg )
init =
( { web3 = Web3.init (Web3.Types.chainId 369), ... }, Cmd.none )
update msg model =
case msg of
Web3Msg subMsg ->
( { model | web3 = Web3.update subMsg model.web3 }, Cmd.none )
subscriptions model =
web3Sub (Json.Decode.decodeValue Web3.Wallet.decoder
>> Result.map Web3.WalletMsg
>> Result.withDefault (Web3Msg (Web3.WalletMsg Web3.Wallet.WalletDisconnected))
)For individual modules without the combined wrapper, import Web3.Wallet,
Web3.Transaction, Web3.Balance, Web3.Block, etc. directly.
Messages for wallet and transaction updates.
Placeholder for port subscriptions. Wire your port decoder here.
Encode a TxCmd (e.g. RequestReceipt) for sending via your port.
web3Cmd (Web3.encodeTxCmd (Tx.RequestReceipt hash "my-id"))
Combined wallet + transaction state.