Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin committed Nov 12, 2020
2 parents d93f50e + 4e4dde1 commit b44f651
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gnosis.pm/dex-react",
"version": "1.6.0",
"version": "1.6.1",
"description": "",
"main": "src/index.js",
"sideEffects": false,
Expand Down
30 changes: 25 additions & 5 deletions src/api/wallet/composeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ import {
removeTxPendingApproval,
} from 'components/OuterModal'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const sanitizeErrorData = (jsonRpcError?: JsonRpcError<any>): void => {
if (!jsonRpcError) return

if (jsonRpcError.data?.originalError) {
jsonRpcError.data = jsonRpcError.data.originalError.data
}
}

// custom providerAsMiddleware
function providerAsMiddleware(provider: Provider): JsonRpcMiddleware {
// WalletConnectProvider.sendAsync is web3-provider-engine.sendAsync
Expand All @@ -46,10 +55,17 @@ function providerAsMiddleware(provider: Provider): JsonRpcMiddleware {
return
}

provider.request(req).then((providerRes) => {
Object.assign(res, providerRes)
end()
}, end)
provider.request(req).then(
(providerRes) => {
Object.assign(res, providerRes)
sanitizeErrorData(res.error)
end()
},
(error) => {
sanitizeErrorData(error)
end(error)
},
)
}
}

Expand All @@ -62,7 +78,11 @@ function providerAsMiddleware(provider: Provider): JsonRpcMiddleware {

provider[sendFName](req, (err: JsonRpcError<unknown>, providerRes: JsonRpcResponse<unknown>) => {
// forward any error
if (err) return end(err)
if (err) {
sanitizeErrorData(err)
return end(err)
}
sanitizeErrorData(providerRes.error)
// copy provider response onto original response
Object.assign(res, providerRes)
end()
Expand Down

0 comments on commit b44f651

Please sign in to comment.