@@ -15,23 +15,27 @@ import { signatureToVRS, packSignatures } from '../utils/signatures'
1515import { getSuccessExecutionData } from '../utils/getFinalizationEvent'
1616import { TransactionReceipt } from 'web3-eth'
1717
18- const StyledButton = styled . button `
18+ const ActionButton = styled . button `
1919 color: var(--button-color);
2020 border-color: var(--font-color);
2121 margin-top: 10px;
22+ min-width: 120px;
23+ padding: 1rem;
2224 &:focus {
2325 outline: var(--button-color);
2426 }
2527`
2628
2729interface ManualExecutionButtonParams {
30+ safeExecutionAvailable : boolean
2831 messageData : string
2932 setExecutionData : Function
3033 signatureCollected : string [ ]
3134 setPendingExecution : Function
3235}
3336
3437export const ManualExecutionButton = ( {
38+ safeExecutionAvailable,
3539 messageData,
3640 setExecutionData,
3741 signatureCollected,
@@ -40,6 +44,7 @@ export const ManualExecutionButton = ({
4044 const { foreign, setError } = useStateProvider ( )
4145 const { library, activate, account, active } = useWeb3React ( )
4246 const [ manualExecution , setManualExecution ] = useState ( false )
47+ const [ allowFailures , setAllowFailures ] = useState ( false )
4348
4449 useEffect (
4550 ( ) => {
@@ -72,7 +77,11 @@ export const ManualExecutionButton = ({
7277 const signatures = packSignatures ( signatureCollected . map ( signatureToVRS ) )
7378 const messageId = messageData . slice ( 0 , 66 )
7479 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 ( )
7685 setManualExecution ( false )
7786
7887 library . eth
@@ -132,15 +141,35 @@ export const ManualExecutionButton = ({
132141 messageData ,
133142 signatureCollected ,
134143 setExecutionData ,
135- setPendingExecution
144+ setPendingExecution ,
145+ safeExecutionAvailable ,
146+ allowFailures
136147 ]
137148 )
138149
139150 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+ ) }
144173 </ div >
145174 )
146175}
0 commit comments