-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
113 lines (103 loc) · 2.6 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package main
import (
"context"
"embed"
"os"
"github.com/rs/zerolog/log"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
"github.com/vultisig/vultisig-win/mediator"
"github.com/vultisig/vultisig-win/storage"
"github.com/vultisig/vultisig-win/tss"
"github.com/vultisig/vultisig-win/utils"
)
//go:embed all:frontend/dist
var assets embed.FS
//go:embed appicon.png
var icon []byte
func main() {
argsWithoutProg := os.Args[1:]
// Create an instance of the app structure
app := NewApp(argsWithoutProg)
tssIns := tss.NewTssService()
store, err := storage.NewStore()
if err != nil {
panic(err)
}
goHttp, err := utils.NewGoHttp()
if err != nil {
panic(err)
}
mediator, err := mediator.NewRelayServer()
if err != nil {
panic(err)
}
go func() {
if err := mediator.StartServer(); err != nil {
log.Err(err).Msg("relay server exit")
}
}()
// Migrate db, ensure db is in correct state
if err := store.Migrate(); err != nil {
panic(err)
}
// Create an instance of InstallMarkerService
installMarkerService := &InstallMarkerService{}
// Optionally handle fresh install logic in Go on startup
if installMarkerService.IsFreshInstall() {
log.Info().Msg("Fresh install detected. Creating install marker.")
if err := installMarkerService.CreateInstallMarker(); err != nil {
log.Err(err).Msg("Failed to create install marker")
}
}
// Create application with options
err = wails.Run(&options.App{
Title: "Vultisig",
Width: 1024,
Height: 768,
MinHeight: 768,
MinWidth: 1024,
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: func(ctx context.Context) {
app.startup(ctx)
tssIns.Startup(ctx)
},
OnShutdown: func(ctx context.Context) {
if err := mediator.StopServer(); err != nil {
log.Err(err).Msg("fail to stop mediator")
}
},
Bind: []interface{}{
app,
tssIns,
store,
mediator,
goHttp,
installMarkerService,
},
EnumBind: []interface{}{},
LogLevel: logger.ERROR,
Windows: &windows.Options{},
Mac: &mac.Options{
Appearance: mac.DefaultAppearance,
WebviewIsTransparent: true,
WindowIsTranslucent: false,
DisableZoom: false,
About: &mac.AboutInfo{
Title: "Vultisig",
Message: "Vultisig Application",
Icon: icon,
},
},
})
if err != nil {
println("Error:", err.Error())
}
}