Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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 .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ run:
timeout: 5m
tests: false
skip-dirs:
- client/v2/common
- client/v2

linters:
disable-all: true
Expand Down
4 changes: 2 additions & 2 deletions .test-env
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Configs for testing repo download:
SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing"
SDK_TESTING_BRANCH="master"
SDK_TESTING_BRANCH="verbose-harness"
SDK_TESTING_HARNESS="test-harness"

INSTALL_ONLY=0

VERBOSE_HARNESS=0
VERBOSE_HARNESS=1

# WARNING: If set to 1, new features will be LOST when downloading the test harness.
# REGARDLESS: modified features are ALWAYS overwritten.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ We use golangci-lint to run linters on our codebase. Please run `make lint` befo

To download the SDK, open a terminal and use the `go get` command.

```command
```sh
go get -u github.com/algorand/go-algorand-sdk/...
```
12 changes: 12 additions & 0 deletions client/v2/algod/algod.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ func (c *Client) PendingTransactionInformation(txid string) *PendingTransactionI
return &PendingTransactionInformation{c: c, txid: txid}
}

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

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

func (c *Client) GetLedgerStateDeltaForTransactionGroup(id string) *GetLedgerStateDeltaForTransactionGroup {
return &GetLedgerStateDeltaForTransactionGroup{c: c, id: id}
}

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

import (
"context"
"fmt"

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

// GetLedgerStateDeltaParams contains all of the query parameters for url serialization.
type GetLedgerStateDeltaParams struct {

// Format configures whether the response object is JSON or MessagePack encoded. If
// not provided, defaults to JSON.
Format string `url:"format,omitempty"`
}

// GetLedgerStateDelta get ledger deltas for a round.
type GetLedgerStateDelta struct {
c *Client

round uint64

p GetLedgerStateDeltaParams
}

// Do performs the HTTP request
func (s *GetLedgerStateDelta) Do(ctx context.Context, headers ...*common.Header) (response types.LedgerStateDelta, err error) {
err = s.c.get(ctx, &response, fmt.Sprintf("/v2/deltas/%s", common.EscapeParams(s.round)...), s.p, headers)
return
}
33 changes: 33 additions & 0 deletions client/v2/algod/getLedgerStateDeltaForTransactionGroup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package algod

import (
"context"
"fmt"

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

// GetLedgerStateDeltaForTransactionGroupParams contains all of the query parameters for url serialization.
type GetLedgerStateDeltaForTransactionGroupParams struct {

// Format configures whether the response object is JSON or MessagePack encoded. If
// not provided, defaults to JSON.
Format string `url:"format,omitempty"`
}

// GetLedgerStateDeltaForTransactionGroup get a ledger delta for a given
// transaction group.
type GetLedgerStateDeltaForTransactionGroup struct {
c *Client

id string

p GetLedgerStateDeltaForTransactionGroupParams
}

// Do performs the HTTP request
func (s *GetLedgerStateDeltaForTransactionGroup) Do(ctx context.Context, headers ...*common.Header) (response types.LedgerStateDelta, err error) {
err = s.c.get(ctx, &response, fmt.Sprintf("/v2/deltas/txn/group/%s", common.EscapeParams(s.id)...), s.p, headers)
return
}
33 changes: 33 additions & 0 deletions client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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"
)

// GetTransactionGroupLedgerStateDeltasForRoundParams contains all of the query parameters for url serialization.
type GetTransactionGroupLedgerStateDeltasForRoundParams struct {

// Format configures whether the response object is JSON or MessagePack encoded. If
// not provided, defaults to JSON.
Format string `url:"format,omitempty"`
}

// GetTransactionGroupLedgerStateDeltasForRound get ledger deltas for transaction
// groups in a given round.
type GetTransactionGroupLedgerStateDeltasForRound struct {
c *Client

round uint64

p GetTransactionGroupLedgerStateDeltasForRoundParams
}

// Do performs the HTTP request
func (s *GetTransactionGroupLedgerStateDeltasForRound) Do(ctx context.Context, headers ...*common.Header) (response models.TransactionGroupLedgerStateDeltasForRoundResponse, err error) {
err = s.c.get(ctx, &response, fmt.Sprintf("/v2/deltas/%s/txn/group", common.EscapeParams(s.round)...), s.p, headers)
return
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package models
// transaction group
type LedgerStateDeltaForTransactionGroup struct {
// Delta ledger StateDelta object
Delta *map[string]interface{} `json:"delta"`
Delta *map[string]interface{} `json:"Delta"`

// Ids
Ids []string `json:"ids"`
Ids []string `json:"Ids"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package models

// TransactionGroupLedgerStateDeltasForRoundResponse response containing all ledger
// state deltas for transaction groups, with their associated Ids, in a single
// round.
type TransactionGroupLedgerStateDeltasForRoundResponse struct {
// Deltas
Deltas []LedgerStateDeltaForTransactionGroup `json:"Deltas"`
}
30 changes: 30 additions & 0 deletions test/algodclientv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func AlgodClientV2Context(s *godog.Suite) {
s.Step(`^we make a UnsetSyncRound call$`, weMakeAUnsetSyncRoundCall)
s.Step(`^we make a SetBlockTimeStampOffset call against offset (\d+)$`, weMakeASetBlockTimeStampOffsetCallAgainstOffset)
s.Step(`^we make a GetBlockTimeStampOffset call$`, weMakeAGetBlockTimeStampOffsetCall)
s.Step(`^we make a GetLedgerStateDelta call against round (\d+)$`, weMakeAGetLedgerStateDeltaCallAgainstRound)
s.Step(`^we make a LedgerStateDeltaForTransactionGroupResponse call for ID "([^"]*)"$`, weMakeALedgerStateDeltaForTransactionGroupResponseCallForID)
s.Step(`^we make a TransactionGroupLedgerStateDeltaForRoundResponse call for round (\d+)$`, weMakeATransactionGroupLedgerStateDeltaForRoundResponseCallForRound)

s.BeforeScenario(func(interface{}) {
globalErrForExamination = nil
Expand Down Expand Up @@ -364,3 +367,30 @@ func weMakeAGetBlockTimeStampOffsetCall() error {
algodClient.GetBlockTimeStampOffset().Do(context.Background())
return nil
}

func weMakeAGetLedgerStateDeltaCallAgainstRound(round int) error {
algodClient, err := algod.MakeClient(mockServer.URL, "")
if err != nil {
return err
}
algodClient.GetLedgerStateDelta(uint64(round)).Do(context.Background())
return nil
}

func weMakeALedgerStateDeltaForTransactionGroupResponseCallForID(id string) error {
algodClient, err := algod.MakeClient(mockServer.URL, "")
if err != nil {
return err
}
algodClient.GetLedgerStateDeltaForTransactionGroup(id).Do(context.Background())
return nil
}

func weMakeATransactionGroupLedgerStateDeltaForRoundResponseCallForRound(round int) error {
algodClient, err := algod.MakeClient(mockServer.URL, "")
if err != nil {
return err
}
algodClient.GetTransactionGroupLedgerStateDeltasForRound(uint64(round)).Do(context.Background())
return nil
}
9 changes: 9 additions & 0 deletions test/responses_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ func weMakeAnyCallTo(client /* algod/indexer */, endpoint string) (err error) {
case "GetBlockTimeStampOffset":
response, err =
algodC.GetBlockTimeStampOffset().Do(context.Background())
case "GetLedgerStateDelta":
response, err =
algodC.GetLedgerStateDelta(123).Do(context.Background())
case "GetTransactionGroupLedgerStateDeltaForRound":
response, err =
algodC.GetTransactionGroupLedgerStateDeltasForRound(123).Do(context.Background())
case "GetLedgerStateDeltaForTransactionGroup":
response, err =
algodC.GetLedgerStateDeltaForTransactionGroup("someID").Do(context.Background())
case "any":
// This is an error case
// pickup the error as the response
Expand Down
6 changes: 5 additions & 1 deletion test/unit.tags
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@
@unit.responses.timestamp
@unit.responses.unlimited_assets
@unit.sourcemap
@unit.statedelta
@unit.stateproof.paths
@unit.stateproof.responses
@unit.sync
@unit.tealsign
@unit.timestamp
@unit.responses.statedelta
@unit.responses.timestamp
@unit.responses.txngroupdeltas
@unit.transactions
@unit.transactions.keyreg
@unit.transactions.payment
@unit.txngroupdeltas