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

API: Add types for ledgercore.StateDelta. #467

Merged
merged 16 commits into from
Feb 28, 2023
3 changes: 2 additions & 1 deletion client/v2/algod/accountApplicationInformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
// AccountApplicationInformationParams contains all of the query parameters for url serialization.
type AccountApplicationInformationParams struct {

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

Expand Down
3 changes: 2 additions & 1 deletion client/v2/algod/accountAssetInformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
// AccountAssetInformationParams contains all of the query parameters for url serialization.
type AccountAssetInformationParams struct {

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

Expand Down
3 changes: 2 additions & 1 deletion client/v2/algod/accountInformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ type AccountInformationParams struct {
// `none`.
Exclude string `url:"exclude,omitempty"`

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

Expand Down
4 changes: 0 additions & 4 deletions client/v2/algod/algod.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ 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) GetStateProof(round uint64) *GetStateProof {
return &GetStateProof{c: c, round: round}
}
Expand Down
3 changes: 2 additions & 1 deletion client/v2/algod/getBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
// BlockParams contains all of the query parameters for url serialization.
type BlockParams struct {

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

Expand Down
22 changes: 0 additions & 22 deletions client/v2/algod/getLedgerStateDelta.go

This file was deleted.

3 changes: 2 additions & 1 deletion client/v2/algod/getPendingTransactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
// PendingTransactionsParams contains all of the query parameters for url serialization.
type PendingTransactionsParams struct {

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

// Max truncated number of transactions to display. If max=0, returns all pending
Expand Down
3 changes: 2 additions & 1 deletion client/v2/algod/getPendingTransactionsByAddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
// PendingTransactionsByAddressParams contains all of the query parameters for url serialization.
type PendingTransactionsByAddressParams struct {

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

// Max truncated number of transactions to display. If max=0, returns all pending
Expand Down
3 changes: 2 additions & 1 deletion client/v2/algod/getTransactionProof.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
// GetTransactionProofParams contains all of the query parameters for url serialization.
type GetTransactionProofParams struct {

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

// Hashtype the type of hash function used to create the proof, must be one of:
Expand Down
3 changes: 2 additions & 1 deletion client/v2/algod/pendingTransactionInformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
// PendingTransactionInformationParams contains all of the query parameters for url serialization.
type PendingTransactionInformationParams struct {

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

Expand Down
3 changes: 2 additions & 1 deletion client/v2/algod/rawTransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
"github.com/algorand/go-algorand-sdk/v2/client/v2/common/models"
)

// SendRawTransaction broadcasts a raw transaction to the network.
// SendRawTransaction broadcasts a raw transaction or transaction group to the
// network.
type SendRawTransaction struct {
c *Client

Expand Down
10 changes: 0 additions & 10 deletions client/v2/common/models/account_balance_record.go

This file was deleted.

13 changes: 0 additions & 13 deletions client/v2/common/models/account_deltas.go

This file was deleted.

16 changes: 0 additions & 16 deletions client/v2/common/models/account_totals.go

This file was deleted.

22 changes: 0 additions & 22 deletions client/v2/common/models/app_resource_record.go

This file was deleted.

22 changes: 0 additions & 22 deletions client/v2/common/models/asset_resource_record.go

This file was deleted.

28 changes: 0 additions & 28 deletions client/v2/common/models/ledger_state_delta.go

This file was deleted.

13 changes: 0 additions & 13 deletions client/v2/common/models/modified_app.go

This file was deleted.

13 changes: 0 additions & 13 deletions client/v2/common/models/modified_asset.go

This file was deleted.

24 changes: 24 additions & 0 deletions client/v2/common/models/node_status_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,28 @@ type NodeStatusResponse struct {

// TimeSinceLastRound timeSinceLastRound in nanoseconds
TimeSinceLastRound uint64 `json:"time-since-last-round"`

// UpgradeDelay upgrade delay
UpgradeDelay uint64 `json:"upgrade-delay,omitempty"`

// UpgradeNextProtocolVoteBefore next protocol round
UpgradeNextProtocolVoteBefore uint64 `json:"upgrade-next-protocol-vote-before,omitempty"`

// UpgradeNoVotes no votes cast for consensus upgrade
UpgradeNoVotes uint64 `json:"upgrade-no-votes,omitempty"`

// UpgradeNodeVote this node's upgrade vote
UpgradeNodeVote bool `json:"upgrade-node-vote,omitempty"`

// UpgradeVoteRounds total voting ounds for current upgrade
UpgradeVoteRounds uint64 `json:"upgrade-vote-rounds,omitempty"`

// UpgradeVotes total votes cast for consensus upgrade
UpgradeVotes uint64 `json:"upgrade-votes,omitempty"`

// UpgradeVotesRequired yes votes required for consensus upgrade
UpgradeVotesRequired uint64 `json:"upgrade-votes-required,omitempty"`

// UpgradeYesVotes yes votes cast for consensus upgrade
UpgradeYesVotes uint64 `json:"upgrade-yes-votes,omitempty"`
}
13 changes: 0 additions & 13 deletions client/v2/common/models/tx_lease.go

This file was deleted.

5 changes: 5 additions & 0 deletions client/v2/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const authHeader = "X-Indexer-API-Token"

type Client common.Client

// delete performs a DELETE request to the specific path against the server, assumes JSON response
func (c *Client) delete(ctx context.Context, response interface{}, path string, body interface{}, headers []*common.Header) error {
return (*common.Client)(c).Delete(ctx, response, path, body, headers)
}

// get performs a GET request to the specific path against the server, assumes JSON response
func (c *Client) get(ctx context.Context, response interface{}, path string, body interface{}, headers []*common.Header) error {
return (*common.Client)(c).Get(ctx, response, path, body, headers)
Expand Down
22 changes: 22 additions & 0 deletions encoding/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ var CodecHandle *codec.JsonHandle
// LenientCodecHandle is used to instantiate msgpack encoders for the REST API.
var LenientCodecHandle *codec.JsonHandle

// JSONStrictHandle is the same as CodecHandle but with MapKeyAsString=true
// for correct maps[int]interface{} encoding
var JSONStrictHandle *codec.JsonHandle

// init configures our json encoder and decoder
func init() {
CodecHandle = new(codec.JsonHandle)
Expand All @@ -30,6 +34,15 @@ func init() {
LenientCodecHandle.RecursiveEmptyCheck = true
LenientCodecHandle.Indent = 2
LenientCodecHandle.HTMLCharsAsIs = true

JSONStrictHandle = new(codec.JsonHandle)
JSONStrictHandle.ErrorIfNoField = CodecHandle.ErrorIfNoField
JSONStrictHandle.ErrorIfNoArrayExpand = CodecHandle.ErrorIfNoArrayExpand
JSONStrictHandle.Canonical = CodecHandle.Canonical
JSONStrictHandle.RecursiveEmptyCheck = CodecHandle.RecursiveEmptyCheck
JSONStrictHandle.Indent = CodecHandle.Indent
JSONStrictHandle.HTMLCharsAsIs = CodecHandle.HTMLCharsAsIs
JSONStrictHandle.MapKeyAsString = true
}

// Encode returns a json-encoded byte buffer for a given object
Expand All @@ -40,6 +53,15 @@ func Encode(obj interface{}) []byte {
return b
}

// EncodeStrict returns a JSON-encoded byte buffer for a given object
// It is the same Encode but encodes map's int keys as strings
func EncodeStrict(obj interface{}) []byte {
var b []byte
enc := codec.NewEncoderBytes(&b, JSONStrictHandle)
enc.MustEncode(obj)
return b
}

// Decode attempts to decode a json-encoded byte buffer into an
// object instance pointed to by objptr
func Decode(b []byte, objptr interface{}) error {
Expand Down
Loading