Merge branch 'master' into startCoding

pull/3654/head
yann300 1 year ago committed by GitHub
commit 7f9b0f98f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      apps/remix-ide/src/app/providers/injected-provider.tsx
  2. 3
      apps/remix-ide/src/app/udapp/run-tab.js
  3. 36
      apps/remix-ide/src/blockchain/blockchain.tsx
  4. 12
      apps/remix-ide/src/blockchain/execution-context.js
  5. 14
      apps/remix-ide/src/blockchain/providers/injected.ts
  6. 2
      apps/remix-ide/src/blockchain/providers/vm.ts
  7. 2
      libs/remix-lib/src/execution/txExecution.ts
  8. 14
      libs/remix-lib/src/execution/txRunnerWeb3.ts
  9. 2
      libs/remix-ui/run-tab/src/lib/actions/deploy.ts

@ -104,16 +104,22 @@ export abstract class InjectedProvider extends Plugin implements IProvider {
if (error.data && error.data.originalError && error.data.originalError.data) {
resolve({
jsonrpc: '2.0',
error: error.data.originalError.message,
errorData: error.data.originalError.data,
error: error.data.originalError,
id: data.id
})
} else
} else if (error.data && error.data.message) {
resolve({
jsonrpc: '2.0',
error: error.data && error.data.message ? error.data.message : error.message,
error: error.data && error.data,
id: data.id
})
} else {
resolve({
jsonrpc: '2.0',
error,
id: data.id
})
}
}
}
}

@ -133,8 +133,7 @@ export class RunTab extends ViewPlugin {
}
},
provider: {
async sendAsync (payload) {
sendAsync (payload) {
return udapp.call(name, 'sendAsync', payload)
}
}

@ -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)
}
@ -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)
}
})
}
@ -962,14 +941,11 @@ export class Blockchain extends Plugin {
cb(null, txResult, address, returnValue)
} catch (error) {
if (this.isInjectedWeb3()) {
let errorObj = error.replace('Returned error: ', '')
errorObj = JSON.parse(errorObj)
if (errorObj.errorData) {
const compiledContracts = await this.call('compilerArtefacts', 'getAllContractDatas')
const injectedError = txExecution.checkError({ errorMessage: errorObj.error, errorData: errorObj.errorData }, 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)
}

@ -86,20 +86,16 @@ export class ExecutionContext {
else if (id === 11155111) name = 'Sepolia'
else name = 'Custom'
if (id === '1') {
web3.eth.getBlock(0, (error, block) => {
if (error) console.log('cant query first block')
if (id === 1) {
web3.eth.getBlock(0).then((block) => {
if (block && block.hash !== this.mainNetGenesisHash) name = 'Custom'
callback(err, { id, name, lastBlock: this.lastBlock, currentFork: this.currentFork })
})
}).catch((error) => callback(error))
} else {
callback(err, { id, name, lastBlock: this.lastBlock, currentFork: this.currentFork })
}
}
const res = web3.eth.net.getId(cb)
if(res && typeof res.then ==='function'){
res.then(id=>cb(null,id)).catch(err=>cb(err))
}
web3.eth.net.getId().then(id=>cb(null,parseInt(id))).catch(err=>cb(err))
}
}

@ -10,12 +10,16 @@ export class InjectedProvider {
}
getAccounts (cb) {
return this.executionContext.web3().eth.getAccounts(cb)
return this.executionContext.web3().eth.getAccounts()
.then(accounts => cb(null, accounts))
.catch(err => {
cb(err.message)
})
}
newAccount (passwordPromptCb, cb) {
passwordPromptCb((passphrase) => {
this.executionContext.web3().eth.personal.newAccount(passphrase, cb)
this.executionContext.web3().eth.personal.newAccount(passphrase).then((result) => cb(null, result)).catch(error => cb(error))
})
}
@ -29,16 +33,16 @@ export class InjectedProvider {
}
getGasPrice (cb) {
this.executionContext.web3().eth.getGasPrice(cb)
this.executionContext.web3().eth.getGasPrice().then((result => cb(null, result)))
}
signMessage (message, account, _passphrase, cb) {
const messageHash = hashPersonalMessage(Buffer.from(message))
try {
message = isHexString(message) ? message : Web3.utils.utf8ToHex(message)
this.executionContext.web3().eth.personal.sign(message, account, (error, signedData) => {
this.executionContext.web3().eth.personal.sign(message, account).then((error, signedData) => {
cb(error, '0x' + messageHash.toString('hex'), signedData)
})
}).catch((error => cb(error)))
} catch (e) {
cb(e.message)
}

@ -100,7 +100,7 @@ export class VMProvider {
}
getGasPrice (cb) {
this.web3.eth.getGasPrice(cb)
this.web3.eth.getGasPrice().then((result => cb(null, result))).catch((error) => cb(error))
}
signMessage (message, account, _passphrase, cb) {

@ -81,7 +81,7 @@ export function checkError (execResult, compiledContracts) {
}
const exceptionError = execResult.errorMessage || ''
const error = `Error occured: ${execResult.errorMessage}.\n`
let msg
let msg = ''
if (exceptionError === errorCode.INVALID_OPCODE) {
msg = '\t\n\tThe execution might have thrown.\n'
ret.error = true

@ -69,7 +69,10 @@ export class TxRunnerWeb3 {
cb(null, res.transactionHash)
} catch (e) {
console.log(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)
cb(null, e.receipt.transactionHash)
// in case the receipt is available, we consider that only the execution failed but the transaction went through.
// So we don't consider this to be an error.
if (e.receipt) cb(null, e.receipt.transactionHash)
else cb(e, null)
}
},
() => {
@ -82,7 +85,10 @@ export class TxRunnerWeb3 {
cb(null, res.transactionHash)
} catch (e) {
console.log(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)
cb(null, e.receipt.transactionHash)
// in case the receipt is available, we consider that only the execution failed but the transaction went through.
// So we don't consider this to be an error.
if (e.receipt) cb(null, e.receipt.transactionHash)
else cb(e, null)
}
}
}
@ -143,7 +149,7 @@ export class TxRunnerWeb3 {
}, (error) => {
callback(error)
})
})
}, callback)
})
.catch(err => {
if (err && err.message.indexOf('Invalid JSON RPC response') !== -1) {
@ -163,7 +169,7 @@ export class TxRunnerWeb3 {
}, (error) => {
callback(error)
})
})
}, callback)
})
})
}

@ -124,7 +124,7 @@ export const continueHandler = (dispatch: React.Dispatch<any>, gasEstimationProm
dispatch(displayNotification('Gas estimation failed', gasEstimationPrompt(msg), 'Send Transaction', 'Cancel Transaction', () => {
continueTxExecution()
}, () => {
cancelCb()
cancelCb(error)
}))
} else {
continueTxExecution()

Loading…
Cancel
Save