status-go/services/accounts/settings.go

40 lines
1.0 KiB
Go
Raw Normal View History

package accounts
import (
"context"
"github.com/status-im/status-go/multiaccounts/accounts"
"github.com/status-im/status-go/nodecfg"
"github.com/status-im/status-go/params"
)
func NewSettingsAPI(db *accounts.Database) *SettingsAPI {
return &SettingsAPI{db}
}
// SettingsAPI is class with methods available over RPC.
type SettingsAPI struct {
db *accounts.Database
}
func (api *SettingsAPI) SaveSetting(ctx context.Context, typ string, val interface{}) error {
2020-09-16 07:31:01 +00:00
// NOTE(Ferossgp): v0.62.0 Backward compatibility, skip this for older clients instead of returning error
if typ == "waku-enabled" {
return nil
}
return api.db.SaveSetting(typ, val)
}
func (api *SettingsAPI) GetSettings(ctx context.Context) (accounts.Settings, error) {
return api.db.GetSettings()
}
func (api *SettingsAPI) NodeConfig(ctx context.Context) (*params.NodeConfig, error) {
return nodecfg.GetNodeConfig(api.db.DB())
}
func (api *SettingsAPI) SaveNodeConfig(ctx context.Context, n *params.NodeConfig) error {
return nodecfg.SaveNodeConfig(api.db.DB(), n)
}