Skip to content

Commit

Permalink
fix: verify signer matches current account before enabling transactio…
Browse files Browse the repository at this point in the history
…n approval button
  • Loading branch information
andy-haynes committed Feb 23, 2022
1 parent e6db0fe commit c18958a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default ({
onClickMoreInformation,
accountUrlReferrer,
submittingTransaction,
isSignerValid,
isValidCallbackUrl
}) => {
const insufficientBalance = availableBalance && transferAmount && new BN(availableBalance).lt(new BN(transferAmount));
Expand Down Expand Up @@ -89,7 +90,7 @@ export default ({
</FormButton>
<FormButton
onClick={onClickApprove}
disabled={submittingTransaction || insufficientBalance || !isValidCallbackUrl}
disabled={submittingTransaction || insufficientBalance || !isValidCallbackUrl || !isSignerValid}
sending={submittingTransaction}
>
<Translate id='button.approve' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default ({
onClickApprove,
submittingTransaction,
signGasFee,
isSignerValid,
isValidCallbackUrl
}) => {

const accountLocalStorageAccountId = useSelector(selectAccountLocalStorageAccountId);
const accountUrlReferrer = useSelector(selectAccountUrlReferrer);
const availableBalance = useSelector(selectAvailableBalance);
Expand All @@ -36,6 +36,7 @@ export default ({
onClickMoreInformation={onClickMoreInformation}
accountUrlReferrer={accountUrlReferrer}
submittingTransaction={submittingTransaction}
isSignerValid={isSignerValid}
isValidCallbackUrl={isValidCallbackUrl}
/>
);
Expand Down
4 changes: 3 additions & 1 deletion packages/frontend/src/routes/SignWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function SignWrapper() {
const signerId = transactions.length && transactions[0].signerId;
const signGasFee = new BN(signFeesGasLimitIncludingGasChanges).div(new BN('1000000000000')).toString();
const submittingTransaction = signStatus === SIGN_STATUS.IN_PROGRESS;
const isSignerValid = accountId === signerId;

useEffect(() => {
if (!transactionBatchisValid) {
Expand All @@ -66,7 +67,7 @@ export function SignWrapper() {

useEffect(() => {
if (
accountId !== signerId &&
!isSignerValid &&
availableAccounts.some(
(accountId) => accountId === signerId
)
Expand Down Expand Up @@ -161,6 +162,7 @@ export function SignWrapper() {
signGasFee={signGasFee}
onClickMoreInformation={() => setCurrentDisplay(DISPLAY.TRANSACTION_DETAILS)}
onClickEditAccount={() => setCurrentDisplay(DISPLAY.ACCOUNT_SELECTION)}
isSignerValid={isSignerValid}
isValidCallbackUrl={isValidCallbackUrl}
/>
);
Expand Down

0 comments on commit c18958a

Please sign in to comment.