-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7944a78
commit f46cfbc
Showing
19 changed files
with
1,136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/maestro-org/go-sdk/models" | ||
"github.com/maestro-org/go-sdk/utils" | ||
) | ||
|
||
func (c *Client) AccountsHoldingAsset(assetId string, params *utils.Parameters) (*models.AccountsHoldingAsset, error) { | ||
formattedParams := "" | ||
if params != nil { | ||
formattedParams = params.Format() | ||
} | ||
url := fmt.Sprintf("/assets/%s/accounts%s", assetId, formattedParams) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var accountsHoldingAsset models.AccountsHoldingAsset | ||
err = json.NewDecoder(resp.Body).Decode(&accountsHoldingAsset) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &accountsHoldingAsset, nil | ||
} | ||
|
||
func (c *Client) AddressHoldingAsset(assetId string, params *utils.Parameters) (*models.AddressesHoldingAsset, error) { | ||
formattedParams := "" | ||
if params != nil { | ||
formattedParams = params.Format() | ||
} | ||
url := fmt.Sprintf("/assets/%s/addresses%s", assetId, formattedParams) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var addressesHoldingAsset models.AddressesHoldingAsset | ||
err = json.NewDecoder(resp.Body).Decode(&addressesHoldingAsset) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &addressesHoldingAsset, nil | ||
} | ||
|
||
func (c *Client) Asset(assetId string) (*models.AssetInformations, error) { | ||
url := fmt.Sprintf("/assets/%s", assetId) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var assetInformation models.AssetInformations | ||
err = json.NewDecoder(resp.Body).Decode(&assetInformation) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &assetInformation, nil | ||
} | ||
|
||
func (c *Client) AssetTransactions(assetId string, params *utils.Parameters) (*models.AssetTransactions, error) { | ||
formattedParams := "" | ||
if params != nil { | ||
formattedParams = params.Format() | ||
} | ||
url := fmt.Sprintf("/assets/%s/txs%s", assetId, formattedParams) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var assetTransactions models.AssetTransactions | ||
err = json.NewDecoder(resp.Body).Decode(&assetTransactions) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &assetTransactions, nil | ||
} | ||
|
||
func (c *Client) AssetUpdates(assetId string, params *utils.Parameters) (*models.AssetUpdates, error) { | ||
formattedParams := "" | ||
if params != nil { | ||
formattedParams = params.Format() | ||
} | ||
url := fmt.Sprintf("/assets/%s/updates%s", assetId, formattedParams) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var assetUpdates models.AssetUpdates | ||
err = json.NewDecoder(resp.Body).Decode(&assetUpdates) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &assetUpdates, nil | ||
|
||
} | ||
|
||
func (c *Client) AssetUtxos(assetId string, params *utils.Parameters) (*models.AssetUtxos, error) { | ||
formattedParams := "" | ||
if params != nil { | ||
formattedParams = params.Format() | ||
} | ||
url := fmt.Sprintf("/assets/%s/utxos%s", assetId, formattedParams) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var assetUtxos models.AssetUtxos | ||
err = json.NewDecoder(resp.Body).Decode(&assetUtxos) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &assetUtxos, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/maestro-org/go-sdk/models" | ||
"github.com/maestro-org/go-sdk/utils" | ||
) | ||
|
||
func (c *Client) AccountsHoldingPolicy(policy string, params *utils.Parameters) (*models.AccountsHoldingPolicy, error) { | ||
formattedParams := "" | ||
if params != nil { | ||
formattedParams = params.Format() | ||
} | ||
url := fmt.Sprintf("/assets/policy/%s/accounts?%s", policy, formattedParams) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var response models.AccountsHoldingPolicy | ||
err = json.NewDecoder(resp.Body).Decode(&response) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &response, err | ||
} | ||
|
||
func (c *Client) AddressesHoldingPolicy(policy string, params *utils.Parameters) (*models.AddressesHoldingPolicy, error) { | ||
formattedParams := "" | ||
if params != nil { | ||
formattedParams = params.Format() | ||
} | ||
url := fmt.Sprintf("/assets/policy/%s/addresses?%s", policy, formattedParams) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var response models.AddressesHoldingPolicy | ||
err = json.NewDecoder(resp.Body).Decode(&response) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &response, err | ||
} | ||
|
||
func (c *Client) SpecificPolicyInformations(policy string, params *utils.Parameters) (*models.PolicyInformation, error) { | ||
formattedParams := "" | ||
if params != nil { | ||
formattedParams = params.Format() | ||
} | ||
url := fmt.Sprintf("/assets/policy/%s?%s", policy, formattedParams) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var response models.PolicyInformation | ||
err = json.NewDecoder(resp.Body).Decode(&response) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &response, err | ||
} | ||
|
||
func (c *Client) TransactionsMovingPolicy(policy string, params *utils.Parameters) (*models.PolicyTransactions, error) { | ||
formattedParams := "" | ||
if params != nil { | ||
formattedParams = params.Format() | ||
} | ||
url := fmt.Sprintf("/assets/policy/%s/txs?%s", policy, formattedParams) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var response models.PolicyTransactions | ||
err = json.NewDecoder(resp.Body).Decode(&response) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &response, err | ||
} | ||
|
||
func (c *Client) UtxosContainingPolicy(policy string, params *utils.Parameters) (*models.UtxosContainingPolicy, error) { | ||
formattedParams := "" | ||
if params != nil { | ||
formattedParams = params.Format() | ||
} | ||
url := fmt.Sprintf("/assets/policy/%s/utxos?%s", policy, formattedParams) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var response models.UtxosContainingPolicy | ||
err = json.NewDecoder(resp.Body).Decode(&response) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &response, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/maestro-org/go-sdk/models" | ||
) | ||
|
||
func (c *Client) DatumFromHash(hash string) (*models.DatumFromHash, error) { | ||
url := fmt.Sprintf("/data/%s", hash) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var datum models.DatumFromHash | ||
err = json.NewDecoder(resp.Body).Decode(&datum) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &datum, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/maestro-org/go-sdk/models" | ||
) | ||
|
||
func (c *Client) ResolveAdaHandle(handle string) (*models.BasicResponse, error) { | ||
url := fmt.Sprintf("/ecosystem/adahandle/%s", handle) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var adaHandle models.BasicResponse | ||
err = json.NewDecoder(resp.Body).Decode(&adaHandle) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &adaHandle, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/maestro-org/go-sdk/models" | ||
) | ||
|
||
func (c *Client) CurrentEpoch() (*models.EpochResp, error) { | ||
url := "/epochs/current" | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var currentEpoch models.EpochResp | ||
err = json.NewDecoder(resp.Body).Decode(¤tEpoch) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return ¤tEpoch, nil | ||
} | ||
|
||
func (c *Client) SpecificEpoch(epochNo int) (*models.EpochResp, error) { | ||
url := fmt.Sprintf("/epochs/%d/info", epochNo) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var specificEpoch models.EpochResp | ||
err = json.NewDecoder(resp.Body).Decode(&specificEpoch) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &specificEpoch, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/maestro-org/go-sdk/models" | ||
) | ||
|
||
func (c *Client) ChainTip() (*models.ChainTip, error) { | ||
url := "/chain-tip" | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var chainTip models.ChainTip | ||
err = json.NewDecoder(resp.Body).Decode(&chainTip) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &chainTip, nil | ||
} | ||
|
||
func (c *Client) EraHistory() (*models.EraHistory, error) { | ||
url := "/era-history" | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var eraHistory models.EraHistory | ||
err = json.NewDecoder(resp.Body).Decode(&eraHistory) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &eraHistory, nil | ||
} | ||
|
||
func (c *Client) ProtocolParameters() (*models.ProtocolParameters, error) { | ||
url := "/protocol-params" | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var protocolParameters models.ProtocolParameters | ||
err = json.NewDecoder(resp.Body).Decode(&protocolParameters) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &protocolParameters, nil | ||
} | ||
|
||
func (c *Client) BlockChainStartTime() (models.BasicResponse, error) { | ||
url := "/system-start" | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return models.BasicResponse{}, err | ||
} | ||
defer resp.Body.Close() | ||
var blockchainStartTime models.BasicResponse | ||
err = json.NewDecoder(resp.Body).Decode(&blockchainStartTime) | ||
if err != nil { | ||
return models.BasicResponse{}, err | ||
} | ||
return blockchainStartTime, nil | ||
} |
Oops, something went wrong.