forked from TrueCloudLab/neoneo-go
rpc: fix bad name spellings noted by golint
pkg/rpc/neoScanBalanceGetter.go:54:56: method parameter assetIdUint should be assetIDUint pkg/rpc/neoScanBalanceGetter.go:62:3: var assetId should be assetID pkg/rpc/server_test.go:27:5: var testRpcCases should be testRPCCases pkg/rpc/txTypes.go:19:3: struct field assetId should be assetID pkg/rpc/txTypes.go:39:35: interface method parameter assetId should be assetID pkg/rpc/types.go:115:2: struct field TxId should be TxID Refs. #213.
This commit is contained in:
parent
db9e37b3bb
commit
1fd5e5928c
7 changed files with 15 additions and 15 deletions
|
@ -51,7 +51,7 @@ func filterSpecificAsset(asset string, balance []*Unspent, assetBalance *Unspent
|
|||
}
|
||||
|
||||
// CalculateInputs creates input transactions for the specified amount of given asset belonging to specified address.
|
||||
func (s NeoScanServer) CalculateInputs(address string, assetIdUint util.Uint256, cost util.Fixed8) ([]transaction.Input, util.Fixed8, error) {
|
||||
func (s NeoScanServer) CalculateInputs(address string, assetIDUint util.Uint256, cost util.Fixed8) ([]transaction.Input, util.Fixed8, error) {
|
||||
var (
|
||||
err error
|
||||
num, i uint16
|
||||
|
@ -59,12 +59,12 @@ func (s NeoScanServer) CalculateInputs(address string, assetIdUint util.Uint256,
|
|||
selected = util.Fixed8(0)
|
||||
us []*Unspent
|
||||
assetUnspent Unspent
|
||||
assetId = GlobalAssets[assetIdUint.ReverseString()]
|
||||
assetID = GlobalAssets[assetIDUint.ReverseString()]
|
||||
)
|
||||
if us, err = s.GetBalance(address); err != nil {
|
||||
return nil, util.Fixed8(0), errs.Wrapf(err, "Cannot get balance for address %v", address)
|
||||
}
|
||||
filterSpecificAsset(assetId, us, &assetUnspent)
|
||||
filterSpecificAsset(assetID, us, &assetUnspent)
|
||||
sort.Sort(assetUnspent.Unspent)
|
||||
|
||||
for _, us := range assetUnspent.Unspent {
|
||||
|
|
|
@ -115,7 +115,7 @@ func (c *Client) SendToAddress(asset util.Uint256, address string, amount util.F
|
|||
rawTx *transaction.Transaction
|
||||
rawTxStr string
|
||||
txParams = ContractTxParams{
|
||||
assetId: asset,
|
||||
assetID: asset,
|
||||
address: address,
|
||||
value: amount,
|
||||
wif: c.WIF(),
|
||||
|
|
|
@ -24,18 +24,18 @@ type tc struct {
|
|||
expectedResult string
|
||||
}
|
||||
|
||||
var testRpcCases = []tc{
|
||||
var testRPCCases = []tc{
|
||||
|
||||
{
|
||||
rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getassetstate", "params": ["602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"] }`,
|
||||
method: "getassetstate_1",
|
||||
expectedResult: `{"jsonrpc":"2.0","result":{"assetId":"0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7","assetType":1,"name":"NEOGas","amount":"100000000","available":"0","precision":8,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"AWKECj9RD8rS8RPcpCgYVjk1DeYyHwxZm3","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`,
|
||||
expectedResult: `{"jsonrpc":"2.0","result":{"assetID":"0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7","assetType":1,"name":"NEOGas","amount":"100000000","available":"0","precision":8,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"AWKECj9RD8rS8RPcpCgYVjk1DeYyHwxZm3","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`,
|
||||
},
|
||||
|
||||
{
|
||||
rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "getassetstate", "params": ["c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b"] }`,
|
||||
method: "getassetstate_2",
|
||||
expectedResult: `{"jsonrpc":"2.0","result":{"assetId":"0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b","assetType":0,"name":"NEO","amount":"100000000","available":"0","precision":0,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`,
|
||||
expectedResult: `{"jsonrpc":"2.0","result":{"assetID":"0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b","assetType":0,"name":"NEO","amount":"100000000","available":"0","precision":0,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`,
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -255,13 +255,13 @@ func TestHandler(t *testing.T) {
|
|||
// setup handler
|
||||
handler := http.HandlerFunc(rpcServer.requestHandler)
|
||||
|
||||
testRpcCases = append(testRpcCases, tc{
|
||||
testRPCCases = append(testRPCCases, tc{
|
||||
rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getversion", "params": [] }`,
|
||||
method: "getversion",
|
||||
expectedResult: fmt.Sprintf(`{"jsonrpc":"2.0","result":{"port":20333,"nonce":%s,"useragent":"/NEO-GO:/"},"id":1}`, strconv.FormatUint(uint64(server.ID()), 10)),
|
||||
})
|
||||
|
||||
for _, tc := range testRpcCases {
|
||||
for _, tc := range testRPCCases {
|
||||
t.Run(fmt.Sprintf("method: %s, rpc call: %s", tc.method, tc.rpcCall), func(t *testing.T) {
|
||||
|
||||
req := httptest.NewRequest("POST", "http://0.0.0.0:20333/", strings.NewReader(tc.rpcCall))
|
||||
|
|
|
@ -22,7 +22,7 @@ func CreateRawContractTransaction(params ContractTxParams) (*transaction.Transac
|
|||
spent util.Fixed8
|
||||
witness transaction.Witness
|
||||
|
||||
wif, assetID, address, amount, balancer = params.wif, params.assetId, params.address, params.value, params.balancer
|
||||
wif, assetID, address, amount, balancer = params.wif, params.assetID, params.address, params.value, params.balancer
|
||||
)
|
||||
|
||||
if fromAddress, err = wif.PrivateKey.Address(); err != nil {
|
||||
|
|
|
@ -16,7 +16,7 @@ type (
|
|||
// includes parameters duplication `sendtoaddress` RPC call params
|
||||
// and also some utility data;
|
||||
ContractTxParams struct {
|
||||
assetId util.Uint256
|
||||
assetID util.Uint256
|
||||
address string
|
||||
value util.Fixed8
|
||||
wif keys.WIF // a WIF to send the transaction
|
||||
|
@ -30,12 +30,12 @@ type (
|
|||
BalanceGetter interface {
|
||||
// parameters
|
||||
// address: base58-encoded address assets would be transferred from
|
||||
// assetId: asset identifier
|
||||
// assetID: asset identifier
|
||||
// amount: an asset amount to spend
|
||||
// return values
|
||||
// inputs: UTXO's for the preparing transaction
|
||||
// total: summarized asset amount from all the `inputs`
|
||||
// error: error would be considered in the caller function
|
||||
CalculateInputs(address string, assetId util.Uint256, amount util.Fixed8) (inputs []transaction.Input, total util.Fixed8, err error)
|
||||
CalculateInputs(address string, assetID util.Uint256, amount util.Fixed8) (inputs []transaction.Input, total util.Fixed8, err error)
|
||||
}
|
||||
)
|
||||
|
|
|
@ -112,7 +112,7 @@ type TxResponse struct {
|
|||
|
||||
// Vin represents JSON-serializable tx input.
|
||||
type Vin struct {
|
||||
TxId string `json:"txid"`
|
||||
TxID string `json:"txid"`
|
||||
Vout int `json:"vout"`
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
// AssetState wrapper used for the representation of
|
||||
// core.AssetState on the RPC Server.
|
||||
type AssetState struct {
|
||||
ID util.Uint256 `json:"assetId"`
|
||||
ID util.Uint256 `json:"assetID"`
|
||||
AssetType transaction.AssetType `json:"assetType"`
|
||||
Name string `json:"name"`
|
||||
Amount util.Fixed8 `json:"amount"`
|
||||
|
|
Loading…
Reference in a new issue