From 7ba9d9810c5e2997f49bb5bc0784f213792a1699 Mon Sep 17 00:00:00 2001 From: pharr117 Date: Wed, 26 Jun 2024 02:59:34 -0400 Subject: [PATCH 1/3] Improve error handling during TX querying when unpack errors occur, show warning when an unpack fails --- cmd/index.go | 6 +++++- cosmos/modules/ibc/types.go | 2 +- cosmos/modules/tx/errors.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- rpc/requests.go | 26 ++++++++++++++++++++------ rpc/rpc_test.go | 4 ++-- 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/cmd/index.go b/cmd/index.go index 7c3109ce..965abd73 100644 --- a/cmd/index.go +++ b/cmd/index.go @@ -328,7 +328,7 @@ func processBlock(cl *client.ChainClient, dbConn *gorm.DB, failedBlockHandler fu var err error errTypeURL := false - txsEventResp, err := rpc.GetTxsByBlockHeight(cl, newBlock.Height) + txsEventResp, unpackError, err := rpc.GetTxsByBlockHeight(cl, newBlock.Height) if err != nil { if strings.Contains(err.Error(), "unable to resolve type URL") { errTypeURL = true @@ -338,6 +338,10 @@ func processBlock(cl *client.ChainClient, dbConn *gorm.DB, failedBlockHandler fu } } + if unpackError != nil { + config.Log.Warn("There was an error unpacking interfaces during RPC querying, check your codecs", unpackError) + } + // There are two reasons this block would be hit // 1) The node might have pruned history resulting in a failed lookup. Recheck to see if the block was supposed to have TX results. // 2) The RPC endpoint (node we queried) doesn't recognize the type URL anymore, for an older type (e.g. on an archive node). diff --git a/cosmos/modules/ibc/types.go b/cosmos/modules/ibc/types.go index 4b7c4265..666454cf 100644 --- a/cosmos/modules/ibc/types.go +++ b/cosmos/modules/ibc/types.go @@ -229,5 +229,5 @@ func (w *WrapperMsgAcknowledgement) String() string { return "MsgAcknowledgement: IBC transfer was not a FungibleTokenTransfer" } - return fmt.Sprintf("MsgAcknowledgement: IBC transfer of %s%s from %s to %s\n", w.Amount, w.Denom, w.SenderAddress, w.ReceiverAddress) + return fmt.Sprintf("MsgAcknowledgement: IBC transfer of %s%s from %s to %s", w.Amount, w.Denom, w.SenderAddress, w.ReceiverAddress) } diff --git a/cosmos/modules/tx/errors.go b/cosmos/modules/tx/errors.go index 28fb050c..aff2d6f0 100644 --- a/cosmos/modules/tx/errors.go +++ b/cosmos/modules/tx/errors.go @@ -13,5 +13,5 @@ type MessageLogFormatError struct { } func (e *MessageLogFormatError) Error() string { - return fmt.Sprintf("Type: %s could not handle message log %s\n", e.MessageType, e.Log) + return fmt.Sprintf("Type: %s could not handle message log %s", e.MessageType, e.Log) } diff --git a/go.mod b/go.mod index b501a06e..62f0b0a9 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/BurntSushi/toml v1.3.2 // FYI, you can do go get github.com/DefiantLabs/lens@1f6f34841280df179c6e098f040bd584ced43a4c // (using the commit hash from github) to pin to a specific commit. - github.com/DefiantLabs/lens v0.3.1-0.20240530040544-3ad0f04acd32 + github.com/DefiantLabs/lens v0.3.1-0.20240626064943-499ef68c78a4 github.com/cosmos/cosmos-sdk v0.47.8 github.com/gin-gonic/gin v1.9.1 github.com/go-co-op/gocron v1.13.0 diff --git a/go.sum b/go.sum index fadac8bc..05ebad02 100644 --- a/go.sum +++ b/go.sum @@ -558,8 +558,8 @@ github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.0 h1:+K/VEwIAaPcHiMtQvpLD4lqW7f0Gk3xdYZmI1hD+CXo= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/DefiantLabs/lens v0.3.1-0.20240530040544-3ad0f04acd32 h1:wl/7DINIB9ekq3/Hm9Ck0T0y9oA49YdLvAUh8AsTRXE= -github.com/DefiantLabs/lens v0.3.1-0.20240530040544-3ad0f04acd32/go.mod h1:+PbjDba4Lz2mDEywmIv3DKuWH2G/asWovif+Dph6zd8= +github.com/DefiantLabs/lens v0.3.1-0.20240626064943-499ef68c78a4 h1:ReN2eDugPg51M/c2v7dLeYm/CA2gFT47qnJxikGE6zI= +github.com/DefiantLabs/lens v0.3.1-0.20240626064943-499ef68c78a4/go.mod h1:+PbjDba4Lz2mDEywmIv3DKuWH2G/asWovif+Dph6zd8= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= diff --git a/rpc/requests.go b/rpc/requests.go index 0723994c..7311207c 100644 --- a/rpc/requests.go +++ b/rpc/requests.go @@ -1,6 +1,7 @@ package rpc import ( + "fmt" "time" coretypes "github.com/cometbft/cometbft/rpc/core/types" @@ -50,13 +51,22 @@ func GetBlock(cl *lensClient.ChainClient, height int64) (*coretypes.ResultBlock, } // GetTxsByBlockHeight makes a request to the Cosmos RPC API and returns all the transactions for a specific block -func GetTxsByBlockHeight(cl *lensClient.ChainClient, height int64) (*txTypes.GetTxsEventResponse, error) { +func GetTxsByBlockHeight(cl *lensClient.ChainClient, height int64) (resp *txTypes.GetTxsEventResponse, unpackError error, queryError error) { pg := query.PageRequest{Limit: 100} options := lensQuery.QueryOptions{Height: height, Pagination: &pg} query := lensQuery.Query{Client: cl, Options: &options} - resp, err := query.TxByHeight(cl.Codec) + resp, unpackError, err := query.TxByHeight(cl.Codec) + if err != nil { - return nil, err + return nil, unpackError, err + } + + unpackErrors := "" + hadUnpackErrors := false + + if unpackError != nil { + unpackErrors = unpackError.Error() + hadUnpackErrors = true } // handle pagination if needed @@ -64,16 +74,20 @@ func GetTxsByBlockHeight(cl *lensClient.ChainClient, height int64) (*txTypes.Get // if there are more total objects than we have so far, keep going for resp.Pagination.Total > uint64(len(resp.Txs)) { query.Options.Pagination.Offset = uint64(len(resp.Txs)) - chunkResp, err := query.TxByHeight(cl.Codec) + chunkResp, chunkUnpackError, err := query.TxByHeight(cl.Codec) if err != nil { - return nil, err + return nil, err, chunkUnpackError } resp.Txs = append(resp.Txs, chunkResp.Txs...) resp.TxResponses = append(resp.TxResponses, chunkResp.TxResponses...) } } - return resp, nil + if hadUnpackErrors { + return resp, fmt.Errorf("error unpacking the TX response: %s", unpackErrors), nil + } + + return resp, nil, nil } // IsCatchingUp true if the node is catching up to the chain, false otherwise diff --git a/rpc/rpc_test.go b/rpc/rpc_test.go index c4c0254c..862c402b 100644 --- a/rpc/rpc_test.go +++ b/rpc/rpc_test.go @@ -38,7 +38,7 @@ func TestRPC(t *testing.T) { func TestDecodeIBCTypes(t *testing.T) { cl := GetOsmosisTestClient(t) - resp, err := GetTxsByBlockHeight(cl, 2620000) + resp, _, err := GetTxsByBlockHeight(cl, 2620000) assert.Empty(t, err) hasIbcType := false @@ -146,7 +146,7 @@ func rpcQueryTx(t *testing.T, height int64) error { // requestEndpoint := fmt.Sprintf(rest.GetEndpoint("txs_by_block_height_endpoint"), height) options := lensQuery.QueryOptions{Height: height} query := lensQuery.Query{Client: cl, Options: &options} - resp, err := query.TxByHeight(cl.Codec) + resp, _, err := query.TxByHeight(cl.Codec) if err != nil { return err } From 0b99f56f7c4754fd957d162377fe31136d159f0b Mon Sep 17 00:00:00 2001 From: pharr117 Date: Wed, 26 Jun 2024 03:15:26 -0400 Subject: [PATCH 2/3] Update lens package usage to use module basics from Osmosis directly --- config/lens_helper.go | 2 +- go.mod | 10 +++++++--- go.sum | 10 ++++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/config/lens_helper.go b/config/lens_helper.go index b1f8d8ab..7e186372 100644 --- a/config/lens_helper.go +++ b/config/lens_helper.go @@ -38,6 +38,6 @@ func GetLensConfig(conf lens, debug bool) *lensClient.ChainClientConfig { Timeout: "30s", OutputFormat: "json", SignModeStr: "direct", - Modules: lensClient.ModuleBasics, + Modules: lensClient.OsmosisModuleBasics, } } diff --git a/go.mod b/go.mod index 62f0b0a9..530c397a 100644 --- a/go.mod +++ b/go.mod @@ -6,9 +6,8 @@ toolchain go1.21.11 require ( github.com/BurntSushi/toml v1.3.2 - // FYI, you can do go get github.com/DefiantLabs/lens@1f6f34841280df179c6e098f040bd584ced43a4c - // (using the commit hash from github) to pin to a specific commit. - github.com/DefiantLabs/lens v0.3.1-0.20240626064943-499ef68c78a4 + // Our lens library is pinned to this specific SHA and branch: 7732945f81598e4d6aff47e0d4ca81b0ec26d8b3, https://github.com/DefiantLabs/lens/tree/v0.0.21-dl + github.com/DefiantLabs/lens v0.3.1-0.20240626071018-7732945f8159 github.com/cosmos/cosmos-sdk v0.47.8 github.com/gin-gonic/gin v1.9.1 github.com/go-co-op/gocron v1.13.0 @@ -93,6 +92,9 @@ require ( github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/gogoproto v1.4.11 // indirect github.com/cosmos/iavl v1.1.2-0.20240405173644-e52f7630d3b7 // indirect + github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3 // indirect + github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.1.1 // indirect + github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-ibc-go-v7.3-wasmvm-v1.5 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect @@ -161,6 +163,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.1.0 // indirect github.com/huandu/skiplist v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect @@ -204,6 +207,7 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/osmosis-labs/osmosis/osmomath v0.0.13 // indirect github.com/osmosis-labs/osmosis/osmoutils v0.0.13 // indirect + github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.15 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect diff --git a/go.sum b/go.sum index 05ebad02..e102c343 100644 --- a/go.sum +++ b/go.sum @@ -558,8 +558,8 @@ github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.0 h1:+K/VEwIAaPcHiMtQvpLD4lqW7f0Gk3xdYZmI1hD+CXo= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/DefiantLabs/lens v0.3.1-0.20240626064943-499ef68c78a4 h1:ReN2eDugPg51M/c2v7dLeYm/CA2gFT47qnJxikGE6zI= -github.com/DefiantLabs/lens v0.3.1-0.20240626064943-499ef68c78a4/go.mod h1:+PbjDba4Lz2mDEywmIv3DKuWH2G/asWovif+Dph6zd8= +github.com/DefiantLabs/lens v0.3.1-0.20240626071018-7732945f8159 h1:GB/lSc4/UT7M64scdyh0lrwyRRi3UyCto9RvwJekVKI= +github.com/DefiantLabs/lens v0.3.1-0.20240626071018-7732945f8159/go.mod h1:nTPf+NQkhPH6NcBY5p0lpdb14WPiZOeMZDDkq1IWl30= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= @@ -1799,7 +1799,11 @@ github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= +github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= @@ -1887,6 +1891,8 @@ go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/mock v0.2.0 h1:TaP3xedm7JaAgScZO7tlvlKrqT0p7I6OsdGB5YNSMDU= +go.uber.org/mock v0.2.0/go.mod h1:J0y0rp9L3xiff1+ZBfKxlC1fz2+aO16tw0tsDOixfuM= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= From 6e6ab2e90f9fab58042e03750f655e4a6a3551c8 Mon Sep 17 00:00:00 2001 From: pharr117 Date: Wed, 26 Jun 2024 13:34:01 -0400 Subject: [PATCH 3/3] lint --- chainregistry/requests.go | 1 - client/client.go | 1 - cmd/block_enqueue.go | 1 - cmd/index.go | 1 - config/index_config.go | 2 -- config/update_denoms_config.go | 1 - config/update_epochs_config.go | 2 -- core/tx.go | 1 - csv/parsers/accointing/accointing.go | 8 ++++---- csv/parsers/koinly/koinly.go | 24 ++++++++++++------------ csv/parsers/taxbit/taxbit.go | 8 ++++---- osmosis/modules/gamm/exits.go | 2 -- rest/requests.go | 4 ---- rpc/requests.go | 1 - 14 files changed, 20 insertions(+), 37 deletions(-) diff --git a/chainregistry/requests.go b/chainregistry/requests.go index c86413ce..af44125e 100644 --- a/chainregistry/requests.go +++ b/chainregistry/requests.go @@ -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 } diff --git a/client/client.go b/client/client.go index a80efbaa..145f8340 100644 --- a/client/client.go +++ b/client/client.go @@ -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) } diff --git a/cmd/block_enqueue.go b/cmd/block_enqueue.go index b4f86d90..e4e31757 100644 --- a/cmd/block_enqueue.go +++ b/cmd/block_enqueue.go @@ -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() diff --git a/cmd/index.go b/cmd/index.go index 965abd73..d82403b3 100644 --- a/cmd/index.go +++ b/cmd/index.go @@ -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) } diff --git a/config/index_config.go b/config/index_config.go index 44db2b36..ef2f5605 100644 --- a/config/index_config.go +++ b/config/index_config.go @@ -83,7 +83,6 @@ func (conf *IndexConfig) Validate() error { lensConf := conf.Lens lensConf, err = validateLensConf(lensConf) - if err != nil { return err } @@ -91,7 +90,6 @@ func (conf *IndexConfig) Validate() error { conf.Lens = lensConf err = validateThrottlingConf(conf.Base.throttlingBase) - if err != nil { return err } diff --git a/config/update_denoms_config.go b/config/update_denoms_config.go index e1da628c..b6ac041a 100644 --- a/config/update_denoms_config.go +++ b/config/update_denoms_config.go @@ -29,7 +29,6 @@ func (conf *UpdateDenomsConfig) Validate() error { lensConf := conf.Lens lensConf, err = validateLensConf(lensConf) - if err != nil { return err } diff --git a/config/update_epochs_config.go b/config/update_epochs_config.go index ce50af7d..85775ad4 100644 --- a/config/update_epochs_config.go +++ b/config/update_epochs_config.go @@ -31,7 +31,6 @@ func (conf *UpdateEpochsConfig) Validate() error { lensConf := conf.Lens lensConf, err = validateLensConf(lensConf) - if err != nil { return err } @@ -39,7 +38,6 @@ func (conf *UpdateEpochsConfig) Validate() error { conf.Lens = lensConf err = validateThrottlingConf(conf.Base.throttlingBase) - if err != nil { return err } diff --git a/core/tx.go b/core/tx.go index c04337b3..a00f950b 100644 --- a/core/tx.go +++ b/core/tx.go @@ -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) } diff --git a/csv/parsers/accointing/accointing.go b/csv/parsers/accointing/accointing.go index 103c0733..95c9cf29 100644 --- a/csv/parsers/accointing/accointing.go +++ b/csv/parsers/accointing/accointing.go @@ -158,12 +158,12 @@ 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 @@ -171,7 +171,7 @@ func HandleFees(address string, events []db.TaxableTransaction, allFees []db.Fee txID := fee.Tx.ID if _, ok := txToFeesMap[txID]; !ok { txToFeesMap[txID] = []db.Fee{fee} - txIdsToTx[txID] = fee.Tx + txIDsToTX[txID] = fee.Tx } } @@ -179,7 +179,7 @@ func HandleFees(address string, events []db.TaxableTransaction, allFees []db.Fee 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 } diff --git a/csv/parsers/koinly/koinly.go b/csv/parsers/koinly/koinly.go index 3b460b3d..501e9c02 100644 --- a/csv/parsers/koinly/koinly.go +++ b/csv/parsers/koinly/koinly.go @@ -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 @@ -42,7 +42,7 @@ func init() { for _, asset := range assetList.Assets { // Required format for koinly IDs is ID: - symbolsToKoinlyIds[asset.Symbol] = fmt.Sprintf("ID:%s", asset.KoinlyID) + symbolsToKoinlyIDs[asset.Symbol] = fmt.Sprintf("ID:%s", asset.KoinlyID) } } @@ -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] } } } @@ -226,12 +226,12 @@ 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 @@ -239,7 +239,7 @@ func HandleFees(address string, events []db.TaxableTransaction, allFees []db.Fee txID := fee.Tx.ID if _, ok := txToFeesMap[txID]; !ok { txToFeesMap[txID] = []db.Fee{fee} - txIdsToTx[txID] = fee.Tx + txIDsToTX[txID] = fee.Tx } } @@ -247,7 +247,7 @@ func HandleFees(address string, events []db.TaxableTransaction, allFees []db.Fee 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 } diff --git a/csv/parsers/taxbit/taxbit.go b/csv/parsers/taxbit/taxbit.go index e3ef1bb7..3afb3e5f 100644 --- a/csv/parsers/taxbit/taxbit.go +++ b/csv/parsers/taxbit/taxbit.go @@ -155,12 +155,12 @@ 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 @@ -168,7 +168,7 @@ func HandleFees(address string, events []db.TaxableTransaction, allFees []db.Fee txID := fee.Tx.ID if _, ok := txToFeesMap[txID]; !ok { txToFeesMap[txID] = []db.Fee{fee} - txIdsToTx[txID] = fee.Tx + txIDsToTX[txID] = fee.Tx } } @@ -176,7 +176,7 @@ func HandleFees(address string, events []db.TaxableTransaction, allFees []db.Fee 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 } diff --git a/osmosis/modules/gamm/exits.go b/osmosis/modules/gamm/exits.go index 1fc768b3..39c76bea 100644 --- a/osmosis/modules/gamm/exits.go +++ b/osmosis/modules/gamm/exits.go @@ -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)} } @@ -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)} } diff --git a/rest/requests.go b/rest/requests.go index 6459434e..6c9bfb84 100644 --- a/rest/requests.go +++ b/rest/requests.go @@ -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 } @@ -76,7 +75,6 @@ func GetTxsByBlockHeight(host string, height uint64) (tx.GetTxByBlockHeightRespo } err = json.Unmarshal(body, &result) - if err != nil { return result, err } @@ -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 } @@ -108,7 +105,6 @@ func GetLatestBlock(host string) (tx.GetLatestBlockResponse, error) { } err = json.Unmarshal(body, &result) - if err != nil { return result, err } diff --git a/rpc/requests.go b/rpc/requests.go index 7311207c..799d6073 100644 --- a/rpc/requests.go +++ b/rpc/requests.go @@ -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 }