Skip to content

Commit

Permalink
Merge branch 'release/v2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
excalq committed May 9, 2023
2 parents 937511e + 9aa610b commit 282ba95
Show file tree
Hide file tree
Showing 107 changed files with 7,579 additions and 382 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pr-type-category.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ jobs:
labels: "New Feature, Enhancement, Bug-Fix, Not-Yet-Enabled, Skip-Release-Notes"

- name: "Checking for PR Category in PR title. Should be like '<category>: <pr title>'."
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
if [[ ! "${{ github.event.pull_request.title }}" =~ ^.{2,}\:.{2,} ]]; then
if [[ ! "$PR_TITLE" =~ ^.{2,}\:.{2,} ]]; then
echo "## PR Category is missing from PR title. Please add it like '<category>: <pr title>'." >> GITHUB_STEP_SUMMARY
exit 1
fi
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# 2.1.0

## What's Changed

Supports new devmode block timestamp offset endpoints.

### Bugfixes
* bugfix: Fix wrong response error type. by @winder in https://github.com/algorand/go-algorand-sdk/pull/461
* debug: Remove debug output. by @winder in https://github.com/algorand/go-algorand-sdk/pull/465
* bug: Fix extractError parsing by @Eric-Warehime in https://github.com/algorand/go-algorand-sdk/pull/492
### Enhancements
* enhancement: add genesis type by @shiqizng in https://github.com/algorand/go-algorand-sdk/pull/443
* docs: Update README.md by @algochoi in https://github.com/algorand/go-algorand-sdk/pull/460
* tests: Add disassembly test for Go SDK by @algochoi in https://github.com/algorand/go-algorand-sdk/pull/462
* marshaling: Lenient Address and BlockHash go-codec unmarshalers. by @winder in https://github.com/algorand/go-algorand-sdk/pull/464
* API: Add types for ledgercore.StateDelta. by @winder in https://github.com/algorand/go-algorand-sdk/pull/467
* docs: Create runnable examples to be pulled into docs by @barnjamin in https://github.com/algorand/go-algorand-sdk/pull/480
* Docs: Examples by @barnjamin in https://github.com/algorand/go-algorand-sdk/pull/491
* api: Regenerate client interfaces for timestamp, ready, and simulate endpoints by @algochoi in https://github.com/algorand/go-algorand-sdk/pull/513
* Performance: Add MakeClientWithTransport client override that allows the user to pass a custom http transport by @pbennett in https://github.com/algorand/go-algorand-sdk/pull/520
* DevOps: Add CODEOWNERS to restrict workflow editing by @onetechnical in https://github.com/algorand/go-algorand-sdk/pull/524
* Performance: Add custom http transport to MakeClientWithTransport by @algochoi in https://github.com/algorand/go-algorand-sdk/pull/523
### Other
* Regenerate code with the latest specification file (c90fd645) by @github-actions in https://github.com/algorand/go-algorand-sdk/pull/522

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

**Full Changelog**: https://github.com/algorand/go-algorand-sdk/compare/v2.0.0...v2.1.0

# 2.0.0

## What's Changed
Expand Down
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.github/ @algorand/dev
.circleci/ @algorand/dev
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ docker-gosdk-run:
docker ps -a
docker run -it --network host go-sdk-testing:latest

smoke-test-examples:
cd "$(SRCPATH)/examples" && bash smoke_test.sh && cd -

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


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The Algorand golang SDK provides:

# Documentation

Full documentation is available [on godoc](https://godoc.org/github.com/algorand/go-algorand-sdk). You can also self-host the documentation by running `godoc -http=:8099` and visiting `http://localhost:8099/pkg/github.com/algorand/go-algorand-sdk` in your web browser.
Full documentation is available [on pkg.go.dev](https://pkg.go.dev/github.com/algorand/go-algorand-sdk/v2). You can also self-host the documentation by running `godoc -http=:8099` and visiting `http://localhost:8099/pkg/github.com/algorand/go-algorand-sdk` in your web browser.

Additional developer documentation and examples can be found on [developer.algorand.org](https://developer.algorand.org/docs/sdks/go/)

Expand All @@ -21,7 +21,7 @@ In `client/`, the `kmd` packages provide HTTP clients for the Key Management Dae
In `client/v2` the `algod` package contains a client for the Algorand protocol daemon HTTP API. You can use it to check the status of the blockchain, read a block, look at transactions, or submit a signed transaction.
In `client/v2` the `indexer` package contains a client for the Algorand Indexer API. You can use it to query historical transactions or make queries about the current state of the chain.

`future` package contains Transaction building utility functions.
`transaction` package contains Transaction building utility functions.

`types` contains the data structures you'll use when interacting with the network, including addresses, transactions, multisig signatures, etc.

Expand Down
83 changes: 83 additions & 0 deletions _examples/account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package main

import (
"context"
"fmt"
"log"

"github.com/algorand/go-algorand-sdk/v2/client/v2/algod"
"github.com/algorand/go-algorand-sdk/v2/crypto"
"github.com/algorand/go-algorand-sdk/v2/mnemonic"
"github.com/algorand/go-algorand-sdk/v2/transaction"
)

func main() {
// example: ACCOUNT_GENERATE
account := crypto.GenerateAccount()
mn, err := mnemonic.FromPrivateKey(account.PrivateKey)

if err != nil {
log.Fatalf("failed to generate account: %s", err)
}

log.Printf("Address: %s\n", account.Address)
log.Printf("Mnemonic: %s\n", mn)
// example: ACCOUNT_GENERATE

// example: ACCOUNT_RECOVER_MNEMONIC
k, err := mnemonic.ToPrivateKey(mn)
if err != nil {
log.Fatalf("failed to parse mnemonic: %s", err)
}

recovered, err := crypto.AccountFromPrivateKey(k)
if err != nil {
log.Fatalf("failed to recover account from key: %s", err)
}

log.Printf("%+v", recovered)
// example: ACCOUNT_RECOVER_MNEMONIC
accts, err := getSandboxAccounts()
if err != nil {
log.Fatalf("failed to get sandbox accounts: %s", err)
}
rekeyAccount(getAlgodClient(), accts[0], accts[1])
}

func rekeyAccount(algodClient *algod.Client, acct crypto.Account, rekeyTarget crypto.Account) {
// example: ACCOUNT_REKEY
sp, err := algodClient.SuggestedParams().Do(context.Background())
if err != nil {
log.Fatalf("failed to get suggested params: %s", err)
}

addr := acct.Address.String()
// here we create a payment transaction but rekey is valid
// on any transaction type
rktxn, err := transaction.MakePaymentTxn(addr, addr, 0, nil, "", sp)
if err != nil {
log.Fatalf("failed to creating transaction: %s\n", err)
}
// Set the rekey parameter
rktxn.RekeyTo = rekeyTarget.Address

_, stxn, err := crypto.SignTransaction(acct.PrivateKey, rktxn)
if err != nil {
fmt.Printf("Failed to sign transaction: %s\n", err)
}

txID, err := algodClient.SendRawTransaction(stxn).Do(context.Background())
if err != nil {
fmt.Printf("failed to send transaction: %s\n", err)
return
}

result, err := transaction.WaitForConfirmation(algodClient, txID, 4, context.Background())
if err != nil {
fmt.Printf("Error waiting for confirmation on txID: %s\n", txID)
return
}

fmt.Printf("Confirmed Transaction: %s in Round %d\n", txID, result.ConfirmedRound)
// example: ACCOUNT_REKEY
}
100 changes: 100 additions & 0 deletions _examples/application/approval.teal
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#pragma version 4
// Handle each possible OnCompletion type. We don't have to worry about
// handling ClearState, because the ClearStateProgram will execute in that
// case, not the ApprovalProgram.
txn ApplicationID
int 0
==
bnz handle_approve

txn OnCompletion
int NoOp
==
bnz handle_noop

txn OnCompletion
int OptIn
==
bnz handle_approve

txn OnCompletion
int CloseOut
==
bnz handle_closeout

txn OnCompletion
int UpdateApplication
==
bnz handle_updateapp

txn OnCompletion
int DeleteApplication
==
bnz handle_deleteapp

// Unexpected OnCompletion value. Should be unreachable.
err

handle_noop:
// Handle NoOp

// read global state
byte "counter"
dup
app_global_get

// increment the value
int 1
+

// store to scratch space
dup
store 0

// update global state
app_global_put

// read local state for sender
int 0
byte "counter"
app_local_get

// increment the value
int 1
+
store 1

// update local state for sender
int 0
byte "counter"
load 1
app_local_put

// load return value as approval
load 0
return


handle_closeout:
// Handle CloseOut
//approval
int 1
return

handle_deleteapp:
// Check for creator
global CreatorAddress
txn Sender
==
return

handle_updateapp:
// Check for creator
global CreatorAddress
txn Sender
==
return

handle_approve:
int 1
return
107 changes: 107 additions & 0 deletions _examples/application/approval_refactored.teal
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#pragma version 4
// Handle each possible OnCompletion type. We don't have to worry about
// handling ClearState, because the ClearStateProgram will execute in that
// case, not the ApprovalProgram.

txn ApplicationID
int 0
==
bnz handle_approve

txn OnCompletion
int NoOp
==
bnz handle_noop

txn OnCompletion
int OptIn
==
bnz handle_approve

txn OnCompletion
int CloseOut
==
bnz handle_closeout

txn OnCompletion
int UpdateApplication
==
bnz handle_updateapp

txn OnCompletion
int DeleteApplication
==
bnz handle_deleteapp

// Unexpected OnCompletion value. Should be unreachable.
err

handle_noop:
// Handle NoOp

// read global state
byte "counter"
dup
app_global_get

// increment the value
int 1
+

// store to scratch space
dup
store 0

// update global state
app_global_put

// read local state for sender
int 0
byte "counter"
app_local_get

// increment the value
int 1
+
store 1

// update local state for sender
// update "counter"
int 0
byte "counter"
load 1
app_local_put

// update "timestamp"
int 0
byte "timestamp"
txn ApplicationArgs 0
app_local_put

// load return value as approval
load 0
return

handle_closeout:
// Handle CloseOut
//approval
int 1
return

handle_deleteapp:
// Check for creator
global CreatorAddress
txn Sender
==
return

handle_updateapp:
// Check for creator
global CreatorAddress
txn Sender
==
return

handle_approve:
int 1
return
3 changes: 3 additions & 0 deletions _examples/application/clear.teal
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma version 4
int 1
return
Loading

0 comments on commit 282ba95

Please sign in to comment.