Skip to content

Commit

Permalink
fix add and switch chain inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Jan 7, 2024
1 parent 4ea96ff commit 9e96a35
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/controllers/network/createMetamaskMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ export function createAddChainMiddleware({ processAddChain }) {
}
*/

const { chainId, rpcUrls, nativeCurrency } = request.params || {}
let finalObj = {}

if (Array.isArray(request.params)) finalObj = request.params[0]
else finalObj = request.params

const { chainId, rpcUrls, nativeCurrency } = finalObj || {}
if (!chainId) throw new Error('createAddChainMiddleware - params.chainId not provided')
if (!rpcUrls || rpcUrls.length === 0) throw new Error('createAddChainMiddleware - params.rpcUrls not provided')
if (!nativeCurrency) throw new Error('createAddChainMiddleware - params.nativeCurrency not provided')
Expand All @@ -95,7 +100,12 @@ export function createSwitchChainMiddleware({ processSwitchChain }) {
}
*/

const { chainId } = request.params || {}
let finalObj = {}

if (Array.isArray(request.params)) finalObj = request.params[0]
else finalObj = request.params

const { chainId } = finalObj || {}
if (!chainId) throw new Error('createSwitchChainMiddleware - params.chainId not provided')

response.result = await processSwitchChain(request.params, request)
Expand Down

0 comments on commit 9e96a35

Please sign in to comment.