1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

Merge pull request #14837 from MetaMask/prop-type-fixups

Prop type fixups
This commit is contained in:
Zachary Belford 2022-06-10 12:36:31 -07:00 committed by GitHub
commit 7dc6a5feaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 62 additions and 24 deletions

View File

@ -124,12 +124,12 @@ AdvancedGasControls.propTypes = {
gasEstimateType: PropTypes.oneOf(Object.values(GAS_ESTIMATE_TYPES)),
setMaxPriorityFee: PropTypes.func,
setMaxFee: PropTypes.func,
maxPriorityFee: PropTypes.number,
maxFee: PropTypes.number,
maxPriorityFee: PropTypes.string,
maxFee: PropTypes.string,
onManualChange: PropTypes.func,
gasLimit: PropTypes.number,
setGasLimit: PropTypes.func,
gasPrice: PropTypes.number,
gasPrice: PropTypes.string,
setGasPrice: PropTypes.func,
maxPriorityFeeFiat: PropTypes.string,
maxFeeFiat: PropTypes.string,

View File

@ -217,8 +217,8 @@ export default function EditGasDisplay({
hasGasErrors === false &&
supportsEIP1559 && (
<GasTiming
maxFeePerGas={maxFeePerGas}
maxPriorityFeePerGas={maxPriorityFeePerGas}
maxFeePerGas={maxFeePerGas.toString()}
maxPriorityFeePerGas={maxPriorityFeePerGas.toString()}
gasWarnings={gasWarnings}
/>
)

View File

@ -90,8 +90,8 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
}
subTitle={
<GasTiming
maxPriorityFeePerGas={maxPriorityFeePerGas}
maxFeePerGas={maxFeePerGas}
maxPriorityFeePerGas={maxPriorityFeePerGas.toString()}
maxFeePerGas={maxFeePerGas.toString()}
/>
}
/>

View File

@ -43,7 +43,7 @@ const NicknamePopovers = ({ address, onClose }) => {
<UpdateNicknamePopover
address={address}
nickname={recipientNickname || null}
memo={addressBookEntryObject?.memo}
memo={addressBookEntryObject?.memo || null}
onClose={() => setPopoverToDisplay(SHOW_NICKNAME_POPOVER)}
onAdd={(recipient, nickname, memo) =>
dispatch(addToAddressBook(recipient, nickname, memo))

View File

@ -185,7 +185,7 @@ export default function TransactionDecoding({ to = '', inputData: data = '' }) {
</details>
</li>
) : (
<li className="solidity-value">
<li className="solidity-value" key={`solidity-value-${index}`}>
<div className="solidity-named-item solidity-item">
{typeClass !== 'array' && !Array.isArray(value) ? (
<span className="param-name typography--color-black">{name}: </span>
@ -239,6 +239,6 @@ export default function TransactionDecoding({ to = '', inputData: data = '' }) {
}
TransactionDecoding.propTypes = {
to: PropTypes.string.isRequired,
to: PropTypes.string,
inputData: PropTypes.string.isRequired,
};

View File

@ -12,16 +12,18 @@ import Identicon from '../identicon/identicon.component';
import { getUseTokenDetection, getTokenList } from '../../../selectors';
export default function UpdateNicknamePopover({
nickname,
address,
nickname = '',
memo = '',
onAdd,
memo,
onClose,
}) {
const t = useContext(I18nContext);
const [nicknameInput, setNicknameInput] = useState(nickname);
const [memoInput, setMemoInput] = useState(memo);
const [nicknameInput, setNicknameInput] = useState(
nickname === null ? '' : nickname,
);
const [memoInput, setMemoInput] = useState(memo === null ? '' : memo);
const handleNicknameChange = (event) => {
setNicknameInput(event.target.value);

View File

@ -124,4 +124,3 @@ input.form-control {
* {
font-family: $font-family;
}

View File

@ -85,14 +85,39 @@ const AssetOptions = ({
);
};
const isNotFunc = (p) => {
return typeof p !== 'function';
};
AssetOptions.propTypes = {
isEthNetwork: PropTypes.bool,
isNativeAsset: PropTypes.bool,
onRemove: PropTypes.func.isRequired,
onClickBlockExplorer: PropTypes.func.isRequired,
onViewAccountDetails: PropTypes.func.isRequired,
onViewTokenDetails: PropTypes.func.isRequired,
tokenSymbol: PropTypes.string,
onRemove: (props) => {
if (props.isNativeAsset === false && isNotFunc(props.onRemove)) {
throw new Error(
'When isNativeAsset is true, onRemove is a required prop',
);
}
},
onViewTokenDetails: (props) => {
if (props.isNativeAsset === false && isNotFunc(props.onViewTokenDetails)) {
throw new Error(
'When isNativeAsset is true, onViewTokenDetails is a required prop',
);
}
},
tokenSymbol: (props) => {
if (
props.isNativeAsset === false &&
typeof props.tokenSymbol !== 'string'
) {
throw new Error(
'When isNativeAsset is true, tokenSymbol is a required prop',
);
}
},
};
export default AssetOptions;

View File

@ -417,7 +417,7 @@ export default class ConfirmTransactionBase extends Component {
<div className="custom-nonce-input">
<TextField
type="number"
min="0"
min={0}
placeholder={
typeof nextNonce === 'number' ? nextNonce.toString() : null
}
@ -546,10 +546,10 @@ export default class ConfirmTransactionBase extends Component {
maxPriorityFeePerGas={hexWEIToDecGWEI(
maxPriorityFeePerGas ||
txData.txParams.maxPriorityFeePerGas,
)}
).toString()}
maxFeePerGas={hexWEIToDecGWEI(
maxFeePerGas || txData.txParams.maxFeePerGas,
)}
).toString()}
/>
)}
</>

View File

@ -123,7 +123,16 @@ export default class Home extends PureComponent {
showRecoveryPhraseReminder: PropTypes.bool.isRequired,
setRecoveryPhraseReminderHasBeenShown: PropTypes.func.isRequired,
setRecoveryPhraseReminderLastShown: PropTypes.func.isRequired,
seedPhraseBackedUp: PropTypes.bool.isRequired,
seedPhraseBackedUp: (props) => {
if (
props.seedPhraseBackedUp !== null &&
typeof props.seedPhraseBackedUp !== 'boolean'
) {
throw new Error(
`seedPhraseBackedUp is required to be null or boolean. Received ${props.seedPhraseBackedUp}`,
);
}
},
newNetworkAdded: PropTypes.string,
setNewNetworkAdded: PropTypes.func.isRequired,
// This prop is used in the `shouldCloseNotificationPopup` function

View File

@ -342,7 +342,10 @@ class SettingsPage extends PureComponent {
path={ADD_NETWORK_ROUTE}
render={() => <NetworksTab addNewNetwork />}
/>
<Route path={NETWORKS_ROUTE} component={NetworksTab} />
<Route
path={NETWORKS_ROUTE}
render={() => <NetworksTab addNewNetwork={false} />}
/>
<Route exact path={SECURITY_ROUTE} component={SecurityTab} />
<Route exact path={EXPERIMENTAL_ROUTE} component={ExperimentalTab} />
<Route exact path={CONTACT_LIST_ROUTE} component={ContactListTab} />