Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e4b53e4
Github-Actions: Adding pr title and label checks (#336)
algojack Jul 6, 2022
5fa9667
Dev Tools: Source map decoder (#335)
barnjamin Jul 20, 2022
373fcc8
Updated CHANGELOG.md
algojack Jul 22, 2022
50c809e
Merge branch 'release/v1.18.0' into develop
algojack Jul 27, 2022
1f6b1a6
AVM: Consolidate TEAL and AVM versions (#345)
michaeldiamant Aug 1, 2022
b1944bc
Testing: Use Dev mode network for cucumber tests (#349)
algochoi Aug 1, 2022
f7c1489
AVM: Use avm-abi repo (#352)
jasonpaulos Aug 16, 2022
48a02ba
Updated CHANGELOG.md
algobarb Aug 17, 2022
716da0f
Merge branch 'release/v1.19.0' into develop
algobarb Aug 17, 2022
0bc0ce7
Enhancement: Use Sandbox for Testing (#360)
tzaffi Aug 22, 2022
c8a0e9b
Bug-Fix: passthru verbosity (#371)
tzaffi Aug 23, 2022
4837c34
Enhancement: Deprecating use of langspec (#366)
ahangsu Aug 26, 2022
1609463
StateProof: State proof support (#374)
Eric-Warehime Aug 29, 2022
ca1fb5d
State Proofs: Use generic type for StateProof txn field. (#378)
winder Aug 30, 2022
aa22fdf
fix type assertion on source map version (#370)
barnjamin Aug 30, 2022
7297d6e
let the json package figure out how to decode the elements of the inc…
barnjamin Aug 31, 2022
aa81e62
StateProof: State Proof Verification additions (#377)
almog-t Aug 31, 2022
fa3a208
State Proofs: added compute leaf function for light block header to s…
almog-t Sep 1, 2022
e97b2d1
renamed light block header hash func (#383)
almog-t Sep 1, 2022
d303882
Merge branch 'develop' into box-updated-to-dev
ahangsu Sep 1, 2022
eca9198
Enable stpf cucumber unit tests (#386)
Eric-Warehime Sep 2, 2022
8f5429d
Merge branch 'develop' into box-updated-to-dev
ahangsu Sep 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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ workflows:
name: 'test_go_<< matrix.go_version >>'
matrix:
parameters:
go_version: ['1.15', '1.16', '1.17']
go_version: ['1.16', '1.17']

jobs:
test:
Expand Down
14 changes: 14 additions & 0 deletions .test-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Configs for testing repo download:
SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing"
SDK_TESTING_BRANCH="feature/box-storage"
SDK_TESTING_HARNESS="test-harness"

VERBOSE_HARNESS=0

# WARNING: If set to 1, new features will be LOST when downloading the test harness.
# REGARDLESS: modified features are ALWAYS overwritten.
REMOVE_LOCAL_FEATURES=0

# WARNING: Be careful when turning on the next variable.
# In that case you'll need to provide all variables expected by `algorand-sdk-testing`'s `.env`
OVERWRITE_TESTING_ENVIRONMENT=0
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.19.0
## Enhancements
* AVM: Consolidate TEAL and AVM versions ([#345](https://github.com/algorand/go-algorand-sdk/pull/345))
* Testing: Use Dev mode network for cucumber tests ([#349](https://github.com/algorand/go-algorand-sdk/pull/349))
* AVM: Use avm-abi repo ([#352](https://github.com/algorand/go-algorand-sdk/pull/352))

# 1.18.0

## What's Changed
Expand Down
25 changes: 21 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
SRCPATH := $(shell pwd)
TEST_SOURCES := $(shell cd $(SRCPATH) && go list ./...)
TEST_SOURCES_NO_CUCUMBER := $(shell cd $(SRCPATH) && go list ./... | grep -v test)
UNIT_TAGS := "$(shell awk '{print $2}' test/unit.tags | paste -s -d, -)"
INTEGRATIONS_TAGS := "$(shell awk '{print $2}' test/integration.tags | paste -s -d, -)"
GO_IMAGE := golang:$(subst go,,$(shell go version | cut -d' ' -f 3 | cut -d'.' -f 1,2))-stretch

lint:
golint `go list ./... | grep -v /vendor/`
Expand All @@ -19,13 +22,27 @@ test:

unit:
go test $(TEST_SOURCES_NO_CUCUMBER)
cd test && go test -timeout 0s --godog.strict=true --godog.format=pretty --godog.tags="@unit.offline,@unit.algod,@unit.indexer,@unit.transactions.keyreg,@unit.rekey,@unit.tealsign,@unit.dryrun,@unit.responses,@unit.applications,@unit.applications.boxes,@unit.transactions,@unit.indexer.rekey,@unit.responses.messagepack,@unit.responses.231,@unit.responses.messagepack.231,@unit.responses.genesis,@unit.feetest,@unit.indexer.logs,@unit.abijson,@unit.abijson.byname,@unit.transactions.payment,@unit.atomic_transaction_composer,@unit.responses.unlimited_assets,@unit.indexer.ledger_refactoring,@unit.algod.ledger_refactoring,@unit.dryrun.trace.application,@unit.sourcemap" --test.v .
cd test && go test -timeout 0s --godog.strict=true --godog.format=pretty --godog.tags=$(UNIT_TAGS) --test.v .

integration:
go test $(TEST_SOURCES_NO_CUCUMBER)
cd test && go test -timeout 0s --godog.strict=true --godog.format=pretty --godog.tags="@algod,@assets,@auction,@kmd,@send,@indexer,@rekey_v1,@send.keyregtxn,@dryrun,@compile,@applications.verified,@applications.boxes,@indexer.applications,@indexer.231,@abi,@c2c,@compile.sourcemap" --test.v .
cd test && go test -timeout 0s --godog.strict=true --godog.format=pretty --godog.tags=$(INTEGRATIONS_TAGS) --test.v .

display-all-go-steps:
find test -name "*.go" | xargs grep "github.com/cucumber/godog" 2>/dev/null | cut -d: -f1 | sort | uniq | xargs grep -Eo "Step[(].[^\`]+" | awk '{sub(/:Step\(./,":")} 1' | sed -E 's/", [a-zA-Z0-9]+\)//g'

harness:
./test-harness.sh

docker-gosdk-build:
echo "Building docker image from base $(GO_IMAGE)"
docker build -t go-sdk-testing --build-arg GO_IMAGE="$(GO_IMAGE)" -f test/docker/Dockerfile $(shell pwd)

docker-gosdk-run:
docker ps -a
docker run -it --network host go-sdk-testing:latest

docker-test: harness docker-gosdk-build docker-gosdk-run

docker-test:
./test/docker/run_docker.sh

.PHONY: test fmt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ In `client/v2` the `indexer` package contains a client for the Algorand Indexer

# SDK Development

Run tests with `make docker-test`
Run tests with `make docker-test`. To set up the sandbox-based test harness without standing up the go-algorand docker image use `make harness`.

# Quick Start

Expand Down
69 changes: 51 additions & 18 deletions abi/abi.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,66 @@
package abi

import (
"fmt"
"math"

"github.com/algorand/go-algorand/data/abi"
avm_abi "github.com/algorand/avm-abi/abi"
)

type Type = abi.Type
type Type = avm_abi.Type

func TypeOf(str string) (Type, error) {
return abi.TypeOf(str)
return avm_abi.TypeOf(str)
}

// MakeTupleType makes tuple ABI type by taking an array of tuple element types as argument.
func MakeTupleType(argumentTypes []Type) (Type, error) {
if len(argumentTypes) == 0 {
return Type{}, fmt.Errorf("tuple must contain at least one type")
}
return avm_abi.MakeTupleType(argumentTypes)
}

// AnyTransactionType is the ABI argument type string for a nonspecific transaction argument
const AnyTransactionType = avm_abi.AnyTransactionType

// PaymentTransactionType is the ABI argument type string for a payment transaction argument
const PaymentTransactionType = avm_abi.PaymentTransactionType

// KeyRegistrationTransactionType is the ABI argument type string for a key registration transaction
// argument
const KeyRegistrationTransactionType = avm_abi.KeyRegistrationTransactionType

// AssetConfigTransactionType is the ABI argument type string for an asset configuration transaction
// argument
const AssetConfigTransactionType = avm_abi.AssetConfigTransactionType

// AssetTransferTransactionType is the ABI argument type string for an asset transfer transaction
// argument
const AssetTransferTransactionType = avm_abi.AssetTransferTransactionType

if len(argumentTypes) >= math.MaxUint16 {
return Type{}, fmt.Errorf("tuple type child type number larger than maximum uint16 error")
}
// AssetFreezeTransactionType is the ABI argument type string for an asset freeze transaction
// argument
const AssetFreezeTransactionType = avm_abi.AssetFreezeTransactionType

strTuple := "(" + argumentTypes[0].String()
for i := 1; i < len(argumentTypes); i++ {
strTuple += "," + argumentTypes[i].String()
}
strTuple += ")"
// ApplicationCallTransactionType is the ABI argument type string for an application call
// transaction argument
const ApplicationCallTransactionType = avm_abi.ApplicationCallTransactionType

return TypeOf(strTuple)
// IsTransactionType checks if a type string represents a transaction type
// argument, such as "txn", "pay", "keyreg", etc.
func IsTransactionType(typeStr string) bool {
return avm_abi.IsTransactionType(typeStr)
}

// AccountReferenceType is the ABI argument type string for account references
const AccountReferenceType = avm_abi.AccountReferenceType

// AssetReferenceType is the ABI argument type string for asset references
const AssetReferenceType = avm_abi.AssetReferenceType

// ApplicationReferenceType is the ABI argument type string for application references
const ApplicationReferenceType = avm_abi.ApplicationReferenceType

// IsReferenceType checks if a type string represents a reference type argument,
// such as "account", "asset", or "application".
func IsReferenceType(typeStr string) bool {
return avm_abi.IsReferenceType(typeStr)
}

// VoidReturnType is the ABI return type string for a method that does not return any value
const VoidReturnType = avm_abi.VoidReturnType
4 changes: 2 additions & 2 deletions abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/stretchr/testify/require"
)

func TestGoAlgorandImportWorks(t *testing.T) {
func TestImportWorks(t *testing.T) {
// This test is not meant to be exhaustive. It's just a simple test to
// verify importing the ABI package from go-algorand is working
// verify importing the ABI package from avm-abi is working

abiType, err := TypeOf("uint64")
require.NoError(t, err)
Expand Down
123 changes: 9 additions & 114 deletions abi/interactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,9 @@ import (
"fmt"
"strings"

"github.com/algorand/go-algorand-sdk/types"
avm_abi "github.com/algorand/avm-abi/abi"
)

// AnyTransactionType is the ABI argument type string for a nonspecific
// transaction argument
const AnyTransactionType = "txn"

var transactionArgTypes = map[string]interface{}{
AnyTransactionType: nil, // denotes a placeholder for any of the size types below
string(types.PaymentTx): nil,
string(types.KeyRegistrationTx): nil,
string(types.AssetConfigTx): nil,
string(types.AssetTransferTx): nil,
string(types.AssetFreezeTx): nil,
string(types.ApplicationCallTx): nil,
}

// IsTransactionType checks if a type string represents a transaction type
// argument, such as "txn", "pay", "keyreg", etc.
func IsTransactionType(typeStr string) bool {
_, ok := transactionArgTypes[typeStr]
return ok
}

// AccountReferenceType is the ABI argument type string for account references
const AccountReferenceType = "account"

// AssetReferenceType is the ABI argument type string for asset references
const AssetReferenceType = "asset"

// ApplicationReferenceType is the ABI argument type string for application
// references
const ApplicationReferenceType = "application"

var referenceArgTypes = map[string]interface{}{
AccountReferenceType: nil,
AssetReferenceType: nil,
ApplicationReferenceType: nil,
}

// IsReferenceType checks if a type string represents a reference type argument,
// such as "account", "asset", or "application".
func IsReferenceType(typeStr string) bool {
_, ok := referenceArgTypes[typeStr]
return ok
}

// Arg represents an ABI Method argument
type Arg struct {
// Optional, user-friendly name for the argument
Expand Down Expand Up @@ -95,10 +51,6 @@ func (a *Arg) GetTypeObject() (Type, error) {
return typeObject, err
}

// VoidReturnType is the ABI return type string for a method that does not have
// a return value
const VoidReturnType = "void"

// Return represents an ABI method return value
type Return struct {
// The type of the return value as a string. See the method GetTypeObject to
Expand Down Expand Up @@ -144,91 +96,34 @@ type Method struct {
Returns Return `json:"returns"`
}

// parseMethodArgs parses the arguments from a method signature string.
// trMethod is the complete method signature and startIdx is the index of the
// opening parenthesis of the arguments list. This function returns a list of
// the argument types from the method signature and the index of the closing
// parenthesis of the arguments list.
func parseMethodArgs(strMethod string, startIdx int) ([]string, int, error) {
// handle no args
if startIdx < len(strMethod)-1 && strMethod[startIdx+1] == ')' {
return []string{}, startIdx + 1, nil
}

var argTypes []string
parenCnt := 1
prevPos := startIdx + 1
closeIdx := -1
for curPos := prevPos; curPos < len(strMethod); curPos++ {
if strMethod[curPos] == '(' {
parenCnt++
} else if strMethod[curPos] == ')' {
parenCnt--
}

if parenCnt < 0 {
return nil, -1, fmt.Errorf("method signature parentheses mismatch")
} else if parenCnt > 1 {
continue
}

if strMethod[curPos] == ',' || parenCnt == 0 {
strArg := strMethod[prevPos:curPos]
argTypes = append(argTypes, strArg)
prevPos = curPos + 1
}

if parenCnt == 0 {
closeIdx = curPos
break
}
}

if closeIdx == -1 {
return nil, -1, fmt.Errorf("method signature parentheses mismatch")
}

return argTypes, closeIdx, nil
}

// MethodFromSignature decoded a method signature string into a Method object.
func MethodFromSignature(methodStr string) (Method, error) {
openIdx := strings.Index(methodStr, "(")
if openIdx == -1 {
return Method{}, fmt.Errorf("method signature is missing an open parenthesis")
}

name := methodStr[:openIdx]
if name == "" {
return Method{}, fmt.Errorf("method must have a non empty name")
}

argTypes, closeIdx, err := parseMethodArgs(methodStr, openIdx)
name, argTypesStr, retTypeStr, err := avm_abi.ParseMethodSignature(methodStr)
if err != nil {
return Method{}, err
}

returnType := Return{Type: methodStr[closeIdx+1:]}
returnType := Return{Type: retTypeStr}
if !returnType.IsVoid() {
// fill type object cache and catch any errors
_, err := returnType.GetTypeObject()
if err != nil {
return Method{}, err
return Method{}, fmt.Errorf("Could not parse method return type: %w", err)
}
}

args := make([]Arg, len(argTypes))
for i, argType := range argTypes {
args[i].Type = argType
args := make([]Arg, len(argTypesStr))
for i, argTypeStr := range argTypesStr {
args[i].Type = argTypeStr

if IsTransactionType(argType) || IsReferenceType(argType) {
if IsTransactionType(argTypeStr) || IsReferenceType(argTypeStr) {
continue
}

// fill type object cache and catch any errors
_, err := args[i].GetTypeObject()
if err != nil {
return Method{}, err
return Method{}, fmt.Errorf("Could not parse argument type at index %d: %w", i, err)
}
}

Expand Down
12 changes: 10 additions & 2 deletions client/v2/algod/algod.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func (c *Client) Block(round uint64) *Block {
return &Block{c: c, round: round}
}

func (c *Client) GetProof(round uint64, txid string) *GetProof {
return &GetProof{c: c, round: round, txid: txid}
func (c *Client) GetTransactionProof(round uint64, txid string) *GetTransactionProof {
return &GetTransactionProof{c: c, round: round, txid: txid}
}

func (c *Client) Supply() *Supply {
Expand Down Expand Up @@ -112,6 +112,14 @@ func (c *Client) PendingTransactionInformation(txid string) *PendingTransactionI
return &PendingTransactionInformation{c: c, txid: txid}
}

func (c *Client) GetStateProof(round uint64) *GetStateProof {
return &GetStateProof{c: c, round: round}
}

func (c *Client) GetLightBlockHeaderProof(round uint64) *GetLightBlockHeaderProof {
return &GetLightBlockHeaderProof{c: c, round: round}
}

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

import (
"context"
"fmt"

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

// GetLightBlockHeaderProof gets a proof for a given light block header inside a
// state proof commitment
type GetLightBlockHeaderProof struct {
c *Client

round uint64
}

// Do performs the HTTP request
func (s *GetLightBlockHeaderProof) Do(ctx context.Context, headers ...*common.Header) (response models.LightBlockHeaderProof, err error) {
err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s/lightheader/proof", common.EscapeParams(s.round)...), nil, headers)
return
}
Loading