From 1b5b16fa3f72b452602fad78aaf6a3e815744c1a Mon Sep 17 00:00:00 2001 From: Christopher Tarry Date: Wed, 5 Jun 2024 21:00:19 -0400 Subject: [PATCH] change API routes --- api/client.go | 8 ++++---- api/server.go | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/client.go b/api/client.go index 08bf9e2c..dccc16c1 100644 --- a/api/client.go +++ b/api/client.go @@ -88,19 +88,19 @@ func (c *Client) Transactions(ids []types.TransactionID) (resp []explorer.Transa // AddressUTXOs returns the specified address' unspent outputs. func (c *Client) AddressUTXOs(address types.Address, offset, limit uint64) (resp AddressUTXOsResponse, err error) { - err = c.c.GET(fmt.Sprintf("/explorer/addresses/utxos/%s?offset=%d&limit=%d", address, offset, limit), &resp) + err = c.c.GET(fmt.Sprintf("/explorer/addresses/%s/utxos?offset=%d&limit=%d", address, offset, limit), &resp) return } // AddressEvents returns the specified address' events. func (c *Client) AddressEvents(address types.Address, offset, limit uint64) (resp []explorer.Event, err error) { - err = c.c.GET(fmt.Sprintf("/explorer/addresses/events/%s?offset=%d&limit=%d", address, offset, limit), &resp) + err = c.c.GET(fmt.Sprintf("/explorer/addresses/%s/events?offset=%d&limit=%d", address, offset, limit), &resp) return } // AddressBalance returns the specified address' balance. func (c *Client) AddressBalance(address types.Address) (resp AddressBalanceResponse, err error) { - err = c.c.GET(fmt.Sprintf("/explorer/addresses/balance/%s", address), &resp) + err = c.c.GET(fmt.Sprintf("/explorer/addresses/%s/balance", address), &resp) return } @@ -118,7 +118,7 @@ func (c *Client) Contracts(ids []types.FileContractID) (resp []explorer.FileCont // ContractsKey returns the contracts for a particular ed25519 key. func (c *Client) ContractsKey(key types.PublicKey) (resp []explorer.FileContract, err error) { - err = c.c.GET(fmt.Sprintf("/explorer/contracts/key/%s", key), &resp) + err = c.c.GET(fmt.Sprintf("/explorer/pubkey/%s/contracts", key), &resp) return } diff --git a/api/server.go b/api/server.go index 9fdc7c0d..6b92cb51 100644 --- a/api/server.go +++ b/api/server.go @@ -361,11 +361,11 @@ func NewServer(e Explorer, cm ChainManager, s Syncer) http.Handler { "GET /explorer/metrics/:id": srv.explorerMetricsIDHandler, "GET /explorer/transactions/:id": srv.explorerTransactionsIDHandler, "POST /explorer/transactions": srv.explorerTransactionsHandler, - "GET /explorer/addresses/utxos/:address": srv.explorerAddressessAddressUtxosHandler, - "GET /explorer/addresses/events/:address": srv.explorerAddressessAddressEventsHandler, - "GET /explorer/addresses/balance/:address": srv.explorerAddressessAddressBalanceHandler, - "GET /explorer/contracts/id/:id": srv.explorerContractIDHandler, - "GET /explorer/contracts/key/:key": srv.explorerContractKeyHandler, + "GET /explorer/addresses/:address/utxos": srv.explorerAddressessAddressUtxosHandler, + "GET /explorer/addresses/:address/events": srv.explorerAddressessAddressEventsHandler, + "GET /explorer/addresses/:address/balance": srv.explorerAddressessAddressBalanceHandler, + "GET /explorer/contracts/:id": srv.explorerContractIDHandler, + "GET /explorer/pubkey/:key/contracts": srv.explorerContractKeyHandler, "POST /explorer/contracts": srv.explorerContractsHandler, }) }