forked from TrueCloudLab/neoneo-go
rpc: remove wrappers package, move things to result
These are all RPC call results, `wrappers` package doesn't make much sense to me.
This commit is contained in:
parent
b8f7ab8e6a
commit
1801e545a0
11 changed files with 24 additions and 26 deletions
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/CityOfZion/neo-go/pkg/core/state"
|
||||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
||||
"github.com/CityOfZion/neo-go/pkg/rpc/wrappers"
|
||||
"github.com/CityOfZion/neo-go/pkg/rpc/result"
|
||||
"github.com/CityOfZion/neo-go/pkg/util"
|
||||
errs "github.com/pkg/errors"
|
||||
)
|
||||
|
@ -57,7 +57,7 @@ func (s NeoScanServer) CalculateInputs(address string, assetIDUint util.Uint256,
|
|||
err error
|
||||
us []*Unspent
|
||||
assetUnspent Unspent
|
||||
assetID = wrappers.GlobalAssets[assetIDUint.StringLE()]
|
||||
assetID = result.GlobalAssets[assetIDUint.StringLE()]
|
||||
)
|
||||
if us, err = s.GetBalance(address); err != nil {
|
||||
return nil, util.Fixed8(0), errs.Wrapf(err, "Cannot get balance for address %v", address)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package wrappers
|
||||
package result
|
||||
|
||||
import (
|
||||
"bytes"
|
|
@ -1,4 +1,4 @@
|
|||
package wrappers
|
||||
package result
|
||||
|
||||
import (
|
||||
"github.com/CityOfZion/neo-go/pkg/core/state"
|
|
@ -1,4 +1,4 @@
|
|||
package wrappers
|
||||
package result
|
||||
|
||||
import (
|
||||
"strconv"
|
|
@ -1,4 +1,4 @@
|
|||
package wrappers
|
||||
package result
|
||||
|
||||
import (
|
||||
"github.com/CityOfZion/neo-go/pkg/core/state"
|
|
@ -1,4 +1,4 @@
|
|||
package wrappers
|
||||
package result
|
||||
|
||||
import (
|
||||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
|
@ -1,4 +1,4 @@
|
|||
package wrappers
|
||||
package result
|
||||
|
||||
import (
|
||||
"github.com/CityOfZion/neo-go/pkg/core"
|
|
@ -1,4 +1,4 @@
|
|||
package wrappers
|
||||
package result
|
||||
|
||||
import (
|
||||
"github.com/CityOfZion/neo-go/pkg/core"
|
|
@ -15,7 +15,6 @@ import (
|
|||
"github.com/CityOfZion/neo-go/pkg/io"
|
||||
"github.com/CityOfZion/neo-go/pkg/network"
|
||||
"github.com/CityOfZion/neo-go/pkg/rpc/result"
|
||||
"github.com/CityOfZion/neo-go/pkg/rpc/wrappers"
|
||||
"github.com/CityOfZion/neo-go/pkg/util"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
|
@ -153,7 +152,7 @@ Methods:
|
|||
}
|
||||
|
||||
if len(reqParams) == 2 && reqParams[1].Value == 1 {
|
||||
results = wrappers.NewBlock(block, s.chain)
|
||||
results = result.NewBlock(block, s.chain)
|
||||
} else {
|
||||
writer := io.NewBufBinWriter()
|
||||
block.EncodeBinary(writer.BinWriter)
|
||||
|
@ -228,7 +227,7 @@ Methods:
|
|||
|
||||
as := s.chain.GetAssetState(paramAssetID)
|
||||
if as != nil {
|
||||
results = wrappers.NewAssetState(as)
|
||||
results = result.NewAssetState(as)
|
||||
} else {
|
||||
resultsErr = NewRPCError("Unknown asset", "", nil)
|
||||
}
|
||||
|
@ -334,10 +333,10 @@ func (s *Server) getrawtransaction(reqParams Params) (interface{}, error) {
|
|||
if v == 0 || v == "0" || v == 0.0 || v == false || v == "false" {
|
||||
results = hex.EncodeToString(tx.Bytes())
|
||||
} else {
|
||||
results = wrappers.NewTransactionOutputRaw(tx, header, s.chain)
|
||||
results = result.NewTransactionOutputRaw(tx, header, s.chain)
|
||||
}
|
||||
default:
|
||||
results = wrappers.NewTransactionOutputRaw(tx, header, s.chain)
|
||||
results = result.NewTransactionOutputRaw(tx, header, s.chain)
|
||||
}
|
||||
} else {
|
||||
results = hex.EncodeToString(tx.Bytes())
|
||||
|
@ -377,7 +376,7 @@ func (s *Server) getTxOut(ps Params) (interface{}, error) {
|
|||
}
|
||||
|
||||
out := tx.Outputs[num]
|
||||
return wrappers.NewTxOutput(&out), nil
|
||||
return result.NewTxOutput(&out), nil
|
||||
}
|
||||
|
||||
// getContractState returns contract state (contract information, according to the contract script hash).
|
||||
|
@ -392,7 +391,7 @@ func (s *Server) getContractState(reqParams Params) (interface{}, error) {
|
|||
} else {
|
||||
cs := s.chain.GetContractState(scriptHash)
|
||||
if cs != nil {
|
||||
results = wrappers.NewContractState(cs)
|
||||
results = result.NewContractState(cs)
|
||||
} else {
|
||||
return nil, NewRPCError("Unknown contract", "", nil)
|
||||
}
|
||||
|
@ -420,9 +419,9 @@ func (s *Server) getAccountState(reqParams Params, unspents bool) (interface{},
|
|||
if err != nil {
|
||||
return nil, errInvalidParams
|
||||
}
|
||||
results = wrappers.NewUnspents(as, s.chain, str)
|
||||
results = result.NewUnspents(as, s.chain, str)
|
||||
} else {
|
||||
results = wrappers.NewAccountState(as)
|
||||
results = result.NewAccountState(as)
|
||||
}
|
||||
}
|
||||
return results, resultsErr
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/CityOfZion/neo-go/pkg/io"
|
||||
"github.com/CityOfZion/neo-go/pkg/network"
|
||||
"github.com/CityOfZion/neo-go/pkg/rpc/result"
|
||||
"github.com/CityOfZion/neo-go/pkg/rpc/wrappers"
|
||||
"github.com/CityOfZion/neo-go/pkg/util"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
@ -89,9 +88,9 @@ type StringResultResponse struct {
|
|||
|
||||
// GetBlockResponse struct for testing.
|
||||
type GetBlockResponse struct {
|
||||
Jsonrpc string `json:"jsonrpc"`
|
||||
Result wrappers.Block `json:"result"`
|
||||
ID int `json:"id"`
|
||||
Jsonrpc string `json:"jsonrpc"`
|
||||
Result result.Block `json:"result"`
|
||||
ID int `json:"id"`
|
||||
}
|
||||
|
||||
// GetAssetResponse struct for testing.
|
||||
|
|
|
@ -2,7 +2,7 @@ package rpc
|
|||
|
||||
import (
|
||||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
||||
"github.com/CityOfZion/neo-go/pkg/rpc/wrappers"
|
||||
"github.com/CityOfZion/neo-go/pkg/rpc/result"
|
||||
"github.com/CityOfZion/neo-go/pkg/vm"
|
||||
)
|
||||
|
||||
|
@ -31,8 +31,8 @@ type AccountStateResponse struct {
|
|||
// UnspentResponse represents server response to the `getunspents` command.
|
||||
type UnspentResponse struct {
|
||||
responseHeader
|
||||
Error *Error `json:"error,omitempty"`
|
||||
Result *wrappers.Unspents `json:"result,omitempty"`
|
||||
Error *Error `json:"error,omitempty"`
|
||||
Result *result.Unspents `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
// Account represents details about a NEO account.
|
||||
|
@ -100,7 +100,7 @@ type GetRawTxResponse struct {
|
|||
type GetTxOutResponse struct {
|
||||
responseHeader
|
||||
Error *Error
|
||||
Result *wrappers.TransactionOutput
|
||||
Result *result.TransactionOutput
|
||||
}
|
||||
|
||||
// RawTxResponse stores transaction with blockchain metadata to be sent as a response.
|
||||
|
|
Loading…
Reference in a new issue