Skip to content

Commit

Permalink
feat: run go mod tiny/vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
alaibe committed Oct 26, 2022
1 parent fc836e4 commit 63eb3d7
Show file tree
Hide file tree
Showing 2,388 changed files with 21 additions and 163,589 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ require (
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/karalabe/usb v0.0.2 // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/klauspost/cpuid/v2 v2.0.14 // indirect
github.com/koron/go-ssdp v0.0.3 // indirect
Expand Down Expand Up @@ -208,7 +207,6 @@ require (
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/peterh/liner v1.2.1 // indirect
github.com/pion/datachannel v1.5.2 // indirect
github.com/pion/dtls/v2 v2.1.2 // indirect
github.com/pion/ice/v2 v2.1.20 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,6 @@ github.com/k0kubun/pp v2.3.0+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3t
github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d/go.mod h1:P2viExyCEfeWGU259JnaQ34Inuec4R38JCyBx2edgD0=
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/karalabe/usb v0.0.0-20210518091819-4ea20957c210/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/karalabe/usb v0.0.2 h1:M6QQBNxF+CQ8OFvxrT90BA0qBOXymndZnk5q235mFc4=
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
Expand Down Expand Up @@ -1799,7 +1798,6 @@ github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/peterh/liner v1.2.1 h1:O4BlKaq/LWu6VRWmol4ByWfzx6MfXc5Op5HETyIy5yg=
github.com/peterh/liner v1.2.1/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
Expand Down
2 changes: 1 addition & 1 deletion services/wallet/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type Service struct {
accountsDB *accounts.Database
rpcClient *rpc.Client
savedAddressesManager *SavedAddressesManager
tokenManager *token.TokenManager
tokenManager *token.Manager
transactionManager *TransactionManager
cryptoOnRampManager *CryptoOnRampManager
transferController *transfer.Controller
Expand Down
36 changes: 18 additions & 18 deletions services/wallet/token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (t *Token) IsNative() bool {
return t.Address == nativeChainAddress
}

type TokenManager struct {
type Manager struct {
db *sql.DB
RPCClient *rpc.Client
networkManager *network.Manager
Expand All @@ -50,8 +50,8 @@ func NewTokenManager(
db *sql.DB,
RPCClient *rpc.Client,
networkManager *network.Manager,
) *TokenManager {
tokenManager := &TokenManager{db, RPCClient, networkManager}
) *Manager {
tokenManager := &Manager{db, RPCClient, networkManager}
// Check the networks' custom tokens to see if we must update the tokenStore
networks := networkManager.GetConfiguredNetworks()
for _, network := range networks {
Expand All @@ -75,7 +75,7 @@ func NewTokenManager(
return tokenManager
}

func (tm *TokenManager) FindToken(network *params.Network, tokenSymbol string) *Token {
func (tm *Manager) FindToken(network *params.Network, tokenSymbol string) *Token {
if tokenSymbol == network.NativeCurrencySymbol {
return &Token{
Address: common.HexToAddress("0x"),
Expand All @@ -102,7 +102,7 @@ func (tm *TokenManager) FindToken(network *params.Network, tokenSymbol string) *
return nil
}

func (tm *TokenManager) FindSNT(chainID uint64) *Token {
func (tm *Manager) FindSNT(chainID uint64) *Token {
tokensMap, ok := tokenStore[chainID]
if !ok {
return nil
Expand All @@ -117,7 +117,7 @@ func (tm *TokenManager) FindSNT(chainID uint64) *Token {
return nil
}

func (tm *TokenManager) GetTokens(chainID uint64) ([]*Token, error) {
func (tm *Manager) GetTokens(chainID uint64) ([]*Token, error) {
tokensMap, ok := tokenStore[chainID]
if !ok {
return nil, errors.New("no tokens for this network")
Expand All @@ -132,7 +132,7 @@ func (tm *TokenManager) GetTokens(chainID uint64) ([]*Token, error) {
return res, nil
}

func (tm *TokenManager) DiscoverToken(ctx context.Context, chainID uint64, address common.Address) (*Token, error) {
func (tm *Manager) DiscoverToken(ctx context.Context, chainID uint64, address common.Address) (*Token, error) {
backend, err := tm.RPCClient.EthClient(chainID)
if err != nil {
return nil, err
Expand Down Expand Up @@ -171,7 +171,7 @@ func (tm *TokenManager) DiscoverToken(ctx context.Context, chainID uint64, addre
}, nil
}

func (tm *TokenManager) GetCustoms() ([]*Token, error) {
func (tm *Manager) GetCustoms() ([]*Token, error) {
rows, err := tm.db.Query("SELECT address, name, symbol, decimals, color, network_id FROM tokens")
if err != nil {
return nil, err
Expand All @@ -192,7 +192,7 @@ func (tm *TokenManager) GetCustoms() ([]*Token, error) {
return rst, nil
}

func (tm *TokenManager) GetCustomsByChainID(chainID uint64) ([]*Token, error) {
func (tm *Manager) GetCustomsByChainID(chainID uint64) ([]*Token, error) {
rows, err := tm.db.Query("SELECT address, name, symbol, decimals, color, network_id FROM tokens where network_id=?", chainID)
if err != nil {
return nil, err
Expand All @@ -213,7 +213,7 @@ func (tm *TokenManager) GetCustomsByChainID(chainID uint64) ([]*Token, error) {
return rst, nil
}

func (tm *TokenManager) IsTokenVisible(chainID uint64, address common.Address) (bool, error) {
func (tm *Manager) IsTokenVisible(chainID uint64, address common.Address) (bool, error) {
rows, err := tm.db.Query("SELECT chain_id, address FROM visible_tokens WHERE chain_id = ? AND address = ?", chainID, address)
if err != nil {
return false, err
Expand All @@ -223,7 +223,7 @@ func (tm *TokenManager) IsTokenVisible(chainID uint64, address common.Address) (
return rows.Next(), nil
}

func (tm *TokenManager) Toggle(chainID uint64, address common.Address) error {
func (tm *Manager) Toggle(chainID uint64, address common.Address) error {
isVisible, err := tm.IsTokenVisible(chainID, address)
if err != nil {
return err
Expand All @@ -244,7 +244,7 @@ func (tm *TokenManager) Toggle(chainID uint64, address common.Address) error {
return err
}

func (tm *TokenManager) GetVisible(chainIDs []uint64) (map[uint64][]*Token, error) {
func (tm *Manager) GetVisible(chainIDs []uint64) (map[uint64][]*Token, error) {
customTokens, err := tm.GetCustoms()
if err != nil {
return nil, err
Expand Down Expand Up @@ -312,7 +312,7 @@ func (tm *TokenManager) GetVisible(chainIDs []uint64) (map[uint64][]*Token, erro
return rst, nil
}

func (tm *TokenManager) UpsertCustom(token Token) error {
func (tm *Manager) UpsertCustom(token Token) error {
insert, err := tm.db.Prepare("INSERT OR REPLACE INTO TOKENS (network_id, address, name, symbol, decimals, color) VALUES (?, ?, ?, ?, ?, ?)")
if err != nil {
return err
Expand All @@ -321,12 +321,12 @@ func (tm *TokenManager) UpsertCustom(token Token) error {
return err
}

func (tm *TokenManager) DeleteCustom(chainID uint64, address common.Address) error {
func (tm *Manager) DeleteCustom(chainID uint64, address common.Address) error {
_, err := tm.db.Exec(`DELETE FROM TOKENS WHERE address = ? and network_id = ?`, address, chainID)
return err
}

func (tm *TokenManager) GetTokenBalance(ctx context.Context, client *chain.Client, account common.Address, token common.Address) (*big.Int, error) {
func (tm *Manager) GetTokenBalance(ctx context.Context, client *chain.Client, account common.Address, token common.Address) (*big.Int, error) {
caller, err := ierc20.NewIERC20Caller(token, client)
if err != nil {
return nil, err
Expand All @@ -337,19 +337,19 @@ func (tm *TokenManager) GetTokenBalance(ctx context.Context, client *chain.Clien
}, account)
}

func (tm *TokenManager) GetChainBalance(ctx context.Context, client *chain.Client, account common.Address) (*big.Int, error) {
func (tm *Manager) GetChainBalance(ctx context.Context, client *chain.Client, account common.Address) (*big.Int, error) {
return client.BalanceAt(ctx, account, nil)
}

func (tm *TokenManager) GetBalance(ctx context.Context, client *chain.Client, account common.Address, token common.Address) (*big.Int, error) {
func (tm *Manager) GetBalance(ctx context.Context, client *chain.Client, account common.Address, token common.Address) (*big.Int, error) {
if token == nativeChainAddress {
return tm.GetChainBalance(ctx, client, account)
}

return tm.GetTokenBalance(ctx, client, account, token)
}

func (tm *TokenManager) GetBalances(parent context.Context, clients []*chain.Client, accounts, tokens []common.Address) (map[common.Address]map[common.Address]*hexutil.Big, error) {
func (tm *Manager) GetBalances(parent context.Context, clients []*chain.Client, accounts, tokens []common.Address) (map[common.Address]map[common.Address]*hexutil.Big, error) {
var (
group = async.NewAtomicGroup(parent)
mu sync.Mutex
Expand Down
4 changes: 2 additions & 2 deletions services/wallet/token/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import (
"github.com/status-im/status-go/sqlite"
)

func setupTestTokenDB(t *testing.T) (*TokenManager, func()) {
func setupTestTokenDB(t *testing.T) (*Manager, func()) {
tmpfile, err := ioutil.TempFile("", "wallet-token-tests-")
require.NoError(t, err)
db, err := appdatabase.InitializeDB(tmpfile.Name(), "wallet-token-tests", sqlite.ReducedKDFIterationsNumber)
require.NoError(t, err)
return &TokenManager{db, nil, nil}, func() {
return &Manager{db, nil, nil}, func() {
require.NoError(t, db.Close())
require.NoError(t, os.Remove(tmpfile.Name()))
}
Expand Down
Loading

0 comments on commit 63eb3d7

Please sign in to comment.