Skip to content

Commit

Permalink
Added token standard condition
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsekulic committed Sep 8, 2022
1 parent 4b3fa0b commit b6c4124
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ describe('Confirm Page Container Container Test', () => {
toAddress: '0x7a1A4Ad9cc746a70ee58568466f7996dD0aCE4E8',
origin: 'testOrigin', // required
onNextTx: sinon.spy(),
txTokenAddress: '0x114352b0e1bf40f0b6aae8de4c974250de938c82',
getTokenStandardAndDetails: () => {
return {
standard: 'ERC721',
};
},
// Footer
onCancelAll: sinon.spy(),
onCancel: sinon.spy(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
export default class ConfirmPageContainer extends Component {
state = {
showNicknamePopovers: false,
tokenStandard: '',
};

static contextTypes = {
Expand All @@ -56,8 +55,7 @@ export default class ConfirmPageContainer extends Component {
hideSenderToRecipient: PropTypes.bool,
showAccountInHeader: PropTypes.bool,
accountBalance: PropTypes.string,
txTokenAddress: PropTypes.string,
getTokenStandardAndDetails: PropTypes.func,
assetStandard: PropTypes.string,
// Sender to Recipient
fromAddress: PropTypes.string,
fromName: PropTypes.string,
Expand Down Expand Up @@ -107,13 +105,6 @@ export default class ConfirmPageContainer extends Component {
isBuyableChain: PropTypes.bool,
};

async componentDidMount() {
const { standard } = await this.props.getTokenStandardAndDetails(
this.props.txTokenAddress,
);
this.setState({ tokenStandard: standard });
}

render() {
const {
showEdit,
Expand Down Expand Up @@ -169,6 +160,7 @@ export default class ConfirmPageContainer extends Component {
isBuyableChain,
networkIdentifier,
accountBalance,
assetStandard,
} = this.props;

const showAddToAddressDialog =
Expand Down Expand Up @@ -209,7 +201,7 @@ export default class ConfirmPageContainer extends Component {
ofText={ofText}
requestsWaitingText={requestsWaitingText}
/>
{this.state.tokenStandard === ERC721 &&
{assetStandard === ERC721 &&
(isSetApproveForAll || isSetNftApprove) ? (
<NetworkAccountBalanceHeader
accountName={fromName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getNetworkIdentifier,
getSwapsDefaultToken,
} from '../../../selectors';
import { getTokenStandardAndDetails, showModal } from '../../../store/actions';
import { showModal } from '../../../store/actions';
import ConfirmPageContainer from './confirm-page-container.component';

function mapStateToProps(state, ownProps) {
Expand All @@ -16,7 +16,6 @@ function mapStateToProps(state, ownProps) {
const networkIdentifier = getNetworkIdentifier(state);
const defaultToken = getSwapsDefaultToken(state);
const accountBalance = defaultToken.string;
const txTokenAddress = ownProps.currentTransaction.txParams.to;

return {
isBuyableChain,
Expand All @@ -28,15 +27,12 @@ function mapStateToProps(state, ownProps) {
to,
networkIdentifier,
accountBalance,
txTokenAddress,
};
}

const mapDispatchToProps = (dispatch) => {
return {
showBuyModal: () => dispatch(showModal({ name: 'DEPOSIT_ETHER' })),
getTokenStandardAndDetails: async (tokenAddress) =>
await getTokenStandardAndDetails(tokenAddress),
};
};

Expand Down
1 change: 1 addition & 0 deletions ui/pages/confirm-approve/confirm-approve.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export default function ConfirmApprove({
}
hideSenderToRecipient
customTxParamsData={customData}
assetStandard={assetStandard}
/>
</GasFeeContextProvider>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export default class ConfirmTransactionBase extends Component {
eip1559V2Enabled: PropTypes.bool,
showBuyModal: PropTypes.func,
isBuyableChain: PropTypes.bool,
assetStandard: PropTypes.string,
};

state = {
Expand Down Expand Up @@ -1048,6 +1049,7 @@ export default class ConfirmTransactionBase extends Component {
nativeCurrency,
hardwareWalletRequiresConnection,
image,
assetStandard,
} = this.props;
const {
submitting,
Expand Down Expand Up @@ -1148,6 +1150,7 @@ export default class ConfirmTransactionBase extends Component {
currentTransaction={txData}
supportsEIP1559V2={this.supportsEIP1559V2}
nativeCurrency={nativeCurrency}
assetStandard={assetStandard}
/>
</TransactionModalContextProvider>
);
Expand Down

0 comments on commit b6c4124

Please sign in to comment.