From 235a047f14f775a2ed15b8e500016ebd63fe0793 Mon Sep 17 00:00:00 2001 From: Francois Proulx Date: Thu, 8 Nov 2018 15:11:32 -0500 Subject: [PATCH] Vendored with fix to eosio.wrap --- vendor/github.com/eoscanada/eos-go/api.go | 17 ++++++- vendor/github.com/eoscanada/eos-go/error.go | 50 +++++++++++++------ .../github.com/eoscanada/eos-go/sudo/init.go | 2 +- vendor/vendor.json | 48 +++++++++--------- 4 files changed, 75 insertions(+), 42 deletions(-) diff --git a/vendor/github.com/eoscanada/eos-go/api.go b/vendor/github.com/eoscanada/eos-go/api.go index 304ce079..79ecb8fb 100644 --- a/vendor/github.com/eoscanada/eos-go/api.go +++ b/vendor/github.com/eoscanada/eos-go/api.go @@ -384,6 +384,11 @@ func (api *API) PushTransaction(tx *PackedTransaction) (out *PushTransactionFull return } +func (api *API) PushTransactionRaw(tx *PackedTransaction) (out json.RawMessage, err error) { + err = api.call("chain", "push_transaction", tx, &out) + return +} + func (api *API) GetInfo() (out *InfoResp, err error) { err = api.call("chain", "get_info", nil, &out) return @@ -567,10 +572,18 @@ func (api *API) call(baseAPI string, endpoint string, body interface{}, out inte } if resp.StatusCode == 404 { - return ErrNotFound + var apiErr APIError + if err := json.Unmarshal(cnt.Bytes(), &apiErr); err != nil { + return ErrNotFound + } + return apiErr } if resp.StatusCode > 299 { - return fmt.Errorf("%s: status code=%d, body=%s", req.URL.String(), resp.StatusCode, cnt.String()) + var apiErr APIError + if err := json.Unmarshal(cnt.Bytes(), &apiErr); err != nil { + return fmt.Errorf("%s: status code=%d, body=%s", req.URL.String(), resp.StatusCode, cnt.String()) + } + return apiErr } if api.Debug { diff --git a/vendor/github.com/eoscanada/eos-go/error.go b/vendor/github.com/eoscanada/eos-go/error.go index 0c23327c..1d4cf1b6 100644 --- a/vendor/github.com/eoscanada/eos-go/error.go +++ b/vendor/github.com/eoscanada/eos-go/error.go @@ -1,28 +1,48 @@ package eos -import "errors" +import ( + "github.com/eoscanada/eos-go/eoserr" +) // APIError represents the errors as reported by the server type APIError struct { - Code int - Message string + Code int `json:"code"` // http code + Message string `json:"message"` ErrorStruct struct { - Code int - Name string - What string - Details []struct { - Message string - File string - LineNumber int `json:"line_number"` - Method string - } + Code int `json:"code"` // https://docs.google.com/spreadsheets/d/1uHeNDLnCVygqYK-V01CFANuxUwgRkNkrmeLm9MLqu9c/edit#gid=0 + Name string `json:"name"` + What string `json:"what"` + Details []APIErrorDetail `json:"details"` } `json:"error"` } -func (e APIError) Error() error { - return errors.New(e.String()) +func NewAPIError(httpCode int, msg string, e eoserr.Error) *APIError { + newError := &APIError{ + Code: httpCode, + Message: msg, + } + newError.ErrorStruct.Code = e.Code + newError.ErrorStruct.Name = e.Name + newError.ErrorStruct.What = msg + newError.ErrorStruct.Details = []APIErrorDetail{ + APIErrorDetail{ + File: "", + LineNumber: 0, + Message: msg, + Method: e.Name, + }, + } + + return newError +} + +type APIErrorDetail struct { + Message string `json:"message"` + File string `json:"file"` + LineNumber int `json:"line_number"` + Method string `json:"method"` } -func (e APIError) String() string { +func (e APIError) Error() string { return e.Message } diff --git a/vendor/github.com/eoscanada/eos-go/sudo/init.go b/vendor/github.com/eoscanada/eos-go/sudo/init.go index 68cee287..2e307379 100644 --- a/vendor/github.com/eoscanada/eos-go/sudo/init.go +++ b/vendor/github.com/eoscanada/eos-go/sudo/init.go @@ -3,7 +3,7 @@ package sudo import eos "github.com/eoscanada/eos-go" func init() { - eos.RegisterAction(AN("eosio.sudo"), ActN("exec"), Exec{}) + eos.RegisterAction(AN("eosio.wrap"), ActN("exec"), Exec{}) } var AN = eos.AN diff --git a/vendor/vendor.json b/vendor/vendor.json index 1d2569dd..f3a7b237 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -21,71 +21,71 @@ "revisionTime": "2018-02-21T22:46:20Z" }, { - "checksumSHA1": "2ZZH9Tw42VwNFfjH9tqrI59yvLc=", + "checksumSHA1": "J1Xwz57iOjsrrrcYkaZEle1/yMY=", "path": "github.com/eoscanada/eos-go", - "revision": "33369d9cae16f5c871745ab377785d8baf4e58bc", - "revisionTime": "2018-11-07T16:00:32Z", + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z", "version": "master" }, { "checksumSHA1": "mbdurDenl8bhRVVu8ixJw70fi5E=", "path": "github.com/eoscanada/eos-go/btcsuite/btcd/btcec", - "revision": "6a1c94a1d8025517f300cc54f6517db1f4cfa250", - "revisionTime": "2018-10-31T18:10:37Z" + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z" }, { "checksumSHA1": "9CdGdJ/+qjIwCfyoxoB3JxNtdyg=", "path": "github.com/eoscanada/eos-go/btcsuite/btcutil", - "revision": "6a1c94a1d8025517f300cc54f6517db1f4cfa250", - "revisionTime": "2018-10-31T18:10:37Z" + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z" }, { "checksumSHA1": "VkjW+vswsv7J0PX2UFqqg+/RVgs=", "path": "github.com/eoscanada/eos-go/btcsuite/btcutil/base58", - "revision": "6a1c94a1d8025517f300cc54f6517db1f4cfa250", - "revisionTime": "2018-10-31T18:10:37Z" + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z" }, { "checksumSHA1": "Yx6xxLmmZ4bgk6DZ1kh+lneJetA=", "path": "github.com/eoscanada/eos-go/ecc", - "revision": "6a1c94a1d8025517f300cc54f6517db1f4cfa250", - "revisionTime": "2018-10-31T18:10:37Z" + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z" }, { "checksumSHA1": "mGMPbqDZkxTp8QjdMIgOed2APpM=", "path": "github.com/eoscanada/eos-go/forum", - "revision": "6a1c94a1d8025517f300cc54f6517db1f4cfa250", - "revisionTime": "2018-10-31T18:10:37Z" + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z" }, { "checksumSHA1": "Gk4Dvc3QqbWnUdz4jvCXuxULqyo=", "path": "github.com/eoscanada/eos-go/msig", - "revision": "6a1c94a1d8025517f300cc54f6517db1f4cfa250", - "revisionTime": "2018-10-31T18:10:37Z" + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z" }, { "checksumSHA1": "PGcZRpleDedi3tvY4qdXzBLK5AM=", "path": "github.com/eoscanada/eos-go/p2p", - "revision": "6a1c94a1d8025517f300cc54f6517db1f4cfa250", - "revisionTime": "2018-10-31T18:10:37Z" + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z" }, { - "checksumSHA1": "k9urFt9aTmOSSOfM8HCd178pbmM=", + "checksumSHA1": "5rxfgBTaj8zp8ilEG5AT6In7qYc=", "path": "github.com/eoscanada/eos-go/sudo", - "revision": "6a1c94a1d8025517f300cc54f6517db1f4cfa250", - "revisionTime": "2018-10-31T18:10:37Z" + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z" }, { "checksumSHA1": "INVxgDwm7w2DfWELXYgyj87PSEE=", "path": "github.com/eoscanada/eos-go/system", - "revision": "6a1c94a1d8025517f300cc54f6517db1f4cfa250", - "revisionTime": "2018-10-31T18:10:37Z" + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z" }, { "checksumSHA1": "n/7xl3TEdpCXXT0GtNAxva/ReoI=", "path": "github.com/eoscanada/eos-go/token", - "revision": "6a1c94a1d8025517f300cc54f6517db1f4cfa250", - "revisionTime": "2018-10-31T18:10:37Z" + "revision": "f025823404753ce8283cf235de11608f934cbea4", + "revisionTime": "2018-11-08T20:09:00Z" }, { "checksumSHA1": "7NP1qUMF8Kx1y0zANxx0e+oq9Oo=",