github.com/algorand/go-algorand-sdk@v1.24.0/client/v2/algod/algod.go (about) 1 package algod 2 3 import ( 4 "context" 5 6 "github.com/algorand/go-algorand-sdk/client/v2/common" 7 "github.com/algorand/go-algorand-sdk/client/v2/common/models" 8 ) 9 10 const authHeader = "X-Algo-API-Token" 11 12 type Client common.Client 13 14 // get performs a GET request to the specific path against the server, assumes JSON response 15 func (c *Client) get(ctx context.Context, response interface{}, path string, body interface{}, headers []*common.Header) error { 16 return (*common.Client)(c).Get(ctx, response, path, body, headers) 17 } 18 19 // getMsgpack performs a GET request to the specific path against the server, assumes msgpack response 20 func (c *Client) getMsgpack(ctx context.Context, response interface{}, path string, body interface{}, headers []*common.Header) error { 21 return (*common.Client)(c).GetRawMsgpack(ctx, response, path, body, headers) 22 } 23 24 // getMsgpack performs a GET request to the specific path against the server, assumes msgpack response 25 func (c *Client) getRaw(ctx context.Context, path string, body interface{}, headers []*common.Header) ([]byte, error) { 26 return (*common.Client)(c).GetRaw(ctx, path, body, headers) 27 } 28 29 // post sends a POST request to the given path with the given request object. 30 // No query parameters will be sent if request is nil. 31 // response must be a pointer to an object as post writes the response there. 32 func (c *Client) post(ctx context.Context, response interface{}, path string, params interface{}, headers []*common.Header, body interface{}) error { 33 return (*common.Client)(c).Post(ctx, response, path, params, headers, body) 34 } 35 36 // MakeClient is the factory for constructing a ClientV2 for a given endpoint. 37 func MakeClient(address string, apiToken string) (c *Client, err error) { 38 commonClient, err := common.MakeClient(address, authHeader, apiToken) 39 c = (*Client)(commonClient) 40 return 41 } 42 43 // MakeClientWithHeaders is the factory for constructing a ClientV2 for a 44 // given endpoint with custom headers. 45 func MakeClientWithHeaders(address string, apiToken string, headers []*common.Header) (c *Client, err error) { 46 commonClientWithHeaders, err := common.MakeClientWithHeaders(address, authHeader, apiToken, headers) 47 c = (*Client)(commonClientWithHeaders) 48 return 49 } 50 51 func (c *Client) HealthCheck() *HealthCheck { 52 return &HealthCheck{c: c} 53 } 54 55 func (c *Client) GetGenesis() *GetGenesis { 56 return &GetGenesis{c: c} 57 } 58 59 func (c *Client) Versions() *Versions { 60 return &Versions{c: c} 61 } 62 63 func (c *Client) AccountInformation(address string) *AccountInformation { 64 return &AccountInformation{c: c, address: address} 65 } 66 67 func (c *Client) AccountAssetInformation(address string, assetId uint64) *AccountAssetInformation { 68 return &AccountAssetInformation{c: c, address: address, assetId: assetId} 69 } 70 71 func (c *Client) AccountApplicationInformation(address string, applicationId uint64) *AccountApplicationInformation { 72 return &AccountApplicationInformation{c: c, address: address, applicationId: applicationId} 73 } 74 75 func (c *Client) PendingTransactionsByAddress(address string) *PendingTransactionsByAddress { 76 return &PendingTransactionsByAddress{c: c, address: address} 77 } 78 79 func (c *Client) Block(round uint64) *Block { 80 return &Block{c: c, round: round} 81 } 82 83 func (c *Client) GetBlockHash(round uint64) *GetBlockHash { 84 return &GetBlockHash{c: c, round: round} 85 } 86 87 func (c *Client) GetTransactionProof(round uint64, txid string) *GetTransactionProof { 88 return &GetTransactionProof{c: c, round: round, txid: txid} 89 } 90 91 func (c *Client) Supply() *Supply { 92 return &Supply{c: c} 93 } 94 95 func (c *Client) Status() *Status { 96 return &Status{c: c} 97 } 98 99 func (c *Client) StatusAfterBlock(round uint64) *StatusAfterBlock { 100 return &StatusAfterBlock{c: c, round: round} 101 } 102 103 func (c *Client) SendRawTransaction(rawtxn []byte) *SendRawTransaction { 104 return &SendRawTransaction{c: c, rawtxn: rawtxn} 105 } 106 107 func (c *Client) SuggestedParams() *SuggestedParams { 108 return &SuggestedParams{c: c} 109 } 110 111 func (c *Client) PendingTransactions() *PendingTransactions { 112 return &PendingTransactions{c: c} 113 } 114 115 func (c *Client) PendingTransactionInformation(txid string) *PendingTransactionInformation { 116 return &PendingTransactionInformation{c: c, txid: txid} 117 } 118 119 func (c *Client) GetStateProof(round uint64) *GetStateProof { 120 return &GetStateProof{c: c, round: round} 121 } 122 123 func (c *Client) GetLightBlockHeaderProof(round uint64) *GetLightBlockHeaderProof { 124 return &GetLightBlockHeaderProof{c: c, round: round} 125 } 126 127 func (c *Client) GetApplicationByID(applicationId uint64) *GetApplicationByID { 128 return &GetApplicationByID{c: c, applicationId: applicationId} 129 } 130 131 func (c *Client) GetApplicationBoxes(applicationId uint64) *GetApplicationBoxes { 132 return &GetApplicationBoxes{c: c, applicationId: applicationId} 133 } 134 135 func (c *Client) GetApplicationBoxByName(applicationId uint64, name []byte) *GetApplicationBoxByName { 136 return (&GetApplicationBoxByName{c: c, applicationId: applicationId}).name(name) 137 } 138 139 func (c *Client) GetAssetByID(assetId uint64) *GetAssetByID { 140 return &GetAssetByID{c: c, assetId: assetId} 141 } 142 143 func (c *Client) TealCompile(source []byte) *TealCompile { 144 return &TealCompile{c: c, source: source} 145 } 146 147 func (c *Client) TealDisassemble(source []byte) *TealDisassemble { 148 return &TealDisassemble{c: c, source: source} 149 } 150 151 func (c *Client) TealDryrun(request models.DryrunRequest) *TealDryrun { 152 return &TealDryrun{c: c, request: request} 153 } 154 155 func (c *Client) BlockRaw(round uint64) *BlockRaw { 156 return &BlockRaw{c: c, round: round} 157 }