Skip to content

Commit

Permalink
fix: display error for transactions with invalid callbackUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Haynes committed Feb 28, 2022
1 parent f8417ca commit 9e073ec
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 2 deletions.
43 changes: 43 additions & 0 deletions packages/frontend/src/components/sign/SignTransferInvalid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import { Translate } from 'react-localize-redux';
import styled from 'styled-components';

import Container from '../common/styled/Container.css';

const CustomContainer = styled(Container)`
display: flex;
flex-direction: column;
align-items: center;
color: #25282a;
text-align: center;
.title {
margin-top: 23px;
h2 {
font-weight: 900;
font-size: 22px;
color: #24272a;
}
}
&& .text {
color: #72727a;
margin-top: 24px;
}
`;

const SignTransferInvalid = () => (
<CustomContainer className="small-centered">
<div className="title">
<h2>
<Translate id="sign.invalidTransaction.title" />
</h2>
</div>
<div className="text">
<Translate id="sign.invalidTransaction.body" />
</div>
</CustomContainer>
);

export default SignTransferInvalid;
8 changes: 8 additions & 0 deletions packages/frontend/src/routes/SignWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useState, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';

import SignTransferAccountNotFound from '../components/sign/SignTransferAccountNotFound';
import SignTransferInvalid from '../components/sign/SignTransferInvalid';
import SignTransferRetry from '../components/sign/SignTransferRetry';
import SignTransactionDetailsWrapper from '../components/sign/v2/SignTransactionDetailsWrapper';
import SignTransactionSummaryWrapper from '../components/sign/v2/SignTransactionSummaryWrapper';
Expand Down Expand Up @@ -122,6 +123,13 @@ export function SignWrapper() {
}
};

// potentially malicious callback URL found
if (!isValidCallbackUrl) {
return (
<SignTransferInvalid />
);
}

if (currentDisplay === DISPLAY.INSUFFICIENT_NETWORK_FEE) {
return (
<SignTransferRetry
Expand Down
8 changes: 6 additions & 2 deletions packages/frontend/src/translations/en.global.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@
},
"verifyPassphrase": {
"desc": "Enter an existing passphrase below to secure your new account.",
"passPhrasePlaceholder": "bubble word sun join impact exist ramp skull title hollow symbol very",
"tite": "Verify Your Passphrase",
"yourPassphrase": "Your Passphrase",
"passPhrasePlaceholder": "bubble word sun join impact exist ramp skull title hollow symbol very"
"yourPassphrase": "Your Passphrase"
}
},
"step": "Step ${step}/${total}",
Expand Down Expand Up @@ -1180,6 +1180,10 @@
"hereAreSomeDetails": "Here are some details that will help you.",
"insufficientFunds": "Insufficient Funds",
"insufficientFundsDesc": "You do not have enough available NEAR to complete this transaction.",
"invalidTransaction": {
"body": "The request is invalid and cannot be signed.",
"title": "Invalid Transaction"
},
"isRequesting": {
"authorization": "is requesting authorization",
"transferOf": "is requesting the transfer of"
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/translations/pt.global.json
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,10 @@
},
"hereAreSomeDetails": "Aqui estão alguns detalhes que ajudarão você.",
"insufficientFunds": "Fundos insuficientes",
"invalidTransaction": {
"body": "The request is invalid and cannot be signed.",
"title": "Invalid Transaction"
},
"isRequesting": {
"authorization": "está solicitando autorização",
"transferOf": "está solicitando a transferência de"
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/translations/ru.global.json
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,10 @@
},
"hereAreSomeDetails": "Вот некоторые детали, которые помогут вам.",
"insufficientFunds": "Недостаточно средств",
"invalidTransaction": {
"body": "The request is invalid and cannot be signed.",
"title": "Invalid Transaction"
},
"isRequesting": {
"authorization": "запрашивает разрешение",
"transferOf": "запрашивает перевод"
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/translations/vi.global.json
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,10 @@
},
"hereAreSomeDetails": "Dưới đây là một số chi tiết sẽ hỗ trợ bạn.",
"insufficientFunds": "Không đủ tiền",
"invalidTransaction": {
"body": "The request is invalid and cannot be signed.",
"title": "Invalid Transaction"
},
"isRequesting": {
"authorization": "đang yêu cầu ủy quyền",
"transferOf": "đang yêu cầu chuyển"
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/translations/zh-hans.global.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"hereAreSomeDetails": "这里是能够帮助你的一些信息。",
"insufficientFunds": "资产不足",
"insufficientFundsDesc": "你没有足够的可用 NEAR 完成该操作。",
"invalidTransaction": {
"body": "The request is invalid and cannot be signed.",
"title": "Invalid Transaction"
},
"isRequesting": {
"authorization": "正在请求授权",
"transferOf": "正在请求转账"
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/translations/zh-hant.global.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"hereAreSomeDetails": "這裏是能夠幫助你的一些信息。",
"insufficientFunds": "資產不足",
"insufficientFundsDesc": "你沒有足夠的可用 NEAR 完成該操作。",
"invalidTransaction": {
"body": "The request is invalid and cannot be signed.",
"title": "Invalid Transaction"
},
"isRequesting": {
"authorization": "正在請求授權",
"transferOf": "正在請求轉賬"
Expand Down

0 comments on commit 9e073ec

Please sign in to comment.