Skip to content

Commit

Permalink
Add CoinGecko API key and update main.go to initialize and start the …
Browse files Browse the repository at this point in the history
…price alert service
  • Loading branch information
Jetlum committed Dec 7, 2024
1 parent 303b335 commit 85dd725
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Config struct {
DatabaseURL string
SendGridAPIKey string
InfuraProjectID string
CoinGeckoAPIKey string
}

func LoadConfig() (*Config, error) {
Expand Down
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"math/big"
"os"
"time"

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

// Initialize price monitoring services
priceMonitor := services.NewPriceMonitor(cfg.CoinGeckoAPIKey)
priceAlertRepo := repository.NewPriceAlertRepository(database.DB)
priceAlertService := services.NewPriceAlertService(
priceMonitor,
priceAlertRepo,
emailNotification,
)

// Start monitoring
priceMonitor.StartMonitoring(1 * time.Minute)
priceAlertService.StartMonitoring()

// Connect to Ethereum node
client, err := ethclient.Dial(fmt.Sprintf("wss://mainnet.infura.io/ws/v3/%s", cfg.InfuraProjectID))
if err != nil {
Expand Down

0 comments on commit 85dd725

Please sign in to comment.