This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

ElmArk.Signature

Handles building requests for the signature endpoints and encoding/decoding their json.

Models

type alias SignatureFee = { success : Bool , fee : Int }

SignatureFee represents the JSON returned by getSignatureFee Sample JSON:

{
    "success": true,
    "fee": 500000000
}

Requests

getSignatureFee : RequestHead -> ( RequestHead, RequestBody )

Get the current fee for generating a signature

mainNet
    |> getPeers

JSON

decodeSignatureFee : Json.Decode.Decoder SignatureFee

Parse JSON into SignatureFee record

encodeSignatureFee : SignatureFee -> Json.Encode.Value

Turn SignatureFee record into JSON

module ElmArk.Signature exposing (..)

{-| Handles building requests for the signature endpoints
and encoding/decoding their json.


# Models

@docs SignatureFee


# Requests

@docs getSignatureFee


# JSON

@docs decodeSignatureFee, encodeSignatureFee

-}

import ElmArk.Api.Model exposing (RequestBody(..), RequestHead)
import Json.Encode
import Json.Decode
import Json.Decode.Pipeline


{-| Get the current fee for generating a signature

    mainNet
        |> getPeers

-}
getSignatureFee : RequestHead -> ( RequestHead, RequestBody )
getSignatureFee heads =
    ( heads, GetRequest (heads.url ++ "api/signatures/fee") [] )


{-| SignatureFee represents the JSON returned by getSignatureFee
Sample JSON:

    {
        "success": true,
        "fee": 500000000
    }

-}
type alias SignatureFee =
    { success : Bool
    , fee : Int
    }


{-| Parse JSON into SignatureFee record
-}
decodeSignatureFee : Json.Decode.Decoder SignatureFee
decodeSignatureFee =
    Json.Decode.Pipeline.decode SignatureFee
        |> Json.Decode.Pipeline.required "success" (Json.Decode.bool)
        |> Json.Decode.Pipeline.required "fee" (Json.Decode.int)


{-| Turn SignatureFee record into JSON
-}
encodeSignatureFee : SignatureFee -> Json.Encode.Value
encodeSignatureFee record =
    Json.Encode.object
        [ ( "success", Json.Encode.bool <| record.success )
        , ( "fee", Json.Encode.int <| record.fee )
        ]