Skip to content

Commit

Permalink
add client methods
Browse files Browse the repository at this point in the history
  • Loading branch information
chris124567 committed Oct 31, 2024
1 parent 5fb0e69 commit 5d24a56
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 20 additions & 1 deletion api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (c *Client) Contract(id types.FileContractID) (resp explorer.FileContract,
return
}

// Contracts returns the transactions with the specified IDs.
// Contracts returns the contracts with the specified IDs.
func (c *Client) Contracts(ids []types.FileContractID) (resp []explorer.FileContract, err error) {
err = c.c.POST("/contracts", ids, &resp)
return
Expand All @@ -210,6 +210,25 @@ func (c *Client) ContractRevisions(id types.FileContractID) (resp []explorer.Fil
return
}

// V2Contracts returns the v2 contracts with the specified IDs.
func (c *Client) V2Contracts(ids []types.FileContractID) (resp []explorer.V2FileContract, err error) {
err = c.c.POST("/v2/contracts", ids, &resp)
return
}

// V2ContractsKey returns the v2 contracts for a particular ed25519 key.
func (c *Client) V2ContractsKey(key types.PublicKey) (resp []explorer.V2FileContract, err error) {
err = c.c.GET(fmt.Sprintf("/pubkey/%s/v2/contracts", key), &resp)
return
}

// V2ContractRevisions returns all the revisions of the contract with the
// specified ID.
func (c *Client) V2ContractRevisions(id types.FileContractID) (resp []explorer.V2FileContract, err error) {
err = c.c.GET(fmt.Sprintf("/v2/contracts/%s/revisions", id), &resp)
return
}

// Host returns information about the host with a given ed25519 key.
func (c *Client) Host(key types.PublicKey) (resp explorer.Host, err error) {
err = c.c.GET(fmt.Sprintf("/pubkey/%s/host", key), &resp)
Expand Down
6 changes: 3 additions & 3 deletions explorer/explorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,17 @@ func (e *Explorer) ContractRevisions(id types.FileContractID) (result []FileCont
return e.s.ContractRevisions(id)
}

// V2Contracts returns the contracts with the specified IDs.
// V2Contracts returns the v2 contracts with the specified IDs.
func (e *Explorer) V2Contracts(ids []types.FileContractID) (result []V2FileContract, err error) {
return e.s.V2Contracts(ids)
}

// V2ContractsKey returns the contracts for a particular ed25519 key.
// V2ContractsKey returns the v2 contracts for a particular ed25519 key.
func (e *Explorer) V2ContractsKey(key types.PublicKey) (result []V2FileContract, err error) {
return e.s.V2ContractsKey(key)
}

// V2ContractRevisions returns all the revisions of the contract with the
// V2ContractRevisions returns all the revisions of the v2 contract with the
// specified ID.
func (e *Explorer) V2ContractRevisions(id types.FileContractID) (result []V2FileContract, err error) {
return e.s.V2ContractRevisions(id)
Expand Down

0 comments on commit 5d24a56

Please sign in to comment.