dependency on constant field of ABI removed

pull/5370/head
aniket-engg 5 years ago committed by Aniket
parent 6a58a935aa
commit c250d4ee0c
  1. 3
      remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js
  2. 3
      remix-lib/src/execution/txExecution.js
  3. 9
      remix-lib/src/execution/txHelper.js
  4. 3
      remix-lib/src/universalDapp.js
  5. 6
      remix-tests/src/testRunner.ts

@ -44,7 +44,7 @@ var basicRegex = {
CONTRACTTYPE: '^contract ',
FUNCTIONTYPE: '^function \\(',
EXTERNALFUNCTIONTYPE: '^function \\(.*\\).* external',
CONSTANTFUNCTIONTYPE: '^function \\(.*\\).* (constant|view|pure)',
CONSTANTFUNCTIONTYPE: '^function \\(.*\\).* (view|pure)',
REFTYPE: '( storage )|(mapping\\()|(\\[\\])',
FUNCTIONSIGNATURE: '^function \\(([^\\(]*)\\)',
LIBRARYTYPE: '^type\\(library (.*)\\)'
@ -664,7 +664,6 @@ function isStateVariable (name, stateVariables) {
*/
function isConstantFunction (node) {
return isFunctionDefinition(node) && (
node.attributes.constant === true ||
node.attributes.stateMutability === 'view' ||
node.attributes.stateMutability === 'pure'
)

@ -43,7 +43,8 @@ module.exports = {
* @param {Function} finalCallback - last callback.
*/
callFunction: function (from, to, data, value, gasLimit, funAbi, txRunner, callbacks, finalCallback) {
var tx = { from: from, to: to, data: data, useCall: funAbi.constant, value: value, gasLimit: gasLimit }
const isCall = funAbi.stateMutability === 'view' || funAbi.stateMutability === 'pure'
var tx = { from: from, to: to, data: data, useCall: isCall, value: value, gasLimit: gasLimit }
txRunner.rawRun(tx, callbacks.confirmationCb, callbacks.gasEstimationForceSend, callbacks.promptCb, (error, txResult) => {
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
finalCallback(error, txResult)

@ -44,10 +44,15 @@ module.exports = {
// Sorts the list of ABI entries. Constant functions will appear first,
// followed by non-constant functions. Within those t wo groupings, functions
// will be sorted by their names.
function isConstant (funcABI) {
return (funcABI.stateMutability === 'view' || funcABI.stateMutability === 'pure')
}
return contractabi.sort(function (a, b) {
if (a.constant === true && b.constant !== true) {
if (isConstant(a) && !isConstant(b)) {
return 1
} else if (b.constant === true && a.constant !== true) {
} else if (isConstant(b) && !isConstant(a)) {
return -1
}
// If we reach here, either a and b are both constant or both not; sort by name then

@ -232,7 +232,8 @@ module.exports = class UniversalDApp {
* @param {Function} callback - callback.
*/
callFunction (to, data, funAbi, confirmationCb, continueCb, promptCb, callback) {
this.runTx({to: to, data: data, useCall: funAbi.constant}, confirmationCb, continueCb, promptCb, (error, txResult) => {
const isCall = funAbi.stateMutability === 'view' || funAbi.stateMutability === 'pure'
this.runTx({to: to, data: data, useCall: isCall}, confirmationCb, continueCb, promptCb, (error, txResult) => {
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
callback(error, txResult)
})

@ -13,6 +13,10 @@ function getFunctionFullName (signature: string, methodIdentifiers: Record <stri
return null
}
function isConstant(funcABI: FunctionDescription): boolean {
return (funcABI.stateMutability === 'view' || funcABI.stateMutability === 'pure')
}
function getOverridedSender (userdoc: UserDocumentation, signature: string, methodIdentifiers: Record <string, string>) {
let fullName: any = getFunctionFullName(signature, methodIdentifiers)
let match: RegExp = /sender: account-+(\d)/g
@ -77,7 +81,7 @@ function createRunList (jsonInterface: FunctionDescription[], fileAST: AstNode,
if (availableFunctions.indexOf('beforeEach') >= 0) {
runList.push({ name: 'beforeEach', type: 'internal', constant: false })
}
runList.push({ name: func.name, signature: func.signature, type: 'test', constant: func.constant })
runList.push({ name: func.name, signature: func.signature, type: 'test', constant: isConstant(func) })
if (availableFunctions.indexOf('afterEach') >= 0) {
runList.push({ name: 'afterEach', type: 'internal', constant: false })
}

Loading…
Cancel
Save