fix: handle invalid transaction ids correctly
This commit is contained in:
parent
32c136c167
commit
a3139033b6
5 changed files with 113 additions and 73 deletions
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.2.0.1]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- When the input to the transaction search is invalid, the error is handled properly.
|
||||||
|
|
||||||
## [0.2.0.0]
|
## [0.2.0.0]
|
||||||
|
|
||||||
- Implemented routing
|
- Implemented routing
|
||||||
|
|
123
dev/app.js
123
dev/app.js
|
@ -10929,7 +10929,7 @@
|
||||||
return new Search(ev);
|
return new Search(ev);
|
||||||
})])([p_([input([css("input"), value14(state3.term), placeholder("Search TX ID..."), onValueInput(function(str) {
|
})])([p_([input([css("input"), value14(state3.term), placeholder("Search TX ID..."), onValueInput(function(str) {
|
||||||
return new SetTerm(str);
|
return new SetTerm(str);
|
||||||
})]), button([css("btn-primary raised"), type_19(ButtonSubmit.value)])([i([css("ri-search-line ri-xl")])([])])])]), table([css("footer")])([tr_([td([css("footer")])([p_([text("Made with "), a([href("https://www.purescript.org/")])([text("PureScript")])])]), td([css("footer")])([p_([i([css("ri-copyright-line")])([]), text("2024 Vergara Technologies LLC")])]), td([css("footer")])([p([])([text("Network: "), text(show13(state3.network)), br_, text("Version: "), text(state3.version), br_, text("Zebra Node: "), text(state3.zebra)])])])])]);
|
})]), button([css("btn-primary raised"), type_19(ButtonSubmit.value)])([i([css("ri-search-line ri-xl")])([])])])]), table([css("footer")])([tr_([td([css("footer")])([p_([text("Made with "), a([href("https://www.purescript.org/")])([text("PureScript")])])]), td([css("footer")])([p_([i([css("ri-copyright-line")])([]), text("2024 Vergara Technologies LLC")])]), td([css("footer")])([p([])([text("Network: "), text(show13(state3.network)), br_, text("Server: "), text(state3.version), br_, text("UI: 0.1.0.1"), br_, text("Zebra Node: "), text(state3.zebra)])])])])]);
|
||||||
};
|
};
|
||||||
var handleAction = function(dictMonadAff) {
|
var handleAction = function(dictMonadAff) {
|
||||||
var monadAffHalogenM2 = monadAffHalogenM(dictMonadAff);
|
var monadAffHalogenM2 = monadAffHalogenM(dictMonadAff);
|
||||||
|
@ -11018,10 +11018,10 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
throw new Error("Failed pattern match at Exblo.Home (line 146, column 9 - line 154, column 61): " + [v1.constructor.name]);
|
throw new Error("Failed pattern match at Exblo.Home (line 148, column 9 - line 156, column 61): " + [v1.constructor.name]);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
throw new Error("Failed pattern match at Exblo.Home (line 142, column 5 - line 154, column 61): " + [res.constructor.name]);
|
throw new Error("Failed pattern match at Exblo.Home (line 144, column 5 - line 156, column 61): " + [res.constructor.name]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -11068,7 +11068,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
throw new Error("Failed pattern match at Exblo.Home (line 133, column 16 - line 162, column 23): " + [v.constructor.name]);
|
throw new Error("Failed pattern match at Exblo.Home (line 135, column 16 - line 164, column 23): " + [v.constructor.name]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -11292,7 +11292,9 @@
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
if (state3.tx instanceof Failure) {
|
if (state3.tx instanceof Failure) {
|
||||||
return p_([text(state3.tx.value0)]);
|
return div2([css("card")])([p_([text(state3.tx.value0)]), button([css("btn-primary raised"), onClick(function(ev) {
|
||||||
|
return new Close(ev);
|
||||||
|
})])([i([css("ri-arrow-go-back-fill ri-lg")])([]), text("Back")])]);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
if (state3.tx instanceof Success2) {
|
if (state3.tx instanceof Success2) {
|
||||||
|
@ -11306,7 +11308,7 @@
|
||||||
return tr_([th_([text("orchard")]), table_([tr_([th_([text("actions")]), td_([text(show5(length(v.value0.actions)))])]), tr_([th_([text("value")]), td_([text(show5(v.value0.value))])])])]);
|
return tr_([th_([text("orchard")]), table_([tr_([th_([text("actions")]), td_([text(show5(length(v.value0.actions)))])]), tr_([th_([text("value")]), td_([text(show5(v.value0.value))])])])]);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
throw new Error("Failed pattern match at Exblo.Tx (line 78, column 19 - line 93, column 26): " + [v.constructor.name]);
|
throw new Error("Failed pattern match at Exblo.Tx (line 90, column 19 - line 105, column 26): " + [v.constructor.name]);
|
||||||
}(), function() {
|
}(), function() {
|
||||||
var v = toMaybe(state3.tx.value0.sapling);
|
var v = toMaybe(state3.tx.value0.sapling);
|
||||||
if (v instanceof Nothing) {
|
if (v instanceof Nothing) {
|
||||||
|
@ -11317,7 +11319,7 @@
|
||||||
return tr_([th_([text("sapling")]), table_([tr_([th_([text("spends")]), td_([text(show5(length(v.value0.spends)))])]), tr_([th_([text("outputs")]), td_([text(show5(length(v.value0.outputs)))])]), tr_([th_([text("value")]), td_([text(show5(v.value0.value))])])])]);
|
return tr_([th_([text("sapling")]), table_([tr_([th_([text("spends")]), td_([text(show5(length(v.value0.spends)))])]), tr_([th_([text("outputs")]), td_([text(show5(length(v.value0.outputs)))])]), tr_([th_([text("value")]), td_([text(show5(v.value0.value))])])])]);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
throw new Error("Failed pattern match at Exblo.Tx (line 94, column 19 - line 113, column 26): " + [v.constructor.name]);
|
throw new Error("Failed pattern match at Exblo.Tx (line 106, column 19 - line 125, column 26): " + [v.constructor.name]);
|
||||||
}(), function() {
|
}(), function() {
|
||||||
var v = toMaybe(state3.tx.value0.transparent);
|
var v = toMaybe(state3.tx.value0.transparent);
|
||||||
if (v instanceof Nothing) {
|
if (v instanceof Nothing) {
|
||||||
|
@ -11338,13 +11340,13 @@
|
||||||
})(0)(v.value0.vout)))])])])]);
|
})(0)(v.value0.vout)))])])])]);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
throw new Error("Failed pattern match at Exblo.Tx (line 114, column 19 - line 137, column 26): " + [v.constructor.name]);
|
throw new Error("Failed pattern match at Exblo.Tx (line 126, column 19 - line 149, column 26): " + [v.constructor.name]);
|
||||||
}()]), button([css("btn-primary raised"), onClick(function(ev) {
|
}()]), button([css("btn-primary raised"), onClick(function(ev) {
|
||||||
return new Close(ev);
|
return new Close(ev);
|
||||||
})])([i([css("ri-arrow-go-back-fill ri-lg")])([]), text("Back")])]);
|
})])([i([css("ri-arrow-go-back-fill ri-lg")])([]), text("Back")])]);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
throw new Error("Failed pattern match at Exblo.Tx (line 65, column 7 - line 146, column 14): " + [state3.tx.constructor.name]);
|
throw new Error("Failed pattern match at Exblo.Tx (line 66, column 7 - line 158, column 14): " + [state3.tx.constructor.name]);
|
||||||
}(), p_([i([css("ri-copyright-line")])([]), text("2024 Vergara Technologies LLC")])]);
|
}(), p_([i([css("ri-copyright-line")])([]), text("2024 Vergara Technologies LLC")])]);
|
||||||
};
|
};
|
||||||
var handleAction2 = function(dictMonadAff) {
|
var handleAction2 = function(dictMonadAff) {
|
||||||
|
@ -11354,16 +11356,16 @@
|
||||||
return function(v) {
|
return function(v) {
|
||||||
if (v instanceof Initialize4) {
|
if (v instanceof Initialize4) {
|
||||||
return discard4(modify_5(function(v1) {
|
return discard4(modify_5(function(v1) {
|
||||||
var $297 = {};
|
var $298 = {};
|
||||||
for (var $298 in v1) {
|
for (var $299 in v1) {
|
||||||
if ({}.hasOwnProperty.call(v1, $298)) {
|
if ({}.hasOwnProperty.call(v1, $299)) {
|
||||||
$297[$298] = v1[$298];
|
$298[$299] = v1[$299];
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
$297.tx = Loading2.value;
|
$298.tx = Loading2.value;
|
||||||
return $297;
|
return $298;
|
||||||
}))(function() {
|
}))(function() {
|
||||||
return bind9(gets4(function(v1) {
|
return bind9(gets4(function(v1) {
|
||||||
return v1.hex;
|
return v1.hex;
|
||||||
|
@ -11371,55 +11373,70 @@
|
||||||
return bind9(liftAff2(get4(string)("https://api.exblo.app/gettransaction/" + term)))(function(res) {
|
return bind9(liftAff2(get4(string)("https://api.exblo.app/gettransaction/" + term)))(function(res) {
|
||||||
if (res instanceof Left) {
|
if (res instanceof Left) {
|
||||||
return modify_5(function(v12) {
|
return modify_5(function(v12) {
|
||||||
var $301 = {};
|
var $302 = {};
|
||||||
for (var $302 in v12) {
|
for (var $303 in v12) {
|
||||||
if ({}.hasOwnProperty.call(v12, $302)) {
|
if ({}.hasOwnProperty.call(v12, $303)) {
|
||||||
$301[$302] = v12[$302];
|
$302[$303] = v12[$303];
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
$301.tx = new Failure(printError(res.value0));
|
$302.tx = new Failure(printError(res.value0));
|
||||||
return $301;
|
return $302;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
if (res instanceof Right) {
|
if (res instanceof Right) {
|
||||||
|
if (res.value0.status === 200) {
|
||||||
var v1 = readJSON3(res.value0.body);
|
var v1 = readJSON3(res.value0.body);
|
||||||
if (v1 instanceof Right) {
|
if (v1 instanceof Right) {
|
||||||
return modify_5(function(v2) {
|
return modify_5(function(v2) {
|
||||||
var $306 = {};
|
var $308 = {};
|
||||||
for (var $307 in v2) {
|
for (var $309 in v2) {
|
||||||
if ({}.hasOwnProperty.call(v2, $307)) {
|
if ({}.hasOwnProperty.call(v2, $309)) {
|
||||||
$306[$307] = v2[$307];
|
$308[$309] = v2[$309];
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
$306.tx = new Success2(v1.value0);
|
$308.tx = new Success2(v1.value0);
|
||||||
return $306;
|
return $308;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
if (v1 instanceof Left) {
|
if (v1 instanceof Left) {
|
||||||
return modify_5(function(v2) {
|
return modify_5(function(v2) {
|
||||||
var $310 = {};
|
var $312 = {};
|
||||||
for (var $311 in v2) {
|
for (var $313 in v2) {
|
||||||
if ({}.hasOwnProperty.call(v2, $311)) {
|
if ({}.hasOwnProperty.call(v2, $313)) {
|
||||||
$310[$311] = v2[$311];
|
$312[$313] = v2[$313];
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
$310.tx = new Failure(show14(v1.value0));
|
$312.tx = new Failure(show14(v1.value0));
|
||||||
return $310;
|
return $312;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
throw new Error("Failed pattern match at Exblo.Tx (line 164, column 12 - line 167, column 63): " + [v1.constructor.name]);
|
throw new Error("Failed pattern match at Exblo.Tx (line 178, column 18 - line 181, column 69): " + [v1.constructor.name]);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
throw new Error("Failed pattern match at Exblo.Tx (line 160, column 5 - line 167, column 63): " + [res.constructor.name]);
|
return modify_5(function(v12) {
|
||||||
|
var $316 = {};
|
||||||
|
for (var $317 in v12) {
|
||||||
|
if ({}.hasOwnProperty.call(v12, $317)) {
|
||||||
|
$316[$317] = v12[$317];
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
$316.tx = new Failure("Invalid transaction identifier");
|
||||||
|
return $316;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
;
|
||||||
|
throw new Error("Failed pattern match at Exblo.Tx (line 172, column 5 - line 182, column 85): " + [res.constructor.name]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -11427,36 +11444,36 @@
|
||||||
;
|
;
|
||||||
if (v instanceof Receive4) {
|
if (v instanceof Receive4) {
|
||||||
return bind9(get5)(function(st) {
|
return bind9(get5)(function(st) {
|
||||||
var $315 = st.hex !== v.value0.input;
|
var $320 = st.hex !== v.value0.input;
|
||||||
if ($315) {
|
if ($320) {
|
||||||
return discard4(modify_5(function(v1) {
|
return discard4(modify_5(function(v1) {
|
||||||
var $316 = {};
|
var $321 = {};
|
||||||
for (var $317 in v1) {
|
for (var $322 in v1) {
|
||||||
if ({}.hasOwnProperty.call(v1, $317)) {
|
if ({}.hasOwnProperty.call(v1, $322)) {
|
||||||
$316[$317] = v1[$317];
|
$321[$322] = v1[$322];
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
$316.hex = v.value0.input;
|
$321.hex = v.value0.input;
|
||||||
$316.network = v.value0.context;
|
$321.network = v.value0.context;
|
||||||
return $316;
|
return $321;
|
||||||
}))(function() {
|
}))(function() {
|
||||||
return handleAction2(dictMonadAff)(dictNavigate)(Initialize4.value);
|
return handleAction2(dictMonadAff)(dictNavigate)(Initialize4.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
return modify_5(function(v1) {
|
return modify_5(function(v1) {
|
||||||
var $319 = {};
|
var $324 = {};
|
||||||
for (var $320 in v1) {
|
for (var $325 in v1) {
|
||||||
if ({}.hasOwnProperty.call(v1, $320)) {
|
if ({}.hasOwnProperty.call(v1, $325)) {
|
||||||
$319[$320] = v1[$320];
|
$324[$325] = v1[$325];
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
$319.network = v.value0.context;
|
$324.network = v.value0.context;
|
||||||
return $319;
|
return $324;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -11465,7 +11482,7 @@
|
||||||
return navigate2(Home.value);
|
return navigate2(Home.value);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
throw new Error("Failed pattern match at Exblo.Tx (line 155, column 16 - line 175, column 27): " + [v.constructor.name]);
|
throw new Error("Failed pattern match at Exblo.Tx (line 167, column 16 - line 190, column 27): " + [v.constructor.name]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -11491,8 +11508,8 @@
|
||||||
handleQuery: defaultEval.handleQuery,
|
handleQuery: defaultEval.handleQuery,
|
||||||
finalize: defaultEval.finalize,
|
finalize: defaultEval.finalize,
|
||||||
handleAction: handleAction1(dictNavigate),
|
handleAction: handleAction1(dictNavigate),
|
||||||
receive: function($329) {
|
receive: function($334) {
|
||||||
return Just.create(Receive4.create($329));
|
return Just.create(Receive4.create($334));
|
||||||
},
|
},
|
||||||
initialize: new Just(Initialize4.value)
|
initialize: new Just(Initialize4.value)
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,6 +11,6 @@
|
||||||
"bundle": "spago bundle-app --to dev/app.js",
|
"bundle": "spago bundle-app --to dev/app.js",
|
||||||
"test": "spago test",
|
"test": "spago test",
|
||||||
"serve": "spago build && parcel serve --open --no-cache --dist-dir dist/ dev/index.html",
|
"serve": "spago build && parcel serve --open --no-cache --dist-dir dist/ dev/index.html",
|
||||||
"build-prod": "rm -rf dist && mkdir -p dist && cp dev/index.html dist/ && spago bundle-app --to dist/app.js && parcel build dist/index.html"
|
"build-prod": "rm -rf dist && mkdir -p dist && cp dev/index.html dist/ && cp dev/*.css dist/ && cp -r dev/fonts dist/ && spago bundle-app --to dist/app.js && parcel build dist/index.html"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,9 +118,11 @@ render state =
|
||||||
[ HH.text "Network: "
|
[ HH.text "Network: "
|
||||||
, HH.text $ show state.network
|
, HH.text $ show state.network
|
||||||
, HH.br_
|
, HH.br_
|
||||||
, HH.text "Version: "
|
, HH.text "Server: "
|
||||||
, HH.text state.version
|
, HH.text state.version
|
||||||
, HH.br_
|
, HH.br_
|
||||||
|
, HH.text "UI: 0.2.0.1"
|
||||||
|
, HH.br_
|
||||||
, HH.text "Zebra Node: "
|
, HH.text "Zebra Node: "
|
||||||
, HH.text state.zebra
|
, HH.text state.zebra
|
||||||
]
|
]
|
||||||
|
|
|
@ -3,6 +3,7 @@ module Exblo.Tx where
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Simple.JSON (readJSON)
|
import Simple.JSON (readJSON)
|
||||||
|
import Affjax.StatusCode (StatusCode(..))
|
||||||
import Affjax.Web as AX
|
import Affjax.Web as AX
|
||||||
import Affjax.ResponseFormat as AXRF
|
import Affjax.ResponseFormat as AXRF
|
||||||
import Data.Array (length, foldl)
|
import Data.Array (length, foldl)
|
||||||
|
@ -65,7 +66,18 @@ render state =
|
||||||
, case state.tx of
|
, case state.tx of
|
||||||
NotAsked -> HH.p_ [ HH.text "Explore the Zcash blockchain" ]
|
NotAsked -> HH.p_ [ HH.text "Explore the Zcash blockchain" ]
|
||||||
Loading -> HH.p_ [ HH.text "Processing Zebra response..." ]
|
Loading -> HH.p_ [ HH.text "Processing Zebra response..." ]
|
||||||
Failure e -> HH.p_ [ HH.text e ]
|
Failure e ->
|
||||||
|
HH.div
|
||||||
|
[ css "card" ]
|
||||||
|
[ HH.p_ [ HH.text e ]
|
||||||
|
, HH.button
|
||||||
|
[ css "btn-primary raised"
|
||||||
|
, HE.onClick \ev -> Close ev
|
||||||
|
]
|
||||||
|
[ HH.i [ css "ri-arrow-go-back-fill ri-lg" ] []
|
||||||
|
, HH.text "Back"
|
||||||
|
]
|
||||||
|
]
|
||||||
Success t ->
|
Success t ->
|
||||||
HH.div
|
HH.div
|
||||||
[ css "card" ]
|
[ css "card" ]
|
||||||
|
@ -161,10 +173,13 @@ handleAction = case _ of
|
||||||
Left err -> do
|
Left err -> do
|
||||||
H.modify_ _ { tx = Failure $ AX.printError err }
|
H.modify_ _ { tx = Failure $ AX.printError err }
|
||||||
Right response -> do
|
Right response -> do
|
||||||
|
case response.status of
|
||||||
|
StatusCode 200 -> do
|
||||||
case readJSON response.body of
|
case readJSON response.body of
|
||||||
Right (t :: Transaction) ->
|
Right (t :: Transaction) ->
|
||||||
H.modify_ _ { tx = Success t}
|
H.modify_ _ { tx = Success t}
|
||||||
Left e -> H.modify_ _ { tx = Failure $ show e }
|
Left e -> H.modify_ _ { tx = Failure $ show e }
|
||||||
|
_any -> H.modify_ _ { tx = Failure "Invalid transaction identifier" }
|
||||||
Receive {context: network, input: hex } -> do
|
Receive {context: network, input: hex } -> do
|
||||||
st <- H.get
|
st <- H.get
|
||||||
if (st.hex /= hex) then do
|
if (st.hex /= hex) then do
|
||||||
|
|
Loading…
Reference in a new issue