Skip to content

Commit

Permalink
improved error handling
Browse files Browse the repository at this point in the history
(cherry picked from commit 9267ab4)
  • Loading branch information
CAPtheorem authored and InoMurko committed Jun 17, 2022
1 parent f5ce151 commit 1ef2c15
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/boba/gateway/src/actions/createAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export function createAction (key, asyncAction) {
return false
}

if(response && typeof(response) === 'string' && response.includes('Insufficient balance')) {
//let errorMessage = JSON.parse(response)
dispatch({ type: `UI/ERROR/UPDATE`, payload: "Insufficient BOBA balance for emergency swap" })
dispatch({ type: `${key}/ERROR` })
return false
}

//deal with metamask errors - they will have a 'code' field so we can detect those
if(response && response.hasOwnProperty('message') && response.hasOwnProperty('code')) {

Expand Down
3 changes: 2 additions & 1 deletion packages/boba/gateway/src/containers/wallet/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ function Wallet() {

async function emergencySwap () {
const res = await dispatch(getETHMetaTransaction())
console.log("emergencySwap - res:",res)
if (res) dispatch(openAlert('Emergency Swap submitted'))
}

Expand All @@ -129,7 +130,7 @@ function Wallet() {
/>

{layer === 'L2' && tooSmallETH &&
<G.LayerAlert>
<G.LayerAlert style={{padding: '20px'}}>
<G.AlertInfo>
<Icon as={Info} sx={{color:"#BAE21A"}}/>
<Typography
Expand Down
2 changes: 2 additions & 0 deletions packages/boba/gateway/src/services/networkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ class NetworkService {
}

let signature

try {
signature = await this.provider.send('eth_signTypedData_v4', [this.account, JSON.stringify(data)])
} catch (error) {
Expand All @@ -569,6 +570,7 @@ class NetworkService {
if(errorData.hasOwnProperty('error')) {
errorData = errorData.error.error.body
}
console.log("returning:",error)
return errorData
}
}
Expand Down

0 comments on commit 1ef2c15

Please sign in to comment.