Skip to content

Commit

Permalink
using types.HexBytes for merkle root on api
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmenendez committed Sep 28, 2023
1 parent 871741c commit ca4639f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions api/censuses.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"go.vocdoni.io/dvote/httprouter"
api "go.vocdoni.io/dvote/httprouter/apirest"
"go.vocdoni.io/dvote/log"
"go.vocdoni.io/dvote/types"
)

func (capi *census3API) initCensusHandlers() error {
Expand Down Expand Up @@ -58,7 +59,7 @@ func (capi *census3API) getCensus(msg *api.APIdata, ctx *httprouter.HTTPContext)
res, err := json.Marshal(GetCensusResponse{
CensusID: censusID,
StrategyID: currentCensus.StrategyID,
MerkleRoot: common.Bytes2Hex(currentCensus.MerkleRoot),
MerkleRoot: types.HexBytes(currentCensus.MerkleRoot),
URI: "ipfs://" + currentCensus.Uri.String,
Size: currentCensus.Size,
Weight: new(big.Int).SetBytes(censusWeight).String(),
Expand Down Expand Up @@ -265,7 +266,7 @@ func (capi *census3API) enqueueCensus(msg *api.APIdata, ctx *httprouter.HTTPCont
queueCensus.Census = &GetCensusResponse{
CensusID: currentCensus.ID,
StrategyID: currentCensus.StrategyID,
MerkleRoot: common.Bytes2Hex(currentCensus.MerkleRoot),
MerkleRoot: types.HexBytes(currentCensus.MerkleRoot),
URI: "ipfs://" + currentCensus.Uri.String,
Size: currentCensus.Size,
Weight: new(big.Int).SetBytes(censusWeight).String(),
Expand Down
16 changes: 9 additions & 7 deletions api/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package api

import "go.vocdoni.io/dvote/types"

type CreateTokenRequest struct {
ID string `json:"id"`
Type string `json:"type"`
Expand Down Expand Up @@ -61,13 +63,13 @@ type CreateCensusResponse struct {
}

type GetCensusResponse struct {
CensusID uint64 `json:"censusId"`
StrategyID uint64 `json:"strategyId"`
MerkleRoot string `json:"merkleRoot"`
URI string `json:"uri"`
Size uint64 `json:"size"`
Weight string `json:"weight"`
Anonymous bool `json:"anonymous"`
CensusID uint64 `json:"censusId"`
StrategyID uint64 `json:"strategyId"`
MerkleRoot types.HexBytes `json:"merkleRoot"`
URI string `json:"uri"`
Size uint64 `json:"size"`
Weight string `json:"weight"`
Anonymous bool `json:"anonymous"`
}

type GetCensusesResponse struct {
Expand Down

0 comments on commit ca4639f

Please sign in to comment.