From 742dbfc5d957ff46dbfe0b3667dfdba730aa632a Mon Sep 17 00:00:00 2001 From: algoidurovic <91566643+algoidurovic@users.noreply.github.com> Date: Wed, 11 May 2022 13:08:26 -0400 Subject: [PATCH 1/7] generate client api code --- client/v2/algod/algod.go | 4 ++++ client/v2/algod/getProof.go | 13 +++++++++++ client/v2/algod/tealCompile.go | 2 +- client/v2/algod/tealDisassemble.go | 23 +++++++++++++++++++ client/v2/algod/tealDryrun.go | 2 +- client/v2/common/models/account.go | 12 +++------- client/v2/common/models/application.go | 9 -------- .../common/models/application_local_state.go | 10 -------- client/v2/common/models/application_params.go | 2 +- client/v2/common/models/asset.go | 9 -------- client/v2/common/models/asset_holding.go | 9 -------- .../v2/common/models/disassemble_response.go | 7 ++++++ client/v2/common/models/dryrun_txn_result.go | 7 ++++-- client/v2/common/models/error_response.go | 2 +- client/v2/common/models/proof_response.go | 2 +- 15 files changed, 60 insertions(+), 53 deletions(-) create mode 100644 client/v2/algod/tealDisassemble.go create mode 100644 client/v2/common/models/disassemble_response.go diff --git a/client/v2/algod/algod.go b/client/v2/algod/algod.go index 0289ed41..854b0eba 100644 --- a/client/v2/algod/algod.go +++ b/client/v2/algod/algod.go @@ -124,6 +124,10 @@ func (c *Client) TealCompile(source []byte) *TealCompile { return &TealCompile{c: c, source: source} } +func (c *Client) TealDisassemble(source string) *TealDisassemble { + return &TealDisassemble{c: c, source: source} +} + func (c *Client) TealDryrun(request models.DryrunRequest) *TealDryrun { return &TealDryrun{c: c, request: request} } diff --git a/client/v2/algod/getProof.go b/client/v2/algod/getProof.go index e856702f..737bff32 100644 --- a/client/v2/algod/getProof.go +++ b/client/v2/algod/getProof.go @@ -13,6 +13,11 @@ type GetProofParams struct { // Format configures whether the response object is JSON or MessagePack encoded. Format string `url:"format,omitempty"` + + // Hashtype the type of hash function used to create the proof, must be one of: + // * sha512_256 + // * sha256 + Hashtype string `url:"hashtype,omitempty"` } // GetProof get a Merkle proof for a transaction in a block. @@ -25,6 +30,14 @@ type GetProof struct { p GetProofParams } +// Hashtype the type of hash function used to create the proof, must be one of: +// * sha512_256 +// * sha256 +func (s *GetProof) Hashtype(Hashtype string) *GetProof { + s.p.Hashtype = Hashtype + return s +} + // Do performs the HTTP request func (s *GetProof) Do(ctx context.Context, headers ...*common.Header) (response models.ProofResponse, err error) { err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%v/transactions/%v/proof", s.round, s.txid), s.p, headers) diff --git a/client/v2/algod/tealCompile.go b/client/v2/algod/tealCompile.go index 2d77b75a..055b0296 100644 --- a/client/v2/algod/tealCompile.go +++ b/client/v2/algod/tealCompile.go @@ -9,7 +9,7 @@ import ( // TealCompile given TEAL source code in plain text, return base64 encoded program // bytes and base32 SHA512_256 hash of program bytes (Address style). This endpoint -// is only enabled when a node's configureation file sets EnableDeveloperAPI to +// is only enabled when a node's configuration file sets EnableDeveloperAPI to // true. type TealCompile struct { c *Client diff --git a/client/v2/algod/tealDisassemble.go b/client/v2/algod/tealDisassemble.go new file mode 100644 index 00000000..60689319 --- /dev/null +++ b/client/v2/algod/tealDisassemble.go @@ -0,0 +1,23 @@ +package algod + +import ( + "context" + + "github.com/algorand/go-algorand-sdk/client/v2/common" + "github.com/algorand/go-algorand-sdk/client/v2/common/models" +) + +// TealDisassemble given the base64 encoded program bytes, return the TEAL source +// code in plain text. This endpoint is only enabled when a node's configuration +// file sets EnableDeveloperAPI to true. +type TealDisassemble struct { + c *Client + + source string +} + +// Do performs the HTTP request +func (s *TealDisassemble) Do(ctx context.Context, headers ...*common.Header) (response models.DisassembleResponse, err error) { + err = s.c.get(ctx, &response, "/v2/teal/disassemble", nil, headers) + return +} diff --git a/client/v2/algod/tealDryrun.go b/client/v2/algod/tealDryrun.go index da27faae..87e070a4 100644 --- a/client/v2/algod/tealDryrun.go +++ b/client/v2/algod/tealDryrun.go @@ -9,7 +9,7 @@ import ( ) // TealDryrun executes TEAL program(s) in context and returns debugging information -// about the execution. This endpoint is only enabled when a node's configureation +// about the execution. This endpoint is only enabled when a node's configuration // file sets EnableDeveloperAPI to true. type TealDryrun struct { c *Client diff --git a/client/v2/common/models/account.go b/client/v2/common/models/account.go index 88a054de..cee8ce72 100644 --- a/client/v2/common/models/account.go +++ b/client/v2/common/models/account.go @@ -36,9 +36,6 @@ type Account struct { // transaction by setting the RekeyTo field. AuthAddr string `json:"auth-addr,omitempty"` - // ClosedAtRound round during which this account was most recently closed. - ClosedAtRound uint64 `json:"closed-at-round,omitempty"` - // CreatedApps (appp) parameters of applications created by this account including // app global data. // Note: the raw account uses `map[int] -> AppParams` for this type. @@ -48,11 +45,9 @@ type Account struct { // Note: the raw account uses `map[int] -> Asset` for this type. CreatedAssets []Asset `json:"created-assets,omitempty"` - // CreatedAtRound round during which this account first appeared in a transaction. - CreatedAtRound uint64 `json:"created-at-round,omitempty"` - - // Deleted whether or not this account is currently closed. - Deleted bool `json:"deleted,omitempty"` + // MinBalance microAlgo balance required by the account. + // The requirement grows based on asset and application usage. + MinBalance uint64 `json:"min-balance"` // Participation accountParticipation describes the parameters used by this account // in consensus protocol. @@ -77,7 +72,6 @@ type Account struct { // * sig // * msig // * lsig - // * or null if unknown SigType string `json:"sig-type,omitempty"` // Status (onl) delegation status of the account's MicroAlgos diff --git a/client/v2/common/models/application.go b/client/v2/common/models/application.go index 0d7acdf1..ea15ac80 100644 --- a/client/v2/common/models/application.go +++ b/client/v2/common/models/application.go @@ -2,15 +2,6 @@ package models // Application application index and its parameters type Application struct { - // CreatedAtRound round when this application was created. - CreatedAtRound uint64 `json:"created-at-round,omitempty"` - - // Deleted whether or not this application is currently deleted. - Deleted bool `json:"deleted,omitempty"` - - // DeletedAtRound round when this application was deleted. - DeletedAtRound uint64 `json:"deleted-at-round,omitempty"` - // Id (appidx) application index. Id uint64 `json:"id"` diff --git a/client/v2/common/models/application_local_state.go b/client/v2/common/models/application_local_state.go index 397a8fdd..860fd52a 100644 --- a/client/v2/common/models/application_local_state.go +++ b/client/v2/common/models/application_local_state.go @@ -2,22 +2,12 @@ package models // ApplicationLocalState stores local state associated with an application. type ApplicationLocalState struct { - // ClosedOutAtRound round when account closed out of the application. - ClosedOutAtRound uint64 `json:"closed-out-at-round,omitempty"` - - // Deleted whether or not the application local state is currently deleted from its - // account. - Deleted bool `json:"deleted,omitempty"` - // Id the application which this local state is for. Id uint64 `json:"id"` // KeyValue (tkv) storage. KeyValue []TealKeyValue `json:"key-value,omitempty"` - // OptedInAtRound round when the account opted into the application. - OptedInAtRound uint64 `json:"opted-in-at-round,omitempty"` - // Schema (hsch) schema. Schema ApplicationStateSchema `json:"schema"` } diff --git a/client/v2/common/models/application_params.go b/client/v2/common/models/application_params.go index 4eed80aa..ebeee42d 100644 --- a/client/v2/common/models/application_params.go +++ b/client/v2/common/models/application_params.go @@ -10,7 +10,7 @@ type ApplicationParams struct { // Creator the address that created this application. This is the address where the // parameters and global state for this application can be found. - Creator string `json:"creator,omitempty"` + Creator string `json:"creator"` // ExtraProgramPages (epp) the amount of extra program pages available to this app. ExtraProgramPages uint64 `json:"extra-program-pages,omitempty"` diff --git a/client/v2/common/models/asset.go b/client/v2/common/models/asset.go index 9e1b097f..e87ef1bd 100644 --- a/client/v2/common/models/asset.go +++ b/client/v2/common/models/asset.go @@ -2,15 +2,6 @@ package models // Asset specifies both the unique identifier and the parameters for an asset type Asset struct { - // CreatedAtRound round during which this asset was created. - CreatedAtRound uint64 `json:"created-at-round,omitempty"` - - // Deleted whether or not this asset is currently deleted. - Deleted bool `json:"deleted,omitempty"` - - // DestroyedAtRound round during which this asset was destroyed. - DestroyedAtRound uint64 `json:"destroyed-at-round,omitempty"` - // Index unique asset identifier Index uint64 `json:"index"` diff --git a/client/v2/common/models/asset_holding.go b/client/v2/common/models/asset_holding.go index 033750a2..fc3a0a8d 100644 --- a/client/v2/common/models/asset_holding.go +++ b/client/v2/common/models/asset_holding.go @@ -10,15 +10,6 @@ type AssetHolding struct { // AssetId asset ID of the holding. AssetId uint64 `json:"asset-id"` - // Deleted whether or not the asset holding is currently deleted from its account. - Deleted bool `json:"deleted,omitempty"` - // IsFrozen (f) whether or not the holding is frozen. IsFrozen bool `json:"is-frozen"` - - // OptedInAtRound round during which the account opted into this asset holding. - OptedInAtRound uint64 `json:"opted-in-at-round,omitempty"` - - // OptedOutAtRound round during which the account opted out of this asset holding. - OptedOutAtRound uint64 `json:"opted-out-at-round,omitempty"` } diff --git a/client/v2/common/models/disassemble_response.go b/client/v2/common/models/disassemble_response.go new file mode 100644 index 00000000..946a5620 --- /dev/null +++ b/client/v2/common/models/disassemble_response.go @@ -0,0 +1,7 @@ +package models + +// DisassembleResponse teal disassembly Result +type DisassembleResponse struct { + // Result disassembled Teal code + Result string `json:"result"` +} diff --git a/client/v2/common/models/dryrun_txn_result.go b/client/v2/common/models/dryrun_txn_result.go index 1b65b602..7921f607 100644 --- a/client/v2/common/models/dryrun_txn_result.go +++ b/client/v2/common/models/dryrun_txn_result.go @@ -9,8 +9,11 @@ type DryrunTxnResult struct { // AppCallTrace AppCallTrace []DryrunState `json:"app-call-trace,omitempty"` - // Cost execution cost of app call transaction - Cost uint64 `json:"cost,omitempty"` + // Budgetcredit budget consumed during execution of app call transaction. + Budgetcredit uint64 `json:"budgetCredit,omitempty"` + + // Budgetdebit budget added during execution of app call transaction. + Budgetdebit uint64 `json:"budgetDebit,omitempty"` // Disassembly disassembled program line by line. Disassembly []string `json:"disassembly"` diff --git a/client/v2/common/models/error_response.go b/client/v2/common/models/error_response.go index 389c78f2..8f0af66c 100644 --- a/client/v2/common/models/error_response.go +++ b/client/v2/common/models/error_response.go @@ -1,6 +1,6 @@ package models -// ErrorResponse response for errors +// ErrorResponse an error response with optional data field. type ErrorResponse struct { // Data Data *map[string]interface{} `json:"data,omitempty"` diff --git a/client/v2/common/models/proof_response.go b/client/v2/common/models/proof_response.go index 7d081aa1..6cb41710 100644 --- a/client/v2/common/models/proof_response.go +++ b/client/v2/common/models/proof_response.go @@ -3,8 +3,8 @@ package models // ProofResponse proof of transaction in a block. type ProofResponse struct { // Hashtype the type of hash function used to create the proof, must be one of: - // * sumhash // * sha512_256 + // * sha256 Hashtype string `json:"hashtype,omitempty"` // Idx index of the transaction in the block's payset. From 1ebfc86eeaa61bfc2e130a9493841dbe4b49aae2 Mon Sep 17 00:00:00 2001 From: algoidurovic <91566643+algoidurovic@users.noreply.github.com> Date: Wed, 11 May 2022 13:35:54 -0400 Subject: [PATCH 2/7] missed generated fields required by indexer api spec --- client/v2/common/models/account.go | 12 +++++++++--- client/v2/common/models/application.go | 9 +++++++++ client/v2/common/models/application_local_state.go | 10 ++++++++++ client/v2/common/models/application_params.go | 2 +- client/v2/common/models/asset.go | 9 +++++++++ client/v2/common/models/asset_holding.go | 9 +++++++++ client/v2/common/models/error_response.go | 2 +- client/v2/indexer/lookupAccountTransactions.go | 3 ++- client/v2/indexer/lookupAssetTransactions.go | 3 ++- client/v2/indexer/searchForTransactions.go | 4 +++- 10 files changed, 55 insertions(+), 8 deletions(-) diff --git a/client/v2/common/models/account.go b/client/v2/common/models/account.go index cee8ce72..88a054de 100644 --- a/client/v2/common/models/account.go +++ b/client/v2/common/models/account.go @@ -36,6 +36,9 @@ type Account struct { // transaction by setting the RekeyTo field. AuthAddr string `json:"auth-addr,omitempty"` + // ClosedAtRound round during which this account was most recently closed. + ClosedAtRound uint64 `json:"closed-at-round,omitempty"` + // CreatedApps (appp) parameters of applications created by this account including // app global data. // Note: the raw account uses `map[int] -> AppParams` for this type. @@ -45,9 +48,11 @@ type Account struct { // Note: the raw account uses `map[int] -> Asset` for this type. CreatedAssets []Asset `json:"created-assets,omitempty"` - // MinBalance microAlgo balance required by the account. - // The requirement grows based on asset and application usage. - MinBalance uint64 `json:"min-balance"` + // CreatedAtRound round during which this account first appeared in a transaction. + CreatedAtRound uint64 `json:"created-at-round,omitempty"` + + // Deleted whether or not this account is currently closed. + Deleted bool `json:"deleted,omitempty"` // Participation accountParticipation describes the parameters used by this account // in consensus protocol. @@ -72,6 +77,7 @@ type Account struct { // * sig // * msig // * lsig + // * or null if unknown SigType string `json:"sig-type,omitempty"` // Status (onl) delegation status of the account's MicroAlgos diff --git a/client/v2/common/models/application.go b/client/v2/common/models/application.go index ea15ac80..0d7acdf1 100644 --- a/client/v2/common/models/application.go +++ b/client/v2/common/models/application.go @@ -2,6 +2,15 @@ package models // Application application index and its parameters type Application struct { + // CreatedAtRound round when this application was created. + CreatedAtRound uint64 `json:"created-at-round,omitempty"` + + // Deleted whether or not this application is currently deleted. + Deleted bool `json:"deleted,omitempty"` + + // DeletedAtRound round when this application was deleted. + DeletedAtRound uint64 `json:"deleted-at-round,omitempty"` + // Id (appidx) application index. Id uint64 `json:"id"` diff --git a/client/v2/common/models/application_local_state.go b/client/v2/common/models/application_local_state.go index 860fd52a..397a8fdd 100644 --- a/client/v2/common/models/application_local_state.go +++ b/client/v2/common/models/application_local_state.go @@ -2,12 +2,22 @@ package models // ApplicationLocalState stores local state associated with an application. type ApplicationLocalState struct { + // ClosedOutAtRound round when account closed out of the application. + ClosedOutAtRound uint64 `json:"closed-out-at-round,omitempty"` + + // Deleted whether or not the application local state is currently deleted from its + // account. + Deleted bool `json:"deleted,omitempty"` + // Id the application which this local state is for. Id uint64 `json:"id"` // KeyValue (tkv) storage. KeyValue []TealKeyValue `json:"key-value,omitempty"` + // OptedInAtRound round when the account opted into the application. + OptedInAtRound uint64 `json:"opted-in-at-round,omitempty"` + // Schema (hsch) schema. Schema ApplicationStateSchema `json:"schema"` } diff --git a/client/v2/common/models/application_params.go b/client/v2/common/models/application_params.go index ebeee42d..4eed80aa 100644 --- a/client/v2/common/models/application_params.go +++ b/client/v2/common/models/application_params.go @@ -10,7 +10,7 @@ type ApplicationParams struct { // Creator the address that created this application. This is the address where the // parameters and global state for this application can be found. - Creator string `json:"creator"` + Creator string `json:"creator,omitempty"` // ExtraProgramPages (epp) the amount of extra program pages available to this app. ExtraProgramPages uint64 `json:"extra-program-pages,omitempty"` diff --git a/client/v2/common/models/asset.go b/client/v2/common/models/asset.go index e87ef1bd..9e1b097f 100644 --- a/client/v2/common/models/asset.go +++ b/client/v2/common/models/asset.go @@ -2,6 +2,15 @@ package models // Asset specifies both the unique identifier and the parameters for an asset type Asset struct { + // CreatedAtRound round during which this asset was created. + CreatedAtRound uint64 `json:"created-at-round,omitempty"` + + // Deleted whether or not this asset is currently deleted. + Deleted bool `json:"deleted,omitempty"` + + // DestroyedAtRound round during which this asset was destroyed. + DestroyedAtRound uint64 `json:"destroyed-at-round,omitempty"` + // Index unique asset identifier Index uint64 `json:"index"` diff --git a/client/v2/common/models/asset_holding.go b/client/v2/common/models/asset_holding.go index fc3a0a8d..033750a2 100644 --- a/client/v2/common/models/asset_holding.go +++ b/client/v2/common/models/asset_holding.go @@ -10,6 +10,15 @@ type AssetHolding struct { // AssetId asset ID of the holding. AssetId uint64 `json:"asset-id"` + // Deleted whether or not the asset holding is currently deleted from its account. + Deleted bool `json:"deleted,omitempty"` + // IsFrozen (f) whether or not the holding is frozen. IsFrozen bool `json:"is-frozen"` + + // OptedInAtRound round during which the account opted into this asset holding. + OptedInAtRound uint64 `json:"opted-in-at-round,omitempty"` + + // OptedOutAtRound round during which the account opted out of this asset holding. + OptedOutAtRound uint64 `json:"opted-out-at-round,omitempty"` } diff --git a/client/v2/common/models/error_response.go b/client/v2/common/models/error_response.go index 8f0af66c..389c78f2 100644 --- a/client/v2/common/models/error_response.go +++ b/client/v2/common/models/error_response.go @@ -1,6 +1,6 @@ package models -// ErrorResponse an error response with optional data field. +// ErrorResponse response for errors type ErrorResponse struct { // Data Data *map[string]interface{} `json:"data,omitempty"` diff --git a/client/v2/indexer/lookupAccountTransactions.go b/client/v2/indexer/lookupAccountTransactions.go index e687f728..da87f759 100644 --- a/client/v2/indexer/lookupAccountTransactions.go +++ b/client/v2/indexer/lookupAccountTransactions.go @@ -70,7 +70,8 @@ type LookupAccountTransactionsParams struct { TXID string `url:"txid,omitempty"` } -// LookupAccountTransactions lookup account transactions. +// LookupAccountTransactions lookup account transactions. Transactions are returned +// newest to oldest. type LookupAccountTransactions struct { c *Client diff --git a/client/v2/indexer/lookupAssetTransactions.go b/client/v2/indexer/lookupAssetTransactions.go index 82d27920..9cb2127b 100644 --- a/client/v2/indexer/lookupAssetTransactions.go +++ b/client/v2/indexer/lookupAssetTransactions.go @@ -80,7 +80,8 @@ type LookupAssetTransactionsParams struct { TXID string `url:"txid,omitempty"` } -// LookupAssetTransactions lookup transactions for an asset. +// LookupAssetTransactions lookup transactions for an asset. Transactions are +// returned oldest to newest. type LookupAssetTransactions struct { c *Client diff --git a/client/v2/indexer/searchForTransactions.go b/client/v2/indexer/searchForTransactions.go index c801bf7a..2a04ada4 100644 --- a/client/v2/indexer/searchForTransactions.go +++ b/client/v2/indexer/searchForTransactions.go @@ -85,7 +85,9 @@ type SearchForTransactionsParams struct { TXID string `url:"txid,omitempty"` } -// SearchForTransactions search for transactions. +// SearchForTransactions search for transactions. Transactions are returned oldest +// to newest unless the address parameter is used, in which case results are +// returned newest to oldest. type SearchForTransactions struct { c *Client From 2641f911590fc0d32fcd187be201378f7ef5babe Mon Sep 17 00:00:00 2001 From: algoidurovic <91566643+algoidurovic@users.noreply.github.com> Date: Wed, 11 May 2022 14:08:57 -0400 Subject: [PATCH 3/7] reformat field in spec --- client/v2/common/models/dryrun_txn_result.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/v2/common/models/dryrun_txn_result.go b/client/v2/common/models/dryrun_txn_result.go index 7921f607..f6c461c3 100644 --- a/client/v2/common/models/dryrun_txn_result.go +++ b/client/v2/common/models/dryrun_txn_result.go @@ -9,11 +9,11 @@ type DryrunTxnResult struct { // AppCallTrace AppCallTrace []DryrunState `json:"app-call-trace,omitempty"` - // Budgetcredit budget consumed during execution of app call transaction. - Budgetcredit uint64 `json:"budgetCredit,omitempty"` + // BudgetCredit budget consumed during execution of app call transaction. + BudgetCredit uint64 `json:"budget-credit,omitempty"` - // Budgetdebit budget added during execution of app call transaction. - Budgetdebit uint64 `json:"budgetDebit,omitempty"` + // BudgetDebit budget added during execution of app call transaction. + BudgetDebit uint64 `json:"budget-debit,omitempty"` // Disassembly disassembled program line by line. Disassembly []string `json:"disassembly"` From 5571eee24040413c35a1015c04a96eedb401df50 Mon Sep 17 00:00:00 2001 From: algoidurovic <91566643+algoidurovic@users.noreply.github.com> Date: Wed, 11 May 2022 14:12:45 -0400 Subject: [PATCH 4/7] remove unneeded api changes --- client/v2/algod/getProof.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/client/v2/algod/getProof.go b/client/v2/algod/getProof.go index 737bff32..e856702f 100644 --- a/client/v2/algod/getProof.go +++ b/client/v2/algod/getProof.go @@ -13,11 +13,6 @@ type GetProofParams struct { // Format configures whether the response object is JSON or MessagePack encoded. Format string `url:"format,omitempty"` - - // Hashtype the type of hash function used to create the proof, must be one of: - // * sha512_256 - // * sha256 - Hashtype string `url:"hashtype,omitempty"` } // GetProof get a Merkle proof for a transaction in a block. @@ -30,14 +25,6 @@ type GetProof struct { p GetProofParams } -// Hashtype the type of hash function used to create the proof, must be one of: -// * sha512_256 -// * sha256 -func (s *GetProof) Hashtype(Hashtype string) *GetProof { - s.p.Hashtype = Hashtype - return s -} - // Do performs the HTTP request func (s *GetProof) Do(ctx context.Context, headers ...*common.Header) (response models.ProofResponse, err error) { err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%v/transactions/%v/proof", s.round, s.txid), s.p, headers) From 7dc9f1dbb942b3b1f5374b9f737b603e4a5e8d0b Mon Sep 17 00:00:00 2001 From: algoidurovic <91566643+algoidurovic@users.noreply.github.com> Date: Mon, 16 May 2022 10:48:15 -0400 Subject: [PATCH 5/7] remove generate api code for disassembliy --- client/v2/algod/algod.go | 4 ---- client/v2/algod/tealDisassemble.go | 23 ----------------------- 2 files changed, 27 deletions(-) delete mode 100644 client/v2/algod/tealDisassemble.go diff --git a/client/v2/algod/algod.go b/client/v2/algod/algod.go index 854b0eba..0289ed41 100644 --- a/client/v2/algod/algod.go +++ b/client/v2/algod/algod.go @@ -124,10 +124,6 @@ func (c *Client) TealCompile(source []byte) *TealCompile { return &TealCompile{c: c, source: source} } -func (c *Client) TealDisassemble(source string) *TealDisassemble { - return &TealDisassemble{c: c, source: source} -} - func (c *Client) TealDryrun(request models.DryrunRequest) *TealDryrun { return &TealDryrun{c: c, request: request} } diff --git a/client/v2/algod/tealDisassemble.go b/client/v2/algod/tealDisassemble.go deleted file mode 100644 index 60689319..00000000 --- a/client/v2/algod/tealDisassemble.go +++ /dev/null @@ -1,23 +0,0 @@ -package algod - -import ( - "context" - - "github.com/algorand/go-algorand-sdk/client/v2/common" - "github.com/algorand/go-algorand-sdk/client/v2/common/models" -) - -// TealDisassemble given the base64 encoded program bytes, return the TEAL source -// code in plain text. This endpoint is only enabled when a node's configuration -// file sets EnableDeveloperAPI to true. -type TealDisassemble struct { - c *Client - - source string -} - -// Do performs the HTTP request -func (s *TealDisassemble) Do(ctx context.Context, headers ...*common.Header) (response models.DisassembleResponse, err error) { - err = s.c.get(ctx, &response, "/v2/teal/disassemble", nil, headers) - return -} From 206bd6ef8adea424d58a8044b7c6e5866f89bc5a Mon Sep 17 00:00:00 2001 From: algoidurovic <91566643+algoidurovic@users.noreply.github.com> Date: Wed, 25 May 2022 13:54:09 -0400 Subject: [PATCH 6/7] regenerate --- client/v2/algod/algod.go | 4 ++++ client/v2/algod/getProof.go | 13 +++++++++++ client/v2/algod/tealCompile.go | 17 +++++++++++++++ client/v2/algod/tealDisassemble.go | 23 ++++++++++++++++++++ client/v2/common/models/compile_response.go | 3 +++ client/v2/common/models/dryrun_txn_result.go | 12 ++++++---- 6 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 client/v2/algod/tealDisassemble.go diff --git a/client/v2/algod/algod.go b/client/v2/algod/algod.go index 0289ed41..a43bb93e 100644 --- a/client/v2/algod/algod.go +++ b/client/v2/algod/algod.go @@ -124,6 +124,10 @@ func (c *Client) TealCompile(source []byte) *TealCompile { return &TealCompile{c: c, source: source} } +func (c *Client) TealDisassemble(source []byte) *TealDisassemble { + return &TealDisassemble{c: c, source: source} +} + func (c *Client) TealDryrun(request models.DryrunRequest) *TealDryrun { return &TealDryrun{c: c, request: request} } diff --git a/client/v2/algod/getProof.go b/client/v2/algod/getProof.go index e856702f..737bff32 100644 --- a/client/v2/algod/getProof.go +++ b/client/v2/algod/getProof.go @@ -13,6 +13,11 @@ type GetProofParams struct { // Format configures whether the response object is JSON or MessagePack encoded. Format string `url:"format,omitempty"` + + // Hashtype the type of hash function used to create the proof, must be one of: + // * sha512_256 + // * sha256 + Hashtype string `url:"hashtype,omitempty"` } // GetProof get a Merkle proof for a transaction in a block. @@ -25,6 +30,14 @@ type GetProof struct { p GetProofParams } +// Hashtype the type of hash function used to create the proof, must be one of: +// * sha512_256 +// * sha256 +func (s *GetProof) Hashtype(Hashtype string) *GetProof { + s.p.Hashtype = Hashtype + return s +} + // Do performs the HTTP request func (s *GetProof) Do(ctx context.Context, headers ...*common.Header) (response models.ProofResponse, err error) { err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%v/transactions/%v/proof", s.round, s.txid), s.p, headers) diff --git a/client/v2/algod/tealCompile.go b/client/v2/algod/tealCompile.go index 055b0296..e3e07bed 100644 --- a/client/v2/algod/tealCompile.go +++ b/client/v2/algod/tealCompile.go @@ -7,6 +7,14 @@ import ( "github.com/algorand/go-algorand-sdk/client/v2/common/models" ) +// TealCompileParams contains all of the query parameters for url serialization. +type TealCompileParams struct { + + // Sourcemap when set to `true`, returns the source map of the program as a JSON. + // Defaults to `false`. + Sourcemap bool `url:"sourcemap,omitempty"` +} + // TealCompile given TEAL source code in plain text, return base64 encoded program // bytes and base32 SHA512_256 hash of program bytes (Address style). This endpoint // is only enabled when a node's configuration file sets EnableDeveloperAPI to @@ -15,6 +23,15 @@ type TealCompile struct { c *Client source []byte + + p TealCompileParams +} + +// Sourcemap when set to `true`, returns the source map of the program as a JSON. +// Defaults to `false`. +func (s *TealCompile) Sourcemap(Sourcemap bool) *TealCompile { + s.p.Sourcemap = Sourcemap + return s } // Do performs the HTTP request diff --git a/client/v2/algod/tealDisassemble.go b/client/v2/algod/tealDisassemble.go new file mode 100644 index 00000000..9efa7d75 --- /dev/null +++ b/client/v2/algod/tealDisassemble.go @@ -0,0 +1,23 @@ +package algod + +import ( + "context" + + "github.com/algorand/go-algorand-sdk/client/v2/common" + "github.com/algorand/go-algorand-sdk/client/v2/common/models" +) + +// TealDisassemble given the program bytes, return the TEAL source code in plain +// text. This endpoint is only enabled when a node's configuration file sets +// EnableDeveloperAPI to true. +type TealDisassemble struct { + c *Client + + source []byte +} + +// Do performs the HTTP request +func (s *TealDisassemble) Do(ctx context.Context, headers ...*common.Header) (response models.DisassembleResponse, err error) { + err = s.c.get(ctx, &response, "/v2/teal/disassemble", nil, headers) + return +} diff --git a/client/v2/common/models/compile_response.go b/client/v2/common/models/compile_response.go index fd476839..d461fdab 100644 --- a/client/v2/common/models/compile_response.go +++ b/client/v2/common/models/compile_response.go @@ -7,4 +7,7 @@ type CompileResponse struct { // Result base64 encoded program bytes Result string `json:"result"` + + // Sourcemap jSON of the source map + Sourcemap *map[string]interface{} `json:"sourcemap,omitempty"` } diff --git a/client/v2/common/models/dryrun_txn_result.go b/client/v2/common/models/dryrun_txn_result.go index f6c461c3..7537bbbd 100644 --- a/client/v2/common/models/dryrun_txn_result.go +++ b/client/v2/common/models/dryrun_txn_result.go @@ -9,11 +9,15 @@ type DryrunTxnResult struct { // AppCallTrace AppCallTrace []DryrunState `json:"app-call-trace,omitempty"` - // BudgetCredit budget consumed during execution of app call transaction. - BudgetCredit uint64 `json:"budget-credit,omitempty"` + // BudgetAdded budget added during execution of app call transaction. + BudgetAdded uint64 `json:"budget-added,omitempty"` - // BudgetDebit budget added during execution of app call transaction. - BudgetDebit uint64 `json:"budget-debit,omitempty"` + // BudgetConsumed budget consumed during execution of app call transaction. + BudgetConsumed uint64 `json:"budget-consumed,omitempty"` + + // Cost net cost of app execution. Field is DEPRECATED and is subject for removal. + // Instead, use `budget-added` and `budget-consumed. + Cost uint64 `json:"cost,omitempty"` // Disassembly disassembled program line by line. Disassembly []string `json:"disassembly"` From cffedd1ad939826eedbfb028d9586186b8ac19f5 Mon Sep 17 00:00:00 2001 From: algoidurovic <91566643+algoidurovic@users.noreply.github.com> Date: Wed, 25 May 2022 13:59:00 -0400 Subject: [PATCH 7/7] remove state proof code --- client/v2/algod/getProof.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/client/v2/algod/getProof.go b/client/v2/algod/getProof.go index 737bff32..e856702f 100644 --- a/client/v2/algod/getProof.go +++ b/client/v2/algod/getProof.go @@ -13,11 +13,6 @@ type GetProofParams struct { // Format configures whether the response object is JSON or MessagePack encoded. Format string `url:"format,omitempty"` - - // Hashtype the type of hash function used to create the proof, must be one of: - // * sha512_256 - // * sha256 - Hashtype string `url:"hashtype,omitempty"` } // GetProof get a Merkle proof for a transaction in a block. @@ -30,14 +25,6 @@ type GetProof struct { p GetProofParams } -// Hashtype the type of hash function used to create the proof, must be one of: -// * sha512_256 -// * sha256 -func (s *GetProof) Hashtype(Hashtype string) *GetProof { - s.p.Hashtype = Hashtype - return s -} - // Do performs the HTTP request func (s *GetProof) Do(ctx context.Context, headers ...*common.Header) (response models.ProofResponse, err error) { err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%v/transactions/%v/proof", s.round, s.txid), s.p, headers)