Skip to content

Commit

Permalink
Slight refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
alwx committed May 31, 2023
1 parent 3734527 commit 597c239
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 63 deletions.
42 changes: 21 additions & 21 deletions cmd/ping-community/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,37 +266,37 @@ var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWa
func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*settings.Settings, error) {
chatKeyString := derivedAddresses[pathDefaultChat].PublicKey

settings := &settings.Settings{}
settings.KeyUID = generatedAccountInfo.KeyUID
settings.Address = types.HexToAddress(generatedAccountInfo.Address)
settings.WalletRootAddress = types.HexToAddress(derivedAddresses[pathWalletRoot].Address)
defaultSettings := &settings.Settings{}
defaultSettings.KeyUID = generatedAccountInfo.KeyUID
defaultSettings.Address = types.HexToAddress(generatedAccountInfo.Address)
defaultSettings.WalletRootAddress = types.HexToAddress(derivedAddresses[pathWalletRoot].Address)

// Set chat key & name
name, err := alias.GenerateFromPublicKeyString(chatKeyString)
if err != nil {
return nil, err
}
settings.Name = name
settings.PublicKey = chatKeyString
defaultSettings.Name = name
defaultSettings.PublicKey = chatKeyString

settings.DappsAddress = types.HexToAddress(derivedAddresses[pathDefaultWallet].Address)
settings.EIP1581Address = types.HexToAddress(derivedAddresses[pathEIP1581].Address)
settings.Mnemonic = mnemonic
defaultSettings.DappsAddress = types.HexToAddress(derivedAddresses[pathDefaultWallet].Address)
defaultSettings.EIP1581Address = types.HexToAddress(derivedAddresses[pathEIP1581].Address)
defaultSettings.Mnemonic = mnemonic

signingPhrase, err := buildSigningPhrase()
if err != nil {
return nil, err
}
settings.SigningPhrase = signingPhrase
defaultSettings.SigningPhrase = signingPhrase

settings.SendPushNotifications = true
settings.InstallationID = uuid.New().String()
settings.UseMailservers = true
defaultSettings.SendPushNotifications = true
defaultSettings.InstallationID = uuid.New().String()
defaultSettings.UseMailservers = true

settings.PreviewPrivacy = true
settings.Currency = "usd"
settings.ProfilePicturesVisibility = 2
settings.LinkPreviewRequestEnabled = true
defaultSettings.PreviewPrivacy = true
defaultSettings.Currency = "usd"
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
defaultSettings.LinkPreviewRequestEnabled = true

visibleTokens := make(map[string][]string)
visibleTokens["mainnet"] = []string{"SNT"}
Expand All @@ -305,7 +305,7 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
return nil, err
}
visibleTokenJSONRaw := json.RawMessage(visibleTokensJSON)
settings.WalletVisibleTokens = &visibleTokenJSONRaw
defaultSettings.WalletVisibleTokens = &visibleTokenJSONRaw

// TODO: fix this
networks := make([]map[string]string, 0)
Expand All @@ -314,10 +314,10 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
return nil, err
}
networkRawMessage := json.RawMessage(networksJSON)
settings.Networks = &networkRawMessage
settings.CurrentNetwork = "mainnet_rpc"
defaultSettings.Networks = &networkRawMessage
defaultSettings.CurrentNetwork = "mainnet_rpc"

return settings, nil
return defaultSettings, nil
}

func defaultNodeConfig(installationID string) (*params.NodeConfig, error) {
Expand Down
42 changes: 21 additions & 21 deletions cmd/populate-db/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,37 +330,37 @@ var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWa
func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*settings.Settings, error) {
chatKeyString := derivedAddresses[pathDefaultChat].PublicKey

settings := &settings.Settings{}
settings.KeyUID = generatedAccountInfo.KeyUID
settings.Address = types.HexToAddress(generatedAccountInfo.Address)
settings.WalletRootAddress = types.HexToAddress(derivedAddresses[pathWalletRoot].Address)
defaultSettings := &settings.Settings{}
defaultSettings.KeyUID = generatedAccountInfo.KeyUID
defaultSettings.Address = types.HexToAddress(generatedAccountInfo.Address)
defaultSettings.WalletRootAddress = types.HexToAddress(derivedAddresses[pathWalletRoot].Address)

// Set chat key & name
name, err := alias.GenerateFromPublicKeyString(chatKeyString)
if err != nil {
return nil, err
}
settings.Name = name
settings.PublicKey = chatKeyString
defaultSettings.Name = name
defaultSettings.PublicKey = chatKeyString

settings.DappsAddress = types.HexToAddress(derivedAddresses[pathDefaultWallet].Address)
settings.EIP1581Address = types.HexToAddress(derivedAddresses[pathEIP1581].Address)
settings.Mnemonic = mnemonic
defaultSettings.DappsAddress = types.HexToAddress(derivedAddresses[pathDefaultWallet].Address)
defaultSettings.EIP1581Address = types.HexToAddress(derivedAddresses[pathEIP1581].Address)
defaultSettings.Mnemonic = mnemonic

signingPhrase, err := buildSigningPhrase()
if err != nil {
return nil, err
}
settings.SigningPhrase = signingPhrase
defaultSettings.SigningPhrase = signingPhrase

settings.SendPushNotifications = true
settings.InstallationID = uuid.New().String()
settings.UseMailservers = true
defaultSettings.SendPushNotifications = true
defaultSettings.InstallationID = uuid.New().String()
defaultSettings.UseMailservers = true

settings.PreviewPrivacy = true
settings.Currency = "usd"
settings.ProfilePicturesVisibility = 2
settings.LinkPreviewRequestEnabled = true
defaultSettings.PreviewPrivacy = true
defaultSettings.Currency = "usd"
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
defaultSettings.LinkPreviewRequestEnabled = true

visibleTokens := make(map[string][]string)
visibleTokens["mainnet"] = []string{"SNT"}
Expand All @@ -369,7 +369,7 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
return nil, err
}
visibleTokenJSONRaw := json.RawMessage(visibleTokensJSON)
settings.WalletVisibleTokens = &visibleTokenJSONRaw
defaultSettings.WalletVisibleTokens = &visibleTokenJSONRaw

// TODO: fix this
networks := make([]map[string]string, 0)
Expand All @@ -378,10 +378,10 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
return nil, err
}
networkRawMessage := json.RawMessage(networksJSON)
settings.Networks = &networkRawMessage
settings.CurrentNetwork = "mainnet_rpc"
defaultSettings.Networks = &networkRawMessage
defaultSettings.CurrentNetwork = "mainnet_rpc"

return settings, nil
return defaultSettings, nil
}

func defaultNodeConfig(installationID string) (*params.NodeConfig, error) {
Expand Down
42 changes: 21 additions & 21 deletions cmd/spiff-workflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,37 +207,37 @@ var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWa
func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*settings.Settings, error) {
chatKeyString := derivedAddresses[pathDefaultChat].PublicKey

settings := &settings.Settings{}
settings.KeyUID = generatedAccountInfo.KeyUID
settings.Address = types.HexToAddress(generatedAccountInfo.Address)
settings.WalletRootAddress = types.HexToAddress(derivedAddresses[pathWalletRoot].Address)
defaultSettings := &settings.Settings{}
defaultSettings.KeyUID = generatedAccountInfo.KeyUID
defaultSettings.Address = types.HexToAddress(generatedAccountInfo.Address)
defaultSettings.WalletRootAddress = types.HexToAddress(derivedAddresses[pathWalletRoot].Address)

// Set chat key & name
name, err := alias.GenerateFromPublicKeyString(chatKeyString)
if err != nil {
return nil, err
}
settings.Name = name
settings.PublicKey = chatKeyString
defaultSettings.Name = name
defaultSettings.PublicKey = chatKeyString

settings.DappsAddress = types.HexToAddress(derivedAddresses[pathDefaultWallet].Address)
settings.EIP1581Address = types.HexToAddress(derivedAddresses[pathEIP1581].Address)
settings.Mnemonic = mnemonic
defaultSettings.DappsAddress = types.HexToAddress(derivedAddresses[pathDefaultWallet].Address)
defaultSettings.EIP1581Address = types.HexToAddress(derivedAddresses[pathEIP1581].Address)
defaultSettings.Mnemonic = mnemonic

signingPhrase, err := buildSigningPhrase()
if err != nil {
return nil, err
}
settings.SigningPhrase = signingPhrase
defaultSettings.SigningPhrase = signingPhrase

settings.SendPushNotifications = true
settings.InstallationID = uuid.New().String()
settings.UseMailservers = true
defaultSettings.SendPushNotifications = true
defaultSettings.InstallationID = uuid.New().String()
defaultSettings.UseMailservers = true

settings.PreviewPrivacy = true
settings.Currency = "usd"
settings.ProfilePicturesVisibility = 2
settings.LinkPreviewRequestEnabled = true
defaultSettings.PreviewPrivacy = true
defaultSettings.Currency = "usd"
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
defaultSettings.LinkPreviewRequestEnabled = true

visibleTokens := make(map[string][]string)
visibleTokens["mainnet"] = []string{"SNT"}
Expand All @@ -246,7 +246,7 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
return nil, err
}
visibleTokenJSONRaw := json.RawMessage(visibleTokensJSON)
settings.WalletVisibleTokens = &visibleTokenJSONRaw
defaultSettings.WalletVisibleTokens = &visibleTokenJSONRaw

// TODO: fix this
networks := make([]map[string]string, 0)
Expand All @@ -255,10 +255,10 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
return nil, err
}
networkRawMessage := json.RawMessage(networksJSON)
settings.Networks = &networkRawMessage
settings.CurrentNetwork = "mainnet_rpc"
defaultSettings.Networks = &networkRawMessage
defaultSettings.CurrentNetwork = "mainnet_rpc"

return settings, nil
return defaultSettings, nil
}

func defaultNodeConfig(installationID string) (*params.NodeConfig, error) {
Expand Down

0 comments on commit 597c239

Please sign in to comment.