Skip to content

Commit

Permalink
refactor: remove unused end param in ethereum-chain-util helpers (#29619
Browse files Browse the repository at this point in the history
)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

Removes unused `end` param in the ethereum-chain-util helpers
* validateChainId
* validateAddEthereumChainParams
* validateSwitchEthereumChainParams

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/29619?quickstart=1)

Extending E2E timeout to get past "no timings found" error:

```
flags = { "circleci": { "timeoutMinutes": 30 } }
```

## **Related issues**

See:
#27847 (comment)

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
jiexi authored Jan 10, 2025
1 parent 1df79a9 commit f58258b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function addEthereumChainHandler(
) {
let validParams;
try {
validParams = validateAddEthereumChainParams(req.params[0], end);
validParams = validateAddEthereumChainParams(req.params[0]);
} catch (error) {
return end(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function validateChainId(chainId) {
return _chainId;
}

export function validateSwitchEthereumChainParams(req, end) {
export function validateSwitchEthereumChainParams(req) {
if (!req.params?.[0] || typeof req.params[0] !== 'object') {
throw rpcErrors.invalidParams({
message: `Expected single, object parameter. Received:\n${JSON.stringify(
Expand All @@ -43,10 +43,10 @@ export function validateSwitchEthereumChainParams(req, end) {
});
}

return validateChainId(chainId, end);
return validateChainId(chainId);
}

export function validateAddEthereumChainParams(params, end) {
export function validateAddEthereumChainParams(params) {
if (!params || typeof params !== 'object') {
throw rpcErrors.invalidParams({
message: `Expected single, object parameter. Received:\n${JSON.stringify(
Expand Down Expand Up @@ -75,7 +75,7 @@ export function validateAddEthereumChainParams(params, end) {
});
}

const _chainId = validateChainId(chainId, end);
const _chainId = validateChainId(chainId);
if (!rpcUrls || !Array.isArray(rpcUrls) || rpcUrls.length === 0) {
throw rpcErrors.invalidParams({
message: `Expected an array with at least one valid string HTTPS url 'rpcUrls', Received:\n${rpcUrls}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function switchEthereumChainHandler(
) {
let chainId;
try {
chainId = validateSwitchEthereumChainParams(req, end);
chainId = validateSwitchEthereumChainParams(req);
} catch (error) {
return end(error);
}
Expand Down

0 comments on commit f58258b

Please sign in to comment.