Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support customized block hash for balance API #128

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .codeflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
secure:
required_reviews: 1
requires_mfa: true
operate:
slack_channels:
- "#crypto-deploys"
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
Loading