diff --git a/api/service/explorer/service.go b/api/service/explorer/service.go index e94d0703d..14387aff1 100644 --- a/api/service/explorer/service.go +++ b/api/service/explorer/service.go @@ -695,7 +695,6 @@ func (s *Service) GetExplorerAddress(w http.ResponseWriter, r *http.Request) { balance, err := s.GetAccountBalance(address) if err == nil { balanceAddr = balance - data.Address.Balance = balance } } diff --git a/api/service/explorer/structs.go b/api/service/explorer/structs.go index dfd70d69a..5060b4908 100644 --- a/api/service/explorer/structs.go +++ b/api/service/explorer/structs.go @@ -57,6 +57,9 @@ type Transaction struct { Value *big.Int `json:"value"` Bytes string `json:"bytes"` Data string `json:"data"` + GasFee *big.Int `json:"gasFee"` + FromShard uint32 `json:"fromShard"` + ToShard uint32 `json:"toShard"` Type string `json:"type"` } @@ -118,6 +121,8 @@ func GetTransaction(tx *types.Transaction, addressBlock *types.Block) *Transacti if err != nil { utils.Logger().Error().Err(err).Msg("Error when parsing tx into message") } + gasFee := big.NewInt(0) + gasFee = gasFee.Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas())) return &Transaction{ ID: tx.Hash().Hex(), Timestamp: strconv.Itoa(int(addressBlock.Time().Int64() * 1000)), @@ -126,6 +131,9 @@ func GetTransaction(tx *types.Transaction, addressBlock *types.Block) *Transacti Value: msg.Value(), Bytes: strconv.Itoa(int(tx.Size())), Data: hex.EncodeToString(tx.Data()), + GasFee: gasFee, + FromShard: tx.ShardID(), + ToShard: tx.ToShardID(), Type: "", } } diff --git a/node/contract.go b/node/contract.go index 2d2c53d85..013aa1770 100644 --- a/node/contract.go +++ b/node/contract.go @@ -150,7 +150,9 @@ func (node *Node) GetBalanceOfAddress(address common.Address) (*big.Int, error) utils.Logger().Error().Err(err).Msg("Failed to get chain state") return nil, err } - return state.GetBalance(address), nil + balance := big.NewInt(0) + balance.SetBytes(state.GetBalance(address).Bytes()) + return balance, nil } // AddFaucetContractToPendingTransactions adds the faucet contract the genesis block.