2023-01-06 12:32:20 +01:00
|
|
|
package filter
|
|
|
|
|
|
|
|
import (
|
2023-01-11 09:13:59 +01:00
|
|
|
"context"
|
|
|
|
|
2023-08-10 12:10:19 +02:00
|
|
|
"github.com/inethi/inethi-cic-chain-events/pkg/fetch"
|
2023-01-06 12:32:20 +01:00
|
|
|
"github.com/zerodha/logf"
|
|
|
|
)
|
|
|
|
|
2023-08-10 12:10:19 +02:00
|
|
|
const (
|
|
|
|
KRNVoucherAddress = "0x8bab657c88eb3c724486d113e650d2c659aa23d2"
|
|
|
|
)
|
|
|
|
|
2023-03-08 15:30:40 +01:00
|
|
|
type (
|
|
|
|
AddressFilterOpts struct {
|
2023-08-10 12:10:19 +02:00
|
|
|
Logg logf.Logger
|
2023-03-08 15:30:40 +01:00
|
|
|
}
|
2023-01-06 12:32:20 +01:00
|
|
|
|
2023-03-08 15:30:40 +01:00
|
|
|
AddressFilter struct {
|
2023-08-10 12:10:19 +02:00
|
|
|
logg logf.Logger
|
2023-03-08 15:30:40 +01:00
|
|
|
}
|
|
|
|
)
|
2023-01-06 12:32:20 +01:00
|
|
|
|
|
|
|
func NewAddressFilter(o AddressFilterOpts) Filter {
|
|
|
|
return &AddressFilter{
|
2023-08-10 12:10:19 +02:00
|
|
|
logg: o.Logg,
|
2023-01-06 12:32:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-11 10:29:51 +01:00
|
|
|
func (f *AddressFilter) Execute(_ context.Context, transaction *fetch.Transaction) (bool, error) {
|
2023-08-10 12:10:19 +02:00
|
|
|
if transaction.To.Address == KRNVoucherAddress {
|
2023-01-06 12:32:20 +01:00
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return false, nil
|
|
|
|
}
|