aboutsummaryrefslogtreecommitdiffstats
path: root/eth/api.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-04-27 21:29:13 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-04-27 22:15:23 +0800
commitcdcbb2f16014077597e5901c0f328920c904409e (patch)
treec0b750618d97a278f73ccfd7bbf380b40f1d3a0f /eth/api.go
parentdb62979514c69574aefdcf8c2ed9099aa0cd1abe (diff)
downloaddexon-cdcbb2f16014077597e5901c0f328920c904409e.tar
dexon-cdcbb2f16014077597e5901c0f328920c904409e.tar.gz
dexon-cdcbb2f16014077597e5901c0f328920c904409e.tar.bz2
dexon-cdcbb2f16014077597e5901c0f328920c904409e.tar.lz
dexon-cdcbb2f16014077597e5901c0f328920c904409e.tar.xz
dexon-cdcbb2f16014077597e5901c0f328920c904409e.tar.zst
dexon-cdcbb2f16014077597e5901c0f328920c904409e.zip
accounts/abi/bind, eth: add contract non-existent error
Diffstat (limited to 'eth/api.go')
-rw-r--r--eth/api.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/eth/api.go b/eth/api.go
index a0b1f8ac2..02b34541f 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -51,6 +51,15 @@ import (
"golang.org/x/net/context"
)
+// ErrNoCode is returned by call and transact operations for which the requested
+// recipient contract to operate on does not exist in the state db or does not
+// have any code associated with it (i.e. suicided).
+//
+// Please note, this error string is part of the RPC API and is expected by the
+// native contract bindings to signal this particular error. Do not change this
+// as it will break all dependent code!
+var ErrNoCode = errors.New("no contract code at given address")
+
const defaultGas = uint64(90000)
// blockByNumber is a commonly used helper function which retrieves and returns
@@ -694,6 +703,12 @@ func (s *PublicBlockChainAPI) doCall(args CallArgs, blockNr rpc.BlockNumber) (st
}
stateDb = stateDb.Copy()
+ // If there's no code to interact with, respond with an appropriate error
+ if args.To != nil {
+ if code := stateDb.GetCode(*args.To); len(code) == 0 {
+ return "0x", nil, ErrNoCode
+ }
+ }
// Retrieve the account state object to interact with
var from *state.StateObject
if args.From == (common.Address{}) {