aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/packages.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-01-13 23:27:36 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-01-13 23:27:36 +0800
commit961e4da7d885a6d5d00fc7c3ab2e11c80c9eeecc (patch)
treefa9deabbbce89ad263a996cc5bd4cf5893bf38e5 /rpc/packages.go
parentb178414a475aa48764622487223237a7d28edd46 (diff)
downloaddexon-961e4da7d885a6d5d00fc7c3ab2e11c80c9eeecc.tar.gz
dexon-961e4da7d885a6d5d00fc7c3ab2e11c80c9eeecc.tar.zst
dexon-961e4da7d885a6d5d00fc7c3ab2e11c80c9eeecc.zip
Add support for CodeAt
Diffstat (limited to 'rpc/packages.go')
-rw-r--r--rpc/packages.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/rpc/packages.go b/rpc/packages.go
index 8a58700b2..4e6016b9e 100644
--- a/rpc/packages.go
+++ b/rpc/packages.go
@@ -149,6 +149,15 @@ func (p *EthereumApi) GetBalanceAt(args *GetBalanceArgs, reply *interface{}) err
return nil
}
+func (p *EthereumApi) GetCodeAt(args *GetCodeAtArgs, reply *interface{}) error {
+ err := args.requirements()
+ if err != nil {
+ return err
+ }
+ *reply = p.pipe.CodeAt(args.Address)
+ return nil
+}
+
type GetBlockArgs struct {
BlockNumber int32
Hash string
@@ -236,6 +245,15 @@ type GetStorageArgs struct {
Key string
}
+func (obj *GetStorageArgs) UnmarshalJSON(b []byte) (err error) {
+ arg0 := ""
+ if err = json.Unmarshal(b, arg0); err == nil {
+ obj.Address = arg0
+ return
+ }
+ return NewErrorResponse(ErrorDecodeArgs)
+}
+
func (a *GetStorageArgs) requirements() error {
if a.Address == "" {
return NewErrorResponse("GetStorageAt requires an 'address' value as argument")
@@ -316,3 +334,22 @@ type BalanceRes struct {
Balance string `json:"balance"`
Address string `json:"address"`
}
+type GetCodeAtArgs struct {
+ Address string
+}
+
+func (obj *GetCodeAtArgs) UnmarshalJSON(b []byte) (err error) {
+ arg0 := ""
+ if err = json.Unmarshal(b, &arg0); err == nil {
+ obj.Address = arg0
+ return
+ }
+ return NewErrorResponse(ErrorDecodeArgs)
+}
+
+func (a *GetCodeAtArgs) requirements() error {
+ if a.Address == "" {
+ return NewErrorResponse("GetCodeAt requires an 'address' value as argument")
+ }
+ return nil
+}