Skip to content

Commit

Permalink
Merge branch 'release/v1.24.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
excalq committed Dec 6, 2022
2 parents f29a667 + f29b791 commit 4781c16
Show file tree
Hide file tree
Showing 13 changed files with 383 additions and 230 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# 1.24.0
## What's Changed
### Bugfixes
* BugFix: Fix disassemble endpoint by @zyablitsev in https://github.com/algorand/go-algorand-sdk/pull/436
### Enhancements
* Tests: Support for new cucumber app call txn decoding test by @jasonpaulos in https://github.com/algorand/go-algorand-sdk/pull/433
* Tests: Migrate v1 algod dependencies to v2 in cucumber tests by @algochoi in https://github.com/algorand/go-algorand-sdk/pull/434
* REST API: Add KV counts to NodeStatusResponse by @michaeldiamant in https://github.com/algorand/go-algorand-sdk/pull/437
* Enhancement: allowing zero length static array by @ahangsu in https://github.com/algorand/go-algorand-sdk/pull/438
* Enhancement: revert generic StateProof txn field by @shiqizng in https://github.com/algorand/go-algorand-sdk/pull/439
* Refactoring: Move old transaction dependencies to future.transaction by @algochoi in https://github.com/algorand/go-algorand-sdk/pull/435

## New Contributors
* @zyablitsev made their first contribution in https://github.com/algorand/go-algorand-sdk/pull/436

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

# 1.23.0
## What's Changed
### New Features
Expand Down
2 changes: 1 addition & 1 deletion client/v2/algod/tealDisassemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ type TealDisassemble struct {

// Do performs the HTTP request
func (s *TealDisassemble) Do(ctx context.Context, headers ...*common.Header) (response models.DisassembleResponse, err error) {
err = s.c.get(ctx, &response, "/v2/teal/disassemble", nil, headers)
err = s.c.post(ctx, &response, "/v2/teal/disassemble", nil, headers, s.source)
return
}
7 changes: 4 additions & 3 deletions client/v2/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import (

// rawRequestPaths is a set of paths where the body should not be urlencoded
var rawRequestPaths = map[string]bool{
"/v2/transactions": true,
"/v2/teal/compile": true,
"/v2/teal/dryrun": true,
"/v2/transactions": true,
"/v2/teal/compile": true,
"/v2/teal/disassemble": true,
"/v2/teal/dryrun": true,
}

// Header is a struct for custom headers.
Expand Down
12 changes: 12 additions & 0 deletions client/v2/common/models/node_status_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ type NodeStatusResponse struct {
// that have been processed so far as part of the catchup
CatchpointProcessedAccounts uint64 `json:"catchpoint-processed-accounts,omitempty"`

// CatchpointProcessedKvs the number of key-values (KVs) from the current
// catchpoint that have been processed so far as part of the catchup
CatchpointProcessedKvs uint64 `json:"catchpoint-processed-kvs,omitempty"`

// CatchpointTotalAccounts the total number of accounts included in the current
// catchpoint
CatchpointTotalAccounts uint64 `json:"catchpoint-total-accounts,omitempty"`
Expand All @@ -21,10 +25,18 @@ type NodeStatusResponse struct {
// the current catchpoint catchup
CatchpointTotalBlocks uint64 `json:"catchpoint-total-blocks,omitempty"`

// CatchpointTotalKvs the total number of key-values (KVs) included in the current
// catchpoint
CatchpointTotalKvs uint64 `json:"catchpoint-total-kvs,omitempty"`

// CatchpointVerifiedAccounts the number of accounts from the current catchpoint
// that have been verified so far as part of the catchup
CatchpointVerifiedAccounts uint64 `json:"catchpoint-verified-accounts,omitempty"`

// CatchpointVerifiedKvs the number of key-values (KVs) from the current catchpoint
// that have been verified so far as part of the catchup
CatchpointVerifiedKvs uint64 `json:"catchpoint-verified-kvs,omitempty"`

// CatchupTime catchupTime in nanoseconds
CatchupTime uint64 `json:"catchup-time"`

Expand Down
37 changes: 36 additions & 1 deletion future/transaction.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package future

import (
"bytes"
"encoding/base64"
"fmt"

"github.com/algorand/go-algorand-sdk/crypto"
"github.com/algorand/go-algorand-sdk/encoding/msgpack"
"github.com/algorand/go-algorand-sdk/transaction"
"github.com/algorand/go-algorand-sdk/types"
)

// MinTxnFee is v5 consensus params, in microAlgos
const MinTxnFee = transaction.MinTxnFee

// NumOfAdditionalBytesAfterSigning is the number of bytes added to a txn after signing it
const NumOfAdditionalBytesAfterSigning = 75

func setFee(tx types.Transaction, params types.SuggestedParams) (types.Transaction, error) {
if !params.FlatFee {
eSize, err := transaction.EstimateSize(tx)
eSize, err := EstimateSize(tx)
if err != nil {
return types.Transaction{}, err
}
Expand Down Expand Up @@ -1273,6 +1279,35 @@ func MakeApplicationCallTxWithBoxes(
return setFee(tx, sp)
}

// AssignGroupID computes and return list of transactions with Group field set.
// - txns is a list of transactions to process
// - account specifies a sender field of transaction to return. Set to empty string to return all of them
func AssignGroupID(txns []types.Transaction, account string) (result []types.Transaction, err error) {
gid, err := crypto.ComputeGroupID(txns)
if err != nil {
return
}
var decoded types.Address
if account != "" {
decoded, err = types.DecodeAddress(account)
if err != nil {
return
}
}
for _, tx := range txns {
if account == "" || bytes.Compare(tx.Sender[:], decoded[:]) == 0 {
tx.Group = gid
result = append(result, tx)
}
}
return result, nil
}

// EstimateSize returns the estimated length of the encoded transaction
func EstimateSize(txn types.Transaction) (uint64, error) {
return uint64(len(msgpack.Encode(txn))) + NumOfAdditionalBytesAfterSigning, nil
}

func parseTxnAccounts(accounts []string) (parsed []types.Address, err error) {
for _, acct := range accounts {
addr, err := types.DecodeAddress(acct)
Expand Down
7 changes: 3 additions & 4 deletions future/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/algorand/go-algorand-sdk/crypto"
"github.com/algorand/go-algorand-sdk/encoding/msgpack"
"github.com/algorand/go-algorand-sdk/mnemonic"
"github.com/algorand/go-algorand-sdk/transaction"
"github.com/algorand/go-algorand-sdk/types"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -841,15 +840,15 @@ func TestComputeGroupID(t *testing.T) {
require.Equal(t, byteFromBase64(goldenTxg), txg)

// check transaction.AssignGroupID, do not validate correctness of Group field calculation
result, err := transaction.AssignGroupID([]types.Transaction{tx1, tx2}, "BH55E5RMBD4GYWXGX5W5PJ5JAHPGM5OXKDQH5DC4O2MGI7NW4H6VOE4CP4")
result, err := AssignGroupID([]types.Transaction{tx1, tx2}, "BH55E5RMBD4GYWXGX5W5PJ5JAHPGM5OXKDQH5DC4O2MGI7NW4H6VOE4CP4")
require.NoError(t, err)
require.Equal(t, 0, len(result))

result, err = transaction.AssignGroupID([]types.Transaction{tx1, tx2}, address)
result, err = AssignGroupID([]types.Transaction{tx1, tx2}, address)
require.NoError(t, err)
require.Equal(t, 2, len(result))

result, err = transaction.AssignGroupID([]types.Transaction{tx1, tx2}, "")
result, err = AssignGroupID([]types.Transaction{tx1, tx2}, "")
require.NoError(t, err)
require.Equal(t, 2, len(result))
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/algorand/go-algorand-sdk
go 1.17

require (
github.com/algorand/avm-abi v0.1.0
github.com/algorand/avm-abi v0.1.1
github.com/algorand/go-codec/codec v1.1.8
github.com/cucumber/godog v0.8.1
github.com/google/go-querystring v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/algorand/avm-abi v0.1.0 h1:znZFQXpSUVYz37vXbaH5OZG2VK4snTyXwnc/tV9CVr4=
github.com/algorand/avm-abi v0.1.0/go.mod h1:+CgwM46dithy850bpTeHh9MC99zpn2Snirb3QTl2O/g=
github.com/algorand/avm-abi v0.1.1 h1:dbyQKzXiyaEbzpmqXFB30yAhyqseBsyqXTyZbNbkh2Y=
github.com/algorand/avm-abi v0.1.1/go.mod h1:+CgwM46dithy850bpTeHh9MC99zpn2Snirb3QTl2O/g=
github.com/algorand/go-codec v1.1.8 h1:XDSreeeZY8gMst6Edz4RBkl08/DGMJOeHYkoXL2B7wI=
github.com/algorand/go-codec v1.1.8/go.mod h1:XhzVs6VVyWMLu6cApb9/192gBjGRVGm5cX5j203Heg4=
github.com/algorand/go-codec/codec v1.1.8 h1:lsFuhcOH2LiEhpBH3BVUUkdevVmwCRyvb7FCAAPeY6U=
Expand Down
5 changes: 5 additions & 0 deletions test/applications_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func anAlgodVClientConnectedToPortWithToken(v int, host string, port int, token
portAsString := strconv.Itoa(port)
fullHost := "http://" + host + ":" + portAsString
algodV2client, err = algod.MakeClient(fullHost, token)
aclv2 = algodV2client
gh = []byte("MLWBXKMRJ5W3USARAFOHPQJAF4DN6KY3ZJVPIXKODKNN5ZXSZ2DQ")

return err
Expand Down Expand Up @@ -328,6 +329,10 @@ func parseBoxes(boxesStr string) (staticBoxes []types.AppBoxReference, err error
}
}

if len(nameBytes) == 0 {
nameBytes = nil
}

staticBoxes = append(staticBoxes,
types.AppBoxReference{
AppID: appID,
Expand Down
Loading

0 comments on commit 4781c16

Please sign in to comment.