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-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
|
|
|
|
cache.Store(strings.ToLower("0x617f3112bf5397D0467D315cC709EF968D9ba546"), "USDT")
|
|
|
|
cache.Store(strings.ToLower("0x765DE816845861e75A25fCA122bb6898B8B1282a"), "cUSD")
|
|
|
|
cache.Store(strings.ToLower("0xD8763CBa276a3738E6DE85b4b3bF5FDed6D6cA73"), "cEUR")
|
|
|
|
|
2023-01-06 12:32:20 +01:00
|
|
|
return filter.NewAddressFilter(filter.AddressFilterOpts{
|
2023-01-14 11:17:34 +01:00
|
|
|
Cache: cache,
|
|
|
|
Logg: lo,
|
2023-01-06 12:32:20 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-01-14 10:12:34 +01:00
|
|
|
func initDecodeFilter() filter.Filter {
|
2023-01-14 11:17:34 +01:00
|
|
|
js, err := initJetStream()
|
|
|
|
if err != nil {
|
|
|
|
lo.Fatal("filters: critical error loading jetstream", "error", err)
|
|
|
|
}
|
|
|
|
|
2023-01-14 10:12:34 +01:00
|
|
|
return filter.NewDecodeFilter(filter.DecodeFilterOpts{
|
2023-01-14 11:17:34 +01:00
|
|
|
Logg: lo,
|
|
|
|
JSCtx: js,
|
2023-01-06 12:32:20 +01:00
|
|
|
})
|
|
|
|
}
|