Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed settings.Usernames and reactivate PreferredName #3964

Merged
merged 5 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.166.10
0.166.11
3 changes: 2 additions & 1 deletion api/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const pathDefaultWallet = pathWalletRoot + "/0"
const defaultMnemonicLength = 12
const walletAccountDefaultName = "Ethereum account"
const keystoreRelativePath = "keystore"
const defaultKeycardPairingDataFile = "/ethereum/mainnet_rpc/keycard/pairings.json"

var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWallet}

Expand Down Expand Up @@ -96,7 +97,7 @@ func defaultNodeConfig(installationID string, request *requests.CreateAccount) (
nodeConfig.LogDir = request.LogFilePath
nodeConfig.LogLevel = "ERROR"
nodeConfig.DataDir = "/ethereum/mainnet_rpc"
nodeConfig.KeycardPairingDataFile = "/ethereum/mainnet_rpc/keycard/pairings.json"
nodeConfig.KeycardPairingDataFile = defaultKeycardPairingDataFile

if request.LogLevel != nil {
nodeConfig.LogLevel = *request.LogLevel
Expand Down
30 changes: 27 additions & 3 deletions api/geth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"context"
"database/sql"
"encoding/json"
"errors"
"fmt"
"math/big"
Expand All @@ -12,6 +13,8 @@ import (
"sync"
"time"

"github.com/status-im/status-go/services/ens"

"github.com/imdario/mergo"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -614,7 +617,11 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
return err
}

err = b.loadNodeConfig(nil)
defaultCfg := &params.NodeConfig{
// why we need this? relate PR: https://github.com/status-im/status-go/pull/4014
KeycardPairingDataFile: defaultKeycardPairingDataFile,
}
err = b.loadNodeConfig(defaultCfg)
if err != nil {
return err
}
Expand Down Expand Up @@ -763,6 +770,12 @@ func (b *GethStatusBackend) GetSettings() (*settings.Settings, error) {
return &settings, nil
}

func (b *GethStatusBackend) GetEnsUsernames() ([]*ens.UsernameDetail, error) {
db := ens.NewEnsDatabase(b.appDB)
removed := false
return db.GetEnsUsernames(&removed)
}

func (b *GethStatusBackend) MigrateKeyStoreDir(acc multiaccounts.Account, password, oldDir, newDir string) error {
err := b.ensureDBsOpened(acc, password)
if err != nil {
Expand Down Expand Up @@ -812,7 +825,7 @@ func (b *GethStatusBackend) StartNodeWithAccount(acc multiaccounts.Account, pass

func (b *GethStatusBackend) LoggedIn(keyUID string, err error) error {
if err != nil {
signal.SendLoggedIn(nil, nil, err)
signal.SendLoggedIn(nil, nil, nil, err)
return err
}
settings, err := b.GetSettings()
Expand All @@ -824,7 +837,18 @@ func (b *GethStatusBackend) LoggedIn(keyUID string, err error) error {
return err
}

signal.SendLoggedIn(account, settings, nil)
ensUsernames, err := b.GetEnsUsernames()
if err != nil {
return err
}
var ensUsernamesJSON json.RawMessage
if ensUsernames != nil {
ensUsernamesJSON, err = json.Marshal(ensUsernames)
if err != nil {
return err
}
}
signal.SendLoggedIn(account, settings, ensUsernamesJSON, nil)
return nil
}

Expand Down
178 changes: 89 additions & 89 deletions appdatabase/migrations/bindata.go

Large diffs are not rendered by default.

108 changes: 54 additions & 54 deletions appdatabase/migrationsprevnodecfg/bindata.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions mailserver/migrations/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions multiaccounts/migrations/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions multiaccounts/settings/columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ var (
PreferredName = SettingField{
reactFieldName: "preferred-name",
dBColumnName: "preferred_name",
// TODO resolve issue 9 https://github.com/status-im/status-mobile/pull/13053#issuecomment-1075336559
syncProtobufFactory: &SyncProtobufFactory{
inactive: true, // Remove after issue is resolved
fromInterface: preferredNameProtobufFactory,
fromStruct: preferredNameProtobufFactoryStruct,
valueFromProtobuf: StringFromSyncProtobuf,
Expand Down Expand Up @@ -399,17 +397,6 @@ var (
dBColumnName: "use_mailservers",
valueHandler: BoolHandler,
}
Usernames = SettingField{
reactFieldName: "usernames",
dBColumnName: "usernames",
valueHandler: JSONBlobHandler,
syncProtobufFactory: &SyncProtobufFactory{
fromInterface: usernamesProtobufFactory,
fromStruct: usernamesProtobufFactoryStruct,
valueFromProtobuf: BytesFromSyncProtobuf,
protobufType: protobuf.SyncSetting_ENS_USERNAMES,
},
}
WakuBloomFilterMode = SettingField{
reactFieldName: "waku-bloom-filter-mode",
dBColumnName: "waku_bloom_filter_mode",
Expand Down Expand Up @@ -519,7 +506,6 @@ var (
TelemetryServerURL,
TestNetworksEnabled,
UseMailservers,
Usernames,
WakuBloomFilterMode,
WalletRootAddress,
WalletSetUpPassed,
Expand Down
5 changes: 0 additions & 5 deletions multiaccounts/settings/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,6 @@ func (db *Database) GetInstalledStickerPacks() (rst *json.RawMessage, err error)
return
}

func (db *Database) Usernames() (rst *json.RawMessage, err error) {
err = db.makeSelectRow(Usernames).Scan(&rst)
return
}

func (db *Database) GetPendingStickerPacks() (rst *json.RawMessage, err error) {
err = db.makeSelectRow(StickersPacksPending).Scan(&rst)
return
Expand Down
26 changes: 0 additions & 26 deletions multiaccounts/settings/sync_protobuf_factories.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,32 +515,6 @@ func mnemonicRemovedProtobufFactoryStruct(s Settings, clock uint64, chatID strin
return buildRawMnemonicRemovedSyncMessage(s.MnemonicRemoved, clock, chatID)
}

// Usernames

func buildRawUsernamesSyncMessage(v []byte, clock uint64, chatID string) (*common.RawMessage, *protobuf.SyncSetting, error) {
pb := &protobuf.SyncSetting{
Type: protobuf.SyncSetting_ENS_USERNAMES,
Value: &protobuf.SyncSetting_ValueBytes{ValueBytes: v},
Clock: clock,
}
rm, err := buildRawSyncSettingMessage(pb, chatID)
return rm, pb, err
}

func usernamesProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, *protobuf.SyncSetting, error) {
v, err := assertBytes(value)
if err != nil {
return nil, nil, err
}

return buildRawUsernamesSyncMessage(v, clock, chatID)
}

func usernamesProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, *protobuf.SyncSetting, error) {
us := extractJSONRawMessage(s.Usernames)
return buildRawUsernamesSyncMessage(us, clock, chatID)
}

// IncludeWatchOnlyAccount

func buildRawIncludeWatchOnlyAccountSyncMessage(v bool, clock uint64, chatID string) (*common.RawMessage, *protobuf.SyncSetting, error) {
Expand Down
1 change: 1 addition & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ type NodeConfig struct {
KeyStoreDir string `validate:"required"`

// KeycardPairingDataFile is the file where we keep keycard pairings data.
// note: this field won't be saved into db, it's local to the device.
KeycardPairingDataFile string `validate:"required"`

// NodeKey is the hex-encoded node ID (private key). Should be a valid secp256k1 private key that will be used for both
Expand Down
6 changes: 3 additions & 3 deletions protocol/anonmetrics/migrations/migrations.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading