Skip to content

Commit

Permalink
FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
davcrypto committed Oct 17, 2023
1 parent 4afefe0 commit 35ccd9f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
9 changes: 2 additions & 7 deletions infrastructure/httpapi/handlers/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,8 @@ func (handler *Blocks) ListAccountByHeight(ctx *fasthttp.RequestCtx) {
return
}

for i := range rawEventAccounts {
accountStrSlice = append(accountStrSlice, rawEventAccounts[i])
}

for i := range rawTransactionAccounts {
accountStrSlice = append(accountStrSlice, rawTransactionAccounts[i])
}
accountStrSlice = append(accountStrSlice, rawEventAccounts...)
accountStrSlice = append(accountStrSlice, rawTransactionAccounts...)

accountStrSlice = unique(accountStrSlice)
accounts := make([]account, 0)
Expand Down
6 changes: 3 additions & 3 deletions infrastructure/tendermint/httpclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var _ = Describe("HTTPClient", func() {

client := NewHTTPClient(server.URL(), true)

blockResults, err := client.BlockResults(anyBlockHeight)
blockResults, err := client.BlockResults(anyBlockHeight, &Base64BlockResultEventAttributeDecoder{})
Expect(err).To(BeNil())
Expect(*blockResults).To(Equal(usecase_model.BlockResults{
Height: anyBlockHeight,
Expand Down Expand Up @@ -97,7 +97,7 @@ var _ = Describe("HTTPClient", func() {

client := NewHTTPClient(server.URL(), true)

blockResults, err := client.BlockResults(anyBlockHeight)
blockResults, err := client.BlockResults(anyBlockHeight, &Base64BlockResultEventAttributeDecoder{})
Expect(err).To(BeNil())
expected := "{\"height\":367216,\"txsResults\":[{\"code\":0,\"data\":\"\\n\\n\\n\\u0008delegate\",\"log\":[{\"msgIndex\":0,\"events\":[{\"type\":\"delegate\",\"attributes\":[{\"key\":\"validator\",\"value\":\"tcrocncl1pm27djcs5djxjsxw3unrkv3m3jtxdexktw5epu\",\"index\":false},{\"key\":\"amount\",\"value\":\"19302674761\",\"index\":false}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"delegate\",\"index\":false},{\"key\":\"sender\",\"value\":\"tcro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8339p4l\",\"index\":false},{\"key\":\"module\",\"value\":\"staking\",\"index\":false},{\"key\":\"sender\",\"value\":\"tcro1pm27djcs5djxjsxw3unrkv3m3jtxdexk73hqel\",\"index\":false}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"tcro1pm27djcs5djxjsxw3unrkv3m3jtxdexk73hqel\",\"index\":false},{\"key\":\"sender\",\"value\":\"tcro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8339p4l\",\"index\":false},{\"key\":\"amount\",\"value\":\"1913979901basetcro\",\"index\":false}]}]}],\"rawLog\":\"[{\\\"events\\\":[{\\\"type\\\":\\\"delegate\\\",\\\"attributes\\\":[{\\\"key\\\":\\\"validator\\\",\\\"value\\\":\\\"tcrocncl1pm27djcs5djxjsxw3unrkv3m3jtxdexktw5epu\\\"},{\\\"key\\\":\\\"amount\\\",\\\"value\\\":\\\"19302674761\\\"}]},{\\\"type\\\":\\\"message\\\",\\\"attributes\\\":[{\\\"key\\\":\\\"action\\\",\\\"value\\\":\\\"delegate\\\"},{\\\"key\\\":\\\"sender\\\",\\\"value\\\":\\\"tcro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8339p4l\\\"},{\\\"key\\\":\\\"module\\\",\\\"value\\\":\\\"staking\\\"},{\\\"key\\\":\\\"sender\\\",\\\"value\\\":\\\"tcro1pm27djcs5djxjsxw3unrkv3m3jtxdexk73hqel\\\"}]},{\\\"type\\\":\\\"transfer\\\",\\\"attributes\\\":[{\\\"key\\\":\\\"recipient\\\",\\\"value\\\":\\\"tcro1pm27djcs5djxjsxw3unrkv3m3jtxdexk73hqel\\\"},{\\\"key\\\":\\\"sender\\\",\\\"value\\\":\\\"tcro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8339p4l\\\"},{\\\"key\\\":\\\"amount\\\",\\\"value\\\":\\\"1913979901basetcro\\\"}]}]}]\",\"info\":\"\",\"gasWanted\":\"200000\",\"gasUsed\":\"143179\",\"events\":[{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"tcro17xpfvakm2amg962yls6f84z3kell8c5lxhzaha\",\"index\":true},{\"key\":\"sender\",\"value\":\"tcro1pm27djcs5djxjsxw3unrkv3m3jtxdexk73hqel\",\"index\":true},{\"key\":\"amount\",\"value\":\"20000basetcro\",\"index\":true}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"sender\",\"value\":\"tcro1pm27djcs5djxjsxw3unrkv3m3jtxdexk73hqel\",\"index\":true}]}],\"codespace\":\"\"},{\"code\":0,\"data\":\"\\n\\n\\n\\u0008delegate\",\"log\":[{\"msgIndex\":0,\"events\":[{\"type\":\"delegate\",\"attributes\":[{\"key\":\"validator\",\"value\":\"tcrocncl10gsqs8jzdlrem80shp0x6wx0jw7qu7m8cd29y5\",\"index\":false},{\"key\":\"amount\",\"value\":\"17338013566\",\"index\":false}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"delegate\",\"index\":false},{\"key\":\"sender\",\"value\":\"tcro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8339p4l\",\"index\":false},{\"key\":\"module\",\"value\":\"staking\",\"index\":false},{\"key\":\"sender\",\"value\":\"tcro10gsqs8jzdlrem80shp0x6wx0jw7qu7m8djfuuh\",\"index\":false}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"tcro10gsqs8jzdlrem80shp0x6wx0jw7qu7m8djfuuh\",\"index\":false},{\"key\":\"sender\",\"value\":\"tcro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8339p4l\",\"index\":false},{\"key\":\"amount\",\"value\":\"2310941249basetcro\",\"index\":false}]}]}],\"rawLog\":\"[{\\\"events\\\":[{\\\"type\\\":\\\"delegate\\\",\\\"attributes\\\":[{\\\"key\\\":\\\"validator\\\",\\\"value\\\":\\\"tcrocncl10gsqs8jzdlrem80shp0x6wx0jw7qu7m8cd29y5\\\"},{\\\"key\\\":\\\"amount\\\",\\\"value\\\":\\\"17338013566\\\"}]},{\\\"type\\\":\\\"message\\\",\\\"attributes\\\":[{\\\"key\\\":\\\"action\\\",\\\"value\\\":\\\"delegate\\\"},{\\\"key\\\":\\\"sender\\\",\\\"value\\\":\\\"tcro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8339p4l\\\"},{\\\"key\\\":\\\"module\\\",\\\"value\\\":\\\"staking\\\"},{\\\"key\\\":\\\"sender\\\",\\\"value\\\":\\\"tcro10gsqs8jzdlrem80shp0x6wx0jw7qu7m8djfuuh\\\"}]},{\\\"type\\\":\\\"transfer\\\",\\\"attributes\\\":[{\\\"key\\\":\\\"recipient\\\",\\\"value\\\":\\\"tcro10gsqs8jzdlrem80shp0x6wx0jw7qu7m8djfuuh\\\"},{\\\"key\\\":\\\"sender\\\",\\\"value\\\":\\\"tcro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8339p4l\\\"},{\\\"key\\\":\\\"amount\\\",\\\"value\\\":\\\"2310941249basetcro\\\"}]}]}]\",\"info\":\"\",\"gasWanted\":\"200000\",\"gasUsed\":\"143737\",\"events\":[{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"tcro17xpfvakm2amg962yls6f84z3kell8c5lxhzaha\",\"index\":true},{\"key\":\"sender\",\"value\":\"tcro10gsqs8jzdlrem80shp0x6wx0jw7qu7m8djfuuh\",\"index\":true},{\"key\":\"amount\",\"value\":\"20000basetcro\",\"index\":true}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"sender\",\"value\":\"tcro10gsqs8jzdlrem80shp0x6wx0jw7qu7m8djfuuh\",\"index\":true}]}],\"codespace\":\"\"}],\"beginBlockEvents\":[{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"tcro17xpfvakm2amg962yls6f84z3kell8c5lxhzaha\",\"index\":true},{\"key\":\"sender\",\"value\":\"tcro1m3h30wlvsf8llruxtpukdvsy0km2kum87lx9mq\",\"index\":true},{\"key\":\"amount\",\"value\":\"17449528321basetcro\",\"index\":true}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"sender\",\"value\":\"tcro1m3h30wlvsf8llruxtpukdvsy0km2kum87lx9mq\",\"index\":true}]},{\"type\":\"mint\",\"attributes\":[{\"key\":\"bonded_ratio\",\"value\":\"0.000809196054376644\",\"index\":true},{\"key\":\"inflation\",\"value\":\"0.013755821936855184\",\"index\":true},{\"key\":\"annual_provisions\",\"value\":\"110133046994204576.138016526579386288\",\"index\":true},{\"key\":\"amount\",\"value\":\"17449528321\",\"index\":true}]}],\"endBlockEvents\":[{\"type\":\"commission\",\"attributes\":[{\"key\":\"amount\",\"value\":\"87247841.605000000000000000basetcro\",\"index\":true},{\"key\":\"validator\",\"value\":\"tcrocncl18p07yvmphymscz6tl4a7zmh93g0k6vy72ww4s4\",\"index\":true}]},{\"type\":\"rewards\",\"attributes\":[{\"key\":\"amount\",\"value\":\"872478416.050000000000000000basetcro\",\"index\":true},{\"key\":\"validator\",\"value\":\"tcrocncl18p07yvmphymscz6tl4a7zmh93g0k6vy72ww4s4\",\"index\":true}]}],\"validatorUpdates\":[{\"pubkey\":{\"type\":\"tendermint.crypto.PublicKey_Ed25519\",\"pubkey\":\"SE5zeTjcYPXVrfcOva61QWokSZFfQu2h316fR6bB2dY=\"},\"address\":\"CA721C3A05F500838DDD1B16F4E2D2D09E463218\",\"power\":138525202},{\"pubkey\":{\"type\":\"tendermint.crypto.PublicKey_Ed25519\",\"pubkey\":\"Epmo3U6yXlxSDQzWZ8yBPOMHw2R85lc26RK98Rlo0oM=\"},\"address\":\"E067FCE33F7FDBD0CE4872F8E240A7AD6E654726\",\"power\":112904113}],\"consensusParamUpdates\":{\"block\":{\"maxBytes\":\"22020096\",\"maxGas\":\"-1\"},\"evidence\":{\"maxAgeNumBlocks\":\"100000\",\"maxAgeDuration\":\"172800000000000\",\"maxBytes\":\"\"},\"validator\":{\"pubKeyTypes\":[\"ed25519\"]}}}"
Expect(jsoniter.MarshalToString(blockResults)).To(Equal(expected))
Expand All @@ -114,7 +114,7 @@ var _ = Describe("HTTPClient", func() {

client := NewHTTPClient(server.URL(), true)

blockResults, err := client.BlockResults(anyBlockHeight)
blockResults, err := client.BlockResults(anyBlockHeight, &Base64BlockResultEventAttributeDecoder{})
Expect(err).To(BeNil())
Expect(jsoniter.MarshalToString(blockResults)).To(Equal("{\"height\":4794,\"txsResults\":[],\"beginBlockEvents\":[],\"endBlockEvents\":[],\"validatorUpdates\":[{\"pubkey\":{\"type\":\"tendermint.crypto.PublicKey_Ed25519\",\"pubkey\":\"CpCz+c19SHaNWW31P+7blzyHo0sQMn4uk8gIej+pXW8=\"},\"address\":\"02D50170AFB2B3718477AA607469BEA96C80CE88\",\"power\":null}],\"consensusParamUpdates\":{\"block\":{\"maxBytes\":\"22020096\",\"maxGas\":\"-1\"},\"evidence\":{\"maxAgeNumBlocks\":\"100000\",\"maxAgeDuration\":\"172800000000000\",\"maxBytes\":\"\"},\"validator\":{\"pubKeyTypes\":[\"ed25519\"]}}}"))
})
Expand Down
9 changes: 0 additions & 9 deletions infrastructure/tendermint/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,6 @@ func mustBase64Decode(s string) string {
return string(decoded)
}

func base64Decode(s string) (string, error) {
decoded, err := base64.StdEncoding.DecodeString(s)
if err != nil {
return "", err
}

return string(decoded), nil
}

func parseBlockResultsConsensusParamsUpdates(rawUpdates RawBlockResultsConsensusParamUpdates) model.BlockResultsConsensusParamUpdates {
var validatorPubKeyTypes []string
if rawUpdates.Validator.PubKeyTypes == nil {
Expand Down
6 changes: 3 additions & 3 deletions usecase/parser/v0_42_7/msg_ibc_recv_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = Describe("ParseMsgCommands", func() {
))
blockResults, _ := tendermint.ParseBlockResultsResp(strings.NewReader(
usecase_parser_V0_42_7_test.TX_MSG_RECV_PACKET_BLOCK_RESULTS_RESP,
))
), &tendermint.Base64BlockResultEventAttributeDecoder{})

resTx, _ := cosmosapp.ParseTxsResp(strings.NewReader(
usecase_parser_V0_42_7_test.TX_MSG_RECV_PACKET_TXS_RESP,
Expand Down Expand Up @@ -174,7 +174,7 @@ var _ = Describe("ParseMsgCommands", func() {
))
blockResults, _ := tendermint.ParseBlockResultsResp(strings.NewReader(
usecase_parser_V0_42_7_test.TX_MSG_RECV_PACKET_PACKET_ACK_ERROR_BLOCK_RESULTS_RESP,
))
), &tendermint.Base64BlockResultEventAttributeDecoder{})

resTx, _ := cosmosapp.ParseTxsResp(strings.NewReader(
usecase_parser_V0_42_7_test.TX_MSG_RECV_PACKET_PACKET_ACK_ERROR_TXS_RESP,
Expand Down Expand Up @@ -275,7 +275,7 @@ var _ = Describe("ParseMsgCommands", func() {
))
blockResults, _ := tendermint.ParseBlockResultsResp(strings.NewReader(
usecase_parser_V0_42_7_test.TX_MSG_RECV_PACKET_MISSING_FUNGIBLE_TOKEN_PACKET_BLOCK_RESULTS_RESP,
))
), &tendermint.Base64BlockResultEventAttributeDecoder{})

resTx, _ := cosmosapp.ParseTxsResp(strings.NewReader(
usecase_parser_V0_42_7_test.TX_MSG_RECV_PACKET_MISSING_FUNGIBLE_TOKEN_PACKET_TXS_RESP,
Expand Down

0 comments on commit 35ccd9f

Please sign in to comment.