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

There is no need to check if the recipient of a transaction is a contract or not #119

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions lib/statemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,28 +810,9 @@ StateManager.prototype.createFakeTransactionWithCorrectNonce = function(rawTx, f
}
}

// 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;