Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Complete removal
Browse files Browse the repository at this point in the history
  • Loading branch information
adibas03 committed Aug 25, 2018
1 parent 8d311f3 commit f52e1ab
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
24 changes: 1 addition & 23 deletions lib/statemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,29 +880,7 @@ StateManager.prototype.createFakeTransactionWithCorrectNonce = function(rawTx, f
`tx has nonce of: ${to.number(tx.nonce)}`))
}
}

// If we're calling a contract, check to make sure the address specified is a contract address
if (_transactionIsContractCall(rawTx)) {
self.getCode(to.hex(rawTx.to), 'latest', function(err, code) {
if (err) {
callback(err);
} else if (code === '0x0') {
callback(new TXRejectedError(`Attempting to run transaction which calls a contract function, but recipient address ${to.hex(rawTx.to)} is not a contract address`))
} else {
callback(null, tx)
}
});
} else {
callback(null, tx)
}
callback(null, tx)
});
}

// returns true when transaction has a non-null, non-empty to and data field
var _transactionIsContractCall = function(rawTx) {
let recipient = to.hex(rawTx.to || '0x0')
let data = to.hex(rawTx.data || '0x0')

return recipient !== '0x0' && data !== '0x0'
}
module.exports = StateManager;
12 changes: 0 additions & 12 deletions test/transaction_rejection.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,6 @@ describe("Transaction rejection", function() {
}, /sender doesn't have enough funds to send tx/, done)
});

it("should reject contract transaction if 'to' is not a contract address", function(done) {
let params = {
to: '0x0000000000000000000000001234000000000000'
}

testTransactionForRejection(
params,
new RegExp(`Attempting to run transaction which calls a contract function, but recipient address ${params.to} is not a contract address`),
done
)
});

function testTransactionForRejection(paramsOverride, messageRegex, done) {
let params = Object.assign({
from: accounts[0],
Expand Down

0 comments on commit f52e1ab

Please sign in to comment.