feat: sepolia default
This commit is contained in:
parent
23ee898754
commit
972a4f9df9
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE settings ADD COLUMN is_goerli_enabled BOOLEAN NOT NULL DEFAULT FALSE;
|
|
@ -9,8 +9,9 @@ import (
|
||||||
var errorNotAvailableOnChainID = errors.New("not available for chainID")
|
var errorNotAvailableOnChainID = errors.New("not available for chainID")
|
||||||
|
|
||||||
var contractAddressByChainID = map[uint64]common.Address{
|
var contractAddressByChainID = map[uint64]common.Address{
|
||||||
1: common.HexToAddress("0x744d70fdbe2ba4cf95131626614a1763df805b9e"), // mainnet
|
1: common.HexToAddress("0x744d70fdbe2ba4cf95131626614a1763df805b9e"), // mainnet
|
||||||
5: common.HexToAddress("0x3d6afaa395c31fcd391fe3d562e75fe9e8ec7e6a"), // goerli
|
5: common.HexToAddress("0x3d6afaa395c31fcd391fe3d562e75fe9e8ec7e6a"), // goerli
|
||||||
|
11155111: common.HexToAddress("0xE452027cdEF746c7Cd3DB31CB700428b16cD8E51"), // sepolia
|
||||||
}
|
}
|
||||||
|
|
||||||
func ContractAddress(chainID uint64) (common.Address, error) {
|
func ContractAddress(chainID uint64) (common.Address, error) {
|
||||||
|
|
|
@ -961,7 +961,7 @@ func (db *Database) updateKeypairClock(tx *sql.Tx, keyUID string, clock uint64)
|
||||||
return err
|
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 {
|
if tx == nil {
|
||||||
return errDbTransactionIsNil
|
return errDbTransactionIsNil
|
||||||
}
|
}
|
||||||
|
@ -994,10 +994,10 @@ func (db *Database) saveOrUpdateAccounts(tx *sql.Tx, accounts []*Account, update
|
||||||
}
|
}
|
||||||
|
|
||||||
if acc.TestPreferredChainIDs == "" {
|
if acc.TestPreferredChainIDs == "" {
|
||||||
if isSepoliaEnabled {
|
if isGoerliEnabled {
|
||||||
acc.TestPreferredChainIDs = TestSepoliaPreferredChainIDsDefault
|
|
||||||
} else {
|
|
||||||
acc.TestPreferredChainIDs = TestPreferredChainIDsDefault
|
acc.TestPreferredChainIDs = TestPreferredChainIDsDefault
|
||||||
|
} else {
|
||||||
|
acc.TestPreferredChainIDs = TestSepoliaPreferredChainIDsDefault
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1090,7 +1090,7 @@ func (db *Database) SaveOrUpdateAccounts(accounts []*Account, updateKeypairClock
|
||||||
if len(accounts) == 0 {
|
if len(accounts) == 0 {
|
||||||
return errors.New("no provided accounts to save/update")
|
return errors.New("no provided accounts to save/update")
|
||||||
}
|
}
|
||||||
isSepoliaEnabled, err := db.GetIsSepoliaEnabled()
|
isGoerliEnabled, err := db.GetIsGoerliEnabled()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1106,7 +1106,7 @@ func (db *Database) SaveOrUpdateAccounts(accounts []*Account, updateKeypairClock
|
||||||
}
|
}
|
||||||
_ = tx.Rollback()
|
_ = tx.Rollback()
|
||||||
}()
|
}()
|
||||||
err = db.saveOrUpdateAccounts(tx, accounts, updateKeypairClock, isSepoliaEnabled)
|
err = db.saveOrUpdateAccounts(tx, accounts, updateKeypairClock, isGoerliEnabled)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1119,7 +1119,7 @@ func (db *Database) SaveOrUpdateKeypair(keypair *Keypair) error {
|
||||||
return errDbPassedParameterIsNil
|
return errDbPassedParameterIsNil
|
||||||
}
|
}
|
||||||
|
|
||||||
isSepoliaEnabled, err := db.GetIsSepoliaEnabled()
|
isGoerliEnabled, err := db.GetIsGoerliEnabled()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1173,7 +1173,7 @@ func (db *Database) SaveOrUpdateKeypair(keypair *Keypair) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
func (db *Database) UpdateKeypairName(keyUID string, name string, clock uint64, updateChatAccountName bool) error {
|
||||||
|
|
|
@ -392,9 +392,9 @@ var (
|
||||||
dBColumnName: "test_networks_enabled",
|
dBColumnName: "test_networks_enabled",
|
||||||
valueHandler: BoolHandler,
|
valueHandler: BoolHandler,
|
||||||
}
|
}
|
||||||
IsSepoliaEnabled = SettingField{
|
IsGoerliEnabled = SettingField{
|
||||||
reactFieldName: "is-sepolia-enabled?",
|
reactFieldName: "is-goerli-enabled?",
|
||||||
dBColumnName: "is_sepolia_enabled",
|
dBColumnName: "is_goerli_enabled",
|
||||||
valueHandler: BoolHandler,
|
valueHandler: BoolHandler,
|
||||||
}
|
}
|
||||||
TokenGroupByCommunity = SettingField{
|
TokenGroupByCommunity = SettingField{
|
||||||
|
@ -574,7 +574,7 @@ var (
|
||||||
WalletVisibleTokens,
|
WalletVisibleTokens,
|
||||||
WebviewAllowPermissionRequests,
|
WebviewAllowPermissionRequests,
|
||||||
ProfileMigrationNeeded,
|
ProfileMigrationNeeded,
|
||||||
IsSepoliaEnabled,
|
IsGoerliEnabled,
|
||||||
TokenGroupByCommunity,
|
TokenGroupByCommunity,
|
||||||
ShowCommunityAssetWhenSendingTokens,
|
ShowCommunityAssetWhenSendingTokens,
|
||||||
DisplayAssetsBelowBalance,
|
DisplayAssetsBelowBalance,
|
||||||
|
|
|
@ -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,
|
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,
|
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,
|
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,
|
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
|
wallet_display_assets_below_balance_threshold, wallet_collectible_preferences_group_by_collection, wallet_collectible_preferences_group_by_community
|
||||||
FROM
|
FROM
|
||||||
|
@ -465,7 +465,7 @@ func (db *Database) GetSettings() (Settings, error) {
|
||||||
&s.TestNetworksEnabled,
|
&s.TestNetworksEnabled,
|
||||||
&s.MutualContactEnabled,
|
&s.MutualContactEnabled,
|
||||||
&s.ProfileMigrationNeeded,
|
&s.ProfileMigrationNeeded,
|
||||||
&s.IsSepoliaEnabled,
|
&s.IsGoerliEnabled,
|
||||||
&s.TokenGroupByCommunity,
|
&s.TokenGroupByCommunity,
|
||||||
&s.URLUnfurlingMode,
|
&s.URLUnfurlingMode,
|
||||||
&s.OmitTransfersHistoryScan,
|
&s.OmitTransfersHistoryScan,
|
||||||
|
@ -755,8 +755,8 @@ func (db *Database) GetTestNetworksEnabled() (result bool, err error) {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) GetIsSepoliaEnabled() (result bool, err error) {
|
func (db *Database) GetIsGoerliEnabled() (result bool, err error) {
|
||||||
err = db.makeSelectRow(IsSepoliaEnabled).Scan(&result)
|
err = db.makeSelectRow(IsGoerliEnabled).Scan(&result)
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ type DatabaseSettingsManager interface {
|
||||||
GetEIP1581Address() (rst types.Address, err error)
|
GetEIP1581Address() (rst types.Address, err error)
|
||||||
GetMasterAddress() (rst types.Address, err error)
|
GetMasterAddress() (rst types.Address, err error)
|
||||||
GetTestNetworksEnabled() (result bool, err error)
|
GetTestNetworksEnabled() (result bool, err error)
|
||||||
GetIsSepoliaEnabled() (result bool, err error)
|
GetIsGoerliEnabled() (result bool, err error)
|
||||||
GetTokenGroupByCommunity() (result bool, err error)
|
GetTokenGroupByCommunity() (result bool, err error)
|
||||||
GetCollectibleGroupByCommunity() (result bool, err error)
|
GetCollectibleGroupByCommunity() (result bool, err error)
|
||||||
GetCollectibleGroupByCollection() (result bool, err error)
|
GetCollectibleGroupByCollection() (result bool, err error)
|
||||||
|
|
|
@ -216,19 +216,19 @@ func (mr *MockDatabaseSettingsManagerMockRecorder) GetInstalledStickerPacks() *g
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInstalledStickerPacks", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).GetInstalledStickerPacks))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInstalledStickerPacks", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).GetInstalledStickerPacks))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIsSepoliaEnabled mocks base method.
|
// GetIsGoerliEnabled mocks base method.
|
||||||
func (m *MockDatabaseSettingsManager) GetIsSepoliaEnabled() (bool, error) {
|
func (m *MockDatabaseSettingsManager) GetIsGoerliEnabled() (bool, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "GetIsSepoliaEnabled")
|
ret := m.ctrl.Call(m, "GetIsGoerliEnabled")
|
||||||
ret0, _ := ret[0].(bool)
|
ret0, _ := ret[0].(bool)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIsSepoliaEnabled indicates an expected call of GetIsSepoliaEnabled.
|
// GetIsGoerliEnabled indicates an expected call of GetIsGoerliEnabled.
|
||||||
func (mr *MockDatabaseSettingsManagerMockRecorder) GetIsSepoliaEnabled() *gomock.Call {
|
func (mr *MockDatabaseSettingsManagerMockRecorder) GetIsGoerliEnabled() *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
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.
|
// GetMasterAddress mocks base method.
|
||||||
|
|
|
@ -205,7 +205,7 @@ type Settings struct {
|
||||||
GifAPIKey string `json:"gifs/api-key"`
|
GifAPIKey string `json:"gifs/api-key"`
|
||||||
TestNetworksEnabled bool `json:"test-networks-enabled?,omitempty"`
|
TestNetworksEnabled bool `json:"test-networks-enabled?,omitempty"`
|
||||||
ProfileMigrationNeeded bool `json:"profile-migration-needed,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"`
|
TokenGroupByCommunity bool `json:"token-group-by-community?,omitempty"`
|
||||||
ShowCommunityAssetWhenSendingTokens bool `json:"show-community-asset-when-sending-tokens?,omitempty"`
|
ShowCommunityAssetWhenSendingTokens bool `json:"show-community-asset-when-sending-tokens?,omitempty"`
|
||||||
DisplayAssetsBelowBalance bool `json:"display-assets-below-balance?,omitempty"`
|
DisplayAssetsBelowBalance bool `json:"display-assets-below-balance?,omitempty"`
|
||||||
|
|
|
@ -231,7 +231,7 @@ func (nm *Manager) GetAll() ([]*params.Network, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *Manager) Get(onlyEnabled bool) ([]*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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ func (nm *Manager) Get(onlyEnabled bool) ([]*params.Network, error) {
|
||||||
|
|
||||||
var results []*params.Network
|
var results []*params.Network
|
||||||
for _, network := range networks {
|
for _, network := range networks {
|
||||||
if !isSepoliaEnabled {
|
if isGoerliEnabled {
|
||||||
found := false
|
found := false
|
||||||
for _, chainID := range SepoliaChainIDs {
|
for _, chainID := range SepoliaChainIDs {
|
||||||
if network.ChainID == chainID {
|
if network.ChainID == chainID {
|
||||||
|
@ -261,7 +261,7 @@ func (nm *Manager) Get(onlyEnabled bool) ([]*params.Network, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if isSepoliaEnabled {
|
if !isGoerliEnabled {
|
||||||
found := false
|
found := false
|
||||||
|
|
||||||
for _, chainID := range GoerliChainIDs {
|
for _, chainID := range GoerliChainIDs {
|
||||||
|
|
|
@ -24,10 +24,10 @@ var initNetworks = []params.Network{
|
||||||
IsTest: false,
|
IsTest: false,
|
||||||
Layer: 1,
|
Layer: 1,
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
RelatedChainID: 5,
|
RelatedChainID: 11155111,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ChainID: 5,
|
ChainID: 11155111,
|
||||||
ChainName: "Goerli",
|
ChainName: "Goerli",
|
||||||
RPCURL: "http://goerli.blockscout.com/",
|
RPCURL: "http://goerli.blockscout.com/",
|
||||||
BlockExplorerURL: "https://goerli.etherscan.io/",
|
BlockExplorerURL: "https://goerli.etherscan.io/",
|
||||||
|
@ -100,7 +100,7 @@ func TestGetCombinedNetworks(t *testing.T) {
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, 2, len(combinedNetworks))
|
require.Equal(t, 2, len(combinedNetworks))
|
||||||
require.Equal(t, uint64(1), combinedNetworks[0].Prod.ChainID)
|
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.Equal(t, uint64(10), combinedNetworks[1].Prod.ChainID)
|
||||||
require.Nil(t, combinedNetworks[1].Test)
|
require.Nil(t, combinedNetworks[1].Test)
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,7 +366,7 @@ func (c *Controller) startSettingsWatcher() {
|
||||||
}
|
}
|
||||||
|
|
||||||
settingChangeCb := func(setting settings.SettingField, value interface{}) {
|
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()
|
c.stopPeriodicalOwnershipFetch()
|
||||||
err := c.startPeriodicalOwnershipFetch()
|
err := c.startPeriodicalOwnershipFetch()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue