diff --git a/daedalus/src/Daedalus/BackendApi.purs b/daedalus/src/Daedalus/BackendApi.purs index f253290f826..67761fa50dd 100644 --- a/daedalus/src/Daedalus/BackendApi.purs +++ b/daedalus/src/Daedalus/BackendApi.purs @@ -214,8 +214,11 @@ getHistory tls walletId accountId addr skip limit = nextUpdate :: forall eff. TLSOptions -> Aff (http :: HTTP, exception :: EXCEPTION | eff) CUpdateInfo nextUpdate tls = getR tls $ noQueryParam ["update"] +postponeUpdate :: forall eff. TLSOptions -> Aff (http :: HTTP, exception :: EXCEPTION | eff) Unit +postponeUpdate tls = postR tls $ noQueryParam ["update", "postpone"] + applyUpdate :: forall eff. TLSOptions -> Aff (http :: HTTP, exception :: EXCEPTION | eff) Unit -applyUpdate tls = postR tls $ noQueryParam ["update"] +applyUpdate tls = postR tls $ noQueryParam ["update", "apply"] -------------------------------------------------------------------------------- -- Redemptions ----------------------------------------------------------------- diff --git a/daedalus/src/Daedalus/ClientApi.purs b/daedalus/src/Daedalus/ClientApi.purs index 6f043ffceeb..a24ecc5a275 100644 --- a/daedalus/src/Daedalus/ClientApi.purs +++ b/daedalus/src/Daedalus/ClientApi.purs @@ -724,6 +724,15 @@ getAddressHistory = mkEffFn5 \tls acId address skip limit -> fromAff <<< map enc nextUpdate :: forall eff. EffFn1 (http :: HTTP, exception :: EXCEPTION | eff) TLSOptions (Promise Json) nextUpdate = mkEffFn1 $ fromAff <<< map encodeJson <<< B.nextUpdate +-- Example in nodejs: +-- | ```js +-- | > api.postponeUpdate().then(console.log).catch(console.log) +-- | Promise { } +-- | > {} +-- | ``` +postponeUpdate :: forall eff. EffFn1 (http :: HTTP, exception :: EXCEPTION | eff) TLSOptions (Promise Unit) +postponeUpdate = mkEffFn1 $ fromAff <<< B.postponeUpdate + -- Example in nodejs: -- | ```js -- | > api.applyUpdate().then(console.log).catch(console.log) diff --git a/pkgs/default.nix b/pkgs/default.nix index 092edf2dbb1..4017c6036fa 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4445,6 +4445,8 @@ self: { pname = "memory"; version = "0.14.6"; sha256 = "0q61zxdlgcw7wg244hb3c11qm5agrmnmln0h61sz2mj72xqc1pn7"; + revision = "1"; + editedCabalFile = "0pyzdy5ca1cbkjzy1scnz6mr9251ap4w8a5phzxp91wkxpc45538"; libraryHaskellDepends = [ base bytestring diff --git a/wallet/src/Pos/Wallet/Web/Api.hs b/wallet/src/Pos/Wallet/Web/Api.hs index 9b9f132a653..a2eb0ba76d9 100644 --- a/wallet/src/Pos/Wallet/Web/Api.hs +++ b/wallet/src/Pos/Wallet/Web/Api.hs @@ -44,6 +44,7 @@ module Pos.Wallet.Web.Api , GetHistory , NextUpdate + , PostponeUpdate , ApplyUpdate , RedeemADA @@ -274,8 +275,14 @@ type NextUpdate = "update" :> WRes Get CUpdateInfo +type PostponeUpdate = + "update" + :> "postpone" + :> WRes Post () + type ApplyUpdate = "update" + :> "apply" :> WRes Post () ------------------------------------------------------------------------- @@ -420,6 +427,8 @@ type WalletApi = ApiPrefix :> ( -- Updates ------------------------------------------------------------------------- NextUpdate + :<|> + PostponeUpdate :<|> ApplyUpdate :<|> diff --git a/wallet/src/Pos/Wallet/Web/Methods/Misc.hs b/wallet/src/Pos/Wallet/Web/Methods/Misc.hs index aa519a0bf8c..908c461c6f5 100644 --- a/wallet/src/Pos/Wallet/Web/Methods/Misc.hs +++ b/wallet/src/Pos/Wallet/Web/Methods/Misc.hs @@ -9,6 +9,7 @@ module Pos.Wallet.Web.Methods.Misc , isValidAddress , nextUpdate + , postponeUpdate , applyUpdate , syncProgress @@ -25,7 +26,7 @@ import Pos.Util (maybeThrow) import Pos.Wallet.KeyStorage (deleteSecretKey, getSecretKeys) import Pos.Wallet.WalletMode (applyLastUpdate, connectedPeers, localChainDifficulty, networkChainDifficulty) -import Pos.Wallet.Web.ClientTypes (CProfile, CProfile (..), CUpdateInfo (..), +import Pos.Wallet.Web.ClientTypes (CProfile (..), CUpdateInfo (..), SyncProgress (..)) import Pos.Wallet.Web.Error (WalletError (..)) import Pos.Wallet.Web.Mode (MonadWalletWebMode) @@ -61,6 +62,11 @@ nextUpdate :: MonadWalletWebMode m => m CUpdateInfo nextUpdate = getNextUpdate >>= maybeThrow (RequestError "No updates available") +-- | Postpone next update after restart +postponeUpdate :: MonadWalletWebMode m => m () +postponeUpdate = removeNextUpdate + +-- | Delete next update info and restart immediately applyUpdate :: MonadWalletWebMode m => m () applyUpdate = removeNextUpdate >> applyLastUpdate diff --git a/wallet/src/Pos/Wallet/Web/Server/Handlers.hs b/wallet/src/Pos/Wallet/Web/Server/Handlers.hs index 2ff112aaa61..9f70fa76aaf 100644 --- a/wallet/src/Pos/Wallet/Web/Server/Handlers.hs +++ b/wallet/src/Pos/Wallet/Web/Server/Handlers.hs @@ -76,6 +76,8 @@ servantHandlers sendActions = :<|> M.nextUpdate + :<|> + M.postponeUpdate :<|> M.applyUpdate :<|> diff --git a/wallet/src/Pos/Wallet/Web/Swagger/Description.hs b/wallet/src/Pos/Wallet/Web/Swagger/Description.hs index 3f23d5f680f..65316b9f822 100644 --- a/wallet/src/Pos/Wallet/Web/Swagger/Description.hs +++ b/wallet/src/Pos/Wallet/Web/Swagger/Description.hs @@ -143,6 +143,10 @@ instance HasCustomSwagger NextUpdate where swaggerModifier = modifyDescription "Get information about the next update." +instance HasCustomSwagger PostponeUpdate where + swaggerModifier = modifyDescription + "Postpone last update." + instance HasCustomSwagger ApplyUpdate where swaggerModifier = modifyDescription "Apply last update."