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

chore_: reorganize thirdparty dir into categories #6349

Merged
merged 1 commit into from
Feb 20, 2025
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
4 changes: 2 additions & 2 deletions services/wallet/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package wallet

import (
"github.com/status-im/status-go/services/wallet/thirdparty"
"github.com/status-im/status-go/services/wallet/thirdparty/fourbyte"
"github.com/status-im/status-go/services/wallet/thirdparty/fourbytegithub"
"github.com/status-im/status-go/services/wallet/thirdparty/decoder/fourbyte"
"github.com/status-im/status-go/services/wallet/thirdparty/decoder/fourbytegithub"
)

type Decoder struct {
Expand Down
10 changes: 5 additions & 5 deletions services/wallet/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ import (
"github.com/status-im/status-go/services/wallet/router"
"github.com/status-im/status-go/services/wallet/router/pathprocessor"
"github.com/status-im/status-go/services/wallet/thirdparty"
"github.com/status-im/status-go/services/wallet/thirdparty/alchemy"
"github.com/status-im/status-go/services/wallet/thirdparty/coingecko"
"github.com/status-im/status-go/services/wallet/thirdparty/cryptocompare"
"github.com/status-im/status-go/services/wallet/thirdparty/opensea"
"github.com/status-im/status-go/services/wallet/thirdparty/rarible"
"github.com/status-im/status-go/services/wallet/thirdparty/collectibles/alchemy"
"github.com/status-im/status-go/services/wallet/thirdparty/collectibles/opensea"
"github.com/status-im/status-go/services/wallet/thirdparty/collectibles/rarible"
"github.com/status-im/status-go/services/wallet/thirdparty/market/coingecko"
"github.com/status-im/status-go/services/wallet/thirdparty/market/cryptocompare"
"github.com/status-im/status-go/services/wallet/token"
"github.com/status-im/status-go/services/wallet/transfer"
"github.com/status-im/status-go/services/wallet/walletevent"
Expand Down
14 changes: 1 addition & 13 deletions services/wallet/thirdparty/collectible_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package thirdparty
import (
"context"
"database/sql"
"errors"
"fmt"
"math/big"

Expand All @@ -15,19 +14,8 @@ import (
w_common "github.com/status-im/status-go/services/wallet/common"
)

var (
ErrChainIDNotSupported = errors.New("chainID not supported")
ErrEndpointNotSupported = errors.New("endpoint not supported")
)

const FetchNoLimit = 0
const FetchFromStartCursor = ""
const FetchFromAnyProvider = ""

type CollectibleProvider interface {
ID() string
IsChainSupported(chainID w_common.ChainID) bool
IsConnected() bool
ChainProvider
}

type ContractID struct {
Expand Down
14 changes: 14 additions & 0 deletions services/wallet/thirdparty/decoder_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package thirdparty

//go:generate mockgen -package=mock_thirdparty -source=decoder_types.go -destination=mock/decoder_types.go

type DataParsed struct {
Name string `json:"name"`
ID string `json:"id"`
Inputs map[string]string `json:"inputs"`
Signature string `json:"signature"`
}

type DecoderProvider interface {
Run(data string) (*DataParsed, error)
}
40 changes: 40 additions & 0 deletions services/wallet/thirdparty/market_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package thirdparty

//go:generate mockgen -package=mock_thirdparty -source=market_types.go -destination=mock/market_types.go

type HistoricalPrice struct {
Timestamp int64 `json:"time"`
Value float64 `json:"close"`
}

type TokenMarketValues struct {
MKTCAP float64 `json:"MKTCAP"`
HIGHDAY float64 `json:"HIGHDAY"`
LOWDAY float64 `json:"LOWDAY"`
CHANGEPCTHOUR float64 `json:"CHANGEPCTHOUR"`
CHANGEPCTDAY float64 `json:"CHANGEPCTDAY"`
CHANGEPCT24HOUR float64 `json:"CHANGEPCT24HOUR"`
CHANGE24HOUR float64 `json:"CHANGE24HOUR"`
}

type TokenDetails struct {
ID string `json:"Id"`
Name string `json:"Name"`
Symbol string `json:"Symbol"`
Description string `json:"Description"`
TotalCoinsMined float64 `json:"TotalCoinsMined"`
AssetLaunchDate string `json:"AssetLaunchDate"`
AssetWhitepaperURL string `json:"AssetWhitepaperUrl"`
AssetWebsiteURL string `json:"AssetWebsiteUrl"`
BuiltOn string `json:"BuiltOn"`
SmartContractAddress string `json:"SmartContractAddress"`
}

type MarketDataProvider interface {
ID() string
FetchPrices(symbols []string, currencies []string) (map[string]map[string]float64, error)
FetchHistoricalDailyPrices(symbol string, currency string, limit int, allData bool, aggregate int) ([]HistoricalPrice, error)
FetchHistoricalHourlyPrices(symbol string, currency string, limit int, aggregate int) ([]HistoricalPrice, error)
FetchTokenMarketValues(symbols []string, currency string) (map[string]TokenMarketValues, error)
FetchTokenDetails(symbols []string) (map[string]TokenDetails, error)
}
57 changes: 17 additions & 40 deletions services/wallet/thirdparty/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,27 @@ package thirdparty

//go:generate mockgen -package=mock_thirdparty -source=types.go -destination=mock/types.go

type HistoricalPrice struct {
Timestamp int64 `json:"time"`
Value float64 `json:"close"`
}
import (
"errors"

type TokenMarketValues struct {
MKTCAP float64 `json:"MKTCAP"`
HIGHDAY float64 `json:"HIGHDAY"`
LOWDAY float64 `json:"LOWDAY"`
CHANGEPCTHOUR float64 `json:"CHANGEPCTHOUR"`
CHANGEPCTDAY float64 `json:"CHANGEPCTDAY"`
CHANGEPCT24HOUR float64 `json:"CHANGEPCT24HOUR"`
CHANGE24HOUR float64 `json:"CHANGE24HOUR"`
}
w_common "github.com/status-im/status-go/services/wallet/common"
)

type TokenDetails struct {
ID string `json:"Id"`
Name string `json:"Name"`
Symbol string `json:"Symbol"`
Description string `json:"Description"`
TotalCoinsMined float64 `json:"TotalCoinsMined"`
AssetLaunchDate string `json:"AssetLaunchDate"`
AssetWhitepaperURL string `json:"AssetWhitepaperUrl"`
AssetWebsiteURL string `json:"AssetWebsiteUrl"`
BuiltOn string `json:"BuiltOn"`
SmartContractAddress string `json:"SmartContractAddress"`
}
var (
ErrChainIDNotSupported = errors.New("chainID not supported")
ErrEndpointNotSupported = errors.New("endpoint not supported")
)

type MarketDataProvider interface {
ID() string
FetchPrices(symbols []string, currencies []string) (map[string]map[string]float64, error)
FetchHistoricalDailyPrices(symbol string, currency string, limit int, allData bool, aggregate int) ([]HistoricalPrice, error)
FetchHistoricalHourlyPrices(symbol string, currency string, limit int, aggregate int) ([]HistoricalPrice, error)
FetchTokenMarketValues(symbols []string, currency string) (map[string]TokenMarketValues, error)
FetchTokenDetails(symbols []string) (map[string]TokenDetails, error)
}
const FetchNoLimit = 0
const FetchFromStartCursor = ""
const FetchFromAnyProvider = ""

type DataParsed struct {
Name string `json:"name"`
ID string `json:"id"`
Inputs map[string]string `json:"inputs"`
Signature string `json:"signature"`
type Provider interface {
ID() string
IsConnected() bool
}

type DecoderProvider interface {
Run(data string) (*DataParsed, error)
type ChainProvider interface {
Provider
IsChainSupported(chainID w_common.ChainID) bool
}
2 changes: 1 addition & 1 deletion tests-unit-network/cryptocompare/cryptocompare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/status-im/status-go/params"
mock_network "github.com/status-im/status-go/rpc/network/mock"
w_common "github.com/status-im/status-go/services/wallet/common"
"github.com/status-im/status-go/services/wallet/thirdparty/cryptocompare"
"github.com/status-im/status-go/services/wallet/thirdparty/market/cryptocompare"
"github.com/status-im/status-go/services/wallet/token"
"github.com/status-im/status-go/t/helpers"
"github.com/status-im/status-go/walletdatabase"
Expand Down
Loading