mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #14837 from MetaMask/prop-type-fixups
Prop type fixups
This commit is contained in:
commit
7dc6a5feaa
@ -10,7 +10,7 @@
|
|||||||
<body style="width:357px; height:600px;">
|
<body style="width:357px; height:600px;">
|
||||||
<div id="app-content">
|
<div id="app-content">
|
||||||
<img class="loading-logo" src="./images/logo/metamask-fox.svg" alt="" />
|
<img class="loading-logo" src="./images/logo/metamask-fox.svg" alt="" />
|
||||||
<img class="loading-spinner" src="./images/spinner.gif" alt="" />
|
<img class="loading-spinner" src="./images/spinner.gif" alt="" />
|
||||||
</div>
|
</div>
|
||||||
<div id="popover-content"></div>
|
<div id="popover-content"></div>
|
||||||
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
|
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
|
||||||
|
@ -124,12 +124,12 @@ AdvancedGasControls.propTypes = {
|
|||||||
gasEstimateType: PropTypes.oneOf(Object.values(GAS_ESTIMATE_TYPES)),
|
gasEstimateType: PropTypes.oneOf(Object.values(GAS_ESTIMATE_TYPES)),
|
||||||
setMaxPriorityFee: PropTypes.func,
|
setMaxPriorityFee: PropTypes.func,
|
||||||
setMaxFee: PropTypes.func,
|
setMaxFee: PropTypes.func,
|
||||||
maxPriorityFee: PropTypes.number,
|
maxPriorityFee: PropTypes.string,
|
||||||
maxFee: PropTypes.number,
|
maxFee: PropTypes.string,
|
||||||
onManualChange: PropTypes.func,
|
onManualChange: PropTypes.func,
|
||||||
gasLimit: PropTypes.number,
|
gasLimit: PropTypes.number,
|
||||||
setGasLimit: PropTypes.func,
|
setGasLimit: PropTypes.func,
|
||||||
gasPrice: PropTypes.number,
|
gasPrice: PropTypes.string,
|
||||||
setGasPrice: PropTypes.func,
|
setGasPrice: PropTypes.func,
|
||||||
maxPriorityFeeFiat: PropTypes.string,
|
maxPriorityFeeFiat: PropTypes.string,
|
||||||
maxFeeFiat: PropTypes.string,
|
maxFeeFiat: PropTypes.string,
|
||||||
|
@ -217,8 +217,8 @@ export default function EditGasDisplay({
|
|||||||
hasGasErrors === false &&
|
hasGasErrors === false &&
|
||||||
supportsEIP1559 && (
|
supportsEIP1559 && (
|
||||||
<GasTiming
|
<GasTiming
|
||||||
maxFeePerGas={maxFeePerGas}
|
maxFeePerGas={maxFeePerGas.toString()}
|
||||||
maxPriorityFeePerGas={maxPriorityFeePerGas}
|
maxPriorityFeePerGas={maxPriorityFeePerGas.toString()}
|
||||||
gasWarnings={gasWarnings}
|
gasWarnings={gasWarnings}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
@ -90,8 +90,8 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
|
|||||||
}
|
}
|
||||||
subTitle={
|
subTitle={
|
||||||
<GasTiming
|
<GasTiming
|
||||||
maxPriorityFeePerGas={maxPriorityFeePerGas}
|
maxPriorityFeePerGas={maxPriorityFeePerGas.toString()}
|
||||||
maxFeePerGas={maxFeePerGas}
|
maxFeePerGas={maxFeePerGas.toString()}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -43,7 +43,7 @@ const NicknamePopovers = ({ address, onClose }) => {
|
|||||||
<UpdateNicknamePopover
|
<UpdateNicknamePopover
|
||||||
address={address}
|
address={address}
|
||||||
nickname={recipientNickname || null}
|
nickname={recipientNickname || null}
|
||||||
memo={addressBookEntryObject?.memo}
|
memo={addressBookEntryObject?.memo || null}
|
||||||
onClose={() => setPopoverToDisplay(SHOW_NICKNAME_POPOVER)}
|
onClose={() => setPopoverToDisplay(SHOW_NICKNAME_POPOVER)}
|
||||||
onAdd={(recipient, nickname, memo) =>
|
onAdd={(recipient, nickname, memo) =>
|
||||||
dispatch(addToAddressBook(recipient, nickname, memo))
|
dispatch(addToAddressBook(recipient, nickname, memo))
|
||||||
|
@ -185,7 +185,7 @@ export default function TransactionDecoding({ to = '', inputData: data = '' }) {
|
|||||||
</details>
|
</details>
|
||||||
</li>
|
</li>
|
||||||
) : (
|
) : (
|
||||||
<li className="solidity-value">
|
<li className="solidity-value" key={`solidity-value-${index}`}>
|
||||||
<div className="solidity-named-item solidity-item">
|
<div className="solidity-named-item solidity-item">
|
||||||
{typeClass !== 'array' && !Array.isArray(value) ? (
|
{typeClass !== 'array' && !Array.isArray(value) ? (
|
||||||
<span className="param-name typography--color-black">{name}: </span>
|
<span className="param-name typography--color-black">{name}: </span>
|
||||||
@ -239,6 +239,6 @@ export default function TransactionDecoding({ to = '', inputData: data = '' }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TransactionDecoding.propTypes = {
|
TransactionDecoding.propTypes = {
|
||||||
to: PropTypes.string.isRequired,
|
to: PropTypes.string,
|
||||||
inputData: PropTypes.string.isRequired,
|
inputData: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
@ -12,16 +12,18 @@ import Identicon from '../identicon/identicon.component';
|
|||||||
import { getUseTokenDetection, getTokenList } from '../../../selectors';
|
import { getUseTokenDetection, getTokenList } from '../../../selectors';
|
||||||
|
|
||||||
export default function UpdateNicknamePopover({
|
export default function UpdateNicknamePopover({
|
||||||
nickname,
|
|
||||||
address,
|
address,
|
||||||
|
nickname = '',
|
||||||
|
memo = '',
|
||||||
onAdd,
|
onAdd,
|
||||||
memo,
|
|
||||||
onClose,
|
onClose,
|
||||||
}) {
|
}) {
|
||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
|
|
||||||
const [nicknameInput, setNicknameInput] = useState(nickname);
|
const [nicknameInput, setNicknameInput] = useState(
|
||||||
const [memoInput, setMemoInput] = useState(memo);
|
nickname === null ? '' : nickname,
|
||||||
|
);
|
||||||
|
const [memoInput, setMemoInput] = useState(memo === null ? '' : memo);
|
||||||
|
|
||||||
const handleNicknameChange = (event) => {
|
const handleNicknameChange = (event) => {
|
||||||
setNicknameInput(event.target.value);
|
setNicknameInput(event.target.value);
|
||||||
|
@ -124,4 +124,3 @@ input.form-control {
|
|||||||
* {
|
* {
|
||||||
font-family: $font-family;
|
font-family: $font-family;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,14 +85,39 @@ const AssetOptions = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isNotFunc = (p) => {
|
||||||
|
return typeof p !== 'function';
|
||||||
|
};
|
||||||
|
|
||||||
AssetOptions.propTypes = {
|
AssetOptions.propTypes = {
|
||||||
isEthNetwork: PropTypes.bool,
|
isEthNetwork: PropTypes.bool,
|
||||||
isNativeAsset: PropTypes.bool,
|
isNativeAsset: PropTypes.bool,
|
||||||
onRemove: PropTypes.func.isRequired,
|
|
||||||
onClickBlockExplorer: PropTypes.func.isRequired,
|
onClickBlockExplorer: PropTypes.func.isRequired,
|
||||||
onViewAccountDetails: PropTypes.func.isRequired,
|
onViewAccountDetails: PropTypes.func.isRequired,
|
||||||
onViewTokenDetails: PropTypes.func.isRequired,
|
onRemove: (props) => {
|
||||||
tokenSymbol: PropTypes.string,
|
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;
|
export default AssetOptions;
|
||||||
|
@ -417,7 +417,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
<div className="custom-nonce-input">
|
<div className="custom-nonce-input">
|
||||||
<TextField
|
<TextField
|
||||||
type="number"
|
type="number"
|
||||||
min="0"
|
min={0}
|
||||||
placeholder={
|
placeholder={
|
||||||
typeof nextNonce === 'number' ? nextNonce.toString() : null
|
typeof nextNonce === 'number' ? nextNonce.toString() : null
|
||||||
}
|
}
|
||||||
@ -546,10 +546,10 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
maxPriorityFeePerGas={hexWEIToDecGWEI(
|
maxPriorityFeePerGas={hexWEIToDecGWEI(
|
||||||
maxPriorityFeePerGas ||
|
maxPriorityFeePerGas ||
|
||||||
txData.txParams.maxPriorityFeePerGas,
|
txData.txParams.maxPriorityFeePerGas,
|
||||||
)}
|
).toString()}
|
||||||
maxFeePerGas={hexWEIToDecGWEI(
|
maxFeePerGas={hexWEIToDecGWEI(
|
||||||
maxFeePerGas || txData.txParams.maxFeePerGas,
|
maxFeePerGas || txData.txParams.maxFeePerGas,
|
||||||
)}
|
).toString()}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -123,7 +123,16 @@ export default class Home extends PureComponent {
|
|||||||
showRecoveryPhraseReminder: PropTypes.bool.isRequired,
|
showRecoveryPhraseReminder: PropTypes.bool.isRequired,
|
||||||
setRecoveryPhraseReminderHasBeenShown: PropTypes.func.isRequired,
|
setRecoveryPhraseReminderHasBeenShown: PropTypes.func.isRequired,
|
||||||
setRecoveryPhraseReminderLastShown: 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,
|
newNetworkAdded: PropTypes.string,
|
||||||
setNewNetworkAdded: PropTypes.func.isRequired,
|
setNewNetworkAdded: PropTypes.func.isRequired,
|
||||||
// This prop is used in the `shouldCloseNotificationPopup` function
|
// This prop is used in the `shouldCloseNotificationPopup` function
|
||||||
|
@ -342,7 +342,10 @@ class SettingsPage extends PureComponent {
|
|||||||
path={ADD_NETWORK_ROUTE}
|
path={ADD_NETWORK_ROUTE}
|
||||||
render={() => <NetworksTab addNewNetwork />}
|
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={SECURITY_ROUTE} component={SecurityTab} />
|
||||||
<Route exact path={EXPERIMENTAL_ROUTE} component={ExperimentalTab} />
|
<Route exact path={EXPERIMENTAL_ROUTE} component={ExperimentalTab} />
|
||||||
<Route exact path={CONTACT_LIST_ROUTE} component={ContactListTab} />
|
<Route exact path={CONTACT_LIST_ROUTE} component={ContactListTab} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user