feat: sepolia default

This commit is contained in:
Anthony Laibe 2024-02-20 10:30:47 +01:00 committed by Anthony Laibe
parent 23ee898754
commit 972a4f9df9
13 changed files with 496 additions and 368 deletions

View File

@ -1 +1 @@
0.175.3
0.175.4

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
ALTER TABLE settings ADD COLUMN is_goerli_enabled BOOLEAN NOT NULL DEFAULT FALSE;

View File

@ -11,6 +11,7 @@ var errorNotAvailableOnChainID = errors.New("not available for chainID")
var contractAddressByChainID = map[uint64]common.Address{
1: common.HexToAddress("0x744d70fdbe2ba4cf95131626614a1763df805b9e"), // mainnet
5: common.HexToAddress("0x3d6afaa395c31fcd391fe3d562e75fe9e8ec7e6a"), // goerli
11155111: common.HexToAddress("0xE452027cdEF746c7Cd3DB31CB700428b16cD8E51"), // sepolia
}
func ContractAddress(chainID uint64) (common.Address, error) {

View File

@ -961,7 +961,7 @@ func (db *Database) updateKeypairClock(tx *sql.Tx, keyUID string, clock uint64)
return err
}
func (db *Database) saveOrUpdateAccounts(tx *sql.Tx, accounts []*Account, updateKeypairClock, isSepoliaEnabled bool) (err error) {
func (db *Database) saveOrUpdateAccounts(tx *sql.Tx, accounts []*Account, updateKeypairClock, isGoerliEnabled bool) (err error) {
if tx == nil {
return errDbTransactionIsNil
}
@ -994,10 +994,10 @@ func (db *Database) saveOrUpdateAccounts(tx *sql.Tx, accounts []*Account, update
}
if acc.TestPreferredChainIDs == "" {
if isSepoliaEnabled {
acc.TestPreferredChainIDs = TestSepoliaPreferredChainIDsDefault
} else {
if isGoerliEnabled {
acc.TestPreferredChainIDs = TestPreferredChainIDsDefault
} else {
acc.TestPreferredChainIDs = TestSepoliaPreferredChainIDsDefault
}
}
}
@ -1090,7 +1090,7 @@ func (db *Database) SaveOrUpdateAccounts(accounts []*Account, updateKeypairClock
if len(accounts) == 0 {
return errors.New("no provided accounts to save/update")
}
isSepoliaEnabled, err := db.GetIsSepoliaEnabled()
isGoerliEnabled, err := db.GetIsGoerliEnabled()
if err != nil {
return err
}
@ -1106,7 +1106,7 @@ func (db *Database) SaveOrUpdateAccounts(accounts []*Account, updateKeypairClock
}
_ = tx.Rollback()
}()
err = db.saveOrUpdateAccounts(tx, accounts, updateKeypairClock, isSepoliaEnabled)
err = db.saveOrUpdateAccounts(tx, accounts, updateKeypairClock, isGoerliEnabled)
return err
}
@ -1119,7 +1119,7 @@ func (db *Database) SaveOrUpdateKeypair(keypair *Keypair) error {
return errDbPassedParameterIsNil
}
isSepoliaEnabled, err := db.GetIsSepoliaEnabled()
isGoerliEnabled, err := db.GetIsGoerliEnabled()
if err != nil {
return err
}
@ -1173,7 +1173,7 @@ func (db *Database) SaveOrUpdateKeypair(keypair *Keypair) error {
if err != nil {
return err
}
return db.saveOrUpdateAccounts(tx, keypair.Accounts, false, isSepoliaEnabled)
return db.saveOrUpdateAccounts(tx, keypair.Accounts, false, isGoerliEnabled)
}
func (db *Database) UpdateKeypairName(keyUID string, name string, clock uint64, updateChatAccountName bool) error {

View File

@ -392,9 +392,9 @@ var (
dBColumnName: "test_networks_enabled",
valueHandler: BoolHandler,
}
IsSepoliaEnabled = SettingField{
reactFieldName: "is-sepolia-enabled?",
dBColumnName: "is_sepolia_enabled",
IsGoerliEnabled = SettingField{
reactFieldName: "is-goerli-enabled?",
dBColumnName: "is_goerli_enabled",
valueHandler: BoolHandler,
}
TokenGroupByCommunity = SettingField{
@ -574,7 +574,7 @@ var (
WalletVisibleTokens,
WebviewAllowPermissionRequests,
ProfileMigrationNeeded,
IsSepoliaEnabled,
IsGoerliEnabled,
TokenGroupByCommunity,
ShowCommunityAssetWhenSendingTokens,
DisplayAssetsBelowBalance,

View File

@ -389,7 +389,7 @@ func (db *Database) GetSettings() (Settings, error) {
profile_pictures_show_to, profile_pictures_visibility, wallet_root_address, wallet_set_up_passed, wallet_visible_tokens,
waku_bloom_filter_mode, webview_allow_permission_requests, current_user_status, send_status_updates, gif_recents,
gif_favorites, opensea_enabled, last_backup, backup_enabled, telemetry_server_url, auto_message_enabled, gif_api_key,
test_networks_enabled, mutual_contact_enabled, profile_migration_needed, is_sepolia_enabled, wallet_token_preferences_group_by_community, url_unfurling_mode,
test_networks_enabled, mutual_contact_enabled, profile_migration_needed, is_goerli_enabled, wallet_token_preferences_group_by_community, url_unfurling_mode,
omit_transfers_history_scan, mnemonic_was_not_shown, wallet_show_community_asset_when_sending_tokens, wallet_display_assets_below_balance,
wallet_display_assets_below_balance_threshold, wallet_collectible_preferences_group_by_collection, wallet_collectible_preferences_group_by_community
FROM
@ -465,7 +465,7 @@ func (db *Database) GetSettings() (Settings, error) {
&s.TestNetworksEnabled,
&s.MutualContactEnabled,
&s.ProfileMigrationNeeded,
&s.IsSepoliaEnabled,
&s.IsGoerliEnabled,
&s.TokenGroupByCommunity,
&s.URLUnfurlingMode,
&s.OmitTransfersHistoryScan,
@ -755,8 +755,8 @@ func (db *Database) GetTestNetworksEnabled() (result bool, err error) {
return result, err
}
func (db *Database) GetIsSepoliaEnabled() (result bool, err error) {
err = db.makeSelectRow(IsSepoliaEnabled).Scan(&result)
func (db *Database) GetIsGoerliEnabled() (result bool, err error) {
err = db.makeSelectRow(IsGoerliEnabled).Scan(&result)
if err == sql.ErrNoRows {
return result, nil
}

View File

@ -36,7 +36,7 @@ type DatabaseSettingsManager interface {
GetEIP1581Address() (rst types.Address, err error)
GetMasterAddress() (rst types.Address, err error)
GetTestNetworksEnabled() (result bool, err error)
GetIsSepoliaEnabled() (result bool, err error)
GetIsGoerliEnabled() (result bool, err error)
GetTokenGroupByCommunity() (result bool, err error)
GetCollectibleGroupByCommunity() (result bool, err error)
GetCollectibleGroupByCollection() (result bool, err error)

View File

@ -216,19 +216,19 @@ func (mr *MockDatabaseSettingsManagerMockRecorder) GetInstalledStickerPacks() *g
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInstalledStickerPacks", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).GetInstalledStickerPacks))
}
// GetIsSepoliaEnabled mocks base method.
func (m *MockDatabaseSettingsManager) GetIsSepoliaEnabled() (bool, error) {
// GetIsGoerliEnabled mocks base method.
func (m *MockDatabaseSettingsManager) GetIsGoerliEnabled() (bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetIsSepoliaEnabled")
ret := m.ctrl.Call(m, "GetIsGoerliEnabled")
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetIsSepoliaEnabled indicates an expected call of GetIsSepoliaEnabled.
func (mr *MockDatabaseSettingsManagerMockRecorder) GetIsSepoliaEnabled() *gomock.Call {
// GetIsGoerliEnabled indicates an expected call of GetIsGoerliEnabled.
func (mr *MockDatabaseSettingsManagerMockRecorder) GetIsGoerliEnabled() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIsSepoliaEnabled", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).GetIsSepoliaEnabled))
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIsGoerliEnabled", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).GetIsGoerliEnabled))
}
// GetMasterAddress mocks base method.

View File

@ -205,7 +205,7 @@ type Settings struct {
GifAPIKey string `json:"gifs/api-key"`
TestNetworksEnabled bool `json:"test-networks-enabled?,omitempty"`
ProfileMigrationNeeded bool `json:"profile-migration-needed,omitempty"`
IsSepoliaEnabled bool `json:"is-sepolia-enabled?,omitempty"`
IsGoerliEnabled bool `json:"is-goerli-enabled?,omitempty"`
TokenGroupByCommunity bool `json:"token-group-by-community?,omitempty"`
ShowCommunityAssetWhenSendingTokens bool `json:"show-community-asset-when-sending-tokens?,omitempty"`
DisplayAssetsBelowBalance bool `json:"display-assets-below-balance?,omitempty"`

View File

@ -231,7 +231,7 @@ func (nm *Manager) GetAll() ([]*params.Network, error) {
}
func (nm *Manager) Get(onlyEnabled bool) ([]*params.Network, error) {
isSepoliaEnabled, err := nm.accountsDB.GetIsSepoliaEnabled()
isGoerliEnabled, err := nm.accountsDB.GetIsGoerliEnabled()
if err != nil {
return nil, err
}
@ -248,7 +248,7 @@ func (nm *Manager) Get(onlyEnabled bool) ([]*params.Network, error) {
var results []*params.Network
for _, network := range networks {
if !isSepoliaEnabled {
if isGoerliEnabled {
found := false
for _, chainID := range SepoliaChainIDs {
if network.ChainID == chainID {
@ -261,7 +261,7 @@ func (nm *Manager) Get(onlyEnabled bool) ([]*params.Network, error) {
}
}
if isSepoliaEnabled {
if !isGoerliEnabled {
found := false
for _, chainID := range GoerliChainIDs {

View File

@ -24,10 +24,10 @@ var initNetworks = []params.Network{
IsTest: false,
Layer: 1,
Enabled: true,
RelatedChainID: 5,
RelatedChainID: 11155111,
},
{
ChainID: 5,
ChainID: 11155111,
ChainName: "Goerli",
RPCURL: "http://goerli.blockscout.com/",
BlockExplorerURL: "https://goerli.etherscan.io/",
@ -100,7 +100,7 @@ func TestGetCombinedNetworks(t *testing.T) {
require.Nil(t, err)
require.Equal(t, 2, len(combinedNetworks))
require.Equal(t, uint64(1), combinedNetworks[0].Prod.ChainID)
require.Equal(t, uint64(5), combinedNetworks[0].Test.ChainID)
require.Equal(t, uint64(11155111), combinedNetworks[0].Test.ChainID)
require.Equal(t, uint64(10), combinedNetworks[1].Prod.ChainID)
require.Nil(t, combinedNetworks[1].Test)
}

View File

@ -366,7 +366,7 @@ func (c *Controller) startSettingsWatcher() {
}
settingChangeCb := func(setting settings.SettingField, value interface{}) {
if setting.Equals(settings.TestNetworksEnabled) || setting.Equals(settings.IsSepoliaEnabled) {
if setting.Equals(settings.TestNetworksEnabled) || setting.Equals(settings.IsGoerliEnabled) {
c.stopPeriodicalOwnershipFetch()
err := c.startPeriodicalOwnershipFetch()
if err != nil {