Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pharr117 committed Jun 26, 2024
1 parent 0b99f56 commit 6e6ab2e
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 37 deletions.
1 change: 0 additions & 1 deletion chainregistry/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func GetAssetMapOnDisk(chainRegistryLocation string, chainRegBlacklist map[strin

currAssets := &AssetList{}
err = json.NewDecoder(jsonFile).Decode(currAssets)

if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func setup() (*gorm.DB, *config.ClientConfig, int, string, error) {
dbTypes.CacheIBCDenoms(db)

err = db.AutoMigrate(&dbTypes.Address{}, &AddressUsageCSV{}, &AddressUsageJSON{})

if err != nil {
config.Log.Fatalf("Error migrating client models. Err: %v", err)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/block_enqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func (idxr *Indexer) enqueueBlocksToProcessFromBlockInputFile(blockChan chan int
}
var blocksToIndex []uint64
err = json.Unmarshal(plan, &blocksToIndex)

if err != nil {
errString := err.Error()

Expand Down
1 change: 0 additions & 1 deletion cmd/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ func (idxr *Indexer) doDBUpdates(wg *sync.WaitGroup, txDataChan chan *dbData, bl
}

err = dbTypes.UpdateEpochIndexingStatus(idxr.db, idxr.dryRun, epochEventData.epochNumber, epochEventData.epochIdentifier, idxr.cfg.Lens.ChainID, idxr.cfg.Lens.ChainName)

if err != nil {
config.Log.Fatal(fmt.Sprintf("Error indexing block events for %s. Could not mark Epoch indexed.", identifierLoggingString), err)
}
Expand Down
2 changes: 0 additions & 2 deletions config/index_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@ func (conf *IndexConfig) Validate() error {
lensConf := conf.Lens

lensConf, err = validateLensConf(lensConf)

if err != nil {
return err
}

conf.Lens = lensConf

err = validateThrottlingConf(conf.Base.throttlingBase)

if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion config/update_denoms_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func (conf *UpdateDenomsConfig) Validate() error {
lensConf := conf.Lens

lensConf, err = validateLensConf(lensConf)

if err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions config/update_epochs_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ func (conf *UpdateEpochsConfig) Validate() error {
lensConf := conf.Lens

lensConf, err = validateLensConf(lensConf)

if err != nil {
return err
}

conf.Lens = lensConf

err = validateThrottlingConf(conf.Base.throttlingBase)

if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion core/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ func ProcessRPCBlockByHeightTXs(db *gorm.DB, cl *client.ChainClient, blockResult
// We can entirely ignore failed TXs in downstream parsers, because according to the Cosmos specification, a single failed message in a TX fails the whole TX
if txResult.Code == 0 {
logs, err = types.ParseABCILogs(txResult.Log)

if err != nil {
logs, err = indexerEvents.ParseTxEventsToMessageIndexEvents(len(txFull.Body.Messages), txResult.Events)
}
Expand Down
8 changes: 4 additions & 4 deletions csv/parsers/accointing/accointing.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,28 +158,28 @@ func HandleFees(address string, events []db.TaxableTransaction, allFees []db.Fee
// We need to gather all unique fees, but we are receiving Messages not Txes
// Make a map from TX hash to fees array to keep unique
txToFeesMap := make(map[uint][]db.Fee)
txIdsToTx := make(map[uint]db.Tx)
txIDsToTX := make(map[uint]db.Tx)
for _, event := range events {
txID := event.Message.Tx.ID
feeStore := event.Message.Tx.Fees
txToFeesMap[txID] = feeStore
txIdsToTx[txID] = event.Message.Tx
txIDsToTX[txID] = event.Message.Tx
}

// Due to the way we are parsing, we may have fees for TX that we don't have events for
for _, fee := range allFees {
txID := fee.Tx.ID
if _, ok := txToFeesMap[txID]; !ok {
txToFeesMap[txID] = []db.Fee{fee}
txIdsToTx[txID] = fee.Tx
txIDsToTX[txID] = fee.Tx
}
}

for id, txFees := range txToFeesMap {
for _, fee := range txFees {
if fee.PayerAddress.Address == address {
newRow := Row{}
err = newRow.ParseFee(txIdsToTx[id], fee)
err = newRow.ParseFee(txIDsToTX[id], fee)
if err != nil {
return nil, err
}
Expand Down
24 changes: 12 additions & 12 deletions csv/parsers/koinly/koinly.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var unsupportedCoins = []string{

var coinReplacementMap = map[string]string{}

var symbolsToKoinlyIds = map[string]string{}
var symbolsToKoinlyIDs = map[string]string{}

// Probably not the best place for this, but its only used in Koinly for now
// May want to consider adding the asset list URL as a config value and passing the AssetList value down to parsers if needed
Expand All @@ -42,7 +42,7 @@ func init() {

for _, asset := range assetList.Assets {
// Required format for koinly IDs is ID:<val>
symbolsToKoinlyIds[asset.Symbol] = fmt.Sprintf("ID:%s", asset.KoinlyID)
symbolsToKoinlyIDs[asset.Symbol] = fmt.Sprintf("ID:%s", asset.KoinlyID)
}
}

Expand Down Expand Up @@ -124,18 +124,18 @@ func (p *Parser) GetRows(address string, startDate, endDate *time.Time) ([]parse
for i, row := range koinlyRows {

if row.FeeCurrency != "" {
if _, ok := symbolsToKoinlyIds[row.FeeCurrency]; ok {
koinlyRows[i].FeeCurrency = symbolsToKoinlyIds[row.FeeCurrency]
if _, ok := symbolsToKoinlyIDs[row.FeeCurrency]; ok {
koinlyRows[i].FeeCurrency = symbolsToKoinlyIDs[row.FeeCurrency]
}
}
if row.ReceivedCurrency != "" {
if _, ok := symbolsToKoinlyIds[row.ReceivedCurrency]; ok {
koinlyRows[i].ReceivedCurrency = symbolsToKoinlyIds[row.ReceivedCurrency]
if _, ok := symbolsToKoinlyIDs[row.ReceivedCurrency]; ok {
koinlyRows[i].ReceivedCurrency = symbolsToKoinlyIDs[row.ReceivedCurrency]
}
}
if row.SentCurrency != "" {
if _, ok := symbolsToKoinlyIds[row.SentCurrency]; ok {
koinlyRows[i].SentCurrency = symbolsToKoinlyIds[row.SentCurrency]
if _, ok := symbolsToKoinlyIDs[row.SentCurrency]; ok {
koinlyRows[i].SentCurrency = symbolsToKoinlyIDs[row.SentCurrency]
}
}
}
Expand Down Expand Up @@ -226,28 +226,28 @@ func HandleFees(address string, events []db.TaxableTransaction, allFees []db.Fee
// We need to gather all unique fees, but we are receiving Messages not Txes
// Make a map from TX hash to fees array to keep unique
txToFeesMap := make(map[uint][]db.Fee)
txIdsToTx := make(map[uint]db.Tx)
txIDsToTX := make(map[uint]db.Tx)
for _, event := range events {
txID := event.Message.Tx.ID
feeStore := event.Message.Tx.Fees
txToFeesMap[txID] = feeStore
txIdsToTx[txID] = event.Message.Tx
txIDsToTX[txID] = event.Message.Tx
}

// Due to the way we are parsing, we may have fees for TX that we don't have events for
for _, fee := range allFees {
txID := fee.Tx.ID
if _, ok := txToFeesMap[txID]; !ok {
txToFeesMap[txID] = []db.Fee{fee}
txIdsToTx[txID] = fee.Tx
txIDsToTX[txID] = fee.Tx
}
}

for id, txFees := range txToFeesMap {
for _, fee := range txFees {
if fee.PayerAddress.Address == address {
newRow := Row{}
err = newRow.ParseFee(txIdsToTx[id], fee)
err = newRow.ParseFee(txIDsToTX[id], fee)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions csv/parsers/taxbit/taxbit.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,28 @@ func HandleFees(address string, events []db.TaxableTransaction, allFees []db.Fee
// We need to gather all unique fees, but we are receiving Messages not Txes
// Make a map from TX hash to fees array to keep unique
txToFeesMap := make(map[uint][]db.Fee)
txIdsToTx := make(map[uint]db.Tx)
txIDsToTX := make(map[uint]db.Tx)
for _, event := range events {
txID := event.Message.Tx.ID
feeStore := event.Message.Tx.Fees
txToFeesMap[txID] = feeStore
txIdsToTx[txID] = event.Message.Tx
txIDsToTX[txID] = event.Message.Tx
}

// Due to the way we are parsing, we may have fees for TX that we don't have events for
for _, fee := range allFees {
txID := fee.Tx.ID
if _, ok := txToFeesMap[txID]; !ok {
txToFeesMap[txID] = []db.Fee{fee}
txIdsToTx[txID] = fee.Tx
txIDsToTX[txID] = fee.Tx
}
}

for id, txFees := range txToFeesMap {
for _, fee := range txFees {
if fee.PayerAddress.Address == address {
newRow := Row{}
err = newRow.ParseFee(txIdsToTx[id], fee)
err = newRow.ParseFee(txIDsToTX[id], fee)
if err != nil {
return nil, err
}
Expand Down
2 changes: 0 additions & 2 deletions osmosis/modules/gamm/exits.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func (sf *WrapperMsgExitSwapShareAmountIn) HandleMsg(msgType string, msg sdk.Msg
return &txModule.MessageLogFormatError{MessageType: msgType, Log: fmt.Sprintf("%+v", log)}
}
sf.TokenOut, err = sdk.ParseCoinNormalized(tokenOut)

if err != nil {
return &txModule.MessageLogFormatError{MessageType: msgType, Log: fmt.Sprintf("%+v", log)}
}
Expand Down Expand Up @@ -357,7 +356,6 @@ func (sf *WrapperMsgExitSwapExternAmountOut) HandleMsg(msgType string, msg sdk.M
return &txModule.MessageLogFormatError{MessageType: msgType, Log: fmt.Sprintf("%+v", log)}
}
sf.TokenOut, err = sdk.ParseCoinNormalized(tokenOut)

if err != nil {
return &txModule.MessageLogFormatError{MessageType: msgType, Log: fmt.Sprintf("%+v", log)}
}
Expand Down
4 changes: 0 additions & 4 deletions rest/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func GetTxsByBlockHeight(host string, height uint64) (tx.GetTxByBlockHeightRespo
defer resp.Body.Close()

err = checkResponseErrorCode(requestEndpoint, resp)

if err != nil {
return result, err
}
Expand All @@ -76,7 +75,6 @@ func GetTxsByBlockHeight(host string, height uint64) (tx.GetTxByBlockHeightRespo
}

err = json.Unmarshal(body, &result)

if err != nil {
return result, err
}
Expand All @@ -97,7 +95,6 @@ func GetLatestBlock(host string) (tx.GetLatestBlockResponse, error) {
defer resp.Body.Close()

err = checkResponseErrorCode(requestEndpoint, resp)

if err != nil {
return result, err
}
Expand All @@ -108,7 +105,6 @@ func GetLatestBlock(host string) (tx.GetLatestBlockResponse, error) {
}

err = json.Unmarshal(body, &result)

if err != nil {
return result, err
}
Expand Down
1 change: 0 additions & 1 deletion rpc/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func GetTxsByBlockHeight(cl *lensClient.ChainClient, height int64) (resp *txType
options := lensQuery.QueryOptions{Height: height, Pagination: &pg}
query := lensQuery.Query{Client: cl, Options: &options}
resp, unpackError, err := query.TxByHeight(cl.Codec)

if err != nil {
return nil, unpackError, err
}
Expand Down

0 comments on commit 6e6ab2e

Please sign in to comment.