-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7680 from epociask/indexer.api.supply_view
feat(indexer) API Observability for Bridge Supplies
- Loading branch information
Showing
9 changed files
with
125 additions
and
5 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
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
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
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
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,35 @@ | ||
package routes | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/ethereum-optimism/optimism/indexer/api/models" | ||
) | ||
|
||
// SupplyView ... Handles /api/v0/supply GET requests | ||
func (h Routes) SupplyView(w http.ResponseWriter, r *http.Request) { | ||
|
||
depositSum, err := h.view.L1BridgeDepositSum() | ||
if err != nil { | ||
http.Error(w, "internal server error reading deposits", http.StatusInternalServerError) | ||
h.logger.Error("unable to read deposits from DB", "err", err.Error()) | ||
return | ||
} | ||
|
||
withdrawalSum, err := h.view.L2BridgeWithdrawalSum() | ||
if err != nil { | ||
http.Error(w, "internal server error reading withdrawals", http.StatusInternalServerError) | ||
h.logger.Error("unable to read withdrawals from DB", "err", err.Error()) | ||
return | ||
} | ||
|
||
view := models.BridgeSupplyView{ | ||
L1DepositSum: depositSum, | ||
L2WithdrawalSum: withdrawalSum, | ||
} | ||
|
||
err = jsonResponse(w, view, http.StatusOK) | ||
if err != nil { | ||
h.logger.Error("error writing response", "err", 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
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
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
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