add documentation for contract_info_query
@@ -5,11 +5,14 @@ import (
"time"
)
+// ContractInfoQuery retrieves information about a smart contract instance. This includes the account that it uses, the
+// file containing its bytecode, and the time when it will expire.
type ContractInfoQuery struct {
QueryBuilder
pb *proto.ContractGetInfoQuery
}
+// ContractInfo is the information about the contract instance returned by a ContractInfoQuery
type ContractInfo struct {
AccountID AccountID
ContractID ContractID
@@ -21,6 +24,8 @@ type ContractInfo struct {
ContractMemo string
}
+// NewContractInfoQuery creates a ContractInfoQuery builder which can be used to construct and execute a
+// Contract Get Info Query.
func NewContractInfoQuery() *ContractInfoQuery {
pb := &proto.ContractGetInfoQuery{Header: &proto.QueryHeader{}}
@@ -30,11 +35,13 @@ func NewContractInfoQuery() *ContractInfoQuery {
return &ContractInfoQuery{inner, pb}
}
+// SetContractID sets the contract for which information is requested
func (builder *ContractInfoQuery) SetContractID(id ContractID) *ContractInfoQuery {
builder.pb.ContractID = id.toProto()
return builder
}
+// Execute executes the ContractInfoQuery using the provided client
func (builder *ContractInfoQuery) Execute(client *Client) (ContractInfo, error) {
resp, err := builder.execute(client)
if err != nil {
@@ -58,10 +65,10 @@ func (builder *ContractInfoQuery) Execute(client *Client) (ContractInfo, error)
}, nil
}
+// Cost is a wrapper around the standard Cost function for a query. It must exist because deleted files return a
+// COST_ANSWER of zero which triggers an INSUFFICIENT_TX_FEE response Status if set as the query payment. However,
+// 25 tinybar seems to be enough to get FILE_DELETED back instead, so that is used instead.
func (builder *ContractInfoQuery) Cost(client *Client) (Hbar, error) {
- // deleted files return a COST_ANSWER of zero which triggers `INSUFFICIENT_TX_FEE`
- // if you set that as the query payment; 25 tinybar seems to be enough to get
- // `FILE_DELETED` back instead.
cost, err := builder.QueryBuilder.GetCost(client)
if err != nil {
return ZeroHbar, err
