Skip to content

Commit 4781c16

Browse files
committed
Merge branch 'release/v1.24.0'
2 parents f29a667 + f29b791 commit 4781c16

File tree

13 files changed

+383
-230
lines changed

13 files changed

+383
-230
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# 1.24.0
2+
## What's Changed
3+
### Bugfixes
4+
* BugFix: Fix disassemble endpoint by @zyablitsev in https://github.com/algorand/go-algorand-sdk/pull/436
5+
### Enhancements
6+
* Tests: Support for new cucumber app call txn decoding test by @jasonpaulos in https://github.com/algorand/go-algorand-sdk/pull/433
7+
* Tests: Migrate v1 algod dependencies to v2 in cucumber tests by @algochoi in https://github.com/algorand/go-algorand-sdk/pull/434
8+
* REST API: Add KV counts to NodeStatusResponse by @michaeldiamant in https://github.com/algorand/go-algorand-sdk/pull/437
9+
* Enhancement: allowing zero length static array by @ahangsu in https://github.com/algorand/go-algorand-sdk/pull/438
10+
* Enhancement: revert generic StateProof txn field by @shiqizng in https://github.com/algorand/go-algorand-sdk/pull/439
11+
* Refactoring: Move old transaction dependencies to future.transaction by @algochoi in https://github.com/algorand/go-algorand-sdk/pull/435
12+
13+
## New Contributors
14+
* @zyablitsev made their first contribution in https://github.com/algorand/go-algorand-sdk/pull/436
15+
16+
**Full Changelog**: https://github.com/algorand/go-algorand-sdk/compare/v1.23.0...v1.24.0
17+
118
# 1.23.0
219
## What's Changed
320
### New Features

client/v2/algod/tealDisassemble.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ type TealDisassemble struct {
1818

1919
// Do performs the HTTP request
2020
func (s *TealDisassemble) Do(ctx context.Context, headers ...*common.Header) (response models.DisassembleResponse, err error) {
21-
err = s.c.get(ctx, &response, "/v2/teal/disassemble", nil, headers)
21+
err = s.c.post(ctx, &response, "/v2/teal/disassemble", nil, headers, s.source)
2222
return
2323
}

client/v2/common/common.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ import (
1717

1818
// rawRequestPaths is a set of paths where the body should not be urlencoded
1919
var rawRequestPaths = map[string]bool{
20-
"/v2/transactions": true,
21-
"/v2/teal/compile": true,
22-
"/v2/teal/dryrun": true,
20+
"/v2/transactions": true,
21+
"/v2/teal/compile": true,
22+
"/v2/teal/disassemble": true,
23+
"/v2/teal/dryrun": true,
2324
}
2425

2526
// Header is a struct for custom headers.

client/v2/common/models/node_status_response.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ type NodeStatusResponse struct {
1313
// that have been processed so far as part of the catchup
1414
CatchpointProcessedAccounts uint64 `json:"catchpoint-processed-accounts,omitempty"`
1515

16+
// CatchpointProcessedKvs the number of key-values (KVs) from the current
17+
// catchpoint that have been processed so far as part of the catchup
18+
CatchpointProcessedKvs uint64 `json:"catchpoint-processed-kvs,omitempty"`
19+
1620
// CatchpointTotalAccounts the total number of accounts included in the current
1721
// catchpoint
1822
CatchpointTotalAccounts uint64 `json:"catchpoint-total-accounts,omitempty"`
@@ -21,10 +25,18 @@ type NodeStatusResponse struct {
2125
// the current catchpoint catchup
2226
CatchpointTotalBlocks uint64 `json:"catchpoint-total-blocks,omitempty"`
2327

28+
// CatchpointTotalKvs the total number of key-values (KVs) included in the current
29+
// catchpoint
30+
CatchpointTotalKvs uint64 `json:"catchpoint-total-kvs,omitempty"`
31+
2432
// CatchpointVerifiedAccounts the number of accounts from the current catchpoint
2533
// that have been verified so far as part of the catchup
2634
CatchpointVerifiedAccounts uint64 `json:"catchpoint-verified-accounts,omitempty"`
2735

36+
// CatchpointVerifiedKvs the number of key-values (KVs) from the current catchpoint
37+
// that have been verified so far as part of the catchup
38+
CatchpointVerifiedKvs uint64 `json:"catchpoint-verified-kvs,omitempty"`
39+
2840
// CatchupTime catchupTime in nanoseconds
2941
CatchupTime uint64 `json:"catchup-time"`
3042

future/transaction.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
package future
22

33
import (
4+
"bytes"
45
"encoding/base64"
56
"fmt"
67

8+
"github.com/algorand/go-algorand-sdk/crypto"
9+
"github.com/algorand/go-algorand-sdk/encoding/msgpack"
710
"github.com/algorand/go-algorand-sdk/transaction"
811
"github.com/algorand/go-algorand-sdk/types"
912
)
1013

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

17+
// NumOfAdditionalBytesAfterSigning is the number of bytes added to a txn after signing it
18+
const NumOfAdditionalBytesAfterSigning = 75
19+
1420
func setFee(tx types.Transaction, params types.SuggestedParams) (types.Transaction, error) {
1521
if !params.FlatFee {
16-
eSize, err := transaction.EstimateSize(tx)
22+
eSize, err := EstimateSize(tx)
1723
if err != nil {
1824
return types.Transaction{}, err
1925
}
@@ -1273,6 +1279,35 @@ func MakeApplicationCallTxWithBoxes(
12731279
return setFee(tx, sp)
12741280
}
12751281

1282+
// AssignGroupID computes and return list of transactions with Group field set.
1283+
// - txns is a list of transactions to process
1284+
// - account specifies a sender field of transaction to return. Set to empty string to return all of them
1285+
func AssignGroupID(txns []types.Transaction, account string) (result []types.Transaction, err error) {
1286+
gid, err := crypto.ComputeGroupID(txns)
1287+
if err != nil {
1288+
return
1289+
}
1290+
var decoded types.Address
1291+
if account != "" {
1292+
decoded, err = types.DecodeAddress(account)
1293+
if err != nil {
1294+
return
1295+
}
1296+
}
1297+
for _, tx := range txns {
1298+
if account == "" || bytes.Compare(tx.Sender[:], decoded[:]) == 0 {
1299+
tx.Group = gid
1300+
result = append(result, tx)
1301+
}
1302+
}
1303+
return result, nil
1304+
}
1305+
1306+
// EstimateSize returns the estimated length of the encoded transaction
1307+
func EstimateSize(txn types.Transaction) (uint64, error) {
1308+
return uint64(len(msgpack.Encode(txn))) + NumOfAdditionalBytesAfterSigning, nil
1309+
}
1310+
12761311
func parseTxnAccounts(accounts []string) (parsed []types.Address, err error) {
12771312
for _, acct := range accounts {
12781313
addr, err := types.DecodeAddress(acct)

future/transaction_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/algorand/go-algorand-sdk/crypto"
88
"github.com/algorand/go-algorand-sdk/encoding/msgpack"
99
"github.com/algorand/go-algorand-sdk/mnemonic"
10-
"github.com/algorand/go-algorand-sdk/transaction"
1110
"github.com/algorand/go-algorand-sdk/types"
1211
"github.com/stretchr/testify/require"
1312
)
@@ -841,15 +840,15 @@ func TestComputeGroupID(t *testing.T) {
841840
require.Equal(t, byteFromBase64(goldenTxg), txg)
842841

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

848-
result, err = transaction.AssignGroupID([]types.Transaction{tx1, tx2}, address)
847+
result, err = AssignGroupID([]types.Transaction{tx1, tx2}, address)
849848
require.NoError(t, err)
850849
require.Equal(t, 2, len(result))
851850

852-
result, err = transaction.AssignGroupID([]types.Transaction{tx1, tx2}, "")
851+
result, err = AssignGroupID([]types.Transaction{tx1, tx2}, "")
853852
require.NoError(t, err)
854853
require.Equal(t, 2, len(result))
855854
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/algorand/go-algorand-sdk
33
go 1.17
44

55
require (
6-
github.com/algorand/avm-abi v0.1.0
6+
github.com/algorand/avm-abi v0.1.1
77
github.com/algorand/go-codec/codec v1.1.8
88
github.com/cucumber/godog v0.8.1
99
github.com/google/go-querystring v1.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/algorand/avm-abi v0.1.0 h1:znZFQXpSUVYz37vXbaH5OZG2VK4snTyXwnc/tV9CVr4=
2-
github.com/algorand/avm-abi v0.1.0/go.mod h1:+CgwM46dithy850bpTeHh9MC99zpn2Snirb3QTl2O/g=
1+
github.com/algorand/avm-abi v0.1.1 h1:dbyQKzXiyaEbzpmqXFB30yAhyqseBsyqXTyZbNbkh2Y=
2+
github.com/algorand/avm-abi v0.1.1/go.mod h1:+CgwM46dithy850bpTeHh9MC99zpn2Snirb3QTl2O/g=
33
github.com/algorand/go-codec v1.1.8 h1:XDSreeeZY8gMst6Edz4RBkl08/DGMJOeHYkoXL2B7wI=
44
github.com/algorand/go-codec v1.1.8/go.mod h1:XhzVs6VVyWMLu6cApb9/192gBjGRVGm5cX5j203Heg4=
55
github.com/algorand/go-codec/codec v1.1.8 h1:lsFuhcOH2LiEhpBH3BVUUkdevVmwCRyvb7FCAAPeY6U=

test/applications_integration_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func anAlgodVClientConnectedToPortWithToken(v int, host string, port int, token
4040
portAsString := strconv.Itoa(port)
4141
fullHost := "http://" + host + ":" + portAsString
4242
algodV2client, err = algod.MakeClient(fullHost, token)
43+
aclv2 = algodV2client
4344
gh = []byte("MLWBXKMRJ5W3USARAFOHPQJAF4DN6KY3ZJVPIXKODKNN5ZXSZ2DQ")
4445

4546
return err
@@ -328,6 +329,10 @@ func parseBoxes(boxesStr string) (staticBoxes []types.AppBoxReference, err error
328329
}
329330
}
330331

332+
if len(nameBytes) == 0 {
333+
nameBytes = nil
334+
}
335+
331336
staticBoxes = append(staticBoxes,
332337
types.AppBoxReference{
333338
AppID: appID,

0 commit comments

Comments
 (0)