@@ -5,24 +5,30 @@
55import { BRIDGE_ERROR } from '../lib/error'
66
77function needWeb3(obj) {
8− return obj.web3.matchWith({
9− Nothing: () => { throw BRIDGE_ERROR.MISSING_WEB3 },
10− Just: w => w.value
11− });
8+ return ('web3' in obj === false)
9+ ? (() => { throw BRIDGE_ERROR.MISSING_WEB3 })()
10+ : obj.web3.matchWith({
11+ Nothing: () => { throw BRIDGE_ERROR.MISSING_WEB3 },
12+ Just: w => w.value
13+ });
1214}
1315
1416function needContracts(obj) {
15− return obj.contracts.matchWith({
16− Nothing: () => { throw BRIDGE_ERROR.MISSING_CONTRACTS },
17− Just: c => c.value
18− });
17+ return ('contracts' in obj === false)
18+ ? (() => { throw BRIDGE_ERROR.MISSING_CONTRACTS })()
19+ : obj.contracts.matchWith({
20+ Nothing: () => { throw BRIDGE_ERROR.MISSING_CONTRACTS },
21+ Just: c => c.value
22+ });
1923}
2024
2125function needWallet(obj) {
22− return obj.wallet.matchWith({
23− Nothing: () => { throw BRIDGE_ERROR.MISSING_WALLET },
24− Just: w => w.value
25− });
26+ return ('wallet' in obj === false)
27+ ? (() => { throw BRIDGE_ERROR.MISSING_WALLET })()
28+ : obj.wallet.matchWith({
29+ Nothing: () => { throw BRIDGE_ERROR.MISSING_WALLET },
30+ Just: w => w.value
31+ });
2632}
2733
2834function needAddress(obj) {
@@ -30,16 +36,20 @@ function needAddress(obj) {
3036}
3137
3238function needPointCursor(obj) {
33− return obj.pointCursor.matchWith({
34− Nothing: () => { throw BRIDGE_ERROR.MISSING_POINT },
35− Just: p => p.value
36− });
39+ return ('pointCursor' in obj === false)
40+ ? (() => { throw BRIDGE_ERROR.MISSING_POINT })()
41+ : obj.pointCursor.matchWith({
42+ Nothing: () => { throw BRIDGE_ERROR.MISSING_POINT },
43+ Just: p => p.value
44+ });
3745}
3846
3947function needFromPointCache(obj, point) {
40− return point in obj.pointCache
41− ? obj.pointCache[point]
42− : (() => { throw BRIDGE_ERROR.MISSING_POINT })()
48+ return ('pointCache' in obj === false)
49+ ? (() => { throw BRIDGE_ERROR.MISSING_POINT })()
50+ : point in obj.pointCache
51+ ? obj.pointCache[point]
52+ : (() => { throw BRIDGE_ERROR.MISSING_POINT })()
4353}
4454
4555export {