Skip to content

Commit

Permalink
generate api client code
Browse files Browse the repository at this point in the history
  • Loading branch information
algoidurovic committed May 11, 2022
1 parent 6b6dfc0 commit d1828ae
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 53 deletions.
4 changes: 4 additions & 0 deletions client/v2/algod/algod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
13 changes: 13 additions & 0 deletions client/v2/algod/getProof.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion client/v2/algod/tealCompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions client/v2/algod/tealDisassemble.go
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion client/v2/algod/tealDryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions client/v2/common/models/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand Down
9 changes: 0 additions & 9 deletions client/v2/common/models/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
10 changes: 0 additions & 10 deletions client/v2/common/models/application_local_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
2 changes: 1 addition & 1 deletion client/v2/common/models/application_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
9 changes: 0 additions & 9 deletions client/v2/common/models/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
9 changes: 0 additions & 9 deletions client/v2/common/models/asset_holding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
7 changes: 7 additions & 0 deletions client/v2/common/models/disassemble_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package models

// DisassembleResponse teal disassembly Result
type DisassembleResponse struct {
// Result disassembled Teal code
Result string `json:"result"`
}
7 changes: 5 additions & 2 deletions client/v2/common/models/dryrun_txn_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion client/v2/common/models/error_response.go
Original file line number Diff line number Diff line change
@@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion client/v2/common/models/proof_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d1828ae

Please sign in to comment.