Skip to content

Commit b1ed4db

Browse files
committed
chore_: reorganize thirdparty dir into categories
1 parent f494d09 commit b1ed4db

28 files changed

+80
-61
lines changed

services/wallet/decoder.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package wallet
22

33
import (
44
"github.com/status-im/status-go/services/wallet/thirdparty"
5-
"github.com/status-im/status-go/services/wallet/thirdparty/fourbyte"
6-
"github.com/status-im/status-go/services/wallet/thirdparty/fourbytegithub"
5+
"github.com/status-im/status-go/services/wallet/thirdparty/decoder/fourbyte"
6+
"github.com/status-im/status-go/services/wallet/thirdparty/decoder/fourbytegithub"
77
)
88

99
type Decoder struct {

services/wallet/service.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ import (
3333
"github.com/status-im/status-go/services/wallet/router"
3434
"github.com/status-im/status-go/services/wallet/router/pathprocessor"
3535
"github.com/status-im/status-go/services/wallet/thirdparty"
36-
"github.com/status-im/status-go/services/wallet/thirdparty/alchemy"
37-
"github.com/status-im/status-go/services/wallet/thirdparty/coingecko"
38-
"github.com/status-im/status-go/services/wallet/thirdparty/cryptocompare"
39-
"github.com/status-im/status-go/services/wallet/thirdparty/opensea"
40-
"github.com/status-im/status-go/services/wallet/thirdparty/rarible"
36+
"github.com/status-im/status-go/services/wallet/thirdparty/collectibles/alchemy"
37+
"github.com/status-im/status-go/services/wallet/thirdparty/collectibles/opensea"
38+
"github.com/status-im/status-go/services/wallet/thirdparty/collectibles/rarible"
39+
"github.com/status-im/status-go/services/wallet/thirdparty/market/coingecko"
40+
"github.com/status-im/status-go/services/wallet/thirdparty/market/cryptocompare"
4141
"github.com/status-im/status-go/services/wallet/token"
4242
"github.com/status-im/status-go/services/wallet/transfer"
4343
"github.com/status-im/status-go/services/wallet/walletevent"

services/wallet/thirdparty/collectible_types.go

+1-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package thirdparty
55
import (
66
"context"
77
"database/sql"
8-
"errors"
98
"fmt"
109
"math/big"
1110

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

18-
var (
19-
ErrChainIDNotSupported = errors.New("chainID not supported")
20-
ErrEndpointNotSupported = errors.New("endpoint not supported")
21-
)
22-
23-
const FetchNoLimit = 0
24-
const FetchFromStartCursor = ""
25-
const FetchFromAnyProvider = ""
26-
2717
type CollectibleProvider interface {
28-
ID() string
29-
IsChainSupported(chainID w_common.ChainID) bool
30-
IsConnected() bool
18+
ChainProvider
3119
}
3220

3321
type ContractID struct {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package thirdparty
2+
3+
//go:generate mockgen -package=mock_thirdparty -source=decoder_types.go -destination=mock/decoder_types.go
4+
5+
type DataParsed struct {
6+
Name string `json:"name"`
7+
ID string `json:"id"`
8+
Inputs map[string]string `json:"inputs"`
9+
Signature string `json:"signature"`
10+
}
11+
12+
type DecoderProvider interface {
13+
Run(data string) (*DataParsed, error)
14+
}
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package thirdparty
2+
3+
//go:generate mockgen -package=mock_thirdparty -source=market_types.go -destination=mock/market_types.go
4+
5+
type HistoricalPrice struct {
6+
Timestamp int64 `json:"time"`
7+
Value float64 `json:"close"`
8+
}
9+
10+
type TokenMarketValues struct {
11+
MKTCAP float64 `json:"MKTCAP"`
12+
HIGHDAY float64 `json:"HIGHDAY"`
13+
LOWDAY float64 `json:"LOWDAY"`
14+
CHANGEPCTHOUR float64 `json:"CHANGEPCTHOUR"`
15+
CHANGEPCTDAY float64 `json:"CHANGEPCTDAY"`
16+
CHANGEPCT24HOUR float64 `json:"CHANGEPCT24HOUR"`
17+
CHANGE24HOUR float64 `json:"CHANGE24HOUR"`
18+
}
19+
20+
type TokenDetails struct {
21+
ID string `json:"Id"`
22+
Name string `json:"Name"`
23+
Symbol string `json:"Symbol"`
24+
Description string `json:"Description"`
25+
TotalCoinsMined float64 `json:"TotalCoinsMined"`
26+
AssetLaunchDate string `json:"AssetLaunchDate"`
27+
AssetWhitepaperURL string `json:"AssetWhitepaperUrl"`
28+
AssetWebsiteURL string `json:"AssetWebsiteUrl"`
29+
BuiltOn string `json:"BuiltOn"`
30+
SmartContractAddress string `json:"SmartContractAddress"`
31+
}
32+
33+
type MarketDataProvider interface {
34+
ID() string
35+
FetchPrices(symbols []string, currencies []string) (map[string]map[string]float64, error)
36+
FetchHistoricalDailyPrices(symbol string, currency string, limit int, allData bool, aggregate int) ([]HistoricalPrice, error)
37+
FetchHistoricalHourlyPrices(symbol string, currency string, limit int, aggregate int) ([]HistoricalPrice, error)
38+
FetchTokenMarketValues(symbols []string, currency string) (map[string]TokenMarketValues, error)
39+
FetchTokenDetails(symbols []string) (map[string]TokenDetails, error)
40+
}

services/wallet/thirdparty/types.go

+17-40
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,27 @@ package thirdparty
22

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

5-
type HistoricalPrice struct {
6-
Timestamp int64 `json:"time"`
7-
Value float64 `json:"close"`
8-
}
5+
import (
6+
"errors"
97

10-
type TokenMarketValues struct {
11-
MKTCAP float64 `json:"MKTCAP"`
12-
HIGHDAY float64 `json:"HIGHDAY"`
13-
LOWDAY float64 `json:"LOWDAY"`
14-
CHANGEPCTHOUR float64 `json:"CHANGEPCTHOUR"`
15-
CHANGEPCTDAY float64 `json:"CHANGEPCTDAY"`
16-
CHANGEPCT24HOUR float64 `json:"CHANGEPCT24HOUR"`
17-
CHANGE24HOUR float64 `json:"CHANGE24HOUR"`
18-
}
8+
w_common "github.com/status-im/status-go/services/wallet/common"
9+
)
1910

20-
type TokenDetails struct {
21-
ID string `json:"Id"`
22-
Name string `json:"Name"`
23-
Symbol string `json:"Symbol"`
24-
Description string `json:"Description"`
25-
TotalCoinsMined float64 `json:"TotalCoinsMined"`
26-
AssetLaunchDate string `json:"AssetLaunchDate"`
27-
AssetWhitepaperURL string `json:"AssetWhitepaperUrl"`
28-
AssetWebsiteURL string `json:"AssetWebsiteUrl"`
29-
BuiltOn string `json:"BuiltOn"`
30-
SmartContractAddress string `json:"SmartContractAddress"`
31-
}
11+
var (
12+
ErrChainIDNotSupported = errors.New("chainID not supported")
13+
ErrEndpointNotSupported = errors.New("endpoint not supported")
14+
)
3215

33-
type MarketDataProvider interface {
34-
ID() string
35-
FetchPrices(symbols []string, currencies []string) (map[string]map[string]float64, error)
36-
FetchHistoricalDailyPrices(symbol string, currency string, limit int, allData bool, aggregate int) ([]HistoricalPrice, error)
37-
FetchHistoricalHourlyPrices(symbol string, currency string, limit int, aggregate int) ([]HistoricalPrice, error)
38-
FetchTokenMarketValues(symbols []string, currency string) (map[string]TokenMarketValues, error)
39-
FetchTokenDetails(symbols []string) (map[string]TokenDetails, error)
40-
}
16+
const FetchNoLimit = 0
17+
const FetchFromStartCursor = ""
18+
const FetchFromAnyProvider = ""
4119

42-
type DataParsed struct {
43-
Name string `json:"name"`
44-
ID string `json:"id"`
45-
Inputs map[string]string `json:"inputs"`
46-
Signature string `json:"signature"`
20+
type Provider interface {
21+
ID() string
22+
IsConnected() bool
4723
}
4824

49-
type DecoderProvider interface {
50-
Run(data string) (*DataParsed, error)
25+
type ChainProvider interface {
26+
Provider
27+
IsChainSupported(chainID w_common.ChainID) bool
5128
}

tests-unit-network/cryptocompare/cryptocompare_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/status-im/status-go/params"
88
mock_network "github.com/status-im/status-go/rpc/network/mock"
99
w_common "github.com/status-im/status-go/services/wallet/common"
10-
"github.com/status-im/status-go/services/wallet/thirdparty/cryptocompare"
10+
"github.com/status-im/status-go/services/wallet/thirdparty/market/cryptocompare"
1111
"github.com/status-im/status-go/services/wallet/token"
1212
"github.com/status-im/status-go/t/helpers"
1313
"github.com/status-im/status-go/walletdatabase"

0 commit comments

Comments
 (0)