From 7e26a4359b81eb1fb6796eb5ff5bee7259a98f08 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Thu, 15 Sep 2022 10:09:05 -0400 Subject: [PATCH 1/5] Deprecation: Add deprecated tags to v1 `algod1` API (#392) * Add deprecation tags to v1 API * Delete dangling comment * Revert changes that conflict with generator output * Add deprecation tags to wrappers --- client/algod/algod.go | 15 +++++++++++++++ client/algod/wrappers.go | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/client/algod/algod.go b/client/algod/algod.go index 114d536f..247296ff 100644 --- a/client/algod/algod.go +++ b/client/algod/algod.go @@ -20,23 +20,27 @@ const ( ) // unversionedPaths ais a set of paths that should not be prefixed by the API version +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. var unversionedPaths = map[string]bool{ "/versions": true, "/health": true, } // rawRequestPaths is a set of paths where the body should not be urlencoded +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. var rawRequestPaths = map[string]bool{ "/transactions": true, } // Header is a struct for custom headers. +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. type Header struct { Key string Value string } // Client manages the REST interface for a calling user. +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. type Client struct { serverURL url.URL apiToken string @@ -44,6 +48,7 @@ type Client struct { } // MakeClient is the factory for constructing a Client for a given endpoint. +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func MakeClient(address string, apiToken string) (c Client, err error) { url, err := url.Parse(address) if err != nil { @@ -58,6 +63,7 @@ func MakeClient(address string, apiToken string) (c Client, err error) { } // MakeClientWithHeaders is the factory for constructing a Client for a given endpoint with additional user defined headers. +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func MakeClientWithHeaders(address string, apiToken string, headers []*Header) (c Client, err error) { c, err = MakeClient(address, apiToken) if err != nil { @@ -72,6 +78,7 @@ func MakeClientWithHeaders(address string, apiToken string, headers []*Header) ( // extractError checks if the response signifies an error (for now, StatusCode != 200). // If so, it returns the error. // Otherwise, it returns nil. +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func extractError(resp *http.Response) error { if resp.StatusCode == 200 { return nil @@ -82,6 +89,7 @@ func extractError(resp *http.Response) error { } // stripTransaction gets a transaction of the form "tx-XXXXXXXX" and truncates the "tx-" part, if it starts with "tx-" +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func stripTransaction(tx string) string { if strings.HasPrefix(tx, "tx-") { return strings.SplitAfter(tx, "-")[1] @@ -90,6 +98,7 @@ func stripTransaction(tx string) string { } // mergeRawQueries merges two raw queries, appending an "&" if both are non-empty +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func mergeRawQueries(q1, q2 string) string { if q1 == "" { return q2 @@ -101,6 +110,7 @@ func mergeRawQueries(q1, q2 string) string { } // RawRequest submits the requests, and returns a map of the response fields +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) RawRequest(path string, request interface{}, requestMethod string, encodeJSON bool, headers []*Header) ( v map[string]interface{}, err error) { response, err := client.submitFormRaw(path, request, requestMethod, encodeJSON, headers) @@ -120,6 +130,7 @@ func (client Client) RawRequest(path string, request interface{}, requestMethod } // submitForm is a helper used for submitting (ex.) GETs and POSTs to the server +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) submitFormRaw(path string, request interface{}, requestMethod string, encodeJSON bool, headers []*Header) (resp *http.Response, err error) { queryURL := client.serverURL @@ -185,6 +196,7 @@ func (client Client) submitFormRaw(path string, request interface{}, requestMeth return resp, nil } +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) submitForm(response interface{}, path string, request interface{}, requestMethod string, encodeJSON bool, headers []*Header) error { resp, err := client.submitFormRaw(path, request, requestMethod, encodeJSON, headers) if err != nil { @@ -198,6 +210,7 @@ func (client Client) submitForm(response interface{}, path string, request inter } // get performs a GET request to the specific path against the server +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) get(response interface{}, path string, request interface{}, headers []*Header) error { return client.submitForm(response, path, request, "GET", false /* encodeJSON */, headers) } @@ -210,11 +223,13 @@ func (client Client) post(response interface{}, path string, request interface{} } // as post, but with MethodPut +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) put(response interface{}, path string, request interface{}, headers []*Header) error { return client.submitForm(response, path, request, "PUT", true /* encodeJSON */, headers) } // as post, but with MethodPatch +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) patch(response interface{}, path string, request interface{}, headers []*Header) error { return client.submitForm(response, path, request, "PATCH", true /* encodeJSON */, headers) } diff --git a/client/algod/wrappers.go b/client/algod/wrappers.go index d1779296..e0a9baaa 100644 --- a/client/algod/wrappers.go +++ b/client/algod/wrappers.go @@ -15,6 +15,7 @@ import ( // Status retrieves the StatusResponse from the running node // the StatusResponse includes data like the consensus version and current round +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) Status(headers ...*Header) (response models.NodeStatus, err error) { err = client.get(&response, "/status", nil, headers) return @@ -22,23 +23,27 @@ func (client Client) Status(headers ...*Header) (response models.NodeStatus, err // HealthCheck does a health check on the the potentially running node, // returning an error if the API is down +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) HealthCheck(headers ...*Header) error { return client.get(nil, "/health", nil, headers) } // StatusAfterBlock waits for a block to occur then returns the StatusResponse after that block // blocks on the node end +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) StatusAfterBlock(blockNum uint64, headers ...*Header) (response models.NodeStatus, err error) { err = client.get(&response, fmt.Sprintf("/status/wait-for-block-after/%d", blockNum), nil, headers) return } +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. type pendingTransactionsParams struct { Max uint64 `url:"max"` } // GetPendingTransactions asks algod for a snapshot of current pending txns on the node, bounded by maxTxns. // If maxTxns = 0, fetches as many transactions as possible. +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) GetPendingTransactions(maxTxns uint64, headers ...*Header) (response models.PendingTransactions, err error) { err = client.get(&response, fmt.Sprintf("/transactions/pending"), pendingTransactionsParams{maxTxns}, headers) return @@ -46,17 +51,20 @@ func (client Client) GetPendingTransactions(maxTxns uint64, headers ...*Header) // Versions retrieves the VersionResponse from the running node // the VersionResponse includes data like version number and genesis ID +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) Versions(headers ...*Header) (response models.Version, err error) { err = client.get(&response, "/versions", nil, headers) return } // LedgerSupply gets the supply details for the specified node's Ledger +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) LedgerSupply(headers ...*Header) (response models.Supply, err error) { err = client.get(&response, "/ledger/supply", nil, headers) return } +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. type transactionsByAddrParams struct { FirstRound uint64 `url:"firstRound,omitempty"` LastRound uint64 `url:"lastRound,omitempty"` @@ -67,6 +75,7 @@ type transactionsByAddrParams struct { // TransactionsByAddr returns all transactions for a PK [addr] in the [first, // last] rounds range. +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) TransactionsByAddr(addr string, first, last uint64, headers ...*Header) (response models.TransactionList, err error) { params := transactionsByAddrParams{FirstRound: first, LastRound: last} err = client.get(&response, fmt.Sprintf("/account/%s/transactions", addr), params, headers) @@ -74,6 +83,7 @@ func (client Client) TransactionsByAddr(addr string, first, last uint64, headers } // TransactionsByAddrLimit returns the last [limit] number of transaction for a PK [addr]. +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) TransactionsByAddrLimit(addr string, limit uint64, headers ...*Header) (response models.TransactionList, err error) { params := transactionsByAddrParams{Max: limit} err = client.get(&response, fmt.Sprintf("/account/%s/transactions", addr), params, headers) @@ -82,6 +92,7 @@ func (client Client) TransactionsByAddrLimit(addr string, limit uint64, headers // TransactionsByAddrForDate returns all transactions for a PK [addr] in the [first, // last] date range. Dates are of the form "2006-01-02". +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) TransactionsByAddrForDate(addr string, first, last string, headers ...*Header) (response models.TransactionList, err error) { params := transactionsByAddrParams{FromDate: first, ToDate: last} err = client.get(&response, fmt.Sprintf("/account/%s/transactions", addr), params, headers) @@ -89,12 +100,14 @@ func (client Client) TransactionsByAddrForDate(addr string, first, last string, } // AccountInformation also gets the AccountInformationResponse associated with the passed address +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) AccountInformation(address string, headers ...*Header) (response models.Account, err error) { err = client.get(&response, fmt.Sprintf("/account/%s", address), nil, headers) return } // AssetInformation also gets the AssetInformationResponse associated with the passed asset creator and index +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) AssetInformation(index uint64, headers ...*Header) (response models.AssetParams, err error) { err = client.get(&response, fmt.Sprintf("/asset/%d", index), nil, headers) return @@ -102,6 +115,7 @@ func (client Client) AssetInformation(index uint64, headers ...*Header) (respons // TransactionInformation gets information about a specific transaction involving a specific account // it will only return information about transactions submitted to the node queried +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) TransactionInformation(accountAddress, transactionID string, headers ...*Header) (response models.Transaction, err error) { transactionID = stripTransaction(transactionID) err = client.get(&response, fmt.Sprintf("/account/%s/transaction/%s", accountAddress, transactionID), nil, headers) @@ -117,6 +131,7 @@ func (client Client) TransactionInformation(accountAddress, transactionID string // // Or the transaction may have happened sufficiently long ago that the // node no longer remembers it, and this will return an error. +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) PendingTransactionInformation(transactionID string, headers ...*Header) (response models.Transaction, err error) { transactionID = stripTransaction(transactionID) err = client.get(&response, fmt.Sprintf("/transactions/pending/%s", transactionID), nil, headers) @@ -125,6 +140,7 @@ func (client Client) PendingTransactionInformation(transactionID string, headers // TransactionByID gets a transaction by its ID. Works only if the indexer is enabled on the node // being queried. +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) TransactionByID(transactionID string, headers ...*Header) (response models.Transaction, err error) { transactionID = stripTransaction(transactionID) err = client.get(&response, fmt.Sprintf("/transaction/%s", transactionID), nil, headers) @@ -132,12 +148,14 @@ func (client Client) TransactionByID(transactionID string, headers ...*Header) ( } // SuggestedFee gets the recommended transaction fee from the node +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) SuggestedFee(headers ...*Header) (response models.TransactionFee, err error) { err = client.get(&response, "/transactions/fee", nil, headers) return } // SuggestedParams gets the suggested transaction parameters +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) SuggestedParams(headers ...*Header) (response models.TransactionParams, err error) { err = client.get(&response, "/transactions/params", nil, headers) return @@ -145,6 +163,7 @@ func (client Client) SuggestedParams(headers ...*Header) (response models.Transa // BuildSuggestedParams gets the suggested transaction parameters and // builds a types.SuggestedParams to pass to transaction builders (see package future) +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) BuildSuggestedParams(headers ...*Header) (response types.SuggestedParams, err error) { var httpResponse models.TransactionParams err = client.get(&httpResponse, "/transactions/params", nil, headers) @@ -159,6 +178,7 @@ func (client Client) BuildSuggestedParams(headers ...*Header) (response types.Su } // SendRawTransaction gets the bytes of a SignedTxn and broadcasts it to the network +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) SendRawTransaction(stx []byte, headers ...*Header) (response models.TransactionID, err error) { // Set default Content-Type, if not the user didn't specify it. addContentType := true @@ -176,11 +196,13 @@ func (client Client) SendRawTransaction(stx []byte, headers ...*Header) (respons } // Block gets the block info for the given round +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) Block(round uint64, headers ...*Header) (response models.Block, err error) { err = client.get(&response, fmt.Sprintf("/block/%d", round), nil, headers) return } +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func responseReadAll(resp *http.Response, maxContentLength int64) (body []byte, err error) { if resp.ContentLength > 0 { // more efficient path if we know the ContentLength @@ -196,6 +218,7 @@ func responseReadAll(resp *http.Response, maxContentLength int64) (body []byte, } // BlockRaw gets the raw block msgpack bytes for the given round +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) BlockRaw(round uint64, headers ...*Header) (blockbytes []byte, err error) { var resp *http.Response request := struct { @@ -210,6 +233,7 @@ func (client Client) BlockRaw(round uint64, headers ...*Header) (blockbytes []by return responseReadAll(resp, 10000000) } +// Deprecated: v1 algod client is deprecated, please use the v2 algod client. func (client Client) doGetWithQuery(ctx context.Context, path string, queryArgs map[string]string) (result string, err error) { queryURL := client.serverURL queryURL.Path = path From 45668d4cd67f67c7c241d159aca4d3c7a8cc6c5b Mon Sep 17 00:00:00 2001 From: shiqizng <80276844+shiqizng@users.noreply.github.com> Date: Fri, 16 Sep 2022 12:42:57 -0400 Subject: [PATCH 2/5] run code generator (#401) --- client/v2/common/models/block.go | 4 ++++ client/v2/common/models/participation_updates.go | 9 +++++++++ client/v2/indexer/searchForAccounts.go | 12 ++++++++++-- test/unit.tags | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 client/v2/common/models/participation_updates.go diff --git a/client/v2/common/models/block.go b/client/v2/common/models/block.go index 0c433121..425c40f7 100644 --- a/client/v2/common/models/block.go +++ b/client/v2/common/models/block.go @@ -10,6 +10,10 @@ type Block struct { // GenesisId (gen) ID to which this block belongs. GenesisId string `json:"genesis-id"` + // ParticipationUpdates participation account data that needs to be checked/acted + // on by the network. + ParticipationUpdates ParticipationUpdates `json:"participation-updates,omitempty"` + // PreviousBlockHash (prev) Previous block hash. PreviousBlockHash []byte `json:"previous-block-hash"` diff --git a/client/v2/common/models/participation_updates.go b/client/v2/common/models/participation_updates.go new file mode 100644 index 00000000..74c97fab --- /dev/null +++ b/client/v2/common/models/participation_updates.go @@ -0,0 +1,9 @@ +package models + +// ParticipationUpdates participation account data that needs to be checked/acted +// on by the network. +type ParticipationUpdates struct { + // ExpiredParticipationAccounts (partupdrmv) a list of online accounts that needs + // to be converted to offline since their participation key expired. + ExpiredParticipationAccounts []string `json:"expired-participation-accounts,omitempty"` +} diff --git a/client/v2/indexer/searchForAccounts.go b/client/v2/indexer/searchForAccounts.go index aba7aed1..bd8abadb 100644 --- a/client/v2/indexer/searchForAccounts.go +++ b/client/v2/indexer/searchForAccounts.go @@ -48,7 +48,11 @@ type SearchAccountsParams struct { NextToken string `url:"next,omitempty"` // Round include results for the specified round. For performance reasons, this - // parameter may be disabled on some configurations. + // parameter may be disabled on some configurations. Using application-id or + // asset-id filters will return both creator and opt-in accounts. Filtering by + // include-all will return creator and opt-in accounts for deleted assets and + // accounts. Non-opt-in managers are not included in the results when asset-id is + // used. Round uint64 `url:"round,omitempty"` } @@ -124,7 +128,11 @@ func (s *SearchAccounts) NextToken(NextToken string) *SearchAccounts { } // Round include results for the specified round. For performance reasons, this -// parameter may be disabled on some configurations. +// parameter may be disabled on some configurations. Using application-id or +// asset-id filters will return both creator and opt-in accounts. Filtering by +// include-all will return creator and opt-in accounts for deleted assets and +// accounts. Non-opt-in managers are not included in the results when asset-id is +// used. func (s *SearchAccounts) Round(Round uint64) *SearchAccounts { s.p.Round = Round return s diff --git a/test/unit.tags b/test/unit.tags index 5cff292b..fa3be2fd 100644 --- a/test/unit.tags +++ b/test/unit.tags @@ -19,6 +19,7 @@ @unit.responses.genesis @unit.responses.messagepack @unit.responses.messagepack.231 +@unit.responses.participationupdates @unit.responses.unlimited_assets @unit.sourcemap @unit.stateproof.paths From c363b2604b930b3d6bbf6ecbac0bc3d7b8496637 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Mon, 19 Sep 2022 08:47:10 -0400 Subject: [PATCH 3/5] BugFix: Fix dryrun parser (#400) --- future/dryrun.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/future/dryrun.go b/future/dryrun.go index 1fda533f..98c49ddb 100644 --- a/future/dryrun.go +++ b/future/dryrun.go @@ -154,14 +154,12 @@ type DryrunResponse struct { } func NewDryrunResponse(d models.DryrunResponse) (DryrunResponse, error) { - // TODO: this is lazy but also works? - dr := DryrunResponse{} - b, err := json.Marshal(dr) + // Marshal and unmarshal to fix integer types. + b, err := json.Marshal(d) if err != nil { - return dr, err + return DryrunResponse{}, err } - err = json.Unmarshal(b, &dr) - return dr, err + return NewDryrunResponseFromJson(b) } func NewDryrunResponseFromJson(js []byte) (DryrunResponse, error) { From 7937642cbb7eef51fc1ca0ac4e0aa44cfe9123a1 Mon Sep 17 00:00:00 2001 From: egieseke Date: Mon, 19 Sep 2022 11:05:15 -0400 Subject: [PATCH 4/5] Updated CHANGELOG.md --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d110e831..0ef118bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# 1.21.0 +## What's Changed +### Enhancements +* Deprecation: Add deprecated tags to v1 `algod1` API ([#392](https://github.com/algorand/go-algorand-sdk/pull/392)) +* Enhancement: update block model ([#401](https://github.com/algorand/go-algorand-sdk/pull/401)) +### Bugfixes +* Bugfix: Fix dryrun parser ([#400](https://github.com/algorand/go-algorand-sdk/pull/400)) +## Protocol Upgrade +This release does not contain a protocol upgrade. + # 1.20.0 ## What's Changed ### Bugfixes From 95be0ea89816a6e99af65e2a8d12c672fc139604 Mon Sep 17 00:00:00 2001 From: egieseke Date: Mon, 19 Sep 2022 11:09:58 -0400 Subject: [PATCH 5/5] Updated CHANGELOG.md --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ef118bf..392a0714 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,6 @@ * Enhancement: update block model ([#401](https://github.com/algorand/go-algorand-sdk/pull/401)) ### Bugfixes * Bugfix: Fix dryrun parser ([#400](https://github.com/algorand/go-algorand-sdk/pull/400)) -## Protocol Upgrade -This release does not contain a protocol upgrade. # 1.20.0 ## What's Changed