quietgarden/elm-web3/1.0.0

NOTE: the latest version is 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 1.0.0 found (5 same-name repos checked); no cached copy. Use another version.

Details

Web3.Wallet

Wallet connection state machine.

The wallet is modeled as an explicit state — you can't accidentally call a contract without a connected wallet because the compiler won't give you an Address from a Disconnected state.

case model.wallet of
    Connected info ->
        -- info.address is available here
        buy info.address amount


    _ ->
        -- can't buy, no address to use
        showConnectButton
type State
= Disconnected
| Connecting
| Connected ConnectedInfo
| WrongChain ConnectedInfo ChainId
| Error String

Wallet connection state. Every possible state is explicit.

type Msg
= WalletConnected String Int
| WalletDisconnected
| ChainChanged Int
| AccountChanged String
| WalletError String
| WalletsDiscovered (List WalletProvider)

Messages from the JS wallet port.

= RequestConnect
| RequestDisconnect
| RequestSwitchChain Int
| RequestSelectWallet String

Commands to send to JS via port.

type alias WalletProvider =
{ name : String
, icon : String
, rdns : String
}

A wallet provider discovered via EIP-6963.

Update wallet state from a port message.

Command to request wallet connection.

Command to request wallet disconnection.

Command to switch chain.

Command to select a specific wallet by its RDNS identifier (EIP-6963).

selectWallet "io.metamask"
isConnected : State -> Bool

True if the wallet is in the Connected state.

Extract the connected address, if any.

Extract the connected chain ID, if any.

encode : WalletCmd -> Value

Encode a WalletCmd for the JS port.

decoder : Decoder Msg

Decode a Msg from the JS wallet port.