2023-01-05 12:45:09 +01:00
|
|
|
package main
|
|
|
|
|
2023-01-06 12:32:20 +01:00
|
|
|
import (
|
2023-01-14 11:17:34 +01:00
|
|
|
"strings"
|
|
|
|
"sync"
|
|
|
|
|
2023-01-19 09:42:59 +01:00
|
|
|
"github.com/grassrootseconomics/cic-chain-events/internal/filter"
|
2023-03-08 15:30:40 +01:00
|
|
|
"github.com/grassrootseconomics/cic-chain-events/internal/pub"
|
2023-01-06 12:32:20 +01:00
|
|
|
)
|
|
|
|
|
2023-02-24 11:28:30 +01:00
|
|
|
var (
|
|
|
|
systemAddress = strings.ToLower("0x3D85285e39f05773aC92EAD27CB50a4385A529E4")
|
|
|
|
)
|
|
|
|
|
2023-01-06 12:32:20 +01:00
|
|
|
func initAddressFilter() filter.Filter {
|
2023-01-14 11:17:34 +01:00
|
|
|
// TODO: Bootstrap addresses from smart contract
|
|
|
|
// TODO: Add route to update cache
|
|
|
|
cache := &sync.Map{}
|
|
|
|
|
|
|
|
// Example bootstrap addresses
|
2023-02-24 11:28:30 +01:00
|
|
|
cache.Store(strings.ToLower("0xB92463E2262E700e29c16416270c9Fdfa17934D7"), "TRNVoucher")
|
|
|
|
cache.Store(strings.ToLower("0xf2a1fc19Ad275A0EAe3445798761FeD1Eea725d5"), "GasFaucet")
|
|
|
|
cache.Store(strings.ToLower("0x1e041282695C66944BfC53cabce947cf35CEaf87"), "AddressIndex")
|
2023-01-14 11:17:34 +01:00
|
|
|
|
2023-01-06 12:32:20 +01:00
|
|
|
return filter.NewAddressFilter(filter.AddressFilterOpts{
|
2023-02-24 11:28:30 +01:00
|
|
|
Cache: cache,
|
|
|
|
Logg: lo,
|
|
|
|
SystemAddress: systemAddress,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-03-08 15:30:40 +01:00
|
|
|
func initTransferFilter(pub *pub.Pub) filter.Filter {
|
2023-02-24 11:28:30 +01:00
|
|
|
return filter.NewTransferFilter(filter.TransferFilterOpts{
|
2023-03-08 15:30:40 +01:00
|
|
|
Pub: pub,
|
|
|
|
Logg: lo,
|
2023-01-06 12:32:20 +01:00
|
|
|
})
|
2023-02-24 11:28:30 +01:00
|
|
|
|
2023-01-06 12:32:20 +01:00
|
|
|
}
|
|
|
|
|
2023-03-08 15:30:40 +01:00
|
|
|
func initGasGiftFilter(pub *pub.Pub) filter.Filter {
|
2023-02-24 11:28:30 +01:00
|
|
|
return filter.NewGasFilter(filter.GasFilterOpts{
|
2023-03-08 15:30:40 +01:00
|
|
|
Pub: pub,
|
2023-02-24 11:28:30 +01:00
|
|
|
Logg: lo,
|
|
|
|
SystemAddress: systemAddress,
|
|
|
|
})
|
|
|
|
}
|
2023-01-14 11:17:34 +01:00
|
|
|
|
2023-03-08 15:30:40 +01:00
|
|
|
func initRegisterFilter(pub *pub.Pub) filter.Filter {
|
2023-02-24 11:28:30 +01:00
|
|
|
return filter.NewRegisterFilter(filter.RegisterFilterOpts{
|
2023-03-08 15:30:40 +01:00
|
|
|
Pub: pub,
|
|
|
|
Logg: lo,
|
2023-01-06 12:32:20 +01:00
|
|
|
})
|
|
|
|
}
|