Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
87bbe39
Boxes: Support for Box array transaction field (#337)
michaeldiamant Jul 6, 2022
3956391
Boxes: Query algod Box by application ID and Box name (#338)
michaeldiamant Jul 8, 2022
475a670
Boxes: Add convenience methods for encoding Box names (#342)
michaeldiamant Jul 12, 2022
69644b7
Boxes: Support GetApplicationBoxes (#344)
michaeldiamant Jul 15, 2022
42ba3e3
Merge develop into feature/box-storage (#353)
algochoi Aug 9, 2022
b21b064
Enhancement: Merge `develop` to `feature/box-storage` (#384)
ahangsu Sep 2, 2022
1e09eac
Merge branch 'develop' into feature/box-storage
ahangsu Sep 2, 2022
7d154c4
Box support for Indexer endpoints (#355)
algochoi Sep 6, 2022
6b2f7ba
boxes integration algod test
ahangsu Sep 7, 2022
78ca163
Enhancement: Boxes Indexer Integration test (#391)
ahangsu Sep 15, 2022
266621b
remove unnecessary @applications tag
ahangsu Sep 20, 2022
64001fb
remove unnecessary func
ahangsu Sep 21, 2022
c5e5af8
refactoring in algodclientv2 test
ahangsu Sep 21, 2022
fab3e31
Re-run generator for boxes branch (#411)
jasonpaulos Sep 26, 2022
a042df9
Box storage improvements from review (#410)
jasonpaulos Sep 26, 2022
15c411b
Merge branch 'develop' into feature/box-storage
jasonpaulos Oct 12, 2022
fef13bc
Remove newline
jasonpaulos Oct 12, 2022
5e94270
Box storage merge develop (#425)
jasonpaulos Oct 12, 2022
e2ec98f
Merge branch 'box-storage-merge-develop' into feature/box-storage
jasonpaulos Oct 12, 2022
5d2e5cf
Merge branch 'develop' into feature/box-storage
jasonpaulos Oct 12, 2022
600e1df
Box storage: Improvements from generator (#417)
jasonpaulos Oct 12, 2022
9ae6afa
Re-generate sources from upstream AVM branches
michaeldiamant Oct 31, 2022
1236c6a
Merge branch 'develop' into update_master
michaeldiamant Oct 31, 2022
906ec89
update circle go orb
Oct 31, 2022
87f2a33
don't test unsupported version 1.16 on circle
Oct 31, 2022
47ac940
Update .gitignore
tzaffi Oct 31, 2022
4ca3bd3
Update .circleci/config.yml
tzaffi Oct 31, 2022
86d287b
revert
Oct 31, 2022
9d69302
Merge pull request #429 from algorand/update_update_master
tzaffi Oct 31, 2022
80e7f91
Revert SDK_TESTING_BRANCH to master
michaeldiamant Nov 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
}
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 {
Comment thread
jasonpaulos marked this conversation as resolved.
// 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
47 changes: 47 additions & 0 deletions client/v2/indexer/lookupApplicationBoxByIDandName.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package indexer

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

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

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

// Name a box name in goal-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"`
}

// LookupApplicationBoxByIDAndName given an application ID and box name, returns
// base64 encoded box name and value. Box names must be in the goal app call arg
// form 'encoding:value'. For ints, use the form 'int:1234'. For raw bytes, encode
// base 64 and use 'b64' prefix as in 'b64:A=='. For printable strings, use the
// form 'str:hello'. For addresses, use the form 'addr:XYZ...'.
type LookupApplicationBoxByIDAndName struct {
c *Client

applicationId uint64

p LookupApplicationBoxByIDAndNameParams
}

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

return s
}

// Do performs the HTTP request
func (s *LookupApplicationBoxByIDAndName) 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
}
53 changes: 53 additions & 0 deletions client/v2/indexer/searchForApplicationBoxes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package indexer

import (
"context"
"fmt"

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

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

// Limit maximum number of results to return. There could be additional pages even
// if the limit is not reached.
Limit uint64 `url:"limit,omitempty"`

// Next the next page of results. Use the next token provided by the previous
// results.
Next string `url:"next,omitempty"`
}

// SearchForApplicationBoxes given an application ID, returns the box names of that
// application sorted lexicographically.
type SearchForApplicationBoxes struct {
c *Client

applicationId uint64

p SearchForApplicationBoxesParams
}

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

return s
}

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

return s
}

// Do performs the HTTP request
func (s *SearchForApplicationBoxes) 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
}
18 changes: 8 additions & 10 deletions future/atomicTransactionComposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ type AddMethodCallParams struct {
// Any foreign accounts to be passed that aren't part of the method signature
// If accounts are provided here, the accounts specified in the method args will appear after these
ForeignAccounts []string

// References of the boxes to be accessed by this method call.
BoxReferences []types.AppBoxReference
}

// ExecuteResult contains the results of successfully calling the Execute method on an
Expand Down Expand Up @@ -167,8 +170,8 @@ type AtomicTransactionComposer struct {
// The current status of the composer. The status increases monotonically.
status AtomicTransactionComposerStatus

// The transaction contexts in the group with their respective signers. If status is greater then
// BUILDING then this slice cannot change.
// The transaction contexts in the group with their respective signers.
// If status is greater than BUILDING, then this slice cannot change.
txContexts []transactionContext
}

Expand Down Expand Up @@ -373,17 +376,19 @@ func (atc *AtomicTransactionComposer) AddMethodCall(params AddMethodCallParams)
encodedAbiArgs = append(encodedAbiArgs, encodedArg)
}

tx, err := MakeApplicationCallTx(
tx, err := MakeApplicationCallTxWithBoxes(
params.AppID,
encodedAbiArgs,
foreignAccounts,
foreignApps,
foreignAssets,
params.BoxReferences,
params.OnComplete,
params.ApprovalProgram,
params.ClearProgram,
params.GlobalSchema,
params.LocalSchema,
params.ExtraPages,
params.SuggestedParams,
params.Sender,
params.Note,
Expand All @@ -394,13 +399,6 @@ func (atc *AtomicTransactionComposer) AddMethodCall(params AddMethodCallParams)
return err
}

if params.ExtraPages != 0 {
tx, err = MakeApplicationCallTxWithExtraPages(tx, params.ExtraPages)
if err != nil {
return err
}
}

txAndSigner := TransactionWithSigner{
Txn: tx,
Signer: params.Signer,
Expand Down
Loading