Skip to content

Commit

Permalink
Merge branch 'release/v1.23.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
excalq committed Nov 3, 2022
2 parents d4e6bdf + 8a4d656 commit f29a667
Show file tree
Hide file tree
Showing 46 changed files with 1,257 additions and 126 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
go: circleci/go@1.7.0
go: circleci/go@1.7.1

workflows:
circleci_build_and_test:
Expand All @@ -10,7 +10,7 @@ workflows:
name: 'test_go_<< matrix.go_version >>'
matrix:
parameters:
go_version: ['1.16', '1.17']
go_version: ['1.17']

jobs:
test:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ coverage.html
# Testing files
*.feature
temp

# asdf
.tool-versions
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.23.0
## What's Changed
### New Features
* Boxes: Add support for Boxes by @michaeldiamant in https://github.com/algorand/go-algorand-sdk/pull/341

**Full Changelog**: https://github.com/algorand/go-algorand-sdk/compare/v1.22.0...v1.23.0

# 1.22.0
## What's Changed
## Enhancements
Expand Down
1 change: 1 addition & 0 deletions client/v2/algod/accountInformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type AccountInformation struct {
// `none`.
func (s *AccountInformation) Exclude(Exclude string) *AccountInformation {
s.p.Exclude = Exclude

return s
}

Expand Down
8 changes: 8 additions & 0 deletions client/v2/algod/algod.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ func (c *Client) GetApplicationByID(applicationId uint64) *GetApplicationByID {
return &GetApplicationByID{c: c, applicationId: applicationId}
}

func (c *Client) GetApplicationBoxes(applicationId uint64) *GetApplicationBoxes {
return &GetApplicationBoxes{c: c, applicationId: applicationId}
}

func (c *Client) GetApplicationBoxByName(applicationId uint64, name []byte) *GetApplicationBoxByName {
return (&GetApplicationBoxByName{c: c, applicationId: applicationId}).name(name)
}

func (c *Client) GetAssetByID(assetId uint64) *GetAssetByID {
return &GetAssetByID{c: c, assetId: assetId}
}
Expand Down
47 changes: 47 additions & 0 deletions client/v2/algod/getApplicationBoxByName.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package algod

import (
"context"
"encoding/base64"
"fmt"

"github.com/algorand/go-algorand-sdk/client/v2/common"
"github.com/algorand/go-algorand-sdk/client/v2/common/models"
)

// GetApplicationBoxByNameParams contains all of the query parameters for url serialization.
type GetApplicationBoxByNameParams struct {

// Name a box name, 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...'.
Name string `url:"name,omitempty"`
}

// GetApplicationBoxByName given an application ID and box name, it returns the box
// name and value (each base64 encoded). Box names must be in the goal app call arg
// encoding 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...'.
type GetApplicationBoxByName struct {
c *Client

applicationId uint64

p GetApplicationBoxByNameParams
}

// name a box name, 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 *GetApplicationBoxByName) name(name []byte) *GetApplicationBoxByName {
s.p.Name = "b64:" + base64.StdEncoding.EncodeToString(name)

return s
}

// Do performs the HTTP request
func (s *GetApplicationBoxByName) Do(ctx context.Context, headers ...*common.Header) (response models.Box, err error) {
err = s.c.get(ctx, &response, fmt.Sprintf("/v2/applications/%s/box", common.EscapeParams(s.applicationId)...), s.p, headers)
return
}
42 changes: 42 additions & 0 deletions client/v2/algod/getApplicationBoxes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package algod

import (
"context"
"fmt"

"github.com/algorand/go-algorand-sdk/client/v2/common"
"github.com/algorand/go-algorand-sdk/client/v2/common/models"
)

// 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 uint64 `url:"max,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.
type GetApplicationBoxes struct {
c *Client

applicationId uint64

p GetApplicationBoxesParams
}

// Max max number of box names to return. If max is not set, or max == 0, returns
// all box-names.
func (s *GetApplicationBoxes) Max(Max uint64) *GetApplicationBoxes {
s.p.Max = Max

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)
return
}
1 change: 1 addition & 0 deletions client/v2/algod/getPendingTransactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type PendingTransactions struct {
// txns.
func (s *PendingTransactions) Max(Max uint64) *PendingTransactions {
s.p.Max = Max

return s
}

Expand Down
1 change: 1 addition & 0 deletions client/v2/algod/getPendingTransactionsByAddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type PendingTransactionsByAddress struct {
// txns.
func (s *PendingTransactionsByAddress) Max(Max uint64) *PendingTransactionsByAddress {
s.p.Max = Max

return s
}

Expand Down
1 change: 1 addition & 0 deletions client/v2/algod/getTransactionProof.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type GetTransactionProof struct {
// * sha256
func (s *GetTransactionProof) Hashtype(Hashtype string) *GetTransactionProof {
s.p.Hashtype = Hashtype

return s
}

Expand Down
1 change: 1 addition & 0 deletions client/v2/algod/tealCompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type TealCompile struct {
// Defaults to `false`.
func (s *TealCompile) Sourcemap(Sourcemap bool) *TealCompile {
s.p.Sourcemap = Sourcemap

return s
}

Expand Down
8 changes: 8 additions & 0 deletions client/v2/common/models/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ type Account struct {
// to the count of AssetHolding objects held by this account.
TotalAssetsOptedIn uint64 `json:"total-assets-opted-in"`

// TotalBoxBytes for app-accounts only. The total number of bytes allocated for the
// keys and values of boxes which belong to the associated application.
TotalBoxBytes uint64 `json:"total-box-bytes"`

// TotalBoxes for app-accounts only. The total number of boxes which belong to the
// associated application.
TotalBoxes uint64 `json:"total-boxes"`

// TotalCreatedApps the count of all apps (AppParams objects) created by this
// account.
TotalCreatedApps uint64 `json:"total-created-apps"`
Expand Down
10 changes: 10 additions & 0 deletions client/v2/common/models/box.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package models

// Box box name and its content.
type Box struct {
// Name (name) box name, base64 encoded
Name []byte `json:"name"`

// Value (value) box value, base64 encoded.
Value []byte `json:"value"`
}
7 changes: 7 additions & 0 deletions client/v2/common/models/box_descriptor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package models

// BoxDescriptor box descriptor describes an app box without a value.
type BoxDescriptor struct {
// Name base64 encoded box name
Name []byte `json:"name"`
}
14 changes: 14 additions & 0 deletions client/v2/common/models/boxes_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package models

// BoxesResponse box names of an application
type BoxesResponse struct {
// ApplicationId (appidx) application index.
ApplicationId uint64 `json:"application-id"`

// Boxes
Boxes []BoxDescriptor `json:"boxes"`

// NextToken used for pagination, when making another request provide this token
// with the next parameter.
NextToken string `json:"next-token,omitempty"`
}
8 changes: 8 additions & 0 deletions client/v2/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ func (c *Client) LookupApplicationByID(applicationId uint64) *LookupApplicationB
return &LookupApplicationByID{c: c, applicationId: applicationId}
}

func (c *Client) SearchForApplicationBoxes(applicationId uint64) *SearchForApplicationBoxes {
return &SearchForApplicationBoxes{c: c, applicationId: applicationId}
}

func (c *Client) LookupApplicationBoxByIDAndName(applicationId uint64, name []byte) *LookupApplicationBoxByIDAndName {
return (&LookupApplicationBoxByIDAndName{c: c, applicationId: applicationId}).name(name)
}

func (c *Client) LookupApplicationLogsByID(applicationId uint64) *LookupApplicationLogsByID {
return &LookupApplicationLogsByID{c: c, applicationId: applicationId}
}
Expand Down
4 changes: 4 additions & 0 deletions client/v2/indexer/lookupAccountAppLocalStates.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type LookupAccountAppLocalStates struct {
// ApplicationID application ID
func (s *LookupAccountAppLocalStates) ApplicationID(ApplicationID uint64) *LookupAccountAppLocalStates {
s.p.ApplicationID = ApplicationID

return s
}

Expand All @@ -49,20 +50,23 @@ func (s *LookupAccountAppLocalStates) ApplicationID(ApplicationID uint64) *Looku
// localstates.
func (s *LookupAccountAppLocalStates) IncludeAll(IncludeAll bool) *LookupAccountAppLocalStates {
s.p.IncludeAll = IncludeAll

return s
}

// Limit maximum number of results to return. There could be additional pages even
// if the limit is not reached.
func (s *LookupAccountAppLocalStates) Limit(Limit uint64) *LookupAccountAppLocalStates {
s.p.Limit = Limit

return s
}

// Next the next page of results. Use the next token provided by the previous
// results.
func (s *LookupAccountAppLocalStates) Next(Next string) *LookupAccountAppLocalStates {
s.p.Next = Next

return s
}

Expand Down
4 changes: 4 additions & 0 deletions client/v2/indexer/lookupAccountAssets.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type LookupAccountAssets struct {
// AssetID asset ID
func (s *LookupAccountAssets) AssetID(AssetID uint64) *LookupAccountAssets {
s.p.AssetID = AssetID

return s
}

Expand All @@ -49,20 +50,23 @@ func (s *LookupAccountAssets) AssetID(AssetID uint64) *LookupAccountAssets {
// localstates.
func (s *LookupAccountAssets) IncludeAll(IncludeAll bool) *LookupAccountAssets {
s.p.IncludeAll = IncludeAll

return s
}

// Limit maximum number of results to return. There could be additional pages even
// if the limit is not reached.
func (s *LookupAccountAssets) Limit(Limit uint64) *LookupAccountAssets {
s.p.Limit = Limit

return s
}

// Next the next page of results. Use the next token provided by the previous
// results.
func (s *LookupAccountAssets) Next(Next string) *LookupAccountAssets {
s.p.Next = Next

return s
}

Expand Down
3 changes: 3 additions & 0 deletions client/v2/indexer/lookupAccountByID.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type LookupAccountByID struct {
// application parameters created by this account.
func (s *LookupAccountByID) Exclude(Exclude []string) *LookupAccountByID {
s.p.Exclude = Exclude

return s
}

Expand All @@ -47,12 +48,14 @@ func (s *LookupAccountByID) Exclude(Exclude []string) *LookupAccountByID {
// localstates.
func (s *LookupAccountByID) IncludeAll(IncludeAll bool) *LookupAccountByID {
s.p.IncludeAll = IncludeAll

return s
}

// Round include results for the specified round.
func (s *LookupAccountByID) Round(Round uint64) *LookupAccountByID {
s.p.Round = Round

return s
}

Expand Down
4 changes: 4 additions & 0 deletions client/v2/indexer/lookupAccountCreatedApplications.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type LookupAccountCreatedApplications struct {
// ApplicationID application ID
func (s *LookupAccountCreatedApplications) ApplicationID(ApplicationID uint64) *LookupAccountCreatedApplications {
s.p.ApplicationID = ApplicationID

return s
}

Expand All @@ -49,20 +50,23 @@ func (s *LookupAccountCreatedApplications) ApplicationID(ApplicationID uint64) *
// localstates.
func (s *LookupAccountCreatedApplications) IncludeAll(IncludeAll bool) *LookupAccountCreatedApplications {
s.p.IncludeAll = IncludeAll

return s
}

// Limit maximum number of results to return. There could be additional pages even
// if the limit is not reached.
func (s *LookupAccountCreatedApplications) Limit(Limit uint64) *LookupAccountCreatedApplications {
s.p.Limit = Limit

return s
}

// Next the next page of results. Use the next token provided by the previous
// results.
func (s *LookupAccountCreatedApplications) Next(Next string) *LookupAccountCreatedApplications {
s.p.Next = Next

return s
}

Expand Down
4 changes: 4 additions & 0 deletions client/v2/indexer/lookupAccountCreatedAssets.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type LookupAccountCreatedAssets struct {
// AssetID asset ID
func (s *LookupAccountCreatedAssets) AssetID(AssetID uint64) *LookupAccountCreatedAssets {
s.p.AssetID = AssetID

return s
}

Expand All @@ -49,20 +50,23 @@ func (s *LookupAccountCreatedAssets) AssetID(AssetID uint64) *LookupAccountCreat
// localstates.
func (s *LookupAccountCreatedAssets) IncludeAll(IncludeAll bool) *LookupAccountCreatedAssets {
s.p.IncludeAll = IncludeAll

return s
}

// Limit maximum number of results to return. There could be additional pages even
// if the limit is not reached.
func (s *LookupAccountCreatedAssets) Limit(Limit uint64) *LookupAccountCreatedAssets {
s.p.Limit = Limit

return s
}

// Next the next page of results. Use the next token provided by the previous
// results.
func (s *LookupAccountCreatedAssets) Next(Next string) *LookupAccountCreatedAssets {
s.p.Next = Next

return s
}

Expand Down
Loading

0 comments on commit f29a667

Please sign in to comment.