Skip to content

Commit 5b761d7

Browse files
committed
Fix some rpc response type should be hexstring
Signed-off-by: Eval EXEC <execvy@gmail.com>
1 parent 1107c77 commit 5b761d7

File tree

5 files changed

+468
-14
lines changed

5 files changed

+468
-14
lines changed

indexer/types.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ const (
1818
)
1919

2020
type SearchKey struct {
21-
Script *types.Script `json:"script"`
22-
ScriptType types.ScriptType `json:"script_type"`
23-
ScriptSearchMode types.ScriptSearchMode `json:"script_search_mode,omitempty"`
24-
Filter *Filter `json:"filter,omitempty"`
25-
WithData bool `json:"with_data"`
21+
Script *types.Script `json:"script"`
22+
ScriptType types.ScriptType `json:"script_type"`
23+
ScriptSearchMode types.ScriptSearchMode `json:"script_search_mode,omitempty"`
24+
Filter *Filter `json:"filter,omitempty"`
25+
WithData bool `json:"with_data"`
26+
GroupByTransaction *bool `json:"group_by_transaction,omitempty"`
2627
}
2728

2829
type Filter struct {

rpc/client.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,16 @@ type Client interface {
172172

173173
RemoveTransaction(ctx context.Context, tx_hash types.Hash) (bool, error)
174174

175-
SendAlert(ctx context.Context, alert types.AlertMessage) error
175+
SendAlert(ctx context.Context, alert types.Alert) error
176176

177177
GetBlockTemplate(ctx context.Context) (types.BlockTemplate, error)
178178

179179
TxPoolReady(ctx context.Context) (bool, error)
180180

181181
// GetRawTxPool Returns all transaction ids in tx pool as a json array of string transaction ids.
182-
GetRawTxPool(ctx context.Context, verbose *bool) (*types.RawTxPool, error)
182+
GetRawTxPool(ctx context.Context) (*types.RawTxPool, error)
183+
// GetRawTxPool Returns all transaction ids in tx pool as a json array of string transaction ids.
184+
GetRawTxPoolVerbose(ctx context.Context) (*types.RawTxPoolVerbose, error)
183185

184186
// ClearTxPool Removes all transactions from the transaction pool.
185187
ClearTxPool(ctx context.Context) error
@@ -774,14 +776,21 @@ func (cli *client) TxPoolInfo(ctx context.Context) (*types.TxPoolInfo, error) {
774776
return &result, nil
775777
}
776778

777-
func (cli *client) GetRawTxPool(ctx context.Context, verbose *bool) (*types.RawTxPool, error) {
779+
func (cli *client) GetRawTxPool(ctx context.Context) (*types.RawTxPool, error) {
778780
var txPool types.RawTxPool
779781

780-
if verbose == nil {
781-
defaultVerbose := false
782-
verbose = &defaultVerbose
782+
err := cli.c.CallContext(ctx, &txPool, "get_raw_tx_pool")
783+
if err != nil {
784+
return nil, err
783785
}
784-
err := cli.c.CallContext(ctx, &txPool, "get_raw_tx_pool", verbose)
786+
787+
return &txPool, err
788+
}
789+
790+
func (cli *client) GetRawTxPoolVerbose(ctx context.Context) (*types.RawTxPoolVerbose, error) {
791+
var txPool types.RawTxPool
792+
793+
err := cli.c.CallContext(ctx, &txPool, "get_raw_tx_pool", true)
785794
if err != nil {
786795
return nil, err
787796
}
@@ -996,7 +1005,7 @@ func (cli *client) RemoveTransaction(ctx context.Context, tx_hash types.Hash) (b
9961005
return result, nil
9971006
}
9981007

999-
func (cli *client) SendAlert(ctx context.Context, alert types.AlertMessage) error {
1008+
func (cli *client) SendAlert(ctx context.Context, alert types.Alert) error {
10001009
return cli.c.CallContext(ctx, nil, "send_alert", alert)
10011010
}
10021011

rpc/client_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,3 +557,27 @@ func TestClient_GetTransactions_ExactMode(t *testing.T) {
557557
assert.NotEqual(t, 0, resp2.Objects[0].BlockNumber)
558558
assert.NotEqual(t, "", resp2.Objects[0].IoType)
559559
}
560+
561+
func TestClient_GetPoolTxDetailInfo(t *testing.T) {
562+
info, err := testClient.GetPoolTxDetailInfo(ctx, types.HexToHash("0x8277d74d33850581f8d843613ded0c2a1722dec0e87e748f45c115dfb14210f1"))
563+
if err != nil {
564+
t.Fatal(err)
565+
}
566+
assert.NotNil(t, info)
567+
}
568+
569+
func TestClient_GetHeader(t *testing.t) {
570+
// 0xd5ac7cf8c34a975bf258a34f1c2507638487ab71aa4d10a9ec73704aa3abf9cd
571+
header, err := testClient.GetHeader(context.background(), types.HexToHash("0xd5ac7cf8c34a975bf258a34f1c2507638487ab71aa4d10a9ec73704aa3abf9cd"), nil)
572+
if err != nil {
573+
t.Fatal(err)
574+
}
575+
assert.NotNil(t, header)
576+
}
577+
578+
// GetRawTxPool
579+
func TestClient_GetRawTxPool(t *testing.T) {
580+
resp, err := testClient.GetRawTxPool(context.Background())
581+
assert.NoError(t, err)
582+
assert.NotNil(t, resp)
583+
}

0 commit comments

Comments
 (0)