Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOR REVIEW ONLY: go-algorand-sdk v2.3.0 #615

Merged
merged 14 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.17']
go_version: ['1.20.5']

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v3.5.3
- name: Generate and PR
uses: algorand/generator/.github/actions/sdk-codegen/@master
with:
Expand Down
70 changes: 20 additions & 50 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
required: true
type: string
pre_release_version:
description: "Pre-Release version, e.g. 'beta.1', will be added behind the release_version as the tag."
description: "(Optional) Pre-Release version, e.g. 'beta.1'. Used mainly to support consensus release on betanet."
required: false
type: string

Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
fi
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v3.5.3
with:
fetch-depth: 0

Expand Down Expand Up @@ -78,60 +78,33 @@ jobs:
fi
- name: Build Changelog
uses: mikepenz/[email protected]
id: build-changelog
env:
PREVIOUS_VERSION: ${{ steps.get-release.outputs.latest-tag }}
with:
fromTag: ${{ env.PREVIOUS_VERSION }}
toTag: ${{ env.RELEASE_BRANCH }}
failOnError: true
configurationJson: |
{
"categories": [
{
"title": "## New Features",
"labels": [
"New Feature"
]
},
{
"title": "## Enhancements",
"labels": [
"Enhancement"
]
},
{
"title": "## Bug Fixes",
"labels": [
"Bug-Fix"
]
},
{
"title": "## Not Yet Enabled",
"labels": [
"Not-Yet-Enabled"
]
}
],
"ignore_labels": [
"Skip-Release-Notes"
],
"sort": {
"order": "ASC",
"on_property": "mergedAt"
},
"template": "#{{CHANGELOG}}",
"pr_template": "- #{{TITLE}} by @#{{AUTHOR}} in ##{{NUMBER}}"
}
run: |
CHANGELOG=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/generate-notes \
-d '{"tag_name":"${{ env.RELEASE_VERSION }}","target_commitish":"${{ env.RELEASE_BRANCH }}","previous_tag_name":"${{ env.PREVIOUS_VERSION }}","configuration_file_path":".github/release.yml"}' \
| jq -r '.body')
# The EOF steps are used to save multiline string in github:
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "changelog<<$EOF" >> $GITHUB_OUTPUT
echo -e "${CHANGELOG}" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Update Changelog
if: ${{ env.PRE_RELEASE_VERSION == '' }}
env:
CHANGELOG_CONTENT: ${{ steps.build-changelog.outputs.changelog }}
PREVIOUS_VERSION: ${{ steps.get-release.outputs.latest-tag }}
run: |
echo -e "# ${RELEASE_VERSION}\n\n${CHANGELOG_CONTENT}**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_VERSION}...${RELEASE_VERSION}\n" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md
echo -e "# ${RELEASE_VERSION}\n\n${CHANGELOG_CONTENT}\n" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md
- name: Commit Changes
uses: EndBug/[email protected]
Expand All @@ -147,15 +120,12 @@ jobs:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.set-release.outputs.release-tag }}
run: |
echo -e "# What's Changed\n\n${CHANGELOG_CONTENT}**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_VERSION}...${RELEASE_TAG}" > tmp_msg_body.txt
export msg_body=$(cat tmp_msg_body.txt)
rm tmp_msg_body.txt
# Note: There's an issue adding teams as reviewers, see https://github.com/cli/cli/issues/6395
PULL_REQUEST_URL=$(gh pr create --base "master" \
--title "FOR REVIEW ONLY: ${{ github.event.repository.name }} $RELEASE_TAG" \
--label "Skip-Release-Notes" \
--label "Team Hyper Flow" \
--body "$msg_body" | tail -n 1)
--body "${CHANGELOG_CONTENT}" | tail -n 1)
if [[ $PULL_REQUEST_URL =~ ^https://github.com/${{ github.repository }}/pull/[0-9]+$ ]]; then
PULL_REQUEST_NUM=$(echo $PULL_REQUEST_URL | sed 's:.*/::')
echo "pull-request-master=$PULL_REQUEST_URL" >> $GITHUB_ENV
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3.5.3
with:
fetch-depth: 0 # required for new-from-rev option in .golangci.yml
- name: Install specific golang
uses: actions/setup-go@v2
uses: actions/setup-go@v4.0.1
with:
go-version: '1.17.13'
go-version: '1.20.5'
- name: Check format
run: test -z `go fmt ./...`
- name: Vet
run: go vet ./...
- name: reviewdog-golangci-lint
uses: reviewdog/action-golangci-lint@v2
uses: reviewdog/action-golangci-lint@v2.3.1
with:
golangci_lint_version: "v1.47.3"
golangci_lint_version: "v1.53.2"
golangci_lint_flags: "-c .golangci.yml --allow-parallel-runners"
go_version: "1.17.13"
go_version: "1.20.5"
reporter: "github-pr-review"
tool_name: "Lint Errors"
level: "error"
Expand Down
5 changes: 2 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ run:
linters:
disable-all: true
enable:
- deadcode
- errcheck
- exportloopref
- gci
Expand All @@ -21,10 +20,8 @@ linters:
- nolintlint
- revive
- staticcheck
- structcheck
- typecheck
- unused
- varcheck

linters-settings:
gci:
Expand Down Expand Up @@ -61,6 +58,8 @@ issues:
- "exported method (.*).Unwrap` should have comment or be unexported"
# ignore issues about the way we use _struct fields to define encoding settings
- "`_struct` is unused"
# we are not enforcing package-comments at this point
- "^package-comments: should have a package comment"

# Enable some golangci-lint default exception rules:
# "EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok"
Expand Down
2 changes: 1 addition & 1 deletion .test-env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configs for testing repo download:
SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing"
SDK_TESTING_BRANCH="master"
SDK_TESTING_BRANCH="V2"
SDK_TESTING_HARNESS="test-harness"

INSTALL_ONLY=0
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# v2.3.0

## What's Changed
### Bugfixes
* bug-fix: include currency-greater-than param for 0 value by @shiqizng in https://github.com/algorand/go-algorand-sdk/pull/584
* types: Reject non canonical addresses in DecodeAddress by @algochoi in https://github.com/algorand/go-algorand-sdk/pull/595
### New Features
* Build: Go 1.20 and golint-ci 1.52 support by @gmalouf in https://github.com/algorand/go-algorand-sdk/pull/566
* chore: Add new consensus params to vFuture by @Eric-Warehime in https://github.com/algorand/go-algorand-sdk/pull/577
### Enhancements
* consensus config: add dynamic filter timeout parameter by @yossigi in https://github.com/algorand/go-algorand-sdk/pull/603
* Simulate: Fix simulate request error & support ATC simulation by @jasonpaulos in https://github.com/algorand/go-algorand-sdk/pull/611
* api: Sync client object with latest spec. by @winder in https://github.com/algorand/go-algorand-sdk/pull/613
### Other
* Regenerate code with the latest specification file (7276a1b2) by @github-actions in https://github.com/algorand/go-algorand-sdk/pull/582
* Regenerate code with the latest specification file (fb8a5ede) by @github-actions in https://github.com/algorand/go-algorand-sdk/pull/585

## New Contributors
* @gmalouf made their first contribution in https://github.com/algorand/go-algorand-sdk/pull/566
* @yossigi made their first contribution in https://github.com/algorand/go-algorand-sdk/pull/603

**Full Changelog**: https://github.com/algorand/go-algorand-sdk/compare/v2.2.0...v2.3.0

# v2.2.0

## Enhancements
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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
GO_IMAGE := golang:$(subst go,,$(shell go version | cut -d' ' -f 3 | cut -d'.' -f 1,2))-bookworm

lint:
golangci-lint run -c .golangci.yml
Expand Down
4 changes: 4 additions & 0 deletions client/v2/algod/algod.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func (c *Client) Block(round uint64) *Block {
return &Block{c: c, round: round}
}

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

func (c *Client) GetBlockHash(round uint64) *GetBlockHash {
return &GetBlockHash{c: c, round: round}
}
Expand Down
23 changes: 23 additions & 0 deletions client/v2/algod/getBlockTxids.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/v2/client/v2/common"
"github.com/algorand/go-algorand-sdk/v2/client/v2/common/models"
)

// GetBlockTxids get the top level transaction IDs for the block on the given
// round.
type GetBlockTxids struct {
c *Client

round uint64
}

// Do performs the HTTP request
func (s *GetBlockTxids) Do(ctx context.Context, headers ...*common.Header) (response models.BlockTxidsResponse, err error) {
err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s/txids", common.EscapeParams(s.round)...), nil, headers)
return
}
3 changes: 2 additions & 1 deletion client/v2/algod/simulateTransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

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

// SimulateTransactionParams contains all of the query parameters for url serialization.
Expand All @@ -28,6 +29,6 @@ type SimulateTransaction struct {

// Do performs the HTTP request
func (s *SimulateTransaction) Do(ctx context.Context, headers ...*common.Header) (response models.SimulateResponse, err error) {
err = s.c.post(ctx, &response, "/v2/transactions/simulate", s.p, headers, s.request)
err = s.c.post(ctx, &response, "/v2/transactions/simulate", s.p, headers, msgpack.Encode(&s.request))
return
}
4 changes: 3 additions & 1 deletion client/v2/algod/waitForBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
)

// StatusAfterBlock waits for a block to appear after round {round} and returns the
// node's status at the time.
// node's status at the time. There is a 1 minute timeout, when reached the current
// status is returned regardless of whether or not it is the round after the given
// round.
type StatusAfterBlock struct {
c *Client

Expand Down
9 changes: 5 additions & 4 deletions client/v2/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ 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/disassemble": true,
"/v2/teal/dryrun": true,
"/v2/transactions": true,
"/v2/teal/compile": true,
"/v2/teal/disassemble": true,
"/v2/teal/dryrun": true,
"/v2/transactions/simulate": true,
}

// Header is a struct for custom headers.
Expand Down
17 changes: 17 additions & 0 deletions client/v2/common/models/application_initial_states.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package models

// ApplicationInitialStates an application's initial global/local/box states that
// were accessed during simulation.
type ApplicationInitialStates struct {
// AppBoxes an application's global/local/box state.
AppBoxes ApplicationKVStorage `json:"app-boxes,omitempty"`

// AppGlobals an application's global/local/box state.
AppGlobals ApplicationKVStorage `json:"app-globals,omitempty"`

// AppLocals an application's initial local states tied to different accounts.
AppLocals []ApplicationKVStorage `json:"app-locals,omitempty"`

// Id application index.
Id uint64 `json:"id"`
}
10 changes: 10 additions & 0 deletions client/v2/common/models/application_k_v_storage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package models

// ApplicationKVStorage an application's global/local/box state.
type ApplicationKVStorage struct {
// Account the address of the account associated with the local state.
Account string `json:"account,omitempty"`

// Kvs key-Value pairs representing application states.
Kvs []AvmKeyValue `json:"kvs"`
}
11 changes: 11 additions & 0 deletions client/v2/common/models/application_local_reference.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package models

// ApplicationLocalReference references an account's local state for an
// application.
type ApplicationLocalReference struct {
// Account address of the account with the local state.
Account string `json:"account"`

// App application ID of the local state application.
App uint64 `json:"app"`
}
22 changes: 22 additions & 0 deletions client/v2/common/models/application_state_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package models

// ApplicationStateOperation an operation against an application's global/local/box
// state.
type ApplicationStateOperation struct {
// Account for local state changes, the address of the account associated with the
// local state.
Account string `json:"account,omitempty"`

// AppStateType type of application state. Value `g` is **global state**, `l` is
// **local state**, `b` is **boxes**.
AppStateType string `json:"app-state-type"`

// Key the key (name) of the global/local/box state.
Key []byte `json:"key"`

// NewValue represents an AVM value.
NewValue AvmValue `json:"new-value,omitempty"`

// Operation operation type. Value `w` is **write**, `d` is **delete**.
Operation string `json:"operation"`
}
10 changes: 10 additions & 0 deletions client/v2/common/models/asset_holding_reference.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package models

// AssetHoldingReference references an asset held by an account.
type AssetHoldingReference struct {
// Account address of the account holding the asset.
Account string `json:"account"`

// Asset asset ID of the holding.
Asset uint64 `json:"asset"`
}
10 changes: 10 additions & 0 deletions client/v2/common/models/avm_key_value.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package models

// AvmKeyValue represents an AVM key-value pair in an application store.
type AvmKeyValue struct {
// Key
Key []byte `json:"key"`

// Value represents an AVM value.
Value AvmValue `json:"value"`
}
Loading
Loading