Skip to content

Commit 4fae48c

Browse files
committed
support testnet
1 parent 5d61f98 commit 4fae48c

9 files changed

+1147
-942
lines changed

client_block.go

+16-14
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,35 @@ import (
99
)
1010

1111
type GetBlockOption struct {
12-
HeaderOnlyIdHeight bool
13-
WithTransactions bool
14-
WithConsensus bool
15-
TransactionOnlyID bool
16-
WithContractBytecode bool
17-
WithContractSalt bool
12+
WithHeader bool
13+
WithConsensus bool
14+
WithTransactions bool
15+
WithTransactionDetail bool
16+
WithTransactionReceipts bool
17+
WithContractBytecode bool
18+
WithContractSalt bool
1819
}
1920

2021
func (o GetBlockOption) BuildIgnoreChecker() query.IgnoreChecker {
2122
var checkers []query.IgnoreChecker
22-
if !o.WithTransactions {
23-
checkers = append(checkers, query.IgnoreObjects(types.Transaction{}))
23+
if !o.WithHeader {
24+
checkers = append(checkers, query.IgnoreField(types.Block{}, "Header"))
2425
}
2526
if !o.WithConsensus {
2627
checkers = append(checkers, query.IgnoreField(types.Block{}, "Consensus"))
2728
}
28-
if o.HeaderOnlyIdHeight {
29-
checkers = append(checkers, query.IgnoreOtherFields(types.Header{}, "Id", "Height"))
30-
}
31-
if o.TransactionOnlyID {
29+
if !o.WithTransactions {
30+
checkers = append(checkers, query.IgnoreField(types.Block{}, "Transactions"))
31+
} else if !o.WithTransactionDetail {
3232
checkers = append(checkers, query.IgnoreOtherFields(types.Transaction{}, "Id"))
3333
} else {
3434
// Otherwise it will create circular dependencies
3535
checkers = append(checkers, query.IgnoreField(types.SuccessStatus{}, "Block"))
36-
checkers = append(checkers, query.IgnoreField(types.SuccessStatus{}, "Receipts"))
3736
checkers = append(checkers, query.IgnoreField(types.FailureStatus{}, "Block"))
38-
checkers = append(checkers, query.IgnoreField(types.FailureStatus{}, "Receipts"))
37+
if !o.WithTransactionReceipts {
38+
checkers = append(checkers, query.IgnoreField(types.SuccessStatus{}, "Receipts"))
39+
checkers = append(checkers, query.IgnoreField(types.FailureStatus{}, "Receipts"))
40+
}
3941
}
4042
if !o.WithContractBytecode {
4143
checkers = append(checkers, query.IgnoreField(types.Contract{}, "Bytecode"))

client_block_test.go

+74-324
Large diffs are not rendered by default.

client_chain.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,16 @@ func (c *Client) GetChain(ctx context.Context, opt GetChainOption) (types.ChainI
3838

3939
func (c *Client) GetLatestBlockHeight(ctx context.Context) (types.U32, error) {
4040
info, err := c.GetChain(ctx, GetChainOption{
41-
Simple: true,
42-
GetBlockOption: GetBlockOption{
43-
HeaderOnlyIdHeight: true,
44-
},
41+
Simple: true,
42+
GetBlockOption: GetBlockOption{},
4543
})
46-
return info.LatestBlock.Header.Height, err
44+
return info.LatestBlock.Height, err
4745
}
4846

4947
func (c *Client) GetLatestBlockHeader(ctx context.Context) (types.Header, error) {
5048
info, err := c.GetChain(ctx, GetChainOption{
51-
Simple: true,
52-
GetBlockOption: GetBlockOption{
53-
WithTransactions: false,
54-
},
49+
Simple: true,
50+
GetBlockOption: GetBlockOption{WithHeader: true},
5551
})
5652
return info.LatestBlock.Header, err
5753
}

client_test.go

+154-232
Large diffs are not rendered by default.

client_transaction.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ type GetTransactionOption struct {
1717
func (o GetTransactionOption) BuildIgnoreChecker() query.IgnoreChecker {
1818
ignoreCheckers := []query.IgnoreChecker{
1919
query.IgnoreField(types.Block{}, "Transactions"),
20-
query.IgnoreField(types.SuccessStatus{}, "Receipts"),
21-
query.IgnoreField(types.FailureStatus{}, "Receipts"),
2220
}
2321
if !o.WithContractBytecode {
2422
ignoreCheckers = append(ignoreCheckers, query.IgnoreField(types.Contract{}, "Bytecode"))
@@ -27,7 +25,7 @@ func (o GetTransactionOption) BuildIgnoreChecker() query.IgnoreChecker {
2725
ignoreCheckers = append(ignoreCheckers, query.IgnoreField(types.Contract{}, "Salt"))
2826
}
2927
if !o.WithReceipts {
30-
ignoreCheckers = append(ignoreCheckers, query.IgnoreField(types.Transaction{}, "Receipts"))
28+
ignoreCheckers = append(ignoreCheckers, query.IgnoreObjects(types.Receipt{}))
3129
}
3230
if !o.WithStatus {
3331
ignoreCheckers = append(ignoreCheckers, query.IgnoreField(types.Transaction{}, "Status"))

client_transaction_test.go

+236-270
Large diffs are not rendered by default.

tools/config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ scalarMapper:
2222
String: string
2323
Tai64Timestamp: time.Time
2424
TransactionId: common.Hash
25+
RelayedTransactionId: common.Hash
2526
TxPointer: string
2627
U8: uint8
28+
U16: uint16
2729
U32: uint32
2830
U64: uint64
2931
UtxoId: hexutil.Bytes

0 commit comments

Comments
 (0)