diff --git a/client/v2/algod/getApplicationBoxes.go b/client/v2/algod/getApplicationBoxes.go index 70b40f8b..07bcdd23 100644 --- a/client/v2/algod/getApplicationBoxes.go +++ b/client/v2/algod/getApplicationBoxes.go @@ -11,14 +11,28 @@ import ( // GetApplicationBoxesParams contains all of the query parameters for url serialization. type GetApplicationBoxesParams struct { - // Max max number of box names to return. If max is not set, or max == 0, returns - // all box-names. + // Max maximum number of boxes to return. Server may impose a lower limit. Max uint64 `url:"max,omitempty"` + + // Next a box name, in the goal app call arg form 'encoding:value'. When provided, + // the returned boxes begin (lexographically) with the supplied name. Callers may + // implement pagination by reinvoking the endpoint with the token from a previous + // call's next-token. + Next string `url:"next,omitempty"` + + // Prefix a box name prefix, in the goal app call arg form 'encoding:value'. For + // ints, use the form 'int:1234'. For raw bytes, use the form 'b64:A=='. For + // printable strings, use the form 'str:hello'. For addresses, use the form + // 'addr:XYZ...'. + Prefix string `url:"prefix,omitempty"` + + // Values if true, box values will be returned. + Values bool `url:"values,omitempty"` } -// GetApplicationBoxes given an application ID, return all Box names. No particular -// ordering is guaranteed. Request fails when client or server-side configured -// limits prevent returning all Box names. +// GetApplicationBoxes given an application ID, return boxes in lexographical order +// by name. If the results must be truncated, a next-token is supplied to continue +// the request. type GetApplicationBoxes struct { c *Client @@ -27,14 +41,40 @@ type GetApplicationBoxes struct { p GetApplicationBoxesParams } -// Max max number of box names to return. If max is not set, or max == 0, returns -// all box-names. +// Max maximum number of boxes to return. Server may impose a lower limit. func (s *GetApplicationBoxes) Max(Max uint64) *GetApplicationBoxes { s.p.Max = Max return s } +// Next a box name, in the goal app call arg form 'encoding:value'. When provided, +// the returned boxes begin (lexographically) with the supplied name. Callers may +// implement pagination by reinvoking the endpoint with the token from a previous +// call's next-token. +func (s *GetApplicationBoxes) Next(Next string) *GetApplicationBoxes { + s.p.Next = Next + + return s +} + +// Prefix a box name prefix, in the goal app call arg form 'encoding:value'. For +// ints, use the form 'int:1234'. For raw bytes, use the form 'b64:A=='. For +// printable strings, use the form 'str:hello'. For addresses, use the form +// 'addr:XYZ...'. +func (s *GetApplicationBoxes) Prefix(Prefix string) *GetApplicationBoxes { + s.p.Prefix = Prefix + + return s +} + +// Values if true, box values will be returned. +func (s *GetApplicationBoxes) Values(Values bool) *GetApplicationBoxes { + s.p.Values = Values + + return s +} + // Do performs the HTTP request func (s *GetApplicationBoxes) Do(ctx context.Context, headers ...*common.Header) (response models.BoxesResponse, err error) { err = s.c.get(ctx, &response, fmt.Sprintf("/v2/applications/%s/boxes", common.EscapeParams(s.applicationId)...), s.p, headers) diff --git a/client/v2/algod/getGenesis.go b/client/v2/algod/getGenesis.go index 0c75975f..c9b6f72e 100644 --- a/client/v2/algod/getGenesis.go +++ b/client/v2/algod/getGenesis.go @@ -4,6 +4,7 @@ import ( "context" "github.com/algorand/go-algorand-sdk/v2/client/v2/common" + "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" ) // GetGenesis returns the entire genesis file in json. @@ -12,7 +13,7 @@ type GetGenesis struct { } // Do performs the HTTP request -func (s *GetGenesis) Do(ctx context.Context, headers ...*common.Header) (response string, err error) { +func (s *GetGenesis) Do(ctx context.Context, headers ...*common.Header) (response models.Genesis, err error) { err = s.c.get(ctx, &response, "/genesis", nil, headers) return } diff --git a/client/v2/common/models/genesis.go b/client/v2/common/models/genesis.go new file mode 100644 index 00000000..d487d119 --- /dev/null +++ b/client/v2/common/models/genesis.go @@ -0,0 +1,31 @@ +package models + +// Genesis defines a model for Genesis. +type Genesis struct { + // Alloc + Alloc []GenesisAllocation `json:"alloc"` + + // Comment + Comment string `json:"comment,omitempty"` + + // Devmode + Devmode bool `json:"devmode,omitempty"` + + // Fees + Fees string `json:"fees"` + + // Id + Id string `json:"id"` + + // Network + Network string `json:"network"` + + // Proto + Proto string `json:"proto"` + + // Rwd + Rwd string `json:"rwd"` + + // Timestamp + Timestamp uint64 `json:"timestamp"` +} diff --git a/client/v2/common/models/genesis_allocation.go b/client/v2/common/models/genesis_allocation.go new file mode 100644 index 00000000..c6305ddb --- /dev/null +++ b/client/v2/common/models/genesis_allocation.go @@ -0,0 +1,13 @@ +package models + +// GenesisAllocation defines a model for GenesisAllocation. +type GenesisAllocation struct { + // Addr + Addr string `json:"addr"` + + // Comment + Comment string `json:"comment"` + + // State + State *map[string]interface{} `json:"state"` +} diff --git a/client/v2/common/models/kv_delta.go b/client/v2/common/models/kv_delta.go deleted file mode 100644 index c76f1085..00000000 --- a/client/v2/common/models/kv_delta.go +++ /dev/null @@ -1,11 +0,0 @@ -package models - -// KvDelta a single Delta containing the key, the previous value and the current -// value for a single round. -type KvDelta struct { - // Key the key, base64 encoded. - Key []byte `json:"key,omitempty"` - - // Value the new value of the KV store entry, base64 encoded. - Value []byte `json:"value,omitempty"` -}