@@ -20,6 +20,7 @@ import { useCheckBalance } from '../../hooks/useCheckBalance'
20
20
import { useGetSubscanLinks } from '../../hooks/useSubscanLink'
21
21
import FromCallData from '../EasySetup/FromCallData'
22
22
import { ModalCloseButton } from '../library/ModalCloseButton'
23
+ import { formatBnBalance } from '../../utils/formatBnBalance'
23
24
24
25
const SEND_TOKEN_MENU = 'Send tokens'
25
26
const FROM_CALL_DATA_MENU = 'From call data'
@@ -34,11 +35,11 @@ interface Props {
34
35
35
36
const Send = ( { onClose, className, onSuccess, onFinalized } : Props ) => {
36
37
const { getSubscanExtrinsicLink } = useGetSubscanLinks ( )
37
- const { api, isApiReady } = useApi ( )
38
+ const { api, isApiReady, chainInfo } = useApi ( )
38
39
const [ isSubmitting , setIsSubmitting ] = useState ( false )
39
40
const { selectedMultiProxy, getMultisigAsAccountBaseInfo, getMultisigByAddress } = useMultiProxy ( )
40
41
const { selectedAccount, selectedSigner } = useAccounts ( )
41
- const [ easyOptionErrorMessage , setEasyOptionErrorMessageorMessage ] = useState ( '' )
42
+ const [ easyOptionErrorMessage , setEasyOptionErrorMessage ] = useState ( '' )
42
43
const [ errorMessage , setErrorMessage ] = useState ( '' )
43
44
const { addToast } = useToasts ( )
44
45
const possibleOrigin = useMemo ( ( ) => {
@@ -123,7 +124,7 @@ const Send = ({ onClose, className, onSuccess, onFinalized }: Props) => {
123
124
threshold
124
125
] )
125
126
126
- const { multisigProposalNeededFunds } = useMultisigProposalNeededFunds ( {
127
+ const { multisigProposalNeededFunds, reserved } = useMultisigProposalNeededFunds ( {
127
128
threshold,
128
129
signatories : selectedMultisig ?. signatories ,
129
130
call : multisigTx
@@ -135,11 +136,20 @@ const Send = ({ onClose, className, onSuccess, onFinalized }: Props) => {
135
136
136
137
useEffect ( ( ) => {
137
138
if ( ! multisigProposalNeededFunds . isZero ( ) && ! hasSignerEnoughFunds ) {
139
+ const requiredBalanceString = formatBnBalance (
140
+ multisigProposalNeededFunds ,
141
+ chainInfo ?. tokenDecimals ,
142
+ { tokenSymbol : chainInfo ?. tokenSymbol }
143
+ )
144
+
145
+ const reservedString = formatBnBalance ( reserved , chainInfo ?. tokenDecimals , {
146
+ tokenSymbol : chainInfo ?. tokenSymbol
147
+ } )
138
148
setErrorMessage (
139
- `The "Signing with" account doesn't have enough funds to submit this transaction`
149
+ `The "Signing with" account doesn't have the required ${ requiredBalanceString } to submit this transaction. Note that it includes ${ reservedString } that will be reserved and returned upon tx approval/cancellation `
140
150
)
141
151
}
142
- } , [ hasSignerEnoughFunds , multisigProposalNeededFunds ] )
152
+ } , [ chainInfo , reserved , hasSignerEnoughFunds , multisigProposalNeededFunds ] )
143
153
144
154
const onSubmitting = useCallback ( ( ) => {
145
155
setIsSubmitting ( false )
@@ -163,20 +173,20 @@ const Send = ({ onClose, className, onSuccess, onFinalized }: Props) => {
163
173
< BalancesTransfer
164
174
from = { selectedOrigin . address }
165
175
onSetExtrinsic = { setExtrinsicToCall }
166
- onSetErrorMessage = { setEasyOptionErrorMessageorMessage }
176
+ onSetErrorMessage = { setEasyOptionErrorMessage }
167
177
/>
168
178
) ,
169
179
[ MANUEL_EXTRINSIC_MENU ] : (
170
180
< ManualExtrinsic
171
181
onSetExtrinsic = { setExtrinsicToCall }
172
- onSetErrorMessage = { setEasyOptionErrorMessageorMessage }
182
+ onSetErrorMessage = { setEasyOptionErrorMessage }
173
183
onSelectFromCallData = { ( ) => setSelectedEasyOption ( FROM_CALL_DATA_MENU ) }
174
184
/>
175
185
) ,
176
186
[ FROM_CALL_DATA_MENU ] : (
177
187
< FromCallData
178
188
onSetExtrinsic = { setExtrinsicToCall }
179
- onSetErrorMessage = { setEasyOptionErrorMessageorMessage }
189
+ onSetErrorMessage = { setEasyOptionErrorMessage }
180
190
isProxySelected = { ! ! isProxySelected }
181
191
/>
182
192
)
@@ -257,6 +267,8 @@ const Send = ({ onClose, className, onSuccess, onFinalized }: Props) => {
257
267
] )
258
268
259
269
const onChangeEasySetupOption = useCallback ( ( event : SelectChangeEvent < string > ) => {
270
+ setErrorMessage ( '' )
271
+ setEasyOptionErrorMessage ( '' )
260
272
setSelectedEasyOption ( event . target . value )
261
273
} , [ ] )
262
274
0 commit comments