@@ -15,23 +15,27 @@ import { signatureToVRS, packSignatures } from '../utils/signatures'
15
15
import { getSuccessExecutionData } from '../utils/getFinalizationEvent'
16
16
import { TransactionReceipt } from 'web3-eth'
17
17
18
- const StyledButton = styled . button `
18
+ const ActionButton = styled . button `
19
19
color: var(--button-color);
20
20
border-color: var(--font-color);
21
21
margin-top: 10px;
22
+ min-width: 120px;
23
+ padding: 1rem;
22
24
&:focus {
23
25
outline: var(--button-color);
24
26
}
25
27
`
26
28
27
29
interface ManualExecutionButtonParams {
30
+ safeExecutionAvailable : boolean
28
31
messageData : string
29
32
setExecutionData : Function
30
33
signatureCollected : string [ ]
31
34
setPendingExecution : Function
32
35
}
33
36
34
37
export const ManualExecutionButton = ( {
38
+ safeExecutionAvailable,
35
39
messageData,
36
40
setExecutionData,
37
41
signatureCollected,
@@ -40,6 +44,7 @@ export const ManualExecutionButton = ({
40
44
const { foreign, setError } = useStateProvider ( )
41
45
const { library, activate, account, active } = useWeb3React ( )
42
46
const [ manualExecution , setManualExecution ] = useState ( false )
47
+ const [ allowFailures , setAllowFailures ] = useState ( false )
43
48
44
49
useEffect (
45
50
( ) => {
@@ -72,7 +77,11 @@ export const ManualExecutionButton = ({
72
77
const signatures = packSignatures ( signatureCollected . map ( signatureToVRS ) )
73
78
const messageId = messageData . slice ( 0 , 66 )
74
79
const bridge = foreign . bridgeContract
75
- const data = bridge . methods . executeSignatures ( messageData , signatures ) . encodeABI ( )
80
+ const executeMethod =
81
+ safeExecutionAvailable && ! allowFailures
82
+ ? bridge . methods . safeExecuteSignaturesWithAutoGasLimit
83
+ : bridge . methods . executeSignatures
84
+ const data = executeMethod ( messageData , signatures ) . encodeABI ( )
76
85
setManualExecution ( false )
77
86
78
87
library . eth
@@ -132,15 +141,35 @@ export const ManualExecutionButton = ({
132
141
messageData ,
133
142
signatureCollected ,
134
143
setExecutionData ,
135
- setPendingExecution
144
+ setPendingExecution ,
145
+ safeExecutionAvailable ,
146
+ allowFailures
136
147
]
137
148
)
138
149
139
150
return (
140
- < div className = "is-center" >
141
- < StyledButton className = "button outline" onClick = { ( ) => setManualExecution ( true ) } >
142
- Execute
143
- </ StyledButton >
151
+ < div >
152
+ < div className = "is-center" >
153
+ < ActionButton className = "button outline" onClick = { ( ) => setManualExecution ( true ) } >
154
+ Execute
155
+ </ ActionButton >
156
+ </ div >
157
+ { safeExecutionAvailable && (
158
+ < div
159
+ title = "Allow executed message to fail and record its failure on-chain without reverting the whole transaction.
160
+ Use fixed gas limit for execution."
161
+ className = "is-center"
162
+ style = { { paddingTop : 10 } }
163
+ >
164
+ < input
165
+ type = "checkbox"
166
+ id = "allow-failures"
167
+ checked = { allowFailures }
168
+ onChange = { e => setAllowFailures ( e . target . checked ) }
169
+ />
170
+ < label htmlFor = "allow-failures" > Unsafe mode</ label >
171
+ </ div >
172
+ ) }
144
173
</ div >
145
174
)
146
175
}
0 commit comments