Skip to content

Commit

Permalink
fix getting the innerData from injected provider
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 authored and Aniket-Engg committed Oct 31, 2023
1 parent d294e8d commit 625b343
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
7 changes: 3 additions & 4 deletions apps/remix-ide/src/app/providers/injected-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,19 @@ export abstract class InjectedProvider extends Plugin implements IProvider {
if (error.data && error.data.originalError && error.data.originalError.data) {
resolve({
jsonrpc: '2.0',
error: { message: error.data.originalError.message },
errorData: error.data.originalError.data,
error: error.data.originalError,
id: data.id
})
} else if (error.data && error.data.message) {
resolve({
jsonrpc: '2.0',
error: { message: error.data && error.data.message },
error: error.data && error.data,
id: data.id
})
} else {
resolve({
jsonrpc: '2.0',
error: { message: error.message },
error,
id: data.id
})
}
Expand Down
35 changes: 6 additions & 29 deletions apps/remix-ide/src/blockchain/blockchain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -853,16 +853,6 @@ export class Blockchain extends Plugin {
try {
this.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb, async (error, result) => {
if (error) {
if (typeof error !== 'string') {
if (error.message) error = error.message
else {
try {
error = 'error: ' + JSON.stringify(error)
} catch (e) {
console.log(e)
}
}
}
return reject(error)
}

Expand All @@ -880,18 +870,7 @@ export class Blockchain extends Plugin {
return resolve({result, tx})
})
} catch (err) {
let error = err
if (error && typeof error !== 'string') {
if (error.message) error = error.message
else {
try {
error = 'error: ' + JSON.stringify(error)
} catch (e) {
console.log(e)
}
}
}
return reject(error)
return reject(err)
}
})
}
Expand Down Expand Up @@ -962,13 +941,11 @@ export class Blockchain extends Plugin {
cb(null, txResult, address, returnValue)
} catch (error) {
if (this.isInjectedWeb3()) {
const errorObj = error.replace('Returned error: ', '').replace('error: ', '')
if (errorObj) {
const compiledContracts = await this.call('compilerArtefacts', 'getAllContractDatas')
const injectedError = txExecution.checkError({ errorMessage: errorObj }, compiledContracts)
cb(injectedError.message)
} else
cb(error)
const errorMessage = error.innerError ? error.innerError.message : error.message
const errorData = error.innerError ? error.innerError.data : error.data
const compiledContracts = await this.call('compilerArtefacts', 'getAllContractDatas')
const injectedError = txExecution.checkError({ errorMessage, errorData }, compiledContracts)
cb(injectedError.message)
} else
cb(error)
}
Expand Down

0 comments on commit 625b343

Please sign in to comment.