mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 21:09:11 +00:00
* fix/hway-db-driver * fix/hway-db-driver * chore(scripts): add tx indexer and psql connection to test * fix(scripts): make testnet setup more robust and configurable
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
_ "embed"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
config "github.com/onsonr/sonr/internal/config/hway"
|
|
hwayorm "github.com/onsonr/sonr/pkg/gateway/orm"
|
|
)
|
|
|
|
// main is the entry point for the application
|
|
func main() {
|
|
cmd := rootCmd()
|
|
if err := cmd.Execute(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
os.Exit(0)
|
|
}
|
|
|
|
func loadEnvImplFromArgs(args []string) (config.Hway, error) {
|
|
cmd := rootCmd()
|
|
if err := cmd.ParseFlags(args); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
env := &config.HwayImpl{
|
|
ServePort: servePort,
|
|
ChainId: chainID,
|
|
IpfsGatewayUrl: ipfsGatewayURL,
|
|
SonrApiUrl: sonrAPIURL,
|
|
SonrGrpcUrl: sonrGrpcURL,
|
|
SonrRpcUrl: sonrRPCURL,
|
|
PsqlDSN: formatPsqlDSN(),
|
|
}
|
|
return env, nil
|
|
}
|
|
|
|
func setupPostgresDB() (*hwayorm.Queries, error) {
|
|
pgdsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable", psqlHost, psqlUser, psqlPass, psqlDB)
|
|
conn, err := pgx.Connect(context.Background(), pgdsn)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return hwayorm.New(conn), nil
|
|
}
|