This repository was archived by the owner on Feb 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +41
-3
lines changed Expand file tree Collapse file tree 4 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ const botInitialized = bot => bot && bot.tradeEngine.options;
17
17
const botStarted = bot => botInitialized ( bot ) && bot . tradeEngine . tradeOptions ;
18
18
const shouldRestartOnError = ( bot , errorName = '' ) =>
19
19
! unrecoverableErrors . includes ( errorName ) && botInitialized ( bot ) && bot . tradeEngine . options . shouldRestartOnError ;
20
+
21
+ const shouldStopOnError = ( bot , errorName = '' ) => {
22
+ const stopErrors = [ 'SellNotAvailable' ] ;
23
+ if ( stopErrors . includes ( errorName ) && botInitialized ( bot ) ) {
24
+ return true ;
25
+ }
26
+ return false ;
27
+ } ;
28
+
20
29
const timeMachineEnabled = bot => botInitialized ( bot ) && bot . tradeEngine . options . timeMachineEnabled ;
21
30
22
31
export default class Interpreter {
@@ -94,11 +103,20 @@ export default class Interpreter {
94
103
if ( this . stopped ) {
95
104
return ;
96
105
}
106
+
107
+ if ( shouldStopOnError ( this . bot , e . name ) ) {
108
+ globalObserver . emit ( 'ui.log.error' , e . message ) ;
109
+ $ ( '#stopButton' ) . trigger ( 'click' ) ;
110
+ this . stop ( ) ;
111
+ return ;
112
+ }
113
+
97
114
this . isErrorTriggered = true ;
98
115
if ( ! shouldRestartOnError ( this . bot , e . name ) || ! botStarted ( this . bot ) ) {
99
116
reject ( e ) ;
100
117
return ;
101
118
}
119
+
102
120
globalObserver . emit ( 'Error' , e ) ;
103
121
const { initArgs, tradeOptions } = this . bot . tradeEngine ;
104
122
this . terminateSession ( ) ;
Original file line number Diff line number Diff line change @@ -90,13 +90,20 @@ export default Engine =>
90
90
}
91
91
}
92
92
setContractFlags ( contract ) {
93
- const { is_expired : isExpired , is_valid_to_sell : isValidToSell , is_sold : isSold } = contract ;
93
+ const {
94
+ is_expired : isExpired ,
95
+ is_valid_to_sell : isValidToSell ,
96
+ is_sold : isSold ,
97
+ entry_tick : entryTick ,
98
+ } = contract ;
94
99
95
100
this . isSold = Boolean ( isSold ) ;
96
101
97
102
this . isSellAvailable = ! this . isSold && Boolean ( isValidToSell ) ;
98
103
99
104
this . isExpired = Boolean ( isExpired ) ;
105
+
106
+ this . hasEntryTick = Boolean ( entryTick ) ;
100
107
}
101
108
expectedContractId ( contractId ) {
102
109
return this . contractId && contractId === this . contractId ;
Original file line number Diff line number Diff line change @@ -56,8 +56,15 @@ export default Engine =>
56
56
uuid : getUUID ( ) ,
57
57
} ,
58
58
} )
59
+ // eslint-disable-next-line consistent-return
59
60
. catch ( e => {
60
- if ( e . error . error . code === 'ContractBuyValidationError' ) {
61
+ if ( e && e . name === 'RateLimit' ) {
62
+ return Promise . reject ( e ) ;
63
+ }
64
+
65
+ const errorCode = e . error && e . error . error && e . error . error . code ;
66
+
67
+ if ( errorCode === 'ContractBuyValidationError' ) {
61
68
const { uuid } = e . error . echo_req . passthrough ;
62
69
63
70
if ( ! this . data . hasIn ( [ 'forgetProposals' , uuid ] ) ) {
Original file line number Diff line number Diff line change @@ -17,7 +17,13 @@ export default Engine =>
17
17
}
18
18
19
19
if ( ! this . isSellAtMarketAvailable ( ) ) {
20
- throw Error ( translate ( 'Sell is not available' ) ) ;
20
+ if ( this . hasEntryTick ) {
21
+ const error = new Error ( translate ( 'Resale of this contract is not offered.' ) ) ;
22
+ error . name = 'SellNotAvailable' ;
23
+ throw error ;
24
+ } else {
25
+ return Promise . resolve ( ) ;
26
+ }
21
27
}
22
28
23
29
const onSuccess = ( { sell : { sold_for : soldFor } } ) => {
You can’t perform that action at this time.
0 commit comments