-
Notifications
You must be signed in to change notification settings - Fork 32
/
filter.go
70 lines (67 loc) · 1.85 KB
/
filter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package db
// BuildLogFilter builds a log filter from nullable parameters.
func BuildLogFilter(contractAddress *string, blockNumber *int, txHash *string, txIndex *int, blockHash *string, index *int, confirmed *bool) LogFilter {
logFilter := LogFilter{}
if contractAddress != nil {
logFilter.ContractAddress = *contractAddress
}
if blockNumber != nil {
logFilter.BlockNumber = uint64(*blockNumber)
}
if txHash != nil {
logFilter.TxHash = *txHash
}
if txIndex != nil {
logFilter.TxIndex = uint64(*txIndex)
}
if blockHash != nil {
logFilter.BlockHash = *blockHash
}
if index != nil {
logFilter.Index = uint64(*index)
}
if confirmed != nil {
logFilter.Confirmed = *confirmed
}
return logFilter
}
// BuildReceiptFilter builds a receipt filter.
func BuildReceiptFilter(txHash *string, contractAddress *string, blockHash *string, blockNumber *int, transactionIndex *int, confirmed *bool) ReceiptFilter {
receiptFilter := ReceiptFilter{}
if txHash != nil {
receiptFilter.TxHash = *txHash
}
if contractAddress != nil {
receiptFilter.ContractAddress = *contractAddress
}
if blockHash != nil {
receiptFilter.BlockHash = *blockHash
}
if blockNumber != nil {
receiptFilter.BlockNumber = uint64(*blockNumber)
}
if transactionIndex != nil {
receiptFilter.TransactionIndex = uint64(*transactionIndex)
}
if confirmed != nil {
receiptFilter.Confirmed = *confirmed
}
return receiptFilter
}
// BuildEthTxFilter cannot build eth tx filter.
func BuildEthTxFilter(txHash *string, blockNumber *int, blockHash *string, confirmed *bool) EthTxFilter {
ethTxFilter := EthTxFilter{}
if txHash != nil {
ethTxFilter.TxHash = *txHash
}
if blockNumber != nil {
ethTxFilter.BlockNumber = uint64(*blockNumber)
}
if blockHash != nil {
ethTxFilter.BlockHash = *blockHash
}
if confirmed != nil {
ethTxFilter.Confirmed = *confirmed
}
return ethTxFilter
}