Skip to content

Commit

Permalink
feat: support customized block hash for balance API (#128)
Browse files Browse the repository at this point in the history
* feat: support customized block hash for balance API

Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>

* chore: dummy commit

Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>

* chore: dummy commit

Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>

* test: install docker-compose in ci

Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>

* test: update CI permission

Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>

* chore: dummy commit

Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>

* chore: dummy commit

Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>

* test: add review requirement

Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>

* chore: revert review change

Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>

---------

Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>
  • Loading branch information
GeekArthur authored Aug 15, 2024
1 parent aa8cc6d commit 6b9a6ce
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install Docker Compose via Package Manager
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
shell: bash

- name: Verify Docker Compose Installation
run: docker-compose --version
shell: bash

- name: Start a private ethereum network
uses: ./.github/actions/geth
id: geth
Expand Down
7 changes: 7 additions & 0 deletions services/account_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package services

import (
"context"
"fmt"

"github.com/coinbase/rosetta-geth-sdk/configuration"
AssetTypes "github.com/coinbase/rosetta-geth-sdk/types"
Expand Down Expand Up @@ -70,6 +71,12 @@ func (s *AccountAPIService) AccountBalance(
return nil, AssetTypes.WrapErr(AssetTypes.ErrGeth, err)
}

// get block hash if the block hash can't be calculated from keccak256 hash of its RLP encoding
balanceResponse.BlockIdentifier.Hash, err = s.client.GetBlockHash(ctx, *balanceResponse.BlockIdentifier)
if err != nil {
return nil, AssetTypes.WrapErr(AssetTypes.ErrInternalError, fmt.Errorf("could not get block hash given block identifier %v: %w", request.BlockIdentifier, err))
}

return balanceResponse, nil
}

Expand Down
2 changes: 1 addition & 1 deletion services/block_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *BlockAPIService) populateTransactions(
}
transaction, err := s.PopulateTransaction(ctx, tx)
if err != nil {
return nil, fmt.Errorf("cannot parse %s: %w", tx.Transaction.Hash().Hex(), err)
return nil, fmt.Errorf("cannot parse %s: %w", tx.TxHash, err)
}
transactions = append(transactions, transaction)
}
Expand Down

0 comments on commit 6b9a6ce

Please sign in to comment.