Skip to content

Commit

Permalink
264 inf denom lookup failed for gamm token will be inserted as unknow…
Browse files Browse the repository at this point in the history
…n denom received gammpool717 err getdenomforbase no denom unit for the specified denom gammpool717 (#287)

* add pagination to denom query
* reduce missing denom log msg from inf to warn
  • Loading branch information
davidkonigsberg authored Jan 27, 2023
1 parent 28ddd06 commit 02a725b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
18 changes: 3 additions & 15 deletions core/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,7 @@ func ProcessTx(db *gorm.DB, tx txTypes.MergedTx) (txDBWapper dbTypes.TxDBWrapper
denomSent, err = dbTypes.GetDenomForBase(v.DenominationSent)
if err != nil {
// attempt to add missing denoms to the database
if strings.Contains(v.DenominationSent, "gamm") {
config.Log.Infof("Denom lookup failed for gamm token. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", v.DenominationSent, err)
} else {
config.Log.Warnf("Denom lookup failed. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", v.DenominationSent, err)
}
config.Log.Warnf("Denom lookup failed. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", v.DenominationSent, err)
denomSent, err = dbTypes.AddUnknownDenom(db, v.DenominationSent)
if err != nil {
config.Log.Error(fmt.Sprintf("There was an error adding a missing denom. Denom sent: %v", v.DenominationSent), err)
Expand All @@ -353,11 +349,7 @@ func ProcessTx(db *gorm.DB, tx txTypes.MergedTx) (txDBWapper dbTypes.TxDBWrapper
denomReceived, err = dbTypes.GetDenomForBase(v.DenominationReceived)
if err != nil {
// attempt to add missing denoms to the database
if strings.Contains(v.DenominationReceived, "gamm") {
config.Log.Infof("Denom lookup failed for gamm token. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", v.DenominationReceived, err)
} else {
config.Log.Warnf("Denom lookup failed. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", v.DenominationReceived, err)
}
config.Log.Warnf("Denom lookup failed. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", v.DenominationReceived, err)
denomReceived, err = dbTypes.AddUnknownDenom(db, v.DenominationReceived)
if err != nil {
config.Log.Error(fmt.Sprintf("There was an error adding a missing denom. Denom received: %v", v.DenominationReceived), err)
Expand Down Expand Up @@ -410,11 +402,7 @@ func ProcessFees(db *gorm.DB, authInfo cosmosTx.AuthInfo, signers []types.AccAdd
denom, err := dbTypes.GetDenomForBase(coin.Denom)
if err != nil {
// attempt to add missing denoms to the database
if strings.Contains(coin.Denom, "gamm") {
config.Log.Infof("Denom lookup failed for gamm token. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", coin.Denom, err)
} else {
config.Log.Warnf("Denom lookup failed. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", coin.Denom, err)
}
config.Log.Warnf("Denom lookup failed. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", coin.Denom, err)
denom, err = dbTypes.AddUnknownDenom(db, coin.Denom)
if err != nil {
config.Log.Error(fmt.Sprintf("There was an error adding a missing denom. Denom: %v", coin.Denom), err)
Expand Down
8 changes: 2 additions & 6 deletions db/osmosis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"crypto/sha256"
"fmt"
"sort"
"strings"

"github.com/DefiantLabs/cosmos-tax-cli-private/config"
"github.com/DefiantLabs/cosmos-tax-cli-private/osmosis"
"github.com/DefiantLabs/cosmos-tax-cli-private/util"

"gorm.io/gorm"
)

Expand Down Expand Up @@ -72,11 +72,7 @@ func IndexOsmoRewards(db *gorm.DB, dryRun bool, chainID string, chainName string
denom, err := GetDenomForBase(coin.Denom)
if err != nil {
// attempt to add missing denoms to the database
if strings.Contains(coin.Denom, "gamm") {
config.Log.Infof("Denom lookup failed for gamm token. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", coin.Denom, err)
} else {
config.Log.Warnf("Denom lookup failed. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", coin.Denom, err)
}
config.Log.Warnf("Denom lookup failed. Will be inserted as UNKNOWN. Denom Received: %v. Err: %v", coin.Denom, err)
denom, err = AddUnknownDenom(db, coin.Denom)
if err != nil {
config.Log.Error(fmt.Sprintf("There was an error adding a missing denom. Denom Received: %v", coin.Denom), err)
Expand Down
23 changes: 22 additions & 1 deletion rest/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,30 @@ func checkResponseErrorCode(requestEndpoint string, resp *http.Response) error {
}

func GetDenomsMetadatas(host string) (result denoms.GetDenomsMetadatasResponse, err error) {
result, err = getDenomsMetadatas(host, "")
if err != nil {
return
}
allResults := result
for result.Pagination.NextKey != "" {
result, err = getDenomsMetadatas(host, result.Pagination.NextKey)
if err != nil {
return
}
allResults.Metadatas = append(allResults.Metadatas, result.Metadatas...)
}
result = allResults
return
}

func getDenomsMetadatas(host string, paginationKey string) (result denoms.GetDenomsMetadatasResponse, err error) {
requestEndpoint := apiEndpoints["denoms_metadata"]
url := fmt.Sprintf("%s%s", host, requestEndpoint)
if paginationKey != "" {
url = fmt.Sprintf("%v?pagination.key=%v", url, paginationKey)
}

resp, err := http.Get(fmt.Sprintf("%s%s", host, requestEndpoint))
resp, err := http.Get(url) //nolint:gosec
if err != nil {
return result, err
}
Expand Down

0 comments on commit 02a725b

Please sign in to comment.