Skip to content

Commit

Permalink
chore_: reorganize thirdparty dir into categories
Browse files Browse the repository at this point in the history
  • Loading branch information
dlipicar committed Feb 17, 2025
1 parent b2cd7bd commit edf0768
Show file tree
Hide file tree
Showing 27 changed files with 79 additions and 60 deletions.
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
File renamed without changes.
File renamed without changes.
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=types.go -destination=mock/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=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
}

0 comments on commit edf0768

Please sign in to comment.