Skip to content

Commit 85dd725

Browse files
committed
Add CoinGecko API key and update main.go to initialize and start the price alert service
1 parent 303b335 commit 85dd725

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Config struct {
1010
DatabaseURL string
1111
SendGridAPIKey string
1212
InfuraProjectID string
13+
CoinGeckoAPIKey string
1314
}
1415

1516
func LoadConfig() (*Config, error) {

main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"log"
88
"math/big"
99
"os"
10+
"time"
1011

1112
"github.com/Jetlum/WalletAlertService/config"
1213
"github.com/Jetlum/WalletAlertService/database"
@@ -60,6 +61,19 @@ func main() {
6061
emailNotification := services.NewEmailNotification(cfg.SendGridAPIKey)
6162
nftDetector := nfts.NewNFTDetector()
6263

64+
// Initialize price monitoring services
65+
priceMonitor := services.NewPriceMonitor(cfg.CoinGeckoAPIKey)
66+
priceAlertRepo := repository.NewPriceAlertRepository(database.DB)
67+
priceAlertService := services.NewPriceAlertService(
68+
priceMonitor,
69+
priceAlertRepo,
70+
emailNotification,
71+
)
72+
73+
// Start monitoring
74+
priceMonitor.StartMonitoring(1 * time.Minute)
75+
priceAlertService.StartMonitoring()
76+
6377
// Connect to Ethereum node
6478
client, err := ethclient.Dial(fmt.Sprintf("wss://mainnet.infura.io/ws/v3/%s", cfg.InfuraProjectID))
6579
if err != nil {

0 commit comments

Comments
 (0)