Skip to content

Commit

Permalink
replace grpc dialoption with WithTransportCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
nnn-gif committed Sep 4, 2023
1 parent d9f01eb commit 23d4b04
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
5 changes: 3 additions & 2 deletions pkg/dia/nft/nftTrade-scrapers/nbatopshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go-sdk/client"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

const (
Expand All @@ -34,7 +35,7 @@ var (
)

func NewNBATopshotScraper(rdb *models.RelDB) *NBATopshotScraper {
flowClient, err := client.New(flowhelper.FlowAPICurrent, grpc.WithInsecure())
flowClient, err := client.New(flowhelper.FlowAPICurrent, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -394,7 +395,7 @@ func (scraper *NBATopshotScraper) Close() error {
// Get Trade Event
// ---------------------------------------------------------

// pub event Deposit(id: UInt64, to: Address?)
// pub event Deposit(id: UInt64, to: Address?)
type DepositEvent cadence.Event

// Token Id
Expand Down
3 changes: 3 additions & 0 deletions pkg/dia/scraper/exchange-scrapers/KuCoinScraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ func (s *KuCoinScraper) mainLoop() {
lastTradeMap[pair] = tradeTime
countMap[pair] = 0
} else {
//nolint
tradeTime.Add(time.Duration(countMap[pair]+1) * time.Nanosecond)

countMap[pair] += 1
}
} else {
Expand Down Expand Up @@ -337,6 +339,7 @@ func (s *KuCoinScraper) mainLoop() {
lastTradeMap[pair] = tradeTime
countMap[pair] = 0
} else {
//nolint
tradeTime.Add(time.Duration(countMap[pair]+1) * time.Nanosecond)
countMap[pair] += 1
}
Expand Down
1 change: 1 addition & 0 deletions pkg/dia/service/assetservice/source/curvefi.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ func (cas *CurvefiAssetSource) loadPoolData(pool string, registry curveRegistry)
log.Error("loadPoolData - GetCoins: ", err)
}
// GetCoins on meta pools returns [4]common.Address instead of [8]common.Address for standard pools.
//nolint
for i, item := range aux {
poolCoins[i] = item
}
Expand Down
27 changes: 18 additions & 9 deletions pkg/dia/service/assetservice/source/osmosis.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ type OsmosisAssetSource struct {
}

type OsmosisAssetResponse struct {
Assets *[]OsmosisAsset
Assets *[]OsmosisAsset `json:"Assets"`
}

type OsmosisAsset struct {
Base string // base_denom
Name string // name of denom
Display string // human name
Symbol string // symbol of the denom
Decimals uint8 // to be loaded from Denom_units
Denom_units *[]banktypes.DenomUnit
Base string `json:"Base"` // base_denom
Name string `json:"Name"` // name of denom
Display string `json:"Display"` // human name
Symbol string `json:"Symbol"` // symbol of the denom
Decimals uint8 `json:"Decimals"` // to be loaded from Denom_units
Denom_units *[]banktypes.DenomUnit `json:"Denom_units"`
}

// Returns a new Osmosis asset scraper.
Expand Down Expand Up @@ -211,7 +211,7 @@ func NewGRPCClient(conf *scrapers.OsmosisConfig) (*GRPCClient, error) {
if grpcConn != nil {
grpcConn.Close()
}
return nil, fmt.Errorf("unable to connect to grpcConn: %s", err)
return nil, fmt.Errorf("unable to connect to grpcConn: %w", err)
}
bank := banktypes.NewQueryClient(grpcConn)
ibc := ibctransfertypes.NewQueryClient(grpcConn)
Expand All @@ -228,12 +228,21 @@ func NewGRPCClient(conf *scrapers.OsmosisConfig) (*GRPCClient, error) {

func GetAssetsJson() (map[string]*OsmosisAsset, error) {
url := "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/osmosis-1/osmosis-1.assetlist.json"
res, err := http.Get(url)

client := &http.Client{}
req, err := http.NewRequestWithContext(context.Background(), "GET", url, nil)
if err != nil {
return nil, err
}
res, err := client.Do(req)
if err != nil {
return nil, err
}
defer res.Body.Close()
data, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}
var assetsResponse OsmosisAssetResponse
err = json.Unmarshal([]byte(data), &assetsResponse)
if err != nil {
Expand Down

0 comments on commit 23d4b04

Please sign in to comment.