2019-08-20 15:38:40 +00:00
|
|
|
package accounts
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/multiaccounts/accounts"
|
2022-01-12 20:04:43 +00:00
|
|
|
"github.com/status-im/status-go/nodecfg"
|
|
|
|
"github.com/status-im/status-go/params"
|
2019-08-20 15:38:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewSettingsAPI(db *accounts.Database) *SettingsAPI {
|
|
|
|
return &SettingsAPI{db}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SettingsAPI is class with methods available over RPC.
|
|
|
|
type SettingsAPI struct {
|
|
|
|
db *accounts.Database
|
|
|
|
}
|
|
|
|
|
2019-12-27 09:58:25 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-12-27 09:58:25 +00:00
|
|
|
return api.db.SaveSetting(typ, val)
|
2019-08-20 15:38:40 +00:00
|
|
|
}
|
|
|
|
|
2019-12-27 09:58:25 +00:00
|
|
|
func (api *SettingsAPI) GetSettings(ctx context.Context) (accounts.Settings, error) {
|
|
|
|
return api.db.GetSettings()
|
2019-08-20 15:38:40 +00:00
|
|
|
}
|
2022-01-12 20:04:43 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|