Skip to content

Commit aa76f84

Browse files
committed
cleanup
1 parent 94c41bc commit aa76f84

File tree

8 files changed

+91
-15
lines changed

8 files changed

+91
-15
lines changed

app/_locales/en/messages.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-summary/confirm-page-container-summary.component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const ConfirmPageContainerSummary = (props) => {
5454
transactionType === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER ||
5555
transactionType === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM ||
5656
transactionType === TRANSACTION_TYPES.TOKEN_METHOD_SAFE_TRANSFER_FROM ||
57-
transactionType === TRANSACTION_TYPES.SET_APPROVAL_FOR_ALL
57+
transactionType === TRANSACTION_TYPES.TOKEN_METHOD_SET_APPROVAL_FOR_ALL
5858
? tokenAddress
5959
: toAddress;
6060
}

ui/helpers/utils/token-util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ export function getTokenValueParam(tokenData = {}) {
151151
return tokenData?.args?._value?.toString();
152152
}
153153

154+
export function getTokenApprovedParam(tokenData = {}) {
155+
return tokenData?.args?._approved;
156+
}
157+
154158
export function getTokenValue(tokenParams = []) {
155159
const valueData = tokenParams.find((param) => param.name === '_value');
156160
return valueData && valueData.value;

ui/helpers/utils/transactions.util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function isTokenMethodAction(type) {
116116
return [
117117
TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER,
118118
TRANSACTION_TYPES.TOKEN_METHOD_APPROVE,
119-
TRANSACTION_TYPES.SET_APPROVAL_FOR_ALL,
119+
TRANSACTION_TYPES.TOKEN_METHOD_SET_APPROVAL_FOR_ALL,
120120
TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM,
121121
TRANSACTION_TYPES.TOKEN_METHOD_SAFE_TRANSFER_FROM,
122122
].includes(type);
@@ -218,7 +218,7 @@ export function getTransactionTypeTitle(t, type, nativeCurrency = 'ETH') {
218218
case TRANSACTION_TYPES.TOKEN_METHOD_APPROVE: {
219219
return t('approve');
220220
}
221-
case TRANSACTION_TYPES.SET_APPROVAL_FOR_ALL: {
221+
case TRANSACTION_TYPES.TOKEN_METHOD_SET_APPROVAL_FOR_ALL: {
222222
return t('setApprovalForAll');
223223
}
224224
case TRANSACTION_TYPES.SIMPLE_SEND: {

ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.js

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export default class ConfirmApproveContent extends Component {
7171
assetName: PropTypes.string,
7272
tokenId: PropTypes.string,
7373
assetStandard: PropTypes.string,
74+
isSetApproveForAll: PropTypes.bool,
75+
setApproveForAllArg: PropTypes.bool,
7476
};
7577

7678
state = {
@@ -184,7 +186,7 @@ export default class ConfirmApproveContent extends Component {
184186

185187
renderERC721OrERC1155PermissionContent() {
186188
const { t } = this.context;
187-
const { origin, toAddress, isContract } = this.props;
189+
const { origin, toAddress, isContract, isSetApproveForAll } = this.props;
188190

189191
const titleTokenDescription = this.getTitleTokenDescription();
190192

@@ -201,6 +203,7 @@ export default class ConfirmApproveContent extends Component {
201203
{t('approvedAsset')}:
202204
</div>
203205
<div className="confirm-approve-content__medium-text">
206+
{isSetApproveForAll ? `${t('allOfYour')} ` : null}
204207
{titleTokenDescription}
205208
</div>
206209
</div>
@@ -299,11 +302,18 @@ export default class ConfirmApproveContent extends Component {
299302

300303
renderDataContent() {
301304
const { t } = this.context;
302-
const { data } = this.props;
305+
const { data, isSetApproveForAll, setApproveForAllArg } = this.props;
303306
return (
304307
<div className="flex-column">
305308
<div className="confirm-approve-content__small-text">
306-
{t('functionApprove')}
309+
{isSetApproveForAll
310+
? t('functionSetApprovalForAll')
311+
: t('functionApprove')}
312+
</div>
313+
<div className="confirm-approve-content__small-text">
314+
{isSetApproveForAll && setApproveForAllArg !== undefined
315+
? `${t('parameters')}: ${setApproveForAllArg}`
316+
: null}
307317
</div>
308318
<div className="confirm-approve-content__small-text confirm-approve-content__data__data-block">
309319
{data}
@@ -509,6 +519,41 @@ export default class ConfirmApproveContent extends Component {
509519
return titleTokenDescription;
510520
}
511521

522+
renderTitle() {
523+
const { t } = this.context;
524+
const { isSetApproveForAll, setApproveForAllArg } = this.props;
525+
const titleTokenDescription = this.getTitleTokenDescription();
526+
527+
let title = t('allowSpendToken', [titleTokenDescription]);
528+
529+
if (isSetApproveForAll) {
530+
title = t('approveAllTokensTitle', [titleTokenDescription]);
531+
if (setApproveForAllArg === false) {
532+
title = t('revokeAllTokensTitle', [titleTokenDescription]);
533+
}
534+
}
535+
return title;
536+
}
537+
538+
renderDescription() {
539+
const { t } = this.context;
540+
const { isContract, isSetApproveForAll, setApproveForAllArg } = this.props;
541+
const grantee = isContract
542+
? t('contract').toLowerCase()
543+
: t('account').toLowerCase();
544+
545+
let description = t('trustSiteApprovePermission', [grantee]);
546+
547+
if (isSetApproveForAll && setApproveForAllArg === false) {
548+
description = t('revokeApproveForAllDescription', [
549+
grantee,
550+
this.getTitleTokenDescription(),
551+
]);
552+
}
553+
554+
return description;
555+
}
556+
512557
render() {
513558
const { t } = this.context;
514559
const {
@@ -534,8 +579,6 @@ export default class ConfirmApproveContent extends Component {
534579
} = this.props;
535580
const { showFullTxDetails } = this.state;
536581

537-
const titleTokenDescription = this.getTitleTokenDescription();
538-
539582
return (
540583
<div
541584
className={classnames('confirm-approve-content', {
@@ -575,14 +618,10 @@ export default class ConfirmApproveContent extends Component {
575618
</Box>
576619
</Box>
577620
<div className="confirm-approve-content__title">
578-
{t('allowSpendToken', [titleTokenDescription])}
621+
{this.renderTitle()}
579622
</div>
580623
<div className="confirm-approve-content__description">
581-
{t('trustSiteApprovePermission', [
582-
isContract
583-
? t('contract').toLowerCase()
584-
: t('account').toLowerCase(),
585-
])}
624+
{this.renderDescription()}
586625
</div>
587626
<Box className="confirm-approve-content__address-display-content">
588627
<Box display={DISPLAY.FLEX}>

ui/pages/confirm-approve/confirm-approve.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {
88
updateCustomNonce,
99
getNextNonce,
1010
} from '../../store/actions';
11-
import { calcTokenAmount } from '../../helpers/utils/token-util';
11+
import {
12+
calcTokenAmount,
13+
getTokenApprovedParam,
14+
} from '../../helpers/utils/token-util';
1215
import { readAddressAsContract } from '../../../shared/modules/contract-utils';
1316
import { GasFeeContextProvider } from '../../contexts/gasFee';
1417
import { TransactionModalContextProvider } from '../../contexts/transaction-modal';
@@ -34,6 +37,7 @@ import EditGasFeePopover from '../../components/app/edit-gas-fee-popover';
3437
import EditGasPopover from '../../components/app/edit-gas-popover/edit-gas-popover.component';
3538
import Loading from '../../components/ui/loading-screen';
3639
import { ERC20, ERC1155, ERC721 } from '../../helpers/constants/common';
40+
import { parseStandardTokenTransactionData } from '../../../shared/modules/transaction.utils';
3741
import { getCustomTxParamsData } from './confirm-approve.util';
3842
import ConfirmApproveContent from './confirm-approve-content';
3943

@@ -57,6 +61,7 @@ export default function ConfirmApprove({
5761
ethTransactionTotal,
5862
fiatTransactionTotal,
5963
hexTransactionTotal,
64+
isSetApproveForAll,
6065
}) {
6166
const dispatch = useDispatch();
6267
const { txParams: { data: transactionData } = {} } = transaction;
@@ -150,6 +155,11 @@ export default function ConfirmApprove({
150155
})
151156
: null;
152157

158+
const parsedTransactionData = parseStandardTokenTransactionData(
159+
transactionData,
160+
);
161+
const setApproveForAllArg = getTokenApprovedParam(parsedTransactionData);
162+
153163
return tokenSymbol === undefined && assetName === undefined ? (
154164
<Loading />
155165
) : (
@@ -162,6 +172,8 @@ export default function ConfirmApprove({
162172
contentComponent={
163173
<TransactionModalContextProvider>
164174
<ConfirmApproveContent
175+
isSetApproveForAll={isSetApproveForAll}
176+
setApproveForAllArg={setApproveForAllArg}
165177
decimals={decimals}
166178
siteImage={siteImage}
167179
setCustomAmount={setCustomPermissionAmount}
@@ -290,4 +302,5 @@ ConfirmApprove.propTypes = {
290302
ethTransactionTotal: PropTypes.string,
291303
fiatTransactionTotal: PropTypes.string,
292304
hexTransactionTotal: PropTypes.string,
305+
isSetApproveForAll: PropTypes.bool,
293306
};

ui/pages/confirm-transaction-base/confirm-transaction-base.component.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ export default class ConfirmTransactionBase extends Component {
338338
};
339339

340340
const hasSimulationError = Boolean(txData.simulationFails);
341+
341342
const renderSimulationFailureWarning =
342343
hasSimulationError && !userAcknowledgedGasMissing;
343344
const networkName = NETWORK_TO_NAME_MAP[txData.chainId];

ui/pages/confirm-transaction/confirm-token-transaction-switch.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export default function ConfirmTokenTransactionSwitch({ transaction }) {
7272
path={`${CONFIRM_TRANSACTION_ROUTE}/:id?${CONFIRM_SET_APPROVAL_FOR_ALL_PATH}`}
7373
render={() => (
7474
<ConfirmApprove
75+
isSetApproveForAll
7576
assetStandard={assetStandard}
7677
assetName={assetName}
7778
userBalance={userBalance}

0 commit comments

Comments
 (0)