github.com/koko1123/flow-go-1@v0.29.6/engine/access/rest/request/get_account.go (about)

     1  package request
     2  
     3  import (
     4  	"github.com/koko1123/flow-go-1/model/flow"
     5  )
     6  
     7  const addressVar = "address"
     8  const blockHeightQuery = "block_height"
     9  
    10  type GetAccount struct {
    11  	Address flow.Address
    12  	Height  uint64
    13  }
    14  
    15  func (g *GetAccount) Build(r *Request) error {
    16  	return g.Parse(
    17  		r.GetVar(addressVar),
    18  		r.GetQueryParam(blockHeightQuery),
    19  	)
    20  }
    21  
    22  func (g *GetAccount) Parse(rawAddress string, rawHeight string) error {
    23  	var address Address
    24  	err := address.Parse(rawAddress)
    25  	if err != nil {
    26  		return err
    27  	}
    28  
    29  	var height Height
    30  	err = height.Parse(rawHeight)
    31  	if err != nil {
    32  		return err
    33  	}
    34  
    35  	g.Address = address.Flow()
    36  	g.Height = height.Flow()
    37  
    38  	// default to last block
    39  	if g.Height == EmptyHeight {
    40  		g.Height = SealedHeight
    41  	}
    42  
    43  	return nil
    44  }