Skip to content

Commit

Permalink
Merge pull request #69 from burnable-tech/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
coinop-logan authored Aug 15, 2019
2 parents 1c6e6f3 + 55aafc2 commit 777f522
Show file tree
Hide file tree
Showing 44 changed files with 2,620 additions and 2,230 deletions.
24 changes: 12 additions & 12 deletions assets/static/networkChangeNotifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ var commonModule = (function () {
pub.startWatching = function (_notifyPort, _web3) {
notifyPort = _notifyPort;
web3 = _web3;
setInterval(checkNetworkId, 100);
// setInterval(checkNetworkId, 100);
}

var checkNetworkId = function () {
web3.version.getNetwork(function (e, networkId) {
if (e) {
console.log("error with web3.version.getNetwork: ", e);
}
else if (networkId != lastNetworkId) {
notifyPort.send(parseInt(networkId));
lastNetworkId = networkId;
}
});
}
// var checkNetworkId = function () {
// web3.version.getNetwork(function (e, networkId) {
// if (e) {
// console.log("error with web3.version.getNetwork: ", e);
// }
// else if (networkId != lastNetworkId) {
// notifyPort.send(parseInt(networkId));
// lastNetworkId = networkId;
// }
// });
// }

return pub;
})();
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@

<body>
<div id='elm'></div>
<script type="text/javascript" src="/DAIHard/static/js/main-30b6f9d20a094e02ae79.js"></script></body>
<script type="text/javascript" src="/DAIHard/static/js/main-eba4ac68919b2838e7f6.js"></script></body>

</html>
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@

<body>
<div id='elm'></div>
<script type="text/javascript" src="/DAIHard/static/js/main-30b6f9d20a094e02ae79.js"></script></body>
<script type="text/javascript" src="/DAIHard/static/js/main-eba4ac68919b2838e7f6.js"></script></body>

</html>
7 changes: 0 additions & 7 deletions docs/static/js/main-30b6f9d20a094e02ae79.js

This file was deleted.

7 changes: 7 additions & 0 deletions docs/static/js/main-eba4ac68919b2838e7f6.js

Large diffs are not rendered by default.

77 changes: 45 additions & 32 deletions src/AgentHistory/State.elm
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module AgentHistory.State exposing (init, subscriptions, update, updateUserInfo, updateWeb3Context)
module AgentHistory.State exposing (init, subscriptions, update, updateWalletState)

import AgentHistory.Types exposing (..)
import AppCmd
import Array exposing (Array)
import BigInt exposing (BigInt)
import ChainCmd exposing (ChainCmd)
import CommonTypes exposing (..)
import Config exposing (..)
import Contracts.Generated.DAIHardTrade as DHT
Expand All @@ -13,9 +14,10 @@ import Eth
import Eth.Sentry.Event as EventSentry exposing (EventSentry)
import Eth.Types exposing (Address)
import FiatValue exposing (FiatValue)
import Filters.State as Filters
import Filters.Types as Filter
import Flip exposing (flip)
import Helpers.BigInt as BigIntHelpers
import Helpers.ChainCmd as ChainCmd exposing (ChainCmd)
import Helpers.Eth as EthHelpers
import Helpers.Time as TimeHelpers
import PaymentMethods exposing (PaymentMethod)
Expand All @@ -25,15 +27,24 @@ import Time
import TokenValue exposing (TokenValue)
import TradeCache.State as TradeCache
import TradeCache.Types as TradeCache exposing (TradeCache)
import TradeTable.State as TradeTable
import TradeTable.Types as TradeTable
import Wallet


init : EthHelpers.Web3Context -> Address -> BuyerOrSeller -> Maybe UserInfo -> ( Model, Cmd Msg )
init web3Context agentAddress agentRole maybeUserInfo =
( { web3Context = web3Context
init : Wallet.State -> Address -> ( Model, Cmd Msg )
init wallet agentAddress =
( { wallet = wallet
, agentAddress = agentAddress
, agentRole = agentRole
, userInfo = maybeUserInfo
, viewPhase = CTypes.Open
, filters =
Filters.init
[ Filter.phases True True True False
, Filter.offerType True True
, Filter.role agentAddress True True
]
, tradeTable =
TradeTable.init
( TradeTable.Phase, TradeTable.Ascending )
}
, Cmd.none
)
Expand All @@ -42,20 +53,6 @@ init web3Context agentAddress agentRole maybeUserInfo =
update : Msg -> Model -> UpdateResult
update msg prevModel =
case msg of
ViewUserRoleChanged role ->
UpdateResult
prevModel
Cmd.none
ChainCmd.none
[ AppCmd.GotoRoute (Routing.AgentHistory prevModel.agentAddress role) ]

ViewPhaseChanged phase ->
UpdateResult
{ prevModel | viewPhase = phase }
Cmd.none
ChainCmd.none
[]

Poke address ->
let
txParams =
Expand All @@ -80,12 +77,33 @@ update msg prevModel =
chainCmd
[]

TradeClicked id ->
TradeClicked factory id ->
UpdateResult
prevModel
Cmd.none
ChainCmd.none
[ AppCmd.GotoRoute (Routing.Trade id) ]
[ AppCmd.GotoRoute (Routing.Trade factory id) ]

FiltersMsg filtersMsg ->
justModelUpdate
{ prevModel
| filters =
prevModel.filters |> Filters.update filtersMsg
}

TradeTableMsg tradeTableMsg ->
let
ttUpdateResult =
prevModel.tradeTable
|> TradeTable.update tradeTableMsg
in
UpdateResult
{ prevModel
| tradeTable = ttUpdateResult.model
}
(Cmd.map TradeTableMsg ttUpdateResult.cmd)
(ChainCmd.map TradeTableMsg ttUpdateResult.chainCmd)
(List.map (AppCmd.map TradeTableMsg) ttUpdateResult.appCmds)

NoOp ->
noUpdate prevModel
Expand All @@ -100,14 +118,9 @@ noUpdate model =
[]


updateUserInfo : Maybe UserInfo -> Model -> Model
updateUserInfo userInfo model =
{ model | userInfo = userInfo }


updateWeb3Context : EthHelpers.Web3Context -> Model -> Model
updateWeb3Context newWeb3Context model =
{ model | web3Context = newWeb3Context }
updateWalletState : Wallet.State -> Model -> Model
updateWalletState wallet model =
{ model | wallet = wallet }


subscriptions : Model -> Sub Msg
Expand Down
34 changes: 23 additions & 11 deletions src/AgentHistory/Types.elm
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
module AgentHistory.Types exposing (Model, Msg(..), UpdateResult)
module AgentHistory.Types exposing (Model, Msg(..), UpdateResult, justModelUpdate)

import AppCmd exposing (AppCmd)
import Array exposing (Array)
import BigInt exposing (BigInt)
import ChainCmd exposing (ChainCmd)
import CommonTypes exposing (..)
import Contracts.Types as CTypes
import Dict exposing (Dict)
import Eth.Net
import Eth.Sentry.Event as EventSentry exposing (EventSentry)
import Eth.Types exposing (Address)
import FiatValue exposing (FiatValue)
import Helpers.ChainCmd as ChainCmd exposing (ChainCmd)
import Helpers.Eth as EthHelpers exposing (Web3Context)
import Filters.Types as Filters
import Helpers.Eth as EthHelpers
import Http
import Json.Decode
import PaymentMethods exposing (PaymentMethod)
Expand All @@ -19,22 +21,23 @@ import String.Extra
import Time
import TokenValue exposing (TokenValue)
import TradeCache.Types as TradeCache exposing (TradeCache)
import TradeTable.Types as TradeTable
import Wallet


type alias Model =
{ web3Context : Web3Context
{ wallet : Wallet.State
, agentAddress : Address
, agentRole : BuyerOrSeller
, userInfo : Maybe UserInfo
, viewPhase : CTypes.Phase
, filters : Filters.Model
, tradeTable : TradeTable.Model
}


type Msg
= ViewUserRoleChanged BuyerOrSeller
| ViewPhaseChanged CTypes.Phase
| Poke Address
| TradeClicked Int
= Poke Address
| TradeClicked FactoryType Int
| FiltersMsg Filters.Msg
| TradeTableMsg TradeTable.Msg
| NoOp


Expand All @@ -44,3 +47,12 @@ type alias UpdateResult =
, chainCmd : ChainCmd Msg
, appCmds : List (AppCmd Msg)
}


justModelUpdate : Model -> UpdateResult
justModelUpdate model =
UpdateResult
model
Cmd.none
ChainCmd.none
[]
Loading

0 comments on commit 777f522

Please sign in to comment.